Summary: | advising a private constructor generates an extra ctor that is also advised | ||
---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Pepe <ppregs> |
Component: | Runtime | Assignee: | aspectj inbox <aspectj-inbox> |
Status: | NEW --- | QA Contact: | |
Severity: | major | ||
Priority: | P3 | CC: | aclement |
Version: | unspecified | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Pepe
2011-11-16 19:10:06 EST
The generation of the secondary constructor is not AspectJ, it is how the eclipse compiler chooses to implement private inner class constructors (if the outer class needs to be able to see into the type, the compiler creates a second ctor of package visibility and tries to kind of 'hide it' by making it synthetic and giving it an unusual argument). javac does things differently - it does generate the extra ctor but the parameter is of a different type. This code compiled with javac or plain eclipse will show bytecode containing two ctors (for class B): public class A { static private class B { private B() { } } public void m() { new B(); } } Anyway, the AspectJ weaver sees the bytecode and all it sees are two different constructors, it doesn't know/recognize what the compiler did to create them, so it is kind of working-as-designed that both are advised. In your advice you can exclude synthetic constructors: execution(!synthetic A.new(..)); |