7014715: javac returns different error code for certain failure(s)

Thu, 03 Feb 2011 09:38:19 +0000

author
mcimadamore
date
Thu, 03 Feb 2011 09:38:19 +0000
changeset 855
afe226180744
parent 854
03cf47d4de15
child 856
9e6a09375d37

7014715: javac returns different error code for certain failure(s)
Summary: javac silently crashes when emitting certain kinds of resolution diagnostics
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/comp/Attr.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Resolve.java file | annotate | diff | comparison | revisions
test/tools/javac/AnonStaticMember_2.java file | annotate | diff | comparison | revisions
test/tools/javac/AnonStaticMember_2.out file | annotate | diff | comparison | revisions
test/tools/javac/InterfaceInInner.java file | annotate | diff | comparison | revisions
test/tools/javac/InterfaceInInner.out file | annotate | diff | comparison | revisions
test/tools/javac/QualifiedNew.java file | annotate | diff | comparison | revisions
test/tools/javac/QualifiedNew.out file | annotate | diff | comparison | revisions
test/tools/javac/T6247324.out file | annotate | diff | comparison | revisions
test/tools/javac/generics/diamond/neg/Neg01.out file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/6943278/T6943278.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Feb 03 09:37:28 2011 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Feb 03 09:38:19 2011 +0000
     1.3 @@ -2374,7 +2374,6 @@
     1.4                                   int pkind) {
     1.5              DiagnosticPosition pos = tree.pos();
     1.6              Name name = tree.name;
     1.7 -
     1.8              switch (site.tag) {
     1.9              case PACKAGE:
    1.10                  return rs.access(
    1.11 @@ -3186,7 +3185,7 @@
    1.12                  if (sym == null ||
    1.13                      sym.kind != VAR ||
    1.14                      ((VarSymbol) sym).getConstValue() == null)
    1.15 -                    log.error(l.head.pos(), "icls.cant.have.static.decl", sym.location());
    1.16 +                    log.error(l.head.pos(), "icls.cant.have.static.decl", c);
    1.17              }
    1.18          }
    1.19  
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Feb 03 09:37:28 2011 +0000
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Feb 03 09:38:19 2011 +0000
     2.3 @@ -1952,6 +1952,9 @@
     2.4                          key, name, first, second);
     2.5              }
     2.6              boolean hasLocation = false;
     2.7 +            if (location == null) {
     2.8 +                location = site.tsym;
     2.9 +            }
    2.10              if (!location.name.isEmpty()) {
    2.11                  if (location.kind == PCK && !site.tsym.exists()) {
    2.12                      return diags.create(dkind, log.currentSource(), pos,
    2.13 @@ -1969,7 +1972,7 @@
    2.14                  return diags.create(dkind, log.currentSource(), pos,
    2.15                          errKey, kindname, idname, //symbol kindname, name
    2.16                          typeargtypes, argtypes, //type parameters and arguments (if any)
    2.17 -                        getLocationDiag(location)); //location kindname, type
    2.18 +                        getLocationDiag(location, site)); //location kindname, type
    2.19              }
    2.20              else {
    2.21                  return diags.create(dkind, log.currentSource(), pos,
    2.22 @@ -1990,15 +1993,18 @@
    2.23              }
    2.24              return key + suffix;
    2.25          }
    2.26 -        private JCDiagnostic getLocationDiag(Symbol location) {
    2.27 -            boolean isVar = location.kind == VAR;
    2.28 -            String key = isVar ?
    2.29 -                "location.1" :
    2.30 -                "location";
    2.31 -            return diags.fragment(key,
    2.32 +        private JCDiagnostic getLocationDiag(Symbol location, Type site) {
    2.33 +            if (location.kind == VAR) {
    2.34 +                return diags.fragment("location.1",
    2.35                      kindName(location),
    2.36                      location,
    2.37 -                    isVar ? location.type : null);
    2.38 +                    location.type);
    2.39 +            } else {
    2.40 +                return diags.fragment("location",
    2.41 +                    typeKindName(site),
    2.42 +                    site,
    2.43 +                    null);
    2.44 +            }
    2.45          }
    2.46      }
    2.47  
     3.1 --- a/test/tools/javac/AnonStaticMember_2.java	Thu Feb 03 09:37:28 2011 +0000
     3.2 +++ b/test/tools/javac/AnonStaticMember_2.java	Thu Feb 03 09:38:19 2011 +0000
     3.3 @@ -1,33 +1,10 @@
     3.4  /*
     3.5 - * Copyright (c) 1999, 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 -/*
    3.28 - * @test
    3.29 + * @test  /nodynamiccopyright/
    3.30   * @bug 4279339
    3.31   * @summary Verify that an anonymous class cannot contain a static method.
    3.32   * @author maddox
    3.33   *
    3.34 - * @run compile/fail AnonStaticMember_2.java
    3.35 + * @run compile/fail/ref=AnonStaticMember_2.out -XDrawDiagnostics AnonStaticMember_2.java
    3.36   */
    3.37  
    3.38  class AnonStaticMember_2 {
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/AnonStaticMember_2.out	Thu Feb 03 09:38:19 2011 +0000
     4.3 @@ -0,0 +1,2 @@
     4.4 +AnonStaticMember_2.java:12:21: compiler.err.icls.cant.have.static.decl: compiler.misc.anonymous.class: AnonStaticMember_2$1
     4.5 +1 error
     5.1 --- a/test/tools/javac/InterfaceInInner.java	Thu Feb 03 09:37:28 2011 +0000
     5.2 +++ b/test/tools/javac/InterfaceInInner.java	Thu Feb 03 09:38:19 2011 +0000
     5.3 @@ -1,33 +1,10 @@
     5.4  /*
     5.5 - * Copyright (c) 1997, 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 + * @test  /nodynamiccopyright/
    5.30   * @bug 4063740
    5.31   * @summary Interfaces may only be declared in top level classes.
    5.32   * @author turnidge
    5.33   *
    5.34 - * @compile/fail InterfaceInInner.java
    5.35 + * @compile/fail/ref=InterfaceInInner.out -XDrawDiagnostics InterfaceInInner.java
    5.36   */
    5.37  class InterfaceInInner {
    5.38      InterfaceInInner() {
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/javac/InterfaceInInner.out	Thu Feb 03 09:38:19 2011 +0000
     6.3 @@ -0,0 +1,2 @@
     6.4 +InterfaceInInner.java:12:13: compiler.err.intf.not.allowed.here
     6.5 +1 error
     7.1 --- a/test/tools/javac/QualifiedNew.java	Thu Feb 03 09:37:28 2011 +0000
     7.2 +++ b/test/tools/javac/QualifiedNew.java	Thu Feb 03 09:38:19 2011 +0000
     7.3 @@ -1,33 +1,10 @@
     7.4  /*
     7.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
     7.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 - *
     7.8 - * This code is free software; you can redistribute it and/or modify it
     7.9 - * under the terms of the GNU General Public License version 2 only, as
    7.10 - * published by the Free Software Foundation.
    7.11 - *
    7.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    7.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.15 - * version 2 for more details (a copy is included in the LICENSE file that
    7.16 - * accompanied this code).
    7.17 - *
    7.18 - * You should have received a copy of the GNU General Public License version
    7.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    7.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.21 - *
    7.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.23 - * or visit www.oracle.com if you need additional information or have any
    7.24 - * questions.
    7.25 - */
    7.26 -
    7.27 -/*
    7.28 - * @test
    7.29 + * @test  /nodynamiccopyright/
    7.30   * @bug 4406966
    7.31   * @summary null qualifying inner instance creation should be error.
    7.32   * @author gafter
    7.33   *
    7.34 - * @compile/fail QualifiedNew.java
    7.35 + * @compile/fail/ref=QualifiedNew.out -XDrawDiagnostics QualifiedNew.java
    7.36   */
    7.37  
    7.38  class QualifiedNew {
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/tools/javac/QualifiedNew.out	Thu Feb 03 09:38:19 2011 +0000
     8.3 @@ -0,0 +1,3 @@
     8.4 +QualifiedNew.java:14:23: compiler.err.type.found.req: compiler.misc.type.null, (compiler.misc.type.req.ref)
     8.5 +QualifiedNew.java:15:29: compiler.err.cant.resolve.location: kindname.class, Y, , , (compiler.misc.location: kindname.class, QualifiedNew.Y[], null)
     8.6 +2 errors
     9.1 --- a/test/tools/javac/T6247324.out	Thu Feb 03 09:37:28 2011 +0000
     9.2 +++ b/test/tools/javac/T6247324.out	Thu Feb 03 09:38:19 2011 +0000
     9.3 @@ -1,2 +1,2 @@
     9.4 -T6247324.java:18:6: compiler.err.cant.resolve.location: kindname.class, Seetharam, , , (compiler.misc.location: kindname.class, Pair, null)
     9.5 +T6247324.java:18:6: compiler.err.cant.resolve.location: kindname.class, Seetharam, , , (compiler.misc.location: kindname.class, Pair<X,Y>, null)
     9.6  1 error
    10.1 --- a/test/tools/javac/generics/diamond/neg/Neg01.out	Thu Feb 03 09:37:28 2011 +0000
    10.2 +++ b/test/tools/javac/generics/diamond/neg/Neg01.out	Thu Feb 03 09:38:19 2011 +0000
    10.3 @@ -17,7 +17,7 @@
    10.4  Neg01.java:29:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
    10.5  Neg01.java:29:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
    10.6  Neg01.java:30:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
    10.7 -Neg01.java:31:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01, null)
    10.8 +Neg01.java:31:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
    10.9  Neg01.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
   10.10  Neg01.java:33:15: compiler.err.not.within.bounds: java.lang.String, X
   10.11  Neg01.java:33:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
    11.1 --- a/test/tools/javac/generics/inference/6943278/T6943278.out	Thu Feb 03 09:37:28 2011 +0000
    11.2 +++ b/test/tools/javac/generics/inference/6943278/T6943278.out	Thu Feb 03 09:38:19 2011 +0000
    11.3 @@ -1,3 +1,3 @@
    11.4  T6943278.java:7:35: compiler.err.cant.resolve: kindname.class, NonExistentInterface, , 
    11.5 -T6943278.java:9:25: compiler.err.cant.resolve.location: kindname.class, NonExistentInterface, , , (compiler.misc.location: kindname.class, T6943278, null)
    11.6 +T6943278.java:9:25: compiler.err.cant.resolve.location: kindname.class, NonExistentInterface, , , (compiler.misc.location: kindname.class, T6943278<X>, null)
    11.7  2 errors

mercurial