IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader Class Reference

Static Public Member Functions

static void setWrapper (global::java.lang.ClassLoader _this, Assembly assembly)
 
static global::java.lang.Class loadClass (global::java.lang.ClassLoader _this, string name, bool resolve)
 
static global::java.net.URL getResource (global::java.lang.ClassLoader _this, string name)
 
static global::java.util.Enumeration getResources (global::java.lang.ClassLoader _this, string name)
 
static global::java.net.URL findResource (global::java.lang.ClassLoader _this, string name)
 
static global::java.util.Enumeration findResources (global::java.lang.ClassLoader _this, string name)
 
static void lazyDefinePackages (global::java.lang.ClassLoader _this)
 Defines all of the packages in the class loader that are not currently defined, using the assembly as a source.
 
static string toString (global::java.lang.ClassLoader _this)
 
static global::java.lang.ClassLoader getAssemblyClassLoader (Assembly asm)
 

Detailed Description

Definition at line 34 of file AssemblyClassLoader.cs.

Member Function Documentation

◆ findResource()

static global.java.net.URL IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.findResource ( global.java.lang.ClassLoader _this,
string name )
static

Definition at line 116 of file AssemblyClassLoader.cs.

117 {
118#if FIRST_PASS
119 throw new NotImplementedException();
120#else
121 var wrapper = (RuntimeAssemblyClassLoader)JVM.Context.ClassLoaderFactory.GetClassLoaderWrapper(_this);
122 foreach (global::java.net.URL url in wrapper.FindResources(name))
123 {
124 return url;
125 }
126
127 return null;
128#endif
129 }
Main state of the running JVM.
RuntimeClassLoaderFactory ClassLoaderFactory
Gets the RuntimeClassLoaderFactory associated with this instance of the runtime.

◆ findResources()

static global.java.util.Enumeration IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.findResources ( global.java.lang.ClassLoader _this,
string name )
static

Definition at line 131 of file AssemblyClassLoader.cs.

132 {
133#if FIRST_PASS
134 throw new NotImplementedException();
135#else
136 return new global::ikvm.runtime.EnumerationWrapper(((RuntimeAssemblyClassLoader)JVM.Context.ClassLoaderFactory.GetClassLoaderWrapper(_this)).FindResources(name));
137#endif
138 }

◆ getAssemblyClassLoader()

static global.java.lang.ClassLoader IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.getAssemblyClassLoader ( Assembly asm)
static

Definition at line 258 of file AssemblyClassLoader.cs.

259 {
260#if FIRST_PASS
261 throw new NotImplementedException();
262#else
263 // note that we don't do a security check here, because if you have the Assembly object,
264 // you can already get at all the types in it.
265 return JVM.Context.AssemblyClassLoaderFactory.FromAssembly(asm).GetJavaClassLoader();
266#endif
267 }
RuntimeAssemblyClassLoader FromAssembly(Assembly assembly)
Obtains the RuntimeAssemblyClassLoader for the given Assembly. This method should not be used with dy...
RuntimeAssemblyClassLoaderFactory AssemblyClassLoaderFactory
Gets the RuntimeAssemblyClassLoaderFactory associated with this instance of the runtime.

◆ getResource()

static global.java.net.URL IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.getResource ( global.java.lang.ClassLoader _this,
string name )
static

Definition at line 94 of file AssemblyClassLoader.cs.

95 {
96#if FIRST_PASS
97 throw new NotImplementedException();
98#else
99 var wrapper = (RuntimeAssemblyClassLoader)JVM.Context.ClassLoaderFactory.GetClassLoaderWrapper(_this);
100 foreach (global::java.net.URL url in wrapper.GetResources(name))
101 return url;
102
103 return null;
104#endif
105 }

◆ getResources()

static global.java.util.Enumeration IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.getResources ( global.java.lang.ClassLoader _this,
string name )
static

Definition at line 107 of file AssemblyClassLoader.cs.

108 {
109#if FIRST_PASS
110 throw new NotImplementedException();
111#else
112 return new global::ikvm.runtime.EnumerationWrapper(((RuntimeAssemblyClassLoader)JVM.Context.ClassLoaderFactory.GetClassLoaderWrapper(_this)).GetResources(name));
113#endif
114 }

◆ lazyDefinePackages()

static void IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.lazyDefinePackages ( global.java.lang.ClassLoader _this)
static

Defines all of the packages in the class loader that are not currently defined, using the assembly as a source.

Parameters
_this

Definition at line 209 of file AssemblyClassLoader.cs.

210 {
211#if FIRST_PASS
212 throw new NotImplementedException();
213#else
214 var wrapper = (RuntimeAssemblyClassLoader)JVM.Context.ClassLoaderFactory.GetClassLoaderWrapper(_this);
215 var sealBase = GetCodeBase(wrapper.MainAssembly);
216
217 foreach (var packages in wrapper.GetPackageInfo())
218 {
219 // if the package exists in a JAR within the main assembly, load its manifest
220 var manifest = packages.Key != null ? GetManifestForAssemblyJar(wrapper.MainAssembly, packages.Key) : null;
221
222 // if we loaded a manifest, get the main attributes
223 var mainAttributes = manifest?.getMainAttributes();
224
225 // for each package, check if defined, else define
226 foreach (var name in packages.Value)
227 {
228 if (_this.getPackage(name) != null)
229 continue;
230
231 // manifest might contain an overriding entry for this specific package
232 var packageAttributes = manifest?.getAttributes(name.Replace('.', '/') + '/');
233
234 // define package with package information from package attributes or main attributes
235 _this.definePackage(
236 name,
237 GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_TITLE, packageAttributes, mainAttributes),
238 GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_VERSION, packageAttributes, mainAttributes),
239 GetAttributeValue(global::java.util.jar.Attributes.Name.SPECIFICATION_VENDOR, packageAttributes, mainAttributes),
240 GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_TITLE, packageAttributes, mainAttributes),
241 GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_VERSION, packageAttributes, mainAttributes),
242 GetAttributeValue(global::java.util.jar.Attributes.Name.IMPLEMENTATION_VENDOR, packageAttributes, mainAttributes),
243 string.Equals(GetAttributeValue(global::java.util.jar.Attributes.Name.SEALED, packageAttributes, mainAttributes), "true", StringComparison.OrdinalIgnoreCase) ? sealBase : null);
244 }
245 }
246#endif
247 }

◆ loadClass()

static global.java.lang.Class IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.loadClass ( global.java.lang.ClassLoader _this,
string name,
bool resolve )
static

Definition at line 54 of file AssemblyClassLoader.cs.

55 {
56#if FIRST_PASS
57 throw new NotImplementedException();
58#else
59 try
60 {
61 if (ClassLoaderAccessor.InvokeCheckName(_this, name) == false)
62 throw new ClassNotFoundException(name);
63
64 var wrapper = (RuntimeAssemblyClassLoader)JVM.Context.ClassLoaderFactory.GetClassLoaderWrapper(_this);
65 var tw = wrapper.LoadClass(name);
66 if (tw == null)
67 {
68 JVM.Context.Diagnostics.GenericClassLoadingInfo($"Failed to load class \"{name}\" from {_this}");
69 global::java.lang.Throwable.suppressFillInStackTrace = true;
70 throw new global::java.lang.ClassNotFoundException(name);
71 }
72
73 JVM.Context.Diagnostics.GenericClassLoadingInfo($"Loaded class \"{name}\" from {_this}");
74 return tw.ClassObject;
75 }
77 {
78 JVM.Context.Diagnostics.GenericClassLoadingInfo($"Failed to load class \"{name}\" from {_this}: {x.Message}");
79 throw new global::java.lang.ClassNotFoundException(x.Message);
80 }
81 catch (ClassLoadingException x)
82 {
83 JVM.Context.Diagnostics.GenericClassLoadingInfo($"Failed to load class \"{name}\" from {_this}: {x.Message}");
84 throw x.InnerException;
85 }
87 {
88 JVM.Context.Diagnostics.GenericClassLoadingInfo($"Failed to load class \"{name}\" from {_this}: {x.Message}");
89 throw x.ToJava();
90 }
91#endif
92 }
This is not a Java exception, but instead it wraps a Java exception that was thrown by a class loader...
.NET exception that corresponds to a Java exception.
IDiagnosticHandler Diagnostics
Gets the IDiagnosticHandler where events should be sent.
void GenericClassLoadingInfo(string arg0)
The 'GenericClassLoadingInfo' diagnostic.

◆ setWrapper()

static void IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.setWrapper ( global.java.lang.ClassLoader _this,
Assembly assembly )
static

Definition at line 45 of file AssemblyClassLoader.cs.

46 {
47#if FIRST_PASS
48 throw new NotImplementedException();
49#else
51#endif
52 }
void SetWrapperForClassLoader(java.lang.ClassLoader javaClassLoader, RuntimeClassLoader wrapper)

◆ toString()

static string IKVM.Java.Externs.ikvm.runtime.AssemblyClassLoader.toString ( global.java.lang.ClassLoader _this)
static

Definition at line 249 of file AssemblyClassLoader.cs.

250 {
251#if FIRST_PASS
252 throw new NotImplementedException();
253#else
254 return ((RuntimeAssemblyClassLoader)JVM.Context.ClassLoaderFactory.GetClassLoaderWrapper(_this)).MainAssembly.FullName;
255#endif
256 }

The documentation for this class was generated from the following file: