ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.17k stars 110 forks source link

Runtime Context #393

Closed wasabii closed 12 months ago

wasabii commented 1 year ago

Introduced a top-level container for all of the Runtime elements of IKVM Runtime. Everything that was a static, or cached static, becomes a Factory hanging off of this Context. The idea here is to remove statics, for potential reuse of the Runtime logic outside of IKVM.Runtime.

RuntimeContext gains a IManagedTypeResolver interface, which abstracts out three concepts: resolving "Types", that is, .NET types, which live outside the Runtime, and may be loaded by either IKVM.Reflection, or differently by the Importer and Exporter. This externalization also removes the hard type binding between the Runtime logic and the active runtime itself. Importer and Exporter now scan references without considering the assembly relevant. Same code should thus be able to resolve types from Core, .NET5, etc and Framework, without consideration to the platform of the current runtime instance. This should get us .NET 5+ support!

Also contains ResolveBaseType, which targets resolving RuntimeJavaType instances out of IKVM.Java. For logic which needs to escape the class loader hierarchy and go directly to the bootstrap types.

ResolveRuntimeType is similar, but targets IKVM.Runtime.

Once this is accepted, we can start trying to enable .NET 5 support. And maybe cross compilation support with ikvmc.