View Single Post
Old 03-31-2014, 04:17 AM   #1
dsmid
Linux devotee
dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.dsmid ought to be getting tired of karma fortunes by now.
 
dsmid's Avatar
 
Posts: 598
Karma: 2069047
Join Date: Feb 2011
Device: Kindle 3, Kindle 4B, Kindle PW2
Java Bytecode Editor + Method Tools

Ando Saabas' JBE is very popular here because it allows user to modify features like margins width, tweak font size selection list, enable few hidden menu items (PDF reflow, Wi-Fi on/off,...), etc.

I have added two new classes to JBE: ExportMethod and ImportMethod.
The purpose of these tools is to avoid unnecessary clicking when performing bytecode changes.
Besides that I've also fixed two JBE bugs that prevented JBE from being able to eat its own dog food.

Usage:
java eu.smidovi.david.methodtools.ExportMethod <class file> [<method>] [<method signature>]
If <method> is not specified, <init> (the constructor) is used.
If <method signature> is not specified, the first method with the name <method> is used.
Method bytecode is printed on the standard output, e.g.:
Code:
java eu.smidovi.david.methodtools.ExportMethod ReaderResources_en_GB.class > ReaderResources_en_GB.bytecode
This will dump the class constructor to the given file.

Usage of ImportMethod is very similar:
java eu.smidovi.david.methodtools.ImportMethod <class file> [<method>] [<method signature>]
This reads bytecode from the standard input and replaces given method's code in the class file with the bytecode.
E.g.:
Code:
java eu.smidovi.david.methodtools.ImportMethod ReaderResources_en_GB.class < ReaderResources_en_GB.bytecode
On Linux, you can use included helper scripts em and im (I recommend creating symlinks in your path):
Code:
em ReaderResources_en_GB.class > ReaderResources_en_GB.bytecode
Bugs fixed:
  • JBE was not able to parse byte constants greater than 127, but happily produced them on output.
  • JBE was not able to parse multiline string constants it produced. I've fixed that by C-style escaping of special characters, <LF> included.
Attached Files
File Type: zip jbe_mt.zip (2.12 MB, 880 views)
dsmid is offline   Reply With Quote