aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2003-05-21 17:51:24 +0000
committerjhugunin <jhugunin>2003-05-21 17:51:24 +0000
commit556537033f794d632baccf560a06414755b58381 (patch)
tree2118a8f9ed837d73e41776115c167a3f6e1ba345 /weaver
parent2b2c99e671577d96af2ccfb9ade2483dddf582cf (diff)
downloadaspectj-556537033f794d632baccf560a06414755b58381.tar.gz
aspectj-556537033f794d632baccf560a06414755b58381.zip
fix for Bugzilla Bug 37758
Weaving rt.jar results in stack overflow
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/Utility.java47
1 files changed, 35 insertions, 12 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/Utility.java b/weaver/src/org/aspectj/weaver/bcel/Utility.java
index 9dc9e2a90..d2179010b 100644
--- a/weaver/src/org/aspectj/weaver/bcel/Utility.java
+++ b/weaver/src/org/aspectj/weaver/bcel/Utility.java
@@ -421,19 +421,42 @@ public class Utility {
}
/** returns -1 if no source line attribute */
+ // this naive version overruns the JVM stack size, if only Java understood tail recursion...
+// public static int getSourceLine(InstructionHandle ih) {
+// if (ih == null) return -1;
+//
+// InstructionTargeter[] ts = ih.getTargeters();
+// if (ts != null) {
+// for (int j = ts.length - 1; j >= 0; j--) {
+// InstructionTargeter t = ts[j];
+// if (t instanceof LineNumberTag) {
+// return ((LineNumberTag)t).getLineNumber();
+// }
+// }
+// }
+// return getSourceLine(ih.getNext());
+// }
+
+
public static int getSourceLine(InstructionHandle ih) {
- if (ih == null) return -1;
-
- InstructionTargeter[] ts = ih.getTargeters();
- if (ts != null) {
- for (int j = ts.length - 1; j >= 0; j--) {
- InstructionTargeter t = ts[j];
- if (t instanceof LineNumberTag) {
- return ((LineNumberTag)t).getLineNumber();
- }
- }
- }
- return getSourceLine(ih.getNext());
+ int lookahead=0;
+ // arbitrary rule that we will never lookahead more than 100 instructions for a line #
+ while (lookahead++ < 100) {
+ if (ih == null) return -1;
+
+ InstructionTargeter[] ts = ih.getTargeters();
+ if (ts != null) {
+ for (int j = ts.length - 1; j >= 0; j--) {
+ InstructionTargeter t = ts[j];
+ if (t instanceof LineNumberTag) {
+ return ((LineNumberTag)t).getLineNumber();
+ }
+ }
+ }
+ ih = ih.getNext();
+ }
+ //System.err.println("no line information available for: " + ih);
+ return -1;
}
// assumes that there is no already extant source line tag. Otherwise we'll have to be better.