]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 52394
authoraclement <aclement>
Thu, 4 Mar 2004 16:09:34 +0000 (16:09 +0000)
committeraclement <aclement>
Thu, 4 Mar 2004 16:09:34 +0000 (16:09 +0000)
   inter-type declarations cause JRockit Crash

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

index 4c1ed2ff1389e6b0e954895e76f392fb51368420..769f32e791344cb9734745a1441643a90d261bf8 100644 (file)
@@ -76,11 +76,14 @@ public class AspectClinit extends Clinit {
                }
                
                if (initFailureField != null) {
+                       // Changes to this exception handling code may require changes to
+                       // BcelClassWeaver.isInitFailureHandler()
                        handlerLabel.placeEnd();
                        Label endLabel = new Label(codeStream);
                        codeStream.goto_(endLabel);
-                       
                        handlerLabel.place();
+                       codeStream.astore_0(); // Bug #52394
+                   codeStream.aload_0();
                        codeStream.putstatic(initFailureField);
                        endLabel.place();
                }
index 514e922625f5ed6cd7f07f58febf7ec744546b30..7c6ddb9fd8e8728bc785a47b23a71d433b146a0a 100644 (file)
@@ -998,8 +998,13 @@ class BcelClassWeaver implements IClassWeaver {
        }
 
        private boolean isInitFailureHandler(InstructionHandle ih) {
-               if (ih.getInstruction() instanceof PUTSTATIC) {
-                       String name = ((PUTSTATIC)ih.getInstruction()).getFieldName(cpg);
+               // Skip the astore_0 and aload_0 at the start of the handler and 
+               // then check if the instruction following these is 
+               // 'putstatic ajc$initFailureCause'.  If it is then we are 
+               // in the handler we created in AspectClinit.generatePostSyntheticCode()
+               InstructionHandle twoInstructionsAway = ih.getNext().getNext();
+               if (twoInstructionsAway.getInstruction() instanceof PUTSTATIC) {
+                       String name = ((PUTSTATIC)twoInstructionsAway.getInstruction()).getFieldName(cpg);
                        if (name.equals(NameMangler.INITFAILURECAUSE_FIELD_NAME)) return true;
                }
                return false;