Commits

md_5 authored 8707a3a572b
Be more resilient to asynchronous package loads like URLClassLoader
No tags

src/main/java/org/bukkit/plugin/java/PluginClassLoader.java

Modified
97 97 try (InputStream is = jar.getInputStream(entry)) {
98 98 classBytes = ByteStreams.toByteArray(is);
99 99 } catch (IOException ex) {
100 100 throw new ClassNotFoundException(name, ex);
101 101 }
102 102
103 103 int dot = name.lastIndexOf('.');
104 104 if (dot != -1) {
105 105 String pkgName = name.substring(0, dot);
106 106 if (getPackage(pkgName) == null) {
107 - if (manifest != null) {
108 - definePackage(pkgName, manifest, url);
109 - } else {
110 - definePackage(pkgName, null, null, null, null, null, null, null);
107 + try {
108 + if (manifest != null) {
109 + definePackage(pkgName, manifest, url);
110 + } else {
111 + definePackage(pkgName, null, null, null, null, null, null, null);
112 + }
113 + } catch (IllegalArgumentException ex) {
114 + if (getPackage(pkgName) == null) {
115 + throw new IllegalStateException("Cannot find package " + pkgName);
116 + }
111 117 }
112 118 }
113 119 }
114 120
115 121 CodeSigner[] signers = entry.getCodeSigners();
116 122 CodeSource source = new CodeSource(url, signers);
117 123
118 124 result = defineClass(name, classBytes, 0, classBytes.length, source);
119 125 }
120 126

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut