Skip to content

Commit

Permalink
Merge branch 'hotfix-0.3.2' into master-0.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
jamierocks committed May 26, 2020
2 parents dc6ba55 + 2a097c7 commit 9a7b020
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import java.util.List;
import java.util.function.BiFunction;
import java.util.jar.Attributes;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ subprojects {

group = 'org.cadixdev'
archivesBaseName = project.name.toLowerCase()
version = '0.3.1'
version = '0.3.2'

repositories {
mavenCentral()
Expand Down
9 changes: 9 additions & 0 deletions changelogs/0.3.2.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 9a7b020

Please sign in to comment.