OpenHFT / Java-Runtime-Compiler

Java Runtime Compiler
Other
651 stars 145 forks source link

"java.lang.NoSuchFieldException: override" using loadFromJava (JDK 12, Mac) #42

Closed human-research closed 5 years ago

human-research commented 5 years ago

Hello. I'm using compiler v 2.3.4. Here is my code:

    public ILogicalExpression generateFunction(String funcName, String function, String arguments) throws Exception {
        String prepared = prepareExpression(function, arguments);

        String className = funcName + "Expression";

        String source = "import static java.lang.Math.*;\n" +
                "public final class " + className + " implements " + BASE_CLASS_NAME + " {\n"
                + "public boolean compute(double[] args) {\n"
                + "\treturn " + prepared + ";}\n}\n";

        Class aClass = CompilerUtils.CACHED_COMPILER.loadFromJava(className, source);
        ILogicalExpression expr = (ILogicalExpression) aClass.getConstructor().newInstance();

        return expr;
    }
Exception in thread "main" java.lang.AssertionError: java.lang.NoSuchFieldException: override
    at net.openhft.compiler.CompilerUtils.<clinit>(CompilerUtils.java:64)
    at com.synstorm.common.Utils.ConfigInterfaces.CodeGeneration.LogicalFunctionFactory.generateFunction(LogicalFunctionFactory.java:35)
Caused by: java.lang.NoSuchFieldException: override
    at java.base/java.lang.Class.getDeclaredField(Class.java:2417)
    at net.openhft.compiler.CompilerUtils.<clinit>(CompilerUtils.java:60)
    ... 14 more

java.lang.NoSuchFieldException: override occured when calling CompilerUtils.CACHED_COMPILER.loadFromJava.

Is it issue with my code or with compiler on Java 12?

dpisklov commented 5 years ago

we don't support Java 12 (not sure if we have such plans even...)