view src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/ @ 48562:0cd5e2ca53dd

8193476: (jdeprscan) additional version updates for JDK 10 Reviewed-by: darcy
author smarks
date Wed, 13 Dec 2017 14:23:34 -0800
parents 71c04702a3d5
children a6c4b85163c1
line wrap: on
line source

Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

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.  Oracle designates this
particular file as subject to the "Classpath" exception as provided
by Oracle in the LICENSE file that accompanied this code.

This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 if you need additional information or have any


JDeprScan Tool Command Reference


        jdeprscan - Java deprecation scanner


        jdeprscan [options] {dir | jar | class} ...


        --class-path PATH

            Sets the classpath to PATH.


            Limit reporting to deprecations whose forRemoval element
            is true.


            Prints the full version string of the tool and exits.


            Prints a help message and exits.


            Prints out the set of deprecated APIs.

        --release 6|7|8|9|10

            Specifies the Java SE release that is the source of
            the list of deprecated APIs. If no --release option is
            provided, the latest release is used.


            Enables additional output.


            Prints the version string of the tool and exits.


**jdeprscan** scans a class library for uses of deprecated APIs.
**jdeprscan** processes one or more arguments, which can be any
combination of a directory, a jar file, or a class name.

A directory argument must specify a path to a directory hierarchy that
reflects the Java package hierarchy of the classes it contains.
**jdeprscan** will scan each class found in the directory hierarchy
and report information about how those classes use deprecated APIs.

Given a jar file, **jdeprscan** will scan the classes found within
that jar file and report information about how those classes use
deprecated APIs.

Given a class file, **jdeprscan** will scan that class and report
its use of deprecated APIs.

Given a class name, **jdeprscan** will search for that class on the
classpath, scan that class, and report information about how that
class uses deprecated APIs. The class name must use the fully
qualified binary name of the class, as described in the
[Java Language Specification, section 13.1][jls131]. This form uses
the '$' character instead of '.' as the separator for nested class names.
For example, the `Thread.State` enum would be specified using the string


The `--class-path` option specifies the classpath used for
class searching. The classpath is used for classes named on the
command line, as well as for dependencies of the classes in jar file
or directory hierarchy to be scanned.

The `--for-removal` option limits output to uses of deprecated APIs
whose `@Deprecated` annotation includes the `forRemoval` element with
the value `true`. Note: the `forRemoval` attribute of the
`@Deprecated` annotation did not exist prior to Java SE 9, so this
option cannot be used with a release value of 6, 7, or 8.

The `--release` option specifies the Java SE specification version
that determines the set of deprecated APIs for which scanning is
done. This is useful if a deprecation report is desired that lists
uses of deprecated APIs as of a particular release in the past. If no
`--release` option is given, the latest release is used.

The `--list` and `-l` options will list the known set of deprecated
APIs instead of doing any scanning. Since no scanning is done,
no directory, jar, or class arguments should be provided. The set
of deprecated APIs listed is affected by the `--release` and the
`--for-removal` options.


The output is a report that lists program elements that use deprecated
APIs. Output is subject to change.

Consider the following declarations from Java SE 9:

        // java.lang.Boolean

        public Boolean(boolean value)

        // java.lang.Runtime

        @Deprecated(since="1.2", forRemoval=true)
        public static void runFinalizersOnExit(boolean value)

Running **jdeprscan** over a class that calls these methods will result
in output something like the following:

        class Example uses method java/lang/Boolean.<init>(Z)V deprecated
        class Example uses method java/lang/Runtime.runFinalizersOnExit(Z)V deprecated for removal

Running **jdeprscan** with the `--list` option will result in output
including something like the following:

        @Deprecated(since="9") java.lang.Boolean(boolean)
        @Deprecated(since="1.2", forRemoval=true) void java.lang.Runtime.runFinalizersOnExit(boolean)


The **jdeprscan** tool operates by opening Java class files and
reading their structures directly, particularly the constant
pool. Because of this, **jdeprscan** can tell _that_ a deprecated API
is used, but it often cannot tell _where_ in the class that API is

The **jdeprscan** tool doesn't follow the same set of rules for
emitting warnings as specified for Java compilers in [JLS section][jls9646]. In particular, **jdeprscan** does not respond to
the `@SuppressWarnings` annotation, as that is significant only in
source code, not in class files. In addition, **jdeprscan** emits
warnings even if the usage is within the API element that is
deprecated and when the use and declaration are within the same
outermost class.