public static IClassFileAttribute getAttribute( IClassFileReader classFileReader, char[] attributeName) { IClassFileAttribute[] attributes = classFileReader.getAttributes(); for (int i = 0, max = attributes.length; i < max; i++) { if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) { return attributes[i]; } } return null; }
public static IClassFileAttribute getAttribute( ICodeAttribute codeAttribute, char[] attributeName) { IClassFileAttribute[] attributes = codeAttribute.getAttributes(); for (int i = 0, max = attributes.length; i < max; i++) { if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) { return attributes[i]; } } return null; }
public static IClassFileAttribute getAttribute(IFieldInfo fieldInfo, char[] attributeName) { IClassFileAttribute[] attributes = fieldInfo.getAttributes(); for (int i = 0, max = attributes.length; i < max; i++) { if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) { return attributes[i]; } } return null; }
public static IClassFileAttribute getAttribute(IMethodInfo methodInfo, char[] attributeName) { IClassFileAttribute[] attributes = methodInfo.getAttributes(); for (int i = 0, max = attributes.length; i < max; i++) { if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) { return attributes[i]; } } return null; }
public static IClassFileAttribute getAttribute(IClassFileReader classFileReader, char[] attributeName) { IClassFileAttribute[] attributes = classFileReader.getAttributes(); for (int i = 0, max = attributes.length; i < max; i++) { if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) { return attributes[i]; } } return null; }
public static IClassFileAttribute getAttribute(ICodeAttribute codeAttribute, char[] attributeName) { IClassFileAttribute[] attributes = codeAttribute.getAttributes(); for (int i = 0, max = attributes.length; i < max; i++) { if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) { return attributes[i]; } } return null; }
CodeAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { super(classFileBytes, constantPool, offset); this.classFileBytes = classFileBytes; this.constantPool = constantPool; this.maxStack = u2At(classFileBytes, 6, offset); this.maxLocals = u2At(classFileBytes, 8, offset); this.codeLength = u4At(classFileBytes, 10, offset); this.codeOffset = offset + 14; int readOffset = (int) (14 + this.codeLength); this.exceptionTableLength = u2At(classFileBytes, readOffset, offset); readOffset += 2; this.exceptionTableEntries = NO_EXCEPTION_TABLE; if (this.exceptionTableLength != 0) { this.exceptionTableEntries = new ExceptionTableEntry[this.exceptionTableLength]; for (int i = 0; i < this.exceptionTableLength; i++) { this.exceptionTableEntries [i] = new ExceptionTableEntry(classFileBytes, constantPool, offset + readOffset); readOffset += 8; } } this.attributesCount = u2At(classFileBytes, readOffset, offset); this.attributes = ClassFileAttribute.NO_ATTRIBUTES; if (this.attributesCount != 0) { this.attributes = new IClassFileAttribute[this.attributesCount]; } int attributesIndex = 0; readOffset += 2; for (int i = 0; i < this.attributesCount; i++) { IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset)); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } char[] attributeName = constantPoolEntry.getUtf8Value(); if (equals(attributeName, IAttributeNamesConstants.LINE_NUMBER)) { this.lineNumberAttribute = new LineNumberAttribute(classFileBytes, constantPool, offset + readOffset); this.attributes[attributesIndex++] = this.lineNumberAttribute; } else if (equals(attributeName, IAttributeNamesConstants.LOCAL_VARIABLE)) { this.localVariableAttribute = new LocalVariableAttribute(classFileBytes, constantPool, offset + readOffset); this.attributes[attributesIndex++] = this.localVariableAttribute; } else if (equals(attributeName, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE)) { this.attributes[attributesIndex++] = new LocalVariableTypeAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.STACK_MAP_TABLE)) { this.attributes[attributesIndex++] = new StackMapTableAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.STACK_MAP)) { this.attributes[attributesIndex++] = new StackMapAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_VISIBLE_TYPE_ANNOTATIONS)) { this.attributes[attributesIndex++] = new RuntimeVisibleTypeAnnotationsAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_INVISIBLE_TYPE_ANNOTATIONS)) { this.attributes[attributesIndex++] = new RuntimeInvisibleTypeAnnotationsAttribute(classFileBytes, constantPool, offset + readOffset); } else { this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); } readOffset += (6 + u4At(classFileBytes, readOffset + 2, offset)); } }
/** * @see ICodeAttribute#getAttributes() */ public IClassFileAttribute[] getAttributes() { return this.attributes; }
/** * @see IMethodInfo#getAttributes() */ public IClassFileAttribute[] getAttributes() { return this.attributes; }
/** * @see IClassFileReader#getAttributes() */ public IClassFileAttribute[] getAttributes() { return this.attributes; }
/** * @param classFileBytes byte[] * @param constantPool IConstantPool * @param offset int */ public FieldInfo(byte classFileBytes[], IConstantPool constantPool, int offset) throws ClassFormatException { final int flags = u2At(classFileBytes, 0, offset); this.accessFlags = flags; if ((flags & IModifierConstants.ACC_SYNTHETIC) != 0) { this.isSynthetic = true; } this.nameIndex = u2At(classFileBytes, 2, offset); IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(this.nameIndex); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } this.name = constantPoolEntry.getUtf8Value(); this.descriptorIndex = u2At(classFileBytes, 4, offset); constantPoolEntry = constantPool.decodeEntry(this.descriptorIndex); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } this.descriptor = constantPoolEntry.getUtf8Value(); this.attributesCount = u2At(classFileBytes, 6, offset); this.attributes = ClassFileAttribute.NO_ATTRIBUTES; int readOffset = 8; if (this.attributesCount != 0) { this.attributes = new IClassFileAttribute[this.attributesCount]; } int attributesIndex = 0; for (int i = 0; i < this.attributesCount; i++) { constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset)); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } char[] attributeName = constantPoolEntry.getUtf8Value(); if (equals(attributeName, IAttributeNamesConstants.DEPRECATED)) { this.isDeprecated = true; this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.SYNTHETIC)) { this.isSynthetic = true; this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.CONSTANT_VALUE)) { this.constantValueAttribute = new ConstantValueAttribute(classFileBytes, constantPool, offset + readOffset); this.attributes[attributesIndex++] = this.constantValueAttribute; } else if (equals(attributeName, IAttributeNamesConstants.SIGNATURE)) { this.attributes[attributesIndex++] = new SignatureAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_VISIBLE_ANNOTATIONS)) { this.attributes[attributesIndex++] = new RuntimeVisibleAnnotationsAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_INVISIBLE_ANNOTATIONS)) { this.attributes[attributesIndex++] = new RuntimeInvisibleAnnotationsAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_VISIBLE_TYPE_ANNOTATIONS)) { this.attributes[attributesIndex++] = new RuntimeVisibleTypeAnnotationsAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_INVISIBLE_TYPE_ANNOTATIONS)) { this.attributes[attributesIndex++] = new RuntimeInvisibleTypeAnnotationsAttribute(classFileBytes, constantPool, offset + readOffset); } else { this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); } readOffset += (6 + u4At(classFileBytes, readOffset + 2, offset)); } this.attributeBytes = readOffset; }
/** * @see IFieldInfo#getAttributes() */ public IClassFileAttribute[] getAttributes() { return this.attributes; }
CodeAttribute(byte[] classFileBytes, IConstantPool constantPool, int offset) throws ClassFormatException { super(classFileBytes, constantPool, offset); this.classFileBytes = classFileBytes; this.constantPool = constantPool; this.maxStack = u2At(classFileBytes, 6, offset); this.maxLocals = u2At(classFileBytes, 8, offset); this.codeLength = u4At(classFileBytes, 10, offset); this.codeOffset = offset + 14; int readOffset = (int) (14 + this.codeLength); this.exceptionTableLength = u2At(classFileBytes, readOffset, offset); readOffset += 2; this.exceptionTableEntries = NO_EXCEPTION_TABLE; if (this.exceptionTableLength != 0) { this.exceptionTableEntries = new ExceptionTableEntry[this.exceptionTableLength]; for (int i = 0; i < this.exceptionTableLength; i++) { this.exceptionTableEntries [i] = new ExceptionTableEntry(classFileBytes, constantPool, offset + readOffset); readOffset += 8; } } this.attributesCount = u2At(classFileBytes, readOffset, offset); this.attributes = ClassFileAttribute.NO_ATTRIBUTES; if (this.attributesCount != 0) { this.attributes = new IClassFileAttribute[this.attributesCount]; } int attributesIndex = 0; readOffset += 2; for (int i = 0; i < this.attributesCount; i++) { IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset)); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } char[] attributeName = constantPoolEntry.getUtf8Value(); if (equals(attributeName, IAttributeNamesConstants.LINE_NUMBER)) { this.lineNumberAttribute = new LineNumberAttribute(classFileBytes, constantPool, offset + readOffset); this.attributes[attributesIndex++] = this.lineNumberAttribute; } else if (equals(attributeName, IAttributeNamesConstants.LOCAL_VARIABLE)) { this.localVariableAttribute = new LocalVariableAttribute(classFileBytes, constantPool, offset + readOffset); this.attributes[attributesIndex++] = this.localVariableAttribute; } else if (equals(attributeName, IAttributeNamesConstants.LOCAL_VARIABLE_TYPE_TABLE)) { this.attributes[attributesIndex++] = new LocalVariableTypeAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.STACK_MAP_TABLE)) { this.attributes[attributesIndex++] = new StackMapTableAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.STACK_MAP)) { this.attributes[attributesIndex++] = new StackMapAttribute(classFileBytes, constantPool, offset + readOffset); } else { this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); } readOffset += (6 + u4At(classFileBytes, readOffset + 2, offset)); } }
/** * @param classFileBytes byte[] * @param constantPool IConstantPool * @param offset int */ public FieldInfo(byte classFileBytes[], IConstantPool constantPool, int offset) throws ClassFormatException { final int flags = u2At(classFileBytes, 0, offset); this.accessFlags = flags; if ((flags & IModifierConstants.ACC_SYNTHETIC) != 0) { this.isSynthetic = true; } this.nameIndex = u2At(classFileBytes, 2, offset); IConstantPoolEntry constantPoolEntry = constantPool.decodeEntry(this.nameIndex); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } this.name = constantPoolEntry.getUtf8Value(); this.descriptorIndex = u2At(classFileBytes, 4, offset); constantPoolEntry = constantPool.decodeEntry(this.descriptorIndex); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } this.descriptor = constantPoolEntry.getUtf8Value(); this.attributesCount = u2At(classFileBytes, 6, offset); this.attributes = ClassFileAttribute.NO_ATTRIBUTES; int readOffset = 8; if (this.attributesCount != 0) { this.attributes = new IClassFileAttribute[this.attributesCount]; } int attributesIndex = 0; for (int i = 0; i < this.attributesCount; i++) { constantPoolEntry = constantPool.decodeEntry(u2At(classFileBytes, readOffset, offset)); if (constantPoolEntry.getKind() != IConstantPoolConstant.CONSTANT_Utf8) { throw new ClassFormatException(ClassFormatException.INVALID_CONSTANT_POOL_ENTRY); } char[] attributeName = constantPoolEntry.getUtf8Value(); if (equals(attributeName, IAttributeNamesConstants.DEPRECATED)) { this.isDeprecated = true; this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.SYNTHETIC)) { this.isSynthetic = true; this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.CONSTANT_VALUE)) { this.constantValueAttribute = new ConstantValueAttribute(classFileBytes, constantPool, offset + readOffset); this.attributes[attributesIndex++] = this.constantValueAttribute; } else if (equals(attributeName, IAttributeNamesConstants.SIGNATURE)) { this.attributes[attributesIndex++] = new SignatureAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_VISIBLE_ANNOTATIONS)) { this.attributes[attributesIndex++] = new RuntimeVisibleAnnotationsAttribute(classFileBytes, constantPool, offset + readOffset); } else if (equals(attributeName, IAttributeNamesConstants.RUNTIME_INVISIBLE_ANNOTATIONS)) { this.attributes[attributesIndex++] = new RuntimeInvisibleAnnotationsAttribute(classFileBytes, constantPool, offset + readOffset); } else { this.attributes[attributesIndex++] = new ClassFileAttribute(classFileBytes, constantPool, offset + readOffset); } readOffset += (6 + u4At(classFileBytes, readOffset + 2, offset)); } this.attributeBytes = readOffset; }