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

Manages instances of RuntimeManagedJavaType. More...

Public Member Functions

 RuntimeManagedJavaTypeFactory (RuntimeContext context)
 Initializes a new instance.
 
RuntimeJavaType GetJavaTypeFromManagedType (Type type)
 Gets the RuntimeJavaType associated with the specified managed type, or creates one on demand.
 
RuntimeJavaType GetBaseJavaType (Type type)
 Gets the RuntimeJavaType associated with the base type of the specified type.
 

Detailed Description

Manages instances of RuntimeManagedJavaType.

Definition at line 41 of file RuntimeManagedJavaTypeFactory.cs.

Constructor & Destructor Documentation

◆ RuntimeManagedJavaTypeFactory()

IKVM.Runtime.RuntimeManagedJavaTypeFactory.RuntimeManagedJavaTypeFactory ( RuntimeContext context)

Initializes a new instance.

Parameters
context
Exceptions
ArgumentNullException

Definition at line 52 of file RuntimeManagedJavaTypeFactory.cs.

53 {
54 this.context = context ?? throw new ArgumentNullException(nameof(context));
55 }

Member Function Documentation

◆ GetBaseJavaType()

RuntimeJavaType IKVM.Runtime.RuntimeManagedJavaTypeFactory.GetBaseJavaType ( Type type)

Gets the RuntimeJavaType associated with the base type of the specified type.

Parameters
type
Returns

Definition at line 72 of file RuntimeManagedJavaTypeFactory.cs.

73 {
74 // interfaces have no base type
75 if (type.IsInterface)
76 return null;
77
78 // remapped types extend their alter ego (e.g. cli.System.Object must appear to be derived from java.lang.Object)
79 if (context.ClassLoaderFactory.IsRemappedType(type))
80 {
81 // except when they're sealed.
82 if (type.IsSealed)
83 return context.JavaBase.TypeOfJavaLangObject;
84
85 return context.ClassLoaderFactory.GetJavaTypeFromType(type);
86 }
87
88 // if base type is remapped, return java type of remapped base type
89 if (context.ClassLoaderFactory.IsRemappedType(type.BaseType))
90 return GetJavaTypeFromManagedType(type.BaseType);
91
92 // return java type of base type
93 return context.ClassLoaderFactory.GetJavaTypeFromType(type.BaseType);
94 }
CoreClasses JavaBase
Gets the CoreClasses associated with this instance of the runtime.
RuntimeClassLoaderFactory ClassLoaderFactory
Gets the RuntimeClassLoaderFactory associated with this instance of the runtime.
RuntimeJavaType GetJavaTypeFromManagedType(Type type)
Gets the RuntimeJavaType associated with the specified managed type, or creates one on demand.

◆ GetJavaTypeFromManagedType()

RuntimeJavaType IKVM.Runtime.RuntimeManagedJavaTypeFactory.GetJavaTypeFromManagedType ( Type type)

Gets the RuntimeJavaType associated with the specified managed type, or creates one on demand.

Parameters
type
Returns

Definition at line 62 of file RuntimeManagedJavaTypeFactory.cs.

63 {
64 return cache.GetValue(type, _ => context.AssemblyClassLoaderFactory.FromAssembly(_.Assembly).GetJavaTypeFromAssemblyType(_));
65 }
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.

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