From 41ac91d56607a3a196d09c6969bc7ff8e53b99b1 Mon Sep 17 00:00:00 2001 From: zhibei <785740487@qq.com> Date: Thu, 23 Apr 2026 18:17:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(common-env):=20=E4=BF=AE=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E4=B8=8D=E5=90=8C=E5=8D=8F=E7=A8=8B=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=AF=BC=E8=87=B4=20NoClassDefFoundError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AetherResolver.inject() 的去重 id 仅包含依赖的 group/name, 不包含 relocate 规则信息。当多个 TabooLib 插件使用不同版本的 Kotlin Coroutines 时,先加载的插件注册了依赖 id,后加载的插件 因去重被跳过,但其模块代码已被 relocate 成引用不同版本的包名, 导致 NoClassDefFoundError。 在去重 id 中加入 relocation 规则的 hashCode,使不同 relocate 规则的同一依赖可以分别加载。 --- .../main/java/taboolib/common/env/aether/AetherResolver.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common-env/src/main/java/taboolib/common/env/aether/AetherResolver.java b/common-env/src/main/java/taboolib/common/env/aether/AetherResolver.java index b177b8abe..9f3769779 100644 --- a/common-env/src/main/java/taboolib/common/env/aether/AetherResolver.java +++ b/common-env/src/main/java/taboolib/common/env/aether/AetherResolver.java @@ -119,8 +119,11 @@ public static AetherResolver of(@NotNull String repository) { public static @Nullable ClassLoader inject(@NotNull File file, @Nullable List relocation, boolean isExternal) throws Throwable { // 文件路径: group/name/version/file // 两次获取父文件跳到 name 层, 避免重复加载同一个依赖 (的不同版本) + // 同时加入 relocation 规则的 hashCode, 使不同 relocate 规则的同一依赖可以分别加载 + // 解决多个 TabooLib 插件使用不同 Kotlin/Coroutines 版本时的 NoClassDefFoundError String id = file.getParentFile().getParentFile().getPath() - + ":" + PrimitiveSettings.IS_ISOLATED_MODE; // 区分类加载器 (隔离类加载器或插件类加载器) + + ":" + PrimitiveSettings.IS_ISOLATED_MODE // 区分类加载器 (隔离类加载器或插件类加载器) + + ":" + (relocation != null ? relocation.hashCode() : 0); // 区分不同的重定向规则 if (injectedDependencies.contains(id)) return null; else injectedDependencies.add(id); // 如果没有重定向规则,直接注入