how to fix illegal package import checkstyle warning

5.8k Views Asked by At

I am using "java.lang.reflect.Type" in web app project all working fine..but I am stuck with code review how to fix "java.lang.reflect.Type illegal package import " -checkstyle warning.. I am more intrested in explanation of this warning.

Thanks

2

There are 2 best solutions below

0
On

The original IllegalImport check only forbids the sun.* packages, so you are looking at a custom rule definition made by your client.

The rule simply means that you are not supposed to use classes from certain packages. This can make sense for various reasons. If your rule forbids java.lang.reflect.Type, then your client does not want you to use Reflection.

Since you say that you may not modify the rules, you will have to find some way to reach your goal without Reflection.

0
On

Usually packages that are for internal use and version specific. They can be dropped/modified anytime. Like sun.*. Look for anything that is not by default in your Checkstyle config.

Reference.