From 0d3581d0e357e66523b8dc2b642546051712c36b Mon Sep 17 00:00:00 2001 From: acolyer Date: Wed, 2 Jun 2004 12:20:38 +0000 Subject: [PATCH] integrating changes from HEAD --- weaver/src/org/aspectj/weaver/Lint.java | 3 ++ .../aspectj/weaver/WeavingURLClassLoader.java | 8 ++--- .../aspectj/weaver/XlintDefault.properties | 4 ++- .../aspectj/weaver/bcel/BcelClassWeaver.java | 10 ++++-- .../aspectj/weaver/tools/WeavingAdaptor.java | 16 +++------ weaver/testdata/ltw-deaspects.jar | Bin 0 -> 1096 bytes weaver/testdata/ltw-dwaspects.jar | Bin 0 -> 1100 bytes .../weaver/WeavingURLClassLoaderTest.java | 31 ++++++++++++++++++ 8 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 weaver/testdata/ltw-deaspects.jar create mode 100644 weaver/testdata/ltw-dwaspects.jar diff --git a/weaver/src/org/aspectj/weaver/Lint.java b/weaver/src/org/aspectj/weaver/Lint.java index 8b0d82ddd..9e02bf7ae 100644 --- a/weaver/src/org/aspectj/weaver/Lint.java +++ b/weaver/src/org/aspectj/weaver/Lint.java @@ -58,6 +58,9 @@ public class Lint { 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; diff --git a/weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java b/weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java index c01f18812..347cb104c 100644 --- a/weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java +++ b/weaver/src/org/aspectj/weaver/WeavingURLClassLoader.java @@ -17,10 +17,6 @@ import java.io.File; 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; @@ -28,8 +24,8 @@ import java.util.List; 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 { diff --git a/weaver/src/org/aspectj/weaver/XlintDefault.properties b/weaver/src/org/aspectj/weaver/XlintDefault.properties index 91ce5d469..3b584d93f 100644 --- a/weaver/src/org/aspectj/weaver/XlintDefault.properties +++ b/weaver/src/org/aspectj/weaver/XlintDefault.properties @@ -12,4 +12,6 @@ unmatchedSuperTypeInCall = warning canNotImplementLazyTjp = warning needsSerialVersionUIDField = ignore -brokeSerialVersionCompatibility = ignore \ No newline at end of file +brokeSerialVersionCompatibility = ignore + +noInterfaceCtorJoinpoint = warning \ No newline at end of file diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 1c3b93be0..2a487d008 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -360,7 +360,10 @@ class BcelClassWeaver implements IClassWeaver { // 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); } @@ -402,7 +405,8 @@ class BcelClassWeaver implements IClassWeaver { } - 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("")) continue; @@ -410,8 +414,10 @@ class BcelClassWeaver implements IClassWeaver { if (ih != null && isThisCall(ih)) { LazyMethodGen donor = getCalledMethod(ih); inlineMethod(donor, mg, ih); + inlinedSomething = true; } } + return inlinedSomething; } private void positionAndImplement(List initializationShadows) { diff --git a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java index a7cd1ed74..f89dbb533 100644 --- a/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -18,32 +18,23 @@ import java.io.IOException; 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; /** @@ -271,14 +262,15 @@ public class WeavingAdaptor { 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)); } } diff --git a/weaver/testdata/ltw-deaspects.jar b/weaver/testdata/ltw-deaspects.jar new file mode 100644 index 0000000000000000000000000000000000000000..982c609ad5c3220ceaa013661d3c39e2433fa354 GIT binary patch literal 1096 zcmWIWW@Zs#-~d9&taSzqNI-;vg~8V~#8KDN&rRRg(a+P(H8@1i*X`da28PeRXHNTg z>*`(P_14uocjo-&AcHH$51tn3dHL#i`d%zuwI!%PN6*7o?_*HGx%0Xw&UorRdiv-o z6GMPEJIAIg;a!$Mi_C#I0H^h$Kv|!VaF^8NoW!D3*P^2QB0V6pxHvZ?+F#gFCd z%Bj{ID`Hp{E)aVvsLvS|pu{*?$iuf+a+~tqw40e_%NHC|_x+=+mZikc#4q9brI)>a zN>$pfgJR{A*B3u~^L;LmnECJ5-@oh)I(bH0^w;Ow2uwR{yYWHgCGQ5ql8_&K^9y(E zHr>1{QgE7=!l4U?wXf}Xdn;?=ZNIa^mT{k1o!@`5{}y#~^6r|;g4-p3neNrvv*&G| zrITm*$*-d2x|2%u=AZQX@+{PU ziub(2tewj}I5|sRJ-)dvVr6bVSH7>c zn|k!GmTAIQR@IX}tygSS_O8vD8*=g;*FNPvZ)#Nkp9)P~n4{gxGHKT-Z=T66b2(Rh zO$vXq=jOfXrrWoCxFi&s>TTY*aLGTO%QM@qJ)7#@yGQoco0X-pKQp)v?>KZJ>RFxb zn#`xclVi89(O;oFb-L+!q3*K1@@L&oed0Roa$?~;kK3VPzE@Aih@Uc$aN=2H$kVb_ zO(RF;N$lP=b4sRGtUP4BJ8{~cM_vh2{DhZU<~e%xGet7*y1C`pi|teQ@I22bpBv_u z{Y(0mo#M}mUjnkfj|nS=ibvi}Io|7TTPI$b}(Xw_%%?Q%zzPr`%>nef?1oYizDSRFXRnRIdQ ziMYv1OZA;6C*AmQ($3BMA;;wQ6K~8tAB9ZZwyd!Cnz>^5#TSonJ55dPoFW+P)U$48 znw?OeviXwdQ+V<_Kk#&F^)4%l+3;fi1I9x-HYx>&Vh^d+N+itNnBu&P?OpbvXr4K; z=M}=;5@&; zzPJQ(#!ubx$o2l_JkkIAWuJL7Dz_LOl5rF`)$+ZizvX<3zKN|#qTmC4P)^C3#uxaU ziGd-X6_isLnM4>6Srs`KfwC$pz?E^)O+mH+l;aSf9>~O+{{p;O*+9yefUpxtuVe=C E0K>k%IsgCw literal 0 HcmV?d00001 diff --git a/weaver/testdata/ltw-dwaspects.jar b/weaver/testdata/ltw-dwaspects.jar new file mode 100644 index 0000000000000000000000000000000000000000..d3cbc6728d2964a495630b3de9a73e874ed1b222 GIT binary patch literal 1100 zcmWIWW@Zs#-~d9&taSzqNI-;vg~8V~#8KDN&rRRg(a+P(H8@1i*X`da28PeRXHNTg z>*`(P_14uocjo-&AcHH$51tn3dHL#i`d%zuwI!%PN6*7o?_*HGx%0Xw&UorRdiv-o z6GMPEJIAIg;a!$Mi_C#I0H^ihKv|!VaF^8NoW!Ek@Wi6L%)E3xAg8!EHze9$*iqzP z+r5mnG2BIgc}1D4#U2KBvT3_GF{`NxY~hsLmc0AyrrU4)7~?B0v;XffRCIg5sNA{l z^Jj*?5&B9Pwx3Q$3>`<aw_Gh^Z+g#dzCA*F-}cl{kINoPZDmuR$F@l}o%?km zZCCcWMRxlNq{=E^UJxkFv?}9Ke)~#m)649)x?bU|JUJCjAxD?ziA;TL+V-+xQ=IiO-QKpGLp!~uCTcLe_?;}llhrr> zR>XnrX-SpGr#%W_`(Eaq?|O3S0gJ1`%PRAnoqCxwn^)c4;{L+iFRU%Pq{_p3vF%S; z+4&du&9ZgA-np%%#AJz!UqlpRGCHlXAZBxl6m3rn|2)TgiskPb`)ixU5KA zu{0)yV|mzp&3C!+N`KxmExv7=y!?gL@xSr2rd;ZCeB$Y|b%OhrXobSAm)H$*D8Q&Fl0d#<%W`{6WHk%PaWZXsiO4dhRC<6 z8+6i77p~oOZ0)2s3SrAXPMO9l_V2a6g2!R5PRCDkmiUA-Kbe{JICMw$4dqGw68kI{ z)ot0LbyVqRll!XrH(j$AKW5)^)?QQhqP_QB;iW%!{+#row0>C`-=3eBzDhpcy6KE$ zpSD*}#ilc=`jzVp!?~)If9-4FoTNF4brM(Srh28o?_Z`qX-VsNro-}w8I)Io58l82 zoQZ*(M>_N0hH$updQG?kply~S=m4enSihxNUvrF F@c_4^#TNho literal 0 HcmV?d00001 diff --git a/weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java b/weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java index d3f940e4d..4035ed278 100644 --- a/weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java +++ b/weaver/testsrc/org/aspectj/weaver/WeavingURLClassLoaderTest.java @@ -35,6 +35,8 @@ public class WeavingURLClassLoaderTest extends TestCase { 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"; @@ -117,6 +119,35 @@ public class WeavingURLClassLoaderTest extends TestCase { } } + 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); -- 2.39.5