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

Regression with JVM anonymous class


    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 10, 11
    • Fix Version/s: 11
    • Component/s: hotspot
    • Subcomponent:
    • Resolved In Build:


      Email from Maurizio:

      I'm writing to you as Alan Bateman suggested you did some refactorings in this area. I noted that the JDK 10/11 code is more strict when it comes to Unsafe.dAC - that is generally a good thing, but lately I've been bumping into an issue which seems to be more a 'bug' than a feature. Attached is a test case - I would expect the test to run w/o issue (the test is defining an anonymous class which implements an interface but does NOT override the interface method I::m). Typically this should run and then fail over with AbstractMethodError if I call I::m on the obtained instance.

      Instead, if I run this I get a cryptic message:

      Exception in thread "main" java.lang.reflect.InvocationTargetException
          at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:493)
          at TestUdAC.main(TestUdAC.java:61)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.base/java.lang.reflect.Method.invoke(Method.java:569)
          at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
      Caused by: java.lang.NoClassDefFoundError: TestUdAC$I$$impl
          at TestUdAC$I$$impl/0x00000007c00ac830.<init>(Unknown Source)
          ... 10 more
      Caused by: java.lang.ClassNotFoundException: TestUdAC$I$$impl
          at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
          at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
          ... 11 more

      Which seems to have more to do with class loading; however there's nothing wrong in the bytecode (apart from the obviously missing method implementation); it seems to me that some check that was added in jdk10/11 is going wild here, probably as a result of the covariant override in Struct::ptr.


          Issue Links



              • Assignee:
                hseigel Harold Seigel
                hseigel Harold Seigel
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: