-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Meta Lambda failures - make the code more resilient to class loader challenges #3095
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
Conversation
src/test/groovy/graphql/schema/PropertyDataFetcherClassLoadingTest.groovy
Show resolved
Hide resolved
| * Proprs to https://www.baeldung.com/java-string-compile-execute-code where | ||
| * most of this code came from. | ||
| */ | ||
| public class DynamicJavacSupport { |
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.
I added this to allow is to generate classes in the tests - that are in seperate and diverse class loaders.
Neato!
|
I applied this PR to the master branch, built it and used it inside a Felix container and it works. |
| static class BrokenClass { | ||
| static { | ||
| // this should prevent it from existing | ||
| throw new RuntimeException("No soup for you!") |
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.
lol
The JVM has an interesting runtime.
It turns out that in certain cases is possible to use reflection to invoke a certain class method, even if the class loaders of the two bits of code are not visible to each other. However its not possible to create a meta lambda call across class loaders
This has been improved in Java 9 - however are we likely to delay the Java 11 upgrade in graphql-java so this PR does not use the new mechanism
Rather it makes the code more resilient in the face of class cast and linkage errors
This relates to #3095