Add checking for 'ENUM$VALUES' in EnumHelper. Eclipse uses it's own internal compiler which does not follow the java standard of making the values field names $VALUES and private. Instead its public and ENUM$VALUES. Closes #502

This commit is contained in:
LexManos 2013-04-04 16:04:04 -07:00
parent b3a814785c
commit 488322baa2

View file

@ -218,22 +218,23 @@ public class EnumHelper
for (Field field : fields)
{
if (field.getName().equals("$VALUES"))
String name = field.getName();
if (name.equals("$VALUES") || name.equals("ENUM$VALUES")) //Added 'ENUM$VALUES' because Eclipse's internal compiler doesn't follow standards
{
valuesField = field;
break;
}
}
int flags = (FMLForgePlugin.RUNTIME_DEOBF ? Modifier.PUBLIC : Modifier.PRIVATE) | Modifier.STATIC | Modifier.FINAL | 0x1000 /*SYNTHETIC*/;
if (valuesField == null)
{
int flags = (FMLForgePlugin.RUNTIME_DEOBF ? Modifier.PUBLIC : Modifier.PRIVATE) | Modifier.STATIC | Modifier.FINAL | 0x1000 /*SYNTHETIC*/;
String valueType = String.format("[L%s;", enumType.getName().replace('.', '/'));
for (Field field : fields)
{
if ((field.getModifiers() & flags) == flags &&
field.getType().getName().replace('.', '/').equals(valueType)) //Apparently some JVMs return .'s and some don't..
field.getType().getName().replace('.', '/').equals(valueType)) //Apparently some JVMs return .'s and some don't..
{
valuesField = field;
break;
@ -245,10 +246,12 @@ public class EnumHelper
{
FMLLog.severe("Could not find $VALUES field for enum: %s", enumType.getName());
FMLLog.severe("Runtime Deobf: %s", FMLForgePlugin.RUNTIME_DEOBF);
FMLLog.severe("Flags: %s", String.format("%16s", Integer.toBinaryString(flags)).replace(' ', '0'));
FMLLog.severe("Fields:");
for (Field field : fields)
{
FMLLog.severe(" %s: %s", field.getName(), field.getType().getName());
String mods = String.format("%16s", Integer.toBinaryString(field.getModifiers())).replace(' ', '0');
FMLLog.severe(" %s %s: %s", mods, field.getName(), field.getType().getName());
}
return null;
}