IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
DynamicCallerIDProvider.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 System;
25using System.Diagnostics;
26
27namespace IKVM.Runtime
28{
29
30#if IMPORTER == false
31
33 {
34
35 // this object acts as a capability that is passed to trusted code to allow the DynamicCallerID()
36 // method to be public without giving untrusted code the ability to forge a CallerID token
37 internal static readonly DynamicCallerIDProvider Instance = new DynamicCallerIDProvider();
38
43 {
44
45 }
46
47 internal ikvm.@internal.CallerID GetCallerID()
48 {
49#if FIRST_PASS
50 throw new NotImplementedException();
51#else
52 for (int i = 0; ;)
53 {
54 var method = new StackFrame(i++, false).GetMethod();
55 if (method == null)
56 return ikvm.@internal.CallerID.create(null, null);
57
58 if (IKVM.Java.Externs.sun.reflect.Reflection.IsHideFromStackWalk(method))
59 continue;
60
61 var caller = JVM.Context.ClassLoaderFactory.GetJavaTypeFromType(method.DeclaringType);
62 return CreateCallerID(caller.Host ?? caller);
63 }
64#endif
65 }
66
67 internal static ikvm.@internal.CallerID CreateCallerID(RuntimeJavaType tw)
68 {
69#if FIRST_PASS
70 throw new NotImplementedException();
71#else
72 return ikvm.@internal.CallerID.create(tw.ClassObject, tw.ClassLoader.GetJavaClassLoader());
73#endif
74 }
75
76 }
77
78#endif
79
80}
Provides the implementations of the native methods in global::sun.reflect.Reflection.
Definition Reflection.cs:40
Main state of the running JVM.
RuntimeClassLoaderFactory ClassLoaderFactory
Gets the RuntimeClassLoaderFactory associated with this instance of the runtime.