Skip to content

Commit 9afdba7

Browse files
sreenath-tmsnicoll
authored andcommitted
Adapt FieldHint to recent GraalVM versions
In recent GraalVM versions, allowWrite and allowUnsafeAccess have been deprecated and are no longer use. This commit updates FieldHint to remove the irrelevant properties. See spring-projectsgh-29130
1 parent 7642ac8 commit 9afdba7

File tree

2 files changed

+7
-173
lines changed

2 files changed

+7
-173
lines changed

spring-core/src/main/java/org/springframework/aot/hint/FieldHint.java

Lines changed: 0 additions & 144 deletions
This file was deleted.

spring-core/src/main/java/org/springframework/aot/hint/TypeHint.java

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public final class TypeHint implements ConditionalHint {
4444
@Nullable
4545
private final TypeReference reachableType;
4646

47-
private final Set<FieldHint> fields;
47+
private final Set<String> fields;
4848

4949
private final Set<ExecutableHint> constructors;
5050

@@ -57,7 +57,7 @@ private TypeHint(Builder builder) {
5757
this.type = builder.type;
5858
this.reachableType = builder.reachableType;
5959
this.memberCategories = Set.copyOf(builder.memberCategories);
60-
this.fields = builder.fields.values().stream().map(FieldHint.Builder::build).collect(Collectors.toSet());
60+
this.fields = builder.fields;
6161
this.constructors = builder.constructors.values().stream().map(ExecutableHint.Builder::build).collect(Collectors.toSet());
6262
this.methods = builder.methods.values().stream().map(ExecutableHint.Builder::build).collect(Collectors.toSet());
6363
}
@@ -89,10 +89,10 @@ public TypeReference getReachableType() {
8989

9090
/**
9191
* Return the fields that require reflection.
92-
* @return a stream of {@link FieldHint}
92+
* @return a stream of Strings
9393
*/
94-
public Stream<FieldHint> fields() {
95-
return this.fields.stream();
94+
public Set<String> fields() {
95+
return this.fields;
9696
}
9797

9898
/**
@@ -147,7 +147,7 @@ public static class Builder {
147147
@Nullable
148148
private TypeReference reachableType;
149149

150-
private final Map<String, FieldHint.Builder> fields = new HashMap<>();
150+
private final Set<String> fields = new HashSet<>();
151151

152152
private final Map<ExecutableKey, ExecutableHint.Builder> constructors = new HashMap<>();
153153

@@ -191,31 +191,9 @@ public Builder onReachableType(Class<?> reachableType) {
191191
* @return {@code this}, to facilitate method chaining
192192
*/
193193
public Builder withField(String name) {
194-
return withField(name, FieldMode.WRITE);
194+
return withField(name);
195195
}
196196

197-
/**
198-
* Register the need for reflection on the field with the specified name
199-
* using the specified {@link FieldMode}.
200-
* @param name the name of the field
201-
* @param mode the requested mode
202-
* @return {@code this}, to facilitate method chaining
203-
*/
204-
public Builder withField(String name, FieldMode mode) {
205-
return withField(name, FieldHint.builtWith(mode));
206-
}
207-
208-
/**
209-
* Register the need for reflection on the field with the specified name.
210-
* @param name the name of the field
211-
* @param fieldHint a builder to further customize the hints of this field
212-
* @return {@code this}, to facilitate method chaining
213-
*/
214-
public Builder withField(String name, Consumer<FieldHint.Builder> fieldHint) {
215-
FieldHint.Builder builder = this.fields.computeIfAbsent(name, FieldHint.Builder::new);
216-
fieldHint.accept(builder);
217-
return this;
218-
}
219197

220198
/**
221199
* Register the need for reflection on the constructor with the specified

0 commit comments

Comments
 (0)