This was discovered while executing DirtiesContextTransactionalTestNGSpringContextTests
from spring-test
in AOT mode.
The config file DirtiesContextTransactionalTestNGSpringContextTests-context.xml
contains the following.
<jdbc:embedded-database id="dataSource" />
AOT processing generates the following source code in the javax.sql
package.
---- source: javax/sql/DataSource__TestContext004_BeanDefinitions.java
package javax.sql;
import java.lang.Class;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean;
/**
* Bean definitions for {@link DataSource}
*/
public class DataSource__TestContext004_BeanDefinitions {
/**
* Get the bean definition for 'dataSource'
*/
public static BeanDefinition getDataSourceBeanDefinition() {
Class<?> beanType = EmbeddedDatabaseFactoryBean.class;
RootBeanDefinition beanDefinition = new RootBeanDefinition(beanType);
beanDefinition.getPropertyValues().addPropertyValue("generateUniqueDatabaseName", "false");
beanDefinition.getPropertyValues().addPropertyValue("databaseName", "dataSource");
beanDefinition.getPropertyValues().addPropertyValue("databaseType", "HSQL");
beanDefinition.setInstanceSupplier(EmbeddedDatabaseFactoryBean::new);
return beanDefinition;
}
}
Compilation fails as follows:
package exists in another module: java.sql javax/sql/DataSource__TestContext004_BeanDefinitions.java 1:1
cannot find symbol
symbol: class DataSource__TestContext004_BeanDefinitions
location: package javax.sql org/springframework/test/context/testng/DirtiesContextTransactionalTestNGSpringContextTests__TestContext004_BeanFactoryRegistrations.java 3:17
Comment From: snicoll
Compilation fails as follows:
That's a bit odd. We have plenty of cases where AOT generates in existing packages. I don't understand why this case is different.
Comment From: sbrannen
I don't know why it's different. I merely reported something that I observed.
Though perhaps this only fails in conjunction with the TestCompiler
and the CompileWithForkedClassLoaderExtension
.
org.springframework.core.test.tools.CompilationException: Unable to compile source
package exists in another module: java.sql /javax/sql/DataSource__TestContext001_BeanDefinitions.java 1:1