Skip to content

Maybe a bug, or bad usage from my part: Resource loading fails for runtime loaded IKVM assemblies #711

Description

@maxpiva

When a Java JAR is compiled into a DLL and loaded at runtime (plugin scenario), any attempt to load resources via getResource() fails.

Observed behavior

If everything is compiled and loaded together, resource resolution works correctly.
In that case, it seems a Virtual File System appears to point back to the original jar.

However, when the Java-compiled DLL is loaded dynamically at runtime, resource loading breaks because the VFS tries to resolve resources from a jar file that does not exists in the ikvm\win-x64\assembly\ directory.

Root cause

The issue seems to originate in RuntimeAssemblyClassLoader, which reference a non-existent jar-backed VFS when the assembly is loaded dynamically.

Suggestion

Would it be possible for RuntimeAssemblyClassLoader to fall back to ikvmres: when VFS resolution fails?

My understanding is that ikvmres: will be able to resolve the resource? correct?

For example:

If the VFS lookup fails,

then automatically attempt to resolve the resource from the embedded DLL jar resources (ikvmres:).

Possible approaches

Add a fallback mechanism inside RuntimeAssemblyClassLoader

Or introduce an additional ClassLoader that redirects resource lookups to ikvmres:

I attempted to subclass the existing Java class loaders in ikvm.runtime, but they are final, so creating a custom loader is not straightforward.

Any suggestions how to accomplish this?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions