Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle UnsupportedClassVersionError in ServiceLoader on jdk9 #7090

Merged

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Nov 7, 2022

Hopefully resolves the issue described in #7084

@laurit laurit requested a review from a team as a code owner November 7, 2022 16:36

@Override
public boolean hasNext() {
// jdk9 and newer throw UnsupportedClassVersionError in hasNext()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh interesting, so we would have run into this problem on Java 11 if we introduced Java 17-only instrumentation

do you know if the underlying iterator will move on item hasNext when it throws exception, so that we will continue iterating over it from that point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it manually and believe that hasNext will move to the next element on exception. Relevant code is in
https://github.com/openjdk/jdk11u/blob/b928a88fd564fab88f00086a62c0695ed5cc9353/src/java.base/share/classes/java/util/ServiceLoader.java#L1181 pending iterator is advanced before Class.forName

@trask trask merged commit 0c53d1a into open-telemetry:main Nov 8, 2022
@laurit laurit deleted the unsupported-class-version-handling branch July 6, 2023 17:47
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.

None yet

3 participants