From deb181f01c43d03e41b06cddf383503bfe943d8a Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Wed, 29 Aug 2018 13:07:25 -0700 Subject: [PATCH] Fix 538393: Allow for toString() to fail on some classloaders --- weaver/src/org/aspectj/weaver/ltw/LTWWorld.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/weaver/src/org/aspectj/weaver/ltw/LTWWorld.java b/weaver/src/org/aspectj/weaver/ltw/LTWWorld.java index 49185a2fb..a053acefd 100644 --- a/weaver/src/org/aspectj/weaver/ltw/LTWWorld.java +++ b/weaver/src/org/aspectj/weaver/ltw/LTWWorld.java @@ -73,7 +73,12 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld { public LTWWorld(ClassLoader loader, IWeavingContext weavingContext, IMessageHandler handler, ICrossReferenceHandler xrefHandler) { super(loader, handler, xrefHandler); this.weavingContext = weavingContext; - classLoaderString = loader.toString(); + try { + classLoaderString = loader.toString(); + } catch (NullPointerException npe) { + // Possibly some state in the loader isn't initialized but is used in the toString() + classLoaderString = loader.getClass().getName()+":"+Integer.toString(System.identityHashCode(loader)); + } classLoaderParentString = (loader.getParent() == null ? "" : loader.getParent().toString()); setBehaveInJava5Way(LangUtil.is15VMOrGreater()); annotationFinder = ReflectionWorld.makeAnnotationFinderIfAny(loader, this); -- 2.39.5