7151802: compiler update caused sqe test failed

Fri, 09 Mar 2012 17:10:56 +0000

author
mcimadamore
date
Fri, 09 Mar 2012 17:10:56 +0000
changeset 1226
97bec6ab1227
parent 1225
83352b2e2ebc
child 1227
08a3425f39f8
child 1230
b14d9583ce92

7151802: compiler update caused sqe test failed
Summary: Fix regression caused by 7144506
Reviewed-by: jjg, dlsmith

src/share/classes/com/sun/tools/javac/comp/Attr.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Check.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Infer.java file | annotate | diff | comparison | revisions
test/tools/javac/6758789/T6758789b.out file | annotate | diff | comparison | revisions
test/tools/javac/generics/7015430/T7015430.out file | annotate | diff | comparison | revisions
test/tools/javac/generics/7151802/T7151802.java file | annotate | diff | comparison | revisions
test/tools/javac/generics/7151802/T7151802.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Mar 08 08:19:58 2012 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Mar 09 17:10:56 2012 +0000
     1.3 @@ -2725,6 +2725,8 @@
     1.4                                        useVarargs,
     1.5                                        noteWarner);
     1.6  
     1.7 +        boolean unchecked = noteWarner.hasNonSilentLint(LintCategory.UNCHECKED);
     1.8 +
     1.9          // If this fails, something went wrong; we should not have
    1.10          // found the identifier in the first place.
    1.11          if (owntype == null) {
    1.12 @@ -2735,10 +2737,10 @@
    1.13                            Type.toString(pt().getParameterTypes()));
    1.14              owntype = types.createErrorType(site);
    1.15              return types.createErrorType(site);
    1.16 -        } else if (owntype.getReturnType().tag == FORALL) {
    1.17 +        } else if (owntype.getReturnType().tag == FORALL && !unchecked) {
    1.18              return owntype;
    1.19          } else {
    1.20 -            return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs);
    1.21 +            return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs, unchecked);
    1.22          }
    1.23      }
    1.24  
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Mar 08 08:19:58 2012 -0800
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Mar 09 17:10:56 2012 +0000
     2.3 @@ -755,8 +755,8 @@
     2.4                              Env<AttrContext> env,
     2.5                              final List<JCExpression> argtrees,
     2.6                              List<Type> argtypes,
     2.7 -                            boolean useVarargs) {
     2.8 -        boolean warned = false;
     2.9 +                            boolean useVarargs,
    2.10 +                            boolean unchecked) {
    2.11          // System.out.println("call   : " + env.tree);
    2.12          // System.out.println("method : " + owntype);
    2.13          // System.out.println("actuals: " + argtypes);
    2.14 @@ -770,7 +770,6 @@
    2.15              JCTree arg = args.head;
    2.16              Warner warn = convertWarner(arg.pos(), arg.type, formals.head);
    2.17              assertConvertible(arg, arg.type, formals.head, warn);
    2.18 -            warned |= warn.hasNonSilentLint(LintCategory.UNCHECKED);
    2.19              args = args.tail;
    2.20              formals = formals.tail;
    2.21          }
    2.22 @@ -780,7 +779,6 @@
    2.23                  JCTree arg = args.head;
    2.24                  Warner warn = convertWarner(arg.pos(), arg.type, varArg);
    2.25                  assertConvertible(arg, arg.type, varArg, warn);
    2.26 -                warned |= warn.hasNonSilentLint(LintCategory.UNCHECKED);
    2.27                  args = args.tail;
    2.28              }
    2.29          } else if ((sym.flags() & VARARGS) != 0 && allowVarargs) {
    2.30 @@ -792,7 +790,7 @@
    2.31                  log.warning(argtrees.last().pos(), "inexact.non-varargs.call",
    2.32                          types.elemtype(varParam), varParam);
    2.33          }
    2.34 -        if (warned) {
    2.35 +        if (unchecked) {
    2.36              warnUnchecked(env.tree.pos(),
    2.37                      "unchecked.meth.invocation.applied",
    2.38                      kindName(sym),
     3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 08 08:19:58 2012 -0800
     3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Mar 09 17:10:56 2012 +0000
     3.3 @@ -385,7 +385,6 @@
     3.4                                    final Warner warn) throws InferenceException {
     3.5          //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
     3.6          List<Type> undetvars = Type.map(tvars, fromTypeVarFun);
     3.7 -        //final List<Type> capturedArgs = types.capture(argtypes);
     3.8  
     3.9          final List<Type> capturedArgs =
    3.10                  rs.checkRawArgumentsAcceptable(env, undetvars, argtypes, mt.getParameterTypes(),
    3.11 @@ -451,11 +450,12 @@
    3.12                                         types.subst(getThrownTypes(), tvars, inferred),
    3.13                                         qtype.tsym);
    3.14                      // check that actuals conform to inferred formals
    3.15 +                    warn.clear();
    3.16                      checkArgumentsAcceptable(env, capturedArgs, owntype.getParameterTypes(), allowBoxing, useVarargs, warn);
    3.17                      // check that inferred bounds conform to their bounds
    3.18                      checkWithinBounds(all_tvars,
    3.19                             types.subst(inferredTypes, tvars, inferred), warn);
    3.20 -                    qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs);
    3.21 +                    qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs, warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED));
    3.22                  }
    3.23              };
    3.24          }
     4.1 --- a/test/tools/javac/6758789/T6758789b.out	Thu Mar 08 08:19:58 2012 -0800
     4.2 +++ b/test/tools/javac/6758789/T6758789b.out	Fri Mar 09 17:10:56 2012 +0000
     4.3 @@ -1,4 +1,4 @@
     4.4 -T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<java.lang.Object>
     4.5 +T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X>
     4.6  T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo<X>, T6758789a.Foo, kindname.class, T6758789a
     4.7  - compiler.err.warnings.and.werror
     4.8  1 error
     5.1 --- a/test/tools/javac/generics/7015430/T7015430.out	Thu Mar 08 08:19:58 2012 -0800
     5.2 +++ b/test/tools/javac/generics/7015430/T7015430.out	Fri Mar 09 17:10:56 2012 +0000
     5.3 @@ -1,14 +1,14 @@
     5.4 -T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
     5.5 +T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
     5.6  T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
     5.7  T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
     5.8  T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
     5.9 -T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
    5.10 +T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
    5.11  T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
    5.12  T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
    5.13  T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
    5.14  T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
    5.15  T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
    5.16 -T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
    5.17 +T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
    5.18  T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
    5.19  T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
    5.20  T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/javac/generics/7151802/T7151802.java	Fri Mar 09 17:10:56 2012 +0000
     6.3 @@ -0,0 +1,43 @@
     6.4 +/*
     6.5 + * @test /nodynamiccopyright/
     6.6 + * @bug     7151802
     6.7 + * @summary compiler update caused sqe test failed
     6.8 + * @compile/fail/ref=T7151802.out -Werror -Xlint:unchecked -XDrawDiagnostics T7151802.java
     6.9 + */
    6.10 +class T7151802 {
    6.11 +    static class Foo<X> { }
    6.12 +
    6.13 +    static class SubFoo<X> extends Foo<X> { }
    6.14 +
    6.15 +    //generic - bound - arg - non-slilent
    6.16 +    <Z extends Foo<String>> void get1(Z fz) { }
    6.17 +    void test1(Foo foo) { get1(foo); }
    6.18 +
    6.19 +    //generic - bound - arg - silent
    6.20 +    <Z extends Foo<?>> void get2(Z fz) { }
    6.21 +    void test2(Foo foo) { get2(foo); }
    6.22 +
    6.23 +    //generic - nobound - arg - non-slilent
    6.24 +    <Z> void get3(Foo<Z> fz) { }
    6.25 +    void test(Foo foo) { get3(foo); }
    6.26 +
    6.27 +    //generic - nobound - arg - slilent
    6.28 +    <Z> void get4(Foo<?> fz) { }
    6.29 +    void test4(Foo foo) { get4(foo); }
    6.30 +
    6.31 +    //generic - bound - ret - non-slilent
    6.32 +    <Z extends Foo<String>> Z get5() { return null; }
    6.33 +    void test5() { SubFoo sf = get5(); }
    6.34 +
    6.35 +    //generic - bound - ret - slilent
    6.36 +    static <Z extends Foo<?>> Z get6() { return null; }
    6.37 +    void test6() { SubFoo sf = get6(); }
    6.38 +
    6.39 +    //nogeneric - nobound - arg - non-slilent
    6.40 +    void get7(Foo<String> fz) { }
    6.41 +    void test7(Foo foo) { get7(foo); }
    6.42 +
    6.43 +    //nogeneric - nobound - arg - slilent
    6.44 +    static void get8(Foo<?> fz) { }
    6.45 +    void test8(Foo foo) { get8(foo); }
    6.46 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/tools/javac/generics/7151802/T7151802.out	Fri Mar 09 17:10:56 2012 +0000
     7.3 @@ -0,0 +1,9 @@
     7.4 +T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802
     7.5 +T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<Z>
     7.6 +T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo<Z>, T7151802.Foo, kindname.class, T7151802
     7.7 +T7151802.java:30:36: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get5, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7151802
     7.8 +T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.String>
     7.9 +T7151802.java:38:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get7, T7151802.Foo<java.lang.String>, T7151802.Foo, kindname.class, T7151802
    7.10 +- compiler.err.warnings.and.werror
    7.11 +1 error
    7.12 +6 warnings

mercurial