6988407: javac crashes running processor on errant code; it used to print error message
Reviewed-by: darcy
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Oct 12 12:55:38 2010 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Tue Oct 12 13:15:46 2010 -0700
@@ -668,9 +668,9 @@
public void visitTree(JCTree tree) {
}
-
public void visitErroneous(JCErroneous tree) {
- memberEnter(tree.errs, env);
+ if (tree.errs != null)
+ memberEnter(tree.errs, env);
}
public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) {
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Oct 12 12:55:38 2010 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Tue Oct 12 13:15:46 2010 -0700
@@ -511,7 +511,7 @@
protected boolean shouldStop(CompileState cs) {
if (shouldStopPolicy == null)
- return (errorCount() > 0);
+ return (errorCount() > 0 || unrecoverableError());
else
return cs.ordinal() > shouldStopPolicy.ordinal();
}
--- a/langtools/test/tools/javac/api/6406133/Erroneous.java Tue Oct 12 12:55:38 2010 -0700
+++ b/langtools/test/tools/javac/api/6406133/Erroneous.java Tue Oct 12 13:15:46 2010 -0700
@@ -1,4 +1,26 @@
+/*
+ * Copyright (c) 2008, 2010, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
@Deprecated
-class A {
- class A {}
+class A extends Missing {
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/errors/TestParseErrors/ParseErrors.java Tue Oct 12 13:15:46 2010 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.List;
+import java.util.Vector;
+
+class test {
+
+ public String m(List<? extends String> v, String s ) {
+ return null;
+ }
+
+ public String m2(Vector<String> vs, String s) {
+ return null;
+ }
+
+ public void m3(testclass<String>,
+}
+
+class testclass<T> {
+ T t;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.java Tue Oct 12 13:15:46 2010 -0700
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6988407
+ * @summary javac crashes running processor on errant code; it used to print error message
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestParseErrors
+ * @compile/fail/ref=TestParseErrors.out -XDrawDiagnostics -proc:only -processor TestParseErrors ParseErrors.java
+ */
+
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+
+public class TestParseErrors extends JavacTestingAbstractProcessor {
+
+ public boolean process(Set<? extends TypeElement> annotations,
+ RoundEnvironment roundEnvironment) {
+ throw new Error("Should not be called");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out Tue Oct 12 13:15:46 2010 -0700
@@ -0,0 +1,8 @@
+ParseErrors.java:37:37: compiler.err.expected: token.identifier
+ParseErrors.java:38:1: compiler.err.illegal.start.of.type
+ParseErrors.java:38:2: compiler.err.expected: ')'
+ParseErrors.java:40:6: compiler.err.expected: ';'
+ParseErrors.java:40:20: compiler.err.illegal.start.of.type
+ParseErrors.java:41:5: compiler.err.expected: '('
+ParseErrors.java:41:8: compiler.err.expected: token.identifier
+7 errors