RFR(S): JDK-8033126 : Can't call default methods from JNI

David Holmes david.holmes at oracle.com
Wed Jan 29 16:51:11 PST 2014


Hi Staffan,

On 29/01/2014 11:17 PM, Staffan Larsen wrote:
> This is a more formal review request for the patch proposed in [0]
>
> webrev: http://cr.openjdk.java.net/~sla/8033126/webrev.00/
> bug: https://bugs.openjdk.java.net/browse/JDK-8033126
>
> The bug report has a reproducer/testcase that I have used to verify the fix. I have also run the vm/jni tests in the JCK.

This whole scenario doesn't look right to me. You can't arbitrarily 
invoke default methods in a class hierarchy. Given the testcase:

interface A {
     default int getOne() {
         return 1;
     }
}

interface B extends A {
     default int getOne() {
         return 2;
     }
}

abstract class Abstract implements B {
}

class Impl extends Abstract {
     public int getOne() {
         return 3;
     }
}

class Impl2 extends Impl {
     public int getOne() {
         return 4;
     }
}

public class ImplTest {
     public static void main(String[] args) {
         System.loadLibrary("impl");
         Impl2 i = new Impl2();
         test(i);
     }
     static native void test(Impl i);
}

The only legitimate call is Impl2.getOne() which should return 4.

David
-----


> Thanks,
> /Staffan
>
> [0] http://mail.openjdk.java.net/pipermail/hotspot-dev/2014-January/012325.html
>


More information about the hotspot-dev mailing list