]> source.dussan.org Git - aspectj.git/commitdiff
support weaving of java. and javax. in ltw - risky business
authoraclement <aclement>
Mon, 21 Jan 2008 20:07:52 +0000 (20:07 +0000)
committeraclement <aclement>
Mon, 21 Jan 2008 20:07:52 +0000 (20:07 +0000)
weaver/src/org/aspectj/weaver/World.java
weaver/src/org/aspectj/weaver/tools/WeavingAdaptor.java

index d0e52546bf514196b9c40cf62b091d510e61cf9f..53177ab45d0de59a0862e9b39122a49faf6b5f19 100644 (file)
@@ -787,6 +787,8 @@ public abstract class World implements Dump.INode {
        public Properties getExtraConfiguration() {
                return extraConfiguration;
        }
+    public final static String xsetWEAVE_JAVA_PACKAGES = "weaveJavaPackages"; // default false - controls LTW
+    public final static String xsetWEAVE_JAVAX_PACKAGES = "weaveJavaxPackages"; // default false - controls LTW
        public final static String xsetCAPTURE_ALL_CONTEXT = "captureAllContext"; // default false
        public final static String xsetACTIVATE_LIGHTWEIGHT_DELEGATES = "activateLightweightDelegates"; // default true
        public final static String xsetRUN_MINIMAL_MEMORY ="runMinimalMemory"; // default true
index ff24576251cd59bff9cdb881c5c70537b4a98001..5f1205d3e92d72c15d8416c09207ddcd61d839b7 100644 (file)
@@ -26,6 +26,7 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 
@@ -46,6 +47,7 @@ import org.aspectj.util.LangUtil;
 import org.aspectj.weaver.IClassFileProvider;
 import org.aspectj.weaver.IWeaveRequestor;
 import org.aspectj.weaver.ResolvedType;
+import org.aspectj.weaver.World;
 import org.aspectj.weaver.bcel.BcelObjectType;
 import org.aspectj.weaver.bcel.BcelWeaver;
 import org.aspectj.weaver.bcel.BcelWorld;
@@ -87,6 +89,12 @@ public class WeavingAdaptor implements IMessageContext {
        protected Map generatedClasses = new HashMap(); /* String -> UnwovenClassFile */
        protected BcelObjectType delegateForCurrentClass; // lazily initialized, should be used to prevent parsing bytecode multiple times
 
+       private int weavingSpecialTypes = 0;
+       private static final int INITIALIZED       = 0x1;
+       private static final int WEAVE_JAVA_PACKAGE = 0x2;
+       private static final int WEAVE_JAVAX_PACKAGE= 0x4;
+       
+       
        private static Trace trace = TraceFactory.getTraceFactory().getTrace(WeavingAdaptor.class);
 
        protected WeavingAdaptor () {
@@ -301,10 +309,25 @@ public class WeavingAdaptor implements IMessageContext {
     }
 
        private boolean shouldWeaveName (String name) {
+               if ((weavingSpecialTypes&INITIALIZED)==0) {
+                       weavingSpecialTypes|=INITIALIZED;
+                       // initialize it
+                       Properties p = weaver.getWorld().getExtraConfiguration();
+                       if (p!=null) {
+                               boolean b = p.getProperty(World.xsetWEAVE_JAVA_PACKAGES,"false").equalsIgnoreCase("true");
+                               if (b) {
+                                       weavingSpecialTypes|=WEAVE_JAVA_PACKAGE;
+                               }
+                               b = p.getProperty(World.xsetWEAVE_JAVAX_PACKAGES,"false").equalsIgnoreCase("true");
+                               if (b) {
+                                       weavingSpecialTypes|=WEAVE_JAVAX_PACKAGE;
+                               }
+                       }
+               }
                boolean should =
-                      !((name.startsWith("org.aspectj.")
-                || name.startsWith("java.")
-                || name.startsWith("javax."))
+                      !(name.startsWith("org.aspectj.")
+                || (name.startsWith("java.") && (weavingSpecialTypes&WEAVE_JAVA_PACKAGE)==0)
+                || (name.startsWith("javax.") && (weavingSpecialTypes&WEAVE_JAVAX_PACKAGE)==0)
                 //|| name.startsWith("$Proxy")//JDK proxies//FIXME AV is that 1.3 proxy ? fe. ataspect.$Proxy0 is a java5 proxy...
                 || name.startsWith("sun.reflect."));//JDK reflect
                return should;