Created
April 15, 2024 13:30
-
-
Save lptr/431575e5073804148723725ad3604e0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/platforms/core-configuration/kotlin-dsl-integ-tests/build.gradle.kts b/platforms/core-configuration/kotlin-dsl-integ-tests/build.gradle.kts | |
index e7a687bfbb3..84ffcf22781 100644 | |
--- a/platforms/core-configuration/kotlin-dsl-integ-tests/build.gradle.kts | |
+++ b/platforms/core-configuration/kotlin-dsl-integ-tests/build.gradle.kts | |
@@ -12,6 +12,7 @@ dependencies { | |
integTestImplementation(project(":core-api")) | |
integTestImplementation(project(":core")) | |
integTestImplementation(project(":model-core")) | |
+ integTestImplementation(project(":messaging")) | |
integTestImplementation(project(":internal-testing")) | |
integTestImplementation(project(":logging")) | |
integTestImplementation(project(":language-jvm")) | |
diff --git a/platforms/core-configuration/kotlin-dsl-integ-tests/src/integTest/kotlin/org/gradle/kotlin/dsl/integration/KotlinDslJvmTargetIntegrationTest.kt b/platforms/core-configuration/kotlin-dsl-integ-tests/src/integTest/kotlin/org/gradle/kotlin/dsl/integration/KotlinDslJvmTargetIntegrationTest.kt | |
index d2a61435c6f..42010f6e4b1 100644 | |
--- a/platforms/core-configuration/kotlin-dsl-integ-tests/src/integTest/kotlin/org/gradle/kotlin/dsl/integration/KotlinDslJvmTargetIntegrationTest.kt | |
+++ b/platforms/core-configuration/kotlin-dsl-integ-tests/src/integTest/kotlin/org/gradle/kotlin/dsl/integration/KotlinDslJvmTargetIntegrationTest.kt | |
@@ -18,8 +18,8 @@ package org.gradle.kotlin.dsl.integration | |
import org.gradle.api.JavaVersion | |
import org.gradle.integtests.fixtures.AvailableJavaHomes | |
-import org.gradle.internal.classanalysis.JavaClassUtil | |
import org.gradle.internal.jvm.Jvm | |
+import org.gradle.internal.serialize.JavaClassUtil | |
import org.gradle.kotlin.dsl.fixtures.AbstractKotlinIntegrationTest | |
import org.gradle.test.fixtures.file.LeaksFileHandles | |
import org.gradle.test.precondition.Requires | |
@@ -251,7 +251,7 @@ class KotlinDslJvmTargetIntegrationTest : AbstractKotlinIntegrationTest() { | |
private | |
val printScriptJavaClassFileMajorVersion = """ | |
- println("Java Class Major Version = ${'$'}{org.gradle.internal.classanalysis.JavaClassUtil.getClassMajorVersion(this::class.java)}") | |
+ println("Java Class Major Version = ${'$'}{org.gradle.internal.serialize.JavaClassUtil.getClassMajorVersion(this::class.java)}") | |
""" | |
private | |
diff --git a/platforms/core-runtime/base-services/src/main/java/org/gradle/internal/classanalysis/JavaClassUtil.java b/platforms/core-runtime/base-services/src/main/java/org/gradle/internal/classanalysis/JavaClassUtil.java | |
deleted file mode 100644 | |
index d8fdb0c37c8..00000000000 | |
--- a/platforms/core-runtime/base-services/src/main/java/org/gradle/internal/classanalysis/JavaClassUtil.java | |
+++ /dev/null | |
@@ -1,88 +0,0 @@ | |
-/* | |
- * Copyright 2023 the original author or authors. | |
- * | |
- * Licensed under the Apache License, Version 2.0 (the "License"); | |
- * you may not use this file except in compliance with the License. | |
- * You may obtain a copy of the License at | |
- * | |
- * http://www.apache.org/licenses/LICENSE-2.0 | |
- * | |
- * Unless required by applicable law or agreed to in writing, software | |
- * distributed under the License is distributed on an "AS IS" BASIS, | |
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
- * See the License for the specific language governing permissions and | |
- * limitations under the License. | |
- */ | |
- | |
-package org.gradle.internal.classanalysis; | |
- | |
-import java.io.DataInputStream; | |
-import java.io.File; | |
-import java.io.FileInputStream; | |
-import java.io.IOException; | |
-import java.io.InputStream; | |
- | |
-/** | |
- * Utility class which operates directly on Java class files. | |
- */ | |
-public class JavaClassUtil { | |
- | |
- private static final int MAGIC_BYTES = 0xCAFEBABE; | |
- | |
- private JavaClassUtil() { | |
- // Private to prevent instantiation. | |
- } | |
- | |
- /** | |
- * Get the class file major version from the provided {@code file}. | |
- * | |
- * @throws IOException If the file does not exist or is malformed. | |
- */ | |
- public static int getClassMajorVersion(File file) throws IOException { | |
- return getClassMajorVersion(new FileInputStream(file)); | |
- } | |
- | |
- /** | |
- * Get the class file major version from the provided {@code javaClass} | |
- * | |
- * @throws IOException If there is an error reading the class file contents. | |
- */ | |
- public static int getClassMajorVersion(Class<?> javaClass) throws IOException { | |
- return getClassMajorVersion(javaClass.getName(), javaClass.getClassLoader()); | |
- } | |
- | |
- /** | |
- * Get the class file major version from the class with the given {@code name} by loading it | |
- * from the provided {@code loader}. | |
- * | |
- * @return null if the class cannot be loaded. | |
- * | |
- * @throws IOException If there is an error reading the class file contents. | |
- */ | |
- public static Integer getClassMajorVersion(String name, ClassLoader loader) throws IOException { | |
- InputStream is = loader.getResourceAsStream(name.replace('.', '/') + ".class"); | |
- if (is == null) { | |
- return null; | |
- } | |
- return getClassMajorVersion(is); | |
- } | |
- | |
- /** | |
- * Get the class file major version from class file data provided by {@code is}. | |
- * This method will close the provided {@link InputStream}. | |
- * | |
- * @throws IOException If the stream contents are malformed. | |
- */ | |
- public static int getClassMajorVersion(InputStream is) throws IOException { | |
- DataInputStream data = new DataInputStream(is); | |
- try { | |
- if (MAGIC_BYTES != data.readInt()) { | |
- throw new IOException("Invalid .class file header"); | |
- } | |
- data.readUnsignedShort(); // Minor | |
- return data.readUnsignedShort(); // Major | |
- } finally { | |
- data.close(); | |
- } | |
- } | |
-} | |
diff --git a/platforms/core-runtime/base-services/src/test/groovy/org/gradle/internal/classanalysis/JavaClassUtilTest.groovy b/platforms/core-runtime/base-services/src/test/groovy/org/gradle/internal/classanalysis/JavaClassUtilTest.groovy | |
deleted file mode 100644 | |
index 6ba768c0289..00000000000 | |
--- a/platforms/core-runtime/base-services/src/test/groovy/org/gradle/internal/classanalysis/JavaClassUtilTest.groovy | |
+++ /dev/null | |
@@ -1,38 +0,0 @@ | |
-/* | |
- * Copyright 2023 the original author or authors. | |
- * | |
- * Licensed under the Apache License, Version 2.0 (the "License"); | |
- * you may not use this file except in compliance with the License. | |
- * You may obtain a copy of the License at | |
- * | |
- * http://www.apache.org/licenses/LICENSE-2.0 | |
- * | |
- * Unless required by applicable law or agreed to in writing, software | |
- * distributed under the License is distributed on an "AS IS" BASIS, | |
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
- * See the License for the specific language governing permissions and | |
- * limitations under the License. | |
- */ | |
- | |
-package org.gradle.internal.classanalysis | |
- | |
- | |
-import spock.lang.Specification | |
- | |
-class JavaClassUtilTest extends Specification { | |
- def "can extract java class file major version"() { | |
- expect: | |
- JavaClassUtil.getClassMajorVersion(JavaClassUtil.class) == 50 | |
- } | |
- | |
- def "can extract java class name major version"() { | |
- expect: | |
- JavaClassUtil.getClassMajorVersion(JavaClassUtil.class.getName(), JavaClassUtil.getClassLoader()) == 50 | |
- } | |
- | |
- def "can extract java class input stream major version"() { | |
- expect: | |
- def stream = JavaClassUtil.getClassLoader().getResourceAsStream(JavaClassUtil.getName().replace(".", "/") + ".class") | |
- JavaClassUtil.getClassMajorVersion(stream) == 50 | |
- } | |
-} | |
diff --git a/platforms/core-runtime/messaging/src/main/java/org/gradle/internal/serialize/ClassLoaderObjectInputStream.java b/platforms/core-runtime/messaging/src/main/java/org/gradle/internal/serialize/ClassLoaderObjectInputStream.java | |
index a637070837d..7a85ef18c34 100644 | |
--- a/platforms/core-runtime/messaging/src/main/java/org/gradle/internal/serialize/ClassLoaderObjectInputStream.java | |
+++ b/platforms/core-runtime/messaging/src/main/java/org/gradle/internal/serialize/ClassLoaderObjectInputStream.java | |
@@ -16,7 +16,6 @@ | |
package org.gradle.internal.serialize; | |
import org.gradle.api.JavaVersion; | |
-import org.gradle.internal.classanalysis.JavaClassUtil; | |
import java.io.IOException; | |
import java.io.InputStream; | |
diff --git a/platforms/jvm/language-java/build.gradle.kts b/platforms/jvm/language-java/build.gradle.kts | |
index 20e31648f2a..5b059dd5edf 100644 | |
--- a/platforms/jvm/language-java/build.gradle.kts | |
+++ b/platforms/jvm/language-java/build.gradle.kts | |
@@ -73,6 +73,7 @@ dependencies { | |
because("Required for SystemInfo") | |
} | |
+ integTestImplementation(projects.messaging) | |
// TODO: Make these available for all integration tests? Maybe all tests? | |
integTestImplementation(libs.jetbrainsAnnotations) | |
diff --git a/platforms/jvm/language-java/src/integTest/groovy/org/gradle/api/tasks/compile/CrossCompilationIntegrationTest.groovy b/platforms/jvm/language-java/src/integTest/groovy/org/gradle/api/tasks/compile/CrossCompilationIntegrationTest.groovy | |
index 1a391a554d2..1ebd9a3ffb4 100644 | |
--- a/platforms/jvm/language-java/src/integTest/groovy/org/gradle/api/tasks/compile/CrossCompilationIntegrationTest.groovy | |
+++ b/platforms/jvm/language-java/src/integTest/groovy/org/gradle/api/tasks/compile/CrossCompilationIntegrationTest.groovy | |
@@ -20,7 +20,7 @@ import org.gradle.api.JavaVersion | |
import org.gradle.integtests.fixtures.AbstractIntegrationSpec | |
import org.gradle.integtests.fixtures.AvailableJavaHomes | |
import org.gradle.integtests.fixtures.DefaultTestExecutionResult | |
-import org.gradle.internal.classanalysis.JavaClassUtil | |
+import org.gradle.internal.serialize.JavaClassUtil | |
import org.gradle.test.fixtures.Flaky | |
import org.gradle.test.fixtures.archive.JarTestFixture | |
import org.gradle.util.GradleVersion | |
diff --git a/platforms/jvm/plugins-java/build.gradle.kts b/platforms/jvm/plugins-java/build.gradle.kts | |
index a1d2ced0213..e59d49e2d4b 100644 | |
--- a/platforms/jvm/plugins-java/build.gradle.kts | |
+++ b/platforms/jvm/plugins-java/build.gradle.kts | |
@@ -37,6 +37,7 @@ dependencies { | |
integTestImplementation(testFixtures(project(":enterprise-operations"))) | |
integTestImplementation(testFixtures(project(":language-java"))) | |
integTestImplementation(testFixtures(project(":language-jvm"))) | |
+ integTestImplementation(testFixtures(project(":messaging"))) | |
integTestImplementation(testFixtures(project(":plugins-java-base"))) | |
integTestImplementation(testFixtures(project(":plugins-jvm-test-fixtures"))) | |
integTestImplementation(testFixtures(project(":workers"))) | |
diff --git a/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/java/JavaCrossCompilationIntegrationTest.groovy b/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/java/JavaCrossCompilationIntegrationTest.groovy | |
index 387506454f2..659e54277a3 100644 | |
--- a/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/java/JavaCrossCompilationIntegrationTest.groovy | |
+++ b/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/java/JavaCrossCompilationIntegrationTest.groovy | |
@@ -20,7 +20,7 @@ import org.gradle.api.JavaVersion | |
import org.gradle.integtests.fixtures.AbstractIntegrationSpec | |
import org.gradle.integtests.fixtures.AvailableJavaHomes | |
import org.gradle.internal.FileUtils | |
-import org.gradle.internal.classanalysis.JavaClassUtil | |
+import org.gradle.internal.serialize.JavaClassUtil | |
import org.gradle.test.fixtures.Flaky | |
import org.gradle.test.fixtures.file.DoesNotSupportNonAsciiPaths | |
import org.gradle.util.GradleVersion | |
diff --git a/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/java/compile/BasicJavaCompilerIntegrationSpec.groovy b/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/java/compile/BasicJavaCompilerIntegrationSpec.groovy | |
index 29f3391be46..9d925a6e033 100644 | |
--- a/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/java/compile/BasicJavaCompilerIntegrationSpec.groovy | |
+++ b/platforms/jvm/plugins-java/src/integTest/groovy/org/gradle/java/compile/BasicJavaCompilerIntegrationSpec.groovy | |
@@ -20,7 +20,7 @@ package org.gradle.java.compile | |
import org.gradle.api.Action | |
import org.gradle.integtests.fixtures.AbstractIntegrationSpec | |
import org.gradle.integtests.fixtures.AvailableJavaHomes | |
-import org.gradle.internal.classanalysis.JavaClassUtil | |
+import org.gradle.internal.serialize.JavaClassUtil | |
import org.gradle.test.fixtures.file.ClassFile | |
import org.gradle.test.precondition.Requires | |
import org.gradle.test.preconditions.IntegTestPreconditions | |
diff --git a/testing/architecture-test/src/changes/archunit_store/internal-api-nullability.txt b/testing/architecture-test/src/changes/archunit_store/internal-api-nullability.txt | |
index e9fd6782e3d..af41c629123 100644 | |
--- a/testing/architecture-test/src/changes/archunit_store/internal-api-nullability.txt | |
+++ b/testing/architecture-test/src/changes/archunit_store/internal-api-nullability.txt | |
@@ -1758,7 +1758,6 @@ Class <org.gradle.internal.buildoption.StringBuildOption> is not annotated (dire | |
Class <org.gradle.internal.buildoption.StringInternalOption> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (StringInternalOption.java:0) | |
Class <org.gradle.internal.cache.MonitoredCleanupAction> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (MonitoredCleanupAction.java:0) | |
Class <org.gradle.internal.classanalysis.AsmConstants> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (AsmConstants.java:0) | |
-Class <org.gradle.internal.classanalysis.JavaClassUtil> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (JavaClassUtil.java:0) | |
Class <org.gradle.internal.classpath.CachedClasspathTransformer$StandardTransform> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (CachedClasspathTransformer.java:0) | |
Class <org.gradle.internal.classpath.CachedClasspathTransformer> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (CachedClasspathTransformer.java:0) | |
Class <org.gradle.internal.classpath.ClassData> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (ClassData.java:0) | |
@@ -2727,6 +2726,8 @@ Class <org.gradle.internal.serialize.BaseSerializerFactory$StringMapSerializer> | |
Class <org.gradle.internal.serialize.BaseSerializerFactory$StringSerializer> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (BaseSerializerFactory.java:0) | |
Class <org.gradle.internal.serialize.BaseSerializerFactory$ThrowableSerializer> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (BaseSerializerFactory.java:0) | |
Class <org.gradle.internal.serialize.BaseSerializerFactory> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (BaseSerializerFactory.java:0) | |
+Class <org.gradle.internal.serialize.ClassLoaderObjectInputStream$UnsupportedClassVersionErrorWithJavaVersion> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (ClassLoaderObjectInputStream.java:0) | |
+Class <org.gradle.internal.serialize.ClassLoaderObjectInputStream> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (ClassLoaderObjectInputStream.java:0) | |
Class <org.gradle.internal.serialize.ContextualPlaceholderException> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (ContextualPlaceholderException.java:0) | |
Class <org.gradle.internal.serialize.Decoder$DecodeAction> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (Decoder.java:0) | |
Class <org.gradle.internal.serialize.Decoder> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (Decoder.java:0) | |
@@ -2760,6 +2761,7 @@ Class <org.gradle.internal.serialize.HierarchicalNameSerializer> is not annotate | |
Class <org.gradle.internal.serialize.InputStreamBackedDecoder> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (InputStreamBackedDecoder.java:0) | |
Class <org.gradle.internal.serialize.IntSetSerializer> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (IntSetSerializer.java:0) | |
Class <org.gradle.internal.serialize.InterningStringSerializer> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (InterningStringSerializer.java:0) | |
+Class <org.gradle.internal.serialize.JavaClassUtil> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (JavaClassUtil.java:0) | |
Class <org.gradle.internal.serialize.ListSerializer> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (ListSerializer.java:0) | |
Class <org.gradle.internal.serialize.MapSerializer> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (MapSerializer.java:0) | |
Class <org.gradle.internal.serialize.Message> is not annotated (directly or via its package) with @org.gradle.api.NonNullApi in (Message.java:0) | |
diff --git a/testing/internal-testing/build.gradle.kts b/testing/internal-testing/build.gradle.kts | |
index 6ab7fe9ba39..90215aadbf7 100644 | |
--- a/testing/internal-testing/build.gradle.kts | |
+++ b/testing/internal-testing/build.gradle.kts | |
@@ -12,6 +12,7 @@ sourceSets { | |
} | |
dependencies { | |
+ implementation(projects.messaging) | |
implementation(project(":base-services")) | |
implementation(project(":functional")) | |
implementation(project(":native")) | |
diff --git a/testing/internal-testing/src/main/groovy/org/gradle/test/fixtures/archive/JarTestFixture.groovy b/testing/internal-testing/src/main/groovy/org/gradle/test/fixtures/archive/JarTestFixture.groovy | |
index 59e89576e40..2f81626de14 100644 | |
--- a/testing/internal-testing/src/main/groovy/org/gradle/test/fixtures/archive/JarTestFixture.groovy | |
+++ b/testing/internal-testing/src/main/groovy/org/gradle/test/fixtures/archive/JarTestFixture.groovy | |
@@ -19,8 +19,8 @@ package org.gradle.test.fixtures.archive | |
import org.apache.commons.compress.archivers.zip.ZipFile | |
import org.apache.commons.io.IOUtils | |
import org.gradle.api.JavaVersion | |
-import org.gradle.internal.classanalysis.JavaClassUtil | |
import org.gradle.internal.lazy.Lazy | |
+import org.gradle.internal.serialize.JavaClassUtil | |
import java.util.jar.JarEntry | |
import java.util.jar.JarFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment