Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Painless: Rename *Binding classes to *ClassBinding. #33865

Merged
merged 1 commit into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ public final class Whitelist {
/** The {@link List} of all the whitelisted static Painless methods. */
public final List<WhitelistMethod> whitelistImportedMethods;

/** The {@link List} of all the whitelisted Painless bindings. */
public final List<WhitelistBinding> whitelistBindings;
/** The {@link List} of all the whitelisted Painless class bindings. */
public final List<WhitelistClassBinding> whitelistClassBindings;

/** Standard constructor. All values must be not {@code null}. */
public Whitelist(ClassLoader classLoader, List<WhitelistClass> whitelistClasses,
List<WhitelistMethod> whitelistImportedMethods, List<WhitelistBinding> whitelistBindings) {
List<WhitelistMethod> whitelistImportedMethods, List<WhitelistClassBinding> whitelistClassBindings) {

this.classLoader = Objects.requireNonNull(classLoader);
this.whitelistClasses = Collections.unmodifiableList(Objects.requireNonNull(whitelistClasses));
this.whitelistImportedMethods = Collections.unmodifiableList(Objects.requireNonNull(whitelistImportedMethods));
this.whitelistBindings = Collections.unmodifiableList(Objects.requireNonNull(whitelistBindings));
this.whitelistClassBindings = Collections.unmodifiableList(Objects.requireNonNull(whitelistClassBindings));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@
import java.util.Objects;

/**
* A binding represents a method call that stores state. Each binding class must have exactly one
* public constructor and one public method excluding those inherited directly from {@link Object}.
* The canonical type name parameters provided must match those of the constructor and method combined.
* The constructor for a binding class will be called when the binding method is called for the first
* time at which point state may be stored for the arguments passed into the constructor. The method
* for a binding class will be called each time the binding method is called and may use the previously
* stored state.
* A class binding represents a method call that stores state. Each class binding's Java class must
* have exactly one public constructor and one public method excluding those inherited directly
* from {@link Object}. The canonical type name parameters provided must match those of the
* constructor and method combined. The constructor for a class binding's Java class will be called
* when the binding method is called for the first time at which point state may be stored for the
* arguments passed into the constructor. The method for a binding class will be called each time
* the binding method is called and may use the previously stored state.
*/
public class WhitelistBinding {
public class WhitelistClassBinding {

/** Information about where this constructor was whitelisted from. */
public final String origin;

/** The Java class name this binding represents. */
/** The Java class name this class binding targets. */
public final String targetJavaClassName;

/** The method name for this binding. */
/** The method name for this class binding. */
public final String methodName;

/**
Expand All @@ -54,7 +54,7 @@ public class WhitelistBinding {
public final List<String> canonicalTypeNameParameters;

/** Standard constructor. All values must be not {@code null}. */
public WhitelistBinding(String origin, String targetJavaClassName,
public WhitelistClassBinding(String origin, String targetJavaClassName,
String methodName, String returnCanonicalTypeName, List<String> canonicalTypeNameParameters) {

this.origin = Objects.requireNonNull(origin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public final class WhitelistLoader {
public static Whitelist loadFromResourceFiles(Class<?> resource, String... filepaths) {
List<WhitelistClass> whitelistClasses = new ArrayList<>();
List<WhitelistMethod> whitelistStatics = new ArrayList<>();
List<WhitelistBinding> whitelistBindings = new ArrayList<>();
List<WhitelistClassBinding> whitelistClassBindings = new ArrayList<>();

// Execute a single pass through the whitelist text files. This will gather all the
// constructors, methods, augmented methods, and fields for each whitelisted class.
Expand Down Expand Up @@ -292,7 +292,7 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep
whitelistStatics.add(new WhitelistMethod(origin, targetJavaClassName,
methodName, returnCanonicalTypeName, Arrays.asList(canonicalTypeNameParameters)));
} else if ("bound_to".equals(staticImportType)) {
whitelistBindings.add(new WhitelistBinding(origin, targetJavaClassName,
whitelistClassBindings.add(new WhitelistClassBinding(origin, targetJavaClassName,
methodName, returnCanonicalTypeName, Arrays.asList(canonicalTypeNameParameters)));
} else {
throw new IllegalArgumentException("invalid static import definition: " +
Expand Down Expand Up @@ -392,7 +392,7 @@ public static Whitelist loadFromResourceFiles(Class<?> resource, String... filep

ClassLoader loader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>)resource::getClassLoader);

return new Whitelist(loader, whitelistClasses, whitelistStatics, whitelistBindings);
return new Whitelist(loader, whitelistClasses, whitelistStatics, whitelistClassBindings);
}

private WhitelistLoader() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import java.lang.reflect.Method;
import java.util.List;

public class PainlessBinding {
public class PainlessClassBinding {

public final Constructor<?> javaConstructor;
public final Method javaMethod;

public final Class<?> returnType;
public final List<Class<?>> typeParameters;

PainlessBinding(Constructor<?> javaConstructor, Method javaMethod, Class<?> returnType, List<Class<?>> typeParameters) {
PainlessClassBinding(Constructor<?> javaConstructor, Method javaMethod, Class<?> returnType, List<Class<?>> typeParameters) {
this.javaConstructor = javaConstructor;
this.javaMethod = javaMethod;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ public final class PainlessLookup {
private final Map<Class<?>, PainlessClass> classesToPainlessClasses;

private final Map<String, PainlessMethod> painlessMethodKeysToImportedPainlessMethods;
private final Map<String, PainlessBinding> painlessMethodKeysToPainlessBindings;
private final Map<String, PainlessClassBinding> painlessMethodKeysToPainlessClassBindings;

PainlessLookup(Map<String, Class<?>> canonicalClassNamesToClasses, Map<Class<?>, PainlessClass> classesToPainlessClasses,
Map<String, PainlessMethod> painlessMethodKeysToImportedPainlessMethods,
Map<String, PainlessBinding> painlessMethodKeysToPainlessBindings) {
Map<String, PainlessClassBinding> painlessMethodKeysToPainlessClassBindings) {

Objects.requireNonNull(canonicalClassNamesToClasses);
Objects.requireNonNull(classesToPainlessClasses);

Objects.requireNonNull(painlessMethodKeysToImportedPainlessMethods);
Objects.requireNonNull(painlessMethodKeysToPainlessBindings);
Objects.requireNonNull(painlessMethodKeysToPainlessClassBindings);

this.canonicalClassNamesToClasses = Collections.unmodifiableMap(canonicalClassNamesToClasses);
this.classesToPainlessClasses = Collections.unmodifiableMap(classesToPainlessClasses);

this.painlessMethodKeysToImportedPainlessMethods = Collections.unmodifiableMap(painlessMethodKeysToImportedPainlessMethods);
this.painlessMethodKeysToPainlessBindings = Collections.unmodifiableMap(painlessMethodKeysToPainlessBindings);
this.painlessMethodKeysToPainlessClassBindings = Collections.unmodifiableMap(painlessMethodKeysToPainlessClassBindings);
}

public boolean isValidCanonicalClassName(String canonicalClassName) {
Expand Down Expand Up @@ -182,12 +182,12 @@ public PainlessMethod lookupImportedPainlessMethod(String methodName, int arity)
return painlessMethodKeysToImportedPainlessMethods.get(painlessMethodKey);
}

public PainlessBinding lookupPainlessBinding(String methodName, int arity) {
public PainlessClassBinding lookupPainlessClassBinding(String methodName, int arity) {
Objects.requireNonNull(methodName);

String painlessMethodKey = buildPainlessMethodKey(methodName, arity);

return painlessMethodKeysToPainlessBindings.get(painlessMethodKey);
return painlessMethodKeysToPainlessClassBindings.get(painlessMethodKey);
}

public PainlessMethod lookupFunctionalInterfacePainlessMethod(Class<?> targetClass) {
Expand Down
Loading