"BootstrapMethods"
.
*/
public static final String tag = "BootstrapMethods";
/**
* An element of bootstrap_methods
.
*/
public static class BootstrapMethod {
/**
* Constructs an element of bootstrap_methods
.
*
* @param method bootstrap_method_ref
.
* @param args bootstrap_arguments
.
*/
public BootstrapMethod(int method, int[] args) {
methodRef = method;
arguments = args;
}
/**
* bootstrap_method_ref
.
* The value at this index must be a CONSTANT_MethodHandle_info
.
*/
public int methodRef;
/**
* bootstrap_arguments
.
*/
public int[] arguments;
/**
* Makes a copy. Class names are replaced according to the
* * given Map
object.
*
* @param srcCp the constant pool table from the source
* @param destCp the constant pool table used bt new copy
* @param classnames pairs of replaced and substituted class names.
*
* @return new BootstrapMethod
*/
protected BootstrapMethod copy(ConstPool srcCp, ConstPool destCp, Mapbootstrap_methods
in this attribute.
*
* @return an array of BootstrapMethod
. Since it
* is a fresh copy, modifying the returned array does not
* affect the original contents of this attribute.
*/
public BootstrapMethod[] getMethods() {
byte[] data = this.get();
int num = ByteArray.readU16bit(data, 0);
BootstrapMethod[] methods = new BootstrapMethod[num];
int pos = 2;
for (int i = 0; i < num; i++) {
int ref = ByteArray.readU16bit(data, pos);
int len = ByteArray.readU16bit(data, pos + 2);
int[] args = new int[len];
pos += 4;
for (int k = 0; k < len; k++) {
args[k] = ByteArray.readU16bit(data, pos);
pos += 2;
}
methods[i] = new BootstrapMethod(ref, args);
}
return methods;
}
/**
* Makes a copy. Class names are replaced according to the
* given Map
object.
*
* @param newCp the constant pool table used by the new copy.
* @param classnames pairs of replaced and substituted
* class names.
*/
@Override
public AttributeInfo copy(ConstPool newCp, MapConstPool
and BootstrapMethod
,
* and add it to the specified index. Class names are replaced according to the
* given Map
object.
*
*
* if the index less than 0 or large than the origin method length, then throw RuntimeException
;
* if the index large or equals to 0 and less or equals to the origin method length,
* then replace the origin method with the new BootstrapMethod srcBm
;
* if the index equals to the origin method length, then append the new BootstrapMethod srcBm
at
* the origin methods tail.
*