mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] Поддержка сериализации с аннотацией LauncherInject Map<String, String>
This commit is contained in:
parent
ef6616dfda
commit
b4a75b9076
1 changed files with 15 additions and 1 deletions
|
@ -139,12 +139,26 @@ else if (c == String.class)
|
||||||
else
|
else
|
||||||
throw new UnsupportedOperationException("Unsupported class" + c.getName());
|
throw new UnsupportedOperationException("Unsupported class" + c.getName());
|
||||||
}
|
}
|
||||||
|
} else if (e.desc.equals("Ljava/util/Map;")) {
|
||||||
|
serializeMap(injector, (Map<String, String>) val);
|
||||||
} else {
|
} else {
|
||||||
if (!cPrimitivesList.contains(e.desc) || !zPrimitivesList.contains(val.getClass()))
|
if (!cPrimitivesList.contains(e.desc) || !zPrimitivesList.contains(val.getClass()))
|
||||||
throw new UnsupportedOperationException("Unsupported class");
|
throw new UnsupportedOperationException("Unsupported class");
|
||||||
injector.add(new LdcInsnNode(val));
|
injector.add(new LdcInsnNode(val));
|
||||||
}
|
}
|
||||||
// TODO Map<String,String>
|
}
|
||||||
|
|
||||||
|
private static void serializeMap(InsnList inj, Map<String, String> map) {
|
||||||
|
inj.add(new TypeInsnNode(Opcodes.NEW, "java/util/HashMap"));
|
||||||
|
inj.add(new InsnNode(Opcodes.DUP)); // +1
|
||||||
|
inj.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "java/util/HashMap", "<init>", "()V"));
|
||||||
|
map.forEach((k, v) -> {
|
||||||
|
inj.add(new InsnNode(Opcodes.DUP)); // +1-1
|
||||||
|
inj.add(NodeUtils.getSafeStringInsnList(k));
|
||||||
|
inj.add(NodeUtils.getSafeStringInsnList(v));
|
||||||
|
inj.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/Map", "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", true));
|
||||||
|
inj.add(new InsnNode(Opcodes.POP));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void serializebArr(InsnList injector, byte[] val) {
|
private static void serializebArr(InsnList injector, byte[] val) {
|
||||||
|
|
Loading…
Reference in a new issue