Painless: Clean Up Whitelist Names (#32791)
Renames variables in the whitelists to match the current naming scheme. Mechanical change.
This commit is contained in:
parent
cb1d467124
commit
47d2bcc3c4
|
@ -56,14 +56,14 @@ public final class Whitelist {
|
||||||
Collections.singletonList(WhitelistLoader.loadFromResourceFiles(Whitelist.class, BASE_WHITELIST_FILES));
|
Collections.singletonList(WhitelistLoader.loadFromResourceFiles(Whitelist.class, BASE_WHITELIST_FILES));
|
||||||
|
|
||||||
/** The {@link ClassLoader} used to look up the whitelisted Java classes, constructors, methods, and fields. */
|
/** The {@link ClassLoader} used to look up the whitelisted Java classes, constructors, methods, and fields. */
|
||||||
public final ClassLoader javaClassLoader;
|
public final ClassLoader classLoader;
|
||||||
|
|
||||||
/** The {@link List} of all the whitelisted Painless classes. */
|
/** The {@link List} of all the whitelisted Painless classes. */
|
||||||
public final List<WhitelistClass> whitelistStructs;
|
public final List<WhitelistClass> whitelistClasses;
|
||||||
|
|
||||||
/** Standard constructor. All values must be not {@code null}. */
|
/** Standard constructor. All values must be not {@code null}. */
|
||||||
public Whitelist(ClassLoader javaClassLoader, List<WhitelistClass> whitelistStructs) {
|
public Whitelist(ClassLoader classLoader, List<WhitelistClass> whitelistClasses) {
|
||||||
this.javaClassLoader = Objects.requireNonNull(javaClassLoader);
|
this.classLoader = Objects.requireNonNull(classLoader);
|
||||||
this.whitelistStructs = Collections.unmodifiableList(Objects.requireNonNull(whitelistStructs));
|
this.whitelistClasses = Collections.unmodifiableList(Objects.requireNonNull(whitelistClasses));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
public final class WhitelistClass {
|
public final class WhitelistClass {
|
||||||
|
|
||||||
/** Information about where this class was white-listed from. Can be used for error messages. */
|
/** Information about where this class was white-listed from. */
|
||||||
public final String origin;
|
public final String origin;
|
||||||
|
|
||||||
/** The Java class name this class represents. */
|
/** The Java class name this class represents. */
|
||||||
|
@ -49,7 +49,7 @@ public final class WhitelistClass {
|
||||||
/**
|
/**
|
||||||
* Allow the Java class name to only be specified as the fully-qualified name.
|
* Allow the Java class name to only be specified as the fully-qualified name.
|
||||||
*/
|
*/
|
||||||
public final boolean onlyFQNJavaClassName;
|
public final boolean noImport;
|
||||||
|
|
||||||
/** The {@link List} of whitelisted ({@link WhitelistConstructor}s) available to this class. */
|
/** The {@link List} of whitelisted ({@link WhitelistConstructor}s) available to this class. */
|
||||||
public final List<WhitelistConstructor> whitelistConstructors;
|
public final List<WhitelistConstructor> whitelistConstructors;
|
||||||
|
@ -61,13 +61,14 @@ public final class WhitelistClass {
|
||||||
public final List<WhitelistField> whitelistFields;
|
public final List<WhitelistField> whitelistFields;
|
||||||
|
|
||||||
/** Standard constructor. All values must be not {@code null}. */
|
/** Standard constructor. All values must be not {@code null}. */
|
||||||
public WhitelistClass(String origin, String javaClassName, boolean onlyFQNJavaClassName,
|
public WhitelistClass(String origin, String javaClassName, boolean noImport,
|
||||||
List<WhitelistConstructor> whitelistConstructors,
|
List<WhitelistConstructor> whitelistConstructors,
|
||||||
List<WhitelistMethod> whitelistMethods,
|
List<WhitelistMethod> whitelistMethods,
|
||||||
List<WhitelistField> whitelistFields) {
|
List<WhitelistField> whitelistFields) {
|
||||||
|
|
||||||
this.origin = Objects.requireNonNull(origin);
|
this.origin = Objects.requireNonNull(origin);
|
||||||
this.javaClassName = Objects.requireNonNull(javaClassName);
|
this.javaClassName = Objects.requireNonNull(javaClassName);
|
||||||
this.onlyFQNJavaClassName = onlyFQNJavaClassName;
|
this.noImport = noImport;
|
||||||
|
|
||||||
this.whitelistConstructors = Collections.unmodifiableList(Objects.requireNonNull(whitelistConstructors));
|
this.whitelistConstructors = Collections.unmodifiableList(Objects.requireNonNull(whitelistConstructors));
|
||||||
this.whitelistMethods = Collections.unmodifiableList(Objects.requireNonNull(whitelistMethods));
|
this.whitelistMethods = Collections.unmodifiableList(Objects.requireNonNull(whitelistMethods));
|
||||||
|
|
|
@ -31,18 +31,18 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
public final class WhitelistConstructor {
|
public final class WhitelistConstructor {
|
||||||
|
|
||||||
/** Information about where this constructor was whitelisted from. Can be used for error messages. */
|
/** Information about where this constructor was whitelisted from. */
|
||||||
public final String origin;
|
public final String origin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link List} of {@link String}s that are the Painless type names for the parameters of the
|
* A {@link List} of {@link String}s that are the Painless type names for the parameters of the
|
||||||
* constructor which can be used to look up the Java constructor through reflection.
|
* constructor which can be used to look up the Java constructor through reflection.
|
||||||
*/
|
*/
|
||||||
public final List<String> painlessParameterTypeNames;
|
public final List<String> canonicalTypeNameParameters;
|
||||||
|
|
||||||
/** Standard constructor. All values must be not {@code null}. */
|
/** Standard constructor. All values must be not {@code null}. */
|
||||||
public WhitelistConstructor(String origin, List<String> painlessParameterTypeNames) {
|
public WhitelistConstructor(String origin, List<String> canonicalTypeNameParameters) {
|
||||||
this.origin = Objects.requireNonNull(origin);
|
this.origin = Objects.requireNonNull(origin);
|
||||||
this.painlessParameterTypeNames = Collections.unmodifiableList(Objects.requireNonNull(painlessParameterTypeNames));
|
this.canonicalTypeNameParameters = Collections.unmodifiableList(Objects.requireNonNull(canonicalTypeNameParameters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,19 +28,19 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
public class WhitelistField {
|
public class WhitelistField {
|
||||||
|
|
||||||
/** Information about where this method was whitelisted from. Can be used for error messages. */
|
/** Information about where this method was whitelisted from. */
|
||||||
public final String origin;
|
public final String origin;
|
||||||
|
|
||||||
/** The Java field name used to look up the Java field through reflection. */
|
/** The field name used to look up the field reflection object. */
|
||||||
public final String javaFieldName;
|
public final String fieldName;
|
||||||
|
|
||||||
/** The Painless type name for the field which can be used to look up the Java field through reflection. */
|
/** The canonical type name for the field which can be used to look up the Java field through reflection. */
|
||||||
public final String painlessFieldTypeName;
|
public final String canonicalTypeNameParameter;
|
||||||
|
|
||||||
/** Standard constructor. All values must be not {@code null}. */
|
/** Standard constructor. All values must be not {@code null}. */
|
||||||
public WhitelistField(String origin, String javaFieldName, String painlessFieldTypeName) {
|
public WhitelistField(String origin, String fieldName, String canonicalTypeNameParameter) {
|
||||||
this.origin = Objects.requireNonNull(origin);
|
this.origin = Objects.requireNonNull(origin);
|
||||||
this.javaFieldName = Objects.requireNonNull(javaFieldName);
|
this.fieldName = Objects.requireNonNull(fieldName);
|
||||||
this.painlessFieldTypeName = Objects.requireNonNull(painlessFieldTypeName);
|
this.canonicalTypeNameParameter = Objects.requireNonNull(canonicalTypeNameParameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ public final class WhitelistLoader {
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
public static Whitelist loadFromResourceFiles(Class<?> resource, String... filepaths) {
|
public static Whitelist loadFromResourceFiles(Class<?> resource, String... filepaths) {
|
||||||
List<WhitelistClass> whitelistStructs = new ArrayList<>();
|
List<WhitelistClass> whitelistClasses = new ArrayList<>();
|
||||||
|
|
||||||
// Execute a single pass through the whitelist text files. This will gather all the
|
// Execute a single pass through the whitelist text files. This will gather all the
|
||||||
// constructors, methods, augmented methods, and fields for each whitelisted class.
|
// constructors, methods, augmented methods, and fields for each whitelisted class.
|
||||||
|
@ -143,7 +143,7 @@ public final class WhitelistLoader {
|
||||||
try (LineNumberReader reader = new LineNumberReader(
|
try (LineNumberReader reader = new LineNumberReader(
|
||||||
new InputStreamReader(resource.getResourceAsStream(filepath), StandardCharsets.UTF_8))) {
|
new InputStreamReader(resource.getResourceAsStream(filepath), StandardCharsets.UTF_8))) {
|
||||||
|
|
||||||
String whitelistStructOrigin = null;
|
String whitelistClassOrigin = null;
|
||||||
String javaClassName = null;
|
String javaClassName = null;
|
||||||
boolean onlyFQNJavaClassName = false;
|
boolean onlyFQNJavaClassName = false;
|
||||||
List<WhitelistConstructor> whitelistConstructors = null;
|
List<WhitelistConstructor> whitelistConstructors = null;
|
||||||
|
@ -178,7 +178,7 @@ public final class WhitelistLoader {
|
||||||
throw new IllegalArgumentException("invalid class definition: failed to parse class name [" + line + "]");
|
throw new IllegalArgumentException("invalid class definition: failed to parse class name [" + line + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
whitelistStructOrigin = "[" + filepath + "]:[" + number + "]";
|
whitelistClassOrigin = "[" + filepath + "]:[" + number + "]";
|
||||||
javaClassName = tokens[0];
|
javaClassName = tokens[0];
|
||||||
|
|
||||||
// Reset all the constructors, methods, and fields to support a new class.
|
// Reset all the constructors, methods, and fields to support a new class.
|
||||||
|
@ -194,11 +194,11 @@ public final class WhitelistLoader {
|
||||||
throw new IllegalArgumentException("invalid class definition: extraneous closing bracket");
|
throw new IllegalArgumentException("invalid class definition: extraneous closing bracket");
|
||||||
}
|
}
|
||||||
|
|
||||||
whitelistStructs.add(new WhitelistClass(whitelistStructOrigin, javaClassName, onlyFQNJavaClassName,
|
whitelistClasses.add(new WhitelistClass(whitelistClassOrigin, javaClassName, onlyFQNJavaClassName,
|
||||||
whitelistConstructors, whitelistMethods, whitelistFields));
|
whitelistConstructors, whitelistMethods, whitelistFields));
|
||||||
|
|
||||||
// Set all the variables to null to ensure a new class definition is found before other parsable values.
|
// Set all the variables to null to ensure a new class definition is found before other parsable values.
|
||||||
whitelistStructOrigin = null;
|
whitelistClassOrigin = null;
|
||||||
javaClassName = null;
|
javaClassName = null;
|
||||||
onlyFQNJavaClassName = false;
|
onlyFQNJavaClassName = false;
|
||||||
whitelistConstructors = null;
|
whitelistConstructors = null;
|
||||||
|
@ -300,7 +300,7 @@ public final class WhitelistLoader {
|
||||||
}
|
}
|
||||||
ClassLoader loader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>)resource::getClassLoader);
|
ClassLoader loader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>)resource::getClassLoader);
|
||||||
|
|
||||||
return new Whitelist(loader, whitelistStructs);
|
return new Whitelist(loader, whitelistClasses);
|
||||||
}
|
}
|
||||||
|
|
||||||
private WhitelistLoader() {}
|
private WhitelistLoader() {}
|
||||||
|
|
|
@ -27,7 +27,8 @@ import java.util.Objects;
|
||||||
* Method represents the equivalent of a Java method available as a whitelisted class method
|
* Method represents the equivalent of a Java method available as a whitelisted class method
|
||||||
* within Painless. Methods for Painless classes may be accessed exactly as methods for Java classes
|
* within Painless. Methods for Painless classes may be accessed exactly as methods for Java classes
|
||||||
* are using the '.' operator on an existing class variable/field. Painless classes may have multiple
|
* are using the '.' operator on an existing class variable/field. Painless classes may have multiple
|
||||||
* methods with the same name as long as they comply with arity overloading described for {@link WhitelistMethod}.
|
* methods with the same name as long as they comply with arity overloading described in
|
||||||
|
* {@link WhitelistClass}.
|
||||||
*
|
*
|
||||||
* Classes may also have additional methods that are not part of the Java class the class represents -
|
* Classes may also have additional methods that are not part of the Java class the class represents -
|
||||||
* these are known as augmented methods. An augmented method can be added to a class as a part of any
|
* these are known as augmented methods. An augmented method can be added to a class as a part of any
|
||||||
|
@ -37,40 +38,40 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
public class WhitelistMethod {
|
public class WhitelistMethod {
|
||||||
|
|
||||||
/** Information about where this method was whitelisted from. Can be used for error messages. */
|
/** Information about where this method was whitelisted from. */
|
||||||
public final String origin;
|
public final String origin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Java class name for the owner of an augmented method. If the method is not augmented
|
* The class name for the owner of an augmented method. If the method is not augmented
|
||||||
* this should be {@code null}.
|
* this should be {@code null}.
|
||||||
*/
|
*/
|
||||||
public final String javaAugmentedClassName;
|
public final String augmentedCanonicalClassName;
|
||||||
|
|
||||||
/** The Java method name used to look up the Java method through reflection. */
|
/** The method name used to look up the method reflection object. */
|
||||||
public final String javaMethodName;
|
public final String methodName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Painless type name for the return type of the method which can be used to look up the Java
|
* The canonical type name for the return type.
|
||||||
* method through reflection.
|
|
||||||
*/
|
*/
|
||||||
public final String painlessReturnTypeName;
|
public final String returnCanonicalTypeName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link List} of {@link String}s that are the Painless type names for the parameters of the
|
* A {@link List} of {@link String}s that are the canonical type names for the parameters of the
|
||||||
* method which can be used to look up the Java method through reflection.
|
* method used to look up the method reflection object.
|
||||||
*/
|
*/
|
||||||
public final List<String> painlessParameterTypeNames;
|
public final List<String> canonicalTypeNameParameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor. All values must be not {@code null} with the exception of jAugmentedClass;
|
* Standard constructor. All values must be not {@code null} with the exception of
|
||||||
* jAugmentedClass will be {@code null} unless the method is augmented as described in the class documentation.
|
* augmentedCanonicalClassName; augmentedCanonicalClassName will be {@code null} unless the method
|
||||||
|
* is augmented as described in the class documentation.
|
||||||
*/
|
*/
|
||||||
public WhitelistMethod(String origin, String javaAugmentedClassName, String javaMethodName,
|
public WhitelistMethod(String origin, String augmentedCanonicalClassName, String methodName,
|
||||||
String painlessReturnTypeName, List<String> painlessParameterTypeNames) {
|
String returnCanonicalTypeName, List<String> canonicalTypeNameParameters) {
|
||||||
this.origin = Objects.requireNonNull(origin);
|
this.origin = Objects.requireNonNull(origin);
|
||||||
this.javaAugmentedClassName = javaAugmentedClassName;
|
this.augmentedCanonicalClassName = augmentedCanonicalClassName;
|
||||||
this.javaMethodName = javaMethodName;
|
this.methodName = methodName;
|
||||||
this.painlessReturnTypeName = Objects.requireNonNull(painlessReturnTypeName);
|
this.returnCanonicalTypeName = Objects.requireNonNull(returnCanonicalTypeName);
|
||||||
this.painlessParameterTypeNames = Collections.unmodifiableList(Objects.requireNonNull(painlessParameterTypeNames));
|
this.canonicalTypeNameParameters = Collections.unmodifiableList(Objects.requireNonNull(canonicalTypeNameParameters));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,10 @@ public final class PainlessLookup {
|
||||||
return canonicalClassNamesToClasses.containsKey(canonicalClassName);
|
return canonicalClassNamesToClasses.containsKey(canonicalClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<?> canonicalTypeNameToType(String painlessType) {
|
public Class<?> canonicalTypeNameToType(String canonicalTypeName) {
|
||||||
Objects.requireNonNull(painlessType);
|
Objects.requireNonNull(canonicalTypeName);
|
||||||
|
|
||||||
return PainlessLookupUtility.canonicalTypeNameToType(painlessType, canonicalClassNamesToClasses);
|
return PainlessLookupUtility.canonicalTypeNameToType(canonicalTypeName, canonicalClassNamesToClasses);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Class<?>> getClasses() {
|
public Set<Class<?>> getClasses() {
|
||||||
|
@ -64,10 +64,10 @@ public final class PainlessLookup {
|
||||||
return classesToPainlessClasses.get(targetClass);
|
return classesToPainlessClasses.get(targetClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PainlessConstructor lookupPainlessConstructor(String targetClassName, int constructorArity) {
|
public PainlessConstructor lookupPainlessConstructor(String targetCanonicalClassName, int constructorArity) {
|
||||||
Objects.requireNonNull(targetClassName);
|
Objects.requireNonNull(targetCanonicalClassName);
|
||||||
|
|
||||||
Class<?> targetClass = canonicalTypeNameToType(targetClassName);
|
Class<?> targetClass = canonicalTypeNameToType(targetCanonicalClassName);
|
||||||
|
|
||||||
if (targetClass == null) {
|
if (targetClass == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -95,10 +95,10 @@ public final class PainlessLookup {
|
||||||
return painlessConstructor;
|
return painlessConstructor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PainlessMethod lookupPainlessMethod(String targetClassName, boolean isStatic, String methodName, int methodArity) {
|
public PainlessMethod lookupPainlessMethod(String targetCanonicalClassName, boolean isStatic, String methodName, int methodArity) {
|
||||||
Objects.requireNonNull(targetClassName);
|
Objects.requireNonNull(targetCanonicalClassName);
|
||||||
|
|
||||||
Class<?> targetClass = canonicalTypeNameToType(targetClassName);
|
Class<?> targetClass = canonicalTypeNameToType(targetCanonicalClassName);
|
||||||
|
|
||||||
if (targetClass == null) {
|
if (targetClass == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -127,10 +127,10 @@ public final class PainlessLookup {
|
||||||
targetPainlessClass.methods.get(painlessMethodKey);
|
targetPainlessClass.methods.get(painlessMethodKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PainlessField lookupPainlessField(String targetClassName, boolean isStatic, String fieldName) {
|
public PainlessField lookupPainlessField(String targetCanonicalClassName, boolean isStatic, String fieldName) {
|
||||||
Objects.requireNonNull(targetClassName);
|
Objects.requireNonNull(targetCanonicalClassName);
|
||||||
|
|
||||||
Class<?> targetClass = canonicalTypeNameToType(targetClassName);
|
Class<?> targetClass = canonicalTypeNameToType(targetCanonicalClassName);
|
||||||
|
|
||||||
if (targetClass == null) {
|
if (targetClass == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -199,9 +199,7 @@ public final class PainlessLookup {
|
||||||
return lookupRuntimePainlessObject(originalTargetClass, objectLookup);
|
return lookupRuntimePainlessObject(originalTargetClass, objectLookup);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T lookupRuntimePainlessObject(
|
private <T> T lookupRuntimePainlessObject(Class<?> originalTargetClass, Function<PainlessClass, T> objectLookup) {
|
||||||
Class<?> originalTargetClass, Function<PainlessClass, T> objectLookup) {
|
|
||||||
|
|
||||||
Class<?> currentTargetClass = originalTargetClass;
|
Class<?> currentTargetClass = originalTargetClass;
|
||||||
|
|
||||||
while (currentTargetClass != null) {
|
while (currentTargetClass != null) {
|
||||||
|
|
|
@ -166,35 +166,35 @@ public final class PainlessLookupBuilder {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (Whitelist whitelist : whitelists) {
|
for (Whitelist whitelist : whitelists) {
|
||||||
for (WhitelistClass whitelistClass : whitelist.whitelistStructs) {
|
for (WhitelistClass whitelistClass : whitelist.whitelistClasses) {
|
||||||
origin = whitelistClass.origin;
|
origin = whitelistClass.origin;
|
||||||
painlessLookupBuilder.addPainlessClass(
|
painlessLookupBuilder.addPainlessClass(
|
||||||
whitelist.javaClassLoader, whitelistClass.javaClassName, whitelistClass.onlyFQNJavaClassName == false);
|
whitelist.classLoader, whitelistClass.javaClassName, whitelistClass.noImport == false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Whitelist whitelist : whitelists) {
|
for (Whitelist whitelist : whitelists) {
|
||||||
for (WhitelistClass whitelistClass : whitelist.whitelistStructs) {
|
for (WhitelistClass whitelistClass : whitelist.whitelistClasses) {
|
||||||
String targetCanonicalClassName = whitelistClass.javaClassName.replace('$', '.');
|
String targetCanonicalClassName = whitelistClass.javaClassName.replace('$', '.');
|
||||||
|
|
||||||
for (WhitelistConstructor whitelistConstructor : whitelistClass.whitelistConstructors) {
|
for (WhitelistConstructor whitelistConstructor : whitelistClass.whitelistConstructors) {
|
||||||
origin = whitelistConstructor.origin;
|
origin = whitelistConstructor.origin;
|
||||||
painlessLookupBuilder.addPainlessConstructor(
|
painlessLookupBuilder.addPainlessConstructor(
|
||||||
targetCanonicalClassName, whitelistConstructor.painlessParameterTypeNames);
|
targetCanonicalClassName, whitelistConstructor.canonicalTypeNameParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WhitelistMethod whitelistMethod : whitelistClass.whitelistMethods) {
|
for (WhitelistMethod whitelistMethod : whitelistClass.whitelistMethods) {
|
||||||
origin = whitelistMethod.origin;
|
origin = whitelistMethod.origin;
|
||||||
painlessLookupBuilder.addPainlessMethod(
|
painlessLookupBuilder.addPainlessMethod(
|
||||||
whitelist.javaClassLoader, targetCanonicalClassName, whitelistMethod.javaAugmentedClassName,
|
whitelist.classLoader, targetCanonicalClassName, whitelistMethod.augmentedCanonicalClassName,
|
||||||
whitelistMethod.javaMethodName, whitelistMethod.painlessReturnTypeName,
|
whitelistMethod.methodName, whitelistMethod.returnCanonicalTypeName,
|
||||||
whitelistMethod.painlessParameterTypeNames);
|
whitelistMethod.canonicalTypeNameParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WhitelistField whitelistField : whitelistClass.whitelistFields) {
|
for (WhitelistField whitelistField : whitelistClass.whitelistFields) {
|
||||||
origin = whitelistField.origin;
|
origin = whitelistField.origin;
|
||||||
painlessLookupBuilder.addPainlessField(
|
painlessLookupBuilder.addPainlessField(
|
||||||
targetCanonicalClassName, whitelistField.javaFieldName, whitelistField.painlessFieldTypeName);
|
targetCanonicalClassName, whitelistField.fieldName, whitelistField.canonicalTypeNameParameter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,25 +315,25 @@ public final class PainlessLookupBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPainlessConstructor(String targetCanonicalClassName, List<String> typeNameParameters) {
|
public void addPainlessConstructor(String targetCanonicalClassName, List<String> canonicalTypeNameParameters) {
|
||||||
Objects.requireNonNull(targetCanonicalClassName);
|
Objects.requireNonNull(targetCanonicalClassName);
|
||||||
Objects.requireNonNull(typeNameParameters);
|
Objects.requireNonNull(canonicalTypeNameParameters);
|
||||||
|
|
||||||
Class<?> targetClass = canonicalClassNamesToClasses.get(targetCanonicalClassName);
|
Class<?> targetClass = canonicalClassNamesToClasses.get(targetCanonicalClassName);
|
||||||
|
|
||||||
if (targetClass == null) {
|
if (targetClass == null) {
|
||||||
throw new IllegalArgumentException("target class [" + targetCanonicalClassName + "] not found" +
|
throw new IllegalArgumentException("target class [" + targetCanonicalClassName + "] not found" +
|
||||||
"for constructor [[" + targetCanonicalClassName + "], " + typeNameParameters + "]");
|
"for constructor [[" + targetCanonicalClassName + "], " + canonicalTypeNameParameters + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Class<?>> typeParameters = new ArrayList<>(typeNameParameters.size());
|
List<Class<?>> typeParameters = new ArrayList<>(canonicalTypeNameParameters.size());
|
||||||
|
|
||||||
for (String typeNameParameter : typeNameParameters) {
|
for (String canonicalTypeNameParameter : canonicalTypeNameParameters) {
|
||||||
Class<?> typeParameter = canonicalTypeNameToType(typeNameParameter);
|
Class<?> typeParameter = canonicalTypeNameToType(canonicalTypeNameParameter);
|
||||||
|
|
||||||
if (typeParameter == null) {
|
if (typeParameter == null) {
|
||||||
throw new IllegalArgumentException("type parameter [" + typeNameParameter + "] not found " +
|
throw new IllegalArgumentException("type parameter [" + canonicalTypeNameParameter + "] not found " +
|
||||||
"for constructor [[" + targetCanonicalClassName + "], " + typeNameParameters + "]");
|
"for constructor [[" + targetCanonicalClassName + "], " + canonicalTypeNameParameters + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
typeParameters.add(typeParameter);
|
typeParameters.add(typeParameter);
|
||||||
|
@ -409,19 +409,19 @@ public final class PainlessLookupBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPainlessMethod(ClassLoader classLoader, String targetCanonicalClassName, String augmentedCanonicalClassName,
|
public void addPainlessMethod(ClassLoader classLoader, String targetCanonicalClassName, String augmentedCanonicalClassName,
|
||||||
String methodName, String returnCanonicalTypeName, List<String> typeNameParameters) {
|
String methodName, String returnCanonicalTypeName, List<String> canonicalTypeNameParameters) {
|
||||||
|
|
||||||
Objects.requireNonNull(classLoader);
|
Objects.requireNonNull(classLoader);
|
||||||
Objects.requireNonNull(targetCanonicalClassName);
|
Objects.requireNonNull(targetCanonicalClassName);
|
||||||
Objects.requireNonNull(methodName);
|
Objects.requireNonNull(methodName);
|
||||||
Objects.requireNonNull(returnCanonicalTypeName);
|
Objects.requireNonNull(returnCanonicalTypeName);
|
||||||
Objects.requireNonNull(typeNameParameters);
|
Objects.requireNonNull(canonicalTypeNameParameters);
|
||||||
|
|
||||||
Class<?> targetClass = canonicalClassNamesToClasses.get(targetCanonicalClassName);
|
Class<?> targetClass = canonicalClassNamesToClasses.get(targetCanonicalClassName);
|
||||||
|
|
||||||
if (targetClass == null) {
|
if (targetClass == null) {
|
||||||
throw new IllegalArgumentException("target class [" + targetCanonicalClassName + "] not found for method " +
|
throw new IllegalArgumentException("target class [" + targetCanonicalClassName + "] not found for method " +
|
||||||
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + typeNameParameters + "]");
|
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + canonicalTypeNameParameters + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> augmentedClass = null;
|
Class<?> augmentedClass = null;
|
||||||
|
@ -431,18 +431,18 @@ public final class PainlessLookupBuilder {
|
||||||
augmentedClass = Class.forName(augmentedCanonicalClassName, true, classLoader);
|
augmentedClass = Class.forName(augmentedCanonicalClassName, true, classLoader);
|
||||||
} catch (ClassNotFoundException cnfe) {
|
} catch (ClassNotFoundException cnfe) {
|
||||||
throw new IllegalArgumentException("augmented class [" + augmentedCanonicalClassName + "] not found for method " +
|
throw new IllegalArgumentException("augmented class [" + augmentedCanonicalClassName + "] not found for method " +
|
||||||
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + typeNameParameters + "]", cnfe);
|
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + canonicalTypeNameParameters + "]", cnfe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Class<?>> typeParameters = new ArrayList<>(typeNameParameters.size());
|
List<Class<?>> typeParameters = new ArrayList<>(canonicalTypeNameParameters.size());
|
||||||
|
|
||||||
for (String typeNameParameter : typeNameParameters) {
|
for (String canonicalTypeNameParameter : canonicalTypeNameParameters) {
|
||||||
Class<?> typeParameter = canonicalTypeNameToType(typeNameParameter);
|
Class<?> typeParameter = canonicalTypeNameToType(canonicalTypeNameParameter);
|
||||||
|
|
||||||
if (typeParameter == null) {
|
if (typeParameter == null) {
|
||||||
throw new IllegalArgumentException("parameter type [" + typeNameParameter + "] not found for method " +
|
throw new IllegalArgumentException("parameter type [" + canonicalTypeNameParameter + "] not found for method " +
|
||||||
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + typeNameParameters + "]");
|
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + canonicalTypeNameParameters + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
typeParameters.add(typeParameter);
|
typeParameters.add(typeParameter);
|
||||||
|
@ -452,7 +452,7 @@ public final class PainlessLookupBuilder {
|
||||||
|
|
||||||
if (returnType == null) {
|
if (returnType == null) {
|
||||||
throw new IllegalArgumentException("parameter type [" + returnCanonicalTypeName + "] not found for method " +
|
throw new IllegalArgumentException("parameter type [" + returnCanonicalTypeName + "] not found for method " +
|
||||||
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + typeNameParameters + "]");
|
"[[" + targetCanonicalClassName + "], [" + methodName + "], " + canonicalTypeNameParameters + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
addPainlessMethod(targetClass, augmentedClass, methodName, returnType, typeParameters);
|
addPainlessMethod(targetClass, augmentedClass, methodName, returnType, typeParameters);
|
||||||
|
@ -607,10 +607,10 @@ public final class PainlessLookupBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPainlessField(String targetCanonicalClassName, String fieldName, String typeNameParameter) {
|
public void addPainlessField(String targetCanonicalClassName, String fieldName, String canonicalTypeNameParameter) {
|
||||||
Objects.requireNonNull(targetCanonicalClassName);
|
Objects.requireNonNull(targetCanonicalClassName);
|
||||||
Objects.requireNonNull(fieldName);
|
Objects.requireNonNull(fieldName);
|
||||||
Objects.requireNonNull(typeNameParameter);
|
Objects.requireNonNull(canonicalTypeNameParameter);
|
||||||
|
|
||||||
Class<?> targetClass = canonicalClassNamesToClasses.get(targetCanonicalClassName);
|
Class<?> targetClass = canonicalClassNamesToClasses.get(targetCanonicalClassName);
|
||||||
|
|
||||||
|
@ -618,10 +618,10 @@ public final class PainlessLookupBuilder {
|
||||||
throw new IllegalArgumentException("class [" + targetCanonicalClassName + "] not found");
|
throw new IllegalArgumentException("class [" + targetCanonicalClassName + "] not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> typeParameter = canonicalTypeNameToType(typeNameParameter);
|
Class<?> typeParameter = canonicalTypeNameToType(canonicalTypeNameParameter);
|
||||||
|
|
||||||
if (typeParameter == null) {
|
if (typeParameter == null) {
|
||||||
throw new IllegalArgumentException("type parameter [" + typeNameParameter + "] not found " +
|
throw new IllegalArgumentException("type parameter [" + canonicalTypeNameParameter + "] not found " +
|
||||||
"for field [[" + targetCanonicalClassName + "], [" + fieldName + "]");
|
"for field [[" + targetCanonicalClassName + "], [" + fieldName + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue