Update runtime hints predicates after GraalVM changes
As of gh-33847, method and field introspection is included by default when a type is registered for reflection. Many methods in ReflectionHintsPredicates are now mostly useless as their default behavior checks for introspection. This commit deprecates those methods and promotes instead invocation variants. During the upgrade, developers should replace it for an `onType` check if only reflection is required. If they were checking for invocation, they should use the new 'onXInvocation` method. Closes gh-34239
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2025 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.
|
||||
@@ -53,7 +53,7 @@ class ProblemDetailRuntimeHintsTests {
|
||||
void getterMethodsShouldHaveReflectionHints() {
|
||||
for (String methodName : METHOD_NAMES) {
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onMethod(ProblemDetail.class, methodName)).accepts(this.hints);
|
||||
.onMethodInvocation(ProblemDetail.class, methodName)).accepts(this.hints);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class ProblemDetailRuntimeHintsTests {
|
||||
void mixinShouldHaveReflectionHints() {
|
||||
for (String methodName : METHOD_NAMES) {
|
||||
assertThat(RuntimeHintsPredicates.reflection()
|
||||
.onMethod(ProblemDetailJacksonXmlMixin.class, methodName)).accepts(this.hints);
|
||||
.onMethodInvocation(ProblemDetailJacksonXmlMixin.class, methodName)).accepts(this.hints);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2025 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.
|
||||
@@ -43,10 +43,10 @@ class HttpExchangeReflectiveProcessorTests {
|
||||
Method method = SampleService.class.getDeclaredMethod("get");
|
||||
processor.registerReflectionHints(hints.reflection(), method);
|
||||
assertThat(reflection().onType(SampleService.class)).accepts(hints);
|
||||
assertThat(reflection().onMethod(SampleService.class, "get")).accepts(hints);
|
||||
assertThat(reflection().onMethodInvocation(SampleService.class, "get")).accepts(hints);
|
||||
assertThat(reflection().onType(Response.class)).accepts(hints);
|
||||
assertThat(reflection().onMethod(Response.class, "getMessage")).accepts(hints);
|
||||
assertThat(reflection().onMethod(Response.class, "setMessage")).accepts(hints);
|
||||
assertThat(reflection().onMethodInvocation(Response.class, "getMessage")).accepts(hints);
|
||||
assertThat(reflection().onMethodInvocation(Response.class, "setMessage")).accepts(hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -54,10 +54,10 @@ class HttpExchangeReflectiveProcessorTests {
|
||||
Method method = SampleService.class.getDeclaredMethod("post", Request.class);
|
||||
processor.registerReflectionHints(hints.reflection(), method);
|
||||
assertThat(reflection().onType(SampleService.class)).accepts(hints);
|
||||
assertThat(reflection().onMethod(SampleService.class, "post")).accepts(hints);
|
||||
assertThat(reflection().onMethodInvocation(SampleService.class, "post")).accepts(hints);
|
||||
assertThat(reflection().onType(Request.class)).accepts(hints);
|
||||
assertThat(reflection().onMethod(Request.class, "getMessage")).accepts(hints);
|
||||
assertThat(reflection().onMethod(Request.class, "setMessage")).accepts(hints);
|
||||
assertThat(reflection().onMethodInvocation(Request.class, "getMessage")).accepts(hints);
|
||||
assertThat(reflection().onMethodInvocation(Request.class, "setMessage")).accepts(hints);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user