mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] Нормальная сериализация Enum.
This commit is contained in:
parent
bde9fd55f9
commit
0e4502d38f
3 changed files with 9 additions and 1 deletions
|
@ -171,6 +171,8 @@ private static InsnList serializeValue(Object value) {
|
|||
insnList.add(new LdcInsnNode(value));
|
||||
return insnList;
|
||||
}
|
||||
if (Enum.class.isInstance(value))
|
||||
return NodeUtils.makeValueEnumGetter((Enum)value);
|
||||
for (Map.Entry<Class<?>, Serializer<?>> serializerEntry : serializers.entrySet()) {
|
||||
if (serializerEntry.getKey().isInstance(value)) {
|
||||
return ((Serializer) serializerEntry.getValue()).serialize(value);
|
||||
|
|
|
@ -246,4 +246,11 @@ else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE)
|
|||
ret.add(new LdcInsnNode(value));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static InsnList makeValueEnumGetter(@SuppressWarnings("rawtypes") Enum u) {
|
||||
InsnList ret = new InsnList();
|
||||
Type e = Type.getType(u.getClass());
|
||||
ret.add(new FieldInsnNode(Opcodes.GETSTATIC, e.getInternalName(), u.name(), e.getDescriptor()));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import org.objectweb.asm.tree.FieldNode;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launcher.LauncherConfig;
|
||||
import pro.gravit.launcher.LauncherConfig.LauncherEnvironment;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.asm.ClassMetadataReader;
|
||||
import pro.gravit.launchserver.asm.InjectClassAcceptor;
|
||||
|
|
Loading…
Reference in a new issue