APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.jdeprscan

public Class Main

extends Object
implements DiagnosticListener<JavaFileObject>
Class Inheritance
All Implemented Interfaces
javax.tools.DiagnosticListener
Imports
java.io.File, .IOException, .PrintStream, java.net.URI, java.nio.charset.StandardCharsets, java.nio.file.Files, .FileSystems, .Path, .Paths, java.util.ArrayDeque, .ArrayList, .Arrays, .Collection, .EnumSet, .HashSet, .List, .Map, .NoSuchElementException, .Set, .Queue, java.util.stream.Collectors, .IntStream, .Stream, .StreamSupport, java.util.jar.JarEntry, .JarFile, javax.tools.Diagnostic, .DiagnosticListener, .JavaCompiler, .JavaFileManager, .JavaFileObject, .JavaFileObject.Kind, .StandardJavaFileManager, .StandardLocation, .ToolProvider, com.sun.tools.javac.file.JavacFileManager, com.sun.tools.javac.platform.JDKPlatformProvider, com.sun.tools.jdeprscan.scan.Scan, javax.lang.model.element.PackageElement, .TypeElement

Deprecation Scanner tool. Loads API deprecation information from the JDK image, or optionally, from a jar file or class hierarchy. Then scans a class library for usages of those APIs.

Todo

- audit error handling throughout, but mainly in scan package - handling of covariant overrides - handling of override of method found in multiple superinterfaces - convert type/method/field output to Java source like syntax, e.g. instead of java/lang/Character.isJavaLetter(C)Z print void java.lang.Character.isJavaLetter(char)boolean - more example output in man page - more rigorous GNU style option parsing; use joptsimple? FUTURES: - add module support: --add-modules, --module-path, module arg - load deprecation declarations from a designated class library instead of the JDK - load deprecation declarations from a module - scan a module (but a modular jar can be treated just a like an ordinary jar) - multi-version jar

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum
Main.LoadMode

An enum denoting the mode in which the tool is running.

pack-priv static enum
pack-priv static class
Main.UsageException

A checked exception that's thrown if a command-line syntax error is detected.

Field Summary

Modifier and TypeField and Description
pack-priv final List<File>
pack-priv final List<File>
pack-priv final List<String>
pack-priv final JavaCompiler
pack-priv List<DeprData>
pack-priv final PrintStream
pack-priv final StandardJavaFileManager
pack-priv boolean
pack-priv final List<String>
pack-priv final PrintStream
pack-priv final Set<String>
pack-priv final Set<String>
pack-priv final List<File>
pack-priv final Set<String>
pack-priv boolean

Constructor Summary

AccessConstructor and Description
pack-priv
Main(PrintStream
the stream to which the tool's output is sent
out
,
PrintStream
the stream to which error messages are sent
err
)

Constructs an instance of the finder tool.

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true on success, false otherwise
call
(PrintStream out, PrintStream err, String... args)

Programmatic main entry point: initializes the tool instance to use stdout and stderr; runs the tool, passing command-line args; returns an exit status.

pack-priv String

Returns:

the modular classname
convertModularFileName
(String
the input filename
filename
)

Replaces all but the first occurrence of '/' with '.'.

pack-priv boolean

Returns:

true for success, false for failure
doClassNames
(Collection<String>
collection of fully qualified classnames to process
classNames
)

Processes a collection of class names.

pack-priv boolean

Returns:

true for success, false for failure
doFileNames
(Stream<String>
a Stream of filenames to process
filenames
)

Processes a stream of filenames (strings).

pack-priv boolean

Returns:

true for success, false for failure
doJarFile
(String
the name of the jar file to process
jarname
)

Processes all class files in the given jar file.

pack-priv boolean

Returns:

true for success, false for failure
doModularFileNames
(Stream<String>
a Stream of filenames to process
filenames
)

Processes a stream of filenames (strings) including a module prefix.

public static void
main(String[] args)

Calls the main entry point and exits the JVM with an exit status determined by the return status.

private void
pack-priv boolean

Returns:

true for success, false for failure
processDirectory
(String
the name of the directory to process
dirname
,
Collection<String>
the names of classes to process
classNames
)

Processes named class files in the given directory.

pack-priv boolean

Returns:

true for success, false for failure
processJarFile
(String
the name of the jar file to process
jarname
,
Collection<String>
the names of classes to process
classNames
)

Processes named class files from the given jar file, or all classes if classNames is empty.

pack-priv boolean
processJdk9(String jdkHome, Collection<String> classes)

Processes listed classes given a JDK 9 home.

pack-priv boolean

Returns:

true for success, false for failure
processOldJdk
(String
the path to the "home" of the JDK to process
jdkHome
,
Collection<String>
the names of classes to process
classNames
)

Processes named class files from rt.jar of a JDK version 7 or 8.

pack-priv boolean

Returns:

success value
processRelease
(String
a supported release version, like "8" or "10".
release
,
Collection<String>
collection of classes to process, may be empty
classes
)

Process classes from a particular JDK release, using only information in this JDK.

pack-priv boolean

Returns:

true for success, false for failure
processSelf
(Collection<String> classes)

Processes the class files from the currently running JDK, using the jrt: filesystem.

public void
report(Diagnostic<? extends JavaFileObject>
the tool diagnostic to print
diagnostic
)

Implements javax.tools.DiagnosticListener.report.

Prints the diagnostic to the err stream.

pack-priv void
require(boolean
the condition that's required to be true
cond
)

Convenience method to throw UsageException if a condition is false.

pack-priv boolean

Returns:

true on success, false on error
run
(String...
command-line arguments
argArray
)

Parses arguments and performs the requested processing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bootClassPathback to summary
pack-priv final List<File> bootClassPath
classPathback to summary
pack-priv final List<File> classPath
commentsback to summary
pack-priv final List<String> comments
compilerback to summary
pack-priv final JavaCompiler compiler
deprListback to summary
pack-priv List<DeprData> deprList
errback to summary
pack-priv final PrintStream err
fmback to summary
pack-priv final StandardJavaFileManager fm
forRemovalback to summary
pack-priv boolean forRemoval
optionsback to summary
pack-priv final List<String> options
outback to summary
pack-priv final PrintStream out
releasesWithForRemovalback to summary
pack-priv final Set<String> releasesWithForRemoval
releasesWithoutForRemovalback to summary
pack-priv final Set<String> releasesWithoutForRemoval
systemModulesback to summary
pack-priv final List<File> systemModules
validReleasesback to summary
pack-priv final Set<String> validReleases
verboseback to summary
pack-priv boolean verbose

Constructor Detail

Mainback to summary
pack-priv Main(PrintStream out, PrintStream err)

Constructs an instance of the finder tool.

Parameters
out:PrintStream

the stream to which the tool's output is sent

err:PrintStream

the stream to which error messages are sent

Method Detail

callback to summary
public static boolean call(PrintStream out, PrintStream err, String... args)

Programmatic main entry point: initializes the tool instance to use stdout and stderr; runs the tool, passing command-line args; returns an exit status.

Returns:boolean

true on success, false otherwise

convertModularFileNameback to summary
pack-priv String convertModularFileName(String filename)

Replaces all but the first occurrence of '/' with '.'. Assumes that the name is in the format module/pkg/pkg/classname.class. That is, the name should contain at least one '/' character separating the module name from the package-class name.

Parameters
filename:String

the input filename

Returns:String

the modular classname

doClassNamesback to summary
pack-priv boolean doClassNames(Collection<String> classNames) throws IOException

Processes a collection of class names. Names should fully qualified names in the form "pkg.pkg.pkg.classname".

Parameters
classNames:Collection<String>

collection of fully qualified classnames to process

Returns:boolean

true for success, false for failure

Exceptions
IOException:
if an I/O error occurs
doFileNamesback to summary
pack-priv boolean doFileNames(Stream<String> filenames) throws IOException

Processes a stream of filenames (strings). The strings are in the form pkg/pkg/pkg/classname.class relative to the root of a package hierarchy.

Parameters
filenames:Stream<String>

a Stream of filenames to process

Returns:boolean

true for success, false for failure

Exceptions
IOException:
if an I/O error occurs
doJarFileback to summary
pack-priv boolean doJarFile(String jarname) throws IOException

Processes all class files in the given jar file.

Parameters
jarname:String

the name of the jar file to process

Returns:boolean

true for success, false for failure

Exceptions
IOException:
if an I/O error occurs
doModularFileNamesback to summary
pack-priv boolean doModularFileNames(Stream<String> filenames) throws IOException

Processes a stream of filenames (strings) including a module prefix. The strings are in the form module/pkg/pkg/pkg/classname.class relative to the root of a directory containing modules. The strings are processed into module-qualified class names of the form "module/pkg.pkg.pkg.classname".

Parameters
filenames:Stream<String>

a Stream of filenames to process

Returns:boolean

true for success, false for failure

Exceptions
IOException:
if an I/O error occurs
mainback to summary
public static void main(String[] args)

Calls the main entry point and exits the JVM with an exit status determined by the return status.

printHelpback to summary
private void printHelp(PrintStream out)
processDirectoryback to summary
pack-priv boolean processDirectory(String dirname, Collection<String> classNames) throws IOException

Processes named class files in the given directory. The directory should be the root of a package hierarchy. If classNames is empty, walks the directory hierarchy to find all classes.

Parameters
dirname:String

the name of the directory to process

classNames:Collection<String>

the names of classes to process

Returns:boolean

true for success, false for failure

Exceptions
IOException:
if an I/O error occurs
processJarFileback to summary
pack-priv boolean processJarFile(String jarname, Collection<String> classNames) throws IOException

Processes named class files from the given jar file, or all classes if classNames is empty.

Parameters
jarname:String

the name of the jar file to process

classNames:Collection<String>

the names of classes to process

Returns:boolean

true for success, false for failure

Exceptions
IOException:
if an I/O error occurs
processJdk9back to summary
pack-priv boolean processJdk9(String jdkHome, Collection<String> classes) throws IOException

Processes listed classes given a JDK 9 home.

processOldJdkback to summary
pack-priv boolean processOldJdk(String jdkHome, Collection<String> classNames) throws IOException

Processes named class files from rt.jar of a JDK version 7 or 8. If classNames is empty, processes all classes.

Parameters
jdkHome:String

the path to the "home" of the JDK to process

classNames:Collection<String>

the names of classes to process

Returns:boolean

true for success, false for failure

Exceptions
IOException:
if an I/O error occurs
processReleaseback to summary
pack-priv boolean processRelease(String release, Collection<String> classes) throws IOException

Process classes from a particular JDK release, using only information in this JDK.

Parameters
release:String

a supported release version, like "8" or "10".

classes:Collection<String>

collection of classes to process, may be empty

Returns:boolean

success value

processSelfback to summary
pack-priv boolean processSelf(Collection<String> classes) throws IOException

Processes the class files from the currently running JDK, using the jrt: filesystem.

Returns:boolean

true for success, false for failure

Exceptions
IOException:
if an I/O error occurs
reportback to summary
public void report(Diagnostic<? extends JavaFileObject> diagnostic)

Implements javax.tools.DiagnosticListener.report.

Prints the diagnostic to the err stream. Specified by the DiagnosticListener interface.

Parameters
diagnostic:Diagnostic<? extends JavaFileObject>

the tool diagnostic to print

Annotations
@Override
requireback to summary
pack-priv void require(boolean cond) throws UsageException

Convenience method to throw UsageException if a condition is false.

Parameters
cond:boolean

the condition that's required to be true

runback to summary
pack-priv boolean run(String... argArray)

Parses arguments and performs the requested processing.

Parameters
argArray:String[]

command-line arguments

Returns:boolean

true on success, false on error

com.sun.tools.jdeprscan back to summary

pack-priv final Enum Main.LoadMode

extends Enum<Main.LoadMode>
Class Inheritance

An enum denoting the mode in which the tool is running. Different modes correspond to the different process* methods. The exception is UNKNOWN, which indicates that a mode wasn't specified on the command line, which is an error.

Field Summary

Modifier and TypeField and Description
public static final Main.LoadMode
public static final Main.LoadMode
public static final Main.LoadMode
public static final Main.LoadMode
public static final Main.LoadMode
public static final Main.LoadMode
public static final Main.LoadMode
public static final Main.LoadMode

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Main.LoadMode
public static Main.LoadMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLASSESback to summary
public static final Main.LoadMode CLASSES
DIRback to summary
public static final Main.LoadMode DIR
JARback to summary
public static final Main.LoadMode JAR
JDK9back to summary
public static final Main.LoadMode JDK9
LOAD_CSVback to summary
public static final Main.LoadMode LOAD_CSV
OLD_JDKback to summary
public static final Main.LoadMode OLD_JDK
RELEASEback to summary
public static final Main.LoadMode RELEASE
SELFback to summary
public static final Main.LoadMode SELF

Constructor Detail

LoadModeback to summary
private LoadMode()

Method Detail

valueOfback to summary
public static Main.LoadMode valueOf(String name)
valuesback to summary
public static Main.LoadMode[] values()
com.sun.tools.jdeprscan back to summary

pack-priv final Enum Main.ScanMode

extends Enum<Main.ScanMode>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Main.ScanMode
public static final Main.ScanMode
public static final Main.ScanMode

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Main.ScanMode
public static Main.ScanMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ARGSback to summary
public static final Main.ScanMode ARGS
LISTback to summary
public static final Main.ScanMode LIST
PRINT_CSVback to summary
public static final Main.ScanMode PRINT_CSV

Constructor Detail

ScanModeback to summary
private ScanMode()

Method Detail

valueOfback to summary
public static Main.ScanMode valueOf(String name)
valuesback to summary
public static Main.ScanMode[] values()
com.sun.tools.jdeprscan back to summary

pack-priv Class Main.UsageException

extends Exception
Class Inheritance

A checked exception that's thrown if a command-line syntax error is detected.

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

UsageExceptionback to summary
pack-priv UsageException()