6594914: @SuppressWarnings("deprecation") does not not work for the type of a variable

Thu, 03 Feb 2011 09:35:21 +0000

author
mcimadamore
date
Thu, 03 Feb 2011 09:35:21 +0000
changeset 852
899f7c3d9426
parent 851
cad51b6eb7a6
child 853
875262e89b52

6594914: @SuppressWarnings("deprecation") does not not work for the type of a variable
Summary: Lint warnings generated during MemberEnter might ignore @SuppressWarnings annotations
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java file | annotate | diff | comparison | revisions
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/MemberEnter.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Resolve.java file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/DeprecatedClass.java file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/T6594914a.java file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/T6594914a.out file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/T6594914b.java file | annotate | diff | comparison | revisions
test/tools/javac/warnings/6594914/T6594914b.out file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/DeferredLintHandler.java	Thu Feb 03 09:35:21 2011 +0000
     1.3 @@ -0,0 +1,95 @@
     1.4 +/*
     1.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.javac.code;
    1.30 +
    1.31 +import java.util.HashMap;
    1.32 +import java.util.Map;
    1.33 +
    1.34 +import com.sun.tools.javac.util.Assert;
    1.35 +import com.sun.tools.javac.util.Context;
    1.36 +import com.sun.tools.javac.util.ListBuffer;
    1.37 +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    1.38 +
    1.39 +/**
    1.40 + *
    1.41 + * <p><b>This is NOT part of any supported API.
    1.42 + * If you write code that depends on this, you do so at your own risk.
    1.43 + * This code and its internal interfaces are subject to change or
    1.44 + * deletion without notice.</b>
    1.45 + */
    1.46 +public class DeferredLintHandler {
    1.47 +    protected static final Context.Key<DeferredLintHandler> deferredLintHandlerKey =
    1.48 +        new Context.Key<DeferredLintHandler>();
    1.49 +
    1.50 +    public static DeferredLintHandler instance(Context context) {
    1.51 +        DeferredLintHandler instance = context.get(deferredLintHandlerKey);
    1.52 +        if (instance == null)
    1.53 +            instance = new DeferredLintHandler(context);
    1.54 +        return instance;
    1.55 +    }
    1.56 +
    1.57 +    protected DeferredLintHandler(Context context) {
    1.58 +        context.put(deferredLintHandlerKey, this);
    1.59 +    }
    1.60 +
    1.61 +    private DeferredLintHandler() {}
    1.62 +
    1.63 +    public interface LintLogger {
    1.64 +        void report();
    1.65 +    }
    1.66 +
    1.67 +    private DiagnosticPosition currentPos;
    1.68 +    private Map<DiagnosticPosition, ListBuffer<LintLogger>> loggersQueue = new HashMap<DiagnosticPosition, ListBuffer<LintLogger>>();
    1.69 +
    1.70 +    public void report(LintLogger logger) {
    1.71 +        ListBuffer<LintLogger> loggers = loggersQueue.get(currentPos);
    1.72 +        Assert.checkNonNull(loggers);
    1.73 +        loggers.append(logger);
    1.74 +    }
    1.75 +
    1.76 +    public void flush(DiagnosticPosition pos) {
    1.77 +        ListBuffer<LintLogger> loggers = loggersQueue.get(pos);
    1.78 +        if (loggers != null) {
    1.79 +            for (LintLogger lintLogger : loggers) {
    1.80 +                lintLogger.report();
    1.81 +            }
    1.82 +            loggersQueue.remove(pos);
    1.83 +        }
    1.84 +    }
    1.85 +
    1.86 +    public DeferredLintHandler setPos(DiagnosticPosition currentPos) {
    1.87 +        this.currentPos = currentPos;
    1.88 +        loggersQueue.put(currentPos, ListBuffer.<LintLogger>lb());
    1.89 +        return this;
    1.90 +    }
    1.91 +
    1.92 +    public static final DeferredLintHandler immediateHandler = new DeferredLintHandler() {
    1.93 +        @Override
    1.94 +        public void report(LintLogger logger) {
    1.95 +            logger.report();
    1.96 +        }
    1.97 +    };
    1.98 +}
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Feb 01 10:11:05 2011 -0800
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Feb 03 09:35:21 2011 +0000
     2.3 @@ -83,6 +83,7 @@
     2.4      final Types types;
     2.5      final JCDiagnostic.Factory diags;
     2.6      final Annotate annotate;
     2.7 +    final DeferredLintHandler deferredLintHandler;
     2.8  
     2.9      public static Attr instance(Context context) {
    2.10          Attr instance = context.get(attrKey);
    2.11 @@ -108,6 +109,7 @@
    2.12          types = Types.instance(context);
    2.13          diags = JCDiagnostic.Factory.instance(context);
    2.14          annotate = Annotate.instance(context);
    2.15 +        deferredLintHandler = DeferredLintHandler.instance(context);
    2.16  
    2.17          Options options = Options.instance(context);
    2.18  
    2.19 @@ -125,7 +127,6 @@
    2.20          findDiamonds = options.get("findDiamond") != null &&
    2.21                   source.allowDiamond();
    2.22          useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
    2.23 -        enableSunApiLintControl = options.isSet("enableSunApiLintControl");
    2.24      }
    2.25  
    2.26      /** Switch: relax some constraints for retrofit mode.
    2.27 @@ -174,12 +175,6 @@
    2.28      boolean useBeforeDeclarationWarning;
    2.29  
    2.30      /**
    2.31 -     * Switch: allow lint infrastructure to control proprietary
    2.32 -     * API warnings.
    2.33 -     */
    2.34 -    boolean enableSunApiLintControl;
    2.35 -
    2.36 -    /**
    2.37       * Switch: allow strings in switch?
    2.38       */
    2.39      boolean allowStringsInSwitch;
    2.40 @@ -707,6 +702,7 @@
    2.41          Lint prevLint = chk.setLint(lint);
    2.42          MethodSymbol prevMethod = chk.setMethod(m);
    2.43          try {
    2.44 +            deferredLintHandler.flush(tree.pos());
    2.45              chk.checkDeprecatedAnnotation(tree.pos(), m);
    2.46  
    2.47              attribBounds(tree.typarams);
    2.48 @@ -849,6 +845,7 @@
    2.49  
    2.50          // Check that the variable's declared type is well-formed.
    2.51          chk.validate(tree.vartype, env);
    2.52 +        deferredLintHandler.flush(tree.pos());
    2.53  
    2.54          try {
    2.55              chk.checkDeprecatedAnnotation(tree.pos(), v);
    2.56 @@ -2578,17 +2575,10 @@
    2.57              // Test (1): emit a `deprecation' warning if symbol is deprecated.
    2.58              // (for constructors, the error was given when the constructor was
    2.59              // resolved)
    2.60 -            if (sym.name != names.init &&
    2.61 -                (sym.flags() & DEPRECATED) != 0 &&
    2.62 -                (env.info.scope.owner.flags() & DEPRECATED) == 0 &&
    2.63 -                sym.outermostClass() != env.info.scope.owner.outermostClass())
    2.64 -                chk.warnDeprecated(tree.pos(), sym);
    2.65 -
    2.66 -            if ((sym.flags() & PROPRIETARY) != 0) {
    2.67 -                if (enableSunApiLintControl)
    2.68 -                  chk.warnSunApi(tree.pos(), "sun.proprietary", sym);
    2.69 -                else
    2.70 -                  log.strictWarning(tree.pos(), "sun.proprietary", sym);
    2.71 +
    2.72 +            if (sym.name != names.init) {
    2.73 +                chk.checkDeprecated(tree.pos(), env.info.scope.owner, sym);
    2.74 +                chk.checkSunAPI(tree.pos(), sym);
    2.75              }
    2.76  
    2.77              // Test (3): if symbol is a variable, check that its type and
     3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Feb 01 10:11:05 2011 -0800
     3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Feb 03 09:35:21 2011 +0000
     3.3 @@ -60,7 +60,6 @@
     3.4  
     3.5      private final Names names;
     3.6      private final Log log;
     3.7 -    private final Resolve rs;
     3.8      private final Symtab syms;
     3.9      private final Enter enter;
    3.10      private final Infer infer;
    3.11 @@ -69,6 +68,7 @@
    3.12      private final boolean skipAnnotations;
    3.13      private boolean warnOnSyntheticConflicts;
    3.14      private boolean suppressAbortOnBadClassFile;
    3.15 +    private boolean enableSunApiLintControl;
    3.16      private final TreeInfo treeinfo;
    3.17  
    3.18      // The set of lint options currently in effect. It is initialized
    3.19 @@ -92,7 +92,6 @@
    3.20  
    3.21          names = Names.instance(context);
    3.22          log = Log.instance(context);
    3.23 -        rs = Resolve.instance(context);
    3.24          syms = Symtab.instance(context);
    3.25          enter = Enter.instance(context);
    3.26          infer = Infer.instance(context);
    3.27 @@ -111,13 +110,13 @@
    3.28          skipAnnotations = options.isSet("skipAnnotations");
    3.29          warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
    3.30          suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
    3.31 +        enableSunApiLintControl = options.isSet("enableSunApiLintControl");
    3.32  
    3.33          Target target = Target.instance(context);
    3.34          syntheticNameChar = target.syntheticNameChar();
    3.35  
    3.36          boolean verboseDeprecated = lint.isEnabled(LintCategory.DEPRECATION);
    3.37          boolean verboseUnchecked = lint.isEnabled(LintCategory.UNCHECKED);
    3.38 -        boolean verboseVarargs = lint.isEnabled(LintCategory.VARARGS);
    3.39          boolean verboseSunApi = lint.isEnabled(LintCategory.SUNAPI);
    3.40          boolean enforceMandatoryWarnings = source.enforceMandatoryWarnings();
    3.41  
    3.42 @@ -125,10 +124,10 @@
    3.43                  enforceMandatoryWarnings, "deprecated", LintCategory.DEPRECATION);
    3.44          uncheckedHandler = new MandatoryWarningHandler(log, verboseUnchecked,
    3.45                  enforceMandatoryWarnings, "unchecked", LintCategory.UNCHECKED);
    3.46 -        unsafeVarargsHandler = new MandatoryWarningHandler(log, verboseVarargs,
    3.47 -                enforceMandatoryWarnings, "varargs", LintCategory.VARARGS);
    3.48          sunApiHandler = new MandatoryWarningHandler(log, verboseSunApi,
    3.49                  enforceMandatoryWarnings, "sunapi", null);
    3.50 +
    3.51 +        deferredLintHandler = DeferredLintHandler.immediateHandler;
    3.52      }
    3.53  
    3.54      /** Switch: generics enabled?
    3.55 @@ -168,14 +167,14 @@
    3.56       */
    3.57      private MandatoryWarningHandler uncheckedHandler;
    3.58  
    3.59 -    /** A handler for messages about unchecked or unsafe vararg method decl.
    3.60 -     */
    3.61 -    private MandatoryWarningHandler unsafeVarargsHandler;
    3.62 -
    3.63      /** A handler for messages about using proprietary API.
    3.64       */
    3.65      private MandatoryWarningHandler sunApiHandler;
    3.66  
    3.67 +    /** A handler for deferred lint warnings.
    3.68 +     */
    3.69 +    private DeferredLintHandler deferredLintHandler;
    3.70 +
    3.71  /* *************************************************************************
    3.72   * Errors and Warnings
    3.73   **************************************************************************/
    3.74 @@ -186,6 +185,12 @@
    3.75          return prev;
    3.76      }
    3.77  
    3.78 +    DeferredLintHandler setDeferredLintHandler(DeferredLintHandler newDeferredLintHandler) {
    3.79 +        DeferredLintHandler prev = deferredLintHandler;
    3.80 +        deferredLintHandler = newDeferredLintHandler;
    3.81 +        return prev;
    3.82 +    }
    3.83 +
    3.84      MethodSymbol setMethod(MethodSymbol newMethod) {
    3.85          MethodSymbol prev = method;
    3.86          method = newMethod;
    3.87 @@ -1096,6 +1101,7 @@
    3.88                      log.error(tree.pos(), "improperly.formed.type.param.missing");
    3.89              }
    3.90          }
    3.91 +
    3.92          public void visitSelectInternal(JCFieldAccess tree) {
    3.93              if (tree.type.tsym.isStatic() &&
    3.94                  tree.selected.type.isParameterized()) {
    3.95 @@ -1465,11 +1471,8 @@
    3.96          }
    3.97  
    3.98          // Warn if a deprecated method overridden by a non-deprecated one.
    3.99 -        if ((other.flags() & DEPRECATED) != 0
   3.100 -            && (m.flags() & DEPRECATED) == 0
   3.101 -            && m.outermostClass() != other.outermostClass()
   3.102 -            && !isDeprecatedOverrideIgnorable(other, origin)) {
   3.103 -            warnDeprecated(TreeInfo.diagnosticPositionFor(m, tree), other);
   3.104 +        if (!isDeprecatedOverrideIgnorable(other, origin)) {
   3.105 +            checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other);
   3.106          }
   3.107      }
   3.108      // where
   3.109 @@ -2412,6 +2415,32 @@
   3.110          }
   3.111      }
   3.112  
   3.113 +    void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) {
   3.114 +        if ((s.flags() & DEPRECATED) != 0 &&
   3.115 +                (other.flags() & DEPRECATED) == 0 &&
   3.116 +                s.outermostClass() != other.outermostClass()) {
   3.117 +            deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
   3.118 +                @Override
   3.119 +                public void report() {
   3.120 +                    warnDeprecated(pos, s);
   3.121 +                }
   3.122 +            });
   3.123 +        };
   3.124 +    }
   3.125 +
   3.126 +    void checkSunAPI(final DiagnosticPosition pos, final Symbol s) {
   3.127 +        if ((s.flags() & PROPRIETARY) != 0) {
   3.128 +            deferredLintHandler.report(new DeferredLintHandler.LintLogger() {
   3.129 +                public void report() {
   3.130 +                    if (enableSunApiLintControl)
   3.131 +                      warnSunApi(pos, "sun.proprietary", s);
   3.132 +                    else
   3.133 +                      log.strictWarning(pos, "sun.proprietary", s);
   3.134 +                }
   3.135 +            });
   3.136 +        }
   3.137 +    }
   3.138 +
   3.139  /* *************************************************************************
   3.140   * Check for recursive annotation elements.
   3.141   **************************************************************************/
     4.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Feb 01 10:11:05 2011 -0800
     4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Feb 03 09:35:21 2011 +0000
     4.3 @@ -75,9 +75,9 @@
     4.4      private final Types types;
     4.5      private final JCDiagnostic.Factory diags;
     4.6      private final Target target;
     4.7 +    private final DeferredLintHandler deferredLintHandler;
     4.8  
     4.9      private final boolean skipAnnotations;
    4.10 -    private final boolean allowSimplifiedVarargs;
    4.11  
    4.12      public static MemberEnter instance(Context context) {
    4.13          MemberEnter instance = context.get(memberEnterKey);
    4.14 @@ -102,10 +102,9 @@
    4.15          types = Types.instance(context);
    4.16          diags = JCDiagnostic.Factory.instance(context);
    4.17          target = Target.instance(context);
    4.18 +        deferredLintHandler = DeferredLintHandler.instance(context);
    4.19          Options options = Options.instance(context);
    4.20          skipAnnotations = options.isSet("skipAnnotations");
    4.21 -        Source source = Source.instance(context);
    4.22 -        allowSimplifiedVarargs = source.allowSimplifiedVarargs();
    4.23      }
    4.24  
    4.25      /** A queue for classes whose members still need to be entered into the
    4.26 @@ -571,10 +570,16 @@
    4.27          tree.sym = m;
    4.28          Env<AttrContext> localEnv = methodEnv(tree, env);
    4.29  
    4.30 -        // Compute the method type
    4.31 -        m.type = signature(tree.typarams, tree.params,
    4.32 -                           tree.restype, tree.thrown,
    4.33 -                           localEnv);
    4.34 +        DeferredLintHandler prevLintHandler =
    4.35 +                chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
    4.36 +        try {
    4.37 +            // Compute the method type
    4.38 +            m.type = signature(tree.typarams, tree.params,
    4.39 +                               tree.restype, tree.thrown,
    4.40 +                               localEnv);
    4.41 +        } finally {
    4.42 +            chk.setDeferredLintHandler(prevLintHandler);
    4.43 +        }
    4.44  
    4.45          // Set m.params
    4.46          ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>();
    4.47 @@ -618,7 +623,14 @@
    4.48              localEnv = env.dup(tree, env.info.dup());
    4.49              localEnv.info.staticLevel++;
    4.50          }
    4.51 -        attr.attribType(tree.vartype, localEnv);
    4.52 +        DeferredLintHandler prevLintHandler =
    4.53 +                chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
    4.54 +        try {
    4.55 +            attr.attribType(tree.vartype, localEnv);
    4.56 +        } finally {
    4.57 +            chk.setDeferredLintHandler(prevLintHandler);
    4.58 +        }
    4.59 +
    4.60          if ((tree.mods.flags & VARARGS) != 0) {
    4.61              //if we are entering a varargs parameter, we need to replace its type
    4.62              //(a plain array type) with the more precise VarargsType --- we need
     5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Tue Feb 01 10:11:05 2011 -0800
     5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Feb 03 09:35:21 2011 +0000
     5.3 @@ -1638,10 +1638,7 @@
     5.4                                  names.init, argtypes,
     5.5                                  typeargtypes, allowBoxing,
     5.6                                  useVarargs, false);
     5.7 -        if ((sym.flags() & DEPRECATED) != 0 &&
     5.8 -            (env.info.scope.owner.flags() & DEPRECATED) == 0 &&
     5.9 -            env.info.scope.owner.outermostClass() != sym.outermostClass())
    5.10 -            chk.warnDeprecated(pos, sym);
    5.11 +        chk.checkDeprecated(pos, env.info.scope.owner, sym);
    5.12          return sym;
    5.13      }
    5.14  
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/javac/warnings/6594914/DeprecatedClass.java	Thu Feb 03 09:35:21 2011 +0000
     6.3 @@ -0,0 +1,25 @@
     6.4 +/*
     6.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 + * or visit www.oracle.com if you need additional information or have any
    6.24 + * questions.
    6.25 + */
    6.26 +
    6.27 +@Deprecated
    6.28 +class DeprecatedClass extends Exception {}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/tools/javac/warnings/6594914/T6594914a.java	Thu Feb 03 09:35:21 2011 +0000
     7.3 @@ -0,0 +1,29 @@
     7.4 +/**
     7.5 + * @test /nodynamiccopyright/
     7.6 + * @bug 6594914
     7.7 + * @summary \\@SuppressWarnings("deprecation") does not not work for the type of a variable
     7.8 + * @compile/ref=T6594914a.out -XDrawDiagnostics -Xlint:deprecation T6594914a.java
     7.9 + */
    7.10 +
    7.11 +
    7.12 +class T6747671a {
    7.13 +
    7.14 +    DeprecatedClass a1; //warn
    7.15 +
    7.16 +    @SuppressWarnings("deprecation")
    7.17 +    DeprecatedClass a2;
    7.18 +
    7.19 +    <X extends DeprecatedClass> DeprecatedClass m1(DeprecatedClass a)
    7.20 +            throws DeprecatedClass { return null; } //warn
    7.21 +
    7.22 +    @SuppressWarnings("deprecation")
    7.23 +    <X extends DeprecatedClass> DeprecatedClass m2(DeprecatedClass a)
    7.24 +            throws DeprecatedClass { return null; }
    7.25 +
    7.26 +    void test() {
    7.27 +        DeprecatedClass a1; //warn
    7.28 +
    7.29 +        @SuppressWarnings("deprecation")
    7.30 +        DeprecatedClass a2;
    7.31 +    }
    7.32 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/tools/javac/warnings/6594914/T6594914a.out	Thu Feb 03 09:35:21 2011 +0000
     8.3 @@ -0,0 +1,7 @@
     8.4 +T6594914a.java:11:5: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
     8.5 +T6594914a.java:16:16: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
     8.6 +T6594914a.java:16:52: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
     8.7 +T6594914a.java:16:33: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
     8.8 +T6594914a.java:17:20: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
     8.9 +T6594914a.java:24:9: compiler.warn.has.been.deprecated: DeprecatedClass, compiler.misc.unnamed.package
    8.10 +6 warnings
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/tools/javac/warnings/6594914/T6594914b.java	Thu Feb 03 09:35:21 2011 +0000
     9.3 @@ -0,0 +1,29 @@
     9.4 +/**
     9.5 + * @test /nodynamiccopyright/
     9.6 + * @bug 6594914
     9.7 + * @summary \\@SuppressWarnings("deprecation") does not not work for the type of a variable
     9.8 + * @compile/ref=T6594914b.out -XDenableSunApiLintControl -XDrawDiagnostics -Xlint:sunapi T6594914b.java
     9.9 + */
    9.10 +
    9.11 +
    9.12 +class T6747671b {
    9.13 +
    9.14 +    sun.misc.Lock a1; //warn
    9.15 +
    9.16 +    @SuppressWarnings("sunapi")
    9.17 +    sun.misc.Lock a2;
    9.18 +
    9.19 +    <X extends sun.misc.Lock> sun.misc.Lock m1(sun.misc.Lock a)
    9.20 +            throws sun.misc.CEFormatException { return null; } //warn
    9.21 +
    9.22 +    @SuppressWarnings("sunapi")
    9.23 +    <X extends sun.misc.Lock> sun.misc.Lock m2(sun.misc.Lock a)
    9.24 +            throws sun.misc.CEFormatException { return null; }
    9.25 +
    9.26 +    void test() {
    9.27 +        sun.misc.Lock a1; //warn
    9.28 +
    9.29 +        @SuppressWarnings("sunapi")
    9.30 +        sun.misc.Lock a2;
    9.31 +    }
    9.32 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/tools/javac/warnings/6594914/T6594914b.out	Thu Feb 03 09:35:21 2011 +0000
    10.3 @@ -0,0 +1,7 @@
    10.4 +T6594914b.java:11:13: compiler.warn.sun.proprietary: sun.misc.Lock
    10.5 +T6594914b.java:16:24: compiler.warn.sun.proprietary: sun.misc.Lock
    10.6 +T6594914b.java:16:56: compiler.warn.sun.proprietary: sun.misc.Lock
    10.7 +T6594914b.java:16:39: compiler.warn.sun.proprietary: sun.misc.Lock
    10.8 +T6594914b.java:17:28: compiler.warn.sun.proprietary: sun.misc.CEFormatException
    10.9 +T6594914b.java:24:17: compiler.warn.sun.proprietary: sun.misc.Lock
   10.10 +6 warnings

mercurial