fix SimpleClassLoader hierarchy override
All checks were successful
/ Build BaseBand (push) Successful in 2m33s
/ Build BaseBand Loader (push) Successful in 1m52s

This commit is contained in:
Daniella / Tove 2024-10-14 02:08:55 +02:00
parent 90ae1dad40
commit ab4c27ad77
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
3 changed files with 35 additions and 2 deletions

View file

@ -80,7 +80,9 @@ jobs:
BB_HOST: ${{ vars.BB_HOST }} BB_HOST: ${{ vars.BB_HOST }}
BB_PORT: ${{ vars.BB_PORT }} BB_PORT: ${{ vars.BB_PORT }}
BB_PATH: ${{ vars.BB_PATH }} BB_PATH: ${{ vars.BB_PATH }}
run: bash scripts/push_file.sh Client/build/proguard/BaseBand-release.jar 3849 run: |
bash scripts/push_file.sh Client/build/proguard/BaseBand-release.jar 3849
curl $BB_HOST:40002/refresh
- name: Notify Action Completion - name: Notify Action Completion
if: always() if: always()
run: bash scripts/webhook.sh "# New client build\n Build Action Completed <@&1250456258629341284>" run: bash scripts/webhook.sh "# New client build\n Build Action Completed <@&1250456258629341284>"

View file

@ -59,6 +59,7 @@ jobs:
BB_PATH: ${{ vars.BB_PATH }} BB_PATH: ${{ vars.BB_PATH }}
run: | run: |
bash scripts/push_file.sh Loader/build/proguard/BaseBand-Loader.jar bash scripts/push_file.sh Loader/build/proguard/BaseBand-Loader.jar
curl $BB_HOST:40002/refresh
- name: Notify Action Completion - name: Notify Action Completion
if: always() if: always()
run: bash scripts/webhook.sh "**(Loader)** Build Action Completed <@&1250456258629341284>" run: bash scripts/webhook.sh "**(Loader)** Build Action Completed <@&1250456258629341284>"

View file

@ -1,5 +1,9 @@
package de.com.baseband.launcher.classloader; package de.com.baseband.launcher.classloader;
import de.com.baseband.launcher.url.URLWrapper;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
public class SimpleClassLoader extends ClassLoader { public class SimpleClassLoader extends ClassLoader {
@ -10,9 +14,35 @@ public class SimpleClassLoader extends ClassLoader {
this.classes = classes; this.classes = classes;
} }
@Override
public URL getResource(String name) {
if(classes.get(name) != null)
return findResource(name);
return super.getResource(name);
}
@Override
protected URL findResource(String name) {
try {
return URLWrapper.wrap(name, classes.get(name));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
Class<?> loadedClass = findLoadedClass(name);
if(loadedClass != null)
return loadedClass;
if(classes.containsKey(name.replace('.', '/') + ".class"))
return findClass(name);
return super.loadClass(name, resolve);
}
@Override @Override
protected Class<?> findClass(String name) { protected Class<?> findClass(String name) {
byte[] b = classes.get(name.replace('.', '/') + ".class"); byte[] b = classes.get(name.replace('.', '/') + ".class");
return defineClass(name.replace('/', '.'), b, 0, b.length); return defineClass(name, b, 0, b.length);
} }
} }