From 5d73494d7d222b92cdbb19f860f9215a07430681 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 4 Mar 2004 16:09:34 +0000 Subject: [PATCH] Fix for Bugzilla Bug 52394 inter-type declarations cause JRockit Crash --- .../aspectj/ajdt/internal/compiler/ast/AspectClinit.java | 5 ++++- weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java index 4c1ed2ff1..769f32e79 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java @@ -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(); } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 514e92262..7c6ddb9fd 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -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; -- 2.39.5