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

Update ExpressionCompiler to run on JDK17+ without 'add-opens' JVM opt using Javassist ClassPool.toClass overload that takes a neighbour class #214

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

petergeneric
Copy link
Contributor

@petergeneric petergeneric commented Jul 19, 2023

Addresses #160 by pointing Javassist at a neighbour (a class in the same package) class of the class we're generating, allowing it to avoid using the deprecated ClassLoader.defineClass (which now requires 'add-opens' to use because Javassist must use reflection to make the method visible), and instead use MethodHandles.

This implementation introduces a protected method instantiateClass that can be overridden by ExpressionCompiler subclassers who are customising the exact mechanics of the class instantiation process if needed.

…method to instantiate a CtClass to a Class. The newly introduced method invokes ClassPool.toClass(CtClass, Class neighbour). The introduction of this method allows subclassers of ExpressionCompiler to customise the exact mechanics of the class instantiation process if needed.
@lukaszlenart
Copy link
Collaborator

After merging this change a lot of tests fail - it works good on JDK17. I'm going to revert this PR and introduce this change once OGNL will switch to JDK17

@lukaszlenart
Copy link
Collaborator

You can always use OgnlRuntime.setCompiler() to provide your own version with proper implementation of instantiateClass() method.

lukaszlenart added a commit that referenced this pull request Jul 24, 2023
Partially reverts #214 to keep compatibility with JDK8
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.

2 participants