Search code examples
javasecurityexception

How to overcome `Prohibited package name` exception?


Is it possible to turn off / override java.lang.SecurityException: Prohibited package name?

I need to extend AffineTransform class which was implemented with some lack of functionality, and I need to access members m00, m01, ... which are defined as package protected.


Solution

  • No you cant. It's hardcoded in java.lang.ClassLoader:

        if ((name != null) && name.startsWith("java.")) {
            throw new SecurityException
                ("Prohibited package name: " +
                 name.substring(0, name.lastIndexOf('.')));
    

    ...

    as you can see there is no option