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

Fix redefinition failure on openj9 #5009

Merged
merged 4 commits into from
Jan 6, 2022

Conversation

laurit
Copy link
Contributor

@laurit laurit commented Jan 4, 2022

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.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

great find!

…whether it has any of the virutal field marker interfaces
@laurit laurit requested a review from a team as a code owner January 5, 2022 11:02
/** Helper class for detecting whether given class has virtual fields. */
public final class VirtualFieldDetector {

private static final Cache<Class<?>, Boolean> classesWithVirtualFields = Cache.weak();
Copy link
Member

Choose a reason for hiding this comment

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

ClassValue?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

makes sense, thx!

@trask trask merged commit c45b4ea into open-telemetry:main Jan 6, 2022
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* 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
@laurit laurit deleted the redefinition-fail branch July 6, 2023 17:46
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.

Sporadic openj9 test failure
4 participants