]> source.dussan.org Git - aspectj.git/commitdiff
Fix 538393: Allow for toString() to fail on some classloaders
authorAndy Clement <aclement@pivotal.io>
Wed, 29 Aug 2018 20:07:25 +0000 (13:07 -0700)
committerAndy Clement <aclement@pivotal.io>
Wed, 29 Aug 2018 20:07:25 +0000 (13:07 -0700)
weaver/src/org/aspectj/weaver/ltw/LTWWorld.java

index 49185a2fb2f1ab7ea692732d3fe2dc312b3a9245..a053acefd0f859f1697f10df4960c81d8982b5f0 100644 (file)
@@ -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 ? "<NullParent>" : loader.getParent().toString());
                setBehaveInJava5Way(LangUtil.is15VMOrGreater());
                annotationFinder = ReflectionWorld.makeAnnotationFinderIfAny(loader, this);