Summary: | proper handling of ExceptionInIntializer inside <clinit> in presence of after throwing advice | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Laurie Hendren <hendren> |
Component: | Compiler | Assignee: | Adrian Colyer <adrian.colyer> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 1.2 | ||
Target Milestone: | 1.2.1 | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: |
Description
Laurie Hendren
2004-05-18 10:23:19 EDT
marked as target 1.2.1 argh! bcel is a nightmare. It has taken me ages to program BCEL to generate: if ($r36 instanceof ExceptionInInitializerError) throw($r36); This is the final incantation for BCEL: if (this.getEnclosingMethod().getName().equals("<clinit>")) { ResolvedTypeX eiieType = world.resolve("java.lang.ExceptionInInitializerError"); ObjectType eiieBcelType = (ObjectType)BcelWorld.makeBcelType(eiieType); InstructionList ih = new InstructionList(InstructionConstants.NOP); handler.append(exceptionVar.createLoad(fact)); handler.append(fact.createInstanceOf(eiieBcelType)); BranchInstruction bi = InstructionFactory.createBranchInstruction( Constants.IFEQ,ih.getStart()); handler.append(bi); handler.append(exceptionVar.createLoad(fact)); handler.append(fact.createCheckCast(eiieBcelType)); handler.append(InstructionConstants.ATHROW); handler.append(ih); } I put that in the BcelShadow.weaveAfterThrowing() method. You can see it does a check to determine if it is in the <clinit> before generating this extra check. Here is the extra bytecode that appears in the method: 447: aload_1 448: instanceof #101; //class ExceptionInInitializerError 451: ifeq 459 454: aload_1 455: checkcast #101; //class ExceptionInInitializerError 458: athrow 459: nop Yes, there is one extra NOP but I don't want to fight with BCEL to remove it. I've put Lauries test program into the test suite to verify it behaves and we get the ExceptionInInitializerError rather than the NoClassDefFoundError. Thanks Laurie for describing the right fix :) fix checked in, waiting for build. Fix available: BUILD COMPLETE - build.344 Date of build: 08/18/2004 11:27:31 Time to build: 92 minutes 31 seconds Last changed: 08/18/2004 10:55:59 Latest good AspectJ jar available at: download.eclipse.org/technology/ajdt/dev/aspectj-DEVELOPMENT.jar Fix released as part of AspectJ 1.2.1 |