Skip to content

Conversation

@bbakerman
Copy link
Member

@bbakerman bbakerman commented Feb 19, 2023

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

@bbakerman bbakerman changed the title MAJOR WIP - investigating Meta Lambda failures Meta Lambda failures - make the code more resilient to class loader challenges Feb 23, 2023
@bbakerman bbakerman added this to the 20.1 milestone Feb 23, 2023
* Proprs to https://www.baeldung.com/java-string-compile-execute-code where
* most of this code came from.
*/
public class DynamicJavacSupport {
Copy link
Member Author

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!

@schaefa
Copy link
Contributor

schaefa commented Feb 28, 2023

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!")
Copy link
Member

Choose a reason for hiding this comment

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

lol

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.

4 participants