Update ExpressionCompiler to run on JDK17+ without 'add-opens' JVM opt using Javassist ClassPool.toClass overload that takes a neighbour class by petergeneric · Pull Request #214 · orphan-oss/ognl (original) (raw)

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.