Skip to content

Commit

Permalink
fix: JarPatchBundle loading non-class files to class loader
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed May 27, 2022
1 parent 545c5c1 commit 3f0c740
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Release
on:
workflow_dispatch:
push:
branches:
- main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ import java.util.jar.JarFile
* @param patchBundlePath The path to the patch bundle.
*/
class JarPatchBundle(patchBundlePath: String) : PatchBundle(patchBundlePath) {
fun loadPatches() = loadPatches(URLClassLoader(arrayOf(this.toURI().toURL()), null), StringIterator(
JarFile(this).entries().iterator()
) {
it.realName.replace('/', '.').replace(".class", "")
})
fun loadPatches() = loadPatches(
URLClassLoader(
arrayOf(this.toURI().toURL()),
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", "")
}
)
}

0 comments on commit 3f0c740

Please sign in to comment.