-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor
-
None
-
Affects Version/s: None
-
This server is running CraftBukkit version dev-Spigot-491f367-a0d2d6a (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
-
Yes
enum-compatibility-mode is set to true.
Error: "Duplicate method name" when trying to load generic classes that override an abstract base class or interface.
Example: Method signature:
public class EnumArgument<T extends @NonNull Enum<T>> extends CommandArgument<@NonNull T>:
@Override
public T parseValue(CommandInput input, CommandContextView context, ArgumentsReader argsReader) throws ArgumentParseException
overrides based class version of abstract base class: public abstract class CommandArgument<T>:
public abstract T parseValue(CommandInput input, CommandContextView context, ArgumentsReader argsReader) throws ArgumentParseException;
Error:
java.lang.ClassFormatError: Duplicate method name "parseValue" with signature "(Lcom.nisovin.shopkeepers.commands.lib.CommandInput;Lcom.nisovin.shopkeepers.commands.lib.context.CommandContextView;Lcom.nisovin.shopkeepers.commands.lib.argument.ArgumentsReader;)Ljava.lang.Object;" in class file com/nisovin/shopkeepers/commands/lib/arguments/EnumArgument
at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[?:?]
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027) ~[?:?]
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:206) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:593) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:117) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) ~[?:?]
at java.base/java.lang.Class.forName0(Native Method) ~[?:?]
at java.base/java.lang.Class.forName(Class.java:421) ~[?:?]
at java.base/java.lang.Class.forName(Class.java:412) ~[?:?]
at com.nisovin.shopkeepers.util.java.ClassUtils.loadAllClassesFromJar(ClassUtils.java:152) ~[?:?]
at com.nisovin.shopkeepers.SKShopkeepersPlugin.loadAllPluginClasses(SKShopkeepersPlugin.java:180) ~[?:?]
at com.nisovin.shopkeepers.SKShopkeepersPlugin.onLoad(SKShopkeepersPlugin.java:238) ~[?:?]
at org.bukkit.craftbukkit.v1_21_R1.CraftServer.loadPlugins(CraftServer.java:469) ~[spigot-1.21-R0.1-SNAPSHOT.jar:dev-Spigot-491f367-a0d2d6a]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:236) ~[spigot-1.21-R0.1-SNAPSHOT.jar:dev-Spigot-491f367-a0d2d6a]
at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1017) ~[spigot-1.21-R0.1-SNAPSHOT.jar:dev-Spigot-491f367-a0d2d6a]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[spigot-1.21-R0.1-SNAPSHOT.jar:dev-Spigot-491f367-a0d2d6a]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
With enum compatibility disabled, I get this error instead:
[12:21:23] [Server thread/ERROR]: Could not load 'plugins\Shopkeepers-2.22.2-SNAPSHOT.jar'
org.bukkit.plugin.InvalidPluginException: Exception initializing main class `com.nisovin.shopkeepers.SKShopkeepersPlugin'
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:96) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:145) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:406) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:313) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:122) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_21_R1.CraftServer.loadPlugins(CraftServer.java:464) ~[spigot-1.21-R0.1-SNAPSHOT.jar:dev-Spigot-491f367-a0d2d6a]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:236) ~[spigot-1.21-R0.1-SNAPSHOT.jar:dev-Spigot-491f367-a0d2d6a]
at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1017) ~[spigot-1.21-R0.1-SNAPSHOT.jar:dev-Spigot-491f367-a0d2d6a]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[spigot-1.21-R0.1-SNAPSHOT.jar:dev-Spigot-491f367-a0d2d6a]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74) ~[?:?]
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:88) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
... 9 more
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/nisovin/shopkeepers/shopobjects/living/types/ZombieVillagerShop.cycleProfession(Z)V @8: invokestatic
Reason:
Type 'org/bukkit/entity/Villager$Profession' (current frame, stack[2]) is not assignable to 'java/lang/Enum'
Current Frame:
bci: @8
flags: { }
locals: { 'com/nisovin/shopkeepers/shopobjects/living/types/ZombieVillagerShop', integer }
stack: { 'com/nisovin/shopkeepers/shopobjects/living/types/ZombieVillagerShop', 'java/lang/Class', 'org/bukkit/entity/Villager$Profession', integer }
Bytecode:
0000000: 2a12 092a b600 981b b800 9ec0 0009 b600
0000010: a0b1
at com.nisovin.shopkeepers.shopobjects.living.SKLivingShopObjectTypes.createLivingShopObjectType(SKLivingShopObjectTypes.java:410) ~[?:?]
at com.nisovin.shopkeepers.shopobjects.living.SKLivingShopObjectTypes.createShopObjectTypes(SKLivingShopObjectTypes.java:255) ~[?:?]
at com.nisovin.shopkeepers.shopobjects.living.SKLivingShopObjectTypes.<init>(SKLivingShopObjectTypes.java:246) ~[?:?]
at com.nisovin.shopkeepers.shopobjects.living.LivingShops.<init>(LivingShops.java:76) ~[?:?]
at com.nisovin.shopkeepers.SKShopkeepersPlugin.<init>(SKShopkeepersPlugin.java:156) ~[?:?]
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[?:?]
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[?:?]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:88) ~[spigot-api-1.21-R0.1-SNAPSHOT.jar:?]
... 9 more
The involved code (ZombieVillagerShop.cylceProfession) makes a call to this static helper:
EnumUtils.cycleEnumConstant(Profession.class, this.getProfession(), backwards)
with signature:
public static <T extends @NonNull Enum<T>> @NonNull T cycleEnumConstant(Class<? extends @NonNull T> enumClass, @NonNull T current, boolean backwards)
—
Also, related to these enum changes: Would it be possible to automatically enable the enum-compatibility mode if any plugins are detected that require it, i.e. to keep existing plugins working without manual intervention by server admins, similar to the material legacy handling?