Skip to content

Commit

Permalink
Merge pull request quarkusio#43718 from dmlloyd/fix-bad-classloader
Browse files Browse the repository at this point in the history
Fix faulty class loader
  • Loading branch information
gastaldi authored Oct 5, 2024
2 parents bc37ca4 + aa6bf6c commit af53a4d
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.launcher;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
Expand All @@ -18,20 +17,14 @@ public RuntimeLaunchClassLoader(ClassLoader parent) {

@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
String resourceName = name.replace(".", "/") + ".class";
String resourceName = "META-INF/ide-deps/" + name.replace(".", "/") + ".class.ide-launcher-res";
try {
try (InputStream is = getResourceAsStream(resourceName)) {
try (InputStream is = getParent().getResourceAsStream(resourceName)) {
if (is == null) {
throw new ClassNotFoundException(name);
}
definePackage(name);
byte[] buf = new byte[1024];
int r;
ByteArrayOutputStream out = new ByteArrayOutputStream();
while ((r = is.read(buf)) > 0) {
out.write(buf, 0, r);
}
byte[] bytes = out.toByteArray();
byte[] bytes = is.readAllBytes();

return defineClass(name, bytes, 0, bytes.length);
}
Expand Down

0 comments on commit af53a4d

Please sign in to comment.