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

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

    Details

    • Subcomponent:
    • Resolved In Build:
      b29

      Backports

        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.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  never Tom Rodriguez
                  Reporter:
                  cstancu Codrut Stancu
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: