Java Code Examples for com.sun.org.apache.bcel.internal.Constants#ATTR_CODE
The following examples show how to use
com.sun.org.apache.bcel.internal.Constants#ATTR_CODE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Code.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 2
Source File: Code.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 3
Source File: Code.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 4
Source File: Code.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 5
Source File: Code.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 6
Source File: Code.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 7
Source File: Code.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 8
Source File: Code.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 9
Source File: Code.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 10
Source File: Code.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * @param name_index Index pointing to the name <em>Code</em> * @param length Content length in bytes * @param max_stack Maximum size of stack * @param max_locals Number of local variables * @param code Actual byte code * @param exception_table Table of handled exceptions * @param attributes Attributes of code: LineNumber or LocalVariable * @param constant_pool Array of constants */ public Code(int name_index, int length, int max_stack, int max_locals, byte[] code, CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) { super(Constants.ATTR_CODE, name_index, length, constant_pool); this.max_stack = max_stack; this.max_locals = max_locals; setCode(code); setExceptionTable(exception_table); setAttributes(attributes); // Overwrites length! }
Example 11
Source File: Attribute.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 12
Source File: Attribute.java From JDKSourceCode1.8 with MIT License | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 13
Source File: Attribute.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 14
Source File: Attribute.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 15
Source File: Attribute.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 16
Source File: Attribute.java From hottub with GNU General Public License v2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 17
Source File: Attribute.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 18
Source File: Attribute.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 19
Source File: Attribute.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }
Example 20
Source File: Attribute.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public static final Attribute readAttribute(DataInputStream file, ConstantPool constant_pool) throws IOException, ClassFormatException { ConstantUtf8 c; String name; int name_index; int length; byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute // Get class name from constant pool via `name_index' indirection name_index = (int)file.readUnsignedShort(); c = (ConstantUtf8)constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8); name = c.getBytes(); // Length of data in bytes length = file.readInt(); // Compare strings to find known attribute for(byte i=0; i < Constants.KNOWN_ATTRIBUTES; i++) { if(name.equals(Constants.ATTRIBUTE_NAMES[i])) { tag = i; // found! break; } } // Call proper constructor, depending on `tag' switch(tag) { case Constants.ATTR_UNKNOWN: AttributeReader r = (AttributeReader)readers.get(name); if(r != null) return r.createAttribute(name_index, length, file, constant_pool); else return new Unknown(name_index, length, file, constant_pool); case Constants.ATTR_CONSTANT_VALUE: return new ConstantValue(name_index, length, file, constant_pool); case Constants.ATTR_SOURCE_FILE: return new SourceFile(name_index, length, file, constant_pool); case Constants.ATTR_CODE: return new Code(name_index, length, file, constant_pool); case Constants.ATTR_EXCEPTIONS: return new ExceptionTable(name_index, length, file, constant_pool); case Constants.ATTR_LINE_NUMBER_TABLE: return new LineNumberTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TABLE: return new LocalVariableTable(name_index, length, file, constant_pool); case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE: return new LocalVariableTypeTable(name_index, length, file, constant_pool); case Constants.ATTR_INNER_CLASSES: return new InnerClasses(name_index, length, file, constant_pool); case Constants.ATTR_SYNTHETIC: return new Synthetic(name_index, length, file, constant_pool); case Constants.ATTR_DEPRECATED: return new Deprecated(name_index, length, file, constant_pool); case Constants.ATTR_PMG: return new PMGClass(name_index, length, file, constant_pool); case Constants.ATTR_SIGNATURE: return new Signature(name_index, length, file, constant_pool); case Constants.ATTR_STACK_MAP: return new StackMap(name_index, length, file, constant_pool); default: // Never reached throw new IllegalStateException("Ooops! default case reached."); } }