Skip to content

Commit

Permalink
* fix: support for classes compiled with Java18 (JDK-8272564)
Browse files Browse the repository at this point in the history
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]"
  • Loading branch information
dkimitsa committed Jul 16, 2022
1 parent 01f6bd3 commit 59e7e43
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -870,7 +879,7 @@ private void compile(Clazz clazz, OutputStream out) throws IOException {
}
if (!name.equals("<clinit>") && !name.equals("<init>")
&& !method.isPrivate() && !method.isStatic()
&& !Modifier.isFinal(method.getModifiers())
&& (isJavaLangObject || !Modifier.isFinal(method.getModifiers()))
&& !Modifier.isFinal(sootClass.getModifiers())) {

createLookupFunction(method);
Expand Down

0 comments on commit 59e7e43

Please sign in to comment.