From: Andy Clement Date: Mon, 17 Aug 2020 00:27:48 +0000 (-0700) Subject: debug for test failure under github action X-Git-Tag: V1_9_7M1~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9e794ed21cd5e1435c129628021cf46149898524;p=aspectj.git debug for test failure under github action --- diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java index f1a286ee9..9ee650dc6 100644 --- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java +++ b/loadtime/src/main/java/org/aspectj/weaver/loadtime/WeavingURLClassLoader.java @@ -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("", this, new Object[] { urls, parent }); + } // System.out.println("WeavingURLClassLoader.WeavingURLClassLoader()"); - if (trace.isTraceEnabled()) + if (trace.isTraceEnabled()) { trace.exit(""); + } } 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 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) { - // + // // } // } diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java index c8c141897..e540ae09b 100644 --- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java +++ b/loadtime/src/test/java/org/aspectj/weaver/loadtime/WeavingURLClassLoaderTest.java @@ -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" });