internal MethodHandle(JavaClassImage image, MethodHandleInfo info) { Kind = info.ReferenceKind; switch (Kind) { case MethodReferenceKind.GetField: case MethodReferenceKind.GetStatic: case MethodReferenceKind.PutField: case MethodReferenceKind.PutStatic: _member = new LazyValue <IMemberReference>(() => image.ResolveField(info.ReferenceIndex)); break; case MethodReferenceKind.InvokeVirtual: case MethodReferenceKind.InvokeStatic: case MethodReferenceKind.InvokeSpecial: case MethodReferenceKind.NewInvokeSpecial: _member = new LazyValue <IMemberReference>(() => image.ResolveMethod(info.ReferenceIndex)); break; case MethodReferenceKind.InvokeInterface: throw new NotImplementedException(); default: throw new ArgumentOutOfRangeException(); } }
public bool Equals(MethodHandleInfo x, MethodHandleInfo y) { if (ReferenceEquals(x, y)) { return(true); } if (ReferenceEquals(x, null) || ReferenceEquals(y, null)) { return(false); } return(x.ReferenceKind == y.ReferenceKind && x.ReferenceIndex == y.ReferenceIndex); }
public int GetMethodHandleIndex(MethodHandle methodHandle) { var info = new MethodHandleInfo { ReferenceKind = methodHandle.Kind, ReferenceIndex = (ushort)GetMemberIndex(methodHandle.Member) }; if (!_methodHandleInfos.TryGetValue(info, out int index)) { index = AddConstant(info); _methodHandleInfos.Add(info, index); } return(index); }
internal readonly MethodType[] AdditionalBridges; // Signatures of additional methods to bridge /// <summary> /// Meta-factory constructor. /// </summary> /// <param name="caller"> Stacked automatically by VM; represents a lookup context /// with the accessibility privileges of the caller. </param> /// <param name="invokedType"> Stacked automatically by VM; the signature of the /// invoked method, which includes the expected static /// type of the returned lambda object, and the static /// types of the captured arguments for the lambda. In /// the event that the implementation method is an /// instance method, the first argument in the invocation /// signature will correspond to the receiver. </param> /// <param name="samMethodName"> Name of the method in the functional interface to /// which the lambda or method reference is being /// converted, represented as a String. </param> /// <param name="samMethodType"> Type of the method in the functional interface to /// which the lambda or method reference is being /// converted, represented as a MethodType. </param> /// <param name="implMethod"> The implementation method which should be called /// (with suitable adaptation of argument types, return /// types, and adjustment for captured arguments) when /// methods of the resulting functional interface instance /// are invoked. </param> /// <param name="instantiatedMethodType"> The signature of the primary functional /// interface method after type variables are /// substituted with their instantiation from /// the capture site </param> /// <param name="isSerializable"> Should the lambda be made serializable? If set, /// either the target type or one of the additional SAM /// types must extend {@code Serializable}. </param> /// <param name="markerInterfaces"> Additional interfaces which the lambda object /// should implement. </param> /// <param name="additionalBridges"> Method types for additional signatures to be /// bridged to the implementation method </param> /// <exception cref="LambdaConversionException"> If any of the meta-factory protocol /// invariants are violated </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: AbstractValidatingLambdaMetafactory(MethodHandles.Lookup caller, MethodType invokedType, String samMethodName, MethodType samMethodType, MethodHandle implMethod, MethodType instantiatedMethodType, boolean isSerializable, Class[] markerInterfaces, MethodType[] additionalBridges) throws LambdaConversionException internal AbstractValidatingLambdaMetafactory(MethodHandles.Lookup caller, MethodType invokedType, String samMethodName, MethodType samMethodType, MethodHandle implMethod, MethodType instantiatedMethodType, bool isSerializable, Class[] markerInterfaces, MethodType[] additionalBridges) { if ((caller.LookupModes() & MethodHandles.Lookup.PRIVATE) == 0) { throw new LambdaConversionException(string.Format("Invalid caller: {0}", caller.LookupClass().Name)); } this.TargetClass = caller.LookupClass(); this.InvokedType = invokedType; this.SamBase = invokedType.ReturnType(); this.SamMethodName = samMethodName; this.SamMethodType = samMethodType; this.ImplMethod = implMethod; this.ImplInfo = caller.RevealDirect(implMethod); this.ImplKind = ImplInfo.ReferenceKind; this.ImplIsInstanceMethod = ImplKind == MethodHandleInfo.REF_invokeVirtual || ImplKind == MethodHandleInfo.REF_invokeSpecial || ImplKind == MethodHandleInfo.REF_invokeInterface; this.ImplDefiningClass = ImplInfo.DeclaringClass; this.ImplMethodType = ImplInfo.MethodType; this.InstantiatedMethodType = instantiatedMethodType; this.IsSerializable = isSerializable; this.MarkerInterfaces = markerInterfaces; this.AdditionalBridges = additionalBridges; if (!SamBase.Interface) { throw new LambdaConversionException(string.Format("Functional interface {0} is not an interface", SamBase.Name)); } foreach (Class c in markerInterfaces) { if (!c.Interface) { throw new LambdaConversionException(string.Format("Marker interface {0} is not an interface", c.Name)); } } }
protected bool Equals(MethodHandleInfo other) { return(ReferenceKind == other.ReferenceKind && ReferenceIndex == other.ReferenceIndex); }
public override String ToString() { return(MethodHandleInfo.ToString(ReferenceKind, DeclaringClass, Name, MethodType)); }
public int GetHashCode(MethodHandleInfo obj) { return(((byte)obj.ReferenceKind << 16) | obj.ReferenceIndex); }
public override String ToString() { String implKind = MethodHandleInfo.referenceKindToString(ImplMethodKind_Renamed); return(string.Format("SerializedLambda[{0}={1}, {2}={3}.{4}:{5}, " + "{6}={7} {8}.{9}:{10}, {11}={12}, {13}={14:D}]", "capturingClass", CapturingClass_Renamed, "functionalInterfaceMethod", FunctionalInterfaceClass_Renamed, FunctionalInterfaceMethodName_Renamed, FunctionalInterfaceMethodSignature_Renamed, "implementation", implKind, ImplClass_Renamed, ImplMethodName_Renamed, ImplMethodSignature_Renamed, "instantiatedMethodType", InstantiatedMethodType_Renamed, "numCaptured", CapturedArgs.Length)); }