1 Star 0 Fork 81

胡波道/openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
8214345.patch 3.18 KB
一键复制 编辑 原始数据 按行查看 历史
jdkboy 提交于 2020-03-21 11:30 . delete redundant info
From a3a0d29610bef14392cf20a8d5807ab288320056 Mon Sep 17 00:00:00 2001
Date: Mon, 1 Jul 2019 11:47:36 +0000
Subject: [PATCH] Backpot of JDK-8214345
Summary: infinite recursion while checking super class
LLT: langtools/test/tools/javac/generics/ClassBoundCheckingOverflow.java
Bug url: https://bugs.openjdk.java.net/browse/JDK-8214345
---
.../classes/com/sun/tools/javac/comp/Check.java | 7 +++++++
.../javac/generics/ClassBoundCheckingOverflow.java | 12 ++++++++++++
.../javac/generics/ClassBoundCheckingOverflow.out | 3 +++
3 files changed, 22 insertions(+)
create mode 100644 langtools/test/tools/javac/generics/ClassBoundCheckingOverflow.java
create mode 100644 langtools/test/tools/javac/generics/ClassBoundCheckingOverflow.out
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
index d5e9c47a41..68af438218 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
@@ -2617,6 +2617,10 @@ 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();
@@ -2629,6 +2633,9 @@ 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/langtools/test/tools/javac/generics/ClassBoundCheckingOverflow.java b/langtools/test/tools/javac/generics/ClassBoundCheckingOverflow.java
new file mode 100644
index 0000000000..1aeb7d71ab
--- /dev/null
+++ b/langtools/test/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/langtools/test/tools/javac/generics/ClassBoundCheckingOverflow.out b/langtools/test/tools/javac/generics/ClassBoundCheckingOverflow.out
new file mode 100644
index 0000000000..bed6acfd7f
--- /dev/null
+++ b/langtools/test/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.19.0-rc1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hu_bo_dao/openjdk-1.8.0.git
git@gitee.com:hu_bo_dao/openjdk-1.8.0.git
hu_bo_dao
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助