IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ClassFile.ConstantPoolItemInvokeDynamic.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*/
24using IKVM.ByteCode;
25using IKVM.ByteCode.Decoding;
26
27namespace IKVM.Runtime
28{
29
30 sealed partial class ClassFile
31 {
32
36 internal sealed class ConstantPoolItemInvokeDynamic : ConstantPoolItem
37 {
38
39 readonly ushort _bootstrapMethodAttributeIndex;
40 readonly NameAndTypeConstantHandle _nameAndTypeHandle;
41
42 string _name;
43 string _descriptor;
44 RuntimeJavaType[] _argTypes;
45 RuntimeJavaType _returnType;
46
52 public ConstantPoolItemInvokeDynamic(RuntimeContext context, InvokeDynamicConstantData data) :
53 base(context)
54 {
55 _bootstrapMethodAttributeIndex = data.BootstrapMethodAttributeIndex;
56 _nameAndTypeHandle = data.NameAndType;
57 }
58
60 public override void Resolve(ClassFile classFile, string[] utf8_cp, ClassFileParseOptions options)
61 {
62 var nameAndType = (ConstantPoolItemNameAndType)classFile.GetConstantPoolItem(_nameAndTypeHandle);
63 if (nameAndType == null)
64 throw new ClassFormatError("Bad index in constant pool");
65
66 _name = string.Intern(classFile.GetConstantPoolUtf8String(utf8_cp, nameAndType.NameHandle));
67 _descriptor = string.Intern(classFile.GetConstantPoolUtf8String(utf8_cp, nameAndType.DescriptorHandle).Replace('/', '.'));
68 }
69
71 public override void Link(RuntimeJavaType thisType, LoadMode mode)
72 {
73 lock (this)
74 if (_argTypes != null)
75 return;
76
77 var classLoader = thisType.ClassLoader;
78 var args = classLoader.ArgJavaTypeListFromSig(_descriptor, mode);
79 var ret = classLoader.RetTypeWrapperFromSig(_descriptor, mode);
80
81 lock (this)
82 {
83 if (_argTypes == null)
84 {
85 _argTypes = args;
86 _returnType = ret;
87 }
88 }
89 }
90
91 public RuntimeJavaType[] GetArgTypes()
92 {
93 return _argTypes;
94 }
95
96 public RuntimeJavaType GetRetType()
97 {
98 return _returnType;
99 }
100
101 public string Name => _name;
102
103 public string Signature => _descriptor;
104
105 public ushort BootstrapMethod => _bootstrapMethodAttributeIndex;
106
107 }
108
109 }
110
111}
global::java.lang.invoke.LambdaForm.Name Name