You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

java-class-tools

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

java-class-tools

Read and write java class files in node or browser.

1.1.0
Version published
Weekly downloads
620
55%
Maintainers
1
Weekly downloads
 
Created

java-class-tools

Examples:

Print all methods names

'use strict';

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.
   * 
   * https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.7
   */
  const nameCpEntry = classFile.constant_pool[md.name_index];

  // To utf-8 string
  const name = String.fromCharCode.apply(null, nameCpEntry.bytes);

  console.log(name);
});

FAQs

Package last updated on 26 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts