public final Kind serialVersionUIDBroken =
new Kind("brokeSerialVersionCompatibility", "serialVersionUID of type {0} is broken because of added field {1}");
+
+ public final Kind noInterfaceCtorJoinpoint =
+ new Kind("noInterfaceCtorJoinpoint","no interface constructor-execution join point - use {0}+ for implementing classes");
public Lint(World world) {
this.world = world;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-import java.net.URLStreamHandlerFactory;
import java.security.CodeSource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
-import org.aspectj.util.UtilClassLoader;
-import org.aspectj.weaver.tools.*;
+import org.aspectj.weaver.tools.WeavingAdaptor;
+import org.aspectj.weaver.tools.WeavingClassLoader;
public class WeavingURLClassLoader extends ExtensibleURLClassLoader implements WeavingClassLoader {
canNotImplementLazyTjp = warning
needsSerialVersionUIDField = ignore
-brokeSerialVersionCompatibility = ignore
\ No newline at end of file
+brokeSerialVersionCompatibility = ignore
+
+noInterfaceCtorJoinpoint = warning
\ No newline at end of file
// if we matched any initialization shadows, we inline and weave
if (! initializationShadows.isEmpty()) {
- inlineSelfConstructors(methodGens);
+ // Repeat next step until nothing left to inline...cant go on
+ // infinetly as compiler will have detected and reported
+ // "Recursive constructor invocation"
+ while (inlineSelfConstructors(methodGens));
positionAndImplement(initializationShadows);
}
}
- private void inlineSelfConstructors(List methodGens) {
+ private boolean inlineSelfConstructors(List methodGens) {
+ boolean inlinedSomething = false;
for (Iterator i = methodGens.iterator(); i.hasNext();) {
LazyMethodGen mg = (LazyMethodGen) i.next();
if (! mg.getName().equals("<init>")) continue;
if (ih != null && isThisCall(ih)) {
LazyMethodGen donor = getCalledMethod(ih);
inlineMethod(donor, mg, ih);
+ inlinedSomething = true;
}
}
+ return inlinedSomething;
}
private void positionAndImplement(List initializationShadows) {
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.StringTokenizer;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.MessageHandler;
import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.util.FileUtil;
import org.aspectj.weaver.IClassFileProvider;
import org.aspectj.weaver.IWeaveRequestor;
import org.aspectj.weaver.ResolvedTypeX;
-import org.aspectj.weaver.bcel.BcelObjectType;
import org.aspectj.weaver.bcel.BcelWeaver;
import org.aspectj.weaver.bcel.BcelWorld;
-import org.aspectj.weaver.bcel.LazyClassGen;
import org.aspectj.weaver.bcel.UnwovenClassFile;
/**
public boolean handleMessage(IMessage message) throws AbortException {
if (!isIgnoring(message.getKind())) {
- if (verbose) System.err.println(message.getMessage());
- throw new AbortException(message);
+ System.err.println(message.getSourceLocation()+": "+message.getKind()+" "+message.getMessage());
+ if (message.getKind() == IMessage.ERROR) throw new AbortException(message);
}
return true;
}
public boolean isIgnoring(Kind kind) {
- return ((kind == IMessage.INFO) || (kind == IMessage.DEBUG));
+ if (verbose) return false;
+ else return ((kind == IMessage.INFO) || (kind == IMessage.DEBUG));
}
}
private final static String WOVEN_JAR = BcweaverTests.TESTDATA_PATH + "/ltw-woven.jar";
private final static String JUNK_JAR = BcweaverTests.TESTDATA_PATH + "/ltw-junk.jar";
private final static String ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-aspects.jar";
+ private final static String DW_ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-dwaspects.jar";
+ private final static String DE_ADVICE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-deaspects.jar";
private final static String AROUNDCLOSURE_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-acaspects.jar";
private final static String ITD_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-itdaspects.jar";
private final static String PER_ASPECTS = BcweaverTests.TESTDATA_PATH + "/ltw-peraspects.jar";
}
}
+ public void testWeaveDeclareWarningAdvice () {
+ System.setProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH,DW_ADVICE_ASPECTS);
+ System.setProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,DW_ADVICE_ASPECTS + File.pathSeparator + CLASSES_JAR);
+ WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
+
+ try {
+ Class clazz = loader.loadClass("LTWHelloWorld");
+ invokeMain(clazz,new String[] {} );
+ }
+ catch (Exception ex) {
+ fail(ex.toString());
+ }
+ }
+
+ public void testWeaveDeclareErrorAdvice () {
+ System.setProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH,DE_ADVICE_ASPECTS);
+ System.setProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,DE_ADVICE_ASPECTS + File.pathSeparator + CLASSES_JAR);
+ WeavingURLClassLoader loader = new WeavingURLClassLoader(getClass().getClassLoader());
+
+ try {
+ Class clazz = loader.loadClass("LTWHelloWorld");
+ invokeMain(clazz,new String[] {} );
+ fail("Expecting org.aspectj.bridge.AbortException");
+ }
+ catch (Exception ex) {
+ assertTrue("Expecting org.aspectj.bridge.AbortException caught " + ex,(ex instanceof AbortException));
+ }
+ }
+
public void testWeaveAroundClosure () {
System.setProperty(WeavingURLClassLoader.WEAVING_ASPECT_PATH,AROUNDCLOSURE_ASPECTS);
System.setProperty(WeavingURLClassLoader.WEAVING_CLASS_PATH,AROUNDCLOSURE_ASPECTS + File.pathSeparator + CLASSES_JAR);