diff options
author | aclement <aclement> | 2009-10-22 23:26:14 +0000 |
---|---|---|
committer | aclement <aclement> | 2009-10-22 23:26:14 +0000 |
commit | 35a964971d99283b22510f73b5e7e826b57c619a (patch) | |
tree | 56ff5167b69b9c7f64e06ef2b4413faf51498a47 /weaver | |
parent | d0f582977df09bde57a0513b5d51a766d653d71c (diff) | |
download | aspectj-35a964971d99283b22510f73b5e7e826b57c619a.tar.gz aspectj-35a964971d99283b22510f73b5e7e826b57c619a.zip |
279298: cobertura and AspectJ
Diffstat (limited to 'weaver')
-rw-r--r-- | weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java index bb39fe541..6aa287a1d 100644 --- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -1707,14 +1707,33 @@ public class AtAjAttributes { final List<MethodArgument> arguments = new ArrayList<MethodArgument>(); LocalVariableTable lt = method.getLocalVariableTable(); if (lt != null) { - for (int j = 0; j < lt.getLocalVariableTable().length; j++) { - LocalVariable localVariable = lt.getLocalVariableTable()[j]; + LocalVariable[] lvt = lt.getLocalVariableTable(); + for (int j = 0; j < lvt.length; j++) { + LocalVariable localVariable = lvt[j]; if (localVariable.getStartPC() == 0) { if (localVariable.getIndex() >= startAtStackIndex) { arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex())); } } } + if (arguments.size() == 0) { + // could be cobertura code where some extra bytecode has been stuffed in at the start of the method + // but the local variable table hasn't been repaired - for example: + // LocalVariable(start_pc = 6, length = 40, index = 0:com.example.ExampleAspect this) + // LocalVariable(start_pc = 6, length = 40, index = 1:org.aspectj.lang.ProceedingJoinPoint pjp) + // LocalVariable(start_pc = 6, length = 40, index = 2:int __cobertura__line__number__) + // LocalVariable(start_pc = 6, length = 40, index = 3:int __cobertura__branch__number__) + LocalVariable localVariable = lvt[0]; + if (localVariable.getStartPC() != 0) { + // looks suspicious so let's use this information + for (int j = 0; j < lvt.length && arguments.size() < method.getArgumentTypes().length; j++) { + localVariable = lvt[j]; + if (localVariable.getIndex() >= startAtStackIndex) { + arguments.add(new MethodArgument(localVariable.getName(), localVariable.getIndex())); + } + } + } + } } else { // No debug info, do we have an annotation value we can rely on? if (argNamesFromAnnotation != null) { |