diff options
| author | 2018-06-24 19:12:24 +0200 | |
|---|---|---|
| committer | 2018-06-24 19:12:24 +0200 | |
| commit | 81adac1706ee5f96c97cc26874ebb0d6cbb56c7f (patch) | |
| tree | 3e9d8047df428354d0fe8dc3e71f14fa34fa01b9 /src/main/java/cuchaz/enigma/mapping/entry | |
| parent | Fix method reference and bridge detection (diff) | |
| download | enigma-fork-81adac1706ee5f96c97cc26874ebb0d6cbb56c7f.tar.gz enigma-fork-81adac1706ee5f96c97cc26874ebb0d6cbb56c7f.tar.xz enigma-fork-81adac1706ee5f96c97cc26874ebb0d6cbb56c7f.zip | |
Fix handling of null deobf mappings
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/entry')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/entry/ProcyonEntryFactory.java | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/entry/ProcyonEntryFactory.java b/src/main/java/cuchaz/enigma/mapping/entry/ProcyonEntryFactory.java index 5892a03..73770c5 100644 --- a/src/main/java/cuchaz/enigma/mapping/entry/ProcyonEntryFactory.java +++ b/src/main/java/cuchaz/enigma/mapping/entry/ProcyonEntryFactory.java | |||
| @@ -11,14 +11,14 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.mapping.entry; | 12 | package cuchaz.enigma.mapping.entry; |
| 13 | 13 | ||
| 14 | import com.strobel.assembler.metadata.*; | 14 | import com.strobel.assembler.metadata.FieldDefinition; |
| 15 | import com.strobel.assembler.metadata.MemberReference; | ||
| 16 | import com.strobel.assembler.metadata.MethodDefinition; | ||
| 15 | import cuchaz.enigma.bytecode.AccessFlags; | 17 | import cuchaz.enigma.bytecode.AccessFlags; |
| 16 | import cuchaz.enigma.mapping.MethodDescriptor; | 18 | import cuchaz.enigma.mapping.MethodDescriptor; |
| 17 | import cuchaz.enigma.mapping.Signature; | 19 | import cuchaz.enigma.mapping.Signature; |
| 18 | import cuchaz.enigma.mapping.TypeDescriptor; | 20 | import cuchaz.enigma.mapping.TypeDescriptor; |
| 19 | 21 | ||
| 20 | import java.util.List; | ||
| 21 | |||
| 22 | public class ProcyonEntryFactory { | 22 | public class ProcyonEntryFactory { |
| 23 | private final ReferencedEntryPool entryPool; | 23 | private final ReferencedEntryPool entryPool; |
| 24 | 24 | ||
| @@ -26,30 +26,6 @@ public class ProcyonEntryFactory { | |||
| 26 | this.entryPool = entryPool; | 26 | this.entryPool = entryPool; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | private String getErasedSignature(MemberReference def) { | ||
| 30 | if (!(def instanceof MethodReference)) | ||
| 31 | return def.getErasedSignature(); | ||
| 32 | MethodReference methodReference = (MethodReference) def; | ||
| 33 | StringBuilder builder = new StringBuilder("("); | ||
| 34 | for (ParameterDefinition param : methodReference.getParameters()) { | ||
| 35 | TypeReference paramType = param.getParameterType(); | ||
| 36 | if (paramType.getErasedSignature().equals("Ljava/lang/Object;") && paramType.hasExtendsBound() && paramType.getExtendsBound() instanceof CompoundTypeReference) { | ||
| 37 | List<TypeReference> interfaces = ((CompoundTypeReference) paramType.getExtendsBound()).getInterfaces(); | ||
| 38 | interfaces.forEach((inter) -> builder.append(inter.getErasedSignature())); | ||
| 39 | } else | ||
| 40 | builder.append(paramType.getErasedSignature()); | ||
| 41 | } | ||
| 42 | builder.append(")"); | ||
| 43 | |||
| 44 | TypeReference returnType = methodReference.getReturnType(); | ||
| 45 | if (returnType.getErasedSignature().equals("Ljava/lang/Object;") && returnType.hasExtendsBound() && returnType.getExtendsBound() instanceof CompoundTypeReference) { | ||
| 46 | List<TypeReference> interfaces = ((CompoundTypeReference) returnType.getExtendsBound()).getInterfaces(); | ||
| 47 | interfaces.forEach((inter) -> builder.append(inter.getErasedSignature())); | ||
| 48 | } else | ||
| 49 | builder.append(returnType.getErasedSignature()); | ||
| 50 | return builder.toString(); | ||
| 51 | } | ||
| 52 | |||
| 53 | public FieldEntry getFieldEntry(MemberReference def) { | 29 | public FieldEntry getFieldEntry(MemberReference def) { |
| 54 | ClassEntry classEntry = entryPool.getClass(def.getDeclaringType().getInternalName()); | 30 | ClassEntry classEntry = entryPool.getClass(def.getDeclaringType().getInternalName()); |
| 55 | return entryPool.getField(classEntry, def.getName(), def.getErasedSignature()); | 31 | return entryPool.getField(classEntry, def.getName(), def.getErasedSignature()); |
| @@ -62,7 +38,7 @@ public class ProcyonEntryFactory { | |||
| 62 | 38 | ||
| 63 | public MethodEntry getMethodEntry(MemberReference def) { | 39 | public MethodEntry getMethodEntry(MemberReference def) { |
| 64 | ClassEntry classEntry = entryPool.getClass(def.getDeclaringType().getInternalName()); | 40 | ClassEntry classEntry = entryPool.getClass(def.getDeclaringType().getInternalName()); |
| 65 | return entryPool.getMethod(classEntry, def.getName(), getErasedSignature(def)); | 41 | return entryPool.getMethod(classEntry, def.getName(), def.getErasedSignature()); |
| 66 | } | 42 | } |
| 67 | 43 | ||
| 68 | public MethodDefEntry getMethodDefEntry(MethodDefinition def) { | 44 | public MethodDefEntry getMethodDefEntry(MethodDefinition def) { |