Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8247246

[JVMCI] `ResolvedJavaType.getDeclaredMethod()` can throw NoClassDefFoundError.

XMLWordPrintable

    • b29

        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.

              never Tom Rodriguez
              cstancu Codrut Stancu
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: