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

CTW: Class.getDeclaredMethods fails with assert(k->is_subclass_of(SystemDictionary::Throwable_klass())) failed: invalid exception class

XMLWordPrintable

    • b11

        $ cd test/hotspot/jtreg/testlibrary/ctw
        $ make
        $ cd dist
        $ wget https://repo1.maven.org/maven2/com/uralian/ignition_2.11/0.4.0/ignition_2.11-0.4.0.jar
        $ ./ctw.sh ignition_2.11-0.4.0.jar

        # Internal Error (/home/shade/trunks/jdk-jdk/src/hotspot/share/oops/method.cpp:807), pid=14848, tid=14851
        # assert(k->is_subclass_of(SystemDictionary::Throwable_klass())) failed: invalid exception class
        #
        # JRE version: OpenJDK Runtime Environment (15.0) (fastdebug build 15-internal+0-adhoc.shade.jdk-jdk)
        # Java VM: OpenJDK 64-Bit Server VM (fastdebug 15-internal+0-adhoc.shade.jdk-jdk, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
        # Problematic frame:
        # V [libjvm.so+0x1198081] Method::resolved_checked_exceptions_impl(Method*, Thread*)+0x741

        Current thread (0x00007fd414093800): JavaThread "main" [_thread_in_vm, id=13873, stack(0x00007fd41f10e000,0x00007fd41f20f000)]

        Stack: [0x00007fd41f10e000,0x00007fd41f20f000], sp=0x00007fd41f20c480, free space=1017k
        Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
        V [libjvm.so+0x1198081] Method::resolved_checked_exceptions_impl(Method*, Thread*)+0x741
        V [libjvm.so+0x1395c29] Reflection::new_method(methodHandle const&, bool, Thread*)+0x269
        V [libjvm.so+0xddbd8b] get_class_declared_methods_helper(JNIEnv_*, _jclass*, unsigned char, bool, Klass*, Thread*)+0x8db
        V [libjvm.so+0xddc1a7] JVM_GetClassDeclaredMethods+0xe7
        j java.lang.Class.getDeclaredMethods0(Z)[Ljava/lang/reflect/Method;+0 java.base@15-internal
        j java.lang.Class.privateGetDeclaredMethods(Z)[Ljava/lang/reflect/Method;+34 java.base@15-internal
        j java.lang.Class.getDeclaredMethods()[Ljava/lang/reflect/Method;+20 java.base@15-internal
        j sun.hotspot.tools.ctw.Compiler.compileClass(Ljava/lang/Class;JLjava/util/concurrent/Executor;)V+109

        ----------------------------

        After adding more information to assert:

        assert(k->is_subclass_of(SystemDictionary::Throwable_klass())) failed: invalid exception class: com/ignition/ExecutionException for method com.ignition.Step.output(Lcom/ignition/FlowRuntime;)Ljava/lang/Object;

        Bytecode disassembly shows com/ignition/ExecutionException is interface (!) and com/ignition/Step.class indeed tries to throw it:

        $ javap -c -v -p com/ignition/ExecutionException.class
          Compiled from "ExecutionException.scala"
        public interface com.ignition.ExecutionException
          minor version: 0
          major version: 51
          flags: (0x0601) ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT
          this_class: #2 // com/ignition/ExecutionException
          super_class: #4 // java/lang/Object
          interfaces: 0, fields: 0, methods: 0, attributes: 4

        $ javap -c -v -p com/ignition/Step.class
          Compiled from "entities.scala"
        public interface com.ignition.Step<T extends java.lang.Object, R extends com.ignition.FlowRuntime> extends com.ignition.XmlExport, com.ignition.JsonExport

          public abstract T output(int, R) throws com.ignition.ExecutionException;
            descriptor: (ILcom/ignition/FlowRuntime;)Ljava/lang/Object;
            flags: (0x0401) ACC_PUBLIC, ACC_ABSTRACT
            Exceptions:
              throws com.ignition.ExecutionException
            Signature: #79 // (ITR;)TT;

        Shouldn't / couldn't bytecode verifier catch this? It certainly does not now, even when forced with JAVA_OPTIONS="-Xverify:all".

              hseigel Harold Seigel (Inactive)
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: