Using Spel and emptyList() seems to fail in the native image. This method exists in Collections however in the native image it could not be found. Is there any workaround? Is even calling methods allowed in Spel expressions in Spring native? Thank you.

@Configuration
@ConfigurationProperties(prefix = "test")
@Data
public class TestConfiguration {

    @Value("${test.aaa : #{T(java.util.Collections).emptyList()}}")
    private List<String> aaa;
EL1004E: Method call: Method emptyList() cannot be found on type java.util.Collections

EmptyList is defined as following:

public class Collections {
...
public static final <T> List<T> emptyList() {
        return (List<T>) EMPTY_LIST;
    }
}

Comment From: wilkinsona

It's allowed, but you will have to tell Graal about the methods in your expressions so that they can be called reflectively. https://github.com/spring-projects/spring-framework/issues/29548 is exploring improving this situation. In the meantime, you can provide runtime hints for the methods that you want to call through SpEL expressions.