Skip to content

Method not found in Spel expression in native images #34206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
martinformi opened this issue Feb 15, 2023 · 1 comment
Closed

Method not found in Spel expression in native images #34206

martinformi opened this issue Feb 15, 2023 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@martinformi
Copy link

martinformi commented Feb 15, 2023

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;
    }
}
@martinformi martinformi changed the title Using Spel Method not found in Spel expression in native image Feb 15, 2023
@martinformi martinformi changed the title Method not found in Spel expression in native image Method not found in Spel expression in native images Feb 15, 2023
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 15, 2023
@wilkinsona
Copy link
Member

It's allowed, but you will have to tell Graal about the methods in your expressions so that they can be called reflectively. spring-projects/spring-framework#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants