Community
Participate
Working Groups
The following code generates wrong code: interface I { public void foo() default { System.out.println("default"); } } public class C implements I { public static void main(String[] args) { C c = new C(); c.foo(); } } At runtime this produces: Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Object.foo()V at C.foo(C.java:1) at C.main(C.java:9) The reason is in the way a synthetic method (SuperMethodAccess) for foo is generated: it is assumed that the super method must be in accessMethod.declaringClass.superclass(), which leads to trying to invoke java.lang.Object.foo(), which obviously doesn't exist.
Created attachment 227029 [details] tentative fix This patch fixes the immediate issue but is not sufficiently tested.
Jay, does my patch help for your test re static methods in interfaces? Should I test and release this one first, or wait for you?
If released the immediate patch via commit c22ae4e2acd996824ff94a2b0edaa0df69d9b3b1 Further cross-checking deferred to bug 391376.
(In reply to comment #2) > Jay, does my patch help for your test re static methods in interfaces? > Should I test and release this one first, or wait for you? Yes, Stephan. Thank you!