You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The treatSamePackageAsUnused feature will remove imports for types in the same package as the compilation unit.
However, it may be necessary to keep some of these import statements, in order for the package-local type to shadow a type of the same simple name in the java.lang package. For example, in JDK14, there may be a class in the same package called Record. Removing the explicit import statement will cause java.lang.Record to be used instead of the package-local type that the explicit import statement intended.
I can think of a few mitigations for this:
Keep the package-local import statement if a type, n, exists as java.lang.n (the problem with this is we can only check the build-time JDK, not the target JDK the code is being compiled for, without a lot of extra configuration and pre-defined JDK target signatures, so it could still be overly aggressive),
Add a plugin configuration option to exclude properties from automatic removal, by name (or pattern), or
Add a comment-parsing option so specific imports can be annotated inline in the code to always keep specific imports.
The text was updated successfully, but these errors were encountered:
The
treatSamePackageAsUnused
feature will remove imports for types in the same package as the compilation unit.However, it may be necessary to keep some of these import statements, in order for the package-local type to shadow a type of the same simple name in the
java.lang
package. For example, in JDK14, there may be a class in the same package calledRecord
. Removing the explicit import statement will causejava.lang.Record
to be used instead of the package-local type that the explicit import statement intended.I can think of a few mitigations for this:
n
, exists asjava.lang.n
(the problem with this is we can only check the build-time JDK, not the target JDK the code is being compiled for, without a lot of extra configuration and pre-defined JDK target signatures, so it could still be overly aggressive),The text was updated successfully, but these errors were encountered: