From ed472540bb62d5fdd289a468dba467279d4fd960 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Fri, 20 Nov 2020 01:03:51 +0000 Subject: [PATCH 1/7] 0.5.6: Start dev cycle --- README.md | 4 ++-- build.gradle | 2 +- changelogs/0.5.6.md | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/0.5.6.md diff --git a/README.md b/README.md index 5c53ae92..404f9fd3 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Lorenz releases can be obtained through Maven Central: ### Gradle ```groovy -implementation 'org.cadixdev:lorenz:0.5.3' +implementation 'org.cadixdev:lorenz:0.5.6' ``` ### Maven @@ -40,7 +40,7 @@ implementation 'org.cadixdev:lorenz:0.5.3' org.cadixdev lorenz - 0.5.3 + 0.5.6 ``` diff --git a/build.gradle b/build.gradle index c00dca68..d08ceb65 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ subprojects { group = 'org.cadixdev' archivesBaseName = project.name.toLowerCase() - version = '0.5.5' + version = '0.5.6-SNAPSHOT' repositories { mavenCentral() diff --git a/changelogs/0.5.6.md b/changelogs/0.5.6.md new file mode 100644 index 00000000..2236239b --- /dev/null +++ b/changelogs/0.5.6.md @@ -0,0 +1,2 @@ +Lorenz 0.5.6 +============ From 84ca0718cca9713b228394c8e4c2845b5aa0404b Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Wed, 18 Nov 2020 19:18:28 -0800 Subject: [PATCH 2/7] Allow merging parallelism to be configured --- .../impl/merge/MappingSetMergerImpl.java | 15 ++++- .../cadixdev/lorenz/merge/MergeConfig.java | 58 +++++++++++++++++-- .../cadixdev/lorenz/test/merge/MergeTest.java | 22 +++++++ 3 files changed, 86 insertions(+), 9 deletions(-) diff --git a/lorenz/src/main/java/org/cadixdev/lorenz/impl/merge/MappingSetMergerImpl.java b/lorenz/src/main/java/org/cadixdev/lorenz/impl/merge/MappingSetMergerImpl.java index d1325cae..b5c1690b 100644 --- a/lorenz/src/main/java/org/cadixdev/lorenz/impl/merge/MappingSetMergerImpl.java +++ b/lorenz/src/main/java/org/cadixdev/lorenz/impl/merge/MappingSetMergerImpl.java @@ -69,12 +69,15 @@ public class MappingSetMergerImpl implements MappingSetMerger { private final MergeContext context; + private final int parallelism; + public MappingSetMergerImpl(final MappingSet left, final MappingSet right, final MergeConfig config) { this.left = left; this.right = right; this.handler = config.getHandler(); this.methodMergeStrategy = config.getMethodMergeStrategy(); this.fieldMergeStrategy = config.getFieldMergeStrategy(); + this.parallelism = config.getParallelism(); this.context = new MergeContext(this.left, this.right); } @@ -83,7 +86,13 @@ public MappingSetMergerImpl(final MappingSet left, final MappingSet right, final public MappingSet merge(final MappingSet target) { final HashSet seenNames = new HashSet<>(); - final ExecutorService executor = Executors.newWorkStealingPool(); + final ExecutorService executor; + if (this.parallelism == -1) { + executor = Executors.newWorkStealingPool(); + } else { + executor = Executors.newWorkStealingPool(this.parallelism); + } + try { final CompletableFuture leftFuture = CompletableFuture.allOf(this.left.getTopLevelClassMappings().stream() .peek(mapping -> { @@ -383,9 +392,9 @@ public MethodParameterMapping mergeMethodParameter( if (this.fieldMergeStrategy == FieldMergeStrategy.LOOSE) { // We filter out loose matches which simply match to the same instance as those aren't actually loose looseRightContinuation = right.getFieldMapping(leftMapping.getDeobfuscatedName()) - .filter(m -> m != strictRightContinuation).orElse(null); + .filter(m -> !m.equals(strictRightContinuation)).orElse(null); looseRightDuplicate = right.getFieldMapping(leftMapping.getObfuscatedName()) - .filter(m -> m != strictRightDuplicate).orElse(null); + .filter(m -> !m.equals(strictRightDuplicate)).orElse(null); } else { looseRightContinuation = null; looseRightDuplicate = null; diff --git a/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java b/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java index 15dbdb6b..87a99402 100644 --- a/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java +++ b/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java @@ -40,10 +40,17 @@ public final class MergeConfig { private final MethodMergeStrategy methodMergeStrategy; private final FieldMergeStrategy fieldMergeStrategy; - MergeConfig(final MappingSetMergerHandler handler, final MethodMergeStrategy methodMergeStrategy, final FieldMergeStrategy fieldMergeStrategy) { + private final int parallelism; + + MergeConfig(final MappingSetMergerHandler handler, final MethodMergeStrategy methodMergeStrategy, final FieldMergeStrategy fieldMergeStrategy, final int parallelism) { this.handler = Objects.requireNonNull(handler, "handler must not be null"); this.methodMergeStrategy = Objects.requireNonNull(methodMergeStrategy, "methodMergeStrategy must not be null"); this.fieldMergeStrategy = Objects.requireNonNull(fieldMergeStrategy, "fieldMergeStrategy must not be null"); + if (parallelism == -1 || parallelism > 0) { + this.parallelism = parallelism; + } else { + throw new IllegalArgumentException("Illegal parallelism value: " + parallelism); + } } /** @@ -74,6 +81,19 @@ public FieldMergeStrategy getFieldMergeStrategy() { return this.fieldMergeStrategy; } + /** + * The parallelism level to use for the {@link java.util.concurrent.Executors#newWorkStealingPool(int) work stealing pool} used for the merge + * session. A value of {@code -1} is the default and means + * {@link java.util.concurrent.Executors#newWorkStealingPool() Executors.newWorkStealingPool()} will be used instead to create the work stealing + * pool. + * + * @return The parallelism level to use for the work stealing pool used for the merge. + * @since 0.5.6 + */ + public int getParallelism() { + return this.parallelism; + } + /** * Create a new {@link Builder} to create new instances of {@link MergeConfig}. * @@ -88,6 +108,8 @@ public String toString() { return "MergeConfig{" + "handler=" + this.handler + ", methodMergeStrategy=" + this.methodMergeStrategy + + ", fieldMergeStrategy=" + this.fieldMergeStrategy + + ", parallelism=" + this.parallelism + '}'; } @@ -95,18 +117,21 @@ public String toString() { public boolean equals(final Object o) { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; - final MergeConfig config = (MergeConfig) o; - return Objects.equals(this.handler, config.handler) && - this.methodMergeStrategy == config.methodMergeStrategy; + final MergeConfig that = (MergeConfig) o; + return this.parallelism == that.parallelism + && this.handler.equals(that.handler) + && this.methodMergeStrategy == that.methodMergeStrategy && + this.fieldMergeStrategy == that.fieldMergeStrategy; } @Override public int hashCode() { - return Objects.hash(this.handler, this.methodMergeStrategy); + return Objects.hash(this.handler, this.methodMergeStrategy, this.fieldMergeStrategy, this.parallelism); } /** * This builder class creates instances for {@link MergeConfig}. + * * @see MergeConfig */ public static final class Builder { @@ -117,6 +142,8 @@ public static final class Builder { private FieldMergeStrategy fieldMergeStrategy = FieldMergeStrategy.LOOSE; + private int parallelism = -1; + Builder() {} /** @@ -155,13 +182,32 @@ public Builder withFieldMergeStrategy(final FieldMergeStrategy fieldMergeStrateg return this; } + /** + * Set the parallelism for the {@link java.util.concurrent.Executors#newWorkStealingPool(int) work stealing pool} for the merge session. + * Defaults to {@code -1}, which means to use {@link java.util.concurrent.Executors#newWorkStealingPool() Executors.newWorkStealingPool()} + * to create the work stealing pool instead. Providing any value {@code <= 0} to this method will reset it back to the default value. + * + * @param parallelism The parallelism to use for the work stealing pool for the merge session. + * @return {@code this} instance for chaining. + * @see MergeConfig#getParallelism() + * @since 0.5.6 + */ + public Builder withParallelism(final int parallelism) { + if (parallelism <= 0) { + this.parallelism = -1; + } else { + this.parallelism = parallelism; + } + return this; + } + /** * Create the {@link MergeConfig} from this object. * * @return The merge config created from this builder. Never {@code null}. */ public MergeConfig build() { - return new MergeConfig(this.handler, this.methodMergeStrategy, this.fieldMergeStrategy); + return new MergeConfig(this.handler, this.methodMergeStrategy, this.fieldMergeStrategy, this.parallelism); } } } diff --git a/lorenz/src/test/java/org/cadixdev/lorenz/test/merge/MergeTest.java b/lorenz/src/test/java/org/cadixdev/lorenz/test/merge/MergeTest.java index 4ce0520a..2d909593 100644 --- a/lorenz/src/test/java/org/cadixdev/lorenz/test/merge/MergeTest.java +++ b/lorenz/src/test/java/org/cadixdev/lorenz/test/merge/MergeTest.java @@ -39,6 +39,8 @@ import org.cadixdev.lorenz.merge.MethodMergeStrategy; import org.cadixdev.lorenz.model.ClassMapping; import org.cadixdev.lorenz.model.InnerClassMapping; +import org.junit.jupiter.api.RepeatedTest; +import org.junit.jupiter.api.RepetitionInfo; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -194,6 +196,26 @@ public void combinedCaseLoose() throws IOException { .build()); } + @RepeatedTest(value = 5, name = "parallelMergeTest with " + RepeatedTest.CURRENT_REPETITION_PLACEHOLDER + " threads") + public void parallelMergeTest(final RepetitionInfo info) throws IOException { + System.out.println(info.getCurrentRepetition()); + testCase(buildString( + "A foo/bar/B", + "C bar/baz/D", + "E foo/bar/F" + ), buildString( + "foo/bar/B foo/bar/B", + "\ta (ILbar/baz/D;Lfoo/bar/F;J)V new_a" + ), buildString( + "A foo/bar/B", + "\ta (ILC;LE;J)V new_a", + "C bar/baz/D", + "E foo/bar/F" + ), MergeConfig.builder() + .withParallelism(info.getCurrentRepetition()) + .build()); + } + private static void testCase(final String left, final String right, final String result) throws IOException { testCase(left, right, result, MergeConfig.builder().build()); } From ba7b18c090b28cfb1108d7eba7c7380c21000086 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Fri, 20 Nov 2020 15:17:59 -0800 Subject: [PATCH 3/7] Update to Gradle 6.7.1 This also switches to use Gradle Kotlin DSL and it uses JDK 11 using the new toolchain feature introduced in Gradle 6.7. The --release flag is used to still produce Java 8 bytecode, but using the much improved JDK 11 toolchain. --- build.gradle | 151 ------------------ build.gradle.kts | 141 ++++++++++++++++ gradle.properties | 6 +- gradle/javadoc.options | 3 + gradle/wrapper/gradle-wrapper.properties | 2 +- lorenz-asm/build.gradle | 4 - lorenz-asm/build.gradle.kts | 10 ++ lorenz-io-enigma/build.gradle | 3 - lorenz-io-enigma/build.gradle.kts | 7 + lorenz-io-jam/build.gradle | 3 - lorenz-io-jam/build.gradle.kts | 7 + lorenz-io-kin/build.gradle | 3 - lorenz-io-kin/build.gradle.kts | 7 + lorenz-io-proguard/build.gradle | 4 - lorenz-io-proguard/build.gradle.kts | 8 + lorenz/build.gradle | 11 -- lorenz/build.gradle.kts | 9 ++ .../lorenz/merge/MappingSetMerger.java | 3 +- settings.gradle | 8 - settings.gradle.kts | 11 ++ 20 files changed, 209 insertions(+), 192 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 gradle/javadoc.options delete mode 100644 lorenz-asm/build.gradle create mode 100644 lorenz-asm/build.gradle.kts delete mode 100644 lorenz-io-enigma/build.gradle create mode 100644 lorenz-io-enigma/build.gradle.kts delete mode 100644 lorenz-io-jam/build.gradle create mode 100644 lorenz-io-jam/build.gradle.kts delete mode 100644 lorenz-io-kin/build.gradle create mode 100644 lorenz-io-kin/build.gradle.kts delete mode 100644 lorenz-io-proguard/build.gradle create mode 100644 lorenz-io-proguard/build.gradle.kts delete mode 100644 lorenz/build.gradle create mode 100644 lorenz/build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/build.gradle b/build.gradle deleted file mode 100644 index c00dca68..00000000 --- a/build.gradle +++ /dev/null @@ -1,151 +0,0 @@ -buildscript { - repositories { - maven { - url 'https://plugins.gradle.org/m2/' - } - } - dependencies { - classpath 'gradle.plugin.net.minecrell:licenser:0.3' - classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2' - } -} - -subprojects { - apply plugin: 'java' - apply plugin: 'maven' - apply plugin: 'net.minecrell.licenser' - - sourceCompatibility = '1.8' - targetCompatibility = '1.8' - - group = 'org.cadixdev' - archivesBaseName = project.name.toLowerCase() - version = '0.5.5' - - repositories { - mavenCentral() - if (bombeVersion.endsWith("-SNAPSHOT")) { - maven { - url 'https://oss.sonatype.org/content/groups/public/' - } - } - } - - dependencies { - testCompile 'org.junit.jupiter:junit-jupiter-api:5.2.0' - testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.2.0' - } - - test { - useJUnitPlatform() - } - - license { - header = rootProject.file('HEADER.txt') - } - - processResources { - from 'LICENSE.txt' - } - - javadoc { - def javadocArgsFile = project.file("${project.buildDir}/tmp/javadoc-tags.options") - doFirst { - javadocArgsFile.parentFile.mkdirs() - // These tags aren't supported by default, though they are standard in the JDK - // (and most tools, including IntelliJ, understand them by default) - javadocArgsFile.write("""-tag "apiNote:a:API Note:" --tag "implSpec:a:Implementation Requirements:" --tag "implNote:a:Implementation Note:" -""") - } - options.optionFiles(javadocArgsFile) - } - - task javadocJar(type: Jar, dependsOn: 'javadoc') { - from javadoc.destinationDir - classifier = 'javadoc' - } - - task sourcesJar(type: Jar, dependsOn: 'classes') { - from sourceSets.main.allSource - classifier = 'sources' - } - - artifacts { - archives javadocJar - archives sourcesJar - } - - if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { - apply plugin: 'signing' - signing { - required { !version.endsWith('-SNAPSHOT') && gradle.taskGraph.hasTask(tasks.uploadArchives) } - sign configurations.archives - } - } - - uploadArchives { - repositories { - mavenDeployer { - // Maven Central - if (project.hasProperty('ossrhUsername') && project.hasProperty('ossrhPassword')) { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - - snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') { - authentication(userName: ossrhUsername, password: ossrhPassword) - } - } - - pom { - artifactId = project.archivesBaseName - - project { - name = project.name - description = project.description - packaging = 'jar' - url = project.url - inceptionYear = project.inceptionYear - - scm { - url = 'https://github.com/CadixDev/Lorenz' - connection = 'scm:git:https://github.com/CadixDev/Lorenz.git' - developerConnection = 'scm:git:git@github.com:CadixDev/Lorenz.git' - } - - issueManagement { - system = 'GitHub' - url = 'https://github.com/CadixDev/Lorenz/issues' - } - - licenses { - license { - name = 'MIT License' - url = 'https://opensource.org/licenses/MIT' - distribution = 'repo' - } - } - - developers { - developer { - id = 'jamierocks' - name = 'Jamie Mansfield' - email = 'jmansfield@cadixdev.org' - url = 'https://www.jamiemansfield.me/' - timezone = 'Europe/London' - } - } - } - } - } - } - } -} - -task wrapper(type: Wrapper) { - gradleVersion = '4.10' -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..a66964fa --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,141 @@ +import org.cadixdev.gradle.licenser.Licenser +import org.cadixdev.gradle.licenser.LicenseExtension + +plugins { + `java-library` + id("org.cadixdev.licenser") version "0.5.0" apply false +} + +val projectName: String by project +val projectUrl: String by project +val projectInceptionYear: String by project +val bombeVersion: String by project + +val isSnapshot = version.toString().endsWith("-SNAPSHOT") + +allprojects { + group = "org.cadixdev" + version = "0.5.5" +} + +subprojects { + apply() + apply() + apply() + + repositories { + mavenCentral() + if (bombeVersion.endsWith("-SNAPSHOT")) { + maven("https://oss.sonatype.org/content/groups/public/") + } + } + + dependencies { + testImplementation(platform("org.junit:junit-bom:5.7.0")) + testImplementation("org.junit.jupiter:junit-jupiter-api") + testImplementation("org.junit.jupiter:junit-jupiter-engine") + } + + java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(11)) + } + withSourcesJar() + withJavadocJar() + } + + tasks.javadoc { + options.optionFiles(rootProject.file("gradle/javadoc.options")) + } + + configure { + header = rootProject.file("HEADER.txt") + } + + tasks.withType().configureEach { + options.release.set(8) + } + + tasks.test { + useJUnitPlatform() + } + + tasks.processResources { + from(rootProject.file("LICENSE.txt")) + } + + configure { + publications { + create("maven") { + groupId = project.group.toString() + artifactId = project.name + version = project.version.toString() + + from(components["java"]) + withoutBuildIdentifier() + + pom { + name.set(projectName) + description.set(project.description) + packaging = "jar" + url.set(projectUrl) + inceptionYear.set(projectInceptionYear) + + scm { + connection.set("scm:git:https://github.com/CadixDev/Lorenz.git") + developerConnection.set("scm:git:git@github.com:CadixDev/Lorenz.git") + url.set("https://github.com/CadixDev/Lorenz") + } + + issueManagement { + system.set("GitHub") + url.set("https://github.com/CadixDev/Lorenz/issues") + } + + licenses { + license { + name.set("MIT License") + url.set("https://opensource.org/licenses/MIT") + distribution.set("repo") + } + } + + developers { + developer { + id.set("jamierocks") + name.set("Jamie Mansfield") + email.set("jmansfield@cadixdev.org") + url.set("https://www.jamiemansfield.me") + timezone.set("Europe/London") + } + } + } + } + } + + repositories { + val url = if (isSnapshot) { + "https://oss.sonatype.org/content/repositories/snapshots/" + } else { + "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + } + maven(url) { + credentials(PasswordCredentials::class) + name = "ossrh" + } + } + } + + if (project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) { + apply() + configure { + setRequired { + !isSnapshot && ( + gradle.taskGraph.hasTask("publishAllPublicationsToOssrhRepository") + || gradle.taskGraph.hasTask("publishMavenPublicationToOssrhRepository") + ) + } + sign(project.extensions.getByType().publications["maven"]) + } + } +} diff --git a/gradle.properties b/gradle.properties index dcaa9982..44d48229 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ # Project Information -name = Lorenz -url = https://www.cadixdev.org/ -inceptionYear = 2016 +projectName = Lorenz +projectUrl = https://www.cadixdev.org/ +projectInceptionYear = 2016 # Build Settings bombeVersion = 0.3.4 diff --git a/gradle/javadoc.options b/gradle/javadoc.options new file mode 100644 index 00000000..e0e89e0f --- /dev/null +++ b/gradle/javadoc.options @@ -0,0 +1,3 @@ +-tag "apiNote:a:API Note:" +-tag "implSpec:a:Implementation Requirements:" +-tag "implNote:a:Implementation Note:" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 115e6ac0..4d9ca164 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/lorenz-asm/build.gradle b/lorenz-asm/build.gradle deleted file mode 100644 index d8b11b02..00000000 --- a/lorenz-asm/build.gradle +++ /dev/null @@ -1,4 +0,0 @@ -dependencies { - compile project(':lorenz') - compile "org.cadixdev:bombe-asm:${rootProject.bombeVersion}" -} diff --git a/lorenz-asm/build.gradle.kts b/lorenz-asm/build.gradle.kts new file mode 100644 index 00000000..850163b5 --- /dev/null +++ b/lorenz-asm/build.gradle.kts @@ -0,0 +1,10 @@ +plugins { + `java-library` +} + +val bombeVersion: String by rootProject + +dependencies { + api(project(":lorenz")) + api("org.cadixdev:bombe-asm:$bombeVersion") +} diff --git a/lorenz-io-enigma/build.gradle b/lorenz-io-enigma/build.gradle deleted file mode 100644 index 46ad1462..00000000 --- a/lorenz-io-enigma/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -dependencies { - compile project(':lorenz') -} diff --git a/lorenz-io-enigma/build.gradle.kts b/lorenz-io-enigma/build.gradle.kts new file mode 100644 index 00000000..5dc4e7d7 --- /dev/null +++ b/lorenz-io-enigma/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `java-library` +} + +dependencies { + api(project(":lorenz")) +} diff --git a/lorenz-io-jam/build.gradle b/lorenz-io-jam/build.gradle deleted file mode 100644 index 46ad1462..00000000 --- a/lorenz-io-jam/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -dependencies { - compile project(':lorenz') -} diff --git a/lorenz-io-jam/build.gradle.kts b/lorenz-io-jam/build.gradle.kts new file mode 100644 index 00000000..5dc4e7d7 --- /dev/null +++ b/lorenz-io-jam/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `java-library` +} + +dependencies { + api(project(":lorenz")) +} diff --git a/lorenz-io-kin/build.gradle b/lorenz-io-kin/build.gradle deleted file mode 100644 index 46ad1462..00000000 --- a/lorenz-io-kin/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -dependencies { - compile project(':lorenz') -} diff --git a/lorenz-io-kin/build.gradle.kts b/lorenz-io-kin/build.gradle.kts new file mode 100644 index 00000000..5dc4e7d7 --- /dev/null +++ b/lorenz-io-kin/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `java-library` +} + +dependencies { + api(project(":lorenz")) +} diff --git a/lorenz-io-proguard/build.gradle b/lorenz-io-proguard/build.gradle deleted file mode 100644 index d11c53d4..00000000 --- a/lorenz-io-proguard/build.gradle +++ /dev/null @@ -1,4 +0,0 @@ -dependencies { - compile project(':lorenz') - compile 'me.jamiemansfield:string:0.1.0' -} diff --git a/lorenz-io-proguard/build.gradle.kts b/lorenz-io-proguard/build.gradle.kts new file mode 100644 index 00000000..8eca764d --- /dev/null +++ b/lorenz-io-proguard/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + `java-library` +} + +dependencies { + api(project(":lorenz")) + api("me.jamiemansfield:string:0.1.0") +} diff --git a/lorenz/build.gradle b/lorenz/build.gradle deleted file mode 100644 index 407d4afb..00000000 --- a/lorenz/build.gradle +++ /dev/null @@ -1,11 +0,0 @@ -dependencies { - compile "org.cadixdev:bombe:${rootProject.bombeVersion}" -} - -javadoc { - options.encoding = 'UTF-8' - options.charSet = 'UTF-8' - options.links( - 'https://docs.oracle.com/javase/8/docs/api/' - ) -} diff --git a/lorenz/build.gradle.kts b/lorenz/build.gradle.kts new file mode 100644 index 00000000..0f6e61b6 --- /dev/null +++ b/lorenz/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +val bombeVersion: String by rootProject + +dependencies { + api("org.cadixdev:bombe:$bombeVersion") +} diff --git a/lorenz/src/main/java/org/cadixdev/lorenz/merge/MappingSetMerger.java b/lorenz/src/main/java/org/cadixdev/lorenz/merge/MappingSetMerger.java index 51161133..ec81698d 100644 --- a/lorenz/src/main/java/org/cadixdev/lorenz/merge/MappingSetMerger.java +++ b/lorenz/src/main/java/org/cadixdev/lorenz/merge/MappingSetMerger.java @@ -48,7 +48,8 @@ * More complex situations are likely to occur while merging mappings, so this table will go through the different * possible cases and how a mapping set merger handles them in the default implementation: *

- * + *
+ * * * * diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e8c3b4b8..00000000 --- a/settings.gradle +++ /dev/null @@ -1,8 +0,0 @@ -rootProject.name = name -include 'lorenz' -include 'lorenz-asm' -include 'lorenz-io-enigma' -include 'lorenz-io-jam' -include 'lorenz-io-kin' -include 'lorenz-io-proguard' - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..8ca3635c --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,11 @@ +val projectName: String by settings +rootProject.name = projectName + +include( + "lorenz", + "lorenz-asm", + "lorenz-io-enigma", + "lorenz-io-jam", + "lorenz-io-kin", + "lorenz-io-proguard" +) From ef03ba94936d3f3cdd0855a18b778569330cdbf4 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Sat, 21 Nov 2020 12:53:31 -0800 Subject: [PATCH 4/7] Add release notes for 0.5.6 --- changelogs/0.5.6.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/changelogs/0.5.6.md b/changelogs/0.5.6.md index 2236239b..d776ddc0 100644 --- a/changelogs/0.5.6.md +++ b/changelogs/0.5.6.md @@ -1,2 +1,15 @@ Lorenz 0.5.6 ============ + +Configurable Parallelism during mapping merges +---------------------------------------------- + +The mapping merging system introduced in 0.5.4 merges mappings in parallel - which in quick testing can +improve the merge time by half. There may be cases where the max number of threads needs to be controlled. +One common example is debugging Lorenz itself, having multiple merge threads running at once can make +debugging a lot more difficult. + +This release just adds one new method to [`MergeConfig`](https://github.com/CadixDev/Lorenz/blob/49be5233bff0adfaf59440ac37efdeccbb2893da/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java): +[`getParallelism()`](https://github.com/CadixDev/Lorenz/blob/49be5233bff0adfaf59440ac37efdeccbb2893da/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java#L84-L95). +Set this value using the new [`withParallelism()`](https://github.com/CadixDev/Lorenz/blob/49be5233bff0adfaf59440ac37efdeccbb2893da/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java#L185-L202) +method. Check the javadocs for more info. From f5d8d9ca4bd8dee337853ef5896e82bc261e6d8e Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Sat, 21 Nov 2020 22:32:09 -0800 Subject: [PATCH 5/7] Update gradle.properties values for submodules as well --- lorenz-asm/gradle.properties | 6 +++--- lorenz-io-enigma/gradle.properties | 6 +++--- lorenz-io-jam/gradle.properties | 6 +++--- lorenz-io-kin/gradle.properties | 6 +++--- lorenz-io-proguard/gradle.properties | 6 +++--- lorenz/gradle.properties | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lorenz-asm/gradle.properties b/lorenz-asm/gradle.properties index 62b0a918..0a697fe4 100644 --- a/lorenz-asm/gradle.properties +++ b/lorenz-asm/gradle.properties @@ -1,4 +1,4 @@ -name = Lorenz-ASM +projectName = Lorenz-ASM description = Utility classes for using Lorenz with ASM. -url = https://www.jamiemansfield.me/projects/lorenz -inceptionYear = 2018 +projectUrl = https://www.jamiemansfield.me/projects/lorenz +projectInceptionYear = 2018 diff --git a/lorenz-io-enigma/gradle.properties b/lorenz-io-enigma/gradle.properties index eb2b6031..4fd70d76 100644 --- a/lorenz-io-enigma/gradle.properties +++ b/lorenz-io-enigma/gradle.properties @@ -1,4 +1,4 @@ -name = Lorenz-IO-Enigma +projectName = Lorenz-IO-Enigma description = An implementation of the Enigma mapping format for Lorenz. -url = https://www.jamiemansfield.me/projects/lorenz -inceptionYear = 2018 +projectUrl = https://www.jamiemansfield.me/projects/lorenz +projectInceptionYear = 2018 diff --git a/lorenz-io-jam/gradle.properties b/lorenz-io-jam/gradle.properties index 2afe3258..dcb3072d 100644 --- a/lorenz-io-jam/gradle.properties +++ b/lorenz-io-jam/gradle.properties @@ -1,4 +1,4 @@ -name = Lorenz-IO-JAM +projectName = Lorenz-IO-JAM description = An implementation of the JAM mapping format for Lorenz. -url = https://www.jamiemansfield.me/projects/lorenz -inceptionYear = 2018 +projectUrl = https://www.jamiemansfield.me/projects/lorenz +projectInceptionYear = 2018 diff --git a/lorenz-io-kin/gradle.properties b/lorenz-io-kin/gradle.properties index 80745162..f5c9cb75 100644 --- a/lorenz-io-kin/gradle.properties +++ b/lorenz-io-kin/gradle.properties @@ -1,4 +1,4 @@ -name = Lorenz-IO-Kin +projectName = Lorenz-IO-Kin description = An implementation of the Kin mapping format for Lorenz. -url = https://www.jamiemansfield.me/projects/lorenz -inceptionYear = 2018 +projectUrl = https://www.jamiemansfield.me/projects/lorenz +projectInceptionYear = 2018 diff --git a/lorenz-io-proguard/gradle.properties b/lorenz-io-proguard/gradle.properties index d2fcb4e8..5b3f5d03 100644 --- a/lorenz-io-proguard/gradle.properties +++ b/lorenz-io-proguard/gradle.properties @@ -1,4 +1,4 @@ -name = Lorenz-IO-ProGuard +projectName = Lorenz-IO-ProGuard description = An implementation of the ProGuard mapping format for Lorenz. -url = https://www.jamiemansfield.me/projects/lorenz -inceptionYear = 2019 +projectUrl = https://www.jamiemansfield.me/projects/lorenz +projectInceptionYear = 2019 diff --git a/lorenz/gradle.properties b/lorenz/gradle.properties index d9eacbb6..0715945c 100644 --- a/lorenz/gradle.properties +++ b/lorenz/gradle.properties @@ -1,4 +1,4 @@ -name = Lorenz +projectName = Lorenz description = A library for modelling, creating, and manipulating Java de-obfuscation mappings. -url = https://www.jamiemansfield.me/projects/lorenz -inceptionYear = 2016 +projectUrl = https://www.jamiemansfield.me/projects/lorenz +projectInceptionYear = 2016 From 56e74323a40767bdfcff3c091b7727fba82f114b Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Thu, 26 Nov 2020 17:33:10 -0800 Subject: [PATCH 6/7] Allow any method parameter index The previous implementation required all method parameter indexes be within the range for the parameters of the method mapping based on the method signature. This commit changes the behavior to instead allow any parameter index provided. There are two arguments for allowing this behavior: 1. Some mapping formats have different meanings for the index parameters, and Lorenz has no way of handling them other than taking the parameter index as-is. The most common example is static methods starting to count method parameters at 0, while instance methods start at 1 (as `this` is index 0). Lorenz has no way of knowing a method is static or not, and even if it did it can't be guaranteed that every mapping format behaves the same way. 2. All other mappings (top-level class, field, method, and inner class mappings) have no way to verify, and don't verify, if the mapping is valid. A method parameter index outside of the parameter index range is very similar to a field mapping in a class which doesn't contain a field of that name. It's Lorenz's job to verify mappings are valid, only to store them as given and reproduce them later. There's definitely a risk here that 1 mapping format may want 0-indexed parameter mappings for all methods, whereas another mapping format wants the above strategy of using 1-indexed mappings for instance methods, but I don't see a viable solution for handling cases like these. In situations where parameter mappings are needed it's likely that the mapping format will not change, or if it does then it is up to the user to handle it one way or the other. Lorenz is just a mapping container, it can't perfectly handle all cases. But as long as it provides a flexible model and allows the user to insert the mappings it needs, then the user can write whatever code they need to to handle whichever situation they run into. --- changelogs/0.5.6.md | 15 +++++++ .../lorenz/impl/model/MethodMappingImpl.java | 39 ++++++------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/changelogs/0.5.6.md b/changelogs/0.5.6.md index d776ddc0..00829c6c 100644 --- a/changelogs/0.5.6.md +++ b/changelogs/0.5.6.md @@ -13,3 +13,18 @@ This release just adds one new method to [`MergeConfig`](https://github.com/Cadi [`getParallelism()`](https://github.com/CadixDev/Lorenz/blob/49be5233bff0adfaf59440ac37efdeccbb2893da/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java#L84-L95). Set this value using the new [`withParallelism()`](https://github.com/CadixDev/Lorenz/blob/49be5233bff0adfaf59440ac37efdeccbb2893da/lorenz/src/main/java/org/cadixdev/lorenz/merge/MergeConfig.java#L185-L202) method. Check the javadocs for more info. + +Allow arbitrary indexes for parameter mappings +--------------------------------------------- + +Method mappings may now contain parameter mappings for arbitrary indexes, rather than being constrained to +between 0 and the number of parameters in the method signature. This is nice from a general flexibility +perspective as Lorenz is only a container and isn't intended for validating mappings, but also fixes the issue +where Lorenz can't read mappings which using 1-indexed method parameters for instance methods. With this change +it's up to the user to decide how to use parameter mappings, Lorenz doesn't dictate anything one way or the +other (just like the other mapping types). + +Any code which worked with Lorenz before will still continue to work, as this change only removes constraints +which used to be present. If some code was written which relied on the existing index checks then this will +technically be a breaking change, as you'll need to handle those checks yourself. That is likely to be a minor +edge case however, so this is still considered a minor release. diff --git a/lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodMappingImpl.java b/lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodMappingImpl.java index a7bed3f0..66c9cf3f 100644 --- a/lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodMappingImpl.java +++ b/lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodMappingImpl.java @@ -25,18 +25,18 @@ package org.cadixdev.lorenz.impl.model; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.cadixdev.lorenz.model.ClassMapping; import org.cadixdev.lorenz.model.MethodMapping; import org.cadixdev.lorenz.model.MethodParameterMapping; import org.cadixdev.bombe.type.signature.MethodSignature; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Objects; import java.util.Optional; import java.util.StringJoiner; -import java.util.stream.Collectors; /** * A basic implementation of {@link MethodMapping}. @@ -49,7 +49,8 @@ public class MethodMappingImpl implements MethodMapping { private final MethodSignature signature; - private final MethodParameterMapping[] parameters; + + private final Map parameters = new ConcurrentHashMap<>(); /** * Creates a new method mapping, from the given parameters. @@ -58,11 +59,9 @@ public class MethodMappingImpl * @param signature The signature * @param deobfuscatedName The de-obfuscated name */ - public MethodMappingImpl(final ClassMapping parentClass, final MethodSignature signature, - final String deobfuscatedName) { + public MethodMappingImpl(final ClassMapping parentClass, final MethodSignature signature, final String deobfuscatedName) { super(parentClass, signature.getName(), deobfuscatedName); this.signature = signature; - this.parameters = new MethodParameterMapping[signature.getDescriptor().getParamTypes().size()]; } @Override @@ -72,38 +71,25 @@ public MethodSignature getSignature() { @Override public Collection getParameterMappings() { - return Collections.unmodifiableList(Arrays.stream(this.parameters) - .filter(Objects::nonNull).collect(Collectors.toList())); - } - - private void checkIndex(final int index) { - if (index < 0 || index >= this.parameters.length) { - throw new IndexOutOfBoundsException(String.valueOf(index)); - } + return Collections.unmodifiableCollection(this.parameters.values()); } @Override public MethodParameterMapping createParameterMapping(final int index, final String deobfuscatedName) { - this.checkIndex(index); - final MethodParameterMapping mapping = this.parameters[index]; - if (mapping != null) { - return mapping.setDeobfuscatedName(deobfuscatedName); - } - else { - return this.parameters[index] = this.getMappings().getModelFactory().createMethodParameterMapping(this, index, deobfuscatedName); - } + return this.parameters.compute(index, (i, mapping) -> { + if (mapping != null) return mapping.setDeobfuscatedName(deobfuscatedName); + return this.getMappings().getModelFactory().createMethodParameterMapping(this, i, deobfuscatedName); + }); } @Override public Optional getParameterMapping(final int index) { - this.checkIndex(index); - return Optional.ofNullable(this.parameters[index]); + return Optional.ofNullable(this.parameters.get(index)); } @Override public boolean hasParameterMapping(final int index) { - this.checkIndex(index); - return this.parameters[index] != null; + return this.parameters.containsKey(index); } @Override @@ -125,5 +111,4 @@ public boolean equals(final Object obj) { public int hashCode() { return Objects.hash(super.hashCode(), this.signature); } - } From b026cd16dcd8c74f9318a52bcf15cfebed427e63 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Fri, 27 Nov 2020 20:06:40 +0000 Subject: [PATCH 7/7] 0.5.6: Release Time --- build.gradle.kts | 3 ++- .../org/cadixdev/lorenz/impl/model/MethodMappingImpl.java | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7e88d751..a65ae902 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ val isSnapshot = version.toString().endsWith("-SNAPSHOT") allprojects { group = "org.cadixdev" - version = "0.5.6-SNAPSHOT" + version = "0.5.6" } subprojects { @@ -129,6 +129,7 @@ subprojects { if (project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) { apply() configure { + useGpgCmd() setRequired { !isSnapshot && ( gradle.taskGraph.hasTask("publishAllPublicationsToOssrhRepository") diff --git a/lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodMappingImpl.java b/lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodMappingImpl.java index 66c9cf3f..8d1c96da 100644 --- a/lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodMappingImpl.java +++ b/lorenz/src/main/java/org/cadixdev/lorenz/impl/model/MethodMappingImpl.java @@ -25,18 +25,18 @@ package org.cadixdev.lorenz.impl.model; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import org.cadixdev.bombe.type.signature.MethodSignature; import org.cadixdev.lorenz.model.ClassMapping; import org.cadixdev.lorenz.model.MethodMapping; import org.cadixdev.lorenz.model.MethodParameterMapping; -import org.cadixdev.bombe.type.signature.MethodSignature; import java.util.Collection; import java.util.Collections; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.StringJoiner; +import java.util.concurrent.ConcurrentHashMap; /** * A basic implementation of {@link MethodMapping}. @@ -49,7 +49,6 @@ public class MethodMappingImpl implements MethodMapping { private final MethodSignature signature; - private final Map parameters = new ConcurrentHashMap<>(); /** @@ -111,4 +110,5 @@ public boolean equals(final Object obj) { public int hashCode() { return Objects.hash(super.hashCode(), this.signature); } + }
Merge Situations
LeftRight