74 lines
3.5 KiB
Diff
74 lines
3.5 KiB
Diff
|
|
From 557d2ea5560c2d0e9cae7f9a792329dfc5cb9573 Mon Sep 17 00:00:00 2001
|
||
|
|
Date: Fri, 29 Nov 2019 18:03:11 +0000
|
||
|
|
Subject: [PATCH] 8214345: infinite recursion while checking super class
|
||
|
|
|
||
|
|
Summary: <javac>: infinite recursion while checking super class
|
||
|
|
LLT: ClassBoundCheckingOverflow.java ClassBoundCheckingOverflow.out
|
||
|
|
Bug url: https://bugs.openjdk.java.net/browse/JDK-8214345
|
||
|
|
---
|
||
|
|
.../share/classes/com/sun/tools/javac/comp/Check.java | 5 ++++-
|
||
|
|
.../tools/javac/generics/ClassBoundCheckingOverflow.java | 12 ++++++++++++
|
||
|
|
.../tools/javac/generics/ClassBoundCheckingOverflow.out | 3 +++
|
||
|
|
3 files changed, 19 insertions(+), 1 deletion(-)
|
||
|
|
create mode 100644 test/langtools/tools/javac/generics/ClassBoundCheckingOverflow.java
|
||
|
|
create mode 100644 test/langtools/tools/javac/generics/ClassBoundCheckingOverflow.out
|
||
|
|
|
||
|
|
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
|
||
|
|
index 90cb9d189..b1f4abcb6 100644
|
||
|
|
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
|
||
|
|
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
|
||
|
|
@@ -1,5 +1,5 @@
|
||
|
|
/*
|
||
|
|
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
|
||
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
|
|
*
|
||
|
|
* This code is free software; you can redistribute it and/or modify it
|
||
|
|
@@ -2716,6 +2716,8 @@ public class Check {
|
||
|
|
if (type.isErroneous()) return;
|
||
|
|
for (List<Type> l = types.interfaces(type); l.nonEmpty(); l = l.tail) {
|
||
|
|
Type it = l.head;
|
||
|
|
+ if (type.hasTag(CLASS) && !it.hasTag(CLASS)) continue; // JLS 8.1.5
|
||
|
|
+
|
||
|
|
Type oldit = seensofar.put(it.tsym, it);
|
||
|
|
if (oldit != null) {
|
||
|
|
List<Type> oldparams = oldit.allparams();
|
||
|
|
@@ -2729,6 +2731,7 @@ public class Check {
|
||
|
|
checkClassBounds(pos, seensofar, it);
|
||
|
|
}
|
||
|
|
Type st = types.supertype(type);
|
||
|
|
+ if (type.hasTag(CLASS) && !st.hasTag(CLASS)) return; // JLS 8.1.4
|
||
|
|
if (st != Type.noType) checkClassBounds(pos, seensofar, st);
|
||
|
|
}
|
||
|
|
|
||
|
|
diff --git a/test/langtools/tools/javac/generics/ClassBoundCheckingOverflow.java b/test/langtools/tools/javac/generics/ClassBoundCheckingOverflow.java
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..1aeb7d71a
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/test/langtools/tools/javac/generics/ClassBoundCheckingOverflow.java
|
||
|
|
@@ -0,0 +1,12 @@
|
||
|
|
+/*
|
||
|
|
+ * @test /nodynamiccopyright/
|
||
|
|
+ * @bug 8214345
|
||
|
|
+ * @summary infinite recursion while checking super class
|
||
|
|
+ *
|
||
|
|
+ * @compile/fail/ref=ClassBoundCheckingOverflow.out -XDrawDiagnostics ClassBoundCheckingOverflow.java
|
||
|
|
+ */
|
||
|
|
+
|
||
|
|
+public class ClassBoundCheckingOverflow {
|
||
|
|
+ abstract class InfiniteLoop1<E extends InfiniteLoop1<E>> extends E {}
|
||
|
|
+ abstract class InfiniteLoop2<E extends InfiniteLoop2<E>> implements E {}
|
||
|
|
+}
|
||
|
|
diff --git a/test/langtools/tools/javac/generics/ClassBoundCheckingOverflow.out b/test/langtools/tools/javac/generics/ClassBoundCheckingOverflow.out
|
||
|
|
new file mode 100644
|
||
|
|
index 000000000..bed6acfd7
|
||
|
|
--- /dev/null
|
||
|
|
+++ b/test/langtools/tools/javac/generics/ClassBoundCheckingOverflow.out
|
||
|
|
@@ -0,0 +1,3 @@
|
||
|
|
+ClassBoundCheckingOverflow.java:10:70: compiler.err.type.found.req: (compiler.misc.type.parameter: E), (compiler.misc.type.req.class)
|
||
|
|
+ClassBoundCheckingOverflow.java:11:73: compiler.err.type.found.req: (compiler.misc.type.parameter: E), (compiler.misc.type.req.class)
|
||
|
|
+2 errors
|
||
|
|
--
|
||
|
|
2.12.3
|
||
|
|
|