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

JNI_GetMethodID fails to find an instance method from the superclass

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • 9
    • hs25, 7u45
    • hotspot
    • None

      If a superclass A has an instance class foo() and a subclass B extends A has a static method with the same name and signature (see example code below), JNI_GetMethodID stops the lookup once it finds a matching method from class B and throws NoSuchMethodException since B.foo is a static method.

      class A {
        protected void foo() {
          System.out.println("A.foo");
        }
      }

      class B extends A {
        private static void foo() {
          System.out.println("private static B.foo()");
        }
      }

      javac will fail to compile the above and this requires patching the bytecode to get to this test case.

      This is related to the issue reported at
         http://weblog.ikvm.net/PermaLink.aspx?guid=cce26630-b8f3-4a05-b9d3-2426fb442385

      Another issue when the subclass has a private "foo" instance method and its superclass also defines an instance "foo", the bytecode invocation of invokevirtual will ignore the private method and use the non-private foo method in the superclass.

      The spec of JNI_GetMethodID should also be clarified whether it will ignore the private method in this case.

            hseigel Harold Seigel (Inactive)
            mchung Mandy Chung
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: