diff options
Diffstat (limited to 'bcel-builder')
-rw-r--r-- | bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java index 59cf7397e..21673dec0 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/generic/MethodGen.java @@ -880,9 +880,19 @@ public class MethodGen extends FieldGenOrMethodGen { } /** - * Compute maximum number of local variables. + * Compute maximum number of local variables based on the parameter count and bytecode usage of variables. */ public void setMaxLocals() { + setMaxLocals(false); + } + + /** + * Compute maximum number of local variables. + * + * @param respectLocalVariableTable if true and the local variable table indicates more are in use + * than the code suggests, respect the higher value from the local variable table data. + */ + public void setMaxLocals(boolean respectLocalVariableTable) { if (il != null) { int max = isStatic() ? 0 : 1; @@ -903,10 +913,13 @@ public class MethodGen extends FieldGenOrMethodGen { } } } - - maxLocals = max; + if (!respectLocalVariableTable || max > maxLocals) { + maxLocals = max; + } } else { - maxLocals = 0; + if (!respectLocalVariableTable) { + maxLocals = 0; + } } } |