]> source.dussan.org Git - aspectj.git/commitdiff
incremental and application to binaries improved
authorjhugunin <jhugunin>
Fri, 3 Jan 2003 23:22:23 +0000 (23:22 +0000)
committerjhugunin <jhugunin>
Fri, 3 Jan 2003 23:22:23 +0000 (23:22 +0000)
weaver/src/org/aspectj/weaver/Lint.java
weaver/src/org/aspectj/weaver/ResolvedTypeMunger.java
weaver/src/org/aspectj/weaver/ResolvedTypeX.java
weaver/src/org/aspectj/weaver/XlintDefault.properties
weaver/src/org/aspectj/weaver/bcel/BcelObjectType.java
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/org/aspectj/weaver/bcel/BcelWorld.java
weaver/src/org/aspectj/weaver/bcel/UnwovenZipClassFile.java [deleted file]
weaver/src/org/aspectj/weaver/patterns/DeclareParents.java

index 82135a1dffa864acfb9b8e09aada3aa4df88c3e3..ce8850754d0eaba40c6a1d7b487ded8eeee1498b 100644 (file)
@@ -34,6 +34,9 @@ public class Lint {
        public final Kind unresolvableMember = 
                new Kind("unresolvableMember", "can not resolve this member: {0}");
        
+       public final Kind typeNotExposedToWeaver = 
+               new Kind("typeNotExposedToWeaver", "this affected type is not exposed to the weaver: {0}");
+       
        
        public Lint(World world) {
                this.world = world;
index 2b943ede1df327278f1b59a0a972ae0a1c007989..9f537c9d07bc828b89915792b1c8a43579683668 100644 (file)
@@ -46,7 +46,14 @@ public abstract class ResolvedTypeMunger {
     public boolean matches(ResolvedTypeX matchType) {
        ResolvedTypeX onType = matchType.getWorld().resolve(signature.getDeclaringType());
        //System.err.println("matching: " + this + " to " + matchType + " onType = " + onType);
-               if (matchType.equals(onType)) return true;
+               if (matchType.equals(onType)) { 
+                       if (!onType.isExposedToWeaver() &&
+                                       matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled())
+                       {
+                               matchType.getWorld().getLint().typeNotExposedToWeaver.signal(matchType.getName(), signature.getSourceLocation());
+                       }
+                       return true;
+               }
                //System.err.println("NO MATCH DIRECT");
                
        if (onType.isInterface()) {
index e8a76d99a0f4b43b810fcd43780aac3a57a70d53..1d4042ac9da28147bb763bcb768febad4ea237c6 100644 (file)
@@ -25,6 +25,7 @@ import org.aspectj.weaver.patterns.PerClause;
 public abstract class ResolvedTypeX extends TypeX {
 
     protected World world;
+       
 
     ResolvedTypeX(String signature, World world) {
         super(signature);
@@ -508,9 +509,12 @@ public abstract class ResolvedTypeX extends TypeX {
     
     public static abstract class Name extends ResolvedTypeX {
        protected ISourceContext sourceContext;
+       protected boolean exposedToWeaver;
+       
 
-        public Name(String signature, World world) {
+        public Name(String signature, World world, boolean exposedToWeaver) {
             super(signature, world);
+            this.exposedToWeaver = exposedToWeaver;
         }
                
            public final boolean isClass() {
@@ -565,6 +569,10 @@ public abstract class ResolvedTypeX extends TypeX {
                        return sourceContext;
                }
 
+               public boolean isExposedToWeaver() {
+                       return exposedToWeaver;
+               }
+
        }
     
     static class Array extends ResolvedTypeX {
@@ -1097,4 +1105,5 @@ public abstract class ResolvedTypeX extends TypeX {
        }
        
        public ISourceLocation getSourceLocation() { return null; }
+       public boolean isExposedToWeaver() { return false; }
 }
index eb5944dfa2b26000306bc2121b9b3b494d757bef..25e48c76e8f476375c5d9dd79e451bba0aee8cdc 100644 (file)
@@ -1,4 +1,6 @@
 invalidAbsoluteTypeName = warning
 invalidWildcardTypeName = ignore
 
-unresolvableMember = warning
\ No newline at end of file
+unresolvableMember = warning
+
+typeNotExposedToWeaver = warning
\ No newline at end of file
index e02410a7b0c9b1c3ae2cb56c4f34a77133f522cd..b67fc5238f7016a7362d7b186a1697a8572f5387 100644 (file)
@@ -58,8 +58,8 @@ public class BcelObjectType extends ResolvedTypeX.Name {
        
     
     // IMPORTANT! THIS DOESN'T do real work on the java class, just stores it away.
-    BcelObjectType(String signature, World world, JavaClass javaClass) {
-        super(signature, world);
+    BcelObjectType(String signature, World world, JavaClass javaClass, boolean exposedToWeaver) {
+        super(signature, world, exposedToWeaver);
         this.javaClass = javaClass;
         
         sourceContext = new BcelSourceContext(this);
@@ -146,6 +146,7 @@ public class BcelObjectType extends ResolvedTypeX.Name {
                List l = BcelAttributes.readAjAttributes(javaClass.getAttributes(), getSourceContext());
                for (Iterator iter = l.iterator(); iter.hasNext();) {
                        AjAttribute a = (AjAttribute) iter.next();
+                       //System.err.println("unpacking: " + this + " and " + a);
                        if (a instanceof AjAttribute.Aspect) {
                                perClause = ((AjAttribute.Aspect)a).reify(this);
                        } else if (a instanceof AjAttribute.PointcutDeclarationAttribute) {
@@ -181,13 +182,7 @@ public class BcelObjectType extends ResolvedTypeX.Name {
         return javaClass;
     }
     
-    /**
-     * Switch to a new JavaClass and clear all caches
-     */
-    void replaceJavaClass(JavaClass jc) {
-       if (this.javaClass == jc) return;
-       
-       this.javaClass = jc;
+    void resetState() {
                this.interfaces = null;
        this.superClass = null;
        this.fields = null;
@@ -199,7 +194,17 @@ public class BcelObjectType extends ResolvedTypeX.Name {
        
        isObject = (javaClass.getSuperclassNameIndex() == 0);
         unpackAspectAttributes();
-       //XXX is clearing these caches sufficient
+    }
+    
+    
+    /**
+     * Switch to a new JavaClass and clear all caches
+     */
+    void replaceJavaClass(JavaClass jc) {
+       if (this.javaClass == jc) return;
+       
+       this.javaClass = jc;
+               resetState();
        }
 
        public WeaverStateKind getWeaverState() {
@@ -227,6 +232,7 @@ public class BcelObjectType extends ResolvedTypeX.Name {
     public LazyClassGen getLazyClassGen() {
        LazyClassGen ret = lazyClassGen;
        if (ret == null) {
+               //System.err.println("creating lazy class gen for: " + this);
                ret = new LazyClassGen(this);
                if (isAspect()) {
                        lazyClassGen = ret;
index f22bec950ee86b6c5e28ba858dc0c02177c2fe58..a73330479b6a88952329f11741ee24d5236ec5b1 100644 (file)
@@ -224,6 +224,18 @@ public class BcelWeaver implements IWeaver {
                                        "(world=" + needToReweaveWorld + ")", null, null);
        
        
+       //System.err.println("typeMungers: " + typeMungerList);
+       
+               // clear all state from files we'll be reweaving
+        for (Iterator i = filesToWeave.iterator(); i.hasNext(); ) {
+            UnwovenClassFile classFile = (UnwovenClassFile)i.next();
+               String className = classFile.getClassName();
+            BcelObjectType classType = (BcelObjectType) world.resolve(className);
+            classType.resetState();
+        }
+       
+       
+       
        //XXX this isn't quite the right place for this...
        for (Iterator i = filesToWeave.iterator(); i.hasNext(); ) {
             UnwovenClassFile classFile = (UnwovenClassFile)i.next();
@@ -290,6 +302,7 @@ public class BcelWeaver implements IWeaver {
                
                if (shadowMungers.size() > 0 || typeMungers.size() > 0 || classType.isAspect()) {
                        clazz = classType.getLazyClassGen();
+                       //System.err.println("got lazy gen: " + clazz + ", " + clazz.getWeaverState());
                        try {
                                boolean isChanged = BcelClassWeaver.weave(world, clazz, shadowMungers, typeMungers);
                                if (isChanged) {
index 97d8a09a476a64d661bc6cb4d09ebdc9de45d71b..1e4b603ec801529dbaf888e9ed4c27fdc01c8411 100644 (file)
@@ -170,7 +170,7 @@ public class BcelWorld extends World {
         if (jc == null) {
                return ResolvedTypeX.MISSING;
         } else {
-               return new BcelObjectType(ty.getSignature(), this, jc);
+               return new BcelObjectType(ty.getSignature(), this, jc, false);
         }
        }
        
@@ -195,7 +195,7 @@ public class BcelWorld extends World {
                String signature = TypeX.forName(jc.getClassName()).getSignature();
         BcelObjectType ret = (BcelObjectType)typeMap.get(signature);
         if (ret == null) {
-            ret = new BcelObjectType(signature, this, jc);
+            ret = new BcelObjectType(signature, this, jc, true);
             typeMap.put(signature, ret);
         } else {
             ret.replaceJavaClass(jc);
diff --git a/weaver/src/org/aspectj/weaver/bcel/UnwovenZipClassFile.java b/weaver/src/org/aspectj/weaver/bcel/UnwovenZipClassFile.java
deleted file mode 100644 (file)
index 2c4c760..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/* *******************************************************************
- * 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 Common Public License v1.0 
- * which accompanies this distribution and is available at 
- * http://www.eclipse.org/legal/cpl-v10.html 
- *  
- * Contributors: 
- *     Xerox/PARC     initial implementation 
- * ******************************************************************/
-
-
-package org.aspectj.weaver.bcel;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.zip.*;
-
-//XXX we believe this is now unneeded
-public class UnwovenZipClassFile extends UnwovenClassFile {
-       private ZipOutputStream zipOutputStream;
-       
-       public UnwovenZipClassFile(ZipOutputStream zipOutputStream, String filename, byte[] bytes) {
-               super(filename, bytes);
-               this.zipOutputStream = zipOutputStream;
-       }
-       
-
-       public void writeWovenBytes(byte[] bytes, List childClasses) throws IOException {
-               //??? we rewrite this every time
-               if (!childClasses.isEmpty()) {
-                       throw new RuntimeException("unimplemented");
-               }
-               
-               ZipEntry newEntry = new ZipEntry(filename);  //??? get compression scheme right
-               
-               zipOutputStream.putNextEntry(newEntry);
-               zipOutputStream.write(bytes);
-               zipOutputStream.closeEntry();
-               
-               writtenBytes = bytes;
-       }
-
-}
index 38e5de365171083ca66a42f2470b93ece3db8001..8d67f7815effc98f7b1c5874e2d7150c38ac4664 100644 (file)
@@ -34,10 +34,15 @@ public class DeclareParents extends Declare {
        }
        
        public boolean match(ResolvedTypeX typeX) {
-               return child.matchesStatically(typeX);
+               if (!child.matchesStatically(typeX)) return false;
+               if (typeX.getWorld().getLint().typeNotExposedToWeaver.isEnabled() &&
+                               !typeX.isExposedToWeaver())
+               {
+                       typeX.getWorld().getLint().typeNotExposedToWeaver.signal(typeX.getName(), getSourceLocation());
+               }
+               
+               return true;
        }
-
-
        
        public String toString() {
                StringBuffer buf = new StringBuffer();