|
55 | 55 | import java.util.jar.Attributes;
|
56 | 56 | import java.util.jar.JarFile;
|
57 | 57 | import java.util.jar.Manifest;
|
58 |
| -import java.util.stream.Collectors; |
59 | 58 | import java.util.stream.Stream;
|
60 | 59 | import java.util.zip.ZipEntry;
|
61 | 60 |
|
@@ -90,13 +89,25 @@ private static Map<String, String> getFlatMapping(String sourceNamespace) {
|
90 | 89 | }
|
91 | 90 |
|
92 | 91 | LOGGER.debug(TRANSFORM_MARKER, "Creating flat mapping for namespace {}", sourceNamespace);
|
| 92 | + // Intermediary sometimes contains duplicate names for different methods (why?). We exclude those. |
| 93 | + Set<String> excludedNames = new HashSet<>(); |
93 | 94 | Collection<String> prefixes = MAPPING_PREFIXES.get(sourceNamespace);
|
94 | 95 | MappingResolverImpl resolver = FabricLoaderImpl.INSTANCE.getMappingResolver();
|
95 |
| - Map<String, String> resolved = resolver.getCurrentMap(sourceNamespace).getClasses().stream() |
| 96 | + Map<String, String> resolved = new HashMap<>(); |
| 97 | + resolver.getCurrentMap(sourceNamespace).getClasses().stream() |
96 | 98 | .flatMap(cls -> Stream.concat(Stream.of(cls), Stream.concat(cls.getFields().stream(), cls.getMethods().stream()))
|
97 | 99 | .filter(node -> prefixes.stream().anyMatch(node.getOriginal()::startsWith))
|
98 | 100 | .map(node -> Pair.of(node.getOriginal(), node.getMapped())))
|
99 |
| - .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond, (a, b) -> a)); |
| 101 | + .forEach(pair -> { |
| 102 | + String original = pair.getFirst(); |
| 103 | + if (resolved.containsKey(original)) { |
| 104 | + excludedNames.add(original); |
| 105 | + resolved.remove(original); |
| 106 | + } |
| 107 | + if (!excludedNames.contains(original)) { |
| 108 | + resolved.put(original, pair.getSecond()); |
| 109 | + } |
| 110 | + }); |
100 | 111 | FLAT_MAPPINGS_CACHE.put(sourceNamespace, resolved);
|
101 | 112 | return resolved;
|
102 | 113 | }
|
|
0 commit comments