public static String disassemble(IClassFile classFile) { ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); String disassembledByteCode = null; try { disassembledByteCode = disassembler.disassemble(classFile.getBytes(), LF, ClassFileBytesDisassembler.WORKING_COPY); disassembledByteCode = MISSING_SOURCES_HEADER + LF + disassembledByteCode; } catch (Exception e) { // JavaLanguageServerPlugin.logError("Unable to disassemble " + // classFile.getHandleIdentifier()); e.printStackTrace(); } return disassembledByteCode; }
private String getContent(byte[] bytes, IProgressMonitor monitor) throws CoreException { ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); String disassembledByteCode = null; try { disassembledByteCode = disassembler.disassemble(bytes, LF, ClassFileBytesDisassembler.WORKING_COPY); if (disassembledByteCode != null) { disassembledByteCode = DISASSEMBLED_HEADER + disassembledByteCode; } } catch (ClassFormatException e) { throw new CoreException(new Status(Status.ERROR, "", "Error disassembling", e)); } return disassembledByteCode; }
/** * @see Openable#openBuffer(IProgressMonitor, Object) */ protected IBuffer openBuffer(IProgressMonitor pm, Object info) throws JavaModelException { // create buffer IBuffer buffer = BufferManager.createBuffer(this); // set the buffer source IBuffer classFileBuffer = this.classFile.getBuffer(); if (classFileBuffer != null) { buffer.setContents(classFileBuffer.getCharacters()); } else { // Disassemble IClassFileReader reader = ToolFactory.createDefaultClassFileReader(this.classFile, IClassFileReader.ALL); Disassembler disassembler = new Disassembler(); String contents = disassembler.disassemble(reader, Util.getLineSeparator("", getJavaProject()), ClassFileBytesDisassembler.WORKING_COPY); //$NON-NLS-1$ buffer.setContents(contents); } // add buffer to buffer cache BufferManager bufManager = getBufferManager(); bufManager.addBuffer(buffer); // listen to buffer changes buffer.addBufferChangedListener(this); return buffer; }
private boolean isCompact() { return (this.mode & ClassFileBytesDisassembler.COMPACT) != 0; }
/** * Create a classfile bytecode disassembler, able to produce a String representation of a given * classfile. * * @return a classfile bytecode disassembler * @see org.eclipse.jdt.core.util.ClassFileBytesDisassembler * @since 2.1 */ public static ClassFileBytesDisassembler createDefaultClassFileBytesDisassembler() { return new Disassembler(); }
/** * Create a classfile bytecode disassembler, able to produce a String representation of a given classfile. * * @return a classfile bytecode disassembler * @see ClassFileBytesDisassembler * @since 2.1 */ public static ClassFileBytesDisassembler createDefaultClassFileBytesDisassembler(){ return new Disassembler(); }