In a Java source, I don’t want use some package. For instance, I don’t want any reference to swing, or io, or other.
Is there a system to check that, at compile time, or at test time?
For instance, with supposed annotation
@NoPackage("javax.swing")
class Foo
{
private JFrame fram; // NOT OK.
}
Why I need this? Because I have an application with swing, and I want refactor it with a part which uses swing, and other which doesn’t, because I want to port it to other ui stuff (web, pda, etc).
I am not aware of such a tool, but it is not that complex to create one. References to all used classes are coded in classfile. Using some classfile library, classfiles can be inspected, and all used classes (or packages) listed. If annotations like @NoPaquage inserted, then the tool could just check if the class really dosent use that packages.