Skip to content

Commit c1d25ff

Browse files
authored
Merge pull request #4521 from graphql-java/codex/java17-minimum-runtime
Raise the minimum supported Java version to 17
2 parents a243ba5 + 5409832 commit c1d25ff

10 files changed

Lines changed: 41 additions & 130 deletions

File tree

‎.github/workflows/master.yml‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ jobs:
1414
include:
1515
- gradle-argument: 'assemble && ./gradlew check -x test -x testng'
1616
label: 'check'
17-
- gradle-argument: 'testWithJava11 testngWithJava11'
18-
label: 'java11'
19-
test-results-dirs: 'testWithJava11 testngWithJava11'
2017
- gradle-argument: 'testWithJava17 testngWithJava17'
2118
label: 'java17'
2219
test-results-dirs: 'testWithJava17 testngWithJava17'
@@ -125,7 +122,7 @@ jobs:
125122
const path = require('path');
126123
const { parseJacocoXml } = require('./.github/scripts/parse-jacoco.js');
127124
128-
const versions = ['java11', 'java17', 'java21', 'java25', 'jcstress'];
125+
const versions = ['java17', 'java21', 'java25', 'jcstress'];
129126
const zeroTest = { total: 0, passed: 0, failed: 0, errors: 0, skipped: 0 };
130127
131128
// Read current baseline
@@ -136,13 +133,14 @@ jobs:
136133
}
137134
138135
// Update test stats from artifacts
139-
const tests = baseline.tests || {};
136+
const previousTests = baseline.tests || {};
137+
const tests = {};
140138
for (const v of versions) {
141139
const file = path.join('test-stats', `${v}.json`);
142140
if (fs.existsSync(file)) {
143141
tests[v] = JSON.parse(fs.readFileSync(file, 'utf8'));
144142
} else {
145-
tests[v] = tests[v] || zeroTest;
143+
tests[v] = previousTests[v] || zeroTest;
146144
}
147145
}
148146

‎.github/workflows/pr-report.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
6767
const { parseJacocoXml, pct, zeroCov, isRegression } = require('./.github/scripts/parse-jacoco.js');
6868
69-
const versions = ['java11', 'java17', 'java21', 'java25', 'jcstress'];
69+
const versions = ['java17', 'java21', 'java25', 'jcstress'];
7070
const zeroTest = { total: 0, passed: 0, failed: 0, errors: 0, skipped: 0 };
7171
7272
// --- Read current test stats from artifacts ---

‎.github/workflows/pull_request.yml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ jobs:
2222
include:
2323
- gradle-argument: 'assemble && ./gradlew check -x test -x testng'
2424
label: 'check'
25-
- gradle-argument: 'testWithJava11 testngWithJava11'
26-
label: 'java11'
27-
test-results-dirs: 'testWithJava11 testngWithJava11'
2825
- gradle-argument: 'testWithJava17 testngWithJava17'
2926
label: 'java17'
3027
test-results-dirs: 'testWithJava17 testngWithJava17'

‎AGENTS.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
./gradlew test
1919
```
2020

21-
This runs tests on Java 25 only. Other JVM versions (11, 17, 21) require explicit tasks (e.g. `testWithJava11`).
21+
The library requires Java 17 or later; the build toolchain uses Java 25.
22+
This runs tests on Java 25 only. Other supported JVM versions (17, 21) require explicit tasks (e.g. `testWithJava17`).

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Discuss and ask questions in our Discussions: https://github.com/graphql-java/gr
44

55
This is a [GraphQL](https://github.com/graphql/graphql-spec) Java implementation.
66

7+
The current development version requires **Java 17 or later** to run. The Gradle build uses a JDK 25 toolchain.
8+
79
Latest build in Maven central: https://repo1.maven.org/maven2/com/graphql-java/graphql-java/
810

911
[![Build](https://github.com/graphql-java/graphql-java/actions/workflows/master.yml/badge.svg)](https://github.com/graphql-java/graphql-java/actions/workflows/master.yml)

‎README.zh_cn.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
该组件是 [GraphQL 规范](https://github.com/graphql/graphql-spec) 的 Java 实现。
66

7+
当前开发版本需要 **Java 17 或更高版本**才能运行。Gradle 构建使用 JDK 25 工具链。
8+
79
[![Build](https://github.com/graphql-java/graphql-java/actions/workflows/master.yml/badge.svg)](https://github.com/graphql-java/graphql-java/actions/workflows/master.yml)
810
[![Latest Release](https://img.shields.io/maven-central/v/com.graphql-java/graphql-java?versionPrefix=24.)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/graphql-java/)
911
[![Latest Snapshot](https://img.shields.io/maven-central/v/com.graphql-java/graphql-java?label=maven-central%20snapshot&versionPrefix=0)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/graphql-java/)

‎build.gradle‎

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ plugins {
3737

3838
java {
3939
toolchain {
40-
languageVersion = JavaLanguageVersion.of(25) // build on 25 - release on 11
40+
languageVersion = JavaLanguageVersion.of(25) // build on 25 - release on 17
4141
}
4242
}
4343

4444
kotlin {
4545
compilerOptions {
4646
apiVersion = KotlinVersion.KOTLIN_2_0
4747
languageVersion = KotlinVersion.KOTLIN_2_0
48-
jvmTarget = JvmTarget.JVM_11
48+
jvmTarget = JvmTarget.JVM_17
4949
javaParameters = true
5050
freeCompilerArgs = [
5151
'-Xemit-jvm-type-annotations',
@@ -568,7 +568,7 @@ def verifyShadedClassAnnotations = tasks.register('verifyShadedClassAnnotations'
568568
}
569569

570570
/**
571-
* Compiles a small Java 11 consumer against only the completed shaded JAR.
571+
* Compiles a small Java 17 consumer against only the completed shaded JAR.
572572
* Resolving {@code ExecutionContext.getOperationDirectives()} forces javac to
573573
* inspect the shaded ImmutableList signature; {@code -Xlint:classfile -Werror}
574574
* turns dangling annotation references into a build failure.
@@ -583,7 +583,7 @@ def compileShadedJarConsumer = tasks.register('compileShadedJarConsumer', JavaCo
583583
}
584584
classpath = files(buildFinalJar.flatMap { it.archiveFile })
585585
destinationDirectory = layout.buildDirectory.dir('classes/shaded-jar-consumer')
586-
options.release = 11
586+
options.release = 17
587587
options.compilerArgs.addAll(['-Xlint:classfile', '-Werror'])
588588
}
589589

@@ -695,13 +695,13 @@ tasks.withType(GroovyCompile) {
695695
// Options when compiling Java using the Groovy plugin.
696696
// (Groovy itself defaults to UTF-8 for Groovy code)
697697
options.encoding = 'UTF-8'
698-
sourceCompatibility = '11'
699-
targetCompatibility = '11'
698+
sourceCompatibility = '17'
699+
targetCompatibility = '17'
700700
groovyOptions.forkOptions.memoryMaximumSize = "4g"
701701
}
702702

703703
tasks.withType(JavaCompile) {
704-
options.release = 11
704+
options.release = 17
705705
options.errorprone {
706706
disableAllChecks = true
707707
check("NullAway", CheckSeverity.ERROR)
@@ -812,21 +812,7 @@ tasks.register('testWithJava17', Test) {
812812

813813
}
814814

815-
tasks.register('testWithJava11', Test) {
816-
javaLauncher = javaToolchains.launcherFor {
817-
languageVersion = JavaLanguageVersion.of(11)
818-
}
819-
testClassesDirs = sourceSets.test.output.classesDirs
820-
classpath = sourceSets.test.runtimeClasspath
821-
822-
dependsOn tasks.named('testClasses')
823-
824-
classpath += sourceSets.jmh.output
825-
dependsOn "jmhClasses"
826-
827-
}
828-
829-
['11', '17', '21'].each { ver ->
815+
['17', '21'].each { ver ->
830816
tasks.register("testngWithJava${ver}", Test) {
831817
useTestNG()
832818
javaLauncher = javaToolchains.launcherFor {

‎src/test/groovy/graphql/ExecutionInputTest.groovy‎

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package graphql
22

33
import graphql.execution.ExecutionId
4+
import graphql.execution.instrumentation.ExecuteObjectInstrumentationContext
45
import graphql.execution.instrumentation.ExecutionStrategyInstrumentationContext
56
import graphql.execution.instrumentation.Instrumentation
67
import graphql.execution.instrumentation.InstrumentationContext
78
import graphql.execution.instrumentation.InstrumentationState
9+
import graphql.execution.instrumentation.SimplePerformantInstrumentation
810
import graphql.execution.instrumentation.parameters.InstrumentationExecutionStrategyParameters
911
import graphql.execution.instrumentation.parameters.InstrumentationFieldCompleteParameters
1012
import graphql.execution.instrumentation.parameters.InstrumentationFieldParameters
@@ -768,10 +770,7 @@ class ExecutionInputTest extends Specification {
768770
}
769771
770772
def "without capturePartialResultsOnCancel a late cancel discards even fully gathered nested data"() {
771-
// capture is OFF, so there is no cancellation race; the top-level 'outer' field value info
772-
// completes quickly while its nested 'value' is still resolving. Cancelling at that point and
773-
// then letting 'value' finish means the field values are fully gathered, but because capture
774-
// is disabled the gathered data must be discarded and only the cancel error returned.
773+
given:
775774
def sdl = '''
776775
type Query {
777776
outer : Inner
@@ -780,44 +779,31 @@ class ExecutionInputTest extends Specification {
780779
value : String
781780
}
782781
'''
783-
784-
CountDownLatch valueStarted = new CountDownLatch(1)
785-
CountDownLatch valueRelease = new CountDownLatch(1)
786-
782+
def valueResult = new CompletableFuture<String>()
787783
DataFetcher outerDf = { DataFetchingEnvironment env -> [:] }
788-
DataFetcher valueDf = { DataFetchingEnvironment env ->
789-
return CompletableFuture.supplyAsync {
790-
valueStarted.countDown()
791-
valueRelease.await()
792-
return "value"
793-
}
794-
}
784+
DataFetcher valueDf = { DataFetchingEnvironment env -> valueResult }
785+
def schema = TestUtil.schema(sdl, ["Query": ["outer": outerDf], "Inner": ["value": valueDf]])
786+
def executionInput = ExecutionInput.newExecutionInput("{ outer { value } }").build()
795787
796-
def fetcherMap = ["Query": ["outer": outerDf], "Inner": ["value": valueDf]]
797-
def schema = TestUtil.schema(sdl, fetcherMap)
798-
def graphQL = GraphQL.newGraphQL(schema).build()
788+
// Cancel after the nested values have been gathered, before the object result is assembled.
789+
def objectInstrumentation = Stub(ExecuteObjectInstrumentationContext) {
790+
onFieldValuesInfo(_) >> { executionInput.cancel() }
791+
}
792+
def instrumentation = Spy(SimplePerformantInstrumentation) {
793+
beginExecuteObject(_, _) >> objectInstrumentation
794+
}
795+
def graphQL = GraphQL.newGraphQL(schema).instrumentation(instrumentation).build()
799796
800797
when:
801-
ExecutionInput executionInput = ExecutionInput.newExecutionInput()
802-
.query("{ outer { value } }")
803-
.build() // capturePartialResultsOnCancel NOT enabled
804-
805798
def cf = graphQL.executeAsync(executionInput)
806-
807-
// the nested value DF has started, so 'outer' field value info is already done
808-
valueStarted.await()
809-
// cancel while the nested value is still resolving, then let it finish
810-
executionInput.cancel()
811-
valueRelease.countDown()
812-
799+
valueResult.complete("value")
813800
await().atMost(Duration.ofSeconds(10)).until({ -> cf.isDone() })
814801
def er = cf.join()
815802
816803
then:
817804
!cf.isCompletedExceptionally()
818805
!er.errors.isEmpty()
819806
er.errors[0]["message"] == "Execution has been asked to be cancelled"
820-
// capture disabled - even though the data was fully gathered, it is discarded
821807
er.data == null
822808
}
823809

‎src/test/groovy/graphql/schema/fetching/LambdaFetchingSupportTest.groovy‎

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
package graphql.schema.fetching
22

3-
import graphql.Scalars
4-
import graphql.schema.GraphQLFieldDefinition
5-
import graphql.schema.PropertyDataFetcher
6-
import graphql.util.javac.DynamicJavacSupport
7-
import spock.lang.IgnoreIf
83
import spock.lang.Specification
94

105
class LambdaFetchingSupportTest extends Specification {
@@ -165,53 +160,4 @@ class LambdaFetchingSupportTest extends Specification {
165160
!getter.isPresent()
166161
}
167162

168-
GraphQLFieldDefinition fld(String fldName) {
169-
return GraphQLFieldDefinition.newFieldDefinition().name(fldName).type(Scalars.GraphQLString).build()
170-
}
171-
172-
@IgnoreIf({ System.getProperty("java.version").split('\\.')[0] as Integer > 11 })
173-
def "different class loaders induce certain behaviours"() {
174-
String sourceCode = '''
175-
package com.dynamic;
176-
public class TestClass {
177-
public String hello() {
178-
return "world";
179-
}
180-
}
181-
'''
182-
183-
def customClass = new DynamicJavacSupport(null).compile("com.dynamic.TestClass", sourceCode)
184-
def targetObject = customClass.getDeclaredConstructor().newInstance()
185-
186-
// show that the graphql-java classes cant access this custom loaded class
187-
when:
188-
LambdaFetchingSupport.class.getClassLoader().loadClass("com.dynamic.TestClass")
189-
then:
190-
thrown(ClassNotFoundException)
191-
192-
// show that reflection works
193-
when:
194-
def helloMethod = targetObject.getClass().getMethod("hello")
195-
def reflectedValue = helloMethod.invoke(targetObject)
196-
then:
197-
reflectedValue == "world"
198-
199-
// without MethodHandles.privateLookupIn this will fail crossing class loaders in Java 8
200-
// if we change to privateLookupIn - then this will start working and this test will need to be changed
201-
when:
202-
def getter = LambdaFetchingSupport.createGetter(customClass, "hello")
203-
then:
204-
205-
// with Java 9+ we can get access to methods across class loaders
206-
getter.isPresent()
207-
def value = getter.get().apply(targetObject)
208-
value == "world"
209-
210-
// show that a DF can be used
211-
when:
212-
def ageDF = PropertyDataFetcher.fetching("hello")
213-
value = ageDF.get(fld("hello"), targetObject, { -> null })
214-
then:
215-
value == "world"
216-
}
217163
}

‎test-baseline.json‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
11
{
22
"tests": {
3-
"java11": {
4-
"total": 6178,
5-
"passed": 6122,
6-
"failed": 0,
7-
"errors": 0,
8-
"skipped": 56
9-
},
103
"java17": {
11-
"total": 6178,
4+
"total": 6177,
125
"passed": 6121,
136
"failed": 0,
147
"errors": 0,
15-
"skipped": 57
8+
"skipped": 56
169
},
1710
"java21": {
18-
"total": 6178,
11+
"total": 6177,
1912
"passed": 6121,
2013
"failed": 0,
2114
"errors": 0,
22-
"skipped": 57
15+
"skipped": 56
2316
},
2417
"java25": {
25-
"total": 6178,
18+
"total": 6177,
2619
"passed": 6121,
2720
"failed": 0,
2821
"errors": 0,
29-
"skipped": 57
22+
"skipped": 56
3023
},
3124
"jcstress": {
3225
"total": 32,

0 commit comments

Comments
 (0)