Ive been thinking about writing Java bytecodes directly (using one of the Java assemblers out there) and just want to ask if anyone knows whether this will work:
Forget it. Writing Java bytecode by hand for optimization purposes is a worthless endeavor. Java bytecode is useful in generative techniques, where you're writing a compiler for a language that targets the Java VM, or developing an aspecting system (ala AspectWerkz/AspectJ) / rolling your own aspects. Occassionally you might write some bytecode by hand for correctness purposes - like invoking a MonitorEnter without a corresponding MonitorExit for a self-written mutex class.
Can I push a float value onto the stack, and then pop it off & use it as an int?
Nope. The verifier will check this the moment it loads your class file. If it didn't there'd be security loopholes in the VM. Sun's verifier is a piece of crap, in that it doesn't give you much information when verification fails. You can use BCEL's verifier, Justice, for much better error messages. Unfortunately, Justice has some quirks in that certain classes pass Sun's verifier while failing Justice.