I upgraded my spring boot application from 1.5 to 2.3.5 (using the spring boot gradle plugin). When the spring boot application starts, I get the following warning 4 times:
2020-11-05 13:29:19.432 WARN 3931 --- [nio-8080-exec-4] o.h.v.i.p.javabean.JavaBeanExecutable : HV000254: Missing parameter metadata for FacetField(String, int, String, String, String, int, Class), which declares implicit or synthetic parameters. Automatic resolution of generic type information for method parameters may yield incorrect results if multiple parameters have the same erasure. To solve this, compile your code with the '-parameters' flag.
My FacetField enum looks like this:
public enum FacetField {
CONST_1("KEY", "ESFIELD", "RESOURCEKEY"),
CONST_2("KEY", "ESFIELD", "RESOURCEKEY"),
CONST_3("KEY", "ESFIELD", ""),
CONST_4("KEY", "ESFIELD", "ESMAXFIELD", "RESOURCEKEY", Hours.class),
CONST_5("KEY", "ESFIELD", "RESOURCEKEY", Experience.class),
CONST_6("KEY", "ESFIELD", "", Distance.class);
private String key;
private String esField;
private String esMaxField;
private String resourcekey;
private Class<? extends RangeFacet> rangeFacet;
FacetField(final String key, final String esField, final String resourcekey) {
this.key = key;
this.esField = esField;
this.resourcekey = resourcekey;
this.rangeFacet = null;
}
FacetField(final String key, final String esField, final String resourcekey, final Class<? extends RangeFacet> rangeFacet) {
this.key = key;
this.esField = esField;
this.resourcekey = resourcekey;
this.rangeFacet = rangeFacet;
}
FacetField(final String key, final String esMinField, final String esMaxField, final String resourcekey, final Class<? extends RangeFacet> rangeFacet) {
this.key = key;
this.esField = esMinField;
this.esMaxField = esMaxField;
this.resourcekey = resourcekey;
this.rangeFacet = rangeFacet;
}
public String getKey() {
return key;
}
public String getEsField(final FieldProperty fieldProperty) {
return esField + fieldProperty.getEsFieldProperty();
}
public String getEsMinField() {
return esField;
}
public String getEsMaxField() {
return esMaxField;
}
public String getResourcekey() {
return resourcekey;
}
public enum Distance implements RangeFacet {
FROM_0_TO_5(0d, 5d, "5"),
FROM_0_TO_10(0d, 10d, "10"),
FROM_0_TO_20(0d, 20d, "20"),
FROM_0_TO_30(0d, 30d, "30"),
FROM_0_TO_50(0d, 50d, "50");
private final Double min;
private final Double max;
private final String selectableDescription;
Distance(final Double min, final Double max, final String selectableDescription) {
this.min = min;
this.max = max;
this.selectableDescription = selectableDescription;
}
@Override
public Double getMin() {
return this.min;
}
@Override
public Double getMax() {
return this.max;
}
@Override
public String getSelectableDescription() {
return this.selectableDescription;
}
}
public enum Experience implements RangeFacet {
TO_1(0d, 1d, "1"),
FROM_1_TO_2(1d, 2d, "2"),
FROM_2_TO_5(2d, 5d, "5"),
FROM_5_TO_10(5d, 10d, "10"),
FROM_10(10d, null, "10+");
private final Double min;
private final Double max;
private final String selectableDescription;
Experience(final Double min, final Double max, final String selectableDescription) {
this.min = min;
this.max = max;
this.selectableDescription = selectableDescription;
}
@Override
public Double getMin() {
return this.min;
}
@Override
public Double getMax() {
return this.max;
}
@Override
public String getSelectableDescription() {
return this.selectableDescription;
}
}
public enum Hours implements RangeFacet {
FROM_0_TO_8(0d, 8d, "8"),
FROM_9_TO_16(9d, 16d, "16"),
FROM_17_TO_24(17d, 24d, "24"),
FROM_25_TO_32(25d, 32d, "32"),
FROM_33_TO_36(33d, 36d, "36"),
FROM_37(37d, null, "40");
private final Double min;
private final Double max;
private final String selectableDescription;
Hours(final Double min, final Double max, final String selectableDescription) {
this.min = min;
this.max = max;
this.selectableDescription = selectableDescription;
}
@Override
public Double getMin() {
return this.min;
}
@Override
public Double getMax() {
return this.max;
}
@Override
public String getSelectableDescription() {
return this.selectableDescription;
}
}
}
Only thing that I can find something related to this, is this graal issue on github: https://github.com/oracle/graal/issues/1941
Can somebody explain?
spring-boot-parent
used to have the flag set in the maven-compiler-plugin
up until the 2.2.x version.
You'll have to add the flag yourself to the maven-compiler-plugin
:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
</plugins>
</build>
The other answer explains how to get rid of the warning, by compiling with the -paramaters
flag in Maven. With Spring Boot 2 you don't need to do that anymore (neither with Maven nor Gradle).
If your still getting warnings for enum constants, that seems to be a bug of Hibernate Validator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With