6988407: javac crashes running processor on errant code; it used to print error message

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2010-10-12 13:15:46 -07:00
parent 2baca00eeb
commit 3f57abb0ba
6 changed files with 120 additions and 5 deletions

View File

@ -668,9 +668,9 @@ public class MemberEnter extends JCTree.Visitor implements Completer {
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) {

View File

@ -511,7 +511,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
protected boolean shouldStop(CompileState cs) {
if (shouldStopPolicy == null)
return (errorCount() > 0);
return (errorCount() > 0 || unrecoverableError());
else
return cs.ordinal() > shouldStopPolicy.ordinal();
}

View File

@ -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 {
}

View File

@ -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;
}

View File

@ -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");
}
}

View File

@ -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