]> source.dussan.org Git - aspectj.git/commitdiff
debug for test failure under github action
authorAndy Clement <aclement@pivotal.io>
Mon, 17 Aug 2020 00:27:48 +0000 (17:27 -0700)
committerAndy Clement <aclement@pivotal.io>
Mon, 17 Aug 2020 00:27:48 +0000 (17:27 -0700)
loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java
loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java

index f1a286ee9404a5fde9e293cd66abc3163ead8c7f..9ee650dc68df4f7214c772d224a5ae07f120cdf3 100644 (file)
@@ -1,14 +1,14 @@
 /* *******************************************************************
  * Copyright (c) 2004 IBM Corporation
- * All rights reserved. 
- * This program and the accompanying materials are made available 
- * under the terms of the Eclipse Public License v1.0 
- * which accompanies this distribution and is available at 
- * http://www.eclipse.org/legal/epl-v10.html 
- *  
- * Contributors: 
- *     Matthew Webster, Adrian Colyer, 
- *     Martin Lippert     initial implementation 
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Matthew Webster, Adrian Colyer,
+ *     Martin Lippert     initial implementation
  *     Andy Clement
  *     Abraham Nevado
  * ******************************************************************/
@@ -55,11 +55,13 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
 
        public WeavingURLClassLoader(URL[] urls, ClassLoader parent) {
                super(urls, parent);
-               if (trace.isTraceEnabled())
+               if (trace.isTraceEnabled()) {
                        trace.enter("<init>", this, new Object[] { urls, parent });
+               }
                // System.out.println("WeavingURLClassLoader.WeavingURLClassLoader()");
-               if (trace.isTraceEnabled())
+               if (trace.isTraceEnabled()) {
                        trace.exit("<init>");
+               }
        }
 
        public WeavingURLClassLoader(URL[] classURLs, URL[] aspectURLs, ClassLoader parent) {
@@ -91,14 +93,15 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
        }
 
        private static URL[] getURLs(String path) {
-               List urlList = new ArrayList();
+               List<URL> urlList = new ArrayList<>();
                for (StringTokenizer t = new StringTokenizer(path, File.pathSeparator); t.hasMoreTokens();) {
                        File f = new File(t.nextToken().trim());
                        try {
                                if (f.exists()) {
                                        URL url = f.toURL();
-                                       if (url != null)
+                                       if (url != null) {
                                                urlList.add(url);
+                                       }
                                }
                        } catch (MalformedURLException e) {
                        }
@@ -121,8 +124,9 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
         * Override to weave class using WeavingAdaptor
         */
        protected Class defineClass(String name, byte[] b, CodeSource cs) throws IOException {
-               if (trace.isTraceEnabled())
+               if (trace.isTraceEnabled()) {
                        trace.enter("defineClass", this, new Object[] { name, b, cs });
+               }
                // System.err.println("? WeavingURLClassLoader.defineClass(" + name + ", [" + b.length + "])");
                byte orig[] = b;
                /* Avoid recursion during adaptor initialization */
@@ -143,16 +147,17 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
                        }
                }
                Class clazz;
-               
+
                // On error, define the original form of the class and log the issue
-               try { 
+               try {
                        clazz= super.defineClass(name, b, cs);
                } catch (Throwable th) {
                        trace.error("Weaving class problem. Original class has been returned. The error was caused because of: " + th, th);
                        clazz= super.defineClass(name, orig, cs);
                }
-               if (trace.isTraceEnabled())
+               if (trace.isTraceEnabled()) {
                        trace.exit("defineClass", clazz);
+               }
                return clazz;
        }
 
@@ -209,15 +214,15 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
        // private interface ClassPreProcessorAdaptor extends ClassPreProcessor {
        // public void addURL(URL url);
        // }
-       //      
+       //
        // private class WeavingAdaptorPreProcessor implements ClassPreProcessorAdaptor {
-       //              
+       //
        // private WeavingAdaptor adaptor;
-       //              
+       //
        // public WeavingAdaptorPreProcessor (WeavingClassLoader wcl) {
        // adaptor = new WeavingAdaptor(wcl);
        // }
-       //          
+       //
        // public void initialize() {
        // }
        //
@@ -226,7 +231,7 @@ public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements W
        // }
        //
        // public void addURL(URL url) {
-       //                      
+       //
        // }
        // }
 
index c8c1418979113e095ef0f6a2c2c9d459a58684d2..e540ae09b039d7bbffc15f17d327aafc1c60d957 100644 (file)
@@ -347,13 +347,15 @@ public class WeavingURLClassLoaderTest extends TestCase {
        /*
         * Aspects on ASPECTPATH but missing from CLASSPATH
         */
-       public void testIncompletePath() {
+       public void testIncompletePath() throws Exception {
                System.out.println("ADVICE_ASPECTS exists? " + new File(ADVICE_ASPECTS).exists());
                System.out.println("ASPECTJRT exists? " + new File(ASPECTJRT).exists());
                setSystemProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH, ADVICE_ASPECTS+File.pathSeparator+new File(ASPECTJRT).toString());
-               setSystemProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH, CLASSES_JAR);
+               setSystemProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,
+                               CLASSES_JAR + File.pathSeparator + new File(ASPECTJRT).toString());
                WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
-
+               Class<?> loadClass = loader.loadClass("org.aspectj.lang.JoinPoint$StaticPart");
+               System.out.println("JPSP: " + loadClass);
                try {
                        Class<?> clazz = loader.loadClass("LTWHelloWorld");
                        invokeMain(clazz, new String[] { "LTWAspect" });