Closed snicoll closed 10 months ago
Unfortunately, fixing the logic does not help as we can't refer to a class in the default package. So our attempt to refer to it leads to:
/Users/snicoll/Downloads/demo-kotlin-root/build/generated/aotSources/com/example/demokotlinroot/DemoKotlinRootApplicationKt__BeanFactoryRegistrations.java:46: error: cannot find symbol
beanFactory.registerBeanDefinition("config-MyConfig", MyConfig__BeanDefinitions.getConfigMyConfigBeanDefinition());
Given we don't know the visibility of the component, we'll probably have to reject that use case upfront.
This throws the following now:
Exception in thread "main" java.lang.IllegalArgumentException: Could not add 'MyConfig__BeanDefinitions', processing classes in the default package is not supported. Did you forget to add a package statement?
at org.springframework.aot.generate.GeneratedFiles.validatePackage(GeneratedFiles.java:174)
at org.springframework.aot.generate.GeneratedFiles.addSourceFile(GeneratedFiles.java:47)
at org.springframework.aot.generate.GeneratedClasses.writeTo(GeneratedClasses.java:198)
at org.springframework.aot.generate.DefaultGenerationContext.writeGeneratedContent(DefaultGenerationContext.java:136)
at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:108)
at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:80)
When a
JavaFile
is added to the list of files, its class name is deduced from its package name and type name. When adding aJavaFile
that was added in the default package, this leads to: