diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-02-10 03:09:59 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2017-02-10 03:09:59 +0100 |
commit | fc7d32af36f3913e13b2827780326a9a5c728fb2 (patch) | |
tree | 6ec3a4613e14d207179b4fc0d5e8f183c26ce3b3 /src/launch/lombok | |
parent | 2335512c8e134a1f6a7a567948543bf87613544b (diff) | |
download | lombok-fc7d32af36f3913e13b2827780326a9a5c728fb2.tar.gz lombok-fc7d32af36f3913e13b2827780326a9a5c728fb2.tar.bz2 lombok-fc7d32af36f3913e13b2827780326a9a5c728fb2.zip |
Updated ShadowClassLoader’s finding of ‘self’; it failed exactly once on me and I’d like to know the classloader when that happens (error condition was loading lombok.jar as an AP in eclipse which normally you don’t even do, so it’s not a big deal).
Diffstat (limited to 'src/launch/lombok')
-rw-r--r-- | src/launch/lombok/launch/ShadowClassLoader.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/launch/lombok/launch/ShadowClassLoader.java b/src/launch/lombok/launch/ShadowClassLoader.java index 2bcf46b5..72f006e8 100644 --- a/src/launch/lombok/launch/ShadowClassLoader.java +++ b/src/launch/lombok/launch/ShadowClassLoader.java @@ -118,12 +118,16 @@ class ShadowClassLoader extends ClassLoader { SELF_BASE = selfBase; SELF_BASE_LENGTH = selfBase.length(); } else { - String sclClassUrl = ShadowClassLoader.class.getResource("ShadowClassLoader.class").toString(); - if (!sclClassUrl.endsWith(SELF_NAME)) throw new InternalError("ShadowLoader can't find itself."); - SELF_BASE_LENGTH = sclClassUrl.length() - SELF_NAME.length(); + URL sclClassUrl = ShadowClassLoader.class.getResource("ShadowClassLoader.class"); + String sclClassStr = sclClassUrl == null ? null : sclClassUrl.toString(); + if (sclClassStr == null || !sclClassStr.endsWith(SELF_NAME)) { + ClassLoader cl = ShadowClassLoader.class.getClassLoader(); + throw new RuntimeException("ShadowLoader can't find itself. SCL loader type: " + (cl == null ? "*NULL*" : cl.getClass().toString())); + } + SELF_BASE_LENGTH = sclClassStr.length() - SELF_NAME.length(); String decoded; try { - decoded = URLDecoder.decode(sclClassUrl.substring(0, SELF_BASE_LENGTH), "UTF-8"); + decoded = URLDecoder.decode(sclClassStr.substring(0, SELF_BASE_LENGTH), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new InternalError("UTF-8 not available"); } |