-
Notifications
You must be signed in to change notification settings - Fork 909
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
Fix redefinition failure on openj9 #5009
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great find!
...main/java/io/opentelemetry/javaagent/instrumentation/internal/reflection/RealInterfaces.java
Outdated
Show resolved
Hide resolved
...main/java/io/opentelemetry/javaagent/instrumentation/internal/reflection/RealInterfaces.java
Outdated
Show resolved
Hide resolved
...main/java/io/opentelemetry/javaagent/instrumentation/internal/reflection/RealInterfaces.java
Outdated
Show resolved
Hide resolved
…whether it has any of the virutal field marker interfaces
...ava/io/opentelemetry/javaagent/instrumentation/internal/reflection/VirtualFieldDetector.java
Outdated
Show resolved
Hide resolved
…entation is disabled
/** Helper class for detecting whether given class has virtual fields. */ | ||
public final class VirtualFieldDetector { | ||
|
||
private static final Cache<Class<?>, Boolean> classesWithVirtualFields = Cache.weak(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClassValue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As ClassValue is not mutable, it works best if you can compute the value on first use. Here we can't really compute the value, so the best we could do would be to use a mutable object as value of ClassValue, initialize it to false, and update it when the actual value is known. With current solution we can ignore the classes that don't have virtual fields, with ClassValue we would probably end up initializing a ClassValue for these too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, thx!
* Fix redefinition failure on openj9 * isntead of remembering the list of interfaces the class has remember whether it has any of the virutal field marker interfaces * address review comment * ensure virtual field detection works when internal-reflection instrumentation is disabled
Resolves #4848 The redefinition failure in the linked case isn't what made the test fail, but as it seems to be impossible to tell what the actual cause is it is best to close it.
After hiding our interfaces from
Class.getInterfaces
virtual field implementation isn't able to tell that class has been transformed and thus skips transforming it which breaks redefinition as new bytes don't have the same interfaces as the redefined class.Although this stack trace has been only observed on openj9 it could happen on hotspot too.