diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-09-30 13:46:30 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2014-09-30 13:46:30 +0200 |
commit | 2ee2dbd8f9993a08e9ad281bfa73e2b6c5d01ee8 (patch) | |
tree | e9c4f82f89f38740caf4c46b4ae49f3483717612 /src/delombok/lombok | |
parent | 25b78d313233c9cff14953b960b0c0d89b109478 (diff) | |
download | lombok-2ee2dbd8f9993a08e9ad281bfa73e2b6c5d01ee8.tar.gz lombok-2ee2dbd8f9993a08e9ad281bfa73e2b6c5d01ee8.tar.bz2 lombok-2ee2dbd8f9993a08e9ad281bfa73e2b6c5d01ee8.zip |
first take on the shadow classloader. All seems to be in order, but we still have to solve the problem with adding our shadow loader to the equinox infrastructure (solved in lombok currently by adding all of lombok to the bootclasspath), and all the public API still has to be kept as actual class files by build.xml. Currently it is all shadowed away.
Diffstat (limited to 'src/delombok/lombok')
-rw-r--r-- | src/delombok/lombok/delombok/DelombokApp.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/delombok/lombok/delombok/DelombokApp.java b/src/delombok/lombok/delombok/DelombokApp.java index 276bd7de..aa753fc8 100644 --- a/src/delombok/lombok/delombok/DelombokApp.java +++ b/src/delombok/lombok/delombok/DelombokApp.java @@ -88,7 +88,7 @@ public class DelombokApp extends LombokApp { // Since we only read from it, not closing it should not be a problem. @SuppressWarnings({"resource", "all"}) final JarFile toolsJarFile = new JarFile(toolsJar); - ClassLoader loader = new ClassLoader() { + ClassLoader loader = new ClassLoader(DelombokApp.class.getClassLoader()) { private Class<?> loadStreamAsClass(String name, boolean resolve, InputStream in) throws ClassNotFoundException { try { try { @@ -107,16 +107,24 @@ public class DelombokApp extends LombokApp { } finally { in.close(); } - } catch (IOException e2) { + } catch (Exception e2) { throw new ClassNotFoundException(name, e2); } } @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { - String rawName = name.replace(".", "/") + ".class"; + String rawName, altName; { + String binName = name.replace(".", "/"); + rawName = binName + ".class"; + altName = binName + ".SCL.lombok"; + } JarEntry entry = toolsJarFile.getJarEntry(rawName); if (entry == null) { - if (name.startsWith("lombok.")) return loadStreamAsClass(name, resolve, super.getResourceAsStream(rawName)); + if (name.startsWith("lombok.")) { + InputStream res = getParent().getResourceAsStream(rawName); + if (res == null) res = getParent().getResourceAsStream(altName); + return loadStreamAsClass(name, resolve, res); + } return super.loadClass(name, resolve); } |