Prevent duplicated logs in ConstantFieldSubstitutionProcessor

See gh-28624
This commit is contained in:
Sébastien Deleuze 2022-06-27 19:01:48 +02:00
parent f8508c805f
commit efb83fa064
1 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,8 @@
package org.springframework.aot.graalvm;
import java.lang.reflect.Field;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.regex.Pattern;
import com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor;
@ -47,6 +49,8 @@ class ConstantFieldSubstitutionProcessor extends SubstitutionProcessor {
private final ThrowawayClassLoader throwawayClassLoader;
private Set<String> seen = new LinkedHashSet<>();
ConstantFieldSubstitutionProcessor(DebugContext debug, ClassLoader applicationClassLoader) {
this.throwawayClassLoader = new ThrowawayClassLoader(applicationClassLoader);
@ -63,7 +67,10 @@ class ConstantFieldSubstitutionProcessor extends SubstitutionProcessor {
JavaConstant constant = lookupConstant(declaringClass.toJavaName(), field.getName());
if (constant != null) {
// TODO Use proper logging only when --verbose is specified when https://github.com/oracle/graal/issues/4669 will be fixed
System.out.println("Field " + fieldIdentifier + " set to " + constant.toValueString() + " at build time");
if (!this.seen.contains(fieldIdentifier)) {
this.seen.add(fieldIdentifier);
System.out.println("Field " + fieldIdentifier + " set to " + constant.toValueString() + " at build time");
}
return new ConstantReadableJavaField(field, constant);
}
}