IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
BootstrapClassLoader.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-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
27#if IMPORTER || EXPORTER
28using IKVM.Reflection;
29
30using Type = IKVM.Reflection.Type;
31#endif
32
33namespace IKVM.Runtime
34{
35
39 sealed class BootstrapClassLoader : RuntimeAssemblyClassLoader
40 {
41
45 internal BootstrapClassLoader(RuntimeContext context) :
46 base(context, context.Resolver.ResolveBaseAssembly().AsReflection(), [typeof(object).Assembly.FullName, typeof(Uri).Assembly.FullName])
47 {
48#if FIRST_PASS == false && IMPORTER == false && EXPORTER == false
49 RegisterNativeLibrary(LibJava.Instance.Handle);
50#endif
51 }
52
53 internal override RuntimeJavaType GetJavaTypeFromAssemblyType(Type type)
54 {
55 // we have to special case the fake types here
56 if (type.IsGenericType && !type.IsGenericTypeDefinition)
57 {
58 var outer = Context.ClassLoaderFactory.GetJavaTypeFromType(type.GetGenericArguments()[0]);
59
60 foreach (var inner in outer.InnerClasses)
61 {
62 if (inner.TypeAsTBD == type)
63 return inner;
64
65 foreach (var inner2 in inner.InnerClasses)
66 if (inner2.TypeAsTBD == type)
67 return inner2;
68 }
69
70 return null;
71 }
72
73 return base.GetJavaTypeFromAssemblyType(type);
74 }
75
76 protected override void CheckProhibitedPackage(string className)
77 {
78
79 }
80
81#if !FIRST_PASS && !IMPORTER && !EXPORTER
82
83 internal override java.lang.ClassLoader GetJavaClassLoader()
84 {
85 return null;
86 }
87
88 internal override java.security.ProtectionDomain GetProtectionDomain()
89 {
90 return null;
91 }
92
93 internal override IEnumerable<java.net.URL> GetResources(string name)
94 {
95 foreach (java.net.URL url in FindResources(name))
96 yield return url;
97
98 foreach (var res in FindDelegateResources(name))
99 yield return res.URL;
100 }
101
102#endif
103
104 }
105
106}
IKVM.Reflection.Type Type
IKVM.Reflection.Assembly Assembly
Represents the bootstrap class loader of the system, containing only built-in .NET assemblies.
override void CheckProhibitedPackage(string className)
RuntimeContext Context
Gets a reference to the RuntimeContext that this RuntimeClassLoader is hosted within.
Maintains services relevant to an instane of the IKVM runtime.
ISymbolResolver Resolver
Gets the ISymbolResolver associated with this instance of the runtime.
RuntimeClassLoaderFactory ClassLoaderFactory
Gets the RuntimeClassLoaderFactory associated with this instance of the runtime.