java-class-tools example

node v10.24.1
version: 2.0.0
endpointsharetweet
const { fetchUrl } = require('fetch') const { JavaClassFileReader } = require('java-class-tools') const CLASS_EXAMPLE_GIST = 'https://gist.github.com/leonardosnt/69207dd9bcae55c93ff8fe6546c92eef/raw/fa008a94f9bc208cfa593cf568f0c504e3b30413/Class.class' fetchUrl(CLASS_EXAMPLE_GIST, function (err, meta, body) { const reader = new JavaClassFileReader() const classFile = reader.read(body) classFile.methods.forEach(method => { const methodNameInConstantPool = classFile.constant_pool[method.name_index] const signatureInConstantPool = classFile.constant_pool[method.descriptor_index]; // To string (hacky) const name = String.fromCharCode.apply(null, methodNameInConstantPool.bytes) const signature = String.fromCharCode.apply(null, signatureInConstantPool.bytes) console.log(`${name} ${signature}`) }) })
Loading…

no comments

    sign in to comment