Read and write java class files in node or browser.
npm install java-class-tools
npm install java-class-tools
`
Examples:
- Browser usage example (List all the methods and fields of a class file)
- Node usage example (Simple disassembler)
- Try yourself (_RunKit:_ you must login with GitHub to be able to fork it)
Print all method names (node.js)
`javascript
const { JavaClassFileReader } = require('java-class-tools');
const reader = new JavaClassFileReader();
const classFile = reader.read('path/to/file.class');
classFile.methods.forEach(md => {
/**
* Method name in constant-pool.
*
* Points to a CONSTANT_Utf8_info structure: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.7
*/
const nameInConstantPool = classFile.constant_pool[md.name_index];
// To string (hacky)
const name = String.fromCharCode.apply(null, nameInConstantPool.bytes);
console.log(name);
});
`
Usage Example (browser): print all method names
`html
``