[FIX] Рефакторинг в пакете pro.gravit.launchserver.asm.

This commit is contained in:
Zaxar163 2020-01-18 06:25:11 +01:00
parent ea6e131b60
commit 567e2fefaf
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B

View file

@ -21,11 +21,14 @@ public class InjectClassAcceptor {
public static final List<Class<?>> zPrimitivesList = Arrays.asList(primitives);
public static final String INJ_DESC = Type.getDescriptor(LauncherInject.class);
public static void visit(ClassNode cn, Map<String, Object> object) {
public static void checkMap(Map<String,Object> object) {
if (!object.values().stream().allMatch(zPrimitivesList::contains))
throw new IllegalArgumentException("Only primitives in values...");
}
public static void visit(ClassNode cn, Map<String, Object> object) {
cn.fields.stream().filter(e -> e.invisibleAnnotations != null)
.filter(e -> e.invisibleAnnotations.stream().anyMatch(f -> f.desc.equals(INJ_DESC))).forEach(e -> {
.filter(e -> !e.invisibleAnnotations.isEmpty() && e.invisibleAnnotations.stream().anyMatch(f -> f.desc.equals(INJ_DESC))).forEach(e -> {
// Notice that fields that will be used with this algo should not have default
// value by = ...;
AnnotationNode n = e.invisibleAnnotations.stream().filter(f -> INJ_DESC.equals(f.desc)).findFirst()