why `java.lang.SecurityException: Prohibited package name: java` is required?

前端 未结 8 704
挽巷
挽巷 2020-12-03 16:56

I created a class \"String\" and placed that in package \"java\" [ actually i wanted to create java.lang to see which class is loaded by classLoader as

8条回答
  •  醉酒成梦
    2020-12-03 17:31

    From the ClassLoader.defineClass(..) javadoc:

    ...The specified class name cannot begin with " java. ", since all classes in the " java.* packages can only be defined by the bootstrap class loader

    and

    Throws: ... SecurityException - If an attempt is made to add this class to a package that contains classes that were signed by a different set of certificates than this class, or if the class name begins with " java. ".

提交回复
热议问题