diff --git a/bombe-asm/src/main/java/org/cadixdev/bombe/asm/jar/JarEntryRemappingTransformer.java b/bombe-asm/src/main/java/org/cadixdev/bombe/asm/jar/JarEntryRemappingTransformer.java index fef70dc..2cbd9bc 100644 --- a/bombe-asm/src/main/java/org/cadixdev/bombe/asm/jar/JarEntryRemappingTransformer.java +++ b/bombe-asm/src/main/java/org/cadixdev/bombe/asm/jar/JarEntryRemappingTransformer.java @@ -43,6 +43,7 @@ import java.util.List; import java.util.function.BiFunction; +import java.util.jar.Attributes; import java.util.stream.Collectors; /** @@ -84,14 +85,17 @@ public JarClassEntry transform(final JarClassEntry entry) { @Override public JarManifestEntry transform(final JarManifestEntry entry) { - // Remap the Main-Class attribute - final String mainClassObf = entry.getManifest().getMainAttributes().getValue("Main-Class") - .replace('.', '/'); - final String mainClassDeobf = this.remapper.map(mainClassObf) - .replace('/', '.'); + // Remap the Main-Class attribute, if present + if (entry.getManifest().getMainAttributes().containsKey(new Attributes.Name("Main-Class"))) { + final String mainClassObf = entry.getManifest().getMainAttributes().getValue("Main-Class") + .replace('.', '/'); + final String mainClassDeobf = this.remapper.map(mainClassObf) + .replace('/', '.'); + + // Since Manifest is mutable, we need'nt create a new entry \o/ + entry.getManifest().getMainAttributes().putValue("Main-Class", mainClassDeobf); + } - // Since Manifest is mutable, we need'nt create a new entry \o/ - entry.getManifest().getMainAttributes().putValue("Main-Class", mainClassDeobf); return entry; } diff --git a/bombe-asm/src/test/java/org/cadixdev/bombe/asm/test/JarEntryRemappingTransformerTests.java b/bombe-asm/src/test/java/org/cadixdev/bombe/asm/test/JarEntryRemappingTransformerTests.java index d64105b..65bd26d 100644 --- a/bombe-asm/src/test/java/org/cadixdev/bombe/asm/test/JarEntryRemappingTransformerTests.java +++ b/bombe-asm/src/test/java/org/cadixdev/bombe/asm/test/JarEntryRemappingTransformerTests.java @@ -83,7 +83,7 @@ public void remapsClasses() { } @Test - public void remapsMainClass() throws IOException { + public void remapsMainClass() { final Manifest obfManifest = new Manifest(); { obfManifest.getMainAttributes().putValue("Manifest-Version", "1.0"); @@ -95,6 +95,16 @@ public void remapsMainClass() throws IOException { assertEquals("pkg.Demo", deobfManifest.getMainAttributes().getValue("Main-Class")); } + @Test + public void remapsSimpleManifest() { + final Manifest obfManifest = new Manifest(); + { + obfManifest.getMainAttributes().putValue("Manifest-Version", "1.0"); + } + + TRANSFORMER.transform(new JarManifestEntry(0, obfManifest)); + } + @Test public void remapsConfig() { final ServiceProviderConfiguration obfConfig = new ServiceProviderConfiguration( diff --git a/build.gradle b/build.gradle index 6db20c2..805956c 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ subprojects { group = 'org.cadixdev' archivesBaseName = project.name.toLowerCase() - version = '0.3.1' + version = '0.3.2' repositories { mavenCentral() diff --git a/changelogs/0.3.2.md b/changelogs/0.3.2.md new file mode 100644 index 0000000..cbc1695 --- /dev/null +++ b/changelogs/0.3.2.md @@ -0,0 +1,9 @@ +Bombe 0.3.2 +=========== + +Bombe 0.3.2 resolves a critical bug with `JarEntryRemappingTransformer` where it +would crash given a manifest with no `Main-Class`. + +As Bombe 0.3.x is still in use by the latest version of Lorenz and Atlas, and +used in software running today - this is why a further release to 0.3 is being +made.