From a475e034cdefc8cf73036029b14cc9374c297280 Mon Sep 17 00:00:00 2001 From: Manfred Hanke Date: Sun, 30 Mar 2025 20:05:27 +0200 Subject: [PATCH 1/6] =?UTF-8?q?upgrade=20ASM=20(9.7.1=20=E2=86=92=209.8)?= =?UTF-8?q?=20to=20support=20Java=2025's=20class=20file=20major=20version?= =?UTF-8?q?=2069?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manfred Hanke --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 15ab871adb..83b3b7887d 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ ext { googleRelocationPackage = "${thirdPartyRelocationPackage}.com.google" dependency = [ - asm : [group: 'org.ow2.asm', name: 'asm', version: '9.7.1'], + asm : [group: 'org.ow2.asm', name: 'asm', version: '9.8'], guava : [group: 'com.google.guava', name: 'guava', version: '33.3.1-jre'], addGuava : { dependencyHandler -> dependencyHandler(dependency.guava) { From 93e489fb54d7940251a612f3e24ebb378c39bdbd Mon Sep 17 00:00:00 2001 From: Manfred Hanke Date: Sun, 30 Mar 2025 21:20:57 +0200 Subject: [PATCH 2/6] =?UTF-8?q?upgrade=20Guava=20(33.3.1-jre=20=E2=86=92?= =?UTF-8?q?=2033.4.8-jre)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/google/guava/releases/tag/v33.4.4 has - removed the dependency on JSR-305 [https://github.com/google/guava/commit/04bf0300b8736ec7297a34da40a6efb21231c5da] - migrated from Checker Framework annotations to (JSpecify)[https://jspecify.dev/] annotations [https://github.com/google/guava/commit/2cc8c5eddb587db3ac12dacdd5563e79a4681ec4] - removed the dependency on Checker Framework annotations [https://github.com/google/guava/commit/800b3d42bd124519eac2604b1c4800d523d6065a] compare - https://repo1.maven.org/maven2/com/google/guava/guava/33.3.1-jre/guava-33.3.1-jre.pom - https://repo1.maven.org/maven2/com/google/guava/guava/33.4.8-jre/guava-33.4.8-jre.pom Signed-off-by: Manfred Hanke --- build.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 83b3b7887d..e7c6d1d161 100644 --- a/build.gradle +++ b/build.gradle @@ -36,12 +36,11 @@ ext { dependency = [ asm : [group: 'org.ow2.asm', name: 'asm', version: '9.8'], - guava : [group: 'com.google.guava', name: 'guava', version: '33.3.1-jre'], + guava : [group: 'com.google.guava', name: 'guava', version: '33.4.8-jre'], addGuava : { dependencyHandler -> dependencyHandler(dependency.guava) { exclude module: 'listenablefuture' - exclude module: 'jsr305' - exclude module: 'checker-qual' + exclude module: 'jspecify' exclude module: 'error_prone_annotations' exclude module: 'j2objc-annotations' } From 71f1bf51f219ff7795049b4044cccd94cf1e2fdd Mon Sep 17 00:00:00 2001 From: Manfred Hanke Date: Sun, 30 Mar 2025 21:25:46 +0200 Subject: [PATCH 3/6] =?UTF-8?q?upgrade=20slf4j=20(2.0.16=20=E2=86=92=202.0?= =?UTF-8?q?.17)=20and=20test=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * org.apache.logging.log4j:log4j-{api,core,slf4j2-impl} 2.24.1 → 2.24.3 * org.assertj:assertj-{core,guava} 3.26.3 → 3.27.3 Signed-off-by: Manfred Hanke --- build.gradle | 12 ++++++------ .../src/main/resources/release_check/archunit.pom | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index e7c6d1d161..3e21b98842 100644 --- a/build.gradle +++ b/build.gradle @@ -45,10 +45,10 @@ ext { exclude module: 'j2objc-annotations' } }, - slf4j : [group: 'org.slf4j', name: 'slf4j-api', version: '2.0.16'], - log4j_api : [group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.24.1'], - log4j_core : [group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.24.1'], - log4j_slf4j : [group: 'org.apache.logging.log4j', name: 'log4j-slf4j2-impl', version: '2.24.1'], + slf4j : [group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17'], + log4j_api : [group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.24.3'], + log4j_core : [group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.24.3'], + log4j_slf4j : [group: 'org.apache.logging.log4j', name: 'log4j-slf4j2-impl', version: '2.24.3'], junit4 : [group: 'junit', name: 'junit', version: '4.13.2'], junit5JupiterApi : [group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.11.2'], @@ -61,8 +61,8 @@ ext { junit_dataprovider : [group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.11.0'], mockito : [group: 'org.mockito', name: 'mockito-core', version: '4.11.0'], // mockito 5 requires Java 11 mockito_junit5 : [group: 'org.mockito', name: 'mockito-junit-jupiter', version: '4.6.1'], - assertj : [group: 'org.assertj', name: 'assertj-core', version: '3.26.3'], - assertj_guava : [group: 'org.assertj', name: 'assertj-guava', version: '3.26.3'], + assertj : [group: 'org.assertj', name: 'assertj-core', version: '3.27.3'], + assertj_guava : [group: 'org.assertj', name: 'assertj-guava', version: '3.27.3'], // Dependencies for example projects / tests javaxAnnotationApi : [group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'], diff --git a/buildSrc/src/main/resources/release_check/archunit.pom b/buildSrc/src/main/resources/release_check/archunit.pom index b1d97bce2c..f3934c7a8a 100644 --- a/buildSrc/src/main/resources/release_check/archunit.pom +++ b/buildSrc/src/main/resources/release_check/archunit.pom @@ -50,7 +50,7 @@ org.slf4j slf4j-api - 2.0.16 + 2.0.17 compile From a94e55ec09805b2ca753cf8ceebfaa2fda9cc907 Mon Sep 17 00:00:00 2001 From: Manfred Hanke Date: Mon, 31 Mar 2025 08:09:30 +0200 Subject: [PATCH 4/6] simplify JUnit dependencies junit-jupiter = junit-jupiter-api + junit-jupiter-params + junit-jupiter-engine (runtime) Signed-off-by: Manfred Hanke --- build.gradle | 3 +-- .../src/main/groovy/archunit.java-testing-conventions.gradle | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 3e21b98842..ef4256af47 100644 --- a/build.gradle +++ b/build.gradle @@ -51,8 +51,7 @@ ext { log4j_slf4j : [group: 'org.apache.logging.log4j', name: 'log4j-slf4j2-impl', version: '2.24.3'], junit4 : [group: 'junit', name: 'junit', version: '4.13.2'], - junit5JupiterApi : [group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.11.2'], - junit5JupiterEngine : [group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.11.2'], + junit5Jupiter : [group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.11.2'], junit5VintageEngine : [group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.11.2'], junitPlatform : [group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.11.2'], junitPlatformCommons: [group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.11.2'], diff --git a/buildSrc/src/main/groovy/archunit.java-testing-conventions.gradle b/buildSrc/src/main/groovy/archunit.java-testing-conventions.gradle index 562f0ee7ed..e3a8319ff1 100644 --- a/buildSrc/src/main/groovy/archunit.java-testing-conventions.gradle +++ b/buildSrc/src/main/groovy/archunit.java-testing-conventions.gradle @@ -9,9 +9,8 @@ abstract class ArchUnitTestExtension { ext.archUnitTest = extensions.create('archUnitTest', ArchUnitTestExtension) dependencies { - testImplementation dependency.junit5JupiterApi + testImplementation dependency.junit5Jupiter - testRuntimeOnly dependency.junit5JupiterEngine testRuntimeOnly dependency.junit5VintageEngine testRuntimeOnly dependency.log4j_slf4j } From 8351907bee5675effe9d3e64bbae60f227b33717 Mon Sep 17 00:00:00 2001 From: Manfred Hanke Date: Sun, 30 Mar 2025 22:59:58 +0200 Subject: [PATCH 5/6] =?UTF-8?q?upgrade=20JUnit=20(5.11.2=20=E2=86=92=205.1?= =?UTF-8?q?2.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without the `junit-platform-launcher` dependency, `./gradlew test` fails with ``` org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160) at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:134) at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:108) at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:80) at app//org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:110) at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at app//org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:124) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:94) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63) ... 16 more Caused by: org.junit.platform.commons.JUnitException: OutputDirectoryProvider not available; probably due to unaligned versions of the junit-platform-engine and junit-platform-launcher jars on the classpath/module path. at app//org.junit.platform.engine.EngineDiscoveryRequest.getOutputDirectoryProvider(EngineDiscoveryRequest.java:94) at app//org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:67) at app//org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152) ... 26 more ``` Signed-off-by: Manfred Hanke --- build.gradle | 59 ++++++++++--------- .../archunit.java-testing-conventions.gradle | 1 + .../archunit-junit5-engine-api.pom | 2 +- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/build.gradle b/build.gradle index ef4256af47..88c614e5f6 100644 --- a/build.gradle +++ b/build.gradle @@ -35,9 +35,9 @@ ext { googleRelocationPackage = "${thirdPartyRelocationPackage}.com.google" dependency = [ - asm : [group: 'org.ow2.asm', name: 'asm', version: '9.8'], - guava : [group: 'com.google.guava', name: 'guava', version: '33.4.8-jre'], - addGuava : { dependencyHandler -> + asm : [group: 'org.ow2.asm', name: 'asm', version: '9.8'], + guava : [group: 'com.google.guava', name: 'guava', version: '33.4.8-jre'], + addGuava : { dependencyHandler -> dependencyHandler(dependency.guava) { exclude module: 'listenablefuture' exclude module: 'jspecify' @@ -45,36 +45,37 @@ ext { exclude module: 'j2objc-annotations' } }, - slf4j : [group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17'], - log4j_api : [group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.24.3'], - log4j_core : [group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.24.3'], - log4j_slf4j : [group: 'org.apache.logging.log4j', name: 'log4j-slf4j2-impl', version: '2.24.3'], + slf4j : [group: 'org.slf4j', name: 'slf4j-api', version: '2.0.17'], + log4j_api : [group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.24.3'], + log4j_core : [group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.24.3'], + log4j_slf4j : [group: 'org.apache.logging.log4j', name: 'log4j-slf4j2-impl', version: '2.24.3'], - junit4 : [group: 'junit', name: 'junit', version: '4.13.2'], - junit5Jupiter : [group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.11.2'], - junit5VintageEngine : [group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.11.2'], - junitPlatform : [group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.11.2'], - junitPlatformCommons: [group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.11.2'], - junitPlatformEngine : [group: 'org.junit.platform', name: 'junit-platform-engine', version: '1.11.2'], - hamcrest : [group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'], - junit_dataprovider : [group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.11.0'], - mockito : [group: 'org.mockito', name: 'mockito-core', version: '4.11.0'], // mockito 5 requires Java 11 - mockito_junit5 : [group: 'org.mockito', name: 'mockito-junit-jupiter', version: '4.6.1'], - assertj : [group: 'org.assertj', name: 'assertj-core', version: '3.27.3'], - assertj_guava : [group: 'org.assertj', name: 'assertj-guava', version: '3.27.3'], + junit4 : [group: 'junit', name: 'junit', version: '4.13.2'], + junit5Jupiter : [group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.12.2'], + junit5VintageEngine : [group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.12.2'], + junitPlatform : [group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.12.2'], + junitPlatformCommons : [group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.12.2'], + junitPlatformEngine : [group: 'org.junit.platform', name: 'junit-platform-engine', version: '1.12.2'], + junitPlatformLauncher: [group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.12.2'], + hamcrest : [group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'], + junit_dataprovider : [group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.11.0'], + mockito : [group: 'org.mockito', name: 'mockito-core', version: '4.11.0'], // mockito 5 requires Java 11 + mockito_junit5 : [group: 'org.mockito', name: 'mockito-junit-jupiter', version: '4.6.1'], + assertj : [group: 'org.assertj', name: 'assertj-core', version: '3.27.3'], + assertj_guava : [group: 'org.assertj', name: 'assertj-guava', version: '3.27.3'], // Dependencies for example projects / tests - javaxAnnotationApi : [group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'], - springBeans : [group: 'org.springframework', name: 'spring-beans', version: '5.3.23'], - springBootLoader : [group: 'org.springframework.boot', name: 'spring-boot-loader', version: '2.7.13'], - jakartaInject : [group: 'jakarta.inject', name: 'jakarta.inject-api', version: '2.0.1'], - jakartaAnnotations : [group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: '2.1.1'], - guice : [group: 'com.google.inject', name: 'guice', version: '5.1.0'], + javaxAnnotationApi : [group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'], + springBeans : [group: 'org.springframework', name: 'spring-beans', version: '5.3.23'], + springBootLoader : [group: 'org.springframework.boot', name: 'spring-boot-loader', version: '2.7.13'], + jakartaInject : [group: 'jakarta.inject', name: 'jakarta.inject-api', version: '2.0.1'], + jakartaAnnotations : [group: 'jakarta.annotation', name: 'jakarta.annotation-api', version: '2.1.1'], + guice : [group: 'com.google.inject', name: 'guice', version: '5.1.0'], // NOTE: The pure javaee-api dependencies are crippled, so to run any test we need to choose a full implementation provider - geronimoEjb : [group: 'org.apache.geronimo.specs', name: 'geronimo-ejb_3.1_spec', version: '1.0.2'], - geronimoJpa : [group: 'org.apache.geronimo.specs', name: 'geronimo-jpa_2.0_spec', version: '1.1'], - jodaTime : [group: 'joda-time', name: 'joda-time', version: '2.12.7'], - joox : [group: 'org.jooq', name: 'joox-java-6', version: '1.6.0'] + geronimoEjb : [group: 'org.apache.geronimo.specs', name: 'geronimo-ejb_3.1_spec', version: '1.0.2'], + geronimoJpa : [group: 'org.apache.geronimo.specs', name: 'geronimo-jpa_2.0_spec', version: '1.1'], + jodaTime : [group: 'joda-time', name: 'joda-time', version: '2.12.7'], + joox : [group: 'org.jooq', name: 'joox-java-6', version: '1.6.0'] ] minSupportedJavaVersion = JavaVersion.VERSION_1_8 diff --git a/buildSrc/src/main/groovy/archunit.java-testing-conventions.gradle b/buildSrc/src/main/groovy/archunit.java-testing-conventions.gradle index e3a8319ff1..fc1ed312d2 100644 --- a/buildSrc/src/main/groovy/archunit.java-testing-conventions.gradle +++ b/buildSrc/src/main/groovy/archunit.java-testing-conventions.gradle @@ -12,6 +12,7 @@ dependencies { testImplementation dependency.junit5Jupiter testRuntimeOnly dependency.junit5VintageEngine + testRuntimeOnly dependency.junitPlatformLauncher testRuntimeOnly dependency.log4j_slf4j } diff --git a/buildSrc/src/main/resources/release_check/archunit-junit5-engine-api.pom b/buildSrc/src/main/resources/release_check/archunit-junit5-engine-api.pom index 30f57e3b93..0cf590cb89 100644 --- a/buildSrc/src/main/resources/release_check/archunit-junit5-engine-api.pom +++ b/buildSrc/src/main/resources/release_check/archunit-junit5-engine-api.pom @@ -46,7 +46,7 @@ org.junit.platform junit-platform-engine - 1.11.2 + 1.12.2 compile From 7739b0b5962015e2eaa8effe8f610a743ebaaaa3 Mon Sep 17 00:00:00 2001 From: Manfred Hanke Date: Sat, 12 Apr 2025 22:18:46 +0200 Subject: [PATCH 6/6] Ignore sun packages when importing full classpath resolves #1446 The CI build has recently often failed on `ubuntu` and `macos` with Java 8, due to `java.lang.OutOfMemoryError: GC overhead limit exceeded`. This is due to `ClassFileImporterSlowTest` importing the full classpath in some tests, which gives more than 20k classes on Java 8, which contains 7k classes in `com.sun` and 4k classes in `sun` packages that can easily be ignored. Signed-off-by: Manfred Hanke --- .../importer/ClassFileImporterSlowTest.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/archunit/src/test/java/com/tngtech/archunit/core/importer/ClassFileImporterSlowTest.java b/archunit/src/test/java/com/tngtech/archunit/core/importer/ClassFileImporterSlowTest.java index c449bc3b01..3285b03938 100644 --- a/archunit/src/test/java/com/tngtech/archunit/core/importer/ClassFileImporterSlowTest.java +++ b/archunit/src/test/java/com/tngtech/archunit/core/importer/ClassFileImporterSlowTest.java @@ -179,18 +179,19 @@ public void creates_JavaPackages() { } private JavaClasses importJavaBase() { - return new ClassFileImporter() - .withImportOption(location -> - // before Java 9 packages like java.lang were in rt.jar - location.contains("rt.jar") || - // from Java 9 on those packages were in a JRT with name 'java.base' - (location.asURI().getScheme().equals("jrt") && location.contains("java.base")) - ) - .importClasspath(); + return new ClassFileImporter().withImportOption(location -> !isSunPackage(location) && ( + // before Java 9 packages like java.lang were in rt.jar; + location.contains("rt.jar") || + // from Java 9 on those packages were in a JRT with name 'java.base' + (location.asURI().getScheme().equals("jrt") && location.contains("java.base")) + )).importClasspath(); } private ImportOption importJavaBaseOrRtAndJUnitJarAndFilesOnTheClasspath() { return location -> { + if (isSunPackage(location)) { + return false; + } if (!location.isArchive()) { return true; } @@ -200,4 +201,13 @@ private ImportOption importJavaBaseOrRtAndJUnitJarAndFilesOnTheClasspath() { return location.asURI().getScheme().equals("jrt") && location.contains("java.base"); }; } + + /** + * Importing the full classpath may give thousands of classes in {@link sun} and (especially for Java 8) {@link com.sun} packages. + * Importing those would increase the memory footprint tremendously, but not give an additional benefit for the test, + * so it is convenient to ignore those. + */ + private static boolean isSunPackage(Location location) { + return location.contains("/sun/"); + } }