JDK-8247246 : [JVMCI] `ResolvedJavaType.getDeclaredMethod()` can throw NoClassDefFoundError.
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 11,15
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-06-09
  • Updated: 2020-07-24
  • Resolved: 2020-06-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 15 JDK 16
11.0.10-oracleFixed 15 b29Fixed 16Fixed
Description
This happens when the `type` implements an interface with a default method whose return type is missing from the classpath:
```
interface MissingInterface {
}

class MissingInterfaceImpl implements MissingInterface {
}

interface SomeInterface {
    default MissingInterface someMethod() {
        return new MissingInterfaceImpl();
    }
}

class Wrapper {
    SomeInterface getSomeInterface() {
        return new SomeInterface() {
        };
    }
}
```
The use case for this is to call `ResolvedJavaType.getDeclaredMethod()` from GraalVM Native Image to check if an interface declares any default methods. When `getDeclaredMethod()` is invoked there is no reason to trigger linking of the class so no call to `link_class` should be necessary.

More over, HotSpot already stores a "has default method" flag for interfaces. It would be ideal if JVMCI can expose this.
Comments
Fix Request (OpenJDK 11u): Foivos Zakkak did an OpenJDK 11u backport of this. The patch didn't apply cleanly but the differences are minor. The patch got reviewed by Andrew Dinn and Severin Gehwolf. The risk is minimal since it only affects JVMCI code used by consumers such as Graal for which this patch is now mandatory. This backport is necessary in order to continue to be able to compile Graal VM CE with stock OpenJDK 11u. webrev: http://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8247246/01/webrev/ RFR: http://mail.openjdk.java.net/pipermail/jdk-updates-dev/2020-July/003417.html
03-07-2020

Changeset: 29936542 Author: Tom Rodriguez <never@openjdk.org> Date: 2020-06-24 10:42:26 +0000 URL: https://git.openjdk.java.net/amber/commit/29936542
02-07-2020

Changeset: 29936542 Author: Tom Rodriguez <never@openjdk.org> Date: 2020-06-24 10:42:26 +0000 URL: https://git.openjdk.java.net/mobile/commit/29936542
02-07-2020

URL: https://hg.openjdk.java.net/jdk/jdk15/rev/b58fc6058055 User: never Date: 2020-06-24 17:43:04 +0000
24-06-2020