mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +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));
|
insnList.add(new LdcInsnNode(value));
|
||||||
return insnList;
|
return insnList;
|
||||||
}
|
}
|
||||||
|
if (Enum.class.isInstance(value))
|
||||||
|
return NodeUtils.makeValueEnumGetter((Enum)value);
|
||||||
for (Map.Entry<Class<?>, Serializer<?>> serializerEntry : serializers.entrySet()) {
|
for (Map.Entry<Class<?>, Serializer<?>> serializerEntry : serializers.entrySet()) {
|
||||||
if (serializerEntry.getKey().isInstance(value)) {
|
if (serializerEntry.getKey().isInstance(value)) {
|
||||||
return ((Serializer) serializerEntry.getValue()).serialize(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));
|
ret.add(new LdcInsnNode(value));
|
||||||
return ret;
|
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 org.objectweb.asm.tree.FieldNode;
|
||||||
import pro.gravit.launcher.Launcher;
|
import pro.gravit.launcher.Launcher;
|
||||||
import pro.gravit.launcher.LauncherConfig;
|
import pro.gravit.launcher.LauncherConfig;
|
||||||
import pro.gravit.launcher.LauncherConfig.LauncherEnvironment;
|
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.asm.ClassMetadataReader;
|
import pro.gravit.launchserver.asm.ClassMetadataReader;
|
||||||
import pro.gravit.launchserver.asm.InjectClassAcceptor;
|
import pro.gravit.launchserver.asm.InjectClassAcceptor;
|
||||||
|
|
Loading…
Reference in a new issue