changeset 52137:d883f528689d

8193561: Cyclic hierarchy causes a NullPointerException when setting DEFAULT flag Summary: When marking interface as having default methods, use .owner as it is always defined. Reviewed-by: mcimadamore
author jlahoda
date Mon, 17 Sep 2018 11:49:20 +0200
parents caef940517be
children e10ade04afe5
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java test/langtools/tools/javac/cycle/T8193561.java test/langtools/tools/javac/cycle/T8193561.out
diffstat 3 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Sep 17 14:16:31 2018 +0530
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Sep 17 11:49:20 2018 +0200
@@ -183,7 +183,7 @@
 
         //if this is a default method, add the DEFAULT flag to the enclosing interface
         if ((tree.mods.flags & DEFAULT) != 0) {
-            m.enclClass().flags_field |= DEFAULT;
+            m.owner.flags_field |= DEFAULT;
         }
 
         Env<AttrContext> localEnv = methodEnv(tree, env);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/cycle/T8193561.java	Mon Sep 17 11:49:20 2018 +0200
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8193561
+ * @summary Verify that there is no crash for default methods in mutually dependent interfaces
+ * @compile/fail/ref=T8193561.out -XDrawDiagnostics T8193561.java
+ */
+package p;
+
+interface T8193561 extends p.T8193561.I {
+
+    interface I  extends T8193561 {
+        default boolean m() {
+            return false;
+        }
+    }
+
+    default boolean m() {
+        return false;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/cycle/T8193561.out	Mon Sep 17 11:49:20 2018 +0200
@@ -0,0 +1,2 @@
+T8193561.java:9:1: compiler.err.cyclic.inheritance: p.T8193561
+1 error