Skip to content

Commit 3f2f013

Browse files
christophstroblmp911de
authored andcommitted
Add missing runtime hit for Unpaged required by PageModule.
The PageModule is loading the Unpaged type via its name which requires additional reflection configuration for native images. Closes: #3025 Original pull request: #3026
1 parent 391ef3e commit 3f2f013

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.web.aot.hint;
17+
18+
import org.springframework.aot.hint.RuntimeHints;
19+
import org.springframework.aot.hint.RuntimeHintsRegistrar;
20+
import org.springframework.aot.hint.TypeReference;
21+
import org.springframework.data.web.config.SpringDataJacksonConfiguration.PageModule;
22+
import org.springframework.lang.Nullable;
23+
24+
/**
25+
* @author Christoph Strobl
26+
* @since 3.2.3
27+
*/
28+
public class WebRuntimeHints implements RuntimeHintsRegistrar {
29+
30+
@Override
31+
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
32+
33+
hints.reflection().registerType(TypeReference.of("org.springframework.data.domain.Unpaged"), hint -> {
34+
hint.onReachableType(PageModule.class);
35+
});
36+
}
37+
}

Diff for: src/main/resources/META-INF/spring/aot.factories

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor=\
33

44
org.springframework.aot.hint.RuntimeHintsRegistrar=\
55
org.springframework.data.repository.aot.hint.RepositoryRuntimeHints,\
6-
org.springframework.data.querydsl.aot.QuerydslHints
6+
org.springframework.data.querydsl.aot.QuerydslHints,\
7+
org.springframework.data.web.aot.hint.WebRuntimeHints
78

89
org.springframework.beans.factory.aot.BeanRegistrationAotProcessor=\
910
org.springframework.data.aot.AuditingBeanRegistrationAotProcessor

0 commit comments

Comments
 (0)