aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java18
-rw-r--r--org.aspectj.ajdt.core/src/test/java/AroundAMain.java33
-rw-r--r--org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java20
-rw-r--r--org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactTypePattern.java24
-rw-r--r--org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java88
-rw-r--r--runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java74
-rw-r--r--testing/src/test/java/org/aspectj/testing/util/RunUtils.java655
7 files changed, 467 insertions, 445 deletions
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java
index 47c56f939..a520124da 100644
--- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java
+++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/EclipseAnnotationConvertor.java
@@ -45,7 +45,7 @@ import org.aspectj.weaver.World;
public class EclipseAnnotationConvertor {
/**
* Convert one eclipse annotation into an AnnotationX object containing an AnnotationAJ object.
- *
+ *
* This code and the helper methods used by it will go *BANG* if they encounter anything not currently supported - this is safer
* than limping along with a malformed annotation. When the *BANG* is encountered the bug reporter should indicate the kind of
* annotation they were working with and this code can be enhanced to support it.
@@ -80,7 +80,7 @@ public class EclipseAnnotationConvertor {
// is this just a marker annotation?
throw new MissingImplementationException(
"Please raise an AspectJ bug. AspectJ does not know how to convert this annotation [" + annotation
- + "]");
+ + "]");
} else {
AnnotationValue av = generateElementValue(memberValuePair.value, methodBinding.returnType);
AnnotationNameValuePair anvp = new AnnotationNameValuePair(new String(memberValuePair.name), av);
@@ -118,7 +118,7 @@ public class EclipseAnnotationConvertor {
if (defaultValueBinding == null) {
throw new MissingImplementationException(
"Please raise an AspectJ bug. AspectJ does not know how to convert this annotation value [" + defaultValue
- + "]");
+ + "]");
} else {
if (memberValuePairReturnType.isArrayType() && !defaultValueBinding.isArrayType()) {
if (constant != null && constant != Constant.NotAConstant) {
@@ -159,7 +159,7 @@ public class EclipseAnnotationConvertor {
return new SimpleAnnotationValue(ElementValue.PRIMITIVE_INT, new Integer(iConstant.intValue()));
} else if (c instanceof BooleanConstant) {
BooleanConstant iConstant = (BooleanConstant) c;
- return new SimpleAnnotationValue(ElementValue.PRIMITIVE_BOOLEAN, new Boolean(iConstant.booleanValue()));
+ return new SimpleAnnotationValue(ElementValue.PRIMITIVE_BOOLEAN, iConstant.booleanValue());
} else if (c instanceof StringConstant) {
StringConstant sConstant = (StringConstant) c;
return new SimpleAnnotationValue(ElementValue.STRING, sConstant.stringValue());
@@ -191,11 +191,11 @@ public class EclipseAnnotationConvertor {
}
throw new MissingImplementationException(
"Please raise an AspectJ bug. AspectJ does not know how to convert this annotation value [" + defaultValue
- + "]");
+ + "]");
} else if (defaultValueBinding.isAnnotationType()) {
throw new MissingImplementationException(
"Please raise an AspectJ bug. AspectJ does not know how to convert this annotation value [" + defaultValue
- + "]");
+ + "]");
// contents[contentsOffset++] = (byte) '@';
// generateAnnotation((Annotation) defaultValue,
// attributeOffset);
@@ -223,16 +223,16 @@ public class EclipseAnnotationConvertor {
if (defaultValue instanceof ClassLiteralAccess) {
ClassLiteralAccess cla = (ClassLiteralAccess)defaultValue;
ClassAnnotationValue cav = new ClassAnnotationValue(new String(cla.targetType.signature()));
- return cav;
+ return cav;
}
throw new MissingImplementationException(
"Please raise an AspectJ bug. AspectJ does not know how to convert this annotation value [" + defaultValue
- + "]");
+ + "]");
}
} else {
throw new MissingImplementationException(
"Please raise an AspectJ bug. AspectJ does not know how to convert this annotation value [" + defaultValue
- + "]");
+ + "]");
// contentsOffset = attributeOffset;
}
}
diff --git a/org.aspectj.ajdt.core/src/test/java/AroundAMain.java b/org.aspectj.ajdt.core/src/test/java/AroundAMain.java
index 94f2be84f..d9a2929d0 100644
--- a/org.aspectj.ajdt.core/src/test/java/AroundAMain.java
+++ b/org.aspectj.ajdt.core/src/test/java/AroundAMain.java
@@ -1,45 +1,44 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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:
- * PARC 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:
+ * PARC initial implementation
* ******************************************************************/
-import junit.framework.TestCase;
-
import org.aspectj.runtime.internal.AroundClosure;
import org.aspectj.util.Reflection;
public class AroundAMain {//extends TestCase {
public AroundAMain(String name) {
-// super(name);
+ // super(name);
}
public static void main(String[] args) throws ClassNotFoundException {
AroundClosure closure = new AroundClosure() {
+ @Override
public Object run(Object[] args) throws Throwable {
-// System.out.println("run with: " + Arrays.asList(args));
+ // System.out.println("run with: " + Arrays.asList(args));
return new Integer(10);
}
};
-
+
Object instance = Reflection.getStaticField(Class.forName("AroundA"),
- "ajc$perSingletonInstance");
+ "ajc$perSingletonInstance");
Reflection.invoke(Class.forName("AroundA"), instance, "ajc$around$AroundA$1$73ebb943", // was $AroundA$46
- new Integer(10), new Boolean(true), closure);
+ new Integer(10), true, closure);
Reflection.invoke(Class.forName("AroundA"), instance, "ajc$around$AroundA$2$a758212d", // Was $AroundA$c5
- "hello there", closure);
+ "hello there", closure);
Reflection.invoke(Class.forName("AroundA"), instance, "ajc$around$AroundA$3$a758212d", // Was $AroundA$150
- new String[1], closure);
+ new String[1], closure);
}
}
diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java
index 312f7726b..27af4e8f5 100644
--- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java
+++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/SimpleAnnotationValue.java
@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2006 Contributors
- * 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:
- * Andy Clement IBM 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:
+ * Andy Clement IBM initial implementation
* ******************************************************************/
package org.aspectj.weaver;
@@ -78,6 +78,7 @@ public class SimpleAnnotationValue extends AnnotationValue {
theInt = i;
}
+ @Override
public String stringify() {
switch (valueKind) {
case 'B': // byte
@@ -95,7 +96,7 @@ public class SimpleAnnotationValue extends AnnotationValue {
case 'S': // short
return Short.toString(theShort);
case 'Z': // boolean
- return new Boolean(theBoolean).toString();
+ return Boolean.valueOf(theBoolean).toString();
case 's': // String
return theString;
default:
@@ -103,6 +104,7 @@ public class SimpleAnnotationValue extends AnnotationValue {
}
}
+ @Override
public String toString() {
return stringify();
}
diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactTypePattern.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactTypePattern.java
index 68353422f..d54ad29ab 100644
--- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactTypePattern.java
+++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/ExactTypePattern.java
@@ -1,13 +1,13 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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:
- * PARC 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:
+ * PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver.patterns;
@@ -97,7 +97,7 @@ public class ExactTypePattern extends TypePattern {
/*
* (non-Javadoc)
- *
+ *
* @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern)
*/
@Override
@@ -234,8 +234,8 @@ public class ExactTypePattern extends TypePattern {
public int hashCode() {
int result = 17;
result = 37 * result + type.hashCode();
- result = 37 * result + new Boolean(includeSubtypes).hashCode();
- result = 37 * result + new Boolean(isVarArgs).hashCode();
+ result = 37 * result + Boolean.valueOf(includeSubtypes).hashCode();
+ result = 37 * result + Boolean.valueOf(isVarArgs).hashCode();
result = 37 * result + typeParameters.hashCode();
result = 37 * result + annotationPattern.hashCode();
return result;
@@ -322,7 +322,7 @@ public class ExactTypePattern extends TypePattern {
TypeVariableReference t = (TypeVariableReference) type;
String key = t.getTypeVariable().getName();
if (typeVariableMap.containsKey(key)) {
- newType = (UnresolvedType) typeVariableMap.get(key);
+ newType = typeVariableMap.get(key);
}
} else if (type.isParameterizedType()) {
newType = w.resolve(type).parameterize(typeVariableMap);
diff --git a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java
index 52217f880..252a164fe 100644
--- a/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java
+++ b/org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/AbstractTrace.java
@@ -1,10 +1,10 @@
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * 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 - initial implementation
*******************************************************************************/
@@ -27,17 +27,21 @@ public abstract class AbstractTrace implements Trace {
protected Class<?> tracedClass;
private static SimpleDateFormat timeFormat;
-
+
protected AbstractTrace (Class clazz) {
this.tracedClass = clazz;
}
-
+
+ @Override
public abstract void enter (String methodName, Object thiz, Object[] args);
-
+
+ @Override
public abstract void enter(String methodName, Object thiz);
+ @Override
public abstract void exit(String methodName, Object ret);
+ @Override
public abstract void exit(String methodName, Throwable th);
/*
@@ -47,38 +51,46 @@ public abstract class AbstractTrace implements Trace {
enter(methodName,null,null);
}
+ @Override
public void enter (String methodName, Object thiz, Object arg) {
enter(methodName,thiz,new Object[] { arg });
}
+ @Override
public void enter (String methodName, Object thiz, boolean z) {
- enter(methodName,thiz,new Boolean(z));
+ enter(methodName,thiz,Boolean.valueOf(z));
}
+ @Override
public void exit (String methodName, boolean b) {
- exit(methodName,new Boolean(b));
+ exit(methodName,Boolean.valueOf(b));
}
+ @Override
public void exit (String methodName, int i) {
exit(methodName,new Integer(i));
}
+ @Override
public void event (String methodName, Object thiz, Object arg) {
event(methodName,thiz,new Object[] { arg });
}
+ @Override
public void warn(String message) {
warn(message,null);
}
+ @Override
public void error(String message) {
error(message,null);
}
+ @Override
public void fatal (String message) {
fatal(message,null);
}
-
+
/*
* Formatting
*/
@@ -94,7 +106,7 @@ public abstract class AbstractTrace implements Trace {
if (args != null) message.append(" ").append(formatArgs(args));
return message.toString();
}
-
+
/**
* @param className full dotted class name
* @return short version of class name with package collapse to initials
@@ -102,7 +114,7 @@ public abstract class AbstractTrace implements Trace {
private String formatClassName(String className) {
return packagePrefixPattern.matcher(className).replaceAll("$1.");
}
-
+
protected String formatMessage(String kind, String text, Throwable th) {
StringBuffer message = new StringBuffer();
Date now = new Date();
@@ -113,37 +125,37 @@ public abstract class AbstractTrace implements Trace {
if (th != null) message.append(" ").append(formatObj(th));
return message.toString();
}
-
+
private static String formatDate (Date date) {
if (timeFormat == null) {
timeFormat = new SimpleDateFormat("HH:mm:ss.SSS");
}
-
+
return timeFormat.format(date);
}
/**
* Format objects safely avoiding toString which can cause recursion,
* NullPointerExceptions or highly verbose results.
- *
+ *
* @param obj parameter to be formatted
* @return the formatted parameter
*/
protected Object formatObj(Object obj) {
-
+
/* These classes have a safe implementation of toString() */
if (obj == null
|| obj instanceof String
- || obj instanceof Number
- || obj instanceof Boolean
- || obj instanceof Exception
- || obj instanceof Character
- || obj instanceof Class
- || obj instanceof File
- || obj instanceof StringBuffer
- || obj instanceof URL
- || obj instanceof Kind
- ) return obj;
+ || obj instanceof Number
+ || obj instanceof Boolean
+ || obj instanceof Exception
+ || obj instanceof Character
+ || obj instanceof Class
+ || obj instanceof File
+ || obj instanceof StringBuffer
+ || obj instanceof URL
+ || obj instanceof Kind
+ ) return obj;
else if (obj.getClass().isArray()) {
return formatArray(obj);
}
@@ -151,52 +163,52 @@ public abstract class AbstractTrace implements Trace {
return formatCollection((Collection)obj);
}
else try {
-
+
// Classes can provide an alternative implementation of toString()
if (obj instanceof Traceable) {
return ((Traceable)obj).toTraceString();
}
-
+
// classname@hashcode
else return formatClassName(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() + ")";
}
- /**
+ /**
* 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();
}
-
+
protected Object[] formatObjects(Object[] args) {
for (int i = 0; i < args.length; i++) {
args[i] = formatObj(args[i]);
}
-
+
return args;
}
} \ No newline at end of file
diff --git a/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java b/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java
index 0632ae8f8..13e8d9edd 100644
--- a/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java
+++ b/runtime/src/main/java/org/aspectj/runtime/internal/Conversions.java
@@ -1,14 +1,14 @@
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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:
- * Xerox/PARC 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:
+ * Xerox/PARC initial implementation
* ******************************************************************/
@@ -18,34 +18,34 @@ public final class Conversions {
// Can't make instances of me
private Conversions() {}
- // we might want to keep a cache of small integers around
+ // we might want to keep a cache of small integers around
public static Object intObject(int i) {
- return new Integer(i);
- }
+ return new Integer(i);
+ }
public static Object shortObject(short i) {
- return new Short(i);
- }
+ return new Short(i);
+ }
public static Object byteObject(byte i) {
- return new Byte(i);
- }
+ return new Byte(i);
+ }
public static Object charObject(char i) {
- return new Character(i);
- }
+ return new Character(i);
+ }
public static Object longObject(long i) {
- return new Long(i);
- }
+ return new Long(i);
+ }
public static Object floatObject(float i) {
- return new Float(i);
- }
+ return new Float(i);
+ }
public static Object doubleObject(double i) {
- return new Double(i);
- }
+ return new Double(i);
+ }
public static Object booleanObject(boolean i) {
- return new Boolean(i);
- }
+ return i;
+ }
public static Object voidObject() {
- return null;
- }
+ return null;
+ }
public static int intValue(Object o) {
@@ -55,7 +55,7 @@ public final class Conversions {
return ((Number)o).intValue();
} else {
throw new ClassCastException(o.getClass().getName() +
- " can not be converted to int");
+ " can not be converted to int");
}
}
public static long longValue(Object o) {
@@ -65,7 +65,7 @@ public final class Conversions {
return ((Number)o).longValue();
} else {
throw new ClassCastException(o.getClass().getName() +
- " can not be converted to long");
+ " can not be converted to long");
}
}
public static float floatValue(Object o) {
@@ -75,7 +75,7 @@ public final class Conversions {
return ((Number)o).floatValue();
} else {
throw new ClassCastException(o.getClass().getName() +
- " can not be converted to float");
+ " can not be converted to float");
}
}
public static double doubleValue(Object o) {
@@ -85,7 +85,7 @@ public final class Conversions {
return ((Number)o).doubleValue();
} else {
throw new ClassCastException(o.getClass().getName() +
- " can not be converted to double");
+ " can not be converted to double");
}
}
public static byte byteValue(Object o) {
@@ -95,7 +95,7 @@ public final class Conversions {
return ((Number)o).byteValue();
} else {
throw new ClassCastException(o.getClass().getName() +
- " can not be converted to byte");
+ " can not be converted to byte");
}
}
public static short shortValue(Object o) {
@@ -105,7 +105,7 @@ public final class Conversions {
return ((Number)o).shortValue();
} else {
throw new ClassCastException(o.getClass().getName() +
- " can not be converted to short");
+ " can not be converted to short");
}
}
public static char charValue(Object o) {
@@ -115,7 +115,7 @@ public final class Conversions {
return ((Character)o).charValue();
} else {
throw new ClassCastException(o.getClass().getName() +
- " can not be converted to char");
+ " can not be converted to char");
}
}
public static boolean booleanValue(Object o) {
@@ -125,10 +125,10 @@ public final class Conversions {
return ((Boolean)o).booleanValue();
} else {
throw new ClassCastException(o.getClass().getName() +
- " can not be converted to boolean");
+ " can not be converted to boolean");
}
}
-
+
// identity function for now. This is not typed to "void" because we happen
// to know that in Java, any void context (i.e., {@link ExprStmt})
// can also handle a return value.
diff --git a/testing/src/test/java/org/aspectj/testing/util/RunUtils.java b/testing/src/test/java/org/aspectj/testing/util/RunUtils.java
index 86c29a4a2..df889f222 100644
--- a/testing/src/test/java/org/aspectj/testing/util/RunUtils.java
+++ b/testing/src/test/java/org/aspectj/testing/util/RunUtils.java
@@ -1,20 +1,19 @@
/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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:
- * Xerox/PARC 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:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.testing.util;
import java.io.PrintStream;
-import java.util.Iterator;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
@@ -28,341 +27,351 @@ import org.aspectj.testing.run.RunValidator;
import org.aspectj.util.LangUtil;
/**
- *
+ *
*/
public class RunUtils {
- /** enable verbose for this an any related AbstractRunSpec children */
- public static void enableVerbose(AbstractRunSpec spec) { // instanceof hack
- LangUtil.throwIaxIfNull(spec, "spec");
- spec.runtime.setVerbose(true);
- for (Iterator iter = spec.getChildren().iterator(); iter.hasNext();) {
- IRunSpec child = (IRunSpec) iter.next();
+ /** enable verbose for this an any related AbstractRunSpec children */
+ public static void enableVerbose(AbstractRunSpec spec) { // instanceof hack
+ LangUtil.throwIaxIfNull(spec, "spec");
+ spec.runtime.setVerbose(true);
+ for (Object element : spec.getChildren()) {
+ IRunSpec child = (IRunSpec) element;
if (child instanceof AbstractRunSpec) {
- enableVerbose((AbstractRunSpec) child);
- }
+ enableVerbose((AbstractRunSpec) child);
+ }
+ }
+ }
+
+ /**
+ * Calculate failures for this status.
+ * If the input status has no children and failed, the result is 1.
+ * If it has children and recurse is false, then
+ * the result is the number of children whose status has failed
+ * (so a failed status with some passing and no failing children
+ * will return 0).
+ * If it has children and recurse is true,
+ * then return the number of leaf failures in the tree,
+ * ignoring (roll-up) node failures.
+ * @return number of failures in children of this status
+ */
+ public static int numFailures(IRunStatus status, boolean recurse) {
+ int numFails = 0;
+ IRunStatus[] children = status.getChildren();
+ int numChildren = (null == children? 0 : children.length);
+ if (0 == numChildren) {
+ if (!RunValidator.NORMAL.runPassed(status)) {
+ return 1;
+ }
+ } else {
+ // int i = 0;
+ for (IRunStatus element : children) {
+ if (recurse) {
+ numFails += numFailures(element, recurse);
+ } else {
+ if (!RunValidator.NORMAL.runPassed(element)) {
+ numFails++;
+ }
+ }
+ }
+ }
+ return numFails;
+ }
+
+ // ------------------------ printing status
+ public static void printShort(PrintStream out, IRunStatus status) {
+ if ((null == out) || (null == status)) {
+ return;
+ }
+ printShort(out, "", status);
+ }
+
+ public static void printShort(PrintStream out, String prefix, IRunStatus status) {
+ int numFails = numFailures(status, true);
+ String fails = (0 == numFails ? "" : " - " + numFails + " failures");
+ out.println(prefix + toShortString(status) + fails);
+ IRunStatus[] children = status.getChildren();
+ int numChildren = (null == children? 0 : children.length);
+ if (0 < numChildren) {
+ int i = 0;
+ for (IRunStatus element : children) {
+ printShort(out, prefix + "[" + LangUtil.toSizedString(i++, 3) + "]: ", element);
+ if (!RunValidator.NORMAL.runPassed(element)) {
+ numFails++;
+ }
+ }
+ }
+ }
+
+ public static void print(PrintStream out, IRunStatus status) {
+ if ((null == out) || (null == status)) {
+ return;
+ }
+ print(out, "", status);
+ }
+
+ public static void print(PrintStream out, String prefix, IRunStatus status) {
+ print(out, prefix, status, MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ALL);
+ }
+
+ public static void print(PrintStream out, String prefix, IRunStatus status,
+ IMessageRenderer renderer, IMessageHandler selector) {
+ String label = status.getIdentifier()
+ + (status.runResult() ? "PASS" : "FAIL");
+ out.println(prefix + label);
+ out.println(prefix + debugString(status));
+ IMessageHolder messageHolder = status;
+ if ((null != messageHolder) && (0 < messageHolder.numMessages(null, true))) {
+ MessageUtil.print(out, messageHolder, prefix, renderer, selector);
+ }
+ Throwable thrown = status.getThrown();
+ if (null != thrown) {
+ out.println(prefix + "--- printing stack trace for thrown");
+ thrown.printStackTrace(out);
+ }
+ IRunStatus[] children = status.getChildren();
+ int numChildren = (null == children? 0 : children.length);
+ int numFails = 0;
+ if (0 < numChildren) {
+ out.println(prefix + "--- printing children [" + numChildren + "]");
+ int i = 0;
+ for (IRunStatus element : children) {
+ print(out, prefix + "[" + LangUtil.toSizedString(i++, 3) + "]: ", element);
+ if (!RunValidator.NORMAL.runPassed(element)) {
+ numFails++;
+ }
+ }
+ }
+ if (0 < numFails) {
+ label = numFails + " fails " + label;
+ }
+ out.println("");
+ }
+
+
+ public static String debugString(IRunStatus status) {
+ if (null == status) {
+ return "null";
}
- }
-
- /**
- * Calculate failures for this status.
- * If the input status has no children and failed, the result is 1.
- * If it has children and recurse is false, then
- * the result is the number of children whose status has failed
- * (so a failed status with some passing and no failing children
- * will return 0).
- * If it has children and recurse is true,
- * then return the number of leaf failures in the tree,
- * ignoring (roll-up) node failures.
- * @return number of failures in children of this status
- */
- public static int numFailures(IRunStatus status, boolean recurse) {
- int numFails = 0;
- IRunStatus[] children = status.getChildren();
- int numChildren = (null == children? 0 : children.length);
- if (0 == numChildren) {
- if (!RunValidator.NORMAL.runPassed(status)) {
- return 1;
- }
- } else {
-// int i = 0;
- for (int j = 0; j < children.length; j++) {
- if (recurse) {
- numFails += numFailures(children[j], recurse);
- } else {
- if (!RunValidator.NORMAL.runPassed(children[j])) {
- numFails++;
- }
- }
- }
- }
- return numFails;
- }
-
- // ------------------------ printing status
- public static void printShort(PrintStream out, IRunStatus status) {
- if ((null == out) || (null == status)) {
- return;
- }
- printShort(out, "", status);
- }
+ final String[] LABELS =
+ new String[] {
+ "runResult",
+ "id",
+ "result",
+ "numChildren",
+ "completed",
+ //"parent",
+ "abort",
+ "started",
+ "thrown",
+ "messages" };
+ String runResult = status.runResult() ? "PASS" : "FAIL";
+ Throwable thrown = status.getThrown();
+ String thrownString = LangUtil.unqualifiedClassName(thrown);
+ IRunStatus[] children = status.getChildren();
+ String numChildren = (null == children? "0" : ""+children.length);
+ String numMessages = ""+status.numMessages(null, IMessageHolder.EQUAL);
+ Object[] values =
+ new Object[] {
+ runResult,
+ status.getIdentifier(),
+ status.getResult(),
+ numChildren,
+ status.isCompleted(),
+ //status.getParent(), // costly if parent printing us
+ status.getAbortRequest(),
+ status.started(),
+ thrownString,
+ numMessages };
+ return org.aspectj.testing.util.LangUtil.debugStr(status.getClass(), LABELS, values);
+ }
- public static void printShort(PrintStream out, String prefix, IRunStatus status) {
- int numFails = numFailures(status, true);
- String fails = (0 == numFails ? "" : " - " + numFails + " failures");
- out.println(prefix + toShortString(status) + fails);
- IRunStatus[] children = status.getChildren();
- int numChildren = (null == children? 0 : children.length);
- if (0 < numChildren) {
- int i = 0;
- for (int j = 0; j < children.length; j++) {
- printShort(out, prefix + "[" + LangUtil.toSizedString(i++, 3) + "]: ", children[j]);
- if (!RunValidator.NORMAL.runPassed(children[j])) {
- numFails++;
- }
- }
- }
- }
+ public static String toShortString(IRunStatus status) {
+ if (null == status) {
+ return "null";
+ }
+ String runResult = status.runResult() ? " PASS: " : " FAIL: ";
+ return (runResult + status.getIdentifier());
+ }
- public static void print(PrintStream out, IRunStatus status) {
- if ((null == out) || (null == status)) {
- return;
- }
- print(out, "", status);
- }
-
- public static void print(PrintStream out, String prefix, IRunStatus status) {
- print(out, prefix, status, MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ALL);
- }
+ /** renderer for IRunStatus */
+ public static interface IRunStatusPrinter {
+ void printRunStatus(PrintStream out, IRunStatus status);
+ }
- public static void print(PrintStream out, String prefix, IRunStatus status,
- IMessageRenderer renderer, IMessageHandler selector) {
- String label = status.getIdentifier()
- + (status.runResult() ? "PASS" : "FAIL");
- out.println(prefix + label);
- out.println(prefix + debugString(status));
- IMessageHolder messageHolder = status;
- if ((null != messageHolder) && (0 < messageHolder.numMessages(null, true))) {
- MessageUtil.print(out, messageHolder, prefix, renderer, selector);
- }
- Throwable thrown = status.getThrown();
- if (null != thrown) {
- out.println(prefix + "--- printing stack trace for thrown");
- thrown.printStackTrace(out);
- }
- IRunStatus[] children = status.getChildren();
- int numChildren = (null == children? 0 : children.length);
- int numFails = 0;
- if (0 < numChildren) {
- out.println(prefix + "--- printing children [" + numChildren + "]");
- int i = 0;
- for (int j = 0; j < children.length; j++) {
- print(out, prefix + "[" + LangUtil.toSizedString(i++, 3) + "]: ", children[j]);
- if (!RunValidator.NORMAL.runPassed(children[j])) {
- numFails++;
- }
- }
- }
- if (0 < numFails) {
- label = numFails + " fails " + label;
- }
- out.println("");
- }
+ public static final IRunStatusPrinter VERBOSE_PRINTER = new IRunStatusPrinter() {
+ @Override
+ public String toString() { return "VERBOSE_PRINTER"; }
+ /** Render IRunStatus produced by running an AjcTest */
+ @Override
+ public void printRunStatus(PrintStream out, IRunStatus status) {
+ printRunStatus(out, status, "");
+ }
+ private void printRunStatus(PrintStream out, IRunStatus status, String prefix) {
+ LangUtil.throwIaxIfNull(out, "out");
+ LangUtil.throwIaxIfNull(status, "status");
+ String label = (status.runResult() ? " PASS: " : " FAIL: ")
+ + status.getIdentifier();
+ out.println(prefix + "------------ " + label);
+ out.println(prefix + "--- result: " + status.getResult());
+ if (0 < status.numMessages(null, true)) {
+ out.println(prefix + "--- messages ");
+ MessageUtil.print(out, status, prefix, MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ALL);
+ }
+ Throwable thrown = status.getThrown();
+ if (null != thrown) {
+ out.println(prefix + "--- thrown");
+ thrown.printStackTrace(out);
+ }
+ IRunStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ String number = "[" + LangUtil.toSizedString(i,3) + "] ";
+ printRunStatus(out, children[i], prefix + number);
+ }
+ }
+ };
-
- public static String debugString(IRunStatus status) {
- if (null == status) {
- return "null";
- }
- final String[] LABELS =
- new String[] {
- "runResult",
- "id",
- "result",
- "numChildren",
- "completed",
- //"parent",
- "abort",
- "started",
- "thrown",
- "messages" };
- String runResult = status.runResult() ? "PASS" : "FAIL";
- Throwable thrown = status.getThrown();
- String thrownString = LangUtil.unqualifiedClassName(thrown);
- IRunStatus[] children = status.getChildren();
- String numChildren = (null == children? "0" : ""+children.length);
- String numMessages = ""+status.numMessages(null, IMessageHolder.EQUAL);
- Object[] values =
- new Object[] {
- runResult,
- status.getIdentifier(),
- status.getResult(),
- numChildren,
- new Boolean(status.isCompleted()),
- //status.getParent(), // costly if parent printing us
- status.getAbortRequest(),
- new Boolean(status.started()),
- thrownString,
- numMessages };
- return org.aspectj.testing.util.LangUtil.debugStr(status.getClass(), LABELS, values);
- }
+ /** print only status and fail/abort messages */
+ public static final IRunStatusPrinter TERSE_PRINTER = new IRunStatusPrinter() {
+ @Override
+ public String toString() { return "TERSE_PRINTER"; }
- public static String toShortString(IRunStatus status) {
- if (null == status) {
- return "null";
- }
- String runResult = status.runResult() ? " PASS: " : " FAIL: ";
- return (runResult + status.getIdentifier());
- }
-
- /** renderer for IRunStatus */
- public static interface IRunStatusPrinter {
- void printRunStatus(PrintStream out, IRunStatus status);
- }
-
- public static final IRunStatusPrinter VERBOSE_PRINTER = new IRunStatusPrinter() {
- public String toString() { return "VERBOSE_PRINTER"; }
- /** Render IRunStatus produced by running an AjcTest */
- public void printRunStatus(PrintStream out, IRunStatus status) {
- printRunStatus(out, status, "");
- }
- private void printRunStatus(PrintStream out, IRunStatus status, String prefix) {
- LangUtil.throwIaxIfNull(out, "out");
- LangUtil.throwIaxIfNull(status, "status");
- String label = (status.runResult() ? " PASS: " : " FAIL: ")
- + status.getIdentifier();
- out.println(prefix + "------------ " + label);
- out.println(prefix + "--- result: " + status.getResult());
- if (0 < status.numMessages(null, true)) {
- out.println(prefix + "--- messages ");
- MessageUtil.print(out, status, prefix, MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ALL);
- }
- Throwable thrown = status.getThrown();
- if (null != thrown) {
- out.println(prefix + "--- thrown");
- thrown.printStackTrace(out);
- }
- IRunStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- String number = "[" + LangUtil.toSizedString(i,3) + "] ";
- printRunStatus(out, children[i], prefix + number);
+ /** print only status and fail messages */
+ @Override
+ public void printRunStatus(PrintStream out, IRunStatus status) {
+ printRunStatus(out, status, "");
+ }
+ private void printRunStatus(PrintStream out, IRunStatus status, String prefix) {
+ LangUtil.throwIaxIfNull(out, "out");
+ LangUtil.throwIaxIfNull(status, "status");
+ String label = (status.runResult() ? "PASS: " : "FAIL: ")
+ + status.getIdentifier();
+ out.println(prefix + label);
+ Object result = status.getResult();
+ if ((null != result) && (IRunStatus.PASS != result) && (IRunStatus.FAIL != result)) {
+ out.println(prefix + "--- result: " + status.getResult());
+ }
+ if (0 < status.numMessages(IMessage.FAIL, true)) {
+ MessageUtil.print(out, status, prefix, MessageUtil.MESSAGE_ALL, MessageUtil.PICK_FAIL_PLUS);
+ }
+ Throwable thrown = status.getThrown();
+ if (null != thrown) {
+ out.println(prefix + "--- thrown: " + LangUtil.renderException(thrown, true));
}
- }
- };
+ IRunStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ if (!children[i].runResult()) {
+ String number = "[" + LangUtil.toSizedString(i,3) + "] ";
+ printRunStatus(out, children[i], prefix + number);
+ }
+ }
+ out.println("");
+ }
+ };
- /** print only status and fail/abort messages */
- public static final IRunStatusPrinter TERSE_PRINTER = new IRunStatusPrinter() {
- public String toString() { return "TERSE_PRINTER"; }
+ /** Render IRunStatus produced by running an AjcTest.Suite. */
+ public static final IRunStatusPrinter AJCSUITE_PRINTER = new IRunStatusPrinter() {
+ @Override
+ public String toString() { return "AJCSUITE_PRINTER"; }
- /** print only status and fail messages */
- public void printRunStatus(PrintStream out, IRunStatus status) {
- printRunStatus(out, status, "");
- }
- private void printRunStatus(PrintStream out, IRunStatus status, String prefix) {
- LangUtil.throwIaxIfNull(out, "out");
- LangUtil.throwIaxIfNull(status, "status");
- String label = (status.runResult() ? "PASS: " : "FAIL: ")
- + status.getIdentifier();
- out.println(prefix + label);
- Object result = status.getResult();
- if ((null != result) && (IRunStatus.PASS != result) && (IRunStatus.FAIL != result)) {
- out.println(prefix + "--- result: " + status.getResult());
- }
- if (0 < status.numMessages(IMessage.FAIL, true)) {
- MessageUtil.print(out, status, prefix, MessageUtil.MESSAGE_ALL, MessageUtil.PICK_FAIL_PLUS);
- }
- Throwable thrown = status.getThrown();
- if (null != thrown) {
- out.println(prefix + "--- thrown: " + LangUtil.renderException(thrown, true));
- }
- IRunStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- if (!children[i].runResult()) {
- String number = "[" + LangUtil.toSizedString(i,3) + "] ";
- printRunStatus(out, children[i], prefix + number);
- }
- }
- out.println("");
- }
- };
+ /**
+ * Render IRunStatus produced by running an AjcTest.Suite.
+ * This renders only test failures and
+ * a summary at the end.
+ */
+ @Override
+ public void printRunStatus(PrintStream out, IRunStatus status) {
+ LangUtil.throwIaxIfNull(out, "out");
+ LangUtil.throwIaxIfNull(status, "status");
+ final String prefix = "";
+ final boolean failed = status.runResult();
+ String label = (status.runResult() ? "PASS: " : "FAIL: ")
+ + status.getIdentifier();
+ out.println(prefix + label);
+ // print all messages - these are validator comments
+ if (0 < status.numMessages(null, true)) {
+ MessageUtil.print(out, status, "init", MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ALL);
+ }
+ // XXX ignore thrown if failed - will be printed as message anyway?
+ Throwable thrown = status.getThrown();
+ if ((null != thrown) && !failed) {
+ out.println(prefix + "--- printing stack trace for thrown");
+ thrown.printStackTrace(out);
+ }
+ IRunStatus[] children = status.getChildren();
+ int numChildren = (null == children? 0 : children.length);
+ int numFails = 0;
+ if (0 < numChildren) {
+ for (IRunStatus element : children) {
+ if (!RunValidator.NORMAL.runPassed(element)) {
+ numFails++;
+ }
+ }
+ }
+ if (0 < numFails) {
+ out.println(prefix + "--- " + numFails + " failures when running " + children.length + " tests");
+ for (int j = 0; j < children.length; j++) {
+ if (!RunValidator.NORMAL.runPassed(children[j])) {
+ print(out, prefix + "[" + LangUtil.toSizedString(j, 3) + "]: ", children[j]);
+ out.println("");
+ }
+ }
+ }
+ label = "ran " + children.length + " tests"
+ + (numFails == 0 ? "" : "(" + numFails + " fails)");
+ out.println("");
+ }
- /** Render IRunStatus produced by running an AjcTest.Suite. */
- public static final IRunStatusPrinter AJCSUITE_PRINTER = new IRunStatusPrinter() {
- public String toString() { return "AJCSUITE_PRINTER"; }
-
- /**
- * Render IRunStatus produced by running an AjcTest.Suite.
- * This renders only test failures and
- * a summary at the end.
- */
- public void printRunStatus(PrintStream out, IRunStatus status) {
- LangUtil.throwIaxIfNull(out, "out");
- LangUtil.throwIaxIfNull(status, "status");
- final String prefix = "";
- final boolean failed = status.runResult();
- String label = (status.runResult() ? "PASS: " : "FAIL: ")
- + status.getIdentifier();
- out.println(prefix + label);
- // print all messages - these are validator comments
- if (0 < status.numMessages(null, true)) {
- MessageUtil.print(out, status, "init", MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ALL);
- }
- // XXX ignore thrown if failed - will be printed as message anyway?
- Throwable thrown = status.getThrown();
- if ((null != thrown) && !failed) {
- out.println(prefix + "--- printing stack trace for thrown");
- thrown.printStackTrace(out);
- }
- IRunStatus[] children = status.getChildren();
- int numChildren = (null == children? 0 : children.length);
- int numFails = 0;
- if (0 < numChildren) {
- for (int j = 0; j < children.length; j++) {
- if (!RunValidator.NORMAL.runPassed(children[j])) {
- numFails++;
- }
- }
- }
- if (0 < numFails) {
- out.println(prefix + "--- " + numFails + " failures when running " + children.length + " tests");
- for (int j = 0; j < children.length; j++) {
- if (!RunValidator.NORMAL.runPassed(children[j])) {
- print(out, prefix + "[" + LangUtil.toSizedString(j, 3) + "]: ", children[j]);
- out.println("");
- }
- }
- }
- label = "ran " + children.length + " tests"
- + (numFails == 0 ? "" : "(" + numFails + " fails)");
- out.println("");
- }
-
- };
- /** Render IRunStatus produced by running an AjcTest (verbose) */
- public static final IRunStatusPrinter AJCTEST_PRINTER = VERBOSE_PRINTER;
+ };
+ /** Render IRunStatus produced by running an AjcTest (verbose) */
+ public static final IRunStatusPrinter AJCTEST_PRINTER = VERBOSE_PRINTER;
/** print this with messages, then children using AJCRUN_PRINTER */
- public static final IRunStatusPrinter AJC_PRINTER = new IRunStatusPrinter() {
- public String toString() { return "AJC_PRINTER"; }
- /** Render IRunStatus produced by running an AjcTest */
- public void printRunStatus(PrintStream out, IRunStatus status) {
- LangUtil.throwIaxIfNull(out, "out");
- LangUtil.throwIaxIfNull(status, "status");
- String label = (status.runResult() ? " PASS: " : " FAIL: ")
- + status.getIdentifier();
- out.println("------------ " + label);
- MessageUtil.print(out, status, "", MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ALL);
- IRunStatus[] children = status.getChildren();
- for (int i = 0; i < children.length; i++) {
- AJCRUN_PRINTER.printRunStatus(out, children[i]);
+ public static final IRunStatusPrinter AJC_PRINTER = new IRunStatusPrinter() {
+ @Override
+ public String toString() { return "AJC_PRINTER"; }
+ /** Render IRunStatus produced by running an AjcTest */
+ @Override
+ public void printRunStatus(PrintStream out, IRunStatus status) {
+ LangUtil.throwIaxIfNull(out, "out");
+ LangUtil.throwIaxIfNull(status, "status");
+ String label = (status.runResult() ? " PASS: " : " FAIL: ")
+ + status.getIdentifier();
+ out.println("------------ " + label);
+ MessageUtil.print(out, status, "", MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ALL);
+ IRunStatus[] children = status.getChildren();
+ for (IRunStatus element : children) {
+ AJCRUN_PRINTER.printRunStatus(out, element);
}
- //out.println("------------ END " + label);
- out.println("");
- }
- };
+ //out.println("------------ END " + label);
+ out.println("");
+ }
+ };
/** print only fail messages */
- public static final IRunStatusPrinter AJCRUN_PRINTER = new IRunStatusPrinter() {
- public String toString() { return "AJCRUN_PRINTER"; }
- /** Render IRunStatus produced by running an AjcTest child */
- public void printRunStatus(PrintStream out, IRunStatus status) {
- LangUtil.throwIaxIfNull(out, "out");
- LangUtil.throwIaxIfNull(status, "status");
- final boolean orGreater = false;
- int numFails = status.numMessages(IMessage.FAIL, orGreater);
- if (0 < numFails) {
- out.println("--- " + status.getIdentifier());
- IMessage[] fails = status.getMessages(IMessage.FAIL, orGreater);
- for (int i = 0; i < fails.length; i++) {
- out.println("[fail " + LangUtil.toSizedString(i, 3) + "]: "
- + MessageUtil.MESSAGE_ALL.renderToString(fails[i]));
+ public static final IRunStatusPrinter AJCRUN_PRINTER = new IRunStatusPrinter() {
+ @Override
+ public String toString() { return "AJCRUN_PRINTER"; }
+ /** Render IRunStatus produced by running an AjcTest child */
+ @Override
+ public void printRunStatus(PrintStream out, IRunStatus status) {
+ LangUtil.throwIaxIfNull(out, "out");
+ LangUtil.throwIaxIfNull(status, "status");
+ final boolean orGreater = false;
+ int numFails = status.numMessages(IMessage.FAIL, orGreater);
+ if (0 < numFails) {
+ out.println("--- " + status.getIdentifier());
+ IMessage[] fails = status.getMessages(IMessage.FAIL, orGreater);
+ for (int i = 0; i < fails.length; i++) {
+ out.println("[fail " + LangUtil.toSizedString(i, 3) + "]: "
+ + MessageUtil.MESSAGE_ALL.renderToString(fails[i]));
}
- }
- }
- };
+ }
+ }
+ };
private RunUtils() {
}
-
+
}