fix: JarPatchBundle loading non-class files to class loader

This commit is contained in:
oSumAtrIX 2022-05-27 14:26:06 +02:00
parent e8a131fb08
commit 849616dc2b
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
2 changed files with 18 additions and 5 deletions

View file

@ -1,5 +1,6 @@
name: Release name: Release
on: on:
workflow_dispatch:
push: push:
branches: branches:
- main - main

View file

@ -10,9 +10,21 @@ import java.util.jar.JarFile
* @param patchBundlePath The path to the patch bundle. * @param patchBundlePath The path to the patch bundle.
*/ */
class JarPatchBundle(patchBundlePath: String) : PatchBundle(patchBundlePath) { class JarPatchBundle(patchBundlePath: String) : PatchBundle(patchBundlePath) {
fun loadPatches() = loadPatches(URLClassLoader(arrayOf(this.toURI().toURL()), null), StringIterator( fun loadPatches() = loadPatches(
JarFile(this).entries().iterator() URLClassLoader(
) { arrayOf(this.toURI().toURL()),
it.realName.replace('/', '.').replace(".class", "") Thread.currentThread().contextClassLoader // TODO: find out why this is required
}) ),
StringIterator(
JarFile(this)
.entries()
.toList() // TODO: find a cleaner solution than that to filter non class files
.filter {
it.name.endsWith(".class") && !it.name.contains("$")
}
.iterator()
) {
it.realName.replace('/', '.').replace(".class", "")
}
)
} }