Switch serializable flag to primitive boolean

This commit improves the change made to TypeHint to use a primitive
boolean for the serializable flag.

See gh-36379
This commit is contained in:
Stéphane Nicoll
2026-03-05 11:23:51 +01:00
parent 50c29e64f8
commit 03391dfa94
6 changed files with 64 additions and 46 deletions
@@ -84,11 +84,11 @@ class ProxyHintsTests {
void registerJdkProxyWithJavaSerialization() {
this.proxyHints.registerJdkProxy(hint -> {
hint.proxiedInterfaces(TypeReference.of("com.example.Test"));
hint.javaSerialization(true);
hint.withJavaSerialization(true);
});
assertThat(this.proxyHints.jdkProxyHints()).singleElement().satisfies(hint -> {
assertThat(hint.getProxiedInterfaces()).containsExactly(TypeReference.of("com.example.Test"));
assertThat(hint.getSerializable()).isTrue();
assertThat(hint.hasJavaSerialization()).isTrue();
});
}
@@ -208,7 +208,7 @@ class RuntimeHintsWriterTests {
}
@Test
void serializationEnabled() throws JSONException {
void javaSerializationEnabled() throws JSONException {
RuntimeHints hints = new RuntimeHints();
hints.reflection().registerType(Integer.class, builder -> builder.withJavaSerialization(true));
@@ -224,6 +224,22 @@ class RuntimeHintsWriterTests {
""", hints);
}
@Test
void javaSerializationDisabled() throws JSONException {
RuntimeHints hints = new RuntimeHints();
hints.reflection().registerType(Integer.class, builder -> builder.withJavaSerialization(false));
assertEquals("""
{
"reflection": [
{
"type": "java.lang.Integer"
}
]
}
""", hints);
}
@Test
void ignoreLambda() throws JSONException {
Runnable anonymousRunnable = () -> {};
@@ -658,11 +674,11 @@ class RuntimeHintsWriterTests {
}
@Test
void shouldWriteSerialization() throws JSONException {
void shouldWriteSerializable() throws JSONException {
RuntimeHints hints = new RuntimeHints();
hints.proxies().registerJdkProxy(hint -> {
hint.proxiedInterfaces(Function.class);
hint.javaSerialization(true);
hint.withJavaSerialization(true);
});
assertEquals("""
{