1 /******************************************************************************* 2 * Copyright (c) 2000, 2009 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.jdt.core.util; 15 16 /** 17 * This class is intended to be subclassed to disassemble 18 * classfile bytes onto a String using the proper line separator. 19 * 20 * @since 2.1 21 */ 22 public abstract class ClassFileBytesDisassembler { 23 24 /** 25 * The mode is the detailed mode to disassemble IClassFileReader. It returns the magic 26 * numbers, the version numbers and field and method descriptors. 27 */ 28 public final static int DETAILED = 1; 29 30 /** 31 * The mode is the default mode to disassemble IClassFileReader. 32 */ 33 public final static int DEFAULT = 2; 34 35 /** 36 * This mode corresponds to the detailed mode plus the constant pool contents and 37 * any further information that would be useful for debugging purpose. 38 * @since 3.1 39 */ 40 public final static int SYSTEM = 4; 41 42 /** 43 * This mode is used to compact the class name to a simple name instead of a qualified name. 44 * @since 3.1 45 */ 46 public final static int COMPACT = 8; 47 48 /** 49 * This mode is used to retrive a pseudo code for working copy purpose. 50 * @since 3.2 51 */ 52 public final static int WORKING_COPY = 16; 53 54 /** 55 * Answers back the disassembled string of the classfile bytes using the default 56 * mode. 57 * This is an output quite similar to the javap tool, using DEFAULT mode. 58 * 59 * @param classFileBytes The bytes of the classfile 60 * @param lineSeparator the line separator to use. 61 * 62 * @return the disassembled string of the IClassFileReader using the default mode. 63 * @exception ClassFormatException if the classfile bytes are ill-formed 64 */ disassemble(byte[] classFileBytes, String lineSeparator)65 public abstract String disassemble(byte[] classFileBytes, String lineSeparator) throws ClassFormatException; 66 67 /** 68 * Answers back the disassembled string of the classfile bytes according to the 69 * mode. 70 * This is an output quite similar to the javap tool. 71 * 72 * @param classFileBytes The bytes of the classfile 73 * @param lineSeparator the line separator to use. 74 * @param mode the mode used to disassemble the IClassFileReader 75 * 76 * @return the disassembled string of the IClassFileReader according to the mode 77 * @exception ClassFormatException if the classfile bytes are ill-formed 78 */ disassemble(byte[] classFileBytes, String lineSeparator, int mode)79 public abstract String disassemble(byte[] classFileBytes, String lineSeparator, int mode) throws ClassFormatException; 80 81 /** 82 * Answers a readable short description of this disassembler 83 * 84 * @return String - a string description of the disassembler 85 */ getDescription()86 public abstract String getDescription(); 87 } 88