aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjlahoda <none@none>2014-09-22 14:55:14 +0200
committerjlahoda <none@none>2014-09-22 14:55:14 +0200
commitaf4faf39ee9bd88b61ecdb73200a1e4d11b348ff (patch)
treed3b346d148938e74be2caa8f224a868f6a224a98
parentd525b416efc0b77d4230f2ee98052ef77ff0876f (diff)
8057794: Compiler Error when obtaining .class propertyjdk8u40-b17
Summary: Ensuring a non-null type and sym for illegal T.class to prevent downstream errors. Reviewed-by: mcimadamore
-rw-r--r--src/share/classes/com/sun/tools/javac/comp/Attr.java5
-rw-r--r--test/tools/javac/lambda/T8057794.java12
-rw-r--r--test/tools/javac/lambda/T8057794.out2
3 files changed, 17 insertions, 2 deletions
diff --git a/src/share/classes/com/sun/tools/javac/comp/Attr.java b/src/share/classes/com/sun/tools/javac/comp/Attr.java
index e44b09c6..f5d52595 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -3226,8 +3226,9 @@ public class Attr extends JCTree.Visitor {
elt = ((ArrayType)elt.unannotatedType()).elemtype;
if (elt.hasTag(TYPEVAR)) {
log.error(tree.pos(), "type.var.cant.be.deref");
- result = types.createErrorType(tree.type);
- return;
+ result = tree.type = types.createErrorType(tree.name, site.tsym, site);
+ tree.sym = tree.type.tsym;
+ return ;
}
}
diff --git a/test/tools/javac/lambda/T8057794.java b/test/tools/javac/lambda/T8057794.java
new file mode 100644
index 00000000..2bf4c5ae
--- /dev/null
+++ b/test/tools/javac/lambda/T8057794.java
@@ -0,0 +1,12 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 8057794
+ * @summary The tree for TypeVar.class does not have a type set, which leads to an NPE when
+ * checking if deferred attribution is needed
+ * @compile/fail/ref=T8057794.out -XDrawDiagnostics T8057794.java
+ */
+class T8057794<T> {
+ void t() {
+ System.out.println(T.class.getSimpleName());
+ }
+}
diff --git a/test/tools/javac/lambda/T8057794.out b/test/tools/javac/lambda/T8057794.out
new file mode 100644
index 00000000..fa025a99
--- /dev/null
+++ b/test/tools/javac/lambda/T8057794.out
@@ -0,0 +1,2 @@
+T8057794.java:10:29: compiler.err.type.var.cant.be.deref
+1 error