- Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
theme: aotAn issue related to Ahead-of-time processingAn issue related to Ahead-of-time processingtheme: kotlinAn issue related to Kotlin supportAn issue related to Kotlin supporttype: documentationA documentation taskA documentation task
Milestone
Description
Affects: <6.1.2>
Reproducer: https://github.com/juliuskrah/graphql-demo/tree/spf-32487
Given this valid kotlin class:
class `20240318CreateProductTable` { fun createProductTable() { } fun addProductData() { } }and Bean class:
class ExampleBean { lateinit var migrationClass: Class<*> }with a runtime bean definition:
@Configuration(proxyBeanMethods = false) class MyConfig { companion object { @Bean fun beanProcessor(): BeanFactoryPostProcessor { return BeanFactoryPostProcessor { if (it is DefaultListableBeanFactory) { val beanDefinition = BeanDefinitionBuilder.rootBeanDefinition(ExampleBean::class.java) .addPropertyValue("migrationClass", com.example.graph.migration.`20240318CreateProductTable`::class.java) .beanDefinition it.registerBeanDefinition("exampleBean", beanDefinition) } } } } }generates the following invalid java class:
import com.example.graph.migration.20240318CreateProductTable; import org.springframework.aot.generate.Generated; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.RootBeanDefinition; @Generated public class ExampleBean__BeanDefinitions { /** * Get the bean definition for 'exampleBean'. */ public static BeanDefinition getExampleBeanBeanDefinition() { RootBeanDefinition beanDefinition = new RootBeanDefinition(ExampleBean.class); beanDefinition.getPropertyValues().addPropertyValue("migrationClass", 20240318CreateProductTable.class); beanDefinition.setInstanceSupplier(ExampleBean::new); return beanDefinition; } }that results in:
> Task :compileAotJava FAILED /path/to/file/graphql-demo/build/generated/aotSources/com/example/graph/ExampleBean__BeanDefinitions.java:3: error: ';' expected import com.example.graph.migration.20240318CreateProductTable; ^ /path/to/file/graphql-demo/build/generated/aotSources/com/example/graph/ExampleBean__BeanDefinitions.java:18: error: ')' or ',' expected beanDefinition.getPropertyValues().addPropertyValue("migrationClass", 20240318CreateProductTable.class); ^ /path/to/file/graphql-demo/build/generated/aotSources/com/example/graph/ExampleBean__BeanDefinitions.java:18: error: not a statement beanDefinition.getPropertyValues().addPropertyValue("migrationClass", 20240318CreateProductTable.class); ^ /path/to/file/graphql-demo/build/generated/aotSources/com/example/graph/ExampleBean__BeanDefinitions.java:18: error: ';' expected beanDefinition.getPropertyValues().addPropertyValue("migrationClass", 20240318CreateProductTable.class); ^ 4 errors FAILURE: Build failed with an exception. Expectation
Kotlin sources should generate Kotlin aotSources
Metadata
Metadata
Assignees
Labels
theme: aotAn issue related to Ahead-of-time processingAn issue related to Ahead-of-time processingtheme: kotlinAn issue related to Kotlin supportAn issue related to Kotlin supporttype: documentationA documentation taskA documentation task