From 44df6be0a0e0a90b268a53e0b4b5c49ef8c4db0f Mon Sep 17 00:00:00 2001 From: Runemoro Date: Mon, 18 Jun 2018 18:48:04 -0400 Subject: [PATCH] Fix inheritance map --- .../javaremapper/InheritanceMapper.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/dimdev/javaremapper/InheritanceMapper.java b/src/main/java/org/dimdev/javaremapper/InheritanceMapper.java index edc11bb..74825d7 100644 --- a/src/main/java/org/dimdev/javaremapper/InheritanceMapper.java +++ b/src/main/java/org/dimdev/javaremapper/InheritanceMapper.java @@ -21,7 +21,11 @@ public InheritanceMapper() { public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { super.visit(version, access, name, signature, superName, interfaces); - Set inheritanceSet = inheritanceMap.computeIfAbsent(name, k -> new HashSet<>()); + inheritanceMap.put(name, new HashSet<>()); + inheritableFields.put(name, new HashSet<>()); + inheritableMethods.put(name, new HashSet<>()); + + Set inheritanceSet = inheritanceMap.get(name); if (superName != null) inheritanceSet.add(superName); // java/lang/Object has a null superclass inheritanceSet.addAll(Arrays.asList(interfaces)); if ((access & Opcodes.ACC_ENUM) != 0) inheritanceSet.add("java/lang/Enum"); @@ -50,9 +54,6 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str public Set getSuperclasses(String name) { Set result = inheritanceMap.get(name); if (result == null) { - inheritanceMap.put(name, new HashSet<>()); - inheritableFields.put(name, new HashSet<>()); - inheritableMethods.put(name, new HashSet<>()); visitClasspathClass(name); result = inheritanceMap.get(name); } @@ -81,9 +82,6 @@ public Set getAllSuperclasses(String name) { public Set getInheritableFields(String name) { Set result = inheritableFields.get(name); if (result == null) { - inheritanceMap.put(name, new HashSet<>()); - inheritableFields.put(name, new HashSet<>()); - inheritableMethods.put(name, new HashSet<>()); visitClasspathClass(name); result = inheritableFields.get(name); } @@ -94,9 +92,6 @@ public Set getInheritableFields(String name) { public Set getInheritableMethods(String name) { Set result = inheritableMethods.get(name); if (result == null) { - inheritanceMap.put(name, new HashSet<>()); - inheritableFields.put(name, new HashSet<>()); - inheritableMethods.put(name, new HashSet<>()); visitClasspathClass(name); result = inheritableMethods.get(name); } @@ -104,6 +99,10 @@ public Set getInheritableMethods(String name) { } private void visitClasspathClass(String name) { + inheritanceMap.put(name, new HashSet<>()); + inheritableFields.put(name, new HashSet<>()); + inheritableMethods.put(name, new HashSet<>()); + try (InputStream inputStream = InheritanceMapper.class.getClassLoader().getResourceAsStream(name + ".class")) { if (inputStream == null) return; ClassReader reader = new ClassReader(inputStream);