From 4ab6015280426d00fec4af02e454be1512872765 Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 21 Nov 2024 19:17:58 -0500 Subject: [PATCH] Fix build failing in JDK 23 environments --- build.gradle | 4 ++++ gradle/libs.versions.toml | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- .../coley/recaf/services/file/RecafDirectoriesConfig.java | 5 +++-- .../coley/recaf/services/compile/JavacCompilerTest.java | 2 +- .../recaf/services/decompile/FallbackDecompilerTest.java | 4 ++++ 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 86e720f11..a76a5fa60 100644 --- a/build.gradle +++ b/build.gradle @@ -73,10 +73,14 @@ subprojects { test { useJUnitPlatform() + // Required for Mockito in newer JDK's which disable useful features by default for 'integrity' reasons. + jvmArgs '-XX:+EnableDynamicAgentLoading' + systemProperty 'junit.jupiter.execution.parallel.enabled', true systemProperty 'junit.jupiter.execution.parallel.mode.default', 'concurrent' testLogging { + showStandardStreams = true events "passed", "skipped", "failed" } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f4674dac1..abaedd0e2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -39,7 +39,7 @@ treemapfx = "1.1.0" vineflower = "1.10.1" wordwrap = "0.1.12" benmanes-versions = "0.42.0" -gradle-coverage-report-aggregator = "1.3.0" +gradle-coverage-report-aggregator = "1.3.2" gradle-checker-processor = "2.0.2" javafx-plugin = "0.1.0" shadow = "8.1.1" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 19cfad969..81aa1c044 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-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/recaf-core/src/main/java/software/coley/recaf/services/file/RecafDirectoriesConfig.java b/recaf-core/src/main/java/software/coley/recaf/services/file/RecafDirectoriesConfig.java index af43c256d..ac1e5e2cf 100644 --- a/recaf-core/src/main/java/software/coley/recaf/services/file/RecafDirectoriesConfig.java +++ b/recaf-core/src/main/java/software/coley/recaf/services/file/RecafDirectoriesConfig.java @@ -11,6 +11,7 @@ import software.coley.recaf.config.ConfigContainer; import software.coley.recaf.config.ConfigGroups; import software.coley.recaf.launch.LaunchCommand; +import software.coley.recaf.util.ExcludeFromJacocoGeneratedReport; import software.coley.recaf.util.IOUtil; import software.coley.recaf.util.PlatformType; @@ -25,6 +26,7 @@ * @author Matt Coley */ @ApplicationScoped +@ExcludeFromJacocoGeneratedReport(justification = "We do not access the config directories in tests (avoiding IO is preferred anyways)") public class RecafDirectoriesConfig extends BasicConfigContainer implements ConfigContainer { private static final Logger logger = Logging.get(RecafDirectoriesConfig.class); private final Path baseDirectory = createBaseDirectory(); @@ -48,9 +50,8 @@ public RecafDirectoriesConfig() { * Path to current log-file. */ public void initCurrentLogPath(@Nonnull Path currentLog) { - if (this.currentLog == null) { + if (this.currentLog == null) this.currentLog = currentLog; - } } /** diff --git a/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java b/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java index 792358ea9..7e2fae2d5 100644 --- a/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java +++ b/recaf-core/src/test/java/software/coley/recaf/services/compile/JavacCompilerTest.java @@ -75,7 +75,7 @@ public static void main(String[] args) { // Run compiler, it should fail with no passed workspace due to the unknown 'StringConsumer' CompilerResult result = javac.compile(arguments, null, null); - assertEquals(1, result.getDiagnostics().size(), "Expected compilation failure"); + assertFalse(result.getDiagnostics().isEmpty(), "Expected compilation failure"); assertFalse(result.getCompilations().containsKey("HelloWorld"), "Class should have failed compilation"); // First, create the class that was missing. We cannot use the existing StringConsumer because Javac will find diff --git a/recaf-core/src/test/java/software/coley/recaf/services/decompile/FallbackDecompilerTest.java b/recaf-core/src/test/java/software/coley/recaf/services/decompile/FallbackDecompilerTest.java index 7c5292646..04850e148 100644 --- a/recaf-core/src/test/java/software/coley/recaf/services/decompile/FallbackDecompilerTest.java +++ b/recaf-core/src/test/java/software/coley/recaf/services/decompile/FallbackDecompilerTest.java @@ -4,6 +4,7 @@ import jakarta.annotation.Nonnull; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; +import software.coley.recaf.services.decompile.fallback.FallbackDecompiler; import software.coley.recaf.services.decompile.fallback.print.ClassPrinter; import software.coley.recaf.services.text.TextFormatConfig; import software.coley.recaf.test.TestClassUtils; @@ -22,6 +23,9 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertTrue; +/** + * Tests for {@link FallbackDecompiler} + */ class FallbackDecompilerTest { static TextFormatConfig textConfig = new TextFormatConfig();