]> source.dussan.org Git - aspectj.git/commitdiff
fix and tests for Bugzilla Bug 41123
authorjhugunin <jhugunin>
Fri, 8 Aug 2003 01:23:31 +0000 (01:23 +0000)
committerjhugunin <jhugunin>
Fri, 8 Aug 2003 01:23:31 +0000 (01:23 +0000)
   Weaving failure when using injars

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java
tests/ajcTests.xml
tests/bugs/moreInterfaceLibrary/lib.jar [new file with mode: 0644]
tests/bugs/moreInterfaceLibrary/lib/ExecutionMonitor.aj [new file with mode: 0644]
tests/bugs/moreInterfaceLibrary/model/BusObj.java [new file with mode: 0644]
tests/bugs/moreInterfaceLibrary/model/MonitorBusObj.java [new file with mode: 0644]
weaver/src/org/aspectj/weaver/bcel/BcelTypeMunger.java
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java

index daacbc4e58dc08fda65811447a2cb457a9d138dd..8bbf228a887e30c93b6c3b384b12f81fbed21d15 100644 (file)
@@ -160,7 +160,7 @@ public class AjLookupEnvironment extends LookupEnvironment {
                        Collection mungers = 
                                onType.getWeaverState().getTypeMungers(onType);
                                
-                       //System.out.println("mungers: " + mungers);
+                       //System.out.println(onType + " mungers: " + mungers);
                        for (Iterator i = mungers.iterator(); i.hasNext(); ) {
                                ConcreteTypeMunger m = (ConcreteTypeMunger)i.next();
                                EclipseTypeMunger munger = factory.makeEclipseTypeMunger(m);
@@ -235,6 +235,12 @@ public class AjLookupEnvironment extends LookupEnvironment {
                if (!newParents.isEmpty()) {
                        for (Iterator i = newParents.iterator(); i.hasNext(); ) {
                                ResolvedTypeX parent = (ResolvedTypeX)i.next();
+                               if (dangerousInterfaces.containsKey(parent)) {
+                                       ResolvedTypeX onType = factory.fromEclipse(sourceType);
+                                       factory.showMessage(IMessage.ERROR, 
+                                                                               onType + ": " + dangerousInterfaces.get(parent),
+                                                                               onType.getSourceLocation(), null);
+                               }
                                addParent(sourceType, parent);
                        }
                }
index 1a73d999071ee8f3cd7c8e9bcbf4c1d754e707d0..5fa1ab82ded217a5fd7363bb0c21a4eaa2cb13d3 100644 (file)
                        </compile>
                </ajc-test>
                
+               
+       <ajc-test dir="bugs/moreInterfaceLibrary"
+               pr="41123"
+               title="Weaving failure when using injars (no jars)">
+               <compile
+                       files="lib/ExecutionMonitor.aj,model/BusObj.java,model/MonitorBusObj.java">
+               </compile>
+       </ajc-test>
+       
+       <ajc-test dir="bugs/moreInterfaceLibrary"
+               pr="41123"
+               title="Weaving failure when using injars (on aspectpath)">
+               <compile
+                       files="model/BusObj.java,model/MonitorBusObj.java"
+                       aspectpath="lib.jar">
+               </compile>
+       </ajc-test>
+
+       <ajc-test dir="bugs/moreInterfaceLibrary"
+               pr="41123"
+               title="Weaving failure when using injars (on classpath)">
+               <compile
+                       files="model/BusObj.java,model/MonitorBusObj.java"
+                       classpath="lib.jar">
+                   <message kind="error" line="3"/>
+               </compile>
+       </ajc-test>
+       
+       <ajc-test dir="bugs/moreInterfaceLibrary"
+               pr="41123"
+               title="Weaving failure when using injars (actual injars)">
+               <compile
+                       files="model/BusObj.java,model/MonitorBusObj.java,lib.jar">
+                   <message kind="error" line="3"/>
+               </compile>
+       </ajc-test>
 </suite>
diff --git a/tests/bugs/moreInterfaceLibrary/lib.jar b/tests/bugs/moreInterfaceLibrary/lib.jar
new file mode 100644 (file)
index 0000000..0c6f6c2
Binary files /dev/null and b/tests/bugs/moreInterfaceLibrary/lib.jar differ
diff --git a/tests/bugs/moreInterfaceLibrary/lib/ExecutionMonitor.aj b/tests/bugs/moreInterfaceLibrary/lib/ExecutionMonitor.aj
new file mode 100644 (file)
index 0000000..ec2314d
--- /dev/null
@@ -0,0 +1,6 @@
+package lib;\r
+\r
+public aspect ExecutionMonitor {\r
+    public interface MonitoredItem {}\r
+    private void MonitoredItem.record(String eventType, String eventName) {}\r
+}   
\ No newline at end of file
diff --git a/tests/bugs/moreInterfaceLibrary/model/BusObj.java b/tests/bugs/moreInterfaceLibrary/model/BusObj.java
new file mode 100644 (file)
index 0000000..90efbd7
--- /dev/null
@@ -0,0 +1,5 @@
+package model;
+
+public class BusObj {
+
+}
diff --git a/tests/bugs/moreInterfaceLibrary/model/MonitorBusObj.java b/tests/bugs/moreInterfaceLibrary/model/MonitorBusObj.java
new file mode 100644 (file)
index 0000000..2d52240
--- /dev/null
@@ -0,0 +1,7 @@
+package model;
+
+import lib.ExecutionMonitor;
+
+public aspect MonitorBusObj {
+       declare parents: BusObj implements ExecutionMonitor.MonitoredItem;
+}
\ No newline at end of file
index 5b9de1855379fd89f8139b222a06c928a0b2d8ac..6f57e56bfc7217a5cf377e0988096f44722750bc 100644 (file)
@@ -223,13 +223,15 @@ public class BcelTypeMunger extends ConcreteTypeMunger {
        
        
        private LazyMethodGen makeMethodGen(LazyClassGen gen, ResolvedMember member) {
-               return new LazyMethodGen(
+               LazyMethodGen ret = new LazyMethodGen(
                        member.getModifiers(),
                        BcelWorld.makeBcelType(member.getReturnType()),
                        member.getName(),
                        BcelWorld.makeBcelTypes(member.getParameterTypes()),
                        TypeX.getNames(member.getExceptions()),
                        gen);
+               ret.makeSynthetic();
+               return ret;
        }
 
 
index 7c4e660dbf1156732cdadcc6c7bdb4a9f72d9bed..dd011f6c307af16772086f31cc1b730551c4cdc8 100644 (file)
@@ -30,11 +30,13 @@ import org.apache.bcel.Constants;
 import org.apache.bcel.classfile.Attribute;
 import org.apache.bcel.classfile.ConstantPool;
 import org.apache.bcel.classfile.Method;
+import org.apache.bcel.classfile.Synthetic;
 import org.apache.bcel.generic.BranchHandle;
 import org.apache.bcel.generic.BranchInstruction;
 import org.apache.bcel.generic.CPInstruction;
 import org.apache.bcel.generic.ClassGenException;
 import org.apache.bcel.generic.CodeExceptionGen;
+import org.apache.bcel.generic.ConstantPoolGen;
 import org.apache.bcel.generic.Instruction;
 import org.apache.bcel.generic.InstructionHandle;
 import org.apache.bcel.generic.InstructionList;
@@ -85,6 +87,8 @@ public final class LazyMethodGen {
     private boolean canInline = true;
     private boolean hasExceptionHandlers;
     
+    private boolean isSynthetic = false;
+    
     /**
      * only used by {@link BcelClassWeaver}
      */
@@ -702,6 +706,13 @@ public final class LazyMethodGen {
         for (int i = 0, len = attributes.length; i < len; i++) {
             gen.addAttribute(attributes[i]);
         }
+        
+        if (isSynthetic) {
+                       ConstantPoolGen cpg = gen.getConstantPool();
+                       int index = cpg.addUtf8("Synthetic");
+                       gen.addAttribute(new Synthetic(index, 0, new byte[0], cpg.getConstantPool()));
+        }
+        
         if (hasBody()) {
             packBody(gen);
             gen.setMaxLocals();
@@ -711,6 +722,10 @@ public final class LazyMethodGen {
         }
         return gen;
     }
+    
+    public void makeSynthetic() {
+       isSynthetic = true;
+    }          
         
     /** fill the newly created method gen with our body, 
      * inspired by InstructionList.copy()