Bug 243203 - [ataspectj] [decp] clarify difference between @DeclareParents and 'declare parents'
Summary: [ataspectj] [decp] clarify difference between @DeclareParents and 'declare pa...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-05 13:50 EDT by Andrew Clement CLA
Modified: 2013-06-24 11:06 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2008-08-05 13:50:20 EDT
This bug is to cover any fixes that need putting in to bring these more into line, plus any changes required to the doc to indicate that they don't have identical semantics.  One is using a mixin style because the type system cannot be manipulated like it can with code style aspects that require use of ajc for compilation.

See the thread by Larry Chu:

http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg09516.html

Most recently he wrote:
---
To follow up, I found these references in the archive about the same topic.

http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg07722.html

http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg05884.html


I found a question posted here that interested me but was never answered:

http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg05884.html

> The short question is:
> When using @DeclareParents to define a mixin, how do I gain access to
> the instrumented object from within the mixin object?
 

I was hoping someone might be able to answer this previously asked question.
---
Comment 1 Andrew Clement CLA 2008-08-13 14:40:31 EDT
just adding a target so this doesn't completely drop off the radar - but it may not make 1.6.2
Comment 2 Andrew Clement CLA 2008-08-14 13:30:32 EDT
related bug 242383
Comment 3 Andrew Clement CLA 2009-03-05 19:02:56 EST
@DeclareParents does not offer the same semantics as code style declare parents, it is just a mixin.  I've started to update the documentation to say so:

http://www.eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-itds.html

@DeclareMixin has been created as the proper mixin strategy to use, it overcomes some of the shortcomings of @DeclareParents and makes it more apparent that it is not intended to be an annotation style replacement for code style declare parents.

@DeclareMixin is documented on that same page.

> The short question is:
> When using @DeclareParents to define a mixin, how do I gain access to
> the instrumented object from within the mixin object?

@DeclareMixin makes this possible by being an annotation that is attached to the factory method that creates the delegate objects - this factory method can be defined to take a parameter, and when it does the parameter value will be the object instance for which a delegate is sought.  For example:

@DeclareMixin("Foo")
public static MixinInterface createImplementation(Object fooInstance) {
  return new MixinImplementation(fooInstance);
}

I have not yet decided whether to fully deprecate @DeclareParents.
Comment 4 Andrew Clement CLA 2013-06-24 11:06:28 EDT
unsetting the target field which is currently set for something already released