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

Fixed getDefinedPackage lookup for OpenJ9 (8) #9272

Merged
merged 2 commits into from
Aug 22, 2023

Conversation

JonasKunz
Copy link
Contributor

The InstrumentationModuleClassLoaderTest exposed a bug with the current implementation on OpenJ9 (Java 8):

2023-08-22T06:01:32.4244988Z     java.lang.ExceptionInInitializerError
2023-08-22T06:01:32.4245586Z         at java.lang.J9VMInternals.ensureError(J9VMInternals.java:158)
2023-08-22T06:01:32.4246371Z         at java.lang.J9VMInternals.recordInitializationFailure(J9VMInternals.java:147)
2023-08-22T06:01:32.4247576Z         at io.opentelemetry.javaagent.tooling.instrumentation.indy.InstrumentationModuleClassLoaderTest.checkClassLookupPrecedence(InstrumentationModuleClassLoaderTest.java:122)
2023-08-22T06:01:32.4248388Z 
2023-08-22T06:01:32.4249077Z         Caused by:
2023-08-22T06:01:32.4249942Z         java.lang.IllegalStateException: Method should be accessible from here
2023-08-22T06:01:32.4250867Z             at io.opentelemetry.javaagent.tooling.instrumentation.indy.InstrumentationModuleClassLoader.getFindPackageMethod(InstrumentationModuleClassLoader.java:252)
2023-08-22T06:01:32.4262113Z             at io.opentelemetry.javaagent.tooling.instrumentation.indy.InstrumentationModuleClassLoader.<clinit>(InstrumentationModuleClassLoader.java:50)
2023-08-22T06:01:32.4262964Z             ... 1 more
2023-08-22T06:01:32.4263150Z 
2023-08-22T06:01:32.4263276Z             Caused by:
2023-08-22T06:01:32.4264426Z             java.lang.IllegalAccessException: 'io.opentelemetry.javaagent.tooling.instrumentation.indy.InstrumentationModuleClassLoader' no access to: 'java.lang.ClassLoadergetDefinedPackage:(ClassLoader,String)Package/invokeSpecial'
2023-08-22T06:01:32.4265349Z                 at java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:440)
2023-08-22T06:01:32.4265928Z                 at java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:346)
2023-08-22T06:01:32.4266488Z                 at java.lang.invoke.MethodHandles$Lookup.findVirtual(MethodHandles.java:632)
2023-08-22T06:01:32.4267501Z                 at io.opentelemetry.javaagent.tooling.instrumentation.indy.InstrumentationModuleClassLoader.getFindPackageMethod(InstrumentationModuleClassLoader.java:242)
2023-08-22T06:01:32.4268196Z                 ... 2 more

It looks like in OpenJ9 Java 8 there is a getDefinedPackage method, which is however not accessible (it is either private or package private). I've adapted the logic to fallback to getPackage for this case aswell.

@JonasKunz JonasKunz requested a review from a team as a code owner August 22, 2023 07:51
@laurit laurit added the test openj9 This label can be applied to PRs to trigger them to run openj9 tests label Aug 22, 2023
@laurit
Copy link
Contributor

laurit commented Aug 22, 2023

closing and reopening

@laurit laurit closed this Aug 22, 2023
@laurit laurit reopened this Aug 22, 2023
@mateuszrzeszutek mateuszrzeszutek merged commit 3dbb965 into open-telemetry:main Aug 22, 2023
58 checks passed
@JonasKunz JonasKunz deleted the indy-cl-test-fix branch August 22, 2023 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test openj9 This label can be applied to PRs to trigger them to run openj9 tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants