The "opt-stack-1" option to edu.purdue.cs.bloat.optimize.Main which sets CodeGenerator.OPT_STACK to true has some remaining bugs:
These present themselves when optimizing using the following: java -cp :./:/data/bcel/bcel-5.2.jar:/ edu.purdue.cs.bloat.optimize.Main -pre -prop -color -use-stack-vars -dce -peel-loops 2 -appre -diva -opt-stack-1 -only-method removeNOPs edu.purdue.cs.bloat.cfg.FlowGraph output
> arrin@rimmer:~/Development/djvm/bcel-bloat/build$ java -cp :./:/data/bcel/bcel-5.2.jar:/ edu.purdue.cs.bloat.optimize.Main -pre -prop -color -use-stack-vars -dce -peel-loops 2 -appre -diva -opt-stack-1 -only-method removeNOPs edu.purdue.cs.bloat.cfg.FlowGraph output
> FlowGraph.java source file for class:edu.purdue.cs.bloat.cfg.FlowGraph
> /home/arrin/Development/djvm/bcel-bloat/build/output/FlowGraph.class selected for output of class: edu.purdue.cs.bloat.cfg.FlowGraph
> NOTE: CFG did not verify while bloating removeNOPs after all optimizations. Exception: java.lang.IllegalArgumentException: Assert.isTrue: Index of label_-1 not found
> java.lang.IllegalArgumentException: Assert.isTrue: Index of label_-1 not found
> at edu.purdue.cs.bloat.util.Assert.isTrue(Assert.java:56)
> at edu.purdue.cs.bloat.trans.Peephole.removeUnreachable(Peephole.java:438)
> at edu.purdue.cs.bloat.trans.Peephole.transform(Peephole.java:365)
> at edu.purdue.cs.bloat.trans.Peephole.transform(Peephole.java:74)
> at edu.purdue.cs.bloat.optimize.MethodBloater.doAnOptimization(MethodBloater.java:208)
> at edu.purdue.cs.bloat.optimize.MethodBloater.performOptimizations(MethodBloater.java:139)
> at edu.purdue.cs.bloat.optimize.MethodBloater.bloatMethod(MethodBloater.java:103)
> at edu.purdue.cs.bloat.optimize.Main.editClass(Main.java:731)
> at edu.purdue.cs.bloat.optimize.Main.main(Main.java:499)
> Optimized with: edu.purdue.cs.bloat.optimize.Main -pre -prop -color -use-stack-vars -dce -peel-loops 2 -appre -diva -opt-stack-1 -only-method removeNOPs edu.purdue.cs.bloat.cfg.FlowGraph output
> arrin@rimmer:~/Development/djvm/bcel-bloat/build$
This bug only occurs using -opt-stack-1 which inserts extra SWAP, and DUP instructions during the CodeGeneration phase. These seem to result in a Label with position -1, this remains the case after a call to InstructionList.setPosition().
StackPRE is the file which produces the error it is currently not included in the BCELBLOAT source because the original BLOAT has this optimization disabled.