aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bcel-builder/bcel-src.zipbin0 -> 55121 bytes
-rw-r--r--bcel-builder/bcel-verifier.jarbin0 -> 161556 bytes
-rw-r--r--bcel-builder/bcel.jarbin0 -> 285242 bytes
-rw-r--r--org.aspectj.matcher/src/org/aspectj/weaver/World.java13
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/LazyMethodGen.java57
5 files changed, 50 insertions, 20 deletions
diff --git a/bcel-builder/bcel-src.zip b/bcel-builder/bcel-src.zip
new file mode 100644
index 000000000..a3a9951b7
--- /dev/null
+++ b/bcel-builder/bcel-src.zip
Binary files differ
diff --git a/bcel-builder/bcel-verifier.jar b/bcel-builder/bcel-verifier.jar
new file mode 100644
index 000000000..e6edce128
--- /dev/null
+++ b/bcel-builder/bcel-verifier.jar
Binary files differ
diff --git a/bcel-builder/bcel.jar b/bcel-builder/bcel.jar
new file mode 100644
index 000000000..a7003b981
--- /dev/null
+++ b/bcel-builder/bcel.jar
Binary files differ
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/World.java b/org.aspectj.matcher/src/org/aspectj/weaver/World.java
index 83dac2da4..329fef88d 100644
--- a/org.aspectj.matcher/src/org/aspectj/weaver/World.java
+++ b/org.aspectj.matcher/src/org/aspectj/weaver/World.java
@@ -142,6 +142,7 @@ public abstract class World implements Dump.INode {
public boolean forDEBUG_structuralChangesCode = false;
public boolean forDEBUG_bridgingCode = false;
public boolean optimizedMatching = true;
+ public boolean generateNewLvts = true;
protected long timersPerJoinpoint = 25000;
protected long timersPerType = 250;
@@ -959,6 +960,12 @@ public abstract class World implements Dump.INode {
public final static String xsetITD_VERSION_DEFAULT = xsetITD_VERSION_2NDGEN;
public final static String xsetMINIMAL_MODEL = "minimalModel";
public final static String xsetTARGETING_RUNTIME_1610 = "targetRuntime1_6_10";
+
+ // This option allows you to prevent AspectJ adding local variable tables - some tools (e.g. dex) may
+ // not like what gets created because even though it is valid, the bytecode they are processing has
+ // unexpected quirks that mean the table entries are violated in the code. See issue:
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=470658
+ public final static String xsetGENERATE_NEW_LVTS="generateNewLocalVariableTables";
public boolean isInJava5Mode() {
return behaveInJava5Way;
@@ -1621,6 +1628,12 @@ public abstract class World implements Dump.INode {
s = p.getProperty(xsetDEBUG_BRIDGING, "false");
forDEBUG_bridgingCode = s.equalsIgnoreCase("true");
+ s = p.getProperty(xsetGENERATE_NEW_LVTS,"true");
+ generateNewLvts = s.equalsIgnoreCase("true");
+ if (!generateNewLvts) {
+ getMessageHandler().handleMessage(MessageUtil.info("[generateNewLvts=false] for methods without an incoming local variable table, do not generate one"));
+ }
+
s = p.getProperty(xsetOPTIMIZED_MATCHING, "true");
optimizedMatching = s.equalsIgnoreCase("true");
if (!optimizedMatching) {
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