Skip to content

Files

Latest commit

 

History

History
36 lines (22 loc) · 978 Bytes

IllegalImport.md

File metadata and controls

36 lines (22 loc) · 978 Bytes

Pattern: Import from illegal package

Issue: -

Description

By default this rule rejects all sun.* packages since they are internal APIs: they are subject to change in a undocumented or unsupported way and they are bound to a specific JRE/JDK (Sun in this case), limiting portability of your programs.

Try to avoid uses of such APIs, always prefer a public documented and specified class.

Default configuration

<module name="IllegalImport"/>

Examples

Example of incorrect code:

import sun.misc.Cleaner;

Example of correct code:

import java.lang.ref.Cleaner; // standard replacement for sun.misc.Cleaner

Further Reading