aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2014-02-28 23:41:06 +0100
committerRoel Spilker <r.spilker@gmail.com>2014-03-01 03:15:35 +0100
commit60cce658818e84d4eefaffaec857e08ea48304fc (patch)
tree56611bd5943f43fe7485b892060dc393f0aa8a10
parentfbab1ca77cb8306843e26c5bad91186b34563282 (diff)
downloadlombok-60cce658818e84d4eefaffaec857e08ea48304fc.tar.gz
lombok-60cce658818e84d4eefaffaec857e08ea48304fc.tar.bz2
lombok-60cce658818e84d4eefaffaec857e08ea48304fc.zip
Potential fix for NPE in classloader, issue 648
-rw-r--r--src/core/lombok/javac/apt/Processor.java83
1 files changed, 40 insertions, 43 deletions
diff --git a/src/core/lombok/javac/apt/Processor.java b/src/core/lombok/javac/apt/Processor.java
index 5f28aa88..3d234541 100644
--- a/src/core/lombok/javac/apt/Processor.java
+++ b/src/core/lombok/javac/apt/Processor.java
@@ -161,48 +161,45 @@ public class Processor extends AbstractProcessor {
}
}
- private static class WrappingClassLoader extends ClassLoader {
- private final ClassLoader parent;
-
- public WrappingClassLoader(ClassLoader parent) {
- this.parent = parent;
- }
-
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- return parent.loadClass(name);
- }
-
- public String toString() {
- return parent.toString();
- }
-
- public URL getResource(String name) {
- return parent.getResource(name);
- }
-
- public Enumeration<URL> getResources(String name) throws IOException {
- return parent.getResources(name);
- }
-
- public InputStream getResourceAsStream(String name) {
- return parent.getResourceAsStream(name);
- }
-
- public void setDefaultAssertionStatus(boolean enabled) {
- parent.setDefaultAssertionStatus(enabled);
- }
-
- public void setPackageAssertionStatus(String packageName, boolean enabled) {
- parent.setPackageAssertionStatus(packageName, enabled);
- }
-
- public void setClassAssertionStatus(String className, boolean enabled) {
- parent.setClassAssertionStatus(className, enabled);
- }
-
- public void clearAssertionStatus() {
- parent.clearAssertionStatus();
- }
+ private static ClassLoader wrapClassLoader(final ClassLoader parent) {
+ return new ClassLoader() {
+
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
+ return parent.loadClass(name);
+ }
+
+ public String toString() {
+ return parent.toString();
+ }
+
+ public URL getResource(String name) {
+ return parent.getResource(name);
+ }
+
+ public Enumeration<URL> getResources(String name) throws IOException {
+ return parent.getResources(name);
+ }
+
+ public InputStream getResourceAsStream(String name) {
+ return parent.getResourceAsStream(name);
+ }
+
+ public void setDefaultAssertionStatus(boolean enabled) {
+ parent.setDefaultAssertionStatus(enabled);
+ }
+
+ public void setPackageAssertionStatus(String packageName, boolean enabled) {
+ parent.setPackageAssertionStatus(packageName, enabled);
+ }
+
+ public void setClassAssertionStatus(String className, boolean enabled) {
+ parent.setClassAssertionStatus(className, enabled);
+ }
+
+ public void clearAssertionStatus() {
+ parent.clearAssertionStatus();
+ }
+ };
}
private void stopJavacProcessingEnvironmentFromClosingOurClassloader() {
@@ -211,7 +208,7 @@ public class Processor extends AbstractProcessor {
f.setAccessible(true);
ClassLoader unwrapped = (ClassLoader) f.get(processingEnv);
if (unwrapped == null) return;
- ClassLoader wrapped = new WrappingClassLoader(unwrapped);
+ ClassLoader wrapped = wrapClassLoader(unwrapped);
f.set(processingEnv, wrapped);
} catch (NoSuchFieldException e) {
// Some versions of javac have this (and call close on it), some don't. I guess this one doesn't have it.