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

Tue, 12 Oct 2010 13:15:46 -0700

author
jjg
date
Tue, 12 Oct 2010 13:15:46 -0700
changeset 711
14a707f8ce84
parent 710
68cf07910d74
child 712
a1d31ab7b525

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

src/share/classes/com/sun/tools/javac/comp/MemberEnter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/main/JavaCompiler.java file | annotate | diff | comparison | revisions
test/tools/javac/api/6406133/Erroneous.java file | annotate | diff | comparison | revisions
test/tools/javac/processing/errors/TestParseErrors/ParseErrors.java file | annotate | diff | comparison | revisions
test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.java file | annotate | diff | comparison | revisions
test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Oct 12 12:55:38 2010 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Oct 12 13:15:46 2010 -0700
     1.3 @@ -668,9 +668,9 @@
     1.4      public void visitTree(JCTree tree) {
     1.5      }
     1.6  
     1.7 -
     1.8      public void visitErroneous(JCErroneous tree) {
     1.9 -        memberEnter(tree.errs, env);
    1.10 +        if (tree.errs != null)
    1.11 +            memberEnter(tree.errs, env);
    1.12      }
    1.13  
    1.14      public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) {
     2.1 --- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Oct 12 12:55:38 2010 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Oct 12 13:15:46 2010 -0700
     2.3 @@ -511,7 +511,7 @@
     2.4  
     2.5      protected boolean shouldStop(CompileState cs) {
     2.6          if (shouldStopPolicy == null)
     2.7 -            return (errorCount() > 0);
     2.8 +            return (errorCount() > 0 || unrecoverableError());
     2.9          else
    2.10              return cs.ordinal() > shouldStopPolicy.ordinal();
    2.11      }
     3.1 --- a/test/tools/javac/api/6406133/Erroneous.java	Tue Oct 12 12:55:38 2010 -0700
     3.2 +++ b/test/tools/javac/api/6406133/Erroneous.java	Tue Oct 12 13:15:46 2010 -0700
     3.3 @@ -1,4 +1,26 @@
     3.4 +/*
     3.5 + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27  @Deprecated
    3.28 -class A {
    3.29 -    class A {}
    3.30 +class A extends Missing {
    3.31  }
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/processing/errors/TestParseErrors/ParseErrors.java	Tue Oct 12 13:15:46 2010 -0700
     4.3 @@ -0,0 +1,42 @@
     4.4 +/*
     4.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + *
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + *
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + *
    4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + */
    4.26 +
    4.27 +import java.util.List;
    4.28 +import java.util.Vector;
    4.29 +
    4.30 +class test {
    4.31 +
    4.32 +    public String m(List<? extends String> v, String s ) {
    4.33 +        return null;
    4.34 +    }
    4.35 +
    4.36 +    public String m2(Vector<String> vs, String s) {
    4.37 +        return null;
    4.38 +    }
    4.39 +
    4.40 +    public void m3(testclass<String>,
    4.41 +}
    4.42 +
    4.43 +class testclass<T> {
    4.44 +    T t;
    4.45 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.java	Tue Oct 12 13:15:46 2010 -0700
     5.3 @@ -0,0 +1,43 @@
     5.4 +/*
     5.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.
    5.11 + *
    5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 + * version 2 for more details (a copy is included in the LICENSE file that
    5.16 + * accompanied this code).
    5.17 + *
    5.18 + * You should have received a copy of the GNU General Public License version
    5.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 + *
    5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 + * or visit www.oracle.com if you need additional information or have any
    5.24 + * questions.
    5.25 + */
    5.26 +
    5.27 +/*
    5.28 + * @test
    5.29 + * @bug 6988407
    5.30 + * @summary javac crashes running processor on errant code; it used to print error message
    5.31 + * @library ../../../lib
    5.32 + * @build JavacTestingAbstractProcessor TestParseErrors
    5.33 + * @compile/fail/ref=TestParseErrors.out -XDrawDiagnostics -proc:only -processor TestParseErrors ParseErrors.java
    5.34 + */
    5.35 +
    5.36 +import java.util.*;
    5.37 +import javax.annotation.processing.*;
    5.38 +import javax.lang.model.element.*;
    5.39 +
    5.40 +public class TestParseErrors extends JavacTestingAbstractProcessor {
    5.41 +
    5.42 +    public boolean process(Set<? extends TypeElement> annotations,
    5.43 +                           RoundEnvironment roundEnvironment) {
    5.44 +        throw new Error("Should not be called");
    5.45 +    }
    5.46 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out	Tue Oct 12 13:15:46 2010 -0700
     6.3 @@ -0,0 +1,8 @@
     6.4 +ParseErrors.java:37:37: compiler.err.expected: token.identifier
     6.5 +ParseErrors.java:38:1: compiler.err.illegal.start.of.type
     6.6 +ParseErrors.java:38:2: compiler.err.expected: ')'
     6.7 +ParseErrors.java:40:6: compiler.err.expected: ';'
     6.8 +ParseErrors.java:40:20: compiler.err.illegal.start.of.type
     6.9 +ParseErrors.java:41:5: compiler.err.expected: '('
    6.10 +ParseErrors.java:41:8: compiler.err.expected: token.identifier
    6.11 +7 errors

mercurial