Compiler error connected to metaclasses on java 11 from Oxygene compiled .jar

As subject states.

An exception has occurred in the compiler (11.0.9.1). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NullPointerException
at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.setParameters(ClassReader.java:2562)
at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:2460)
at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:2736)
at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassBuffer(ClassReader.java:2808)
at jdk.compiler/com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:2821)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.fillIn(ClassFinder.java:359)
at jdk.compiler/com.sun.tools.javac.code.ClassFinder.complete(ClassFinder.java:291)
at jdk.compiler/com.sun.tools.javac.code.Symbol.complete(Symbol.java:642)
at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:1326)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.complete(Type.java:1140)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.getTypeArguments(Type.java:1066)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.allparams(Type.java:1088)
at jdk.compiler/com.sun.tools.javac.code.Type$ClassType.isRaw(Type.java:1126)
at jdk.compiler/com.sun.tools.javac.code.Types.isSubtypeUncheckedInternal(Types.java:1026)
at jdk.compiler/com.sun.tools.javac.code.Types.isSubtypeUnchecked(Types.java:1008)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodCheckContext.compatible(Resolve.java:1020)
at jdk.compiler/com.sun.tools.javac.comp.Check.checkType(Check.java:563)
at jdk.compiler/com.sun.tools.javac.comp.Attr$ResultInfo.check(Attr.java:518)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1067)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:887)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:775)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:896)
at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:618)
at jdk.compiler/com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1563)
at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1733)
at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1802)
at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1776)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$10.doLookup(Resolve.java:2654)
at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3293)
at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3543)
at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2651)
at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2645)
at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3721)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3601)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2114)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:695)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1174)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:956)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4683)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4574)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4448)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

To replicate the issue i made a simple case:

type
TestObject = public class
private
protected
public
function test ( testObjectClass : T_TestObject) : TestObject ; overload ;
function test ( i : Integer ) : TestObject ; overload ;
end;

T_TestObject = class of TestObject ;

implementation

function TestObject.test(testObjectClass: T_TestObject): TestObject;
begin
Result := nil ;
end;

function TestObject.test(i: Integer): TestObject;
begin
Result := nil ;
end;

end.

And then i java code which uses the .jar produced

TestObject test2 = new TestObject().test(0);

So even if we dont use this overload with metaclass deliberatly it still give the error.

Thanks, logged as bugs://85438

I take it this is on regular JDK, not Android?

Yes, regular Adopt JDK 11.0.9.101

1 Like

Hi.

Is Updating an option for you? It turns out this is actually a bug in the Java compiler:

http://mail.openjdk.java.net/pipermail/compiler-dev/2018-August/012338.html

I tried emitting “static” too, but it makes little difference. Is updating the compiler an option for you (note: running on 11 is fine, it’s purely compiling)

so id have to update to jdk 12 i guess?

If it’s a problem to update, I can keep investigating, the real problem is finding a pattern where the java compiler hits this pattern. It is fixed in 12 yes ,according to the bugreport.

Well most users i guess use 11 and we provide sample code to them to compile it themselves.
We’ve already made remark that they should use jdk 12 to compile them.

If things turn out to be a big issue to your customers let me know. For now I’ll close the issue.

bugs://85438 got closed with status nochangereq.