aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorAndy Clement <aclement@pivotal.io>2015-08-10 11:35:19 -0700
committerAndy Clement <aclement@pivotal.io>2015-08-10 11:35:19 -0700
commit5219b4af2c6ed2c477d91d3ea0a364a0e5fc3652 (patch)
tree609c1ee2fb67dd238154f582273f54bec6de9b3c /weaver
parent7a61a0d50d7371ef0a8e9904e8da7e93922fe8e4 (diff)
downloadaspectj-5219b4af2c6ed2c477d91d3ea0a364a0e5fc3652.tar.gz
aspectj-5219b4af2c6ed2c477d91d3ea0a364a0e5fc3652.zip
Add option not to generate local variable tables in some scenarios
New Xset option generateNewLocalVariableTables defaults to true but can be set to false. In some situations incoming bytecode for weaving doesn't want them adding (e.g. android situations where the bytecode is a bit funky). Issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=470658
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java57
1 files changed, 37 insertions, 20 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
index a5f042a5e..97e73832b 100644
--- a/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
+++ b/weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java
@@ -62,6 +62,7 @@ import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.WeaverMessages;
+import org.aspectj.weaver.World;
import org.aspectj.weaver.tools.Traceable;
/**
@@ -78,6 +79,8 @@ import org.aspectj.weaver.tools.Traceable;
*/
public final class LazyMethodGen implements Traceable {
+ private static final AnnotationAJ[] NO_ANNOTATIONAJ = new AnnotationAJ[] {};
+
private int modifiers;
private Type returnType;
private final String name;
@@ -95,7 +98,11 @@ public final class LazyMethodGen implements Traceable {
int highestLineNumber = 0;
boolean wasPackedOptimally = false;
private Method savedMethod = null;
- private static final AnnotationAJ[] NO_ANNOTATIONAJ = new AnnotationAJ[] {};
+
+ // Some tools that may post process the output bytecode do not long local variable tables
+ // to be generated as one reason the tables may be missing in the first place is because
+ // the bytecode is odd. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=470658
+ private final boolean originalMethodHasLocalVariableTable;
/*
* We use LineNumberTags and not Gens.
@@ -152,6 +159,7 @@ public final class LazyMethodGen implements Traceable {
this.attributes = new ArrayList<Attribute>();
this.enclosingClass = enclosingClass;
assertGoodBody();
+ this.originalMethodHasLocalVariableTable = true; // it is a new method, we want an lvar table
// @AJ advice are not inlined by default since requires further analysis and weaving ordering control
// TODO AV - improve - note: no room for improvement as long as aspects are reweavable
@@ -186,7 +194,7 @@ public final class LazyMethodGen implements Traceable {
throw new RuntimeException("bad abstract method with code: " + m + " on " + enclosingClass);
}
this.memberView = new BcelMethod(enclosingClass.getBcelObjectType(), m);
-
+ this.originalMethodHasLocalVariableTable = savedMethod.getLocalVariableTable()!=null;
this.modifiers = m.getModifiers();
this.name = m.getName();
@@ -223,7 +231,7 @@ public final class LazyMethodGen implements Traceable {
this.memberView = m;
this.modifiers = savedMethod.getModifiers();
this.name = m.getName();
-
+ this.originalMethodHasLocalVariableTable = savedMethod.getLocalVariableTable() != null;
// @AJ advice are not inlined by default since requires further analysis
// and weaving ordering control
// TODO AV - improve - note: no room for improvement as long as aspects
@@ -1121,14 +1129,19 @@ public final class LazyMethodGen implements Traceable {
}
addExceptionHandlers(gen, map, exceptionList);
- if (localVariables.size() == 0) {
- // Might be a case of 173978 where around advice on an execution join point
- // has caused everything to be extracted from the method and thus we
- // are left with no local variables, not even the ones for 'this' and
- // parameters passed to the method
- createNewLocalVariables(gen);
- } else {
- addLocalVariables(gen, localVariables);
+ if (originalMethodHasLocalVariableTable || enclosingClass
+ .getBcelObjectType()
+ .getResolvedTypeX()
+ .getWorld().generateNewLvts) {
+ if (localVariables.size() == 0) {
+ // Might be a case of 173978 where around advice on an execution join point
+ // has caused everything to be extracted from the method and thus we
+ // are left with no local variables, not even the ones for 'this' and
+ // parameters passed to the method
+ createNewLocalVariables(gen);
+ } else {
+ addLocalVariables(gen, localVariables);
+ }
}
// JAVAC adds line number tables (with just one entry) to generated
@@ -1174,6 +1187,9 @@ public final class LazyMethodGen implements Traceable {
}
}
+ private World getWorld() {
+ return enclosingClass.getBcelObjectType().getResolvedTypeX().getWorld();
+ }
/*
* Optimized packing that does a 'local packing' of the code rather than building a brand new method and packing into it. Only
* usable when the packing is going to be done just once.
@@ -1258,16 +1274,17 @@ public final class LazyMethodGen implements Traceable {
}
}
gen.setInstructionList(theBody);
- if (localVariables.size() == 0) {
- // Might be a case of 173978 where around advice on an execution join point
- // has caused everything to be extracted from the method and thus we
- // are left with no local variables, not even the ones for 'this' and
- // parameters passed to the method
- createNewLocalVariables(gen);
- } else {
- addLocalVariables(gen, localVariables);
+ if (originalMethodHasLocalVariableTable || getWorld().generateNewLvts) {
+ if (localVariables.size() == 0) {
+ // Might be a case of 173978 where around advice on an execution join point
+ // has caused everything to be extracted from the method and thus we
+ // are left with no local variables, not even the ones for 'this' and
+ // parameters passed to the method
+ createNewLocalVariables(gen);
+ } else {
+ addLocalVariables(gen, localVariables);
+ }
}
-
// JAVAC adds line number tables (with just one entry) to generated
// accessor methods - this
// keeps some tools that rely on finding at least some form of