A class of the JDK's internal packages is imported

tx0/java:internal-api-importrecommendedwarningsmell

What it finds

Classes in sun.* and com.sun.*.internal packages are implementation details of the JDK. They change or disappear between releases without notice, are hidden by the module system, and are missing from other JDK builds.

Files of the JDK itself, in java.*, javax.*, jdk.* or an internal package, are left alone.

From the rule's source, internal_api_import.rs.

Example from the rule's tests
package com.example; import sun.misc.Unsafe;tx0 reports: sun.misc.Unsafe is an internal class of the JDKimport com.sun.net.httpserver.HttpServer;import com.sun.org.apache.xerces.internal.parsers.DOMParser;tx0 reports: is an internal class of the JDK class Low {  Unsafe unsafe;  HttpServer server;  DOMParser parser;}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:internal-api-import" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:internal-api-import] reason="..."

tx0 explain tx0/java:internal-api-import shows the same in the terminal. Found a false positive? Report it.