IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.Runtime.RuntimeClassLoader Class Reference

Runtime support for a class loader. More...

Inheritance diagram for IKVM.Runtime.RuntimeClassLoader:
IKVM.Runtime.RuntimeGenericClassLoader IKVM.Tools.Exporter.RuntimeBootstrapClassLoader IKVM.Tools.Importer.ImportClassLoader

Public Member Functions

override string ToString ()
 

Protected Member Functions

virtual RuntimeJavaType FindLoadedClassLazy (string name)
 
virtual void CheckProhibitedPackage (string className)
 
virtual RuntimeJavaType LoadClassImpl (string name, LoadMode mode)
 

Protected Attributes

java.lang.ClassLoader javaClassLoader
 

Properties

virtual IDiagnosticHandler Diagnostics [get]
 Gets the IDiagnosticHandler events originated by this class loader should be sent to.
 
RuntimeContext Context [get]
 Gets a reference to the RuntimeContext that this RuntimeClassLoader is hosted within.
 

Detailed Description

Runtime support for a class loader.

Definition at line 60 of file RuntimeClassLoader.cs.

Member Function Documentation

◆ CheckProhibitedPackage()

virtual void IKVM.Runtime.RuntimeClassLoader.CheckProhibitedPackage ( string className)
protectedvirtual

Reimplemented in IKVM.Runtime.BootstrapClassLoader, and IKVM.Tools.Importer.ImportClassLoader.

Definition at line 244 of file RuntimeClassLoader.cs.

245 {
246 if (className.StartsWith("java.", StringComparison.Ordinal))
247 throw new JavaSecurityException("Prohibited package name: " + className.Substring(0, className.LastIndexOf('.')));
248 }

◆ FindLoadedClassLazy()

virtual RuntimeJavaType IKVM.Runtime.RuntimeClassLoader.FindLoadedClassLazy ( string name)
protectedvirtual

Reimplemented in IKVM.Runtime.RuntimeGenericClassLoader.

Definition at line 136 of file RuntimeClassLoader.cs.

137 {
138 return null;
139 }

◆ LoadClassImpl()

virtual RuntimeJavaType IKVM.Runtime.RuntimeClassLoader.LoadClassImpl ( string name,
LoadMode mode )
protectedvirtual

Reimplemented in IKVM.Tools.Importer.ImportClassLoader.

Definition at line 630 of file RuntimeClassLoader.cs.

631 {
632 var javaType = FindOrLoadGenericClass(name, mode);
633 if (javaType != null)
634 return javaType;
635
636#if !FIRST_PASS && !IMPORTER && !EXPORTER
637
638 if ((mode & LoadMode.Load) == 0)
639 return null;
640
641 Profiler.Enter("ClassLoader.loadClass");
642
643 try
644 {
645 // invoke 'loadClass' on the associated Java class loader instance
646 // this can cause a call to defineClass
647 var c = (java.lang.Class)ClassLoaderAccessor.InvokeLoadClassInternal(GetJavaClassLoader(), name);
648 if (c == null)
649 return null;
650
651 // map resulting reflective instance back into Java type
652 var type = RuntimeJavaType.FromClass(c);
653 if (type.Name != name)
654 return null;
655
656 return type;
657 }
658 catch (java.lang.ClassNotFoundException x)
659 {
660 if ((mode & LoadMode.MaskReturn) == LoadMode.ThrowClassNotFound)
661 throw new ClassLoadingException(ikvm.runtime.Util.mapException(x), name);
662
663 return null;
664 }
665 catch (global::java.lang.ThreadDeath)
666 {
667 throw;
668 }
669 catch (Exception x)
670 {
671 if ((mode & LoadMode.SuppressExceptions) == 0)
672 throw new ClassLoadingException(ikvm.runtime.Util.mapException(x), name);
673
674 if (Diagnostics.IsEnabled(Diagnostic.GenericClassLoadingError))
675 {
676 var cl = GetJavaClassLoader();
677 if (cl != null)
678 {
679 var sb = new ValueStringBuilder();
680 var sep = "";
681 while (cl != null)
682 {
683 sb.Append(sep);
684 sb.Append(cl.ToString());
685 sep = " -> ";
686 cl = cl.getParent();
687 }
688
689 Diagnostics.GenericClassLoadingError($"ClassLoader chain: {sb.ToString()}");
690 }
691
692 var m = ikvm.runtime.Util.mapException(x);
693 Diagnostics.GenericClassLoadingError(m.ToString() + Environment.NewLine + m.StackTrace);
694 }
695
696 return null;
697 }
698 finally
699 {
700 Profiler.Leave("ClassLoader.loadClass");
701 }
702#else
703 return null;
704#endif
705 }
static readonly Diagnostic GenericClassLoadingError
The 'GenericClassLoadingError' diagnostic.

◆ ToString()

override string IKVM.Runtime.RuntimeClassLoader.ToString ( )

Definition at line 909 of file RuntimeClassLoader.cs.

910 {
911 var javaClassLoader = GetJavaClassLoader();
912 if (javaClassLoader == null)
913 return "null";
914 else
915 return string.Format("{0}@{1:X}", Context.ClassLoaderFactory.GetJavaTypeFromType(javaClassLoader.GetType()).Name, javaClassLoader.GetHashCode());
916 }
RuntimeContext Context
Gets a reference to the RuntimeContext that this RuntimeClassLoader is hosted within.
java.lang.ClassLoader javaClassLoader
RuntimeClassLoaderFactory ClassLoaderFactory
Gets the RuntimeClassLoaderFactory associated with this instance of the runtime.

Member Data Documentation

◆ javaClassLoader

java.lang.ClassLoader IKVM.Runtime.RuntimeClassLoader.javaClassLoader
protected

Definition at line 70 of file RuntimeClassLoader.cs.

Property Documentation

◆ Context

RuntimeContext IKVM.Runtime.RuntimeClassLoader.Context
get

Gets a reference to the RuntimeContext that this RuntimeClassLoader is hosted within.

Definition at line 120 of file RuntimeClassLoader.cs.

◆ Diagnostics

virtual IDiagnosticHandler IKVM.Runtime.RuntimeClassLoader.Diagnostics
get

Gets the IDiagnosticHandler events originated by this class loader should be sent to.

Definition at line 100 of file RuntimeClassLoader.cs.


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