IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
RuntimeManagedByteCodeJavaType.DelegateConstructorJavaMethod.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2015 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24
25#if IMPORTER || EXPORTER
26using IKVM.Reflection;
28
29using Type = IKVM.Reflection.Type;
30#else
31using System.Reflection;
32using System.Reflection.Emit;
33#endif
34
35namespace IKVM.Runtime
36{
37
38 partial class RuntimeManagedByteCodeJavaType
39 {
40
41 sealed class DelegateConstructorJavaMethod : RuntimeJavaMethod
42 {
43
44 readonly ConstructorInfo constructor;
45 MethodInfo invoke;
46
53 DelegateConstructorJavaMethod(RuntimeJavaType tw, RuntimeJavaType iface, ExModifiers mods) :
54 base(tw, StringConstants.INIT, "(" + iface.SigName + ")V", null, tw.Context.PrimitiveJavaTypeFactory.VOID, new RuntimeJavaType[] { iface }, mods.Modifiers, mods.IsInternal ? MemberFlags.InternalAccess : MemberFlags.None)
55 {
56
57 }
58
64 internal DelegateConstructorJavaMethod(RuntimeJavaType tw, MethodBase method) :
65 this(tw, tw.ClassLoader.LoadClassByName(tw.Name + RuntimeManagedJavaType.DelegateInterfaceSuffix), tw.Context.AttributeHelper.GetModifiers(method, false))
66 {
67 constructor = (ConstructorInfo)method;
68 }
69
70 protected override void DoLinkMethod()
71 {
72 var mw = GetParameters()[0].GetMethods()[0];
73 mw.Link();
74 invoke = (MethodInfo)mw.GetMethod();
75 }
76
77#if EMITTERS
78
79 internal override void EmitNewobj(CodeEmitter ilgen)
80 {
81 ilgen.Emit(OpCodes.Dup);
82 ilgen.Emit(OpCodes.Ldvirtftn, invoke);
83 ilgen.Emit(OpCodes.Newobj, constructor);
84 }
85
86#endif // EMITTERS
87
88 }
89
90 }
91
92}
IKVM.Reflection.Type Type
IKVM.Reflection.ConstructorInfo ConstructorInfo
IKVM.Reflection.MethodInfo MethodInfo
IKVM.Reflection.MethodBase MethodBase
global::java.lang.invoke.LambdaForm.Name Name
MemberFlags
Describes various options applied to a member.