Commit 649dbed3 authored by Eric Bruneton's avatar Eric Bruneton

Make ConstantDynamic immutable, and make TypePath final.

parent 19735cbf
Pipeline #2937 passed with stage
in 10 minutes and 37 seconds
......@@ -172,10 +172,11 @@ public abstract class Remapper {
}
if (value instanceof ConstantDynamic) {
ConstantDynamic constantDynamic = (ConstantDynamic) value;
Object[] bootstrapMethodArguments = constantDynamic.getBootstrapMethodArguments();
Object[] remappedBootstrapMethodArguments = new Object[bootstrapMethodArguments.length];
for (int i = 0; i < bootstrapMethodArguments.length; ++i) {
remappedBootstrapMethodArguments[i] = mapValue(bootstrapMethodArguments[i]);
int bootstrapMethodArgumentCount = constantDynamic.getBootstrapMethodArgumentCount();
Object[] remappedBootstrapMethodArguments = new Object[bootstrapMethodArgumentCount];
for (int i = 0; i < bootstrapMethodArgumentCount; ++i) {
remappedBootstrapMethodArguments[i] =
mapValue(constantDynamic.getBootstrapMethodArgument(i));
}
String descriptor = constantDynamic.getDescriptor();
return new ConstantDynamic(
......
......@@ -1395,10 +1395,10 @@ public class ASMifier extends Printer {
stringBuilder.append(constantDynamic.getDescriptor()).append("\", ");
appendConstant(constantDynamic.getBootstrapMethod());
stringBuilder.append(", new Object[] {");
Object[] bootstrapMethodArguments = constantDynamic.getBootstrapMethodArguments();
for (int i = 0; i < bootstrapMethodArguments.length; ++i) {
appendConstant(bootstrapMethodArguments[i]);
if (i != bootstrapMethodArguments.length - 1) {
int bootstrapMethodArgumentCount = constantDynamic.getBootstrapMethodArgumentCount();
for (int i = 0; i < bootstrapMethodArgumentCount; ++i) {
appendConstant(constantDynamic.getBootstrapMethodArgument(i));
if (i != bootstrapMethodArgumentCount - 1) {
stringBuilder.append(", ");
}
}
......
......@@ -1215,8 +1215,9 @@ public class CheckMethodAdapter extends MethodVisitor {
checkMethodIdentifier(this.version, constantDynamic.getName(), "constant dynamic name");
checkDescriptor(this.version, constantDynamic.getDescriptor(), false);
checkLdcConstant(constantDynamic.getBootstrapMethod());
for (Object bootstrapArgument : constantDynamic.getBootstrapMethodArguments()) {
checkLdcConstant(bootstrapArgument);
int bootstrapMethodArgumentCount = constantDynamic.getBootstrapMethodArgumentCount();
for (int i = 0; i < bootstrapMethodArgumentCount; ++i) {
checkLdcConstant(constantDynamic.getBootstrapMethodArgument(i));
}
} else {
checkConstant(value);
......
......@@ -99,13 +99,36 @@ public final class ConstantDynamic {
}
/**
* Returns the arguments to pass to the bootstrap method, in order to compute the value of this
* Returns the number of arguments passed to the bootstrap method, in order to compute the value
* of this constant.
*
* @return the number of arguments passed to the bootstrap method, in order to compute the value
* of this constant.
*/
public int getBootstrapMethodArgumentCount() {
return bootstrapMethodArguments.length;
}
/**
* Returns an argument passed to the bootstrap method, in order to compute the value of this
* constant.
*
* @param index an argument index, between 0 and {@link #getBootstrapMethodArgumentCount()}
* (exclusive).
* @return the argument passed to the bootstrap method, with the given index.
*/
public Object getBootstrapMethodArgument(final int index) {
return bootstrapMethodArguments[index];
}
/**
* Returns the arguments to pass to the bootstrap method, in order to compute the value of this
* constant. WARNING: this array must not be modified, and must not be returned to the user.
*
* @return the arguments to pass to the bootstrap method, in order to compute the value of this
* constant.
*/
public Object[] getBootstrapMethodArguments() {
Object[] getBootstrapMethodArgumentsUnsafe() {
return bootstrapMethodArguments;
}
......
......@@ -496,7 +496,7 @@ final class SymbolTable {
constantDynamic.getName(),
constantDynamic.getDescriptor(),
constantDynamic.getBootstrapMethod(),
constantDynamic.getBootstrapMethodArguments());
constantDynamic.getBootstrapMethodArgumentsUnsafe());
} else {
throw new IllegalArgumentException("value " + value);
}
......
......@@ -153,7 +153,7 @@ public final class Type {
* @param valueBuffer a buffer containing the value of this field or method type.
* @param valueBegin the beginning index, inclusive, of the value of this field or method type in
* valueBuffer.
* @param valueEnd tne end index, exclusive, of the value of this field or method type in
* @param valueEnd the end index, exclusive, of the value of this field or method type in
* valueBuffer.
*/
private Type(final int sort, final String valueBuffer, final int valueBegin, final int valueEnd) {
......
......@@ -34,7 +34,7 @@ package org.objectweb.asm;
*
* @author Eric Bruneton
*/
public class TypePath {
public final class TypePath {
/** A type path step that steps into the element type of an array type. See {@link #getStep}. */
public static final int ARRAY_ELEMENT = 0;
......
......@@ -472,7 +472,7 @@ meth public static org.objectweb.asm.Type[] getArgumentTypes(java.lang.reflect.M
supr java.lang.Object
hfds a,b,c,d
CLSS public org.objectweb.asm.TypePath
CLSS public final org.objectweb.asm.TypePath
fld public final static int ARRAY_ELEMENT = 0
fld public final static int INNER_TYPE = 1
fld public final static int TYPE_ARGUMENT = 3
......
......@@ -475,7 +475,7 @@ meth public static org.objectweb.asm.Type[] getArgumentTypes(java.lang.reflect.M
supr java.lang.Object
hfds a,b,c,d
CLSS public org.objectweb.asm.TypePath
CLSS public final org.objectweb.asm.TypePath
fld public final static int ARRAY_ELEMENT = 0
fld public final static int INNER_TYPE = 1
fld public final static int TYPE_ARGUMENT = 3
......
......@@ -505,7 +505,7 @@ meth public static org.objectweb.asm.Type[] getArgumentTypes(java.lang.reflect.M
supr java.lang.Object
hfds buf,len,off,sort
CLSS public org.objectweb.asm.TypePath
CLSS public final org.objectweb.asm.TypePath
fld public final static int ARRAY_ELEMENT = 0
fld public final static int INNER_TYPE = 1
fld public final static int TYPE_ARGUMENT = 3
......
......@@ -506,7 +506,7 @@ meth public static org.objectweb.asm.Type[] getArgumentTypes(java.lang.reflect.M
supr java.lang.Object
hfds INTERNAL,PRIMITIVE_DESCRIPTORS,sort,valueBuffer,valueLength,valueOffset
CLSS public org.objectweb.asm.TypePath
CLSS public final org.objectweb.asm.TypePath
fld public final static int ARRAY_ELEMENT = 0
fld public final static int INNER_TYPE = 1
fld public final static int TYPE_ARGUMENT = 3
......
......@@ -146,18 +146,6 @@ meth public int newUTF8(java.lang.String)
supr org.objectweb.asm.ClassVisitor
hfds accessFlags,compute,debugExtension,enclosingClassIndex,enclosingMethodIndex,firstAttribute,firstField,firstMethod,innerClasses,interfaceCount,interfaces,lastField,lastMethod,lastRuntimeInvisibleAnnotation,lastRuntimeInvisibleTypeAnnotation,lastRuntimeVisibleAnnotation,lastRuntimeVisibleTypeAnnotation,moduleWriter,nestHostClassIndex,nestMemberClasses,numberOfInnerClasses,numberOfNestMemberClasses,signatureIndex,sourceFileIndex,superClass,symbolTable,thisClass,version
CLSS public final org.objectweb.asm.ConstantDynamic
cons public !varargs init(java.lang.String,java.lang.String,org.objectweb.asm.Handle,java.lang.Object[])
meth public boolean equals(java.lang.Object)
meth public int hashCode()
meth public java.lang.Object[] getBootstrapMethodArguments()
meth public java.lang.String getDescriptor()
meth public java.lang.String getName()
meth public java.lang.String toString()
meth public org.objectweb.asm.Handle getBootstrapMethod()
supr java.lang.Object
hfds bootstrapMethod,bootstrapMethodArguments,descriptor,name
CLSS public abstract org.objectweb.asm.FieldVisitor
cons public init(int)
cons public init(int,org.objectweb.asm.FieldVisitor)
......@@ -529,7 +517,7 @@ meth public static org.objectweb.asm.Type[] getArgumentTypes(java.lang.reflect.M
supr java.lang.Object
hfds INTERNAL,PRIMITIVE_DESCRIPTORS,sort,valueBegin,valueBuffer,valueEnd
CLSS public org.objectweb.asm.TypePath
CLSS public final org.objectweb.asm.TypePath
fld public final static int ARRAY_ELEMENT = 0
fld public final static int INNER_TYPE = 1
fld public final static int TYPE_ARGUMENT = 3
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment