@Override
    protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
        // The classes under the package "unit.im.turms.server.common.infra.plugin.hidden"
        // are defined in tests to serve as if they were the classes ONLY defined in a plugin.
        // So we need to make sure the class can only be loaded from the JAR file, not the parent
        // class loader.
        if (name.startsWith("unit.im.turms.server.common.infra.plugin.hidden.")) {
            synchronized (getClassLoadingLock(name)) {
                Class<?> c = findLoadedClass(name);
                if (c == null) {
                    c = findClass(name);
                }
                if (resolve) {
                    resolveClass(c);
                }
                return c;
            }
        }
        Class<?> loadedClass = super.loadClass(name, resolve);
        if (loadedClass.getClassLoader() == this) {
            return loadedClass;
        }
        if (throwIfFoundDuplicateClass) {
            String binaryName = name.replace('.', '/')
                    .concat(".class");
            if (zipFile.getEntry(binaryName) != null) {
                throw new ConflictedClassException(
                        "The class ("
                                + name
                                + ") in the JAR file conflicts with the class defined by Turms server. "
                                + "The plugin developer needs to rename the class in the JAR file to avoid conflicts");
            }
        }
        return loadedClass;
    }
We don't use {@link java.util.jar.JarFile} as we don't want to support multi-version JARs on
purpose, which just waste unnecessary resources.
turms-server-common/src/main/java/im/turms/server/common/infra/plugin/PluginClassLoader.java