From 59e7e433dc385dbd9f09c3f989d4169657623749 Mon Sep 17 00:00:00 2001 From: dkimitsa Date: Sat, 16 Jul 2022 17:27:55 +0300 Subject: [PATCH] * fix: support for classes compiled with Java18 (JDK-8272564) when Java18 used as compiler JDK-8272564 changes will be applied this will affect invocation of java.lang.Object methods on interface receivers. as per changes invokevirtual is replaced with invokeinterface and these methods has to be resolved as per https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-5.html#jvms-5.4.3.4 item 3 in RoboVM case this means that final methods of "java.lang.Object" has to be available for lookup, thus changes added to include [lookup] wrappers for final methods in this case otherwise it will fail during linking with message(s): > Undefined symbols for architecture arm64:"[j]java.lang.Object.notifyAll()V[lookup]" --- .../java/org/robovm/compiler/ClassCompiler.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/compiler/compiler/src/main/java/org/robovm/compiler/ClassCompiler.java b/compiler/compiler/src/main/java/org/robovm/compiler/ClassCompiler.java index 0745bc76a..6390ce34d 100755 --- a/compiler/compiler/src/main/java/org/robovm/compiler/ClassCompiler.java +++ b/compiler/compiler/src/main/java/org/robovm/compiler/ClassCompiler.java @@ -835,8 +835,17 @@ private void compile(Clazz clazz, OutputStream out) throws IOException { } // After this point no changes to methods/fields may be done by CompilerPlugins. - ci.initClassInfo(); - + ci.initClassInfo(); + + // when Java18 used as compiler JDK-8272564 changes will be applied this will affect invocation of + // java.lang.Object methods on interface receivers. + // as per changes invokevirtual is replaced with invokeinterface and these methods + // has to be resolved as per https://docs.oracle.com/javase/specs/jvms/se17/html/jvms-5.html#jvms-5.4.3.4 item 3 + // in RoboVM case this means that final methods of "java.lang.Object" has to be available for lookup, + // thus changes added to include [lookup] wrappers for final methods in this case + // otherwise it will fail during linking with message(s): + // Undefined symbols for architecture arm64:"[j]java.lang.Object.notifyAll()V[lookup]" + boolean isJavaLangObject = sootClass.getName().equals("java.lang.Object"); for (SootMethod method : sootClass.getMethods()) { for (CompilerPlugin compilerPlugin : config.getCompilerPlugins()) { @@ -870,7 +879,7 @@ private void compile(Clazz clazz, OutputStream out) throws IOException { } if (!name.equals("") && !name.equals("") && !method.isPrivate() && !method.isStatic() - && !Modifier.isFinal(method.getModifiers()) + && (isJavaLangObject || !Modifier.isFinal(method.getModifiers())) && !Modifier.isFinal(sootClass.getModifiers())) { createLookupFunction(method);