Skip to content

Replace runnable wrappers by lambda expressions/method references#1380

Open
ViToni wants to merge 2 commits intozsmartsystems:masterfrom
ViToni:feature/replace_runnable_wrapper_by_method_references
Open

Replace runnable wrappers by lambda expressions/method references#1380
ViToni wants to merge 2 commits intozsmartsystems:masterfrom
ViToni:feature/replace_runnable_wrapper_by_method_references

Conversation

@ViToni
Copy link
Contributor

@ViToni ViToni commented Mar 23, 2023

By switching to Java8 (#408) Runnable wrappers can be replaced be Lambda expression or even method references as done in this PR.

@CLAassistant
Copy link

CLAassistant commented Mar 23, 2023

CLA assistant check
All committers have signed the CLA.

@ViToni
Copy link
Contributor Author

ViToni commented Mar 23, 2023

TODO:

  • com.zsmartsystems.zigbee.console.main.ZigBeeConsole.TransactionQueuesCommand.process(ZigBeeApi, String[], PrintStream) is using an empty Runnable to start a Thread. Wondering if this is just a CnP error or if it has more to it.

@ViToni ViToni force-pushed the feature/replace_runnable_wrapper_by_method_references branch from acf69e2 to ce3dc37 Compare March 23, 2023 12:45
@ViToni
Copy link
Contributor Author

ViToni commented Apr 11, 2023

@cdjackson Would you mind taking a look at this one?

@cdjackson
Copy link
Member

@ViToni my concern here is that on some Android versions I understand that lambda expressions are not available, so we have for that reason avoided them. Now that concern is possibly no longer an issue - I'm not sure, but I'm just a bit wary to make this change and find it breaks compatibility.

@ViToni
Copy link
Contributor Author

ViToni commented Apr 19, 2023

@cdjackson Thanks for the feedback. Didn't know about restrictions regarding Android / Lambda expressions (but I have to admit I'm not deep into Android regarding development).
But indeed I remember that some early versions of Java 8 had some issues regarding Lambda expressions but AFAIK these have been fixed for some time now.

Regarding the first Android version supporting Java 8, from what I found, it seems to be Android Nougat from August 2016 or respective Android Studio 3.0.0 from October 2017. The final release of Nougat was October 2019.
The Java 8 support page mentions only serialization of Lambdas not being supported, not sure if serialization has been used anywhere in project on Runnables.

Don't know if this information helps on the decision though...

@cdjackson
Copy link
Member

I found that animal sniffer throws an error with your recent addition of a lambda in the queue management PR, so i guess that answers the compatibility question ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants