From d7422420e076c67f974758bf55994fcca0c4555c Mon Sep 17 00:00:00 2001 From: TudbuT Date: Tue, 18 Jun 2024 17:31:21 +0200 Subject: [PATCH] eliminate a possibility for the loader to lock up --- .../classloader/CustomClassLoader.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Loader/src/main/java/de/com/baseband/launcher/classloader/CustomClassLoader.java b/Loader/src/main/java/de/com/baseband/launcher/classloader/CustomClassLoader.java index 72831c9..ed3a90b 100644 --- a/Loader/src/main/java/de/com/baseband/launcher/classloader/CustomClassLoader.java +++ b/Loader/src/main/java/de/com/baseband/launcher/classloader/CustomClassLoader.java @@ -119,16 +119,18 @@ public class CustomClassLoader extends ClassLoader implements Util { } @Override - protected Class findClass(String name) throws ClassNotFoundException { - if (names.contains(name.replace('.', '/') + ".class")) { - Class clazz = loadBBClass(name); - if(clazz != null) - return clazz; - } - try { - return Launch.classLoader.findClass(name); - } catch (ClassNotFoundException e) { - return super.findClass(name); + protected synchronized Class findClass(String name) throws ClassNotFoundException { + synchronized (Launch.classLoader) { + if (names.contains(name.replace('.', '/') + ".class")) { + Class clazz = loadBBClass(name); + if (clazz != null) + return clazz; + } + try { + return Launch.classLoader.findClass(name); + } catch (ClassNotFoundException e) { + return super.findClass(name); + } } }