提交 f6b5c7ad 编写于 作者: L lana

Merge

/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Demonstrate how to provide a default fall-through solution for adapted Java
// objects, forwarding all calls that are not adapted.
var Date = Java.type('java.time.LocalDate')
function wrapDate(d) {
return new JSAdapter() {
__call__: function() {
// adapted (extra) methods
if (arguments[0] === 'yesterday') {
return d.minusDays(1)
}
// fall-through: forward all other, non-adapted method calls
var args = [d].concat(Array.prototype.slice.call(arguments, 1))
return Function.call.apply(d[arguments[0]], args)
}
}
}
var now = wrapDate(Date.now())
print(now)
print(now.yesterday()) // adapted
print(now.lengthOfMonth()) // fall through to original method
print(now.atTime(23, 42)) // arguments are passed through
......@@ -96,8 +96,6 @@ import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
* guarding linkers so they aren't tempted to directly manipulate the call sites. The constructors of built-in
* {@link RelinkableCallSite} implementations all need a call site descriptor. Even if you create your own call site
* descriptors consider using {@link CallSiteDescriptorFactory#tokenizeName(String)} in your implementation.
*
* @author Attila Szegedi
*/
public interface CallSiteDescriptor {
/**
......@@ -157,7 +155,9 @@ public interface CallSiteDescriptor {
public MethodType getMethodType();
/**
* Returns the lookup passed to the bootstrap method.
* Returns the lookup passed to the bootstrap method. If the lookup isn't the public lookup, the
* implementation must check the {@code RuntimePermission("dynalink.getLookup")} permission if a security
* manager is present.
* @return the lookup passed to the bootstrap method.
*/
public Lookup getLookup();
......
......@@ -85,9 +85,9 @@ package jdk.internal.dynalink;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.util.Arrays;
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;
......@@ -112,7 +112,14 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
PRUNE_SWITCHPOINTS = MethodHandles.insertArguments(PRUNE, 2, false);
}
private final AtomicReference<LinkedList<GuardedInvocation>> invocations = new AtomicReference<>();
/**
* Contains the invocations currently linked into this call site's target. They are used when we are
* relinking to rebuild the guardWithTest chain. Valid values for this field are: {@code null} if there's
* no linked invocations, or an instance of {@link GuardedInvocation} if there is exactly one previous
* invocation, or an instance of {@code GuardedInvocation[]} if there is more than one previous
* invocation.
*/
private Object invocations;
/**
* Creates a new chained call site.
......@@ -142,10 +149,18 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
}
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 =
currentInvocations == null || reset ? new LinkedList<>() : (LinkedList)currentInvocations.clone();
final Object currentInvocations = invocations;
final LinkedList<GuardedInvocation> newInvocations;
if (currentInvocations == null || reset) {
newInvocations = new LinkedList<>();
} else if (currentInvocations instanceof GuardedInvocation) {
newInvocations = new LinkedList<>();
newInvocations.add((GuardedInvocation)currentInvocations);
} else if (currentInvocations instanceof GuardedInvocation[]) {
newInvocations = new LinkedList<>(Arrays.asList(((GuardedInvocation[])currentInvocations)));
} else {
throw new AssertionError();
}
// First, prune the chain of invalidated switchpoints, we always do this
// We also remove any catches if the remove catches flag is set
......@@ -177,12 +192,17 @@ public class ChainedCallSite extends AbstractRelinkableCallSite {
target = inv.compose(target, pruneAndInvokeSwitchPoints, pruneAndInvokeCatches);
}
// If nobody else updated the call site while we were rebuilding the chain, set the target to our chain. In case
// we lost the race for multithreaded update, just do nothing. Either the other thread installed the same thing
// we wanted to install, or otherwise, we'll be asked to relink again.
if(invocations.compareAndSet(currentInvocations, newInvocations)) {
setTarget(target);
switch (newInvocations.size()) {
case 0:
invocations = null;
break;
case 1:
invocations = newInvocations.getFirst();
break;
default:
invocations = newInvocations.toArray(new GuardedInvocation[newInvocations.size()]);
}
setTarget(target);
return target;
}
......
......@@ -97,8 +97,6 @@ import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
* and one that just uses the passed caller as the lookup scope. Using the public lookup one is advised if your language
* runtime has no concept of interacting with Java visibility scopes, as it results in a more lightweight runtime
* information.
*
* @author Attila Szegedi
*/
public class DefaultBootstrapper {
private static final DynamicLinker dynamicLinker = new DynamicLinkerFactory().createLinker();
......
......@@ -147,15 +147,14 @@ import jdk.internal.dynalink.support.RuntimeContextLinkRequestImpl;
* additional parameters to the bootstrap method) to them.</li>
*
* </ul>
*
* @author Attila Szegedi
*/
public class DynamicLinker {
public final class DynamicLinker {
private static final String CLASS_NAME = DynamicLinker.class.getName();
private static final String RELINK_METHOD_NAME = "relink";
private static final String INITIAL_LINK_CLASS_NAME = "java.lang.invoke.MethodHandleNatives";
private static final String INITIAL_LINK_METHOD_NAME = "linkCallSite";
private static final String INVOKE_PACKAGE_PREFIX = "java.lang.invoke.";
private final LinkerServices linkerServices;
private final GuardedInvocationFilter prelinkFilter;
......@@ -305,25 +304,20 @@ public class DynamicLinker {
final StackTraceElement[] trace = new Throwable().getStackTrace();
for(int i = 0; i < trace.length - 1; ++i) {
final StackTraceElement frame = trace[i];
// If we found any of our linking entry points on the stack...
if(isRelinkFrame(frame) || isInitialLinkFrame(frame)) {
return trace[i + 1];
// ... then look for the first thing calling it that isn't j.l.invoke
for (int j = i + 1; j < trace.length; ++j) {
final StackTraceElement frame2 = trace[j];
if (!frame2.getClassName().startsWith(INVOKE_PACKAGE_PREFIX)) {
return frame2;
}
}
}
}
return null;
}
/**
* Deprecated because of imprecise name.
*
* @deprecated Use {@link #getLinkedCallSiteLocation()} instead.
*
* @return see non-deprecated method
*/
@Deprecated
public static StackTraceElement getRelinkedCallSiteLocation() {
return getLinkedCallSiteLocation();
}
/**
* Returns {@code true} if the frame represents {@code MethodHandleNatives.linkCallSite()},
* the frame immediately on top of the call site frame when the call site is
......
......@@ -111,14 +111,13 @@ import jdk.internal.dynalink.support.TypeConverterFactory;
import jdk.internal.dynalink.support.TypeUtilities;
/**
* A factory class for creating {@link DynamicLinker}s. The most usual dynamic linker is a linker that is a composition
* of all {@link GuardingDynamicLinker}s known and pre-created by the caller as well as any
* {@link AutoDiscovery automatically discovered} guarding linkers and the standard fallback {@link BeansLinker} and a
* {@link DefaultPrelinkFilter}. See {@link DynamicLinker} documentation for tips on how to use this class.
*
* @author Attila Szegedi
* A factory class for creating {@link DynamicLinker}s. The usual dynamic linker is a linker composed of all
* {@link GuardingDynamicLinker}s known and pre-created by the caller as well as any
* {@link AutoDiscovery automatically discovered} guarding linkers and the standard fallback
* {@link BeansLinker} and a {@link DefaultPrelinkFilter}. See {@link DynamicLinker} documentation for tips on
* how to use this class.
*/
public class DynamicLinkerFactory {
public final class DynamicLinkerFactory {
/**
* Default value for {@link #setUnstableRelinkThreshold(int) unstable relink threshold}.
*/
......
......@@ -91,8 +91,6 @@ import jdk.internal.dynalink.support.AbstractRelinkableCallSite;
* A relinkable call site that implements monomorphic inline caching strategy. After it linked a method, it will keep it
* until either its guard evaluates to false, or its switchpoint is invalidated, at which time it will throw away the
* previous linkage, and trigger relinking with its associated {@link DynamicLinker}.
*
* @author Attila Szegedi
*/
public class MonomorphicCallSite extends AbstractRelinkableCallSite {
/**
......
......@@ -87,8 +87,6 @@ import jdk.internal.dynalink.linker.GuardingDynamicLinker;
/**
* Thrown at the invocation if the call site can not be linked by any available {@link GuardingDynamicLinker}.
*
* @author Attila Szegedi
*/
public class NoSuchDynamicMethodException extends RuntimeException {
private static final long serialVersionUID = 1L;
......
......@@ -96,13 +96,11 @@ import jdk.internal.dynalink.linker.GuardedInvocation;
* {@link ChainedCallSite} that retains a chain of already linked method handles. The reason this is defined as an
* interface instead of a concrete, albeit abstract class is that it allows independent implementations to choose
* between {@link MutableCallSite} and {@link VolatileCallSite} as they see fit.
*
* @author Attila Szegedi
*/
public interface RelinkableCallSite {
/**
* Initializes the relinkable call site by setting a relink-and-invoke method handle. The call site implementation
* is supposed to set this method handle as its target.
* Initializes the relinkable call site by setting a relink-and-invoke method handle. The call site
* implementation is supposed to set this method handle as its target.
* @param relinkAndInvoke a relink-and-invoke method handle supplied by the {@link DynamicLinker}.
*/
public void initialize(MethodHandle relinkAndInvoke);
......
......@@ -111,8 +111,6 @@ import jdk.internal.dynalink.support.TypeUtilities;
/**
* A base class for both {@link StaticClassLinker} and {@link BeanLinker}. Deals with common aspects of property
* exposure and method calls for both static and instance facets of a class.
*
* @author Attila Szegedi
*/
abstract class AbstractJavaLinker implements GuardingDynamicLinker {
......
......@@ -98,8 +98,6 @@ import java.util.Set;
* public, or belongs to a restricted-access package. In that case, it is required to lookup a member in a publicly
* accessible superclass or implemented interface of the class, and use it instead of the member discovered on the
* class.
*
* @author Attila Szegedi
*/
class AccessibleMembersLookup {
private final Map<MethodSignature, Method> methods;
......@@ -140,8 +138,6 @@ class AccessibleMembersLookup {
/**
* A helper class that represents a method signature - name and argument types.
*
* @author Attila Szegedi
*/
static final class MethodSignature {
private final String name;
......
......@@ -90,8 +90,6 @@ import jdk.internal.dynalink.support.TypeUtilities;
/**
* Represents overloaded methods applicable to a specific call site signature.
*
* @author Attila Szegedi
*/
class ApplicableOverloadedMethods {
private final List<SingleDynamicMethod> methods;
......
......@@ -102,8 +102,6 @@ import jdk.internal.dynalink.support.TypeUtilities;
/**
* A class that provides linking capabilities for a single POJO class. Normally not used directly, but managed by
* {@link BeansLinker}.
*
* @author Attila Szegedi
*/
class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicLinker {
BeanLinker(final Class<?> clazz) {
......@@ -316,8 +314,6 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL
/**
* Contains methods to adapt an item getter/setter method handle to the requested type, optionally binding it to a
* fixed key first.
* @author Attila Szegedi
* @version $Id: $
*/
private static class Binder {
private final LinkerServices linkerServices;
......
......@@ -125,8 +125,6 @@ import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker;
* <p><strong>Variable argument invocation</strong> is handled for both methods and constructors.</p>
* <p>Currently, only public fields and methods are supported. Any Lookup objects passed in the
* {@link LinkRequest}s are ignored and {@link MethodHandles#publicLookup()} is used instead.</p>
*
* @author Attila Szegedi
*/
public class BeansLinker implements GuardingDynamicLinker {
private static final ClassValue<TypeBasedGuardingDynamicLinker> linkers = new ClassValue<TypeBasedGuardingDynamicLinker>() {
......
......@@ -98,8 +98,6 @@ import jdk.internal.dynalink.support.Lookup;
* caller sensitive, it doesn't cache a method handle but rather uses the passed lookup object in
* {@link #getTarget(java.lang.invoke.MethodHandles.Lookup)} to unreflect a method handle from the reflective member on
* every request.
*
* @author Attila Szegedi
*/
class CallerSensitiveDynamicMethod extends SingleDynamicMethod {
// Typed as "AccessibleObject" as it can be either a method or a constructor.
......
......@@ -93,7 +93,6 @@ import jdk.internal.dynalink.support.Lookup;
* A linker for java.lang.Class objects. Provides a synthetic property "static" that allows access to static fields and
* methods on the class (respecting property getter/setter conventions). Note that Class objects are not recognized by
* the Dynalink as constructors for the instances of the class, {@link StaticClass} is used for this purpose.
* @author Attila Szegedi
*/
class ClassLinker extends BeanLinker {
......
......@@ -92,8 +92,9 @@ import jdk.internal.dynalink.support.Guards;
import jdk.internal.dynalink.support.TypeUtilities;
/**
*
* @author Attila Szegedi
* Represents a sequence of {@link Class} objects, useful for representing method signatures. Provides value
* semantics for using them as map keys, as well as specificity calculations and applicability checks as per
* JLS.
*/
final class ClassString {
/**
......
......@@ -93,8 +93,6 @@ import jdk.internal.dynalink.linker.LinkerServices;
* overloaded methods will perform overload resolution (actually, it will perform partial overloaded resolution at link
* time, but if that fails to identify exactly one target method, it will generate a method handle that will perform the
* rest of the overload resolution at invocation time for actual argument types).
*
* @author Attila Szegedi
*/
abstract class DynamicMethod {
private final String name;
......
......@@ -97,7 +97,6 @@ import jdk.internal.dynalink.support.Lookup;
/**
* Base for classes that expose class field and method information to an {@link AbstractJavaLinker}. There are
* subclasses for instance (bean) and static facet of a class.
* @author Attila Szegedi
*/
abstract class FacetIntrospector {
private final Class<?> clazz;
......
......@@ -91,8 +91,6 @@ import jdk.internal.dynalink.linker.GuardedInvocation;
* {@link AbstractJavaLinker}. In addition to holding a guarded invocation, it holds semantic information about its
* guard. All guards produced in the AbstractJavaLinker are either "Class.isInstance()" or "getClass() == clazz"
* expressions. This allows choosing the most restrictive guard as the guard for the composition of two components.
* @author Attila Szegedi
* @version $Id: $
*/
class GuardedInvocationComponent {
enum ValidationType {
......
......@@ -94,8 +94,6 @@ import jdk.internal.dynalink.support.TypeUtilities;
/**
* Utility class that encapsulates the algorithm for choosing the maximally specific methods.
*
* @author Attila Szegedi
*/
class MaximallySpecific {
/**
......
......@@ -101,8 +101,6 @@ import jdk.internal.dynalink.support.TypeUtilities;
* Represents a group of {@link SingleDynamicMethod} objects that represents all overloads of a particular name (or all
* constructors) for a particular class. Correctly handles overload resolution, variable arity methods, and caller
* sensitive methods within the overloads.
*
* @author Attila Szegedi
*/
class OverloadedDynamicMethod extends DynamicMethod {
/**
......
......@@ -100,8 +100,6 @@ import jdk.internal.dynalink.support.TypeUtilities;
* a vararg subset depending on the subclass. The method is for a fixed number of arguments though (as it is generated
* for a concrete call site). As such, all methods in the subset can be invoked with the specified number of arguments
* (exactly matching for fixargs, or having less than or equal fixed arguments, for varargs).
*
* @author Attila Szegedi
*/
class OverloadedMethod {
private final Map<ClassString, MethodHandle> argTypesToMethods = new ConcurrentHashMap<>();
......@@ -122,7 +120,7 @@ class OverloadedMethod {
fixArgMethods = new ArrayList<>(methodHandles.size());
varArgMethods = new ArrayList<>(methodHandles.size());
final int argNum = callSiteType.parameterCount();
for(MethodHandle mh: methodHandles) {
for(final MethodHandle mh: methodHandles) {
if(mh.isVarargsCollector()) {
final MethodHandle asFixed = mh.asFixedArity();
if(argNum == asFixed.type().parameterCount()) {
......
......@@ -93,8 +93,6 @@ import java.lang.invoke.MethodType;
* {@link #getTarget(Lookup)}. Can be used in general to represents dynamic methods bound to a single method handle,
* even if that handle is not mapped to a Java method, i.e. as a wrapper around field getters/setters, array element
* getters/setters, etc.
*
* @author Attila Szegedi
*/
class SimpleDynamicMethod extends SingleDynamicMethod {
private final MethodHandle target;
......
......@@ -97,7 +97,6 @@ import jdk.internal.dynalink.support.Lookup;
* Base class for dynamic methods that dispatch to a single target Java method or constructor. Handles adaptation of the
* target method to a call site type (including mapping variable arity methods to a call site signature with different
* arity).
* @author Attila Szegedi
*/
abstract class SingleDynamicMethod extends DynamicMethod {
......
......@@ -99,7 +99,6 @@ import jdk.internal.dynalink.support.Lookup;
/**
* Provides a linker for the {@link StaticClass} objects.
* @author Attila Szegedi
*/
class StaticClassLinker implements TypeBasedGuardingDynamicLinker {
private static final ClassValue<SingleClassStaticsLinker> linkers = new ClassValue<SingleClassStaticsLinker>() {
......
......@@ -90,15 +90,17 @@ package jdk.internal.dynalink.linker;
* of additional conversions. The static way of selecting the "most specific" method will fail more often, because there
* will be multiple maximally specific method with unrelated signatures. In these cases, language runtimes can be asked
* to resolve the ambiguity by expressing preferences for one conversion over the other.
* @author Attila Szegedi
*/
public interface ConversionComparator {
/**
* Enumeration of possible outcomes of comparing one conversion to another.
*/
enum Comparison {
/** The conversions cannot be compared. **/
INDETERMINATE,
/** The first conversion is better than the second one. **/
TYPE_1_BETTER,
/** The second conversion is better than the first one. **/
TYPE_2_BETTER,
}
......
......@@ -101,8 +101,6 @@ import jdk.internal.dynalink.support.Guards;
* external invalidation of the invocation handle. The invocation handle is suitable for invocation if the guard
* handle returns true for its arguments, and as long as the switch point is not invalidated. Both the guard and the
* switch point are optional; neither, one, or both can be present.
*
* @author Attila Szegedi
*/
public class GuardedInvocation {
private final MethodHandle invocation;
......
......@@ -89,8 +89,6 @@ package jdk.internal.dynalink.linker;
* very least, it depends on the receiver belonging to the language runtime of the linker). Language runtime
* implementors will normally implement one for their own language, and declare it in the
* <tt>META-INF/services/jdk.internal.dynalink.linker.GuardingDynamicLinker</tt> file within their JAR file.
*
* @author Attila Szegedi
*/
public interface GuardingDynamicLinker {
/**
......
......@@ -91,8 +91,6 @@ import jdk.internal.dynalink.support.TypeUtilities;
* very likely want to implement {@link ConversionComparator} interface too, as your additional language-specific
* conversions, in absence of a strategy for prioritizing these conversions, will cause more ambiguity in selecting the
* correct overload when trying to link to an overloaded POJO method.
*
* @author Attila Szegedi
*/
public interface GuardingTypeConverterFactory {
/**
......
......@@ -89,8 +89,6 @@ import jdk.internal.dynalink.DynamicLinkerFactory;
/**
* Represents a request to link a particular invocation at a particular call site. Instances of these requests are being
* passed to {@link GuardingDynamicLinker}.
*
* @author Attila Szegedi
*/
public interface LinkRequest {
/**
......
......@@ -95,8 +95,6 @@ import jdk.internal.dynalink.support.TypeUtilities;
* Interface for services provided to {@link GuardingDynamicLinker} instances by the {@link DynamicLinker} that owns
* them. You can think of it as the interface of the {@link DynamicLinker} that faces the {@link GuardingDynamicLinker}
* s.
*
* @author Attila Szegedi
*/
public interface LinkerServices {
/**
......@@ -130,7 +128,11 @@ public interface LinkerServices {
* {@link MethodHandles#filterArguments(MethodHandle, int, MethodHandle...)} with
* {@link GuardingTypeConverterFactory}-produced type converters as filters.
*/
public MethodHandle asTypeLosslessReturn(MethodHandle handle, MethodType fromType);
public default MethodHandle asTypeLosslessReturn(final MethodHandle handle, final MethodType fromType) {
final Class<?> handleReturnType = handle.type().returnType();
return asType(handle, TypeUtilities.isConvertibleWithoutLoss(handleReturnType, fromType.returnType()) ?
fromType : fromType.changeReturnType(handleReturnType));
}
/**
* Given a source and target type, returns a method handle that converts between them. Never returns null; in worst
......@@ -188,23 +190,4 @@ public interface LinkerServices {
* @return a method handle with parameters and/or return type potentially filtered for wrapping and unwrapping.
*/
public MethodHandle filterInternalObjects(final MethodHandle target);
/**
* If we could just use Java 8 constructs, then {@code asTypeSafeReturn} would be a method with default
* implementation. Since we can't do that, we extract common default implementations into this static class.
*/
public static class Implementation {
/**
* Default implementation for {@link LinkerServices#asTypeLosslessReturn(MethodHandle, MethodType)}.
* @param linkerServices the linker services that delegates to this implementation
* @param handle the passed handle
* @param fromType the passed type
* @return the converted method handle, as per the {@code asTypeSafeReturn} semantics.
*/
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));
}
}
}
......@@ -88,8 +88,6 @@ package jdk.internal.dynalink.linker;
* argument at linking invocation time. (The first argument is usually the receiver class). Most language-specific
* linkers will fall into this category, as they recognize their native objects as Java objects of classes implementing
* a specific language-native interface or superclass. The linker mechanism can optimize the dispatch for these linkers.
*
* @author Attila Szegedi
*/
public interface TypeBasedGuardingDynamicLinker extends GuardingDynamicLinker {
/**
......
......@@ -91,7 +91,6 @@ import jdk.internal.dynalink.CallSiteDescriptor;
/**
* A base class for call site descriptor implementations. Provides reconstruction of the name from the tokens, as well
* as a generally useful {@code equals} and {@code hashCode} methods.
* @author Attila Szegedi
*/
public abstract class AbstractCallSiteDescriptor implements CallSiteDescriptor {
......
......@@ -90,8 +90,6 @@ import jdk.internal.dynalink.RelinkableCallSite;
/**
* A basic implementation of the {@link RelinkableCallSite} as a {@link MutableCallSite} subclass.
*
* @author Attila Szegedi
*/
public abstract class AbstractRelinkableCallSite extends MutableCallSite implements RelinkableCallSite {
private final CallSiteDescriptor descriptor;
......
......@@ -91,8 +91,6 @@ import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker;
/**
* A linker that can't link any call site. Only used internally by {@link CompositeTypeBasedGuardingDynamicLinker}. Can
* be used by other language runtimes if they need it though.
*
* @author Attila Szegedi
*/
public class BottomGuardingDynamicLinker implements TypeBasedGuardingDynamicLinker {
......
......@@ -97,12 +97,12 @@ import java.util.WeakHashMap;
import jdk.internal.dynalink.CallSiteDescriptor;
/**
* Usable as a default factory for call site descriptor implementations. It is weakly canonicalizing, meaning it will
* return the same immutable call site descriptor for identical inputs, i.e. repeated requests for a descriptor
* signifying public lookup for "dyn:getProp:color" of type "Object(Object)" will return the same object as long as
* a previously created, at least softly reachable one exists. It also uses several different implementations of the
* {@link CallSiteDescriptor} internally, and chooses the most space-efficient one based on the input.
* @author Attila Szegedi
* Usable as a default factory for call site descriptor implementations. It is weakly canonicalizing, meaning
* it will return the same immutable call site descriptor for identical inputs, i.e. repeated requests for a
* descriptor signifying public lookup for {@code "dyn:getProp:color"} of type {@code Object(Object)} will
* return the same object as long as a previously created, at least softly reachable one exists. It also uses
* several different implementations of the {@link CallSiteDescriptor} internally, and chooses the most
* space-efficient one based on the input.
*/
public class CallSiteDescriptorFactory {
private static final WeakHashMap<CallSiteDescriptor, Reference<CallSiteDescriptor>> publicDescs =
......
......@@ -96,7 +96,6 @@ import java.util.concurrent.ConcurrentMap;
* A dual map that can either strongly or weakly reference a given class depending on whether the class is visible from
* a class loader or not.
*
* @author Attila Szegedi
* @param <T> the type of the values in the map
*/
public abstract class ClassMap<T> {
......
......@@ -95,8 +95,6 @@ import jdk.internal.dynalink.linker.LinkerServices;
* A {@link GuardingDynamicLinker} that delegates sequentially to a list of other guarding dynamic linkers. The first
* value returned from a component linker other than null is returned. If no component linker returns an invocation,
* null is returned.
*
* @author Attila Szegedi
*/
public class CompositeGuardingDynamicLinker implements GuardingDynamicLinker, Serializable {
......
......@@ -98,8 +98,6 @@ import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker;
* are queried sequentially on their {@link TypeBasedGuardingDynamicLinker#canLinkType(Class)} method. The linkers
* returning true are then bound to the class, and next time a receiver of same type is encountered, the linking is
* delegated to those linkers only, speeding up dispatch.
*
* @author Attila Szegedi
*/
public class CompositeTypeBasedGuardingDynamicLinker implements TypeBasedGuardingDynamicLinker, Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -91,7 +91,6 @@ import jdk.internal.dynalink.CallSiteDescriptor;
* A default, fairly light implementation of a call site descriptor used for describing non-standard operations. It does
* not store {@link Lookup} objects but always returns the public lookup from its {@link #getLookup()} method. If you
* need to support non-public lookup, you can use {@link LookupCallSiteDescriptor}.
* @author Attila Szegedi
*/
class DefaultCallSiteDescriptor extends AbstractCallSiteDescriptor {
......
......@@ -94,7 +94,6 @@ import jdk.internal.dynalink.linker.LinkerServices;
/**
* Utility methods for creating typical guards. TODO: introduce reasonable caching of created guards.
*
* @author Attila Szegedi
*/
public class Guards {
private static final Logger LOG = Logger
......
......@@ -89,8 +89,6 @@ import jdk.internal.dynalink.linker.LinkRequest;
/**
* Default implementation of the {@link LinkRequest}, representing a link request to a call site that passes no language
* runtime specific native context arguments on the stack.
*
* @author Attila Szegedi
*/
public class LinkRequestImpl implements LinkRequest {
......
......@@ -94,8 +94,6 @@ import jdk.internal.dynalink.linker.MethodHandleTransformer;
/**
* Default implementation of the {@link LinkerServices} interface.
*
* @author Attila Szegedi
*/
public class LinkerServicesImpl implements LinkerServices {
......@@ -131,11 +129,6 @@ public class LinkerServicesImpl implements LinkerServices {
return typeConverterFactory.asType(handle, fromType);
}
@Override
public MethodHandle asTypeLosslessReturn(final MethodHandle handle, final MethodType fromType) {
return Implementation.asTypeLosslessReturn(this, handle, fromType);
}
@Override
public MethodHandle getTypeConverter(final Class<?> sourceType, final Class<?> targetType) {
return typeConverterFactory.getTypeConverter(sourceType, targetType);
......
......@@ -93,8 +93,6 @@ import java.lang.reflect.Method;
/**
* A wrapper around MethodHandles.Lookup that masks checked exceptions in those cases when you're looking up methods
* within your own codebase (therefore it is an error if they are not present).
*
* @author Attila Szegedi
*/
public class Lookup {
private final MethodHandles.Lookup lookup;
......
......@@ -89,7 +89,6 @@ import jdk.internal.dynalink.CallSiteDescriptor;
/**
* A call site descriptor that stores a specific {@link Lookup}. It does not, however, store static bootstrap arguments.
* @author Attila Szegedi
*/
class LookupCallSiteDescriptor extends DefaultCallSiteDescriptor {
private final Lookup lookup;
......
......@@ -99,8 +99,6 @@ import jdk.internal.dynalink.CallSiteDescriptor;
* have your own way of creating call site descriptors, but you still delegate to this method of the default factory
* (it is recommended that you do), then you have demangling handled for you already, and only need to ensure that you
* mangle the names when you're emitting them in the bytecode.
*
* @author Attila Szegedi
*/
public class NameCodec {
private static final char ESCAPE_CHAR = '\\';
......
......@@ -89,8 +89,6 @@ import jdk.internal.dynalink.linker.LinkRequest;
/**
* A link request implementation for call sites that pass language runtime specific context arguments on the stack. The
* context specific arguments should be the first "n" arguments.
*
* @author Attila Szegedi
*/
public class RuntimeContextLinkRequestImpl extends LinkRequestImpl {
......
......@@ -103,8 +103,6 @@ import jdk.internal.dynalink.linker.MethodTypeConversionStrategy;
* A factory for type converters. This class is the main implementation behind the
* {@link LinkerServices#asType(MethodHandle, MethodType)}. It manages the known {@link GuardingTypeConverterFactory}
* instances and creates appropriate converters for method handles.
*
* @author Attila Szegedi
*/
public class TypeConverterFactory {
......
......@@ -96,8 +96,6 @@ import java.util.Set;
/**
* Various static utility methods for testing type relationships.
*
* @author Attila Szegedi
*/
public class TypeUtilities {
static final Class<Object> OBJECT_CLASS = Object.class;
......
......@@ -210,11 +210,6 @@ public class NashornBeansLinker implements GuardingDynamicLinker {
return linkerServices.asType(handle, fromType);
}
@Override
public MethodHandle asTypeLosslessReturn(final MethodHandle handle, final MethodType fromType) {
return Implementation.asTypeLosslessReturn(this, handle, fromType);
}
@Override
public MethodHandle getTypeConverter(final Class<?> sourceType, final Class<?> targetType) {
return linkerServices.getTypeConverter(sourceType, targetType);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册