diff options
author | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-06-04 07:58:52 +0700 |
---|---|---|
committer | Alexander Kriegisch <Alexander@Kriegisch.name> | 2021-06-04 07:58:52 +0700 |
commit | 49cb924f5402c9d24379ae1af62def6fa5892649 (patch) | |
tree | 69844405209043e2e18aa9eef0f01f287bc1ae52 /tests/bugs161 | |
parent | 82df3f0fc9842758f15f12299c9113e48f1ccb5c (diff) | |
download | aspectj-49cb924f5402c9d24379ae1af62def6fa5892649.tar.gz aspectj-49cb924f5402c9d24379ae1af62def6fa5892649.zip |
Upgrade license from CPLv1/EPLv1 to EPLv2
This was required by the Eclipse team as one precondition for the next
release.
Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
Diffstat (limited to 'tests/bugs161')
-rw-r--r-- | tests/bugs161/pr230134/HelloWorldTracing.java | 12 | ||||
-rw-r--r-- | tests/bugs161/pr230134/SimpleTracing.java | 68 | ||||
-rw-r--r-- | tests/bugs161/pr230134/Tracing.java | 102 |
3 files changed, 91 insertions, 91 deletions
diff --git a/tests/bugs161/pr230134/HelloWorldTracing.java b/tests/bugs161/pr230134/HelloWorldTracing.java index 1115a876d..cff6e3188 100644 --- a/tests/bugs161/pr230134/HelloWorldTracing.java +++ b/tests/bugs161/pr230134/HelloWorldTracing.java @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 + * are made available under the terms of the Eclipse Public License v 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * * Contributors: - * Matthew Webster initial implementation + * Matthew Webster initial implementation *******************************************************************************/ package demo.hello.tracing; @@ -20,12 +20,12 @@ public aspect HelloWorldTracing extends SimpleTracing { /** * Template method that allows choice of destination for output - * + * * @param s message to be traced */ protected void println (String s) { System.out.println(s); } - + } diff --git a/tests/bugs161/pr230134/SimpleTracing.java b/tests/bugs161/pr230134/SimpleTracing.java index 97f92da8a..e9ef6391f 100644 --- a/tests/bugs161/pr230134/SimpleTracing.java +++ b/tests/bugs161/pr230134/SimpleTracing.java @@ -1,10 +1,10 @@ /******************************************************************************* * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * * Contributors: * Matthew Webster - initial implementation * Sian January @@ -22,9 +22,9 @@ import org.aspectj.lang.JoinPoint; import org.aspectj.lang.reflect.CodeSignature; /** - * This simple abstract aspect is enabled by default and traces method - * signatures as well as arguments to stderr. An abstract scoping pointcut - * is provided for concrete, user-supplied sub-aspect to determine which + * This simple abstract aspect is enabled by default and traces method + * signatures as well as arguments to stderr. An abstract scoping pointcut + * is provided for concrete, user-supplied sub-aspect to determine which * classes should be traced. */ public abstract aspect SimpleTracing extends Tracing { @@ -35,16 +35,16 @@ public abstract aspect SimpleTracing extends Tracing { protected abstract pointcut tracingScope (); private static SimpleDateFormat timeFormat; - + /** * Enabled or disable tracing - * - * @param enabled + * + * @param enabled */ public static void setEnabled (boolean enabled) { tracingEnabled = enabled; } - + public static boolean getEnabled () { return tracingEnabled; } @@ -56,7 +56,7 @@ public abstract aspect SimpleTracing extends Tracing { */ protected pointcut shouldTrace () : if(tracingEnabled) && tracingScope(); - + private static boolean tracingEnabled = getBoolean("org.aspectj.lib.tracing",true); private static boolean getBoolean (String name, boolean def) { @@ -73,31 +73,31 @@ public abstract aspect SimpleTracing extends Tracing { println(signature.getDeclaringType(),formatMessage(">",signature.getDeclaringTypeName(),signature.getName(),obj,jp.getArgs())); // println("> " + signature.toShortString() + " " + formatParam("obj",obj) + " " + formatArgs(signature.getParameterNames(),jp.getArgs())); } - + protected void enter (JoinPoint jp) { CodeSignature signature = (CodeSignature)jp.getSignature(); println(signature.getDeclaringType(),formatMessage(">",signature.getDeclaringTypeName(),signature.getName(),null,jp.getArgs())); // println("> " + jp.getSignature().toShortString() + " " + formatArgs(signature.getParameterNames(),jp.getArgs())); } - + protected void exit (JoinPoint.StaticPart sjp, Object ret) { CodeSignature signature = (CodeSignature)sjp.getSignature(); println(signature.getDeclaringType(),formatMessage("<",signature.getDeclaringTypeName(),signature.getName(),ret,null)); // println("< " + sjp.getSignature().toShortString() + " " + formatParam("ret",ret)); } - + protected void exit (JoinPoint.StaticPart sjp) { CodeSignature signature = (CodeSignature)sjp.getSignature(); println(signature.getDeclaringType(),formatMessage("<",signature.getDeclaringTypeName(),signature.getName(),null,null)); // println("< " + sjp.getSignature().toShortString()); } - + protected void exception (JoinPoint.StaticPart sjp, Throwable th) { CodeSignature signature = (CodeSignature)sjp.getSignature(); println(signature.getDeclaringType(),formatMessage("E",signature.getName(),th)); // println("E " + sjp.getSignature().toShortString() + " " + th.toString()); } - + /* * Formatting */ @@ -113,7 +113,7 @@ public abstract aspect SimpleTracing extends Tracing { if (args != null) message.append(" ").append(formatArgs(args)); return message.toString(); } - + protected String formatMessage(String kind, String text, Throwable th) { StringBuffer message = new StringBuffer(); Date now = new Date(); @@ -125,33 +125,33 @@ public abstract aspect SimpleTracing extends Tracing { return message.toString(); } - /** + /** * Format arguments into a comma separated list - * + * * @param names array of argument names * @param args array of arguments * @return the formated list */ protected String formatArgs(Object[] args) { StringBuffer sb = new StringBuffer(); - + for (int i = 0; i < args.length; i++) { sb.append(formatObj(args[i])); if (i < args.length-1) sb.append(", "); } - + return sb.toString(); } /** * Format objects safely avoiding toString which can cause recursion, * NullPointerExceptions or highly verbose results. - * + * * @param obj parameter to be formatted * @return the formated parameter */ protected Object formatObj(Object obj) { - + /* These classes have a safe implementation of toString() */ if (obj == null || obj instanceof String @@ -171,35 +171,35 @@ public abstract aspect SimpleTracing extends Tracing { return formatCollection((Collection)obj); } else try { - + /* Use classname@hashcode */ return obj.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(obj)); - - /* Object.hashCode() can be override and may thow an exception */ + + /* Object.hashCode() can be override and may thow an exception */ } catch (Exception ex) { return obj.getClass().getName() + "@FFFFFFFF"; } } - + protected String formatArray (Object obj) { - return obj.getClass().getComponentType().getName() + "[" + Array.getLength(obj) + "]"; + return obj.getClass().getComponentType().getName() + "[" + Array.getLength(obj) + "]"; } - + protected String formatCollection (Collection c) { - return c.getClass().getName() + "(" + c.size() + ")"; + return c.getClass().getName() + "(" + c.size() + ")"; } - + private static String formatDate (Date date) { if (timeFormat == null) { timeFormat = new SimpleDateFormat("HH:mm:ss.SSS"); } - + return timeFormat.format(date); } /** * Template method that allows choice of destination for output - * + * * @param s message to be traced */ protected void println (Class clazz, String s) { diff --git a/tests/bugs161/pr230134/Tracing.java b/tests/bugs161/pr230134/Tracing.java index 2029bc968..1f3b76753 100644 --- a/tests/bugs161/pr230134/Tracing.java +++ b/tests/bugs161/pr230134/Tracing.java @@ -1,10 +1,10 @@ /******************************************************************************* * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v 2.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt + * * Contributors: * Matthew Webster - initial implementation * Sian January @@ -14,18 +14,18 @@ package org.aspectj.lib.tracing; import org.aspectj.lang.*; /** - * This root abstract aspect determines the basic tracing behaviour - * i.e. entry/exit/exception using the method/constructor execution() pointcut - * and before/after returning/after throwing advice. Determining what - * methods and constructors belonging to which classes is delegated to a - * user-supplied concrete aspect using an abstract pointcut. When tracing - * occurs and what is done with the captured data is delegated to an abstract, + * This root abstract aspect determines the basic tracing behaviour + * i.e. entry/exit/exception using the method/constructor execution() pointcut + * and before/after returning/after throwing advice. Determining what + * methods and constructors belonging to which classes is delegated to a + * user-supplied concrete aspect using an abstract pointcut. When tracing + * occurs and what is done with the captured data is delegated to an abstract, * infrastructure-specific sub-aspect through template methods. */ public abstract aspect Tracing { /** - * Sub-aspects <b>must</b> implement this pointcut to determine what and when to + * Sub-aspects <b>must</b> implement this pointcut to determine what and when to * trace */ protected abstract pointcut shouldTrace (); @@ -33,14 +33,14 @@ public abstract aspect Tracing { private pointcut staticContext () : !this(Object); private pointcut nonStaticContext (Object obj) : this(obj); private pointcut voidMethod () : execution(void *(..)); - + public final static pointcut methodExecution () : execution(* *(..)); public final static pointcut constructorExecution () : execution(new(..)); public final static pointcut objectMethod () : execution(* Object.*(..)); - /** - * Sub-aspects <b>may</b> override this point to determine which methods if any - * are traced. By default include only public methods and those not inherited + /** + * Sub-aspects <b>may</b> override this point to determine which methods if any + * are traced. By default include only public methods and those not inherited * from java.lang.Object e.g. toString(). */ protected pointcut includedMethod () : @@ -48,18 +48,18 @@ public abstract aspect Tracing { && !objectMethod(); - /** - * Sub-aspects <b>may</b> override this point to determine which constructors if any + /** + * Sub-aspects <b>may</b> override this point to determine which constructors if any * are traced. By default include only public constructors. */ protected pointcut includedConstructor () : execution(public new(..)); - + /* - * Exclude methods and constructors in Tracing and sub-aspects as well as + * Exclude methods and constructors in Tracing and sub-aspects as well as * those in the control flow of Tracing advice or constructors to avoid recursion. */ - private pointcut excluded () : + private pointcut excluded () : within(Tracing+) // || cflow((adviceexecution() || execution(new(..))) && within(Tracing+)) || cflow((adviceexecution() && within(Tracing+))) @@ -83,106 +83,106 @@ public abstract aspect Tracing { && !excluded() && this(obj) ; - + /* * Trace entry to instance methods - * + * * Tracing pattern 1: Only use thisJoinPoint in before() */ before (Object obj) : tracedMethod() && nonStaticContext(obj) && shouldTrace() { enter(thisJoinPoint,obj); } - + /* * Trace entry to static methods - * + * * Tracing pattern 1: Only use thisJoinPoint in before() */ before () : tracedMethod() && staticContext() && shouldTrace() { enter(thisJoinPoint); } - + /* * Trace exit from void methods - * + * * Tracing pattern 1: Use thisJoinPointStaticPart in after() */ after() returning() : tracedMethod() && voidMethod() && shouldTrace() { exit(thisJoinPointStaticPart); } - + /* * Trace exit from non-void methods including return value - * + * * Tracing pattern 1: Use thisJoinPointStaticPart in after() */ after() returning(Object ret) : tracedMethod() && !voidMethod() && shouldTrace() { exit(thisJoinPointStaticPart,ret); } - + /* * Trace exceptions thrown from methods and constructors - * + * * Tracing pattern 1: Use thisJoinPointStaticPart in after() */ after() throwing(Throwable th) : (tracedMethod() || tracedConstructor(Object)) && shouldTrace() { if (shouldTrace(th)) exception(thisJoinPointStaticPart,th); } - + /* * Trace entry to constructors - * + * * Tracing pattern 1: Only use thisJoinPoint in before() */ before () : tracedConstructor(Object) && shouldTrace() { enter(thisJoinPoint); } - + /* * Trace exit from constructors including new object - * + * * Tracing pattern 1: Only use thisJoinPoint in before() */ after (Object obj) : tracedConstructor(obj) && shouldTrace() { exit(thisJoinPointStaticPart,obj); } - + /* * Template methods to log data implemented by infrastructure-specific sub-aspects - * e.g. java.util.logging.Logger + * e.g. java.util.logging.Logger */ protected abstract void enter (JoinPoint jp, Object obj); - + protected abstract void enter (JoinPoint jp); - + protected abstract void exit (JoinPoint.StaticPart sjp); - + protected abstract void exit (JoinPoint.StaticPart sjp, Object ret); - + protected abstract void exception (JoinPoint.StaticPart sjp, Throwable th); - /** + /** * Format arguments into a comma separated list - * + * * @param names array of argument names * @param args array of arguments * @return the formated list */ protected String formatArgs (String[] names, Object[] args) { StringBuffer sb = new StringBuffer(); - + for (int i = 0; i < args.length; i++) { sb.append(formatParam(names[i],args[i])); if (i < args.length-1) sb.append(", "); } - + return sb.toString(); } - + /** * Format objects safely avoiding toString which can cause recursion, * NullPointerExceptions or highly verbose results. - * + * * @param obj parameter to be formatted * @return the formated parameter */ @@ -201,10 +201,10 @@ public abstract aspect Tracing { return obj.getClass().getName(); } } - + /** * Format parameter into name=value pair - * + * * @param name parameter name * @param arg parameted to be formatted * @return the formated parameter @@ -212,11 +212,11 @@ public abstract aspect Tracing { protected String formatParam (String name, Object arg) { return name + "=" + formatObj(arg); } - + /** - * By default we do not trace errors e.g. OutOfMemoryError because the + * By default we do not trace errors e.g. OutOfMemoryError because the * system my be in an inconsistent state. However users may override this - * + * * @param th excpeption or error to be traced * @return whether it should be traced */ |