On 09/13/2013 11:05 AM, Joel Borggrén-Franck wrote:
Hi,

Thanks Karen and Peter.

FWIW my interpretation is that javac is doing the right thing. The bytecode generated is 
an "invokeinterface DefaultStaticMethodTest$C.m()". This looks consistent with 
the other bytecodes generated for calls to methods of anonymous classes implementing an 
interface. There should be no ambiguity in the program since static interface methods are 
not inherited, so javac is right in accepting it.

I think that too. In that case even the AbstractMethodError is incorrect VM behaviour. And the order of "C extends B, A" vs. "C extends A, B" should not effect the behaviour.

Karen, I filed a bug, but don't have the bug ID yet. Will let you know when I get it.

Regards, Peter

cheers /Joel
On Sep 12, 2013, at 8:23 PM, Karen Kinnear <karen.kinn...@oracle.com> wrote:
Thank you, we really appreciate all testing.

I have a fix in a prototype in the vm for this. Let me know if you want an 
early patch.
Or you can just file a bug and that way you'll know when the fix is officially 
in the tree.

thanks,
Karen

On Sep 12, 2013, at 10:59 AM, Peter Levart wrote:

Hi,

While testing behavior of reflection on default and static interface methods, 
using self-built JDK from latest tip of jdk8/tl, I found:

The following program:

public class DefaultVsStaticInterfaceMethodTest {
     public interface A {
         default void m() {
             System.out.println("A.m() called");
         }
     }

     public interface B {
         static void m() {
             System.out.println("B.m() called");
         }
     }

     public interface C extends A, B {
     }

     public static void main(String[] args) throws Exception {
         C c = new C() {};
         c.m();
     }
}


...compiles, but gives a runtime error:

Exception in thread "main" java.lang.AbstractMethodError: Conflicting default 
methods: DefaultVsStaticInterfaceMethodTest$A.m DefaultVsStaticInterfaceMethodTest$B.m
     at 
DefaultVsStaticInterfaceMethodTest$1.m(DefaultVsStaticInterfaceMethodTest.java)
     at 
DefaultVsStaticInterfaceMethodTest.main(DefaultVsStaticInterfaceMethodTest.java:28)


A slightly modified program: "C extends A, B" replaced with "C extends B, A":

http://cr.openjdk.java.net/~plevart/jdk8-tl/StaticVsDefaultInterfaceMethods/DefaultVsStaticInterfaceMethodTest.java

...also compiles, but crashes the VM when run:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fd4d5020bf9, pid=9964, tid=140552419804928
#
# JRE version: OpenJDK Runtime Environment (8.0) (build 
1.8.0-internal-peter_2013_09_12_16_29-b00)
# Java VM: OpenJDK 64-Bit Server VM (25.0-b48 mixed mode linux-amd64 compressed 
oops)
# Problematic frame:
# j  DefaultVsStaticInterfaceMethodTest.main([Ljava/lang/String;)V+9
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try 
"ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/peter/work/git/jdk8-tl/out/production/test/hs_err_pid9964.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#
Aborted (core dumped)


Here's the hs_err_pid file:

http://cr.openjdk.java.net/~plevart/jdk8-tl/StaticVsDefaultInterfaceMethods/hs_err_pid9964.log

Regards, Peter


Reply via email to