8044638: Tidy up Nashorn codebase for code standards

Reviewed-by: lagergren, sundar
This commit is contained in:
Attila Szegedi 2014-06-04 13:08:57 +02:00
parent 7898fee89e
commit 5ec014a881
1177 changed files with 6791 additions and 6826 deletions

View File

@ -31,29 +31,29 @@ import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKEVIRTUAL;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ACCESSORPROPERTY_CREATE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ACCESSORPROPERTY_CREATE_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ACCESSORPROPERTY_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ARRAYLIST_INIT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ARRAYLIST_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.CLINIT;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTIONS_EMPTY_LIST;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTIONS_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTION_ADD;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTION_ADD_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTION_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.DEFAULT_INIT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.GETTER_PREFIX;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.GET_CLASS_NAME;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.GET_CLASS_NAME_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.INIT;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ACCESSORPROPERTY_CREATE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ACCESSORPROPERTY_CREATE_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ACCESSORPROPERTY_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.LIST_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ARRAYLIST_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.ARRAYLIST_INIT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTION_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTION_ADD;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTION_ADD_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTIONS_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.COLLECTIONS_EMPTY_LIST;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_FIELD_NAME;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_NEWMAP;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_NEWMAP_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_MAKEFUNCTION;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_MAKEFUNCTION_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTFUNCTIONIMPL_MAKEFUNCTION_SPECS_DESC;

View File

@ -32,9 +32,9 @@ import static jdk.internal.org.objectweb.asm.Opcodes.V1_7;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.CONSTRUCTOR_SUFFIX;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.DEFAULT_INIT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.INIT;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_FIELD_NAME;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROTOTYPEOBJECT_SETCONSTRUCTOR;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROTOTYPEOBJECT_TYPE;

View File

@ -31,9 +31,9 @@ import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
import static jdk.internal.org.objectweb.asm.Opcodes.V1_7;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.DEFAULT_INIT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.INIT;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROPERTYMAP_FIELD_NAME;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.OBJECT_DESC;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROTOTYPEOBJECT_TYPE;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.PROTOTYPE_SUFFIX;
import static jdk.nashorn.internal.tools.nasgen.StringConstants.SCRIPTOBJECT_INIT_DESC;

View File

@ -26,8 +26,8 @@
package jdk.nashorn.internal.tools.nasgen;
import java.lang.invoke.MethodHandle;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import jdk.internal.org.objectweb.asm.Type;

View File

@ -88,7 +88,6 @@ import java.lang.invoke.MethodHandles;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicReference;
import jdk.internal.dynalink.linker.GuardedInvocation;
import jdk.internal.dynalink.support.AbstractRelinkableCallSite;
import jdk.internal.dynalink.support.Lookup;
@ -132,7 +131,7 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
* Creates a new chained call site.
* @param descriptor the descriptor for the call site.
*/
public ChainedCallSite(CallSiteDescriptor descriptor) {
public ChainedCallSite(final CallSiteDescriptor descriptor) {
super(descriptor);
}
@ -146,16 +145,16 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
}
@Override
public void relink(GuardedInvocation guardedInvocation, MethodHandle fallback) {
public void relink(final GuardedInvocation guardedInvocation, final MethodHandle fallback) {
relinkInternal(guardedInvocation, fallback, false, false);
}
@Override
public void resetAndRelink(GuardedInvocation guardedInvocation, MethodHandle fallback) {
public void resetAndRelink(final GuardedInvocation guardedInvocation, final MethodHandle fallback) {
relinkInternal(guardedInvocation, fallback, true, false);
}
private MethodHandle relinkInternal(GuardedInvocation invocation, MethodHandle relink, boolean reset, boolean removeCatches) {
private MethodHandle relinkInternal(final GuardedInvocation invocation, final MethodHandle relink, final boolean reset, final boolean removeCatches) {
final LinkedList<GuardedInvocation> currentInvocations = invocations.get();
@SuppressWarnings({ "unchecked", "rawtypes" })
final LinkedList<GuardedInvocation> newInvocations =
@ -163,7 +162,7 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
// First, prune the chain of invalidated switchpoints, we always do this
// We also remove any catches if the remove catches flag is set
for(Iterator<GuardedInvocation> it = newInvocations.iterator(); it.hasNext();) {
for(final Iterator<GuardedInvocation> it = newInvocations.iterator(); it.hasNext();) {
final GuardedInvocation inv = it.next();
if(inv.hasBeenInvalidated() || (removeCatches && inv.getException() != null)) {
it.remove();
@ -187,7 +186,7 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
// Fold the new chain
MethodHandle target = relink;
for(GuardedInvocation inv: newInvocations) {
for(final GuardedInvocation inv: newInvocations) {
target = inv.compose(target, pruneAndInvokeSwitchPoints, pruneAndInvokeCatches);
}
@ -222,7 +221,7 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
* @param relink the ultimate fallback for the chain (the {@code DynamicLinker}'s relink).
* @return a method handle for prune-and-invoke
*/
private MethodHandle makePruneAndInvokeMethod(MethodHandle relink, MethodHandle prune) {
private MethodHandle makePruneAndInvokeMethod(final MethodHandle relink, final MethodHandle prune) {
// Bind prune to (this, relink)
final MethodHandle boundPrune = MethodHandles.insertArguments(prune, 0, this, relink);
// Make it ignore all incoming arguments
@ -232,7 +231,7 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
}
@SuppressWarnings("unused")
private MethodHandle prune(MethodHandle relink, final boolean catches) {
private MethodHandle prune(final MethodHandle relink, final boolean catches) {
return relinkInternal(null, relink, false, catches);
}
}

View File

@ -117,7 +117,7 @@ public class DefaultBootstrapper {
* @param type the method signature at the call site
* @return a new {@link MonomorphicCallSite} linked with the default dynamic linker.
*/
public static CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType type) {
public static CallSite bootstrap(final MethodHandles.Lookup caller, final String name, final MethodType type) {
return bootstrapInternal(caller, name, type);
}
@ -133,11 +133,11 @@ public class DefaultBootstrapper {
* @param type the method signature at the call site
* @return a new {@link MonomorphicCallSite} linked with the default dynamic linker.
*/
public static CallSite publicBootstrap(MethodHandles.Lookup caller, String name, MethodType type) {
public static CallSite publicBootstrap(final MethodHandles.Lookup caller, final String name, final MethodType type) {
return bootstrapInternal(MethodHandles.publicLookup(), name, type);
}
private static CallSite bootstrapInternal(MethodHandles.Lookup caller, String name, MethodType type) {
private static CallSite bootstrapInternal(final MethodHandles.Lookup caller, final String name, final MethodType type) {
return dynamicLinker.link(new MonomorphicCallSite(CallSiteDescriptorFactory.create(caller, name, type)));
}
}

View File

@ -159,8 +159,8 @@ public class DynamicLinker {
* @param prelinkFilter see {@link DynamicLinkerFactory#setPrelinkFilter(GuardedInvocationFilter)}
* @param runtimeContextArgCount see {@link DynamicLinkerFactory#setRuntimeContextArgCount(int)}
*/
DynamicLinker(LinkerServices linkerServices, GuardedInvocationFilter prelinkFilter, int runtimeContextArgCount,
boolean syncOnRelink, int unstableRelinkThreshold) {
DynamicLinker(final LinkerServices linkerServices, final GuardedInvocationFilter prelinkFilter, final int runtimeContextArgCount,
final boolean syncOnRelink, final int unstableRelinkThreshold) {
if(runtimeContextArgCount < 0) {
throw new IllegalArgumentException("runtimeContextArgCount < 0");
}
@ -201,7 +201,7 @@ public class DynamicLinker {
private static final MethodHandle RELINK = Lookup.findOwnSpecial(MethodHandles.lookup(), RELINK_METHOD_NAME,
MethodHandle.class, RelinkableCallSite.class, int.class, Object[].class);
private MethodHandle createRelinkAndInvokeMethod(final RelinkableCallSite callSite, int relinkCount) {
private MethodHandle createRelinkAndInvokeMethod(final RelinkableCallSite callSite, final int relinkCount) {
// Make a bound MH of invoke() for this linker and call site
final MethodHandle boundRelinker = MethodHandles.insertArguments(RELINK, 0, this, callSite, Integer.valueOf(
relinkCount));
@ -221,7 +221,7 @@ public class DynamicLinker {
* @throws Exception rethrows any exception thrown by the linkers
*/
@SuppressWarnings("unused")
private MethodHandle relink(RelinkableCallSite callSite, int relinkCount, Object... arguments) throws Exception {
private MethodHandle relink(final RelinkableCallSite callSite, final int relinkCount, final Object... arguments) throws Exception {
final CallSiteDescriptor callSiteDescriptor = callSite.getDescriptor();
final boolean unstableDetectionEnabled = unstableRelinkThreshold > 0;
final boolean callSiteUnstable = unstableDetectionEnabled && relinkCount >= unstableRelinkThreshold;

View File

@ -137,7 +137,7 @@ public class DynamicLinkerFactory {
*
* @param classLoader the class loader used for the autodiscovery of available linkers.
*/
public void setClassLoader(ClassLoader classLoader) {
public void setClassLoader(final ClassLoader classLoader) {
this.classLoader = classLoader;
classLoaderExplicitlySet = true;
}
@ -151,7 +151,7 @@ public class DynamicLinkerFactory {
* @param prioritizedLinkers the list of prioritized linkers. Null can be passed to indicate no prioritized linkers
* (this is also the default value).
*/
public void setPrioritizedLinkers(List<? extends GuardingDynamicLinker> prioritizedLinkers) {
public void setPrioritizedLinkers(final List<? extends GuardingDynamicLinker> prioritizedLinkers) {
this.prioritizedLinkers =
prioritizedLinkers == null ? null : new ArrayList<>(prioritizedLinkers);
}
@ -164,7 +164,7 @@ public class DynamicLinkerFactory {
*
* @param prioritizedLinkers a list of prioritized linkers.
*/
public void setPrioritizedLinkers(GuardingDynamicLinker... prioritizedLinkers) {
public void setPrioritizedLinkers(final GuardingDynamicLinker... prioritizedLinkers) {
setPrioritizedLinkers(Arrays.asList(prioritizedLinkers));
}
@ -175,7 +175,7 @@ public class DynamicLinkerFactory {
* @param prioritizedLinker the single prioritized linker. Must not be null.
* @throws IllegalArgumentException if null is passed.
*/
public void setPrioritizedLinker(GuardingDynamicLinker prioritizedLinker) {
public void setPrioritizedLinker(final GuardingDynamicLinker prioritizedLinker) {
if(prioritizedLinker == null) {
throw new IllegalArgumentException("prioritizedLinker == null");
}
@ -190,7 +190,7 @@ public class DynamicLinkerFactory {
* @param fallbackLinkers the list of fallback linkers. Can be empty to indicate the caller wishes to set no
* fallback linkers.
*/
public void setFallbackLinkers(List<? extends GuardingDynamicLinker> fallbackLinkers) {
public void setFallbackLinkers(final List<? extends GuardingDynamicLinker> fallbackLinkers) {
this.fallbackLinkers = fallbackLinkers == null ? null : new ArrayList<>(fallbackLinkers);
}
@ -202,7 +202,7 @@ public class DynamicLinkerFactory {
* @param fallbackLinkers the list of fallback linkers. Can be empty to indicate the caller wishes to set no
* fallback linkers. If it is left as null, the standard fallback {@link BeansLinker} will be used.
*/
public void setFallbackLinkers(GuardingDynamicLinker... fallbackLinkers) {
public void setFallbackLinkers(final GuardingDynamicLinker... fallbackLinkers) {
setFallbackLinkers(Arrays.asList(fallbackLinkers));
}
@ -216,7 +216,7 @@ public class DynamicLinkerFactory {
*
* @param runtimeContextArgCount the number of language runtime context arguments in call sites.
*/
public void setRuntimeContextArgCount(int runtimeContextArgCount) {
public void setRuntimeContextArgCount(final int runtimeContextArgCount) {
if(runtimeContextArgCount < 0) {
throw new IllegalArgumentException("runtimeContextArgCount < 0");
}
@ -229,7 +229,7 @@ public class DynamicLinkerFactory {
* multithreaded execution of dynamically linked code.
* @param syncOnRelink true for invoking sync on relink, false otherwise.
*/
public void setSyncOnRelink(boolean syncOnRelink) {
public void setSyncOnRelink(final boolean syncOnRelink) {
this.syncOnRelink = syncOnRelink;
}
@ -240,7 +240,7 @@ public class DynamicLinkerFactory {
* call sites will never be considered unstable.
* @see LinkRequest#isCallSiteUnstable()
*/
public void setUnstableRelinkThreshold(int unstableRelinkThreshold) {
public void setUnstableRelinkThreshold(final int unstableRelinkThreshold) {
if(unstableRelinkThreshold < 0) {
throw new IllegalArgumentException("unstableRelinkThreshold < 0");
}
@ -254,7 +254,7 @@ public class DynamicLinkerFactory {
* When not set explicitly, {@link DefaultPrelinkFilter} will be used.
* @param prelinkFilter the pre-link filter for the dynamic linker.
*/
public void setPrelinkFilter(GuardedInvocationFilter prelinkFilter) {
public void setPrelinkFilter(final GuardedInvocationFilter prelinkFilter) {
this.prelinkFilter = prelinkFilter;
}
@ -289,7 +289,7 @@ public class DynamicLinkerFactory {
// ... prioritized linkers, ...
linkers.addAll(prioritizedLinkers);
// ... filtered discovered linkers, ...
for(GuardingDynamicLinker linker: discovered) {
for(final GuardingDynamicLinker linker: discovered) {
if(!knownLinkerClasses.contains(linker.getClass())) {
linkers.add(linker);
}
@ -314,7 +314,7 @@ public class DynamicLinkerFactory {
}
final List<GuardingTypeConverterFactory> typeConverters = new LinkedList<>();
for(GuardingDynamicLinker linker: linkers) {
for(final GuardingDynamicLinker linker: linkers) {
if(linker instanceof GuardingTypeConverterFactory) {
typeConverters.add((GuardingTypeConverterFactory)linker);
}
@ -337,9 +337,9 @@ public class DynamicLinkerFactory {
}, ClassLoaderGetterContextProvider.GET_CLASS_LOADER_CONTEXT);
}
private static void addClasses(Set<Class<? extends GuardingDynamicLinker>> knownLinkerClasses,
List<? extends GuardingDynamicLinker> linkers) {
for(GuardingDynamicLinker linker: linkers) {
private static void addClasses(final Set<Class<? extends GuardingDynamicLinker>> knownLinkerClasses,
final List<? extends GuardingDynamicLinker> linkers) {
for(final GuardingDynamicLinker linker: linkers) {
knownLinkerClasses.add(linker.getClass());
}
}

View File

@ -99,17 +99,17 @@ public class MonomorphicCallSite extends AbstractRelinkableCallSite {
* Creates a new call site with monomorphic inline caching strategy.
* @param descriptor the descriptor for this call site
*/
public MonomorphicCallSite(CallSiteDescriptor descriptor) {
public MonomorphicCallSite(final CallSiteDescriptor descriptor) {
super(descriptor);
}
@Override
public void relink(GuardedInvocation guardedInvocation, MethodHandle relink) {
public void relink(final GuardedInvocation guardedInvocation, final MethodHandle relink) {
setTarget(guardedInvocation.compose(relink));
}
@Override
public void resetAndRelink(GuardedInvocation guardedInvocation, MethodHandle relink) {
public void resetAndRelink(final GuardedInvocation guardedInvocation, final MethodHandle relink) {
relink(guardedInvocation, relink);
}
}

View File

@ -97,7 +97,7 @@ public class NoSuchDynamicMethodException extends RuntimeException {
* Creates a new NoSuchDynamicMethodException
* @param message the message of the exception.
*/
public NoSuchDynamicMethodException(String message) {
public NoSuchDynamicMethodException(final String message) {
super(message);
}
}

View File

@ -123,18 +123,18 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
private final Map<String, DynamicMethod> propertySetters = new HashMap<>();
private final Map<String, DynamicMethod> methods = new HashMap<>();
AbstractJavaLinker(Class<?> clazz, MethodHandle classGuard) {
AbstractJavaLinker(final Class<?> clazz, final MethodHandle classGuard) {
this(clazz, classGuard, classGuard);
}
AbstractJavaLinker(Class<?> clazz, MethodHandle classGuard, MethodHandle assignableGuard) {
AbstractJavaLinker(final Class<?> clazz, final MethodHandle classGuard, final MethodHandle assignableGuard) {
this.clazz = clazz;
this.classGuard = classGuard;
this.assignableGuard = assignableGuard;
final FacetIntrospector introspector = createFacetIntrospector();
// Add methods and properties
for(Method method: introspector.getMethods()) {
for(final Method method: introspector.getMethods()) {
final String name = method.getName();
// Add method
addMember(name, method, methods);
@ -153,7 +153,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
}
// Add field getter/setters as property getters/setters.
for(Field field: introspector.getFields()) {
for(final Field field: introspector.getFields()) {
final String name = field.getName();
// Only add a property getter when one is not defined already as a getXxx()/isXxx() method.
if(!propertyGetters.containsKey(name)) {
@ -166,7 +166,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
}
// Add inner classes, but only those for which we don't hide a property with it
for(Map.Entry<String, MethodHandle> innerClassSpec: introspector.getInnerClassGetters().entrySet()) {
for(final Map.Entry<String, MethodHandle> innerClassSpec: introspector.getInnerClassGetters().entrySet()) {
final String name = innerClassSpec.getKey();
if(!propertyGetters.containsKey(name)) {
setPropertyGetter(name, innerClassSpec.getValue(), ValidationType.EXACT_CLASS);
@ -174,7 +174,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
}
}
private static String decapitalize(String str) {
private static String decapitalize(final String str) {
assert str != null;
if(str.isEmpty()) {
return str;
@ -209,7 +209,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
return getUnmodifiableKeys(methods);
}
private static Collection<String> getUnmodifiableKeys(Map<String, ?> m) {
private static Collection<String> getUnmodifiableKeys(final Map<String, ?> m) {
return Collections.unmodifiableCollection(m.keySet());
}
@ -222,7 +222,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @param handle the method handle that implements the property getter
* @param validationType the validation type for the property
*/
private void setPropertyGetter(String name, SingleDynamicMethod handle, ValidationType validationType) {
private void setPropertyGetter(final String name, final SingleDynamicMethod handle, final ValidationType validationType) {
propertyGetters.put(name, new AnnotatedDynamicMethod(handle, validationType));
}
@ -232,7 +232,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @param prefixLen the getter prefix in the method name; should be 3 for getter names starting with "get" and 2 for
* names starting with "is".
*/
private void setPropertyGetter(Method getter, int prefixLen) {
private void setPropertyGetter(final Method getter, final int prefixLen) {
setPropertyGetter(decapitalize(getter.getName().substring(prefixLen)), createDynamicMethod(
getMostGenericGetter(getter)), ValidationType.INSTANCE_OF);
}
@ -246,15 +246,15 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @param handle the method handle that implements the property getter
* @param validationType the validation type for the property
*/
void setPropertyGetter(String name, MethodHandle handle, ValidationType validationType) {
void setPropertyGetter(final String name, final MethodHandle handle, final ValidationType validationType) {
setPropertyGetter(name, new SimpleDynamicMethod(handle, clazz, name), validationType);
}
private void addMember(String name, AccessibleObject ao, Map<String, DynamicMethod> methodMap) {
private void addMember(final String name, final AccessibleObject ao, final Map<String, DynamicMethod> methodMap) {
addMember(name, createDynamicMethod(ao), methodMap);
}
private void addMember(String name, SingleDynamicMethod method, Map<String, DynamicMethod> methodMap) {
private void addMember(final String name, final SingleDynamicMethod method, final Map<String, DynamicMethod> methodMap) {
final DynamicMethod existingMethod = methodMap.get(name);
final DynamicMethod newMethod = mergeMethods(method, existingMethod, clazz, name);
if(newMethod != existingMethod) {
@ -270,9 +270,9 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @param name the common name of the reflective members.
* @return a dynamic method representing all the specified reflective members.
*/
static DynamicMethod createDynamicMethod(Iterable<? extends AccessibleObject> members, Class<?> clazz, String name) {
static DynamicMethod createDynamicMethod(final Iterable<? extends AccessibleObject> members, final Class<?> clazz, final String name) {
DynamicMethod dynMethod = null;
for(AccessibleObject method: members) {
for(final AccessibleObject method: members) {
dynMethod = mergeMethods(createDynamicMethod(method), dynMethod, clazz, name);
}
return dynMethod;
@ -285,7 +285,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @param m the reflective member
* @return the single dynamic method representing the reflective member
*/
private static SingleDynamicMethod createDynamicMethod(AccessibleObject m) {
private static SingleDynamicMethod createDynamicMethod(final AccessibleObject m) {
if(CallerSensitiveDetector.isCallerSensitive(m)) {
return new CallerSensitiveDynamicMethod(m);
}
@ -301,7 +301,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @param m the method or constructor
* @return the method handle
*/
private static MethodHandle unreflectSafely(AccessibleObject m) {
private static MethodHandle unreflectSafely(final AccessibleObject m) {
if(m instanceof Method) {
final Method reflMethod = (Method)m;
final MethodHandle handle = Lookup.PUBLIC.unreflect(reflMethod);
@ -313,7 +313,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
return StaticClassIntrospector.editConstructorMethodHandle(Lookup.PUBLIC.unreflectConstructor((Constructor<?>)m));
}
private static DynamicMethod mergeMethods(SingleDynamicMethod method, DynamicMethod existing, Class<?> clazz, String name) {
private static DynamicMethod mergeMethods(final SingleDynamicMethod method, final DynamicMethod existing, final Class<?> clazz, final String name) {
if(existing == null) {
return method;
} else if(existing.contains(method)) {
@ -331,7 +331,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, final LinkerServices linkerServices)
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
throws Exception {
final LinkRequest ncrequest = request.withoutRuntimeContext();
// BeansLinker already checked that the name is at least 2 elements long and the first element is "dyn".
@ -353,8 +353,8 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
return null;
}
protected GuardedInvocationComponent getGuardedInvocationComponent(CallSiteDescriptor callSiteDescriptor,
LinkerServices linkerServices, List<String> operations) throws Exception {
protected GuardedInvocationComponent getGuardedInvocationComponent(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final List<String> operations) throws Exception {
if(operations.isEmpty()) {
return null;
}
@ -374,27 +374,27 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
return null;
}
static final <T> List<T> pop(List<T> l) {
static final <T> List<T> pop(final List<T> l) {
return l.subList(1, l.size());
}
MethodHandle getClassGuard(CallSiteDescriptor desc) {
MethodHandle getClassGuard(final CallSiteDescriptor desc) {
return getClassGuard(desc.getMethodType());
}
MethodHandle getClassGuard(MethodType type) {
MethodHandle getClassGuard(final MethodType type) {
return Guards.asType(classGuard, type);
}
GuardedInvocationComponent getClassGuardedInvocationComponent(MethodHandle invocation, MethodType type) {
GuardedInvocationComponent getClassGuardedInvocationComponent(final MethodHandle invocation, final MethodType type) {
return new GuardedInvocationComponent(invocation, getClassGuard(type), clazz, ValidationType.EXACT_CLASS);
}
private MethodHandle getAssignableGuard(MethodType type) {
private MethodHandle getAssignableGuard(final MethodType type) {
return Guards.asType(assignableGuard, type);
}
private GuardedInvocation getCallPropWithThis(CallSiteDescriptor callSiteDescriptor, LinkerServices linkerServices) {
private GuardedInvocation getCallPropWithThis(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) {
switch(callSiteDescriptor.getNameTokenCount()) {
case 3: {
return createGuardedDynamicMethodInvocation(callSiteDescriptor, linkerServices,
@ -406,25 +406,25 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
}
}
private GuardedInvocation createGuardedDynamicMethodInvocation(CallSiteDescriptor callSiteDescriptor,
LinkerServices linkerServices, String methodName, Map<String, DynamicMethod> methodMap){
private GuardedInvocation createGuardedDynamicMethodInvocation(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final String methodName, final Map<String, DynamicMethod> methodMap){
final MethodHandle inv = getDynamicMethodInvocation(callSiteDescriptor, linkerServices, methodName, methodMap);
return inv == null ? null : new GuardedInvocation(inv, getClassGuard(callSiteDescriptor.getMethodType()));
}
private static MethodHandle getDynamicMethodInvocation(CallSiteDescriptor callSiteDescriptor,
LinkerServices linkerServices, String methodName, Map<String, DynamicMethod> methodMap) {
private static MethodHandle getDynamicMethodInvocation(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final String methodName, final Map<String, DynamicMethod> methodMap) {
final DynamicMethod dynaMethod = getDynamicMethod(methodName, methodMap);
return dynaMethod != null ? dynaMethod.getInvocation(callSiteDescriptor, linkerServices) : null;
}
private static DynamicMethod getDynamicMethod(String methodName, Map<String, DynamicMethod> methodMap) {
private static DynamicMethod getDynamicMethod(final String methodName, final Map<String, DynamicMethod> methodMap) {
final DynamicMethod dynaMethod = methodMap.get(methodName);
return dynaMethod != null ? dynaMethod : getExplicitSignatureDynamicMethod(methodName, methodMap);
}
private static SingleDynamicMethod getExplicitSignatureDynamicMethod(String methodName,
Map<String, DynamicMethod> methodsMap) {
private static SingleDynamicMethod getExplicitSignatureDynamicMethod(final String methodName,
final Map<String, DynamicMethod> methodsMap) {
// What's below is meant to support the "name(type, type, ...)" syntax that programmers can use in a method name
// to manually pin down an exact overloaded variant. This is not usually required, as the overloaded method
// resolution works correctly in almost every situation. However, in presence of many language-specific
@ -457,8 +457,8 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
private static final MethodHandle CONSTANT_NULL_DROP_METHOD_HANDLE = MethodHandles.dropArguments(
MethodHandles.constant(Object.class, null), 0, MethodHandle.class);
private GuardedInvocationComponent getPropertySetter(CallSiteDescriptor callSiteDescriptor,
LinkerServices linkerServices, List<String> operations) throws Exception {
private GuardedInvocationComponent getPropertySetter(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final List<String> operations) throws Exception {
switch(callSiteDescriptor.getNameTokenCount()) {
case 2: {
// Must have three arguments: target object, property name, and property value.
@ -547,8 +547,8 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
"getTarget", MethodType.methodType(MethodHandle.class, MethodHandles.Lookup.class));
private static final MethodHandle GETTER_INVOKER = MethodHandles.invoker(MethodType.methodType(Object.class, Object.class));
private GuardedInvocationComponent getPropertyGetter(CallSiteDescriptor callSiteDescriptor,
LinkerServices linkerServices, List<String> ops) throws Exception {
private GuardedInvocationComponent getPropertyGetter(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final List<String> ops) throws Exception {
switch(callSiteDescriptor.getNameTokenCount()) {
case 2: {
// Since we can't know what kind of a getter we'll get back on different invocations, we'll just
@ -631,7 +631,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
}
}
private MethodHandle getGuard(ValidationType validationType, MethodType methodType) {
private MethodHandle getGuard(final ValidationType validationType, final MethodType methodType) {
switch(validationType) {
case EXACT_CLASS: {
return getClassGuard(methodType);
@ -655,8 +655,8 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
MethodType.methodType(boolean.class, Object.class));
private static final MethodHandle OBJECT_IDENTITY = MethodHandles.identity(Object.class);
private GuardedInvocationComponent getMethodGetter(CallSiteDescriptor callSiteDescriptor,
LinkerServices linkerServices, List<String> ops) throws Exception {
private GuardedInvocationComponent getMethodGetter(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final List<String> ops) throws Exception {
// The created method handle will always return a DynamicMethod (or null), but since we don't want that type to
// be visible outside of this linker, declare it to return Object.
final MethodType type = callSiteDescriptor.getMethodType().changeReturnType(Object.class);
@ -730,7 +730,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
}
}
static MethodPair matchReturnTypes(MethodHandle m1, MethodHandle m2) {
static MethodPair matchReturnTypes(final MethodHandle m1, final MethodHandle m2) {
final MethodType type1 = m1.type();
final MethodType type2 = m2.type();
final Class<?> commonRetType = TypeUtilities.getCommonLosslessConversionType(type1.returnType(),
@ -740,7 +740,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
m2.asType(type2.changeReturnType(commonRetType)));
}
private static void assertParameterCount(CallSiteDescriptor descriptor, int paramCount) {
private static void assertParameterCount(final CallSiteDescriptor descriptor, final int paramCount) {
if(descriptor.getMethodType().parameterCount() != paramCount) {
throw new BootstrapMethodError(descriptor.getName() + " must have exactly " + paramCount + " parameters.");
}
@ -755,7 +755,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @return the method handle for retrieving the property, or null if the property does not exist
*/
@SuppressWarnings("unused")
private Object getPropertyGetterHandle(Object id) {
private Object getPropertyGetterHandle(final Object id) {
return propertyGetters.get(id);
}
@ -769,8 +769,8 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
private final MethodHandle getPropertySetterHandle = GET_PROPERTY_SETTER_HANDLE.bindTo(this);
@SuppressWarnings("unused")
private MethodHandle getPropertySetterHandle(CallSiteDescriptor setterDescriptor, LinkerServices linkerServices,
Object id) {
private MethodHandle getPropertySetterHandle(final CallSiteDescriptor setterDescriptor, final LinkerServices linkerServices,
final Object id) {
return getDynamicMethodInvocation(setterDescriptor, linkerServices, String.valueOf(id), propertySetters);
}
@ -782,7 +782,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
// This method is marked to return Object instead of DynamicMethod as it's used as a linking component and we don't
// want to make the DynamicMethod type observable externally (e.g. as the return type of a MethodHandle returned for
// "dyn:getMethod" linking).
private Object getDynamicMethod(Object name) {
private Object getDynamicMethod(final Object name) {
return getDynamicMethod(String.valueOf(name), methods);
}
@ -793,7 +793,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @return the dynamic method (either {@link SimpleDynamicMethod} or {@link OverloadedDynamicMethod}, or null if the
* method with the specified name does not exist.
*/
DynamicMethod getDynamicMethod(String name) {
DynamicMethod getDynamicMethod(final String name) {
return getDynamicMethod(name, methods);
}
@ -804,16 +804,16 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
* @param getter the getter
* @return getter with same name, declared on the most generic superclass/interface of the declaring class
*/
private static Method getMostGenericGetter(Method getter) {
private static Method getMostGenericGetter(final Method getter) {
return getMostGenericGetter(getter.getName(), getter.getReturnType(), getter.getDeclaringClass());
}
private static Method getMostGenericGetter(String name, Class<?> returnType, Class<?> declaringClass) {
private static Method getMostGenericGetter(final String name, final Class<?> returnType, final Class<?> declaringClass) {
if(declaringClass == null) {
return null;
}
// Prefer interfaces
for(Class<?> itf: declaringClass.getInterfaces()) {
for(final Class<?> itf: declaringClass.getInterfaces()) {
final Method itfGetter = getMostGenericGetter(name, returnType, itf);
if(itfGetter != null) {
return itfGetter;
@ -826,7 +826,7 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
if(!CheckRestrictedPackage.isRestrictedClass(declaringClass)) {
try {
return declaringClass.getMethod(name);
} catch(NoSuchMethodException e) {
} catch(final NoSuchMethodException e) {
// Intentionally ignored, meant to fall through
}
}
@ -837,18 +837,18 @@ abstract class AbstractJavaLinker implements GuardingDynamicLinker {
private final SingleDynamicMethod method;
/*private*/ final ValidationType validationType;
AnnotatedDynamicMethod(SingleDynamicMethod method, ValidationType validationType) {
AnnotatedDynamicMethod(final SingleDynamicMethod method, final ValidationType validationType) {
this.method = method;
this.validationType = validationType;
}
MethodHandle getInvocation(CallSiteDescriptor callSiteDescriptor, LinkerServices linkerServices) {
MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) {
return method.getInvocation(callSiteDescriptor, linkerServices);
}
@SuppressWarnings("unused")
MethodHandle getTarget(MethodHandles.Lookup lookup) {
MethodHandle inv = method.getTarget(lookup);
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
final MethodHandle inv = method.getTarget(lookup);
assert inv != null;
return inv;
}

View File

@ -104,7 +104,7 @@ import java.util.Set;
class AccessibleMembersLookup {
private final Map<MethodSignature, Method> methods;
private final Set<Class<?>> innerClasses;
private boolean instance;
private final boolean instance;
/**
* Creates a mapping for all accessible methods and inner classes on a class.
@ -112,7 +112,7 @@ class AccessibleMembersLookup {
* @param clazz the inspected class
* @param instance true to inspect instance methods, false to inspect static methods.
*/
AccessibleMembersLookup(final Class<?> clazz, boolean instance) {
AccessibleMembersLookup(final Class<?> clazz, final boolean instance) {
this.methods = new HashMap<>();
this.innerClasses = new LinkedHashSet<>();
this.instance = instance;
@ -153,7 +153,7 @@ class AccessibleMembersLookup {
* @param name the name of the method this signature represents.
* @param args the argument types of the method.
*/
MethodSignature(String name, Class<?>[] args) {
MethodSignature(final String name, final Class<?>[] args) {
this.name = name;
this.args = args;
}
@ -210,7 +210,7 @@ class AccessibleMembersLookup {
if(!CheckRestrictedPackage.isRestrictedClass(clazz)) {
searchSuperTypes = false;
for(Method method: clazz.getMethods()) {
for(final Method method: clazz.getMethods()) {
final boolean isStatic = Modifier.isStatic(method.getModifiers());
if(instance != isStatic) {
final MethodSignature sig = new MethodSignature(method);
@ -237,7 +237,7 @@ class AccessibleMembersLookup {
}
}
}
for(Class<?> innerClass: clazz.getClasses()) {
for(final Class<?> innerClass: clazz.getClasses()) {
// Add both static and non-static classes, regardless of instance flag. StaticClassLinker will just
// expose non-static classes with explicit constructor outer class argument.
// NOTE: getting inner class objects through getClasses() does not resolve them, so if those classes

View File

@ -108,7 +108,7 @@ class ApplicableOverloadedMethods {
ApplicableOverloadedMethods(final List<SingleDynamicMethod> methods, final MethodType callSiteType,
final ApplicabilityTest test) {
this.methods = new LinkedList<>();
for(SingleDynamicMethod m: methods) {
for(final SingleDynamicMethod m: methods) {
if(test.isApplicable(callSiteType, m)) {
this.methods.add(m);
}
@ -143,7 +143,7 @@ class ApplicableOverloadedMethods {
*/
static final ApplicabilityTest APPLICABLE_BY_SUBTYPING = new ApplicabilityTest() {
@Override
boolean isApplicable(MethodType callSiteType, SingleDynamicMethod method) {
boolean isApplicable(final MethodType callSiteType, final SingleDynamicMethod method) {
final MethodType methodType = method.getMethodType();
final int methodArity = methodType.parameterCount();
if(methodArity != callSiteType.parameterCount()) {
@ -165,7 +165,7 @@ class ApplicableOverloadedMethods {
*/
static final ApplicabilityTest APPLICABLE_BY_METHOD_INVOCATION_CONVERSION = new ApplicabilityTest() {
@Override
boolean isApplicable(MethodType callSiteType, SingleDynamicMethod method) {
boolean isApplicable(final MethodType callSiteType, final SingleDynamicMethod method) {
final MethodType methodType = method.getMethodType();
final int methodArity = methodType.parameterCount();
if(methodArity != callSiteType.parameterCount()) {
@ -188,7 +188,7 @@ class ApplicableOverloadedMethods {
*/
static final ApplicabilityTest APPLICABLE_BY_VARIABLE_ARITY = new ApplicabilityTest() {
@Override
boolean isApplicable(MethodType callSiteType, SingleDynamicMethod method) {
boolean isApplicable(final MethodType callSiteType, final SingleDynamicMethod method) {
if(!method.isVarArgs()) {
return false;
}

View File

@ -88,7 +88,7 @@ import java.util.Collections;
import java.util.Map;
class BeanIntrospector extends FacetIntrospector {
BeanIntrospector(Class<?> clazz) {
BeanIntrospector(final Class<?> clazz) {
super(clazz, true);
}
@ -98,7 +98,7 @@ class BeanIntrospector extends FacetIntrospector {
}
@Override
MethodHandle editMethodHandle(MethodHandle mh) {
MethodHandle editMethodHandle(final MethodHandle mh) {
return mh;
}
}

View File

@ -106,7 +106,7 @@ import jdk.internal.dynalink.support.TypeUtilities;
* @author Attila Szegedi
*/
class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicLinker {
BeanLinker(Class<?> clazz) {
BeanLinker(final Class<?> clazz) {
super(clazz, Guards.getClassGuard(clazz), Guards.getInstanceOfGuard(clazz));
if(clazz.isArray()) {
// Some languages won't have a notion of manipulating collections. Exposing "length" on arrays as an
@ -119,7 +119,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
}
@Override
public boolean canLinkType(Class<?> type) {
public boolean canLinkType(final Class<?> type) {
return type == clazz;
}
@ -129,8 +129,8 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
}
@Override
protected GuardedInvocationComponent getGuardedInvocationComponent(CallSiteDescriptor callSiteDescriptor,
LinkerServices linkerServices, List<String> operations) throws Exception {
protected GuardedInvocationComponent getGuardedInvocationComponent(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final List<String> operations) throws Exception {
final GuardedInvocationComponent superGic = super.getGuardedInvocationComponent(callSiteDescriptor,
linkerServices, operations);
if(superGic != null) {
@ -166,7 +166,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
private static MethodHandle MAP_GUARD = Guards.getInstanceOfGuard(Map.class);
private GuardedInvocationComponent getElementGetter(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, List<String> operations) throws Exception {
final LinkerServices linkerServices, final List<String> operations) throws Exception {
final MethodType callSiteType = callSiteDescriptor.getMethodType();
final Class<?> declaredType = callSiteType.parameterType(0);
final GuardedInvocationComponent nextComponent = getGuardedInvocationComponent(callSiteDescriptor,
@ -248,7 +248,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
CallSiteDescriptor.NAME_OPERAND);
}
private static Object convertKeyToInteger(String fixedKey, LinkerServices linkerServices) throws Exception {
private static Object convertKeyToInteger(final String fixedKey, final LinkerServices linkerServices) throws Exception {
try {
if(linkerServices.canConvert(String.class, Number.class)) {
try {
@ -268,18 +268,18 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
return Integer.valueOf(intIndex);
} catch(Exception|Error e) {
throw e;
} catch(Throwable t) {
} catch(final Throwable t) {
throw new RuntimeException(t);
}
}
return Integer.valueOf(fixedKey);
} catch(NumberFormatException e) {
} catch(final NumberFormatException e) {
// key is not a number
return null;
}
}
private static MethodHandle convertArgToInt(MethodHandle mh, LinkerServices ls, CallSiteDescriptor desc) {
private static MethodHandle convertArgToInt(final MethodHandle mh, final LinkerServices ls, final CallSiteDescriptor desc) {
final Class<?> sourceType = desc.getMethodType().parameterType(1);
if(TypeUtilities.isMethodInvocationConvertible(sourceType, Number.class)) {
return mh;
@ -302,21 +302,21 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
private final MethodType methodType;
private final Object fixedKey;
Binder(LinkerServices linkerServices, MethodType methodType, Object fixedKey) {
Binder(final LinkerServices linkerServices, final MethodType methodType, final Object fixedKey) {
this.linkerServices = linkerServices;
this.methodType = fixedKey == null ? methodType : methodType.insertParameterTypes(1, fixedKey.getClass());
this.fixedKey = fixedKey;
}
/*private*/ MethodHandle bind(MethodHandle handle) {
/*private*/ MethodHandle bind(final MethodHandle handle) {
return bindToFixedKey(linkerServices.asTypeLosslessReturn(handle, methodType));
}
/*private*/ MethodHandle bindTest(MethodHandle handle) {
/*private*/ MethodHandle bindTest(final MethodHandle handle) {
return bindToFixedKey(Guards.asType(handle, methodType));
}
private MethodHandle bindToFixedKey(MethodHandle handle) {
private MethodHandle bindToFixedKey(final MethodHandle handle) {
return fixedKey == null ? handle : MethodHandles.insertArguments(handle, 1, fixedKey);
}
}
@ -326,12 +326,12 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
private static MethodHandle CONTAINS_MAP = Lookup.PUBLIC.findVirtual(Map.class, "containsKey",
MethodType.methodType(boolean.class, Object.class));
private static MethodHandle findRangeCheck(Class<?> collectionType) {
private static MethodHandle findRangeCheck(final Class<?> collectionType) {
return Lookup.findOwnStatic(MethodHandles.lookup(), "rangeCheck", boolean.class, collectionType, Object.class);
}
@SuppressWarnings("unused")
private static final boolean rangeCheck(Object array, Object index) {
private static final boolean rangeCheck(final Object array, final Object index) {
if(!(index instanceof Number)) {
return false;
}
@ -348,7 +348,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
}
@SuppressWarnings("unused")
private static final boolean rangeCheck(List<?> list, Object index) {
private static final boolean rangeCheck(final List<?> list, final Object index) {
if(!(index instanceof Number)) {
return false;
}
@ -370,8 +370,8 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
private static MethodHandle PUT_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "put",
MethodType.methodType(Object.class, Object.class, Object.class));
private GuardedInvocationComponent getElementSetter(CallSiteDescriptor callSiteDescriptor,
LinkerServices linkerServices, List<String> operations) throws Exception {
private GuardedInvocationComponent getElementSetter(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final List<String> operations) throws Exception {
final MethodType callSiteType = callSiteDescriptor.getMethodType();
final Class<?> declaredType = callSiteType.parameterType(0);
@ -458,7 +458,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
private static MethodHandle COLLECTION_GUARD = Guards.getInstanceOfGuard(Collection.class);
private GuardedInvocationComponent getLengthGetter(CallSiteDescriptor callSiteDescriptor) {
private GuardedInvocationComponent getLengthGetter(final CallSiteDescriptor callSiteDescriptor) {
assertParameterCount(callSiteDescriptor, 1);
final MethodType callSiteType = callSiteDescriptor.getMethodType();
final Class<?> declaredType = callSiteType.parameterType(0);
@ -488,7 +488,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
return null;
}
private static void assertParameterCount(CallSiteDescriptor descriptor, int paramCount) {
private static void assertParameterCount(final CallSiteDescriptor descriptor, final int paramCount) {
if(descriptor.getMethodType().parameterCount() != paramCount) {
throw new BootstrapMethodError(descriptor.getName() + " must have exactly " + paramCount + " parameters.");
}

View File

@ -131,7 +131,7 @@ import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker;
public class BeansLinker implements GuardingDynamicLinker {
private static final ClassValue<TypeBasedGuardingDynamicLinker> linkers = new ClassValue<TypeBasedGuardingDynamicLinker>() {
@Override
protected TypeBasedGuardingDynamicLinker computeValue(Class<?> clazz) {
protected TypeBasedGuardingDynamicLinker computeValue(final Class<?> clazz) {
// If ClassValue.put() were public, we could just pre-populate with these known mappings...
return
clazz == Class.class ? new ClassLinker() :
@ -154,7 +154,7 @@ public class BeansLinker implements GuardingDynamicLinker {
* @param clazz the class
* @return a bean linker for that class
*/
public static TypeBasedGuardingDynamicLinker getLinkerForClass(Class<?> clazz) {
public static TypeBasedGuardingDynamicLinker getLinkerForClass(final Class<?> clazz) {
return linkers.get(clazz);
}
@ -173,8 +173,8 @@ public class BeansLinker implements GuardingDynamicLinker {
* @param clazz the class
* @return a collection of names of all readable instance properties of a class.
*/
public static Collection<String> getReadableInstancePropertyNames(Class<?> clazz) {
TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz);
public static Collection<String> getReadableInstancePropertyNames(final Class<?> clazz) {
final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz);
if(linker instanceof BeanLinker) {
return ((BeanLinker)linker).getReadablePropertyNames();
}
@ -186,8 +186,8 @@ public class BeansLinker implements GuardingDynamicLinker {
* @param clazz the class
* @return a collection of names of all writable instance properties of a class.
*/
public static Collection<String> getWritableInstancePropertyNames(Class<?> clazz) {
TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz);
public static Collection<String> getWritableInstancePropertyNames(final Class<?> clazz) {
final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz);
if(linker instanceof BeanLinker) {
return ((BeanLinker)linker).getWritablePropertyNames();
}
@ -199,8 +199,8 @@ public class BeansLinker implements GuardingDynamicLinker {
* @param clazz the class
* @return a collection of names of all instance methods of a class.
*/
public static Collection<String> getInstanceMethodNames(Class<?> clazz) {
TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz);
public static Collection<String> getInstanceMethodNames(final Class<?> clazz) {
final TypeBasedGuardingDynamicLinker linker = getLinkerForClass(clazz);
if(linker instanceof BeanLinker) {
return ((BeanLinker)linker).getMethodNames();
}
@ -212,7 +212,7 @@ public class BeansLinker implements GuardingDynamicLinker {
* @param clazz the class
* @return a collection of names of all readable static properties of a class.
*/
public static Collection<String> getReadableStaticPropertyNames(Class<?> clazz) {
public static Collection<String> getReadableStaticPropertyNames(final Class<?> clazz) {
return StaticClassLinker.getReadableStaticPropertyNames(clazz);
}
@ -221,7 +221,7 @@ public class BeansLinker implements GuardingDynamicLinker {
* @param clazz the class
* @return a collection of names of all writable static properties of a class.
*/
public static Collection<String> getWritableStaticPropertyNames(Class<?> clazz) {
public static Collection<String> getWritableStaticPropertyNames(final Class<?> clazz) {
return StaticClassLinker.getWritableStaticPropertyNames(clazz);
}
@ -230,12 +230,12 @@ public class BeansLinker implements GuardingDynamicLinker {
* @param clazz the class
* @return a collection of names of all static methods of a class.
*/
public static Collection<String> getStaticMethodNames(Class<?> clazz) {
public static Collection<String> getStaticMethodNames(final Class<?> clazz) {
return StaticClassLinker.getStaticMethodNames(clazz);
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, final LinkerServices linkerServices)
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
throws Exception {
final CallSiteDescriptor callSiteDescriptor = request.getCallSiteDescriptor();
final int l = callSiteDescriptor.getNameTokenCount();

View File

@ -107,14 +107,14 @@ public class CallerSensitiveDetector {
private static final DetectionStrategy DETECTION_STRATEGY = getDetectionStrategy();
static boolean isCallerSensitive(AccessibleObject ao) {
static boolean isCallerSensitive(final AccessibleObject ao) {
return DETECTION_STRATEGY.isCallerSensitive(ao);
}
private static DetectionStrategy getDetectionStrategy() {
try {
return new PrivilegedDetectionStrategy();
} catch(Throwable t) {
} catch(final Throwable t) {
return new UnprivilegedDetectionStrategy();
}
}
@ -127,7 +127,7 @@ public class CallerSensitiveDetector {
private static final Class<? extends Annotation> CALLER_SENSITIVE_ANNOTATION_CLASS = CallerSensitive.class;
@Override
boolean isCallerSensitive(AccessibleObject ao) {
boolean isCallerSensitive(final AccessibleObject ao) {
return ao.getAnnotation(CALLER_SENSITIVE_ANNOTATION_CLASS) != null;
}
}
@ -136,8 +136,8 @@ public class CallerSensitiveDetector {
private static final String CALLER_SENSITIVE_ANNOTATION_STRING = "@sun.reflect.CallerSensitive()";
@Override
boolean isCallerSensitive(AccessibleObject o) {
for(Annotation a: o.getAnnotations()) {
boolean isCallerSensitive(final AccessibleObject o) {
for(final Annotation a: o.getAnnotations()) {
if(String.valueOf(a).equals(CALLER_SENSITIVE_ANNOTATION_STRING)) {
return true;
}

View File

@ -107,13 +107,13 @@ class CallerSensitiveDynamicMethod extends SingleDynamicMethod {
private final AccessibleObject target;
private final MethodType type;
public CallerSensitiveDynamicMethod(AccessibleObject target) {
public CallerSensitiveDynamicMethod(final AccessibleObject target) {
super(getName(target));
this.target = target;
this.type = getMethodType(target);
}
private static String getName(AccessibleObject target) {
private static String getName(final AccessibleObject target) {
final Member m = (Member)target;
return getMethodNameWithSignature(getMethodType(target), getClassAndMethodName(m.getDeclaringClass(),
m.getName()));
@ -124,7 +124,7 @@ class CallerSensitiveDynamicMethod extends SingleDynamicMethod {
return type;
}
private static MethodType getMethodType(AccessibleObject ao) {
private static MethodType getMethodType(final AccessibleObject ao) {
final boolean isMethod = ao instanceof Method;
final Class<?> rtype = isMethod ? ((Method)ao).getReturnType() : ((Constructor<?>)ao).getDeclaringClass();
final Class<?>[] ptypes = isMethod ? ((Method)ao).getParameterTypes() : ((Constructor<?>)ao).getParameterTypes();
@ -144,7 +144,7 @@ class CallerSensitiveDynamicMethod extends SingleDynamicMethod {
}
@Override
MethodHandle getTarget(MethodHandles.Lookup lookup) {
MethodHandle getTarget(final MethodHandles.Lookup lookup) {
if(target instanceof Method) {
final MethodHandle mh = Lookup.unreflect(lookup, (Method)target);
if(Modifier.isStatic(((Member)target).getModifiers())) {

View File

@ -101,7 +101,7 @@ class CheckRestrictedPackage {
* @param clazz the class to test
* @return true if the class is either not public, or it resides in a package with restricted access.
*/
static boolean isRestrictedClass(Class<?> clazz) {
static boolean isRestrictedClass(final Class<?> clazz) {
if(!Modifier.isPublic(clazz.getModifiers())) {
// Non-public classes are always restricted
return true;
@ -126,7 +126,7 @@ class CheckRestrictedPackage {
return null;
}
}, NO_PERMISSIONS_CONTEXT);
} catch(SecurityException e) {
} catch(final SecurityException e) {
return true;
}
return false;

View File

@ -104,16 +104,16 @@ final class ClassString {
private final Class<?>[] classes;
private int hashCode;
ClassString(Class<?>[] classes) {
ClassString(final Class<?>[] classes) {
this.classes = classes;
}
ClassString(MethodType type) {
ClassString(final MethodType type) {
this(type.parameterArray());
}
@Override
public boolean equals(Object other) {
public boolean equals(final Object other) {
if(!(other instanceof ClassString)) {
return false;
}
@ -150,7 +150,7 @@ final class ClassString {
return true;
}
List<MethodHandle> getMaximallySpecifics(List<MethodHandle> methods, LinkerServices linkerServices, boolean varArg) {
List<MethodHandle> getMaximallySpecifics(final List<MethodHandle> methods, final LinkerServices linkerServices, final boolean varArg) {
return MaximallySpecific.getMaximallySpecificMethodHandles(getApplicables(methods, linkerServices, varArg),
varArg, classes, linkerServices);
}
@ -158,7 +158,7 @@ final class ClassString {
/**
* Returns all methods that are applicable to actual parameter classes represented by this ClassString object.
*/
LinkedList<MethodHandle> getApplicables(List<MethodHandle> methods, LinkerServices linkerServices, boolean varArg) {
LinkedList<MethodHandle> getApplicables(final List<MethodHandle> methods, final LinkerServices linkerServices, final boolean varArg) {
final LinkedList<MethodHandle> list = new LinkedList<>();
for(final MethodHandle member: methods) {
if(isApplicable(member, linkerServices, varArg)) {
@ -173,7 +173,7 @@ final class ClassString {
* object.
*
*/
private boolean isApplicable(MethodHandle method, LinkerServices linkerServices, boolean varArg) {
private boolean isApplicable(final MethodHandle method, final LinkerServices linkerServices, final boolean varArg) {
final Class<?>[] formalTypes = method.type().parameterArray();
final int cl = classes.length;
final int fl = formalTypes.length - (varArg ? 1 : 0);
@ -203,7 +203,7 @@ final class ClassString {
return true;
}
private static boolean canConvert(LinkerServices ls, Class<?> from, Class<?> to) {
private static boolean canConvert(final LinkerServices ls, final Class<?> from, final Class<?> to) {
if(from == NULL_CLASS) {
return !to.isPrimitive();
}

View File

@ -99,7 +99,7 @@ import jdk.internal.dynalink.linker.LinkerServices;
abstract class DynamicMethod {
private final String name;
DynamicMethod(String name) {
DynamicMethod(final String name) {
this.name = name;
}
@ -138,7 +138,7 @@ abstract class DynamicMethod {
*/
abstract boolean contains(SingleDynamicMethod method);
static String getClassAndMethodName(Class<?> clazz, String name) {
static String getClassAndMethodName(final Class<?> clazz, final String name) {
final String clazzName = clazz.getCanonicalName();
return (clazzName == null ? clazz.getName() : clazzName) + "." + name;
}

View File

@ -99,12 +99,12 @@ import jdk.internal.dynalink.support.Guards;
*/
class DynamicMethodLinker implements TypeBasedGuardingDynamicLinker {
@Override
public boolean canLinkType(Class<?> type) {
public boolean canLinkType(final Class<?> type) {
return DynamicMethod.class.isAssignableFrom(type);
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, LinkerServices linkerServices) {
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) {
final Object receiver = linkRequest.getReceiver();
if(!(receiver instanceof DynamicMethod)) {
return null;

View File

@ -106,7 +106,7 @@ abstract class FacetIntrospector {
protected final AccessibleMembersLookup membersLookup;
FacetIntrospector(Class<?> clazz, boolean instance) {
FacetIntrospector(final Class<?> clazz, final boolean instance) {
this.clazz = clazz;
this.instance = instance;
isRestricted = CheckRestrictedPackage.isRestrictedClass(clazz);
@ -135,7 +135,7 @@ abstract class FacetIntrospector {
final Field[] fields = clazz.getFields();
final Collection<Field> cfields = new ArrayList<>(fields.length);
for(Field field: fields) {
for(final Field field: fields) {
final boolean isStatic = Modifier.isStatic(field.getModifiers());
if(isStatic && clazz != field.getDeclaringClass()) {
// ignore inherited static fields
@ -149,7 +149,7 @@ abstract class FacetIntrospector {
return cfields;
}
boolean isAccessible(Member m) {
boolean isAccessible(final Member m) {
final Class<?> declaring = m.getDeclaringClass();
// (declaring == clazz) is just an optimization - we're calling this only from code that operates on a
// non-restriced class, so if the declaring class is identical to the class being inspected, then forego
@ -166,11 +166,11 @@ abstract class FacetIntrospector {
}
MethodHandle unreflectGetter(Field field) {
MethodHandle unreflectGetter(final Field field) {
return editMethodHandle(Lookup.PUBLIC.unreflectGetter(field));
}
MethodHandle unreflectSetter(Field field) {
MethodHandle unreflectSetter(final Field field) {
return editMethodHandle(Lookup.PUBLIC.unreflectSetter(field));
}

View File

@ -105,38 +105,38 @@ class GuardedInvocationComponent {
private final GuardedInvocation guardedInvocation;
private final Validator validator;
GuardedInvocationComponent(MethodHandle invocation) {
GuardedInvocationComponent(final MethodHandle invocation) {
this(invocation, null, ValidationType.NONE);
}
GuardedInvocationComponent(MethodHandle invocation, MethodHandle guard, ValidationType validationType) {
GuardedInvocationComponent(final MethodHandle invocation, final MethodHandle guard, final ValidationType validationType) {
this(invocation, guard, null, validationType);
}
GuardedInvocationComponent(MethodHandle invocation, MethodHandle guard, Class<?> validatorClass,
ValidationType validationType) {
GuardedInvocationComponent(final MethodHandle invocation, final MethodHandle guard, final Class<?> validatorClass,
final ValidationType validationType) {
this(invocation, guard, new Validator(validatorClass, validationType));
}
GuardedInvocationComponent(GuardedInvocation guardedInvocation, Class<?> validatorClass,
ValidationType validationType) {
GuardedInvocationComponent(final GuardedInvocation guardedInvocation, final Class<?> validatorClass,
final ValidationType validationType) {
this(guardedInvocation, new Validator(validatorClass, validationType));
}
GuardedInvocationComponent replaceInvocation(MethodHandle newInvocation) {
GuardedInvocationComponent replaceInvocation(final MethodHandle newInvocation) {
return replaceInvocation(newInvocation, guardedInvocation.getGuard());
}
GuardedInvocationComponent replaceInvocation(MethodHandle newInvocation, MethodHandle newGuard) {
GuardedInvocationComponent replaceInvocation(final MethodHandle newInvocation, final MethodHandle newGuard) {
return new GuardedInvocationComponent(guardedInvocation.replaceMethods(newInvocation,
newGuard), validator);
}
private GuardedInvocationComponent(MethodHandle invocation, MethodHandle guard, Validator validator) {
private GuardedInvocationComponent(final MethodHandle invocation, final MethodHandle guard, final Validator validator) {
this(new GuardedInvocation(invocation, guard), validator);
}
private GuardedInvocationComponent(GuardedInvocation guardedInvocation, Validator validator) {
private GuardedInvocationComponent(final GuardedInvocation guardedInvocation, final Validator validator) {
this.guardedInvocation = guardedInvocation;
this.validator = validator;
}
@ -153,8 +153,8 @@ class GuardedInvocationComponent {
return validator.validationType;
}
GuardedInvocationComponent compose(MethodHandle compositeInvocation, MethodHandle otherGuard,
Class<?> otherValidatorClass, ValidationType otherValidationType) {
GuardedInvocationComponent compose(final MethodHandle compositeInvocation, final MethodHandle otherGuard,
final Class<?> otherValidatorClass, final ValidationType otherValidationType) {
final Validator compositeValidator = validator.compose(new Validator(otherValidatorClass, otherValidationType));
final MethodHandle compositeGuard = compositeValidator == validator ? guardedInvocation.getGuard() : otherGuard;
return new GuardedInvocationComponent(compositeInvocation, compositeGuard, compositeValidator);
@ -164,12 +164,12 @@ class GuardedInvocationComponent {
/*private*/ final Class<?> validatorClass;
/*private*/ final ValidationType validationType;
Validator(Class<?> validatorClass, ValidationType validationType) {
Validator(final Class<?> validatorClass, final ValidationType validationType) {
this.validatorClass = validatorClass;
this.validationType = validationType;
}
Validator compose(Validator other) {
Validator compose(final Validator other) {
if(other.validationType == ValidationType.NONE) {
return this;
}
@ -240,7 +240,7 @@ class GuardedInvocationComponent {
throw new AssertionError("Incompatible composition " + this + " vs " + other);
}
private boolean isAssignableFrom(Validator other) {
private boolean isAssignableFrom(final Validator other) {
return validatorClass.isAssignableFrom(other.validatorClass);
}

View File

@ -105,7 +105,7 @@ class MaximallySpecific {
* @param varArgs whether to assume the methods are varargs
* @return the list of maximally specific methods.
*/
static List<SingleDynamicMethod> getMaximallySpecificMethods(List<SingleDynamicMethod> methods, boolean varArgs) {
static List<SingleDynamicMethod> getMaximallySpecificMethods(final List<SingleDynamicMethod> methods, final boolean varArgs) {
return getMaximallySpecificSingleDynamicMethods(methods, varArgs, null, null);
}
@ -116,7 +116,7 @@ class MaximallySpecific {
private static final MethodTypeGetter<MethodHandle> METHOD_HANDLE_TYPE_GETTER =
new MethodTypeGetter<MethodHandle>() {
@Override
MethodType getMethodType(MethodHandle t) {
MethodType getMethodType(final MethodHandle t) {
return t.type();
}
};
@ -124,7 +124,7 @@ class MaximallySpecific {
private static final MethodTypeGetter<SingleDynamicMethod> DYNAMIC_METHOD_TYPE_GETTER =
new MethodTypeGetter<SingleDynamicMethod>() {
@Override
MethodType getMethodType(SingleDynamicMethod t) {
MethodType getMethodType(final SingleDynamicMethod t) {
return t.getMethodType();
}
};
@ -138,8 +138,8 @@ class MaximallySpecific {
* @param argTypes concrete argument types for the invocation
* @return the list of maximally specific method handles.
*/
static List<MethodHandle> getMaximallySpecificMethodHandles(List<MethodHandle> methods, boolean varArgs,
Class<?>[] argTypes, LinkerServices ls) {
static List<MethodHandle> getMaximallySpecificMethodHandles(final List<MethodHandle> methods, final boolean varArgs,
final Class<?>[] argTypes, final LinkerServices ls) {
return getMaximallySpecificMethods(methods, varArgs, argTypes, ls, METHOD_HANDLE_TYPE_GETTER);
}
@ -152,8 +152,8 @@ class MaximallySpecific {
* @param argTypes concrete argument types for the invocation
* @return the list of maximally specific methods.
*/
static List<SingleDynamicMethod> getMaximallySpecificSingleDynamicMethods(List<SingleDynamicMethod> methods,
boolean varArgs, Class<?>[] argTypes, LinkerServices ls) {
static List<SingleDynamicMethod> getMaximallySpecificSingleDynamicMethods(final List<SingleDynamicMethod> methods,
final boolean varArgs, final Class<?>[] argTypes, final LinkerServices ls) {
return getMaximallySpecificMethods(methods, varArgs, argTypes, ls, DYNAMIC_METHOD_TYPE_GETTER);
}
@ -166,16 +166,16 @@ class MaximallySpecific {
* @param argTypes concrete argument types for the invocation
* @return the list of maximally specific methods.
*/
private static <T> List<T> getMaximallySpecificMethods(List<T> methods, boolean varArgs,
Class<?>[] argTypes, LinkerServices ls, MethodTypeGetter<T> methodTypeGetter) {
private static <T> List<T> getMaximallySpecificMethods(final List<T> methods, final boolean varArgs,
final Class<?>[] argTypes, final LinkerServices ls, final MethodTypeGetter<T> methodTypeGetter) {
if(methods.size() < 2) {
return methods;
}
final LinkedList<T> maximals = new LinkedList<>();
for(T m: methods) {
for(final T m: methods) {
final MethodType methodType = methodTypeGetter.getMethodType(m);
boolean lessSpecific = false;
for(Iterator<T> maximal = maximals.iterator(); maximal.hasNext();) {
for(final Iterator<T> maximal = maximals.iterator(); maximal.hasNext();) {
final T max = maximal.next();
switch(isMoreSpecific(methodType, methodTypeGetter.getMethodType(max), varArgs, argTypes, ls)) {
case TYPE_1_BETTER: {
@ -202,8 +202,8 @@ class MaximallySpecific {
return maximals;
}
private static Comparison isMoreSpecific(MethodType t1, MethodType t2, boolean varArgs, Class<?>[] argTypes,
LinkerServices ls) {
private static Comparison isMoreSpecific(final MethodType t1, final MethodType t2, final boolean varArgs, final Class<?>[] argTypes,
final LinkerServices ls) {
final int pc1 = t1.parameterCount();
final int pc2 = t2.parameterCount();
assert varArgs || (pc1 == pc2) && (argTypes == null || argTypes.length == pc1);
@ -241,7 +241,7 @@ class MaximallySpecific {
return Comparison.INDETERMINATE;
}
private static Comparison compare(Class<?> c1, Class<?> c2, Class<?>[] argTypes, int i, LinkerServices cmp) {
private static Comparison compare(final Class<?> c1, final Class<?> c2, final Class<?>[] argTypes, final int i, final LinkerServices cmp) {
if(cmp != null) {
final Comparison c = cmp.compareConversion(argTypes[i], c1, c2);
if(c != Comparison.INDETERMINATE) {
@ -256,7 +256,7 @@ class MaximallySpecific {
return Comparison.INDETERMINATE;
}
private static Class<?> getParameterClass(MethodType t, int l, int i, boolean varArgs) {
private static Class<?> getParameterClass(final MethodType t, final int l, final int i, final boolean varArgs) {
return varArgs && i >= l - 1 ? t.parameterType(l - 1).getComponentType() : t.parameterType(i);
}
}

View File

@ -115,20 +115,20 @@ class OverloadedDynamicMethod extends DynamicMethod {
* @param clazz the class this method belongs to
* @param name the name of the method
*/
OverloadedDynamicMethod(Class<?> clazz, String name) {
OverloadedDynamicMethod(final Class<?> clazz, final String name) {
this(new LinkedList<SingleDynamicMethod>(), clazz.getClassLoader(), getClassAndMethodName(clazz, name));
}
private OverloadedDynamicMethod(LinkedList<SingleDynamicMethod> methods, ClassLoader classLoader, String name) {
private OverloadedDynamicMethod(final LinkedList<SingleDynamicMethod> methods, final ClassLoader classLoader, final String name) {
super(name);
this.methods = methods;
this.classLoader = classLoader;
}
@Override
SingleDynamicMethod getMethodForExactParamTypes(String paramTypes) {
SingleDynamicMethod getMethodForExactParamTypes(final String paramTypes) {
final LinkedList<SingleDynamicMethod> matchingMethods = new LinkedList<>();
for(SingleDynamicMethod method: methods) {
for(final SingleDynamicMethod method: methods) {
final SingleDynamicMethod matchingMethod = method.getMethodForExactParamTypes(paramTypes);
if(matchingMethod != null) {
matchingMethods.add(matchingMethod);
@ -217,7 +217,7 @@ class OverloadedDynamicMethod extends DynamicMethod {
// has an already determined Lookup.
final List<MethodHandle> methodHandles = new ArrayList<>(invokables.size());
final MethodHandles.Lookup lookup = callSiteDescriptor.getLookup();
for(SingleDynamicMethod method: invokables) {
for(final SingleDynamicMethod method: invokables) {
methodHandles.add(method.getTarget(lookup));
}
return new OverloadedMethod(methodHandles, this, callSiteType, linkerServices).getInvoker();
@ -227,8 +227,8 @@ class OverloadedDynamicMethod extends DynamicMethod {
}
@Override
public boolean contains(SingleDynamicMethod m) {
for(SingleDynamicMethod method: methods) {
public boolean contains(final SingleDynamicMethod m) {
for(final SingleDynamicMethod method: methods) {
if(method.contains(m)) {
return true;
}
@ -240,8 +240,8 @@ class OverloadedDynamicMethod extends DynamicMethod {
return classLoader;
}
private static boolean isApplicableDynamically(LinkerServices linkerServices, MethodType callSiteType,
SingleDynamicMethod m) {
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final MethodType callSiteType,
final SingleDynamicMethod m) {
final MethodType methodType = m.getMethodType();
final boolean varArgs = m.isVarArgs();
final int fixedArgLen = methodType.parameterCount() - (varArgs ? 1 : 0);
@ -287,13 +287,13 @@ class OverloadedDynamicMethod extends DynamicMethod {
return true;
}
private static boolean isApplicableDynamically(LinkerServices linkerServices, Class<?> callSiteType,
Class<?> methodType) {
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final Class<?> callSiteType,
final Class<?> methodType) {
return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
|| linkerServices.canConvert(callSiteType, methodType);
}
private ApplicableOverloadedMethods getApplicables(MethodType callSiteType, ApplicabilityTest test) {
private ApplicableOverloadedMethods getApplicables(final MethodType callSiteType, final ApplicabilityTest test) {
return new ApplicableOverloadedMethods(methods, callSiteType, test);
}
@ -302,7 +302,7 @@ class OverloadedDynamicMethod extends DynamicMethod {
*
* @param method a method to add
*/
public void addMethod(SingleDynamicMethod method) {
public void addMethod(final SingleDynamicMethod method) {
methods.add(method);
}
}

View File

@ -112,8 +112,8 @@ class OverloadedMethod {
private final ArrayList<MethodHandle> fixArgMethods;
private final ArrayList<MethodHandle> varArgMethods;
OverloadedMethod(List<MethodHandle> methodHandles, OverloadedDynamicMethod parent, MethodType callSiteType,
LinkerServices linkerServices) {
OverloadedMethod(final List<MethodHandle> methodHandles, final OverloadedDynamicMethod parent, final MethodType callSiteType,
final LinkerServices linkerServices) {
this.parent = parent;
final Class<?> commonRetType = getCommonReturnType(methodHandles);
this.callSiteType = callSiteType.changeReturnType(commonRetType);
@ -151,7 +151,7 @@ class OverloadedMethod {
MethodHandle.class, Object[].class);
@SuppressWarnings("unused")
private MethodHandle selectMethod(Object[] args) throws NoSuchMethodException {
private MethodHandle selectMethod(final Object[] args) throws NoSuchMethodException {
final Class<?>[] argTypes = new Class[args.length];
for(int i = 0; i < argTypes.length; ++i) {
final Object arg = args[i];
@ -188,7 +188,7 @@ class OverloadedMethod {
return method;
}
private MethodHandle getNoSuchMethodThrower(Class<?>[] argTypes) {
private MethodHandle getNoSuchMethodThrower(final Class<?>[] argTypes) {
return adaptThrower(MethodHandles.insertArguments(THROW_NO_SUCH_METHOD, 0, this, argTypes));
}
@ -196,7 +196,7 @@ class OverloadedMethod {
"throwNoSuchMethod", void.class, Class[].class);
@SuppressWarnings("unused")
private void throwNoSuchMethod(Class<?>[] argTypes) throws NoSuchMethodException {
private void throwNoSuchMethod(final Class<?>[] argTypes) throws NoSuchMethodException {
if(varArgMethods.isEmpty()) {
throw new NoSuchMethodException("None of the fixed arity signatures " + getSignatureList(fixArgMethods) +
" of method " + parent.getName() + " match the argument types " + argTypesString(argTypes));
@ -206,11 +206,11 @@ class OverloadedMethod {
parent.getName() + " match the argument types " + argTypesString(argTypes));
}
private MethodHandle getAmbiguousMethodThrower(Class<?>[] argTypes, List<MethodHandle> methods) {
private MethodHandle getAmbiguousMethodThrower(final Class<?>[] argTypes, final List<MethodHandle> methods) {
return adaptThrower(MethodHandles.insertArguments(THROW_AMBIGUOUS_METHOD, 0, this, argTypes, methods));
}
private MethodHandle adaptThrower(MethodHandle rawThrower) {
private MethodHandle adaptThrower(final MethodHandle rawThrower) {
return MethodHandles.dropArguments(rawThrower, 0, callSiteType.parameterList()).asType(callSiteType);
}
@ -218,20 +218,20 @@ class OverloadedMethod {
"throwAmbiguousMethod", void.class, Class[].class, List.class);
@SuppressWarnings("unused")
private void throwAmbiguousMethod(Class<?>[] argTypes, List<MethodHandle> methods) throws NoSuchMethodException {
private void throwAmbiguousMethod(final Class<?>[] argTypes, final List<MethodHandle> methods) throws NoSuchMethodException {
final String arity = methods.get(0).isVarargsCollector() ? "variable" : "fixed";
throw new NoSuchMethodException("Can't unambiguously select between " + arity + " arity signatures " +
getSignatureList(methods) + " of the method " + parent.getName() + " for argument types " +
argTypesString(argTypes));
}
private static String argTypesString(Class<?>[] classes) {
private static String argTypesString(final Class<?>[] classes) {
final StringBuilder b = new StringBuilder().append('[');
appendTypes(b, classes, false);
return b.append(']').toString();
}
private static String getSignatureList(List<MethodHandle> methods) {
private static String getSignatureList(final List<MethodHandle> methods) {
final StringBuilder b = new StringBuilder().append('[');
final Iterator<MethodHandle> it = methods.iterator();
if(it.hasNext()) {
@ -243,13 +243,13 @@ class OverloadedMethod {
return b.append(']').toString();
}
private static void appendSig(StringBuilder b, MethodHandle m) {
private static void appendSig(final StringBuilder b, final MethodHandle m) {
b.append('(');
appendTypes(b, m.type().parameterArray(), m.isVarargsCollector());
b.append(')');
}
private static void appendTypes(StringBuilder b, Class<?>[] classes, boolean varArg) {
private static void appendTypes(final StringBuilder b, final Class<?>[] classes, final boolean varArg) {
final int l = classes.length;
if(!varArg) {
if(l > 1) {
@ -266,7 +266,7 @@ class OverloadedMethod {
}
}
private static Class<?> getCommonReturnType(List<MethodHandle> methodHandles) {
private static Class<?> getCommonReturnType(final List<MethodHandle> methodHandles) {
final Iterator<MethodHandle> it = methodHandles.iterator();
Class<?> retType = it.next().type().returnType();
while(it.hasNext()) {

View File

@ -107,12 +107,12 @@ class SimpleDynamicMethod extends SingleDynamicMethod {
* @param clazz the class declaring the method
* @param name the simple name of the method
*/
SimpleDynamicMethod(MethodHandle target, Class<?> clazz, String name) {
SimpleDynamicMethod(final MethodHandle target, final Class<?> clazz, final String name) {
super(getName(target, clazz, name));
this.target = target;
}
private static String getName(MethodHandle target, Class<?> clazz, String name) {
private static String getName(final MethodHandle target, final Class<?> clazz, final String name) {
return getMethodNameWithSignature(target.type(), getClassAndMethodName(clazz, name));
}
@ -127,7 +127,7 @@ class SimpleDynamicMethod extends SingleDynamicMethod {
}
@Override
MethodHandle getTarget(Lookup lookup) {
MethodHandle getTarget(final Lookup lookup) {
return target;
}
}

View File

@ -104,7 +104,7 @@ abstract class SingleDynamicMethod extends DynamicMethod {
private static final MethodHandle CAN_CONVERT_TO = Lookup.findOwnStatic(MethodHandles.lookup(), "canConvertTo", boolean.class, LinkerServices.class, Class.class, Object.class);
SingleDynamicMethod(String name) {
SingleDynamicMethod(final String name) {
super(name);
}
@ -128,22 +128,22 @@ abstract class SingleDynamicMethod extends DynamicMethod {
abstract MethodHandle getTarget(MethodHandles.Lookup lookup);
@Override
MethodHandle getInvocation(CallSiteDescriptor callSiteDescriptor, LinkerServices linkerServices) {
MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) {
return getInvocation(getTarget(callSiteDescriptor.getLookup()), callSiteDescriptor.getMethodType(),
linkerServices);
}
@Override
SingleDynamicMethod getMethodForExactParamTypes(String paramTypes) {
SingleDynamicMethod getMethodForExactParamTypes(final String paramTypes) {
return typeMatchesDescription(paramTypes, getMethodType()) ? this : null;
}
@Override
boolean contains(SingleDynamicMethod method) {
boolean contains(final SingleDynamicMethod method) {
return getMethodType().parameterList().equals(method.getMethodType().parameterList());
}
static String getMethodNameWithSignature(MethodType type, String methodName) {
static String getMethodNameWithSignature(final MethodType type, final String methodName) {
final String typeStr = type.toString();
final int retTypeIndex = typeStr.lastIndexOf(')') + 1;
int secondParamIndex = typeStr.indexOf(',') + 1;
@ -164,7 +164,7 @@ abstract class SingleDynamicMethod extends DynamicMethod {
* @param linkerServices the linker services used for type conversions
* @return the adapted method handle.
*/
static MethodHandle getInvocation(MethodHandle target, MethodType callSiteType, LinkerServices linkerServices) {
static MethodHandle getInvocation(final MethodHandle target, final MethodType callSiteType, final LinkerServices linkerServices) {
final MethodType methodType = target.type();
final int paramsLen = methodType.parameterCount();
final boolean varArgs = target.isVarargsCollector();
@ -266,7 +266,7 @@ abstract class SingleDynamicMethod extends DynamicMethod {
}
@SuppressWarnings("unused")
private static boolean canConvertTo(final LinkerServices linkerServices, Class<?> to, Object obj) {
private static boolean canConvertTo(final LinkerServices linkerServices, final Class<?> to, final Object obj) {
return obj == null ? false : linkerServices.canConvert(obj.getClass(), to);
}
@ -279,7 +279,7 @@ abstract class SingleDynamicMethod extends DynamicMethod {
* @param parameterCount the total number of arguments in the new method handle
* @return a collecting method handle
*/
static MethodHandle collectArguments(MethodHandle target, final int parameterCount) {
static MethodHandle collectArguments(final MethodHandle target, final int parameterCount) {
final MethodType methodType = target.type();
final int fixParamsLen = methodType.parameterCount() - 1;
final Class<?> arrayType = methodType.parameterType(fixParamsLen);
@ -291,7 +291,7 @@ abstract class SingleDynamicMethod extends DynamicMethod {
return linkerServices.asTypeLosslessReturn(sizedMethod, callSiteType);
}
private static boolean typeMatchesDescription(String paramTypes, MethodType type) {
private static boolean typeMatchesDescription(final String paramTypes, final MethodType type) {
final StringTokenizer tok = new StringTokenizer(paramTypes, ", ");
for(int i = 1; i < type.parameterCount(); ++i) { // i = 1 as we ignore the receiver
if(!(tok.hasMoreTokens() && typeNameMatches(tok.nextToken(), type.parameterType(i)))) {
@ -301,7 +301,7 @@ abstract class SingleDynamicMethod extends DynamicMethod {
return !tok.hasMoreTokens();
}
private static boolean typeNameMatches(String typeName, Class<?> type) {
private static boolean typeNameMatches(final String typeName, final Class<?> type) {
return typeName.equals(typeName.indexOf('.') == -1 ? type.getSimpleName() : type.getCanonicalName());
}
}

View File

@ -96,7 +96,7 @@ import java.io.Serializable;
public class StaticClass implements Serializable {
private static final ClassValue<StaticClass> staticClasses = new ClassValue<StaticClass>() {
@Override
protected StaticClass computeValue(Class<?> type) {
protected StaticClass computeValue(final Class<?> type) {
return new StaticClass(type);
}
};
@ -105,7 +105,7 @@ public class StaticClass implements Serializable {
private final Class<?> clazz;
/*private*/ StaticClass(Class<?> clazz) {
/*private*/ StaticClass(final Class<?> clazz) {
clazz.getClass(); // NPE check
this.clazz = clazz;
}
@ -115,7 +115,7 @@ public class StaticClass implements Serializable {
* @param clazz the class for which the static facet is requested.
* @return the {@link StaticClass} instance representing the specified class.
*/
public static StaticClass forClass(Class<?> clazz) {
public static StaticClass forClass(final Class<?> clazz) {
return staticClasses.get(clazz);
}

View File

@ -90,14 +90,14 @@ import java.util.HashMap;
import java.util.Map;
class StaticClassIntrospector extends FacetIntrospector {
StaticClassIntrospector(Class<?> clazz) {
StaticClassIntrospector(final Class<?> clazz) {
super(clazz, false);
}
@Override
Map<String, MethodHandle> getInnerClassGetters() {
final Map<String, MethodHandle> map = new HashMap<>();
for(Class<?> innerClass: membersLookup.getInnerClasses()) {
for(final Class<?> innerClass: membersLookup.getInnerClasses()) {
map.put(innerClass.getSimpleName(), editMethodHandle(MethodHandles.constant(StaticClass.class,
StaticClass.forClass(innerClass))));
}
@ -105,15 +105,15 @@ class StaticClassIntrospector extends FacetIntrospector {
}
@Override
MethodHandle editMethodHandle(MethodHandle mh) {
MethodHandle editMethodHandle(final MethodHandle mh) {
return editStaticMethodHandle(mh);
}
static MethodHandle editStaticMethodHandle(MethodHandle mh) {
static MethodHandle editStaticMethodHandle(final MethodHandle mh) {
return dropReceiver(mh, Object.class);
}
static MethodHandle editConstructorMethodHandle(MethodHandle cmh) {
static MethodHandle editConstructorMethodHandle(final MethodHandle cmh) {
return dropReceiver(cmh, StaticClass.class);
}

View File

@ -104,7 +104,7 @@ import jdk.internal.dynalink.support.Lookup;
class StaticClassLinker implements TypeBasedGuardingDynamicLinker {
private static final ClassValue<SingleClassStaticsLinker> linkers = new ClassValue<SingleClassStaticsLinker>() {
@Override
protected SingleClassStaticsLinker computeValue(Class<?> clazz) {
protected SingleClassStaticsLinker computeValue(final Class<?> clazz) {
return new SingleClassStaticsLinker(clazz);
}
};
@ -112,7 +112,7 @@ class StaticClassLinker implements TypeBasedGuardingDynamicLinker {
private static class SingleClassStaticsLinker extends AbstractJavaLinker {
private final DynamicMethod constructor;
SingleClassStaticsLinker(Class<?> clazz) {
SingleClassStaticsLinker(final Class<?> clazz) {
super(clazz, IS_CLASS.bindTo(clazz));
// Map "staticClassObject.class" to StaticClass.getRepresentedClass(). Some adventurous soul could subclass
// StaticClass, so we use INSTANCE_OF validation instead of EXACT_CLASS.
@ -126,7 +126,7 @@ class StaticClassLinker implements TypeBasedGuardingDynamicLinker {
* @return a dynamic method containing all overloads of a class' public constructor. If the class has no public
* constructors, returns null.
*/
private static DynamicMethod createConstructorMethod(Class<?> clazz) {
private static DynamicMethod createConstructorMethod(final Class<?> clazz) {
if(clazz.isArray()) {
final MethodHandle boundArrayCtor = ARRAY_CTOR.bindTo(clazz.getComponentType());
return new SimpleDynamicMethod(StaticClassIntrospector.editConstructorMethodHandle(
@ -144,7 +144,7 @@ class StaticClassLinker implements TypeBasedGuardingDynamicLinker {
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, LinkerServices linkerServices)
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices)
throws Exception {
final GuardedInvocation gi = super.getGuardedInvocation(request, linkerServices);
if(gi != null) {
@ -162,20 +162,20 @@ class StaticClassLinker implements TypeBasedGuardingDynamicLinker {
}
}
static Collection<String> getReadableStaticPropertyNames(Class<?> clazz) {
static Collection<String> getReadableStaticPropertyNames(final Class<?> clazz) {
return linkers.get(clazz).getReadablePropertyNames();
}
static Collection<String> getWritableStaticPropertyNames(Class<?> clazz) {
static Collection<String> getWritableStaticPropertyNames(final Class<?> clazz) {
return linkers.get(clazz).getWritablePropertyNames();
}
static Collection<String> getStaticMethodNames(Class<?> clazz) {
static Collection<String> getStaticMethodNames(final Class<?> clazz) {
return linkers.get(clazz).getMethodNames();
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest request, LinkerServices linkerServices) throws Exception {
public GuardedInvocation getGuardedInvocation(final LinkRequest request, final LinkerServices linkerServices) throws Exception {
final Object receiver = request.getReceiver();
if(receiver instanceof StaticClass) {
return linkers.get(((StaticClass)receiver).getRepresentedClass()).getGuardedInvocation(request,
@ -185,7 +185,7 @@ class StaticClassLinker implements TypeBasedGuardingDynamicLinker {
}
@Override
public boolean canLinkType(Class<?> type) {
public boolean canLinkType(final Class<?> type) {
return type == StaticClass.class;
}
@ -201,7 +201,7 @@ class StaticClassLinker implements TypeBasedGuardingDynamicLinker {
}
@SuppressWarnings("unused")
private static boolean isClass(Class<?> clazz, Object obj) {
private static boolean isClass(final Class<?> clazz, final Object obj) {
return obj instanceof StaticClass && ((StaticClass)obj).getRepresentedClass() == clazz;
}
}

View File

@ -91,7 +91,6 @@ import java.lang.invoke.MethodType;
import java.lang.invoke.SwitchPoint;
import java.lang.invoke.WrongMethodTypeException;
import java.util.List;
import jdk.internal.dynalink.CallSiteDescriptor;
import jdk.internal.dynalink.support.Guards;

View File

@ -192,7 +192,7 @@ public interface LinkerServices {
* @param fromType the passed type
* @return the converted method handle, as per the {@code asTypeSafeReturn} semantics.
*/
public static MethodHandle asTypeLosslessReturn(LinkerServices linkerServices, MethodHandle handle, MethodType fromType) {
public static MethodHandle asTypeLosslessReturn(final LinkerServices linkerServices, final MethodHandle handle, final MethodType fromType) {
final Class<?> handleReturnType = handle.type().returnType();
return linkerServices.asType(handle, TypeUtilities.isConvertibleWithoutLoss(handleReturnType, fromType.returnType()) ?
fromType : fromType.changeReturnType(handleReturnType));

View File

@ -106,7 +106,7 @@ public abstract class AbstractCallSiteDescriptor implements CallSiteDescriptor {
}
@Override
public boolean equals(Object obj) {
public boolean equals(final Object obj) {
return obj instanceof CallSiteDescriptor && equals((CallSiteDescriptor)obj);
}
@ -115,7 +115,7 @@ public abstract class AbstractCallSiteDescriptor implements CallSiteDescriptor {
* @param csd the other call site descriptor.
* @return true if they are equal.
*/
public boolean equals(CallSiteDescriptor csd) {
public boolean equals(final CallSiteDescriptor csd) {
if(csd == null) {
return false;
}
@ -165,7 +165,7 @@ public abstract class AbstractCallSiteDescriptor implements CallSiteDescriptor {
return l + c - 1;
}
private StringBuilder appendName(StringBuilder b) {
private StringBuilder appendName(final StringBuilder b) {
b.append(getNameToken(0));
final int c = getNameTokenCount();
for(int i = 1; i < c; ++i) {
@ -174,7 +174,7 @@ public abstract class AbstractCallSiteDescriptor implements CallSiteDescriptor {
return b;
}
private static boolean lookupsEqual(Lookup l1, Lookup l2) {
private static boolean lookupsEqual(final Lookup l1, final Lookup l2) {
if(l1 == l2) {
return true;
}

View File

@ -100,7 +100,7 @@ public abstract class AbstractRelinkableCallSite extends MutableCallSite impleme
* Creates a new relinkable call site.
* @param descriptor the descriptor for this call site
*/
protected AbstractRelinkableCallSite(CallSiteDescriptor descriptor) {
protected AbstractRelinkableCallSite(final CallSiteDescriptor descriptor) {
super(descriptor.getMethodType());
this.descriptor = descriptor;
}
@ -111,7 +111,7 @@ public abstract class AbstractRelinkableCallSite extends MutableCallSite impleme
}
@Override
public void initialize(MethodHandle relinkAndInvoke) {
public void initialize(final MethodHandle relinkAndInvoke) {
setTarget(relinkAndInvoke);
}
}

View File

@ -116,14 +116,14 @@ public class AutoDiscovery {
* @return a list of guarding dynamic linkers available through the specified class loader. Can be zero-length list
* but not null.
*/
public static List<GuardingDynamicLinker> loadLinkers(ClassLoader cl) {
public static List<GuardingDynamicLinker> loadLinkers(final ClassLoader cl) {
return getLinkers(ServiceLoader.load(GuardingDynamicLinker.class, cl));
}
/**
* I can't believe there's no Collections API for making a List given an Iterator...
*/
private static <T> List<T> getLinkers(ServiceLoader<T> loader) {
private static <T> List<T> getLinkers(final ServiceLoader<T> loader) {
final List<T> list = new LinkedList<>();
for(final T linker: loader) {
list.add(linker);

View File

@ -105,12 +105,12 @@ public class BottomGuardingDynamicLinker implements TypeBasedGuardingDynamicLink
}
@Override
public boolean canLinkType(Class<?> type) {
public boolean canLinkType(final Class<?> type) {
return false;
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, LinkerServices linkerServices) {
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) {
return null;
}
}

View File

@ -122,7 +122,7 @@ public class CallSiteDescriptorFactory {
* @return a call site descriptor representing the input. Note that although the method name is "create", it will
* in fact return a weakly-referenced canonical instance.
*/
public static CallSiteDescriptor create(Lookup lookup, String name, MethodType methodType) {
public static CallSiteDescriptor create(final Lookup lookup, final String name, final MethodType methodType) {
name.getClass(); // NPE check
methodType.getClass(); // NPE check
lookup.getClass(); // NPE check
@ -156,7 +156,7 @@ public class CallSiteDescriptorFactory {
return new WeakReference<>(desc);
}
private static CallSiteDescriptor createPublicCallSiteDescriptor(String[] tokenizedName, MethodType methodType) {
private static CallSiteDescriptor createPublicCallSiteDescriptor(final String[] tokenizedName, final MethodType methodType) {
final int l = tokenizedName.length;
if(l > 0 && tokenizedName[0] == "dyn") {
if(l == 2) {
@ -168,7 +168,7 @@ public class CallSiteDescriptorFactory {
return new DefaultCallSiteDescriptor(tokenizedName, methodType);
}
private static boolean isPublicLookup(Lookup lookup) {
private static boolean isPublicLookup(final Lookup lookup) {
return lookup == MethodHandles.publicLookup();
}
@ -179,7 +179,7 @@ public class CallSiteDescriptorFactory {
* @param name the composite name consisting of colon-separated, possibly mangled tokens.
* @return an array of tokens
*/
public static String[] tokenizeName(String name) {
public static String[] tokenizeName(final String name) {
final StringTokenizer tok = new StringTokenizer(name, CallSiteDescriptor.TOKEN_DELIMITER);
final String[] tokens = new String[tok.countTokens()];
for(int i = 0; i < tokens.length; ++i) {
@ -198,7 +198,7 @@ public class CallSiteDescriptorFactory {
* @param desc the call site descriptor with the operation
* @return a list of tokens
*/
public static List<String> tokenizeOperators(CallSiteDescriptor desc) {
public static List<String> tokenizeOperators(final CallSiteDescriptor desc) {
final String ops = desc.getNameToken(CallSiteDescriptor.OPERATOR);
final StringTokenizer tok = new StringTokenizer(ops, CallSiteDescriptor.OPERATOR_DELIMITER);
final int count = tok.countTokens();
@ -220,7 +220,7 @@ public class CallSiteDescriptorFactory {
* @param end index of the first parameter to not remove
* @return a new call site descriptor with modified method type
*/
public static CallSiteDescriptor dropParameterTypes(CallSiteDescriptor desc, int start, int end) {
public static CallSiteDescriptor dropParameterTypes(final CallSiteDescriptor desc, final int start, final int end) {
return desc.changeMethodType(desc.getMethodType().dropParameterTypes(start, end));
}
@ -232,7 +232,7 @@ public class CallSiteDescriptorFactory {
* @param nptype the new parameter type
* @return a new call site descriptor with modified method type
*/
public static CallSiteDescriptor changeParameterType(CallSiteDescriptor desc, int num, Class<?> nptype) {
public static CallSiteDescriptor changeParameterType(final CallSiteDescriptor desc, final int num, final Class<?> nptype) {
return desc.changeMethodType(desc.getMethodType().changeParameterType(num, nptype));
}
@ -243,7 +243,7 @@ public class CallSiteDescriptorFactory {
* @param nrtype the new return type
* @return a new call site descriptor with modified method type
*/
public static CallSiteDescriptor changeReturnType(CallSiteDescriptor desc, Class<?> nrtype) {
public static CallSiteDescriptor changeReturnType(final CallSiteDescriptor desc, final Class<?> nrtype) {
return desc.changeMethodType(desc.getMethodType().changeReturnType(nrtype));
}
@ -255,7 +255,7 @@ public class CallSiteDescriptorFactory {
* @param ptypesToInsert the new types to insert
* @return a new call site descriptor with modified method type
*/
public static CallSiteDescriptor insertParameterTypes(CallSiteDescriptor desc, int num, Class<?>... ptypesToInsert) {
public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final Class<?>... ptypesToInsert) {
return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}
@ -267,7 +267,7 @@ public class CallSiteDescriptorFactory {
* @param ptypesToInsert the new types to insert
* @return a new call site descriptor with modified method type
*/
public static CallSiteDescriptor insertParameterTypes(CallSiteDescriptor desc, int num, List<Class<?>> ptypesToInsert) {
public static CallSiteDescriptor insertParameterTypes(final CallSiteDescriptor desc, final int num, final List<Class<?>> ptypesToInsert) {
return desc.changeMethodType(desc.getMethodType().insertParameterTypes(num, ptypesToInsert));
}
}

View File

@ -110,7 +110,7 @@ public abstract class ClassMap<T> {
*
* @param classLoader the classloader that determines strong referenceability.
*/
protected ClassMap(ClassLoader classLoader) {
protected ClassMap(final ClassLoader classLoader) {
this.classLoader = classLoader;
}

View File

@ -109,16 +109,16 @@ public class CompositeGuardingDynamicLinker implements GuardingDynamicLinker, Se
*
* @param linkers a list of component linkers.
*/
public CompositeGuardingDynamicLinker(Iterable<? extends GuardingDynamicLinker> linkers) {
public CompositeGuardingDynamicLinker(final Iterable<? extends GuardingDynamicLinker> linkers) {
final List<GuardingDynamicLinker> l = new LinkedList<>();
for(GuardingDynamicLinker linker: linkers) {
for(final GuardingDynamicLinker linker: linkers) {
l.add(linker);
}
this.linkers = l.toArray(new GuardingDynamicLinker[l.size()]);
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, final LinkerServices linkerServices)
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
throws Exception {
for(final GuardingDynamicLinker linker: linkers) {
final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);

View File

@ -112,7 +112,7 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin
private final List<TypeBasedGuardingDynamicLinker>[] singletonLinkers;
@SuppressWarnings("unchecked")
ClassToLinker(TypeBasedGuardingDynamicLinker[] linkers) {
ClassToLinker(final TypeBasedGuardingDynamicLinker[] linkers) {
this.linkers = linkers;
singletonLinkers = new List[linkers.length];
for(int i = 0; i < linkers.length; ++i) {
@ -121,7 +121,7 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin
}
@Override
protected List<TypeBasedGuardingDynamicLinker> computeValue(Class<?> clazz) {
protected List<TypeBasedGuardingDynamicLinker> computeValue(final Class<?> clazz) {
List<TypeBasedGuardingDynamicLinker> list = NO_LINKER;
for(int i = 0; i < linkers.length; ++i) {
final TypeBasedGuardingDynamicLinker linker = linkers[i];
@ -152,27 +152,27 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin
*
* @param linkers the component linkers
*/
public CompositeTypeBasedGuardingDynamicLinker(Iterable<? extends TypeBasedGuardingDynamicLinker> linkers) {
public CompositeTypeBasedGuardingDynamicLinker(final Iterable<? extends TypeBasedGuardingDynamicLinker> linkers) {
final List<TypeBasedGuardingDynamicLinker> l = new LinkedList<>();
for(TypeBasedGuardingDynamicLinker linker: linkers) {
for(final TypeBasedGuardingDynamicLinker linker: linkers) {
l.add(linker);
}
this.classToLinker = new ClassToLinker(l.toArray(new TypeBasedGuardingDynamicLinker[l.size()]));
}
@Override
public boolean canLinkType(Class<?> type) {
public boolean canLinkType(final Class<?> type) {
return !classToLinker.get(type).isEmpty();
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, final LinkerServices linkerServices)
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices)
throws Exception {
final Object obj = linkRequest.getReceiver();
if(obj == null) {
return null;
}
for(TypeBasedGuardingDynamicLinker linker: classToLinker.get(obj.getClass())) {
for(final TypeBasedGuardingDynamicLinker linker: classToLinker.get(obj.getClass())) {
final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
if(invocation != null) {
return invocation;
@ -189,10 +189,10 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin
* @param linkers the list of linkers to optimize
* @return the optimized list
*/
public static List<GuardingDynamicLinker> optimize(Iterable<? extends GuardingDynamicLinker> linkers) {
public static List<GuardingDynamicLinker> optimize(final Iterable<? extends GuardingDynamicLinker> linkers) {
final List<GuardingDynamicLinker> llinkers = new LinkedList<>();
final List<TypeBasedGuardingDynamicLinker> tblinkers = new LinkedList<>();
for(GuardingDynamicLinker linker: linkers) {
for(final GuardingDynamicLinker linker: linkers) {
if(linker instanceof TypeBasedGuardingDynamicLinker) {
tblinkers.add((TypeBasedGuardingDynamicLinker)linker);
} else {
@ -204,8 +204,8 @@ public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardin
return llinkers;
}
private static void addTypeBased(List<GuardingDynamicLinker> llinkers,
List<TypeBasedGuardingDynamicLinker> tblinkers) {
private static void addTypeBased(final List<GuardingDynamicLinker> llinkers,
final List<TypeBasedGuardingDynamicLinker> tblinkers) {
switch(tblinkers.size()) {
case 0: {
break;

View File

@ -98,7 +98,7 @@ class DefaultCallSiteDescriptor extends AbstractCallSiteDescriptor {
private final String[] tokenizedName;
private final MethodType methodType;
DefaultCallSiteDescriptor(String[] tokenizedName, MethodType methodType) {
DefaultCallSiteDescriptor(final String[] tokenizedName, final MethodType methodType) {
this.tokenizedName = tokenizedName;
this.methodType = methodType;
}
@ -109,10 +109,10 @@ class DefaultCallSiteDescriptor extends AbstractCallSiteDescriptor {
}
@Override
public String getNameToken(int i) {
public String getNameToken(final int i) {
try {
return tokenizedName[i];
} catch(ArrayIndexOutOfBoundsException e) {
} catch(final ArrayIndexOutOfBoundsException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
@ -127,7 +127,7 @@ class DefaultCallSiteDescriptor extends AbstractCallSiteDescriptor {
}
@Override
public CallSiteDescriptor changeMethodType(MethodType newMethodType) {
public CallSiteDescriptor changeMethodType(final MethodType newMethodType) {
return CallSiteDescriptorFactory.getCanonicalPublicDescriptor(new DefaultCallSiteDescriptor(tokenizedName,
newMethodType));
}

View File

@ -93,7 +93,7 @@ import jdk.internal.dynalink.linker.LinkerServices;
*/
public class DefaultPrelinkFilter implements GuardedInvocationFilter {
@Override
public GuardedInvocation filter(GuardedInvocation inv, LinkRequest request, LinkerServices linkerServices) {
public GuardedInvocation filter(final GuardedInvocation inv, final LinkRequest request, final LinkerServices linkerServices) {
return inv.asType(linkerServices, request.getCallSiteDescriptor().getMethodType());
}
}

View File

@ -113,7 +113,7 @@ public class Guards {
* @return a method handle testing whether its first argument is of the specified class.
*/
@SuppressWarnings("boxing")
public static MethodHandle isOfClass(Class<?> clazz, MethodType type) {
public static MethodHandle isOfClass(final Class<?> clazz, final MethodType type) {
final Class<?> declaredType = type.parameterType(0);
if(clazz == declaredType) {
LOG.log(Level.WARNING, "isOfClassGuardAlwaysTrue", new Object[] { clazz.getName(), 0, type, DynamicLinker.getLinkedCallSiteLocation() });
@ -135,7 +135,7 @@ public class Guards {
* @param type the method type
* @return a method handle testing whether its first argument is of the specified class or subclass.
*/
public static MethodHandle isInstance(Class<?> clazz, MethodType type) {
public static MethodHandle isInstance(final Class<?> clazz, final MethodType type) {
return isInstance(clazz, 0, type);
}
@ -150,7 +150,7 @@ public class Guards {
* @return a method handle testing whether its first argument is of the specified class or subclass.
*/
@SuppressWarnings("boxing")
public static MethodHandle isInstance(Class<?> clazz, int pos, MethodType type) {
public static MethodHandle isInstance(final Class<?> clazz, final int pos, final MethodType type) {
final Class<?> declaredType = type.parameterType(pos);
if(clazz.isAssignableFrom(declaredType)) {
LOG.log(Level.WARNING, "isInstanceGuardAlwaysTrue", new Object[] { clazz.getName(), pos, type, DynamicLinker.getLinkedCallSiteLocation() });
@ -172,7 +172,7 @@ public class Guards {
* the arguments are ignored.
*/
@SuppressWarnings("boxing")
public static MethodHandle isArray(int pos, MethodType type) {
public static MethodHandle isArray(final int pos, final MethodType type) {
final Class<?> declaredType = type.parameterType(pos);
if(declaredType.isArray()) {
LOG.log(Level.WARNING, "isArrayGuardAlwaysTrue", new Object[] { pos, type, DynamicLinker.getLinkedCallSiteLocation() });
@ -193,7 +193,7 @@ public class Guards {
* @param referredLoader the referred class loader
* @return true if it is safe to strongly reference the class
*/
public static boolean canReferenceDirectly(ClassLoader referrerLoader, final ClassLoader referredLoader) {
public static boolean canReferenceDirectly(final ClassLoader referrerLoader, final ClassLoader referredLoader) {
if(referredLoader == null) {
// Can always refer directly to a system class
return true;
@ -215,7 +215,7 @@ public class Guards {
return false;
}
private static MethodHandle getClassBoundArgumentTest(MethodHandle test, Class<?> clazz, int pos, MethodType type) {
private static MethodHandle getClassBoundArgumentTest(final MethodHandle test, final Class<?> clazz, final int pos, final MethodType type) {
// Bind the class to the first argument of the test
return asType(test.bindTo(clazz), pos, type);
}
@ -227,7 +227,7 @@ public class Guards {
* @param type the type to adapt the method handle to
* @return the adapted method handle
*/
public static MethodHandle asType(MethodHandle test, MethodType type) {
public static MethodHandle asType(final MethodHandle test, final MethodType type) {
return test.asType(getTestType(test, type));
}
@ -239,16 +239,16 @@ public class Guards {
* @param type the type to adapt the method handle to
* @return the adapted method handle
*/
public static MethodHandle asType(LinkerServices linkerServices, MethodHandle test, MethodType type) {
public static MethodHandle asType(final LinkerServices linkerServices, final MethodHandle test, final MethodType type) {
return linkerServices.asType(test, getTestType(test, type));
}
private static MethodType getTestType(MethodHandle test, MethodType type) {
private static MethodType getTestType(final MethodHandle test, final MethodType type) {
return type.dropParameterTypes(test.type().parameterCount(),
type.parameterCount()).changeReturnType(boolean.class);
}
private static MethodHandle asType(MethodHandle test, int pos, MethodType type) {
private static MethodHandle asType(final MethodHandle test, final int pos, final MethodType type) {
assert test != null;
assert type != null;
assert type.parameterCount() > 0;
@ -283,7 +283,7 @@ public class Guards {
* @param clazz the class to test for.
* @return the desired guard method.
*/
public static MethodHandle getClassGuard(Class<?> clazz) {
public static MethodHandle getClassGuard(final Class<?> clazz) {
return IS_OF_CLASS.bindTo(clazz);
}
@ -292,7 +292,7 @@ public class Guards {
* @param clazz the class to test for.
* @return the desired guard method.
*/
public static MethodHandle getInstanceOfGuard(Class<?> clazz) {
public static MethodHandle getInstanceOfGuard(final Class<?> clazz) {
return IS_INSTANCE.bindTo(clazz);
}
@ -301,7 +301,7 @@ public class Guards {
* @param obj the object used as referential identity test
* @return the desired guard method.
*/
public static MethodHandle getIdentityGuard(Object obj) {
public static MethodHandle getIdentityGuard(final Object obj) {
return IS_IDENTICAL.bindTo(obj);
}
@ -322,39 +322,39 @@ public class Guards {
}
@SuppressWarnings("unused")
private static boolean isNull(Object obj) {
private static boolean isNull(final Object obj) {
return obj == null;
}
@SuppressWarnings("unused")
private static boolean isNotNull(Object obj) {
private static boolean isNotNull(final Object obj) {
return obj != null;
}
@SuppressWarnings("unused")
private static boolean isArray(Object o) {
private static boolean isArray(final Object o) {
return o != null && o.getClass().isArray();
}
@SuppressWarnings("unused")
private static boolean isOfClass(Class<?> c, Object o) {
private static boolean isOfClass(final Class<?> c, final Object o) {
return o != null && o.getClass() == c;
}
@SuppressWarnings("unused")
private static boolean isIdentical(Object o1, Object o2) {
private static boolean isIdentical(final Object o1, final Object o2) {
return o1 == o2;
}
private static MethodHandle constantTrue(MethodType type) {
private static MethodHandle constantTrue(final MethodType type) {
return constantBoolean(Boolean.TRUE, type);
}
private static MethodHandle constantFalse(MethodType type) {
private static MethodHandle constantFalse(final MethodType type) {
return constantBoolean(Boolean.FALSE, type);
}
private static MethodHandle constantBoolean(Boolean value, MethodType type) {
private static MethodHandle constantBoolean(final Boolean value, final MethodType type) {
return MethodHandles.permuteArguments(MethodHandles.constant(Boolean.TYPE, value),
type.changeReturnType(Boolean.TYPE));
}

View File

@ -109,7 +109,7 @@ public class LinkRequestImpl implements LinkRequest {
* @param callSiteUnstable true if the call site being linked is considered unstable
* @param arguments the arguments for the invocation
*/
public LinkRequestImpl(CallSiteDescriptor callSiteDescriptor, Object callSiteToken, int linkCount, boolean callSiteUnstable, Object... arguments) {
public LinkRequestImpl(final CallSiteDescriptor callSiteDescriptor, final Object callSiteToken, final int linkCount, final boolean callSiteUnstable, final Object... arguments) {
this.callSiteDescriptor = callSiteDescriptor;
this.callSiteToken = callSiteToken;
this.linkCount = linkCount;
@ -153,7 +153,7 @@ public class LinkRequestImpl implements LinkRequest {
}
@Override
public LinkRequest replaceArguments(CallSiteDescriptor newCallSiteDescriptor, Object[] newArguments) {
public LinkRequest replaceArguments(final CallSiteDescriptor newCallSiteDescriptor, final Object[] newArguments) {
return new LinkRequestImpl(newCallSiteDescriptor, callSiteToken, linkCount, callSiteUnstable, newArguments);
}
}

View File

@ -117,32 +117,32 @@ public class LinkerServicesImpl implements LinkerServices {
}
@Override
public boolean canConvert(Class<?> from, Class<?> to) {
public boolean canConvert(final Class<?> from, final Class<?> to) {
return typeConverterFactory.canConvert(from, to);
}
@Override
public MethodHandle asType(MethodHandle handle, MethodType fromType) {
public MethodHandle asType(final MethodHandle handle, final MethodType fromType) {
return typeConverterFactory.asType(handle, fromType);
}
@Override
public MethodHandle asTypeLosslessReturn(MethodHandle handle, MethodType fromType) {
public MethodHandle asTypeLosslessReturn(final MethodHandle handle, final MethodType fromType) {
return Implementation.asTypeLosslessReturn(this, handle, fromType);
}
@Override
public MethodHandle getTypeConverter(Class<?> sourceType, Class<?> targetType) {
public MethodHandle getTypeConverter(final Class<?> sourceType, final Class<?> targetType) {
return typeConverterFactory.getTypeConverter(sourceType, targetType);
}
@Override
public Comparison compareConversion(Class<?> sourceType, Class<?> targetType1, Class<?> targetType2) {
public Comparison compareConversion(final Class<?> sourceType, final Class<?> targetType1, final Class<?> targetType2) {
return typeConverterFactory.compareConversion(sourceType, targetType1, targetType2);
}
@Override
public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest) throws Exception {
public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest) throws Exception {
final LinkRequest prevLinkRequest = threadLinkRequest.get();
threadLinkRequest.set(linkRequest);
try {
@ -159,7 +159,7 @@ public class LinkerServicesImpl implements LinkerServices {
* permission.
*/
public static LinkRequest getCurrentLinkRequest() {
SecurityManager sm = System.getSecurityManager();
final SecurityManager sm = System.getSecurityManager();
if(sm != null) {
sm.checkPermission(GET_CURRENT_LINK_REQUEST);
}

View File

@ -104,7 +104,7 @@ public class Lookup {
*
* @param lookup the {@link java.lang.invoke.MethodHandles.Lookup} it delegates to.
*/
public Lookup(MethodHandles.Lookup lookup) {
public Lookup(final MethodHandles.Lookup lookup) {
this.lookup = lookup;
}
@ -120,7 +120,7 @@ public class Lookup {
* @param m the method to unreflect
* @return the unreflected method handle.
*/
public MethodHandle unreflect(Method m) {
public MethodHandle unreflect(final Method m) {
return unreflect(lookup, m);
}
@ -132,10 +132,10 @@ public class Lookup {
* @param m the method to unreflect
* @return the unreflected method handle.
*/
public static MethodHandle unreflect(MethodHandles.Lookup lookup, Method m) {
public static MethodHandle unreflect(final MethodHandles.Lookup lookup, final Method m) {
try {
return lookup.unreflect(m);
} catch(IllegalAccessException e) {
} catch(final IllegalAccessException e) {
final IllegalAccessError ee = new IllegalAccessError("Failed to unreflect method " + m);
ee.initCause(e);
throw ee;
@ -149,10 +149,10 @@ public class Lookup {
* @param f the field for which a getter is unreflected
* @return the unreflected field getter handle.
*/
public MethodHandle unreflectGetter(Field f) {
public MethodHandle unreflectGetter(final Field f) {
try {
return lookup.unreflectGetter(f);
} catch(IllegalAccessException e) {
} catch(final IllegalAccessException e) {
final IllegalAccessError ee = new IllegalAccessError("Failed to unreflect getter for field " + f);
ee.initCause(e);
throw ee;
@ -171,15 +171,15 @@ public class Lookup {
* @throws IllegalAccessError if the field is inaccessible.
* @throws NoSuchFieldError if the field does not exist.
*/
public MethodHandle findGetter(Class<?>refc, String name, Class<?> type) {
public MethodHandle findGetter(final Class<?>refc, final String name, final Class<?> type) {
try {
return lookup.findGetter(refc, name, type);
} catch(IllegalAccessException e) {
} catch(final IllegalAccessException e) {
final IllegalAccessError ee = new IllegalAccessError("Failed to access getter for field " + refc.getName() +
"." + name + " of type " + type.getName());
ee.initCause(e);
throw ee;
} catch(NoSuchFieldException e) {
} catch(final NoSuchFieldException e) {
final NoSuchFieldError ee = new NoSuchFieldError("Failed to find getter for field " + refc.getName() +
"." + name + " of type " + type.getName());
ee.initCause(e);
@ -194,10 +194,10 @@ public class Lookup {
* @param f the field for which a setter is unreflected
* @return the unreflected field setter handle.
*/
public MethodHandle unreflectSetter(Field f) {
public MethodHandle unreflectSetter(final Field f) {
try {
return lookup.unreflectSetter(f);
} catch(IllegalAccessException e) {
} catch(final IllegalAccessException e) {
final IllegalAccessError ee = new IllegalAccessError("Failed to unreflect setter for field " + f);
ee.initCause(e);
throw ee;
@ -211,7 +211,7 @@ public class Lookup {
* @param c the constructor to unreflect
* @return the unreflected constructor handle.
*/
public MethodHandle unreflectConstructor(Constructor<?> c) {
public MethodHandle unreflectConstructor(final Constructor<?> c) {
return unreflectConstructor(lookup, c);
}
@ -223,10 +223,10 @@ public class Lookup {
* @param c the constructor to unreflect
* @return the unreflected constructor handle.
*/
public static MethodHandle unreflectConstructor(MethodHandles.Lookup lookup, Constructor<?> c) {
public static MethodHandle unreflectConstructor(final MethodHandles.Lookup lookup, final Constructor<?> c) {
try {
return lookup.unreflectConstructor(c);
} catch(IllegalAccessException e) {
} catch(final IllegalAccessException e) {
final IllegalAccessError ee = new IllegalAccessError("Failed to unreflect constructor " + c);
ee.initCause(e);
throw ee;
@ -244,15 +244,15 @@ public class Lookup {
* @throws IllegalAccessError if the method is inaccessible.
* @throws NoSuchMethodError if the method does not exist.
*/
public MethodHandle findSpecial(Class<?> declaringClass, String name, MethodType type) {
public MethodHandle findSpecial(final Class<?> declaringClass, final String name, final MethodType type) {
try {
return lookup.findSpecial(declaringClass, name, type, declaringClass);
} catch(IllegalAccessException e) {
} catch(final IllegalAccessException e) {
final IllegalAccessError ee = new IllegalAccessError("Failed to access special method " + methodDescription(
declaringClass, name, type));
ee.initCause(e);
throw ee;
} catch(NoSuchMethodException e) {
} catch(final NoSuchMethodException e) {
final NoSuchMethodError ee = new NoSuchMethodError("Failed to find special method " + methodDescription(
declaringClass, name, type));
ee.initCause(e);
@ -260,7 +260,7 @@ public class Lookup {
}
}
private static String methodDescription(Class<?> declaringClass, String name, MethodType type) {
private static String methodDescription(final Class<?> declaringClass, final String name, final MethodType type) {
return declaringClass.getName() + "#" + name + type;
}
@ -275,15 +275,15 @@ public class Lookup {
* @throws IllegalAccessError if the method is inaccessible.
* @throws NoSuchMethodError if the method does not exist.
*/
public MethodHandle findStatic(Class<?> declaringClass, String name, MethodType type) {
public MethodHandle findStatic(final Class<?> declaringClass, final String name, final MethodType type) {
try {
return lookup.findStatic(declaringClass, name, type);
} catch(IllegalAccessException e) {
} catch(final IllegalAccessException e) {
final IllegalAccessError ee = new IllegalAccessError("Failed to access static method " + methodDescription(
declaringClass, name, type));
ee.initCause(e);
throw ee;
} catch(NoSuchMethodException e) {
} catch(final NoSuchMethodException e) {
final NoSuchMethodError ee = new NoSuchMethodError("Failed to find static method " + methodDescription(
declaringClass, name, type));
ee.initCause(e);
@ -302,15 +302,15 @@ public class Lookup {
* @throws IllegalAccessError if the method is inaccessible.
* @throws NoSuchMethodError if the method does not exist.
*/
public MethodHandle findVirtual(Class<?> declaringClass, String name, MethodType type) {
public MethodHandle findVirtual(final Class<?> declaringClass, final String name, final MethodType type) {
try {
return lookup.findVirtual(declaringClass, name, type);
} catch(IllegalAccessException e) {
} catch(final IllegalAccessException e) {
final IllegalAccessError ee = new IllegalAccessError("Failed to access virtual method " + methodDescription(
declaringClass, name, type));
ee.initCause(e);
throw ee;
} catch(NoSuchMethodException e) {
} catch(final NoSuchMethodException e) {
final NoSuchMethodError ee = new NoSuchMethodError("Failed to find virtual method " + methodDescription(
declaringClass, name, type));
ee.initCause(e);
@ -327,7 +327,7 @@ public class Lookup {
* @param ptypes the parameter types of the method
* @return the method handle for the method
*/
public static MethodHandle findOwnSpecial(MethodHandles.Lookup lookup, String name, Class<?> rtype, Class<?>... ptypes) {
public static MethodHandle findOwnSpecial(final MethodHandles.Lookup lookup, final String name, final Class<?> rtype, final Class<?>... ptypes) {
return new Lookup(lookup).findOwnSpecial(name, rtype, ptypes);
}
@ -341,7 +341,7 @@ public class Lookup {
* @param ptypes the parameter types of the method
* @return the method handle for the method
*/
public MethodHandle findOwnSpecial(String name, Class<?> rtype, Class<?>... ptypes) {
public MethodHandle findOwnSpecial(final String name, final Class<?> rtype, final Class<?>... ptypes) {
return findSpecial(lookup.lookupClass(), name, MethodType.methodType(rtype, ptypes));
}
@ -355,7 +355,7 @@ public class Lookup {
* @param ptypes the parameter types of the method
* @return the method handle for the method
*/
public static MethodHandle findOwnStatic(MethodHandles.Lookup lookup, String name, Class<?> rtype, Class<?>... ptypes) {
public static MethodHandle findOwnStatic(final MethodHandles.Lookup lookup, final String name, final Class<?> rtype, final Class<?>... ptypes) {
return new Lookup(lookup).findOwnStatic(name, rtype, ptypes);
}
@ -368,7 +368,7 @@ public class Lookup {
* @param ptypes the parameter types of the method
* @return the method handle for the method
*/
public MethodHandle findOwnStatic(String name, Class<?> rtype, Class<?>... ptypes) {
public MethodHandle findOwnStatic(final String name, final Class<?> rtype, final Class<?>... ptypes) {
return findStatic(lookup.lookupClass(), name, MethodType.methodType(rtype, ptypes));
}
}

View File

@ -92,7 +92,7 @@ import jdk.internal.dynalink.CallSiteDescriptor;
* @author Attila Szegedi
*/
class LookupCallSiteDescriptor extends DefaultCallSiteDescriptor {
private Lookup lookup;
private final Lookup lookup;
/**
* Create a new call site descriptor from explicit information.
@ -100,7 +100,7 @@ class LookupCallSiteDescriptor extends DefaultCallSiteDescriptor {
* @param methodType the method type
* @param lookup the lookup
*/
LookupCallSiteDescriptor(String[] tokenizedName, MethodType methodType, Lookup lookup) {
LookupCallSiteDescriptor(final String[] tokenizedName, final MethodType methodType, final Lookup lookup) {
super(tokenizedName, methodType);
this.lookup = lookup;
}
@ -111,7 +111,7 @@ class LookupCallSiteDescriptor extends DefaultCallSiteDescriptor {
}
@Override
public CallSiteDescriptor changeMethodType(MethodType newMethodType) {
public CallSiteDescriptor changeMethodType(final MethodType newMethodType) {
return new LookupCallSiteDescriptor(getTokenizedName(), newMethodType, lookup);
}
}

View File

@ -137,7 +137,7 @@ public class NameCodec {
* @param name the symbolic name to mangle
* @return the mangled form of the symbolic name.
*/
public static String encode(String name) {
public static String encode(final String name) {
final int l = name.length();
if(l == 0) {
return EMPTY_NAME;
@ -176,7 +176,7 @@ public class NameCodec {
* @param name the symbolic name to demangle
* @return the demangled form of the symbolic name.
*/
public static String decode(String name) {
public static String decode(final String name) {
if(name.charAt(0) != ESCAPE_CHAR) {
return name;
}
@ -184,11 +184,11 @@ public class NameCodec {
if(l == 2 && name.charAt(1) == EMPTY_CHAR) {
return "";
}
StringBuilder b = new StringBuilder(name.length());
final StringBuilder b = new StringBuilder(name.length());
int lastEscape = -2;
int lastBackslash = -1;
for(;;) {
int nextBackslash = name.indexOf(ESCAPE_CHAR, lastBackslash + 1);
final int nextBackslash = name.indexOf(ESCAPE_CHAR, lastBackslash + 1);
if(nextBackslash == -1 || nextBackslash == l - 1) {
break;
}
@ -211,7 +211,7 @@ public class NameCodec {
return b.toString();
}
private static void addEncoding(char from, char to) {
private static void addEncoding(final char from, final char to) {
ENCODING[from - MIN_ENCODING] = to;
DECODING[to - MIN_DECODING] = from;
}

View File

@ -89,7 +89,7 @@ import jdk.internal.dynalink.CallSiteDescriptor;
class NamedDynCallSiteDescriptor extends UnnamedDynCallSiteDescriptor {
private final String name;
NamedDynCallSiteDescriptor(String op, String name, MethodType methodType) {
NamedDynCallSiteDescriptor(final String op, final String name, final MethodType methodType) {
super(op, methodType);
this.name = name;
}
@ -100,7 +100,7 @@ class NamedDynCallSiteDescriptor extends UnnamedDynCallSiteDescriptor {
}
@Override
public String getNameToken(int i) {
public String getNameToken(final int i) {
switch(i) {
case 0: return "dyn";
case 1: return getOp();
@ -110,7 +110,7 @@ class NamedDynCallSiteDescriptor extends UnnamedDynCallSiteDescriptor {
}
@Override
public CallSiteDescriptor changeMethodType(MethodType newMethodType) {
public CallSiteDescriptor changeMethodType(final MethodType newMethodType) {
return CallSiteDescriptorFactory.getCanonicalPublicDescriptor(new NamedDynCallSiteDescriptor(getOp(), name,
newMethodType));
}

View File

@ -109,8 +109,8 @@ public class RuntimeContextLinkRequestImpl extends LinkRequestImpl {
* runtime specific context arguments.
* @throws IllegalArgumentException if runtimeContextArgCount is less than 1.
*/
public RuntimeContextLinkRequestImpl(CallSiteDescriptor callSiteDescriptor, Object callSiteToken,
int linkCount, boolean callSiteUnstable, Object[] arguments, int runtimeContextArgCount) {
public RuntimeContextLinkRequestImpl(final CallSiteDescriptor callSiteDescriptor, final Object callSiteToken,
final int linkCount, final boolean callSiteUnstable, final Object[] arguments, final int runtimeContextArgCount) {
super(callSiteDescriptor, callSiteToken, linkCount, callSiteUnstable, arguments);
if(runtimeContextArgCount < 1) {
throw new IllegalArgumentException("runtimeContextArgCount < 1");
@ -129,7 +129,7 @@ public class RuntimeContextLinkRequestImpl extends LinkRequestImpl {
}
@Override
public LinkRequest replaceArguments(CallSiteDescriptor callSiteDescriptor, Object[] arguments) {
public LinkRequest replaceArguments(final CallSiteDescriptor callSiteDescriptor, final Object[] arguments) {
return new RuntimeContextLinkRequestImpl(callSiteDescriptor, getCallSiteToken(), getLinkCount(), isCallSiteUnstable(), arguments,
runtimeContextArgCount);
}

View File

@ -91,7 +91,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.LinkedList;
import java.util.List;
import jdk.internal.dynalink.linker.ConversionComparator;
import jdk.internal.dynalink.linker.ConversionComparator.Comparison;
import jdk.internal.dynalink.linker.GuardedInvocation;
@ -116,12 +115,12 @@ public class TypeConverterFactory {
protected ClassMap<MethodHandle> computeValue(final Class<?> sourceType) {
return new ClassMap<MethodHandle>(getClassLoader(sourceType)) {
@Override
protected MethodHandle computeValue(Class<?> targetType) {
protected MethodHandle computeValue(final Class<?> targetType) {
try {
return createConverter(sourceType, targetType);
} catch (RuntimeException e) {
} catch (final RuntimeException e) {
throw e;
} catch (Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -134,7 +133,7 @@ public class TypeConverterFactory {
protected ClassMap<MethodHandle> computeValue(final Class<?> sourceType) {
return new ClassMap<MethodHandle>(getClassLoader(sourceType)) {
@Override
protected MethodHandle computeValue(Class<?> targetType) {
protected MethodHandle computeValue(final Class<?> targetType) {
if(!canAutoConvert(sourceType, targetType)) {
final MethodHandle converter = getCacheableTypeConverter(sourceType, targetType);
if(converter != IDENTITY_CONVERSION) {
@ -152,12 +151,12 @@ public class TypeConverterFactory {
protected ClassMap<Boolean> computeValue(final Class<?> sourceType) {
return new ClassMap<Boolean>(getClassLoader(sourceType)) {
@Override
protected Boolean computeValue(Class<?> targetType) {
protected Boolean computeValue(final Class<?> targetType) {
try {
return getTypeConverterNull(sourceType, targetType) != null;
} catch (RuntimeException e) {
} catch (final RuntimeException e) {
throw e;
} catch (Exception e) {
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
@ -179,10 +178,10 @@ public class TypeConverterFactory {
*
* @param factories the {@link GuardingTypeConverterFactory} instances to compose.
*/
public TypeConverterFactory(Iterable<? extends GuardingTypeConverterFactory> factories) {
public TypeConverterFactory(final Iterable<? extends GuardingTypeConverterFactory> factories) {
final List<GuardingTypeConverterFactory> l = new LinkedList<>();
final List<ConversionComparator> c = new LinkedList<>();
for(GuardingTypeConverterFactory factory: factories) {
for(final GuardingTypeConverterFactory factory: factories) {
l.add(factory);
if(factory instanceof ConversionComparator) {
c.add((ConversionComparator)factory);
@ -207,7 +206,7 @@ public class TypeConverterFactory {
* {@link MethodHandles#filterArguments(MethodHandle, int, MethodHandle...)} with
* {@link GuardingTypeConverterFactory} produced type converters as filters.
*/
public MethodHandle asType(MethodHandle handle, final MethodType fromType) {
public MethodHandle asType(final MethodHandle handle, final MethodType fromType) {
MethodHandle newHandle = handle;
final MethodType toType = newHandle.type();
final int l = toType.parameterCount();
@ -251,7 +250,7 @@ public class TypeConverterFactory {
return newHandle.asType(fromType);
}
private static MethodHandle applyConverters(MethodHandle handle, int pos, List<MethodHandle> converters) {
private static MethodHandle applyConverters(final MethodHandle handle, final int pos, final List<MethodHandle> converters) {
if(converters.isEmpty()) {
return handle;
}
@ -286,8 +285,8 @@ public class TypeConverterFactory {
* @return one of Comparison constants that establish which - if any - of the target types is preferable for the
* conversion.
*/
public Comparison compareConversion(Class<?> sourceType, Class<?> targetType1, Class<?> targetType2) {
for(ConversionComparator comparator: comparators) {
public Comparison compareConversion(final Class<?> sourceType, final Class<?> targetType1, final Class<?> targetType2) {
for(final ConversionComparator comparator: comparators) {
final Comparison result = comparator.compareConversion(sourceType, targetType1, targetType2);
if(result != Comparison.INDETERMINATE) {
return result;
@ -314,20 +313,20 @@ public class TypeConverterFactory {
return TypeUtilities.isMethodInvocationConvertible(fromType, toType);
}
/*private*/ MethodHandle getCacheableTypeConverterNull(Class<?> sourceType, Class<?> targetType) {
/*private*/ MethodHandle getCacheableTypeConverterNull(final Class<?> sourceType, final Class<?> targetType) {
final MethodHandle converter = getCacheableTypeConverter(sourceType, targetType);
return converter == IDENTITY_CONVERSION ? null : converter;
}
/*private*/ MethodHandle getTypeConverterNull(Class<?> sourceType, Class<?> targetType) {
/*private*/ MethodHandle getTypeConverterNull(final Class<?> sourceType, final Class<?> targetType) {
try {
return getCacheableTypeConverterNull(sourceType, targetType);
} catch(NotCacheableConverter e) {
} catch(final NotCacheableConverter e) {
return e.converter;
}
}
/*private*/ MethodHandle getCacheableTypeConverter(Class<?> sourceType, Class<?> targetType) {
/*private*/ MethodHandle getCacheableTypeConverter(final Class<?> sourceType, final Class<?> targetType) {
return converterMap.get(sourceType).get(targetType);
}
@ -340,15 +339,15 @@ public class TypeConverterFactory {
* @param targetType the type to convert to
* @return a method handle performing the conversion.
*/
public MethodHandle getTypeConverter(Class<?> sourceType, Class<?> targetType) {
public MethodHandle getTypeConverter(final Class<?> sourceType, final Class<?> targetType) {
try {
return converterIdentityMap.get(sourceType).get(targetType);
} catch(NotCacheableConverter e) {
} catch(final NotCacheableConverter e) {
return e.converter;
}
}
/*private*/ MethodHandle createConverter(Class<?> sourceType, Class<?> targetType) throws Exception {
/*private*/ MethodHandle createConverter(final Class<?> sourceType, final Class<?> targetType) throws Exception {
final MethodType type = MethodType.methodType(targetType, sourceType);
final MethodHandle identity = IDENTITY_CONVERSION.asType(type);
MethodHandle last = identity;

View File

@ -115,7 +115,7 @@ public class TypeUtilities {
* unrelated superinterfaces as their most specific common type, or the types themselves are completely
* unrelated interfaces, {@link java.lang.Object} is returned.
*/
public static Class<?> getCommonLosslessConversionType(Class<?> c1, Class<?> c2) {
public static Class<?> getCommonLosslessConversionType(final Class<?> c1, final Class<?> c2) {
if(c1 == c2) {
return c1;
} else if(isConvertibleWithoutLoss(c2, c1)) {
@ -144,11 +144,11 @@ public class TypeUtilities {
return getMostSpecificCommonTypeUnequalNonprimitives(c1, c2);
}
private static Class<?> getMostSpecificCommonTypeUnequalNonprimitives(Class<?> c1, Class<?> c2) {
private static Class<?> getMostSpecificCommonTypeUnequalNonprimitives(final Class<?> c1, final Class<?> c2) {
final Class<?> npc1 = c1.isPrimitive() ? getWrapperType(c1) : c1;
final Class<?> npc2 = c2.isPrimitive() ? getWrapperType(c2) : c2;
Set<Class<?>> a1 = getAssignables(npc1, npc2);
Set<Class<?>> a2 = getAssignables(npc2, npc1);
final Set<Class<?>> a1 = getAssignables(npc1, npc2);
final Set<Class<?>> a2 = getAssignables(npc2, npc1);
a1.retainAll(a2);
if(a1.isEmpty()) {
// Can happen when at least one of the arguments is an interface,
@ -159,10 +159,10 @@ public class TypeUtilities {
// thank to interfaces. I.e., if you call this method for String.class
// and Number.class, you'll have Comparable, Serializable, and Object
// as maximal elements.
List<Class<?>> max = new ArrayList<>();
outer: for(Class<?> clazz: a1) {
for(Iterator<Class<?>> maxiter = max.iterator(); maxiter.hasNext();) {
Class<?> maxClazz = maxiter.next();
final List<Class<?>> max = new ArrayList<>();
outer: for(final Class<?> clazz: a1) {
for(final Iterator<Class<?>> maxiter = max.iterator(); maxiter.hasNext();) {
final Class<?> maxClazz = maxiter.next();
if(isSubtype(maxClazz, clazz)) {
// It can't be maximal, if there's already a more specific
// maximal than it.
@ -184,21 +184,21 @@ public class TypeUtilities {
return max.get(0);
}
private static Set<Class<?>> getAssignables(Class<?> c1, Class<?> c2) {
Set<Class<?>> s = new HashSet<>();
private static Set<Class<?>> getAssignables(final Class<?> c1, final Class<?> c2) {
final Set<Class<?>> s = new HashSet<>();
collectAssignables(c1, c2, s);
return s;
}
private static void collectAssignables(Class<?> c1, Class<?> c2, Set<Class<?>> s) {
private static void collectAssignables(final Class<?> c1, final Class<?> c2, final Set<Class<?>> s) {
if(c1.isAssignableFrom(c2)) {
s.add(c1);
}
Class<?> sc = c1.getSuperclass();
final Class<?> sc = c1.getSuperclass();
if(sc != null) {
collectAssignables(sc, c2, s);
}
Class<?>[] itf = c1.getInterfaces();
final Class<?>[] itf = c1.getInterfaces();
for(int i = 0; i < itf.length; ++i) {
collectAssignables(itf[i], c2, s);
}
@ -221,17 +221,17 @@ public class TypeUtilities {
return Collections.unmodifiableMap(wrapperTypes);
}
private static Map<String, Class<?>> createClassNameMapping(Collection<Class<?>> classes) {
private static Map<String, Class<?>> createClassNameMapping(final Collection<Class<?>> classes) {
final Map<String, Class<?>> map = new HashMap<>();
for(Class<?> clazz: classes) {
for(final Class<?> clazz: classes) {
map.put(clazz.getName(), clazz);
}
return map;
}
private static <K, V> Map<V, K> invertMap(Map<K, V> map) {
private static <K, V> Map<V, K> invertMap(final Map<K, V> map) {
final Map<V, K> inverted = new IdentityHashMap<>(map.size());
for(Map.Entry<K, V> entry: map.entrySet()) {
for(final Map.Entry<K, V> entry: map.entrySet()) {
inverted.put(entry.getValue(), entry.getKey());
}
return Collections.unmodifiableMap(inverted);
@ -247,7 +247,7 @@ public class TypeUtilities {
* @param targetType the parameter type being converted to (method type for parameter types, call site type for return types)
* @return true if source type is method invocation convertible to target type.
*/
public static boolean isMethodInvocationConvertible(Class<?> sourceType, Class<?> targetType) {
public static boolean isMethodInvocationConvertible(final Class<?> sourceType, final Class<?> targetType) {
if(targetType.isAssignableFrom(sourceType)) {
return true;
}
@ -275,7 +275,7 @@ public class TypeUtilities {
* @param targetType the target type
* @return true if lossess conversion is possible
*/
public static boolean isConvertibleWithoutLoss(Class<?> sourceType, Class<?> targetType) {
public static boolean isConvertibleWithoutLoss(final Class<?> sourceType, final Class<?> targetType) {
if(targetType.isAssignableFrom(sourceType)) {
return true;
}
@ -310,7 +310,7 @@ public class TypeUtilities {
* @param methodType the parameter type in the method declaration
* @return true if callSiteType is potentially convertible to the methodType.
*/
public static boolean isPotentiallyConvertible(Class<?> callSiteType, Class<?> methodType) {
public static boolean isPotentiallyConvertible(final Class<?> callSiteType, final Class<?> methodType) {
// Widening or narrowing reference conversion
if(areAssignable(callSiteType, methodType)) {
return true;
@ -338,7 +338,7 @@ public class TypeUtilities {
* @param c2 another one of the types
* @return true if either c1 is assignable from c2 or c2 is assignable from c1.
*/
public static boolean areAssignable(Class<?> c1, Class<?> c2) {
public static boolean areAssignable(final Class<?> c1, final Class<?> c2) {
return c1.isAssignableFrom(c2) || c2.isAssignableFrom(c1);
}
@ -353,7 +353,7 @@ public class TypeUtilities {
* @return true if subType can be converted by identity conversion, widening primitive conversion, or widening
* reference conversion to superType.
*/
public static boolean isSubtype(Class<?> subType, Class<?> superType) {
public static boolean isSubtype(final Class<?> subType, final Class<?> superType) {
// Covers both JLS 4.10.2 "Subtyping among Class and Interface Types"
// and JLS 4.10.3 "Subtyping among Array Types", as well as primitive
// type identity.
@ -384,7 +384,7 @@ public class TypeUtilities {
* @param superType the supposed supertype
* @return true if subType is a proper (not identical to) primitive subtype of the superType
*/
private static boolean isProperPrimitiveSubtype(Class<?> subType, Class<?> superType) {
private static boolean isProperPrimitiveSubtype(final Class<?> subType, final Class<?> superType) {
if(superType == boolean.class || subType == boolean.class) {
return false;
}
@ -418,7 +418,7 @@ public class TypeUtilities {
* @return true if subType is a proper (not identical to) primitive subtype of the superType that can be represented
* by the supertype without no precision loss.
*/
private static boolean isProperPrimitiveLosslessSubtype(Class<?> subType, Class<?> superType) {
private static boolean isProperPrimitiveLosslessSubtype(final Class<?> subType, final Class<?> superType) {
if(superType == boolean.class || subType == boolean.class) {
return false;
}
@ -471,13 +471,13 @@ public class TypeUtilities {
return classes.keySet();
}
private static void addClassHierarchy(Map<Class<?>, Class<?>> map, Class<?> clazz) {
private static void addClassHierarchy(final Map<Class<?>, Class<?>> map, final Class<?> clazz) {
if(clazz == null) {
return;
}
map.put(clazz, clazz);
addClassHierarchy(map, clazz.getSuperclass());
for(Class<?> itf: clazz.getInterfaces()) {
for(final Class<?> itf: clazz.getInterfaces()) {
addClassHierarchy(map, itf);
}
}
@ -489,7 +489,7 @@ public class TypeUtilities {
* @return true if the class can be assigned from any boxed primitive. Basically, it is true if the class is any
* primitive wrapper class, or a superclass or superinterface of any primitive wrapper class.
*/
private static boolean isAssignableFromBoxedPrimitive(Class<?> clazz) {
private static boolean isAssignableFromBoxedPrimitive(final Class<?> clazz) {
return PRIMITIVE_WRAPPER_TYPES.contains(clazz);
}
@ -500,7 +500,7 @@ public class TypeUtilities {
* @return the class representing the primitive type, or null if the name does not correspond to a primitive type
* or is "void".
*/
public static Class<?> getPrimitiveTypeByName(String name) {
public static Class<?> getPrimitiveTypeByName(final String name) {
return PRIMITIVE_TYPES_BY_NAME.get(name);
}
@ -511,7 +511,7 @@ public class TypeUtilities {
* @param wrapperType the class object representing a wrapper for a primitive type
* @return the class object representing the primitive type, or null if the passed class is not a primitive wrapper.
*/
public static Class<?> getPrimitiveType(Class<?> wrapperType) {
public static Class<?> getPrimitiveType(final Class<?> wrapperType) {
return WRAPPER_TO_PRIMITIVE_TYPES.get(wrapperType);
}
@ -523,7 +523,7 @@ public class TypeUtilities {
* @param primitiveType the class object representing a primitive type
* @return the class object representing the wrapper type, or null if the passed class is not a primitive.
*/
public static Class<?> getWrapperType(Class<?> primitiveType) {
public static Class<?> getWrapperType(final Class<?> primitiveType) {
return WRAPPER_TYPES.get(primitiveType);
}
}

View File

@ -90,7 +90,7 @@ class UnnamedDynCallSiteDescriptor extends AbstractCallSiteDescriptor {
private final MethodType methodType;
private final String op;
UnnamedDynCallSiteDescriptor(String op, MethodType methodType) {
UnnamedDynCallSiteDescriptor(final String op, final MethodType methodType) {
this.op = op;
this.methodType = methodType;
}
@ -105,7 +105,7 @@ class UnnamedDynCallSiteDescriptor extends AbstractCallSiteDescriptor {
}
@Override
public String getNameToken(int i) {
public String getNameToken(final int i) {
switch(i) {
case 0: return "dyn";
case 1: return op;
@ -119,7 +119,7 @@ class UnnamedDynCallSiteDescriptor extends AbstractCallSiteDescriptor {
}
@Override
public CallSiteDescriptor changeMethodType(MethodType newMethodType) {
public CallSiteDescriptor changeMethodType(final MethodType newMethodType) {
return CallSiteDescriptorFactory.getCanonicalPublicDescriptor(new UnnamedDynCallSiteDescriptor(op,
newMethodType));
}

View File

@ -65,8 +65,8 @@ final class Formatter {
while (m.find()) {
int index = index(m.group(1));
boolean previous = isPreviousArgument(m.group(2));
char conversion = m.group(6).charAt(0);
final boolean previous = isPreviousArgument(m.group(2));
final char conversion = m.group(6).charAt(0);
// skip over some formats
if (index < 0 || previous
@ -85,7 +85,7 @@ final class Formatter {
}
// current argument
Object arg = args[index - 1];
final Object arg = args[index - 1];
// for date we convert double to long
if (m.group(5) != null) {

View File

@ -281,7 +281,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
private static Source makeSource(final Reader reader, final ScriptContext ctxt) throws ScriptException {
try {
return sourceFor(getScriptName(ctxt), reader);
} catch (IOException e) {
} catch (final IOException e) {
throw new ScriptException(e);
}
}

View File

@ -43,13 +43,13 @@ import java.util.Set;
import java.util.concurrent.Callable;
import javax.script.Bindings;
import jdk.nashorn.internal.objects.Global;
import jdk.nashorn.internal.runtime.arrays.ArrayData;
import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime;
import jdk.nashorn.internal.runtime.arrays.ArrayData;
/**
* Mirror object that wraps a given Nashorn Script object.
@ -735,7 +735,7 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin
return global;
}
static Object translateUndefined(Object obj) {
static Object translateUndefined(final Object obj) {
return (obj == ScriptRuntime.UNDEFINED)? null : obj;
}

View File

@ -28,11 +28,11 @@ package jdk.nashorn.api.scripting;
import java.lang.invoke.MethodHandle;
import jdk.internal.dynalink.beans.StaticClass;
import jdk.internal.dynalink.linker.LinkerServices;
import jdk.nashorn.internal.runtime.linker.Bootstrap;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime;
import jdk.nashorn.internal.runtime.linker.Bootstrap;
/**
* Utilities that are to be called from script code.

View File

@ -81,7 +81,7 @@ public final class URLReader extends Reader {
}
@Override
public int read(char cbuf[], int off, int len) throws IOException {
public int read(final char cbuf[], final int off, final int len) throws IOException {
return getReader().read(cbuf, off, len);
}

View File

@ -35,7 +35,6 @@ import java.util.Deque;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import jdk.nashorn.internal.ir.AccessNode;
import jdk.nashorn.internal.ir.CallNode;
import jdk.nashorn.internal.ir.Expression;

View File

@ -48,7 +48,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import jdk.internal.dynalink.support.NameCodec;
import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
import jdk.nashorn.internal.codegen.types.Type;

View File

@ -369,7 +369,7 @@ public enum CompilerConstants {
}
@Override
public void invoke(MethodVisitor mv) {
public void invoke(final MethodVisitor mv) {
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, className, name, desc, false);
}
};
@ -408,7 +408,7 @@ public enum CompilerConstants {
}
@Override
public void invoke(MethodVisitor mv) {
public void invoke(final MethodVisitor mv) {
mv.visitMethodInsn(Opcodes.INVOKESTATIC, className, name, desc, false);
}
};
@ -448,7 +448,7 @@ public enum CompilerConstants {
}
@Override
public void invoke(MethodVisitor mv) {
public void invoke(final MethodVisitor mv) {
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, name, descriptor, false);
}
};
@ -473,7 +473,7 @@ public enum CompilerConstants {
}
@Override
public void invoke(MethodVisitor mv) {
public void invoke(final MethodVisitor mv) {
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, className, name, descriptor, true);
}
};
@ -574,7 +574,7 @@ public enum CompilerConstants {
}
@Override
public void invoke(MethodVisitor mv) {
public void invoke(final MethodVisitor mv) {
mv.visitMethodInsn(Opcodes.INVOKESTATIC, className, name, descriptor, false);
}
};
@ -599,7 +599,7 @@ public enum CompilerConstants {
}
@Override
public void invoke(MethodVisitor mv) {
public void invoke(final MethodVisitor mv) {
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, className, name, descriptor, false);
}
};
@ -625,7 +625,7 @@ public enum CompilerConstants {
}
@Override
public void invoke(MethodVisitor mv) {
public void invoke(final MethodVisitor mv) {
mv.visitMethodInsn(Opcodes.INVOKESPECIAL, className, name, descriptor, false);
}
};

View File

@ -28,15 +28,14 @@ package jdk.nashorn.internal.codegen;
import static jdk.nashorn.internal.codegen.CompilerConstants.ARGUMENTS;
import static jdk.nashorn.internal.codegen.CompilerConstants.constructorNoLookup;
import static jdk.nashorn.internal.codegen.CompilerConstants.typeDescriptor;
import static jdk.nashorn.internal.codegen.ObjectClassGenerator.PRIMITIVE_FIELD_TYPE;
import static jdk.nashorn.internal.codegen.ObjectClassGenerator.getFieldName;
import static jdk.nashorn.internal.codegen.ObjectClassGenerator.getPaddedFieldCount;
import static jdk.nashorn.internal.codegen.ObjectClassGenerator.PRIMITIVE_FIELD_TYPE;
import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.getArrayIndex;
import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.isValidArrayIndex;
import java.util.Iterator;
import java.util.List;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.Symbol;
import jdk.nashorn.internal.runtime.Context;

View File

@ -30,7 +30,6 @@ import java.util.BitSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import jdk.nashorn.internal.codegen.types.Type;
/**

View File

@ -35,7 +35,7 @@ public class LocalStateRestorationInfo {
private final Type[] localVariableTypes;
private final int[] stackLoads;
LocalStateRestorationInfo(Type[] localVariableTypes, final int[] stackLoads) {
LocalStateRestorationInfo(final Type[] localVariableTypes, final int[] stackLoads) {
this.localVariableTypes = localVariableTypes;
this.stackLoads = stackLoads;
}

View File

@ -26,8 +26,8 @@
package jdk.nashorn.internal.codegen;
import static jdk.nashorn.internal.codegen.CompilerConstants.SCOPE;
import java.util.List;
import java.util.List;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject;

View File

@ -55,7 +55,7 @@ public class SplitMethodEmitter extends MethodEmitter {
*/
private final List<BreakableNode> externalTargetNodes = new ArrayList<>();
SplitMethodEmitter(final ClassEmitter classEmitter, final MethodVisitor mv, SplitNode splitNode) {
SplitMethodEmitter(final ClassEmitter classEmitter, final MethodVisitor mv, final SplitNode splitNode) {
super(classEmitter, mv);
this.splitNode = splitNode;
}

View File

@ -31,7 +31,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.nashorn.internal.ir.Block;
import jdk.nashorn.internal.ir.FunctionNode;
import jdk.nashorn.internal.ir.FunctionNode.CompilationState;

View File

@ -29,7 +29,6 @@ import java.lang.invoke.MethodType;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.FunctionNode;
import jdk.nashorn.internal.runtime.ScriptFunction;

View File

@ -101,7 +101,7 @@ final class WeighNodes extends NodeOperatorVisitor<LexicalContext> {
*
* @param weightCache cache of already calculated block weights
*/
private WeighNodes(FunctionNode topFunction, final Map<Node, Long> weightCache) {
private WeighNodes(final FunctionNode topFunction, final Map<Node, Long> weightCache) {
super(new LexicalContext());
this.topFunction = topFunction;
this.weightCache = weightCache;

View File

@ -102,7 +102,7 @@ public final class BooleanType extends Type {
}
@Override
public Type loadForcedInitializer(MethodVisitor method) {
public Type loadForcedInitializer(final MethodVisitor method) {
method.visitInsn(ICONST_0);
return BOOLEAN;
}

View File

@ -267,7 +267,7 @@ class IntType extends BitwiseType {
}
@Override
public Type loadForcedInitializer(MethodVisitor method) {
public Type loadForcedInitializer(final MethodVisitor method) {
method.visitInsn(ICONST_0);
return INT;
}

View File

@ -239,7 +239,7 @@ class LongType extends BitwiseType {
}
@Override
public Type loadForcedInitializer(MethodVisitor method) {
public Type loadForcedInitializer(final MethodVisitor method) {
method.visitInsn(LCONST_0);
return LONG;
}

View File

@ -94,7 +94,7 @@ class NumberType extends NumericType {
}
@Override
public Type loadForcedInitializer(MethodVisitor method) {
public Type loadForcedInitializer(final MethodVisitor method) {
method.visitInsn(DCONST_0);
return NUMBER;
}

View File

@ -95,7 +95,7 @@ class ObjectType extends Type {
}
@Override
public Type loadForcedInitializer(MethodVisitor method) {
public Type loadForcedInitializer(final MethodVisitor method) {
method.visitInsn(ACONST_NULL);
// TODO: do we need a special type for null, e.g. Type.NULL? It should be assignable to any other object type
// without a checkast in convert.

View File

@ -1004,7 +1004,7 @@ public abstract class Type implements Comparable<Type>, BytecodeOps {
}
};
private static <T extends Type> T putInCache(T type) {
private static <T extends Type> T putInCache(final T type) {
cache.put(type.getTypeClass(), type);
return type;
}

View File

@ -40,14 +40,14 @@ import java.util.List;
public class BlockLexicalContext extends LexicalContext {
/** statement stack, each block on the lexical context maintains one of these, which is
* committed to the block on pop */
private Deque<List<Statement>> sstack = new ArrayDeque<>();
private final Deque<List<Statement>> sstack = new ArrayDeque<>();
/** Last non debug statement emitted in this context */
protected Statement lastStatement;
@Override
public <T extends LexicalContextNode> T push(final T node) {
T pushed = super.push(node);
final T pushed = super.push(node);
if (node instanceof Block) {
sstack.push(new ArrayList<Statement>());
}
@ -68,7 +68,7 @@ public class BlockLexicalContext extends LexicalContext {
* @param block the block to operate on
* @return a modified block.
*/
protected Block afterSetStatements(Block block) {
protected Block afterSetStatements(final Block block) {
return block;
}

View File

@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import java.util.Collections;
import java.util.List;
import jdk.nashorn.internal.codegen.Label;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;

View File

@ -26,7 +26,6 @@
package jdk.nashorn.internal.ir;
import java.util.function.Function;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.runtime.UnwarrantedOptimismException;

View File

@ -33,7 +33,6 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import jdk.nashorn.internal.codegen.CompileUnit;
import jdk.nashorn.internal.codegen.Compiler;
import jdk.nashorn.internal.codegen.CompilerConstants;

View File

@ -26,7 +26,6 @@
package jdk.nashorn.internal.ir;
import java.util.List;
import jdk.nashorn.internal.codegen.Label;
/**

View File

@ -29,15 +29,15 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor;
abstract class LexicalContextExpression extends Expression implements LexicalContextNode {
LexicalContextExpression(LexicalContextExpression expr) {
LexicalContextExpression(final LexicalContextExpression expr) {
super(expr);
}
LexicalContextExpression(long token, int start, int finish) {
LexicalContextExpression(final long token, final int start, final int finish) {
super(token, start, finish);
}
LexicalContextExpression(long token, int finish) {
LexicalContextExpression(final long token, final int finish) {
super(token, finish);
}

View File

@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import jdk.nashorn.internal.codegen.CompileUnit;
import jdk.nashorn.internal.codegen.types.ArrayType;
import jdk.nashorn.internal.codegen.types.Type;

View File

@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import jdk.nashorn.internal.codegen.Label;
/**

View File

@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
import java.util.ArrayList;
import java.util.List;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.parser.Token;
import jdk.nashorn.internal.parser.TokenType;

View File

@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;

View File

@ -116,7 +116,7 @@ public class OptimisticLexicalContext extends LexicalContext {
@Override
public <T extends LexicalContextNode> T pop(final T node) {
T popped = super.pop(node);
final T popped = super.pop(node);
if (isEnabled) {
if(node instanceof FunctionNode) {
optimisticAssumptions.pop();

View File

@ -27,6 +27,7 @@ package jdk.nashorn.internal.ir;
import static jdk.nashorn.internal.parser.TokenType.RETURN;
import static jdk.nashorn.internal.parser.TokenType.YIELD;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;

View File

@ -30,7 +30,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.nashorn.internal.codegen.CompileUnit;
import jdk.nashorn.internal.codegen.Label;
import jdk.nashorn.internal.ir.annotations.Immutable;

View File

@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jdk.nashorn.internal.codegen.Label;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;

View File

@ -26,7 +26,6 @@
package jdk.nashorn.internal.ir;
import java.util.function.Function;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;

View File

@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;

View File

@ -34,7 +34,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import jdk.nashorn.internal.codegen.types.Type;
import jdk.nashorn.internal.ir.annotations.Ignore;
import jdk.nashorn.internal.ir.annotations.Immutable;

View File

@ -105,7 +105,7 @@ public final class ASTWriter {
final boolean isReference = field != null && field.isAnnotationPresent(Reference.class);
Class<?> clazz = node.getClass();
final Class<?> clazz = node.getClass();
String type = clazz.getName();
type = type.substring(type.lastIndexOf('.') + 1, type.length());

View File

@ -29,7 +29,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.internal.org.objectweb.asm.Attribute;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassVisitor;
@ -58,27 +57,27 @@ public class NashornClassReader extends ClassReader {
return labelMap.get(key);
}
private static int readByte(final byte[] bytecode, int index) {
private static int readByte(final byte[] bytecode, final int index) {
return (byte)(bytecode[index] & 0xff);
}
private static int readShort(final byte[] bytecode, int index) {
private static int readShort(final byte[] bytecode, final int index) {
return (short)((bytecode[index] & 0xff) << 8) | (bytecode[index + 1] & 0xff);
}
private static int readInt(final byte[] bytecode, int index) {
private static int readInt(final byte[] bytecode, final int index) {
return ((bytecode[index] & 0xff) << 24) | ((bytecode[index + 1] & 0xff) << 16) | ((bytecode[index + 2] & 0xff) << 8) | (bytecode[index + 3] & 0xff);
}
private static long readLong(final byte[] bytecode, int index) {
int hi = readInt(bytecode, index);
int lo = readInt(bytecode, index + 4);
private static long readLong(final byte[] bytecode, final int index) {
final int hi = readInt(bytecode, index);
final int lo = readInt(bytecode, index + 4);
return ((long)hi << 32) | lo;
}
private static String readUTF(int index, final int utfLen, final byte[] bytecode) {
int endIndex = index + utfLen;
char buf[] = new char[utfLen * 2];
private static String readUTF(final int index, final int utfLen, final byte[] bytecode) {
final int endIndex = index + utfLen;
final char buf[] = new char[utfLen * 2];
int strLen = 0;
int c;
int st = 0;
@ -123,7 +122,7 @@ public class NashornClassReader extends ClassReader {
int u = 0;
int magic = readInt(bytecode, u);
final int magic = readInt(bytecode, u);
u += 4; //magic
assert magic == 0xcafebabe : Integer.toHexString(magic);
readShort(bytecode, u); //minor
@ -131,9 +130,9 @@ public class NashornClassReader extends ClassReader {
readShort(bytecode, u); //major
u += 2; //minor
int cpc = readShort(bytecode, u);
final int cpc = readShort(bytecode, u);
u += 2;
ArrayList<Constant> cp = new ArrayList<>(cpc);
final ArrayList<Constant> cp = new ArrayList<>(cpc);
cp.add(null);
for (int i = 1; i < cpc; i++) {
@ -180,7 +179,7 @@ public class NashornClassReader extends ClassReader {
u += 4;
break;
case 1: //utf8
int len = readShort(bytecode, u);
final int len = readShort(bytecode, u);
u += 2;
cp.add(new DirectInfo<>(cp, tag, readUTF(u, len, bytecode)));
u += len;
@ -200,7 +199,7 @@ public class NashornClassReader extends ClassReader {
u += 4;
break;
case 15: //methodhandle
int kind = readByte(bytecode, u);
final int kind = readByte(bytecode, u);
assert kind >= 1 && kind <= 9 : kind;
cp.add(new IndexInfo2(cp, tag, kind, readShort(bytecode, u + 1)) {
@Override
@ -219,16 +218,16 @@ public class NashornClassReader extends ClassReader {
readShort(bytecode, u); //access flags
u += 2; //access
int cls = readShort(bytecode, u);
final int cls = readShort(bytecode, u);
u += 2; //this_class
thisClassName = cp.get(cls).toString();
u += 2; //super
int ifc = readShort(bytecode, u);
final int ifc = readShort(bytecode, u);
u += 2;
u += ifc * 2;
int fc = readShort(bytecode, u);
final int fc = readShort(bytecode, u);
u += 2; //fields
for (int i = 0 ; i < fc ; i++) {
@ -236,41 +235,41 @@ public class NashornClassReader extends ClassReader {
readShort(bytecode, u); //fieldname
u += 2; //name
u += 2; //descriptor
int ac = readShort(bytecode, u);
final int ac = readShort(bytecode, u);
u += 2;
//field attributes
for (int j = 0; j < ac; j++) {
u += 2; //attribute name
int len = readInt(bytecode, u);
final int len = readInt(bytecode, u);
u += 4;
u += len;
}
}
int mc = readShort(bytecode, u);
final int mc = readShort(bytecode, u);
u += 2;
for (int i = 0 ; i < mc ; i++) {
readShort(bytecode, u);
u += 2; //access
int methodNameIndex = readShort(bytecode, u);
final int methodNameIndex = readShort(bytecode, u);
u += 2;
final String methodName = cp.get(methodNameIndex).toString();
int methodDescIndex = readShort(bytecode, u);
final int methodDescIndex = readShort(bytecode, u);
u += 2;
final String methodDesc = cp.get(methodDescIndex).toString();
int ac = readShort(bytecode, u);
final int ac = readShort(bytecode, u);
u += 2;
//method attributes
for (int j = 0; j < ac; j++) {
int nameIndex = readShort(bytecode, u);
final int nameIndex = readShort(bytecode, u);
u += 2;
String attrName = cp.get(nameIndex).toString();
final String attrName = cp.get(nameIndex).toString();
int attrLen = readInt(bytecode, u);
final int attrLen = readInt(bytecode, u);
u += 4;
if ("Code".equals(attrName)) {
@ -278,20 +277,20 @@ public class NashornClassReader extends ClassReader {
u += 2; //max stack
readShort(bytecode, u);
u += 2; //max locals
int len = readInt(bytecode, u);
final int len = readInt(bytecode, u);
u += 4;
parseCode(bytecode, u, len, fullyQualifiedName(thisClassName, methodName, methodDesc));
u += len;
int elen = readShort(bytecode, u); //exception table length
final int elen = readShort(bytecode, u); //exception table length
u += 2;
u += elen * 8;
//method attributes
int ac2 = readShort(bytecode, u);
final int ac2 = readShort(bytecode, u);
u += 2;
for (int k = 0; k < ac2; k++) {
u += 2; //name;
int aclen = readInt(bytecode, u);
final int aclen = readInt(bytecode, u);
u += 4; //length
u += aclen; //bytes;
}
@ -301,13 +300,13 @@ public class NashornClassReader extends ClassReader {
}
}
int ac = readShort(bytecode, u);
final int ac = readShort(bytecode, u);
u += 2;
//other attributes
for (int i = 0 ; i < ac ; i++) {
readShort(bytecode, u); //name index
u += 2;
int len = readInt(bytecode, u);
final int len = readInt(bytecode, u);
u += 4;
u += len;
//attribute
@ -327,7 +326,7 @@ public class NashornClassReader extends ClassReader {
boolean wide = false;
for (int i = index; i < index + len;) {
int opcode = bytecode[i];
final int opcode = bytecode[i];
labels.add(new NashornLabel(opcode, i - index));
switch (opcode & 0xff) {
@ -345,7 +344,7 @@ public class NashornClassReader extends ClassReader {
}
readInt(bytecode, i);
i += 4; //defaultbyte
int npairs = readInt(bytecode, i);
final int npairs = readInt(bytecode, i);
i += 4;
i += 8 * npairs;
break;
@ -356,9 +355,9 @@ public class NashornClassReader extends ClassReader {
}
readInt(bytecode, i); //default
i += 4;
int lo = readInt(bytecode, i);
final int lo = readInt(bytecode, i);
i += 4;
int hi = readInt(bytecode, i);
final int hi = readInt(bytecode, i);
i += 4;
i += 4 * (hi - lo + 1);
break;
@ -437,13 +436,13 @@ public class NashornClassReader extends ClassReader {
}
@Override
public void accept(final ClassVisitor classVisitor, Attribute[] attrs, final int flags) {
public void accept(final ClassVisitor classVisitor, final Attribute[] attrs, final int flags) {
super.accept(classVisitor, attrs, flags);
}
@Override
protected Label readLabel(final int offset, final Label[] labels) {
Label label = super.readLabel(offset, labels);
final Label label = super.readLabel(offset, labels);
label.info = (int)offset;
return label;
}
@ -451,7 +450,7 @@ public class NashornClassReader extends ClassReader {
private abstract static class Constant {
protected ArrayList<Constant> cp;
protected int tag;
protected Constant(final ArrayList<Constant> cp, int tag) {
protected Constant(final ArrayList<Constant> cp, final int tag) {
this.cp = cp;
this.tag = tag;
}
@ -469,7 +468,7 @@ public class NashornClassReader extends ClassReader {
private static class IndexInfo extends Constant {
protected final int index;
IndexInfo(final ArrayList<Constant> cp, int tag, int index) {
IndexInfo(final ArrayList<Constant> cp, final int tag, final int index) {
super(cp, tag);
this.index = index;
}
@ -483,7 +482,7 @@ public class NashornClassReader extends ClassReader {
private static class IndexInfo2 extends IndexInfo {
protected final int index2;
IndexInfo2(final ArrayList<Constant> cp, int tag, int index, int index2) {
IndexInfo2(final ArrayList<Constant> cp, final int tag, final int index, final int index2) {
super(cp, tag, index);
this.index2 = index2;
}
@ -497,7 +496,7 @@ public class NashornClassReader extends ClassReader {
private static class DirectInfo<T> extends Constant {
protected final T info;
DirectInfo(final ArrayList<Constant> cp, int tag, T info) {
DirectInfo(final ArrayList<Constant> cp, final int tag, final T info) {
super(cp, tag);
this.info = info;
}

View File

@ -494,7 +494,7 @@ public final class NashornTextifier extends Printer {
}
@Override
public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
public void visitInvokeDynamicInsn(final String name, final String desc, final Handle bsm, final Object... bsmArgs) {
final StringBuilder sb = new StringBuilder();
appendOpcode(sb, Opcodes.INVOKEDYNAMIC).append(' ');
@ -1005,7 +1005,7 @@ public final class NashornTextifier extends Printer {
private static final String COLOR_DEFAULT = "\"#99bb99\"";
private static final String COLOR_LOCALVARS = "\"#999999\"";
Graph(String name) {
Graph(final String name) {
this.name = name;
this.nodes = new LinkedHashSet<>();
this.contents = new HashMap<>();
@ -1016,7 +1016,7 @@ public final class NashornTextifier extends Printer {
this.exceptionMap = new HashMap<>();
}
void addEdge(String from, String to) {
void addEdge(final String from, final String to) {
Set<String> edgeSet = edges.get(from);
if (edgeSet == null) {
edgeSet = new LinkedHashSet<>();
@ -1026,7 +1026,7 @@ public final class NashornTextifier extends Printer {
hasPreds.add(to);
}
void addTryCatch(String tryNode, String catchNode) {
void addTryCatch(final String tryNode, final String catchNode) {
Set<String> tryNodes = exceptionMap.get(catchNode);
if (tryNodes == null) {
tryNodes = new HashSet<>();
@ -1038,20 +1038,20 @@ public final class NashornTextifier extends Printer {
tryNodes.add(tryNode);
}
void addNode(String node) {
void addNode(final String node) {
assert !nodes.contains(node);
nodes.add(node);
}
void setNoFallThru(String node) {
void setNoFallThru(final String node) {
noFallThru.add(node);
}
boolean isNoFallThru(String node) {
boolean isNoFallThru(final String node) {
return noFallThru.contains(node);
}
void setIsCatch(String node, String exception) {
void setIsCatch(final String node, final String exception) {
catches.put(node, exception);
}
@ -1187,47 +1187,47 @@ public final class NashornTextifier extends Printer {
}
@Override
public Printer visitClassAnnotation(String arg0, boolean arg1) {
public Printer visitClassAnnotation(final String arg0, final boolean arg1) {
return this;
}
@Override
public void visitClassAttribute(Attribute arg0) {
public void visitClassAttribute(final Attribute arg0) {
throw new AssertionError();
}
@Override
public Printer visitFieldAnnotation(String arg0, boolean arg1) {
public Printer visitFieldAnnotation(final String arg0, final boolean arg1) {
throw new AssertionError();
}
@Override
public void visitFieldAttribute(Attribute arg0) {
public void visitFieldAttribute(final Attribute arg0) {
throw new AssertionError();
}
@Override
public Printer visitMethodAnnotation(String arg0, boolean arg1) {
public Printer visitMethodAnnotation(final String arg0, final boolean arg1) {
return this;
}
@Override
public void visitMethodAttribute(Attribute arg0) {
public void visitMethodAttribute(final Attribute arg0) {
throw new AssertionError();
}
@Override
public Printer visitParameterAnnotation(int arg0, String arg1, boolean arg2) {
public Printer visitParameterAnnotation(final int arg0, final String arg1, final boolean arg2) {
throw new AssertionError();
}
@Override
public void visit(String arg0, Object arg1) {
public void visit(final String arg0, final Object arg1) {
throw new AssertionError();
}
@Override
public Printer visitAnnotation(String arg0, String arg1) {
public Printer visitAnnotation(final String arg0, final String arg1) {
throw new AssertionError();
}
@ -1237,17 +1237,17 @@ public final class NashornTextifier extends Printer {
}
@Override
public Printer visitArray(String arg0) {
public Printer visitArray(final String arg0) {
throw new AssertionError();
}
@Override
public void visitEnum(String arg0, String arg1, String arg2) {
public void visitEnum(final String arg0, final String arg1, final String arg2) {
throw new AssertionError();
}
@Override
public void visitInnerClass(String arg0, String arg1, String arg2, int arg3) {
public void visitInnerClass(final String arg0, final String arg1, final String arg2, final int arg3) {
throw new AssertionError();
}
}

View File

@ -36,14 +36,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.Debug;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.logging.DebugLogger;
import jdk.nashorn.internal.runtime.logging.Loggable;
import jdk.nashorn.internal.runtime.logging.Logger;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.options.Options;
/**

View File

@ -30,7 +30,6 @@ import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED;
import static jdk.nashorn.internal.runtime.ScriptRuntime.sameValue;
import java.util.Objects;
import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.runtime.JSType;

View File

@ -38,7 +38,7 @@ import jdk.nashorn.internal.runtime.ScriptRuntime;
final class BoundScriptFunctionImpl extends ScriptFunctionImpl {
private final ScriptFunction targetFunction;
BoundScriptFunctionImpl(ScriptFunctionData data, ScriptFunction targetFunction) {
BoundScriptFunctionImpl(final ScriptFunctionData data, final ScriptFunction targetFunction) {
super(data, Global.instance());
setPrototype(ScriptRuntime.UNDEFINED);
this.targetFunction = targetFunction;

Some files were not shown because too many files have changed in this diff Show More