[JAVA] 日常填坑 java.lang.SecurityException: Prohibited package name: java.xxx
作者:互联网
package java.patterns.v1; import capsule.patterns.v1.factory.SendFactory; public class Test { /** * > 普通工厂模式 * @param args */ public static void main(String[] args) { //发送 SendFactory.sendModule("sms").send(); } }
报错如下:
java.patterns.v1.Test java.lang.SecurityException: Prohibited package name: java.patterns.v1 at java.lang.ClassLoader.preDefineClass(ClassLoader.java:658) at java.lang.ClassLoader.defineClass(ClassLoader.java:794) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482) Exception in thread "main" Process finished with exit code 1
原因:
java虚拟机不允许包名以java开头
标签:lang,java,name,URLClassLoader,ClassLoader,v1,net 来源: https://blog.51cto.com/u_15263565/2884903