IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
Executable.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2007-2013 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 System;
25using System.Collections.Generic;
26
27using IKVM.Runtime;
28
30{
31
32 static class Executable
33 {
34
35 public static object[] getParameters0(global::java.lang.reflect.Executable _this)
36 {
37#if FIRST_PASS
38 throw new NotImplementedException();
39#else
40 var mw = RuntimeJavaMethod.FromExecutable(_this);
41 var methodParameters = mw.DeclaringType.GetMethodParameters(mw);
42 if (methodParameters == null)
43 return null;
44
45 if (methodParameters == MethodParametersEntry.Malformed)
46 throw new global::java.lang.reflect.MalformedParametersException("Invalid constant pool index");
47
48 var parameters = new global::java.lang.reflect.Parameter[methodParameters.Length];
49 for (int i = 0; i < parameters.Length; i++)
50 parameters[i] = new global::java.lang.reflect.Parameter(methodParameters[i].name ?? "", (int)(ushort)methodParameters[i].accessFlags, _this, i);
51
52 return parameters;
53#endif
54 }
55
56 public static byte[] getTypeAnnotationBytes0(global::java.lang.reflect.Executable _this)
57 {
58 var mw = RuntimeJavaMethod.FromExecutable(_this);
59 return mw.DeclaringType.GetMethodRawTypeAnnotations(mw);
60 }
61
62 public static object declaredAnnotationsImpl(global::java.lang.reflect.Executable executable)
63 {
64 var mw = RuntimeJavaMethod.FromExecutable(executable);
65 return IKVM.Java.Externs.java.lang.Class.AnnotationsToMap(mw.DeclaringType.ClassLoader, mw.DeclaringType.GetMethodAnnotations(mw));
66 }
67
68 public static object[][] sharedGetParameterAnnotationsImpl(global::java.lang.reflect.Executable executable)
69 {
70#if FIRST_PASS
71 throw new NotImplementedException();
72#else
73 var mw = RuntimeJavaMethod.FromExecutable(executable);
74 var objAnn = mw.DeclaringType.GetParameterAnnotations(mw);
75 if (objAnn == null)
76 return null;
77
78 var ann = new global::java.lang.annotation.Annotation[objAnn.Length][];
79 for (int i = 0; i < ann.Length; i++)
80 {
81 var list = new List<global::java.lang.annotation.Annotation>();
82 foreach (var obj in objAnn[i])
83 {
84 var a = obj as global::java.lang.annotation.Annotation;
85 if (a != null)
86 {
87 list.Add(IKVM.Java.Externs.java.lang.Class.FreezeOrWrapAttribute(a));
88 }
90 {
91 a = (global::java.lang.annotation.Annotation)JVM.NewAnnotation(mw.DeclaringType.ClassLoader.GetJavaClassLoader(), ((IKVM.Attributes.DynamicAnnotationAttribute)obj).Definition);
92 if (a != null)
93 list.Add(a);
94 }
95 }
96
97 ann[i] = list.ToArray();
98 }
99
100 return ann;
101#endif
102 }
103
104 }
105
106}
Implements the native methods for 'java.lang.Class'.
Definition Class.cs:37
static object[][] sharedGetParameterAnnotationsImpl(global::java.lang.reflect.Executable executable)
Definition Executable.cs:68
static object declaredAnnotationsImpl(global::java.lang.reflect.Executable executable)
Definition Executable.cs:62
static object[] getParameters0(global::java.lang.reflect.Executable _this)
Definition Executable.cs:35
static byte[] getTypeAnnotationBytes0(global::java.lang.reflect.Executable _this)
Definition Executable.cs:56
Main state of the running JVM.