asmble icon indicating copy to clipboard operation
asmble copied to clipboard

Failure to find RuntimeHelpers when Asmble is loaded by a non-system class loader

Open Hawk777 opened this issue 4 years ago • 0 comments

asmble.compile.jvm.SyntheticFuncBuilder.buildIndirectBootstrap calls ClassReader(RuntimeHelpers::class.java.name). Per the documentation:

The ClassFile structure is retrieved with the current class loader's ClassLoader.getSystemResourceAsStream(java.lang.String)

According to the documentation of that method in turn:

This method locates the resource through the system class loader (see getSystemClassLoader()).

That means that, if Asmble itself is loaded by something other than the system class loader, this call will fail. IMO it would be better to replace the ClassReader(RuntimeHelpers::class.java.name) call with something along the lines of ClassReader(RuntimeHelpers::class.java.getClassLoader().getResourceAsStream(RuntimeHelpers::class.java.name.replace('.', '/') + ".class")) (forgive me if I messed up the syntax; I don’t know Kotlin).

Hawk777 avatar May 30 '21 17:05 Hawk777