Skip to content

AOT generated code leads to exception on startup: Object of class [java.lang.Boolean] must be an instance of boolean #28727

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
mhalbritter opened this issue Jun 29, 2022 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Milestone

Comments

@mhalbritter
Copy link
Contributor

Hi,

when running a Spring Boot project with the starter-integration in it in AOT mode, it crashes on startup with this exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'errorChannel': Instantiation of supplied bean failed
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1234) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1209) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1156) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:566) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:526) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:930) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:926) ~[spring-context-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:592) ~[spring-context-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:729) ~[spring-boot-3.0.0-SNAPSHOT.jar!/:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:428) ~[spring-boot-3.0.0-SNAPSHOT.jar!/:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[spring-boot-3.0.0-SNAPSHOT.jar!/:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-3.0.0-SNAPSHOT.jar!/:3.0.0-SNAPSHOT]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-3.0.0-SNAPSHOT.jar!/:3.0.0-SNAPSHOT]
	at com.example.integrationaot.IntegrationAotApplication.main(IntegrationAotApplication.java:10) ~[classes!/:0.0.1-SNAPSHOT]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[integration-aot-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:95) ~[integration-aot-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[integration-aot-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[integration-aot-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: java.lang.IllegalArgumentException: Object of class [java.lang.Boolean] must be an instance of boolean
	at org.springframework.util.Assert.instanceCheckFailed(Assert.java:702) ~[spring-core-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.util.Assert.isInstanceOf(Assert.java:602) ~[spring-core-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.util.Assert.isInstanceOf(Assert.java:633) ~[spring-core-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.aot.AutowiredArguments.get(AutowiredArguments.java:45) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.integration.channel.PublishSubscribeChannel__BeanDefinitions.lambda$getErrorChannelInstance$0(PublishSubscribeChannel__BeanDefinitions.java:31) ~[classes!/:0.0.1-SNAPSHOT]
	at org.springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:63) ~[spring-core-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:51) ~[spring-core-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.beans.factory.aot.AutowiredInstantiationArgumentsResolver.resolve(AutowiredInstantiationArgumentsResolver.java:156) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	at org.springframework.integration.channel.PublishSubscribeChannel__BeanDefinitions.getErrorChannelInstance(PublishSubscribeChannel__BeanDefinitions.java:31) ~[classes!/:0.0.1-SNAPSHOT]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainInstanceFromSupplier(AbstractAutowireCapableBeanFactory.java:1223) ~[spring-beans-6.0.0-SNAPSHOT.jar!/:6.0.0-SNAPSHOT]
	... 25 common frames omitted

This looks like a bug in the AOT generated code (?).

Reproducer repo: https://github.com/mhalbritter/integration-aot

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 29, 2022
@sdeleuze sdeleuze added theme: aot An issue related to Ahead-of-time processing type: bug A general bug labels Jun 29, 2022
@sdeleuze sdeleuze added this to the 6.0.0-M5 milestone Jun 29, 2022
@jhoeller jhoeller self-assigned this Jun 29, 2022
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 29, 2022
@jhoeller
Copy link
Contributor

Looks like a strict instance-of check where we should be using isAssignableValue as we do in other places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants