]> source.dussan.org Git - aspectj.git/commitdiff
test and fix for
authorjhugunin <jhugunin>
Thu, 10 Apr 2003 22:20:14 +0000 (22:20 +0000)
committerjhugunin <jhugunin>
Thu, 10 Apr 2003 22:20:14 +0000 (22:20 +0000)
Bugzilla Bug 36046
   inter-type declaration bug with abstract classes

tests/ajcTests.xml
tests/bugs/interAbstract/Driver.java [new file with mode: 0644]
tests/jimTests.xml
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java
weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java

index 2d00cf805df024e235412433d89887009d9f13bf..55014305b926b60892138ebca89fea8e817c6566 100644 (file)
         <run class="ConvertToUnchecked"/>
     </ajc-test>
     
+    <ajc-test dir="bugs/interAbstract"
+      title="inter-type declaration bug with abstract classes"
+      pr="36046">
+        <compile files="Driver.java"/>
+        <run class="Driver"/>
+    </ajc-test>
+    
 </suite>
diff --git a/tests/bugs/interAbstract/Driver.java b/tests/bugs/interAbstract/Driver.java
new file mode 100644 (file)
index 0000000..1f2f37c
--- /dev/null
@@ -0,0 +1,35 @@
+//Bugzilla Bug 36046  
+//   inter-type declaration bug with abstract classes 
+
+public class Driver {
+       public static void main(String args[]) {
+               Derived generator = new Derived();
+               System.out.println(generator.getExecutions("processEvents"));
+       }
+       static aspect MonitorBase {
+               declare parents: Base implements ExecutionMonitor.MonitoredItem;
+       }    
+}
+
+class Derived extends Base {
+       public String getName() {
+               return null;
+       }
+}
+
+abstract class Base {
+       abstract public String getName();
+}
+
+aspect ExecutionMonitor {
+       /** marker interface to indicate the execution monitor should track calls 
+and executions on this class. */
+       public interface MonitoredItem {
+               int getExecutions(String methodName);
+       }
+
+       /** a Map of events to mutable integers */
+       public int MonitoredItem.getExecutions(String methodName) {
+               return 0;
+       }
+}
\ No newline at end of file
index ea5a825161729527e37dac3de84212e821f504b7..cc3257d9f51b12c474151c9b0793afa5260e8d99 100644 (file)
@@ -1,10 +1,6 @@
 <!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">
 <suite>    
-    <ajc-test dir="new" title="new around construct"
-      keywords="from-resolved_10x">
-        <compile files="AroundAdvice.java"/>
-        <run class="AroundAdvice"/>
-    </ajc-test>
+
     <!--
     
     <ajc-test dir="new" pr="885"
index 79eb5f29cfa04e89dbd124e396d58d89bd30c0c4..4cb41ad1caddb5873ad56c059f4ba05911f4578d 100644 (file)
@@ -220,7 +220,12 @@ class BcelClassWeaver implements IClassWeaver {
 
        private boolean alreadyDefined(LazyClassGen clazz, LazyMethodGen mg) {
                for (Iterator i = clazz.getMethodGens().iterator(); i.hasNext(); ) {
-                       if (signaturesMatch(mg, (LazyMethodGen)i.next())) {
+                       LazyMethodGen existing = (LazyMethodGen)i.next();
+                       if (signaturesMatch(mg, existing)) {
+                               if (!mg.isAbstract() && existing.isAbstract()) {
+                                       i.remove();
+                                       return false;
+                               }
                                return true;
                        }
                }
index 4c6308d01e574b3be1d57e09573fc8bf800afe8c..39f3427e9e3d80cc58001d7718ed94131cd71698 100644 (file)
@@ -147,7 +147,7 @@ public final class LazyClassGen {
     }
 
     public List getMethodGens() {
-        return Collections.unmodifiableList(methodGens);
+        return methodGens; //???Collections.unmodifiableList(methodGens);
 
     }
 
index 7703774f12fd3b5618cb20690da612a35c139cab..adf0c953a0ff130371ac8b8d1a000d60ba298832 100644 (file)
@@ -594,9 +594,13 @@ public final class LazyMethodGen {
         return prevLine;
     }
 
-    public boolean isStatic() {
-        return Modifier.isStatic(getAccessFlags());
-    }
+       public boolean isStatic() {
+               return Modifier.isStatic(getAccessFlags());
+       }
+    
+       public boolean isAbstract() {
+               return Modifier.isAbstract(getAccessFlags());
+       }
     
     public void addExceptionHandler(
             InstructionHandle start,