Affects: 6.0.1
Having a small simple Spring Boot application with Validator dependency, adding a ConfigurationProperties class with @Validated
logs many warning like below:
...
2022-11-23T20:36:30.230+01:00 WARN 10246 --- [ restartedMain] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead: public java.lang.String(java.lang.StringBuilder)
2022-11-23T20:36:30.231+01:00 WARN 10246 --- [ restartedMain] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead: public java.lang.String(char[])
2022-11-23T20:36:30.231+01:00 WARN 10246 --- [ restartedMain] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead: java.lang.String(char[],int,int,java.lang.Void)
2022-11-23T20:36:30.231+01:00 WARN 10246 --- [ restartedMain] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead: java.lang.String(char[],int,int,java.lang.Void)
2022-11-23T20:36:30.231+01:00 WARN 10246 --- [ restartedMain] ocalVariableTableParameterNameDiscoverer : Using deprecated '-debug' fallback for parameter name resolution. Compile the affected code with '-parameters' instead: java.lang.String(char[],int,int,java.lang.Void)
...
I'm not entirely sure what it's saying. The executable is not my code, it's the standard library. Anyway, adding javaParameters = true
to the build script doesn't help.
I started seeing the logs after refreshing the snapshot version of Spring Boot (but Spring Core is v6.0.1). There was no issue before.
sample-project
Comment From: sdeleuze
It is a side effect of fe5bd6751f461532d6817610c47254e0400d25f9 when Hibernate Validator is used. I can reproduce with both Kotlin and Java.
Here we have org.springframework.boot.context.properties.ConfigurationPropertiesJsr303Validator
-> jakarta.validation.Validator.validate("Foooooo")
-> org.hibernate.validator.internal.metadata.BeanMetaDataManagerImpl.createBeanMetaData(String.class)
-> org.hibernate.validator.internal.metadata.aggregated.BeanMetaDataBuilder#build
where here there are 107 builders (String
constructors and methods).
They come from org.hibernate.validator.internal.metadata.provider.AnnotationMetaDataProvider#retrieveBeanConfiguration
which adds all methods and all constructors of the types validated, and then org.hibernate.validator.internal.util.ExecutableParameterNameProvider
delegates to org.springframework.validation.beanvalidation.LocalValidatorFactoryBean
which in turn delegates to org.springframework.core.LocalVariableTableParameterNameDiscoverer
on String
JDK class not compiled with -parameters
.
Comment From: emeraldhieu
This still happens in spring 6.0.2. Spring Boot 3.0.0.
Comment From: plause
This still happens in spring 6.0.2. Spring Boot 3.0.0.
Adding -java-parameters
(Kotlin)/-parameters
(Java) flag to the compiler options helps get rid of these warnings.
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-java-parameters")
}
}
compileJava {
options.compilerArgs << '-parameters'
}
Note: you should read/know the Drawbacks of javac -parameters flag