IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ClassFile.ConstantPoolItemMethodType.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 ConstantPoolItemMethodType : ConstantPoolItem
37 {
38
39 readonly Utf8ConstantHandle signature;
40
41 string descriptor;
42 RuntimeJavaType[] argTypeWrappers;
43 RuntimeJavaType retTypeWrapper;
44
50 public ConstantPoolItemMethodType(RuntimeContext context, MethodTypeConstantData data) :
51 base(context)
52 {
53 signature = data.Descriptor;
54 }
55
57 public override ConstantType GetConstantType() => ConstantType.MethodType;
58
60 public override void Resolve(ClassFile classFile, string[] utf8_cp, ClassFileParseOptions options)
61 {
62 var descriptor = classFile.GetConstantPoolUtf8String(utf8_cp, signature);
63 if (descriptor == null || !IsValidMethodDescriptor(descriptor))
64 throw new ClassFormatError("Invalid MethodType signature");
65
66 this.descriptor = string.Intern(descriptor.Replace('/', '.'));
67 }
68
70 public override void Link(RuntimeJavaType thisType, LoadMode mode)
71 {
72 lock (this)
73 if (argTypeWrappers != null)
74 return;
75
76 var classLoader = thisType.ClassLoader;
77 var args = classLoader.ArgJavaTypeListFromSig(descriptor, mode);
78 var ret = classLoader.RetTypeWrapperFromSig(descriptor, mode);
79
80 lock (this)
81 {
82 if (argTypeWrappers == null)
83 {
84 argTypeWrappers = args;
85 retTypeWrapper = ret;
86 }
87 }
88 }
89
90 public string Signature => descriptor;
91
92 public RuntimeJavaType[] GetArgTypes() => argTypeWrappers;
93
94 public RuntimeJavaType GetRetType() => retTypeWrapper;
95
96 }
97
98 }
99
100}
static bool IsValidMethodDescriptor(string descriptor)
Returns true if the specified descriptor is a valid method descriptor.
Definition ClassFile.cs:220