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

前端 未结 8 702
挽巷
挽巷 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:55

    java is a reserved package name. Only classes inside the JVM can reside in this package.

    If anyone could write in the Java package, that could result in libraries arbitrarily replacing core Java classes by their own implementations. That could result in a lot of thinks, from breaking core Java features to execution of malicious code.

提交回复
热议问题