Skip to content

BeanDefinitionMethodGenerator should not generate code in the javax package name #29123

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
sbrannen opened this issue Sep 9, 2022 · 2 comments
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Sep 9, 2022

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
@sbrannen sbrannen added type: bug A general bug theme: aot An issue related to Ahead-of-time processing labels Sep 9, 2022
@sbrannen sbrannen modified the milestones: 6.0.0-M6, 6.0.0-RC1 Sep 9, 2022
@snicoll snicoll changed the title AOT bean definition for EmbeddedDatabaseFactoryBean is generated in javax.sql package BeanDefinitionMethodGenerator should not generate code in the javax package name Sep 27, 2022
@snicoll
Copy link
Member

snicoll commented Sep 27, 2022

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.

@sbrannen
Copy link
Member Author

sbrannen commented Oct 7, 2022

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

@snicoll snicoll self-assigned this Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants