Skip to content

Conversation

@findepi
Copy link

@findepi findepi commented Dec 31, 2021

Let the SerialPort implement AutoCloseable. This requires bumping
minimal required Java version to 7.

Let the `SerialPort` implement `AutoCloseable`. This requires bumping
minimal required Java version to 7.
@findepi
Copy link
Author

findepi commented Dec 31, 2021

This requires bumping
minimal required Java version to 7.

of course, i've no idea whether this is an OK change for the project.

@hedgecrw
Copy link
Contributor

Thanks for the PR. This is a great idea; however, it's not feasible at the moment as we need to maintain Java 6 compatibility. As soon as global Java 6 usage decreases down to less than 1% (looks like it's currently at around 6%), we can consider bumping the version and adding this. I will leave this PR open until that time.

@hedgecrw
Copy link
Contributor

The next major release (3.X.X series) will drop support for Java 6. Support for try-with-resources will be added at that time.

@tugalsan
Copy link

tugalsan commented Apr 3, 2023

I watched some Venkat Subramaniam videos.

He says rather than using try-with-resources, it is better to use a function with lamda in it. like: ClassName.use(something-> ...)

Beause many forget to use try as there is no compile time check for autoclosable.

@tugalsan
Copy link

tugalsan commented Apr 7, 2023

I wrote an exmaple here to show u the 'use' case

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