Announcement Announcement Module
No announcement yet.
@Configurable not working on Subclass of an Abstract Class in specific case Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Configurable not working on Subclass of an Abstract Class in specific case

    I believe I have narrowed this issue down to a specific case. Take the following general abstract class:

    public abstract class AbstractClass {
    And a subclass of that AbstractClass that is marked as configurable:

    @Configurable(autowire = Autowire.BY_TYPE)
    public class SubClass extends AbstractClass {
       private SomeService someService;
    The following instantiation of SubClass fails to autowire the dependencies:

    //The key here is to define AbstractClass as the type, but invoke the SubClass constructor via the new operator
    AbstractClass abstractClass = new SubClass();
    However, the both of the following instantiations successfully autowire the dependencies:

    //Defining SubClass as the type allows weaving to work
    SubClass subClass = new SubClass();
    //or using the newInstance method on the SubClass class definition, even when the defined type is AbstractClass
    AbstractClass abstractClass = SubClass.class.newInstance();
    For completeness, I'm using Spring 3.2.2.RELEASE, aspectjrt and aspectjtools v1.7.0. I'm using load time weaving with the spring-instrument-tomcat.jar via the META-INF/context.xml, running on Tomcat 7.0.32:

    	<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader" />
    Does this look like a bug? Or is it expected that invoking the constructor for SubClass assigning to the AbstractClass variable will not weave?