Skip to content

Commit

Permalink
Adapt FieldHint to recent GraalVM versions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sreenath-tm authored and snicoll committed Sep 10, 2022
1 parent 70db83a commit b26c714
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 173 deletions.
144 changes: 0 additions & 144 deletions spring-core/src/main/java/org/springframework/aot/hint/FieldHint.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class TypeHint implements ConditionalHint {
@Nullable
private final TypeReference reachableType;

private final Set<FieldHint> fields;
private final Set<String> fields;

private final Set<ExecutableHint> constructors;

Expand All @@ -57,7 +57,7 @@ private TypeHint(Builder builder) {
this.type = builder.type;
this.reachableType = builder.reachableType;
this.memberCategories = Set.copyOf(builder.memberCategories);
this.fields = builder.fields.values().stream().map(FieldHint.Builder::build).collect(Collectors.toSet());
this.fields = builder.fields;
this.constructors = builder.constructors.values().stream().map(ExecutableHint.Builder::build).collect(Collectors.toSet());
this.methods = builder.methods.values().stream().map(ExecutableHint.Builder::build).collect(Collectors.toSet());
}
Expand Down Expand Up @@ -89,10 +89,10 @@ public TypeReference getReachableType() {

/**
* Return the fields that require reflection.
* @return a stream of {@link FieldHint}
* @return a stream of Strings
*/
public Stream<FieldHint> fields() {
return this.fields.stream();
public Set<String> fields() {
return this.fields;
}

/**
Expand Down Expand Up @@ -147,7 +147,7 @@ public static class Builder {
@Nullable
private TypeReference reachableType;

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

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

Expand Down Expand Up @@ -191,31 +191,9 @@ public Builder onReachableType(Class<?> reachableType) {
* @return {@code this}, to facilitate method chaining
*/
public Builder withField(String name) {
return withField(name, FieldMode.WRITE);
return withField(name);
}

/**
* Register the need for reflection on the field with the specified name
* using the specified {@link FieldMode}.
* @param name the name of the field
* @param mode the requested mode
* @return {@code this}, to facilitate method chaining
*/
public Builder withField(String name, FieldMode mode) {
return withField(name, FieldHint.builtWith(mode));
}

/**
* Register the need for reflection on the field with the specified name.
* @param name the name of the field
* @param fieldHint a builder to further customize the hints of this field
* @return {@code this}, to facilitate method chaining
*/
public Builder withField(String name, Consumer<FieldHint.Builder> fieldHint) {
FieldHint.Builder builder = this.fields.computeIfAbsent(name, FieldHint.Builder::new);
fieldHint.accept(builder);
return this;
}

/**
* Register the need for reflection on the constructor with the specified
Expand Down

0 comments on commit b26c714

Please sign in to comment.