From 4d80f041ebac352b1860b4270028fd771fa06121 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Sat, 18 Jun 2016 15:30:39 +0100 Subject: [PATCH] Potential fix for #21 --- build.gradle | 2 +- .../mapping/model/InnerClassMapping.java | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 41d28ba..5bdefa5 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ defaultTasks 'clean', 'licenseFormat', 'build' // Project information allprojects { group = 'blue.lapis.nocturne' - version = '1.0.3-SNAPSHOT' + version = '1.0.3' sourceCompatibility = '1.8' targetCompatibility = '1.8' diff --git a/src/main/java/blue/lapis/nocturne/mapping/model/InnerClassMapping.java b/src/main/java/blue/lapis/nocturne/mapping/model/InnerClassMapping.java index f6f5b15..1decc54 100644 --- a/src/main/java/blue/lapis/nocturne/mapping/model/InnerClassMapping.java +++ b/src/main/java/blue/lapis/nocturne/mapping/model/InnerClassMapping.java @@ -29,9 +29,12 @@ import blue.lapis.nocturne.Main; import blue.lapis.nocturne.gui.scene.text.SelectableMember; +import blue.lapis.nocturne.jar.model.JarClassEntry; import blue.lapis.nocturne.mapping.MappingContext; import blue.lapis.nocturne.util.MemberType; +import java.util.Optional; + /** * Represents a {@link Mapping} for an inner class, i.e. a class parented by * another class. @@ -70,7 +73,7 @@ public ClassMapping getParent() { @Override public String getFullObfuscatedName() { return (parent instanceof InnerClassMapping - ? ((InnerClassMapping) parent).getFullObfuscatedName() + ? parent.getFullObfuscatedName() : parent.getObfuscatedName()) + INNER_CLASS_SEPARATOR_CHAR + getObfuscatedName(); } @@ -83,7 +86,7 @@ public String getFullObfuscatedName() { @Override public String getFullDeobfuscatedName() { return (parent instanceof InnerClassMapping - ? ((InnerClassMapping) parent).getFullDeobfuscatedName() + ? parent.getFullDeobfuscatedName() : parent.getDeobfuscatedName()) + INNER_CLASS_SEPARATOR_CHAR + getDeobfuscatedName(); } @@ -95,10 +98,16 @@ public MappingContext getContext() { @Override public void setDeobfuscatedName(String deobf) { - super.setDeobfuscatedName(deobf); + Optional jarClassEntry = Main.getLoadedJar().getClass(getParent().getFullObfuscatedName()); + if (jarClassEntry.isPresent()) { + jarClassEntry.get().getCurrentInnerClassNames().put(getObfuscatedName(), deobf); + } else { + // log and skip + Main.getLogger().severe("Invalid obfuscated name: " + getParent().getFullObfuscatedName()); + return; + } - Main.getLoadedJar().getClass(getParent().getFullObfuscatedName()).get() - .getCurrentInnerClassNames().put(getObfuscatedName(), deobf); + super.setDeobfuscatedName(deobf); } @Override