aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2019-01-14 15:51:56 -0800
committerAndy Clement <aclement@pivotal.io>2019-01-14 15:51:56 -0800
commit3abc52595deac0e9cd4a427a7eb6fe81170dc618 (patch)
treef542201b7306b7c225b61471a0b77701bcd1e6de /weaver
parenta11b07517aa85fb5c4e856f475050a4136ed36e6 (diff)
downloadaspectj-3abc52595deac0e9cd4a427a7eb6fe81170dc618.tar.gz
aspectj-3abc52595deac0e9cd4a427a7eb6fe81170dc618.zip
Cope with unusual local variable table per 539121
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java63
1 files changed, 39 insertions, 24 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
index 19170b547..2da044c11 100644
--- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
+++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java
@@ -1763,6 +1763,14 @@ public class AtAjAttributes {
}
}
if (arguments.size() == 0) {
+ // The local variable table is causing us trouble, try the annotation value
+ // See 539121 for a jacoco variant of the cobertura issue below
+ if (argNamesFromAnnotation != null) {
+ String[] argNames = extractArgNamesFromAnnotationValue(method, argNamesFromAnnotation, methodStruct);
+ if (argNames.length != 0) {
+ return argNames;
+ }
+ }
// 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)
@@ -1783,32 +1791,11 @@ public class AtAjAttributes {
}
}
} else {
- // No debug info, do we have an annotation value we can rely on?
if (argNamesFromAnnotation != null) {
- StringTokenizer st = new StringTokenizer(argNamesFromAnnotation, " ,");
- List<String> args = new ArrayList<String>();
- while (st.hasMoreTokens()) {
- args.add(st.nextToken());
- }
- if (args.size() != method.getArgumentTypes().length) {
- StringBuffer shortString = new StringBuffer().append(lastbit(method.getReturnType().toString())).append(" ")
- .append(method.getName());
- if (method.getArgumentTypes().length > 0) {
- shortString.append("(");
- for (int i = 0; i < method.getArgumentTypes().length; i++) {
- shortString.append(lastbit(method.getArgumentTypes()[i].toString()));
- if ((i + 1) < method.getArgumentTypes().length) {
- shortString.append(",");
- }
-
- }
- shortString.append(")");
- }
- reportError("argNames annotation value does not specify the right number of argument names for the method '"
- + shortString.toString() + "'", methodStruct);
- return EMPTY_STRINGS;
+ String[] argNames = extractArgNamesFromAnnotationValue(method, argNamesFromAnnotation, methodStruct);
+ if (argNames != null) {
+ return argNames;
}
- return args.toArray(new String[] {});
}
}
@@ -1836,6 +1823,34 @@ public class AtAjAttributes {
return argumentNames;
}
+ private static String[] extractArgNamesFromAnnotationValue(Method method, String argNamesFromAnnotation,
+ AjAttributeMethodStruct methodStruct) {
+ StringTokenizer st = new StringTokenizer(argNamesFromAnnotation, " ,");
+ List<String> args = new ArrayList<String>();
+ while (st.hasMoreTokens()) {
+ args.add(st.nextToken());
+ }
+ if (args.size() != method.getArgumentTypes().length) {
+ StringBuffer shortString = new StringBuffer().append(lastbit(method.getReturnType().toString())).append(" ")
+ .append(method.getName());
+ if (method.getArgumentTypes().length > 0) {
+ shortString.append("(");
+ for (int i = 0; i < method.getArgumentTypes().length; i++) {
+ shortString.append(lastbit(method.getArgumentTypes()[i].toString()));
+ if ((i + 1) < method.getArgumentTypes().length) {
+ shortString.append(",");
+ }
+
+ }
+ shortString.append(")");
+ }
+ reportError("argNames annotation value does not specify the right number of argument names for the method '"
+ + shortString.toString() + "'", methodStruct);
+ return EMPTY_STRINGS;
+ }
+ return args.toArray(new String[] {});
+ }
+
/**
* A method argument, used for sorting by indexOnStack (ie order in signature)
*