From fc7d32af36f3913e13b2827780326a9a5c728fb2 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 10 Feb 2017 03:09:59 +0100 Subject: [PATCH] =?UTF-8?q?Updated=20ShadowClassLoader=E2=80=99s=20finding?= =?UTF-8?q?=20of=20=E2=80=98self=E2=80=99;=20it=20failed=20exactly=20once?= =?UTF-8?q?=20on=20me=20and=20I=E2=80=99d=20like=20to=20know=20the=20class?= =?UTF-8?q?loader=20when=20that=20happens=20(error=20condition=20was=20loa?= =?UTF-8?q?ding=20lombok.jar=20as=20an=20AP=20in=20eclipse=20which=20norma?= =?UTF-8?q?lly=20you=20don=E2=80=99t=20even=20do,=20so=20it=E2=80=99s=20no?= =?UTF-8?q?t=20a=20big=20deal).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/launch/lombok/launch/ShadowClassLoader.java | 12 ++++++++---- 1 file 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"); }