diff options
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/Member.java | 10 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/ResolvedMember.java | 2 | ||||
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/BcelShadow.java | 29 |
3 files changed, 33 insertions, 8 deletions
diff --git a/weaver/src/org/aspectj/weaver/Member.java b/weaver/src/org/aspectj/weaver/Member.java index 79cfbadfc..d30a60f8e 100644 --- a/weaver/src/org/aspectj/weaver/Member.java +++ b/weaver/src/org/aspectj/weaver/Member.java @@ -190,8 +190,8 @@ public class Member implements Comparable { paramTys); } - public static Member makeExceptionHandlerSignature(TypeX inType, TypeX catchType) { - return new Member( + public static ResolvedMember makeExceptionHandlerSignature(TypeX inType, TypeX catchType) { + return new ResolvedMember( HANDLER, inType, Modifier.STATIC, @@ -596,11 +596,9 @@ public class Member implements Comparable { buf.append('-'); buf.append(makeString(getParameterTypes()[0])); buf.append('-'); - //XXX we don't actually try to find the handler parameter name - //XXX it probably wouldn't be too hard String pName = "<missing>"; - //String[] pNames = getParameterNames(world); - //if (pNames != null) pName = pNames[0]; + String[] names = getParameterNames(world); + if (names != null) pName = names[0]; buf.append(pName); buf.append('-'); return buf.toString(); diff --git a/weaver/src/org/aspectj/weaver/ResolvedMember.java b/weaver/src/org/aspectj/weaver/ResolvedMember.java index d1a4e9633..ab1cdc90f 100644 --- a/weaver/src/org/aspectj/weaver/ResolvedMember.java +++ b/weaver/src/org/aspectj/weaver/ResolvedMember.java @@ -26,7 +26,7 @@ import org.aspectj.bridge.ISourceLocation; */ public class ResolvedMember extends Member implements IHasPosition { - protected String[] parameterNames = null; + public String[] parameterNames = null; protected TypeX[] checkedExceptions = TypeX.NONE; diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index fd72970cd..c4ce575bb 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -40,6 +40,7 @@ import org.apache.bcel.generic.NEW; import org.apache.bcel.generic.ObjectType; import org.apache.bcel.generic.ReturnInstruction; import org.apache.bcel.generic.SWAP; +import org.apache.bcel.generic.StoreInstruction; import org.apache.bcel.generic.TargetLostException; import org.apache.bcel.generic.Type; import org.aspectj.bridge.ISourceLocation; @@ -408,11 +409,16 @@ public class BcelShadow extends Shadow { InstructionList body = enclosingMethod.getBody(); TypeX catchType = exceptionRange.getCatchType(); TypeX inType = enclosingMethod.getEnclosingClass().getType(); + + ResolvedMember sig = Member.makeExceptionHandlerSignature(inType, catchType); + + + sig.parameterNames = new String[] {findHandlerParamName(startOfHandler)}; BcelShadow s = new BcelShadow( world, ExceptionHandler, - Member.makeExceptionHandlerSignature(inType, catchType), + sig, enclosingMethod, enclosingShadow); ShadowRange r = new ShadowRange(body); @@ -424,6 +430,27 @@ public class BcelShadow extends Shadow { exceptionRange.updateTarget(startOfHandler, start, body); return s; } + + private static String findHandlerParamName(InstructionHandle startOfHandler) { + if (startOfHandler.getInstruction() instanceof StoreInstruction && + startOfHandler.getNext() != null) + { + int slot = ((StoreInstruction)startOfHandler.getInstruction()).getIndex(); + //System.out.println("got store: " + startOfHandler.getInstruction() + ", " + index); + InstructionTargeter[] targeters = startOfHandler.getNext().getTargeters(); + for (int i=targeters.length-1; i >= 0; i--) { + if (targeters[i] instanceof LocalVariableTag) { + LocalVariableTag t = (LocalVariableTag)targeters[i]; + if (t.getSlot() == slot) { + return t.getName(); + } + //System.out.println("tag: " + targeters[i]); + } + } + } + + return "<missing>"; + } /** create an init join point associated w/ an interface in the body of a constructor */ |