Fix EnumRarity, make sure extensible enums have at least one factory candidate

This commit is contained in:
tterrag committed 2019-04-25 19:38:03 -04:00
1 parent bda3f1b7c6
commit cab1b9716c
2 files changed
+7 -5

No files matched your search

@@ -88,6 +88,10 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
.filter(m -> ((m.access & Opcodes.ACC_STATIC) != 0) && m.name.equals("create") && Type.getReturnType(m.desc).equals(classType))
.collect(Collectors.toList());
if (candidates.isEmpty()) {
throw new IllegalStateException("IExtensibleEnum has no candidate factory methods: " + classType.getClassName());
}
candidates.forEach(mtd ->
{
Type[] args = Type.getArgumentTypes(mtd.desc);