/** * Finds the specified attribute in the target. */ public Attribute findAttribute(String attributeName) { // What's the target? return targetAttribute != null ? findAttribute(targetAttribute.u2attributesCount, targetAttribute.attributes, attributeName) : targetMember != null ? findAttribute(targetMember.u2attributesCount, targetMember.attributes, attributeName) : findAttribute(targetClass.u2attributesCount, targetClass.attributes, attributeName); }
/** * Finds the specified attribute in the target. */ public Attribute findAttribute(String attributeName) { // What's the target? return targetAttribute != null ? findAttribute(targetAttribute.u2attributesCount, targetAttribute.attributes, attributeName) : targetMember != null ? findAttribute(targetMember.u2attributesCount, targetMember.attributes, attributeName) : findAttribute(targetClass.u2attributesCount, targetClass.attributes, attributeName); }
/** * Finds the specified attribute in the target. */ public Attribute findAttribute(String attributeName) { // What's the target? return targetAttribute != null ? findAttribute(targetAttribute.u2attributesCount, targetAttribute.attributes, attributeName) : targetMember != null ? findAttribute(targetMember.u2attributesCount, targetMember.attributes, attributeName) : findAttribute(targetClass.u2attributesCount, targetClass.attributes, attributeName); }
/** * Deletes the attributes with the given name from the given array of * attributes, returning the new number of attributes. */ private int deleteAttribute(int attributesCount, Attribute[] attributes, String attributeName) { // Find the attribute. int index = findAttribute(attributesCount, attributes, attributeName); if (index < 0) { return attributesCount; } // Shift the other attributes in the array. System.arraycopy(attributes, index + 1, attributes, index, attributesCount - index - 1); // Clear the last entry in the array. attributes[--attributesCount] = null; return attributesCount; }
/** * Tries put the given attribute in place of an existing attribute of the * same name, returning whether it was present. */ private boolean replaceAttribute(int attributesCount, Attribute[] attributes, Attribute attribute) { // Find the attribute with the same name. int index = findAttribute(attributesCount, attributes, attribute.getAttributeName(targetClass)); if (index < 0) { return false; } attributes[index] = attribute; return true; }
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant) { // Find the bootstrap methods attribute. AttributesEditor attributesEditor = new AttributesEditor((ProgramClass)clazz, false); BootstrapMethodsAttribute bootstrapMethodsAttribute = (BootstrapMethodsAttribute)attributesEditor.findAttribute(ClassConstants.ATTR_BootstrapMethods); // Add the name and type constant. clazz.constantPoolEntryAccept(invokeDynamicConstant.u2nameAndTypeIndex, this); // Copy the referenced classes. Clazz[] referencedClasses = invokeDynamicConstant.referencedClasses; Clazz[] referencedClassesCopy = null; if (referencedClasses != null) { referencedClassesCopy = new Clazz[referencedClasses.length]; System.arraycopy(referencedClasses, 0, referencedClassesCopy, 0, referencedClasses.length); } bootstrapMethodsAttribute.bootstrapMethodEntryAccept(clazz, invokeDynamicConstant.getBootstrapMethodAttributeIndex(), bootstrapMethodsAttributeAdder); // Then add the actual invoke dynamic constant. constantIndex = constantPoolEditor.addInvokeDynamicConstant(bootstrapMethodsAttributeAdder.getBootstrapMethodIndex(), constantIndex, referencedClassesCopy); }
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant) { // Find the bootstrap methods attribute. AttributesEditor attributesEditor = new AttributesEditor((ProgramClass)clazz, false); BootstrapMethodsAttribute bootstrapMethodsAttribute = (BootstrapMethodsAttribute)attributesEditor.findAttribute(ClassConstants.ATTR_BootstrapMethods); // Add the name and type constant. clazz.constantPoolEntryAccept(invokeDynamicConstant.u2nameAndTypeIndex, this); // Copy the referenced classes. Clazz[] referencedClasses = invokeDynamicConstant.referencedClasses; Clazz[] referencedClassesCopy = null; if (referencedClasses != null) { referencedClassesCopy = new Clazz[referencedClasses.length]; System.arraycopy(referencedClasses, 0, referencedClassesCopy, 0, referencedClasses.length); } bootstrapMethodsAttribute.bootstrapMethodEntryAccept(clazz, invokeDynamicConstant.getBootstrapMethodAttributeIndex(), bootstrapMethodsAttributeAdder); // Then add the actual invoke dynamic constant. constantIndex = constantPoolEditor.addInvokeDynamicConstant(bootstrapMethodsAttributeAdder.getBootstrapMethodIndex(), constantIndex, referencedClassesCopy); }
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant) { // Find the bootstrap methods attribute. AttributesEditor attributesEditor = new AttributesEditor((ProgramClass)clazz, false); BootstrapMethodsAttribute bootstrapMethodsAttribute = (BootstrapMethodsAttribute)attributesEditor.findAttribute(ClassConstants.ATTR_BootstrapMethods); // Add the name and type constant. clazz.constantPoolEntryAccept(invokeDynamicConstant.u2nameAndTypeIndex, this); // Copy the referenced classes. Clazz[] referencedClasses = invokeDynamicConstant.referencedClasses; Clazz[] referencedClassesCopy = null; if (referencedClasses != null) { referencedClassesCopy = new Clazz[referencedClasses.length]; System.arraycopy(referencedClasses, 0, referencedClassesCopy, 0, referencedClasses.length); } bootstrapMethodsAttribute.bootstrapMethodEntryAccept(clazz, invokeDynamicConstant.getBootstrapMethodAttributeIndex(), bootstrapMethodsAttributeAdder); // Then add the actual invoke dynamic constant. constantIndex = constantPoolEditor.addInvokeDynamicConstant(bootstrapMethodsAttributeAdder.getBootstrapMethodIndex(), constantIndex, referencedClassesCopy); }
(BootstrapMethodsAttribute)attributesEditor.findAttribute(ClassConstants.ATTR_BootstrapMethods);
(BootstrapMethodsAttribute)attributesEditor.findAttribute(ClassConstants.ATTR_BootstrapMethods);
(BootstrapMethodsAttribute)attributesEditor.findAttribute(ClassConstants.ATTR_BootstrapMethods);