JDEPRSCAN(1)
hey bestie, welcome to the jdeprscan(1) page from the JDK Commands section β this tool is literally a static analysis icon and we're gonna get into all of it. π
β¨ NAME β¨
okay so jdeprscan is a static analysis tool that scans a jar file (or some other aggregation of class files) for uses of deprecated API elements. no cap, that's the whole vibe check. π
β¨ SYNOPSIS β¨
- **`options`** β see Options for the jdeprscan Command (down below, bestie)
- **`dir|jar|class`** β the `jdeprscan` command scans each argument for usages of deprecated APIs. the arguments can be a:
- **`dir`**: Directory
- **`jar`**: JAR file
- **`class`**: Class name or class file
the class name should use a dot (`.`) as a separator. for example:
for nested classes, the dollar sign $ separator character should be used. for example:
a class file can also be named. for example:
β¨ DESCRIPTION β¨
the jdeprscan tool is a static analysis tool provided by the JDK that scans a JAR file or some other aggregation of class files for uses of deprecated API elements. the deprecated APIs identified by the jdeprscan tool are only those that are defined by Java SE. deprecated APIs defined by third-party libraries aren't reported. (sorry third-party faves, this tool is loyal to Java SE only π)
to scan a JAR file or a set of class files, you must first ensure that all of the classes that the scanned classes depend upon are present in the class path. set the class path using the --class-path option described in Options for the jdeprscan Command. typically, you would use the same class path as the one that you use when invoking your application. (basically, match the energy of your app's class path, fr fr)
if the jdeprscan can't find all the dependent classes, it will generate an error message for each class that's missing. these error messages are typically of the form:
if these errors occur, then you must adjust the class path so that it includes all dependent classes. no skipping, bestie. π«Ά
---
# β¨ OPTIONS FOR THE JDEPRSCAN COMMAND β¨
the following options are available:
- **`--class-path path`** β provides a search path for resolution of dependent classes.
`path` can be a search path that consists of one or more directories separated by the system-specific path separator. for example:
- **Linux and macOS:**
--class-path /some/directory:/another/different/dir
> **Note:** on Windows, use a semicolon (`;`) as the separator instead of a colon (`:`).
- **Windows:**
--class-path \some\directory;\another\different\dir
- **`--for-removal`** β limits scanning or listing to APIs that are deprecated for removal. can't be used with a release value of `6`, `7`, or `8`. π«
- **`--full-version`** β prints out the full version string of the tool. (the whole lore, not just the highlights)
- **`--help`**, **`-h`** β prints out a full help message.
- **`--list`**, **`-l`** β prints the set of deprecated APIs. no scanning is done, so no directory, jar, or class arguments should be provided. (just the list, no extras)
- **`--release 6|7|8|9`** β specifies the Java SE release that provides the set of deprecated APIs for scanning.
- **`--verbose`**, **`-v`** β enables additional message output during processing. (the tea gets spicier πΆοΈ)
- **`--version`** β prints out the abbreviated version string of the tool.
---
# β¨ EXAMPLE OF JDEPRSCAN OUTPUT β¨
the JAR file for this library will be named something similar to `commons-math3-3.6.1.jar`. to scan this JAR file for the use of deprecated APIs, run the following command:
this command produces several lines of output. for example, one line of output might be:
> **Note:** the class name is specified using the slash-separated binary name as described in JVMS 4.2.1. this is the form used internally in class files.
the deprecated API it uses is a method on the `java.lang.Double` class.
the name of the deprecated method is `<init>`, which is a special name that means that the method is actually a constructor. another special name is `<clinit>`, which indicates a class static initializer. (iykyk π§)
other methods are listed just by their method name. following the method name is the argument list and return type:
this indicates that it takes just one double value (a primitive) and returns void. the argument and return types can become cryptic. for example, another line of output might be:
in this line of output, the deprecated method is on class `java.math.BigDecimal`, and the method is `setScale()`. in this case, the `(II)` means that it takes two `int` arguments. the `Ljava/math/BigDecimal;` after the parentheses means that it returns a reference to `java.math.BigDecimal`. (it's giving method signature realness π
)
---
# β¨ JDEPRSCAN ANALYSIS CAN BE VERSION-SPECIFIC β¨
you can use `jdeprscan` relative to the previous three JDK releases. for example, if you are running JDK 9, then you can check against JDK 8, 7, and 6. (time travel but make it Java β³)
as an example, look at this code snippet:
public class Deprecations { SecurityManager sm = new RMISecurityManager(); // deprecated in 8 Boolean b2 = new Boolean(true); // deprecated in 9 }
the complete class compiles without warnings in JDK 7.
if you run `jdeprscan` on a system with JDK 9, then you see:
$ jdeprscan --class-path classes --release 7 example.Deprecations (no output)
run `jdeprscan` with a release value of 8:
$ jdeprscan --class-path classes --release 8 example.Deprecations class example/Deprecations uses type java/rmi/RMISecurityManager deprecated class example/Deprecations uses method in type java/rmi/RMISecurityManager deprecated
run `jdeprscan` on JDK 9:
$ jdeprscan --class-path classes example.Deprecations class example/Deprecations uses type java/rmi/RMISecurityManager deprecated class example/Deprecations uses method in type java/rmi/RMISecurityManager deprecated class example/Deprecations uses method java/lang/Boolean <init> (Z)V deprecated
---
and that's the whole page, bestie! this manual is from <rainbow>JDK 21</rainbow>, dated <rainbow>2023</rainbow> β so you know it's fresh. periodt. πβ¨π
π¦ where this page comes from
- arch rolling: jdk21-openjdk 21.0.13.0.3.u1-1 Β· LicenseRef-Java
- Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms