Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] ITD error with fields at runtime

Andy,
  thanks for the answer. The problem I described in the mail has been fixed by simply renaming the test packages with another name (before they used the same package name, even if the abstract aspect resided in plugin A while tests resided in package B). 
  Though, I'm currently stuck with the https://bugs.eclipse.org/bugs/show_bug.cgi?id=298704 ;). It seems to me that ITD with aspects in one plugin and concrete implementation aren't exactly at friendly terms. But I've only tried with compile-time weaving, not with ltw.

Wish me luck :D,
Mario

On Mon, Jan 4, 2010 at 8:24 PM, Andy Clement <andrew.clement@xxxxxxxxx> wrote:
> Is simply that ITD is not possible with interfaces (but shouldn't ajc signal my suicide action?), is it a bug or is there any advice about how to archieve the intended result?

What you are doing should work just fine.  are you able to distill it
down to a failing simple case?  I've been trying but it just seems to
work for me.  Something you could try is making presenters non-generic
- does that make any difference?  Or remove the initializer from
presenters can cope with null in the other methods - does that make a
difference? Feel free to raise a bug on this.

Andy

2009/12/29 Mario Scalas <mario.scalas@xxxxxxxxx>:
> Hi all,
>   I found an odd error in my application and hope that someone here may give
> an explanation for this behavior. The problem is that I'm trying to enhance
> classes by inter-type declarations:
> // My enhancer aspect declares a fiew methods and a new field to be inserted
> into classes annotated with @View annotation:
> public aspect ViewEnhancerAspect {
> declare parents: (@View *) implements IAugmentedView;
> private final List<IAugmentedPresenter> IAugmentedView.presenters = new
> ArrayList<IAugmentedPresenter>();
> public void IAugmentedView.fire( Object event ) {
> for (IAugmentedPresenter presenter : presenters) {
> presenter.dispatchEvent( event );
> }
> }
> public void IAugmentedView.registerPresenter( IAugmentedPresenter presenter
> ) {
> presenters.add( presenter );
> }
> public void IAugmentedView.unregisterPresenter( IAugmentedPresenter
> presenter ) {
> presenters.remove( presenter );
> }
> }
> // And my mock view
> @View
> public class TestView implements ITestView {
> @PreDestroy
> public void dispose() { ... }
> @PostConstruct
> public void createPartControl( Composite parent ) { ... }
> }
>
> But when I try to instantiate the same class:
> @Before
> public void simulateViewCreation() {
> view = new TestView();
> }
> I get this error:
> java.lang.NoSuchMethodError:
> it.uniba.di.cdg.penelope.ui.mvp.IAugmentedView.ajc$interFieldSet$it_uniba_di_cdg_penelope_ui_mvp_ViewEnhancerAspect$it_uniba_di_cdg_penelope_ui_mvp_IAugmentedView$presenters(Ljava/util/List;)V
> at
> it.uniba.di.cdg.penelope.ui.mvp.ViewEnhancerAspect.ajc$interFieldInit$it_uniba_di_cdg_penelope_ui_mvp_ViewEnhancerAspect$it_uniba_di_cdg_penelope_ui_mvp_IAugmentedView$presenters(ViewEnhancerAspect.aj:57)
> at it.uniba.di.cdg.penelope.ui.mvp.TestView.<init>(TestView.java:22)
> at
> it.uniba.di.cdg.penelope.ui.mvp.PresenterEnhancerIntegrationTest.simulateViewCreation(PresenterEnhancerIntegrationTest.java:46)
> ...
> If I remove the field ("presenters") declaration it works ok. If I use ITD
> with a class instead of an interface then it works ok but then if the View
> inherits from something different than java.lang.Object (let's say,
> org.eclipse.ui.ViewPart) that it does not weave (no message).
> Is simply that ITD is not possible with interfaces (but shouldn't ajc signal
> my suicide action?), is it a bug or is there any advice about how to
> archieve the intended result?
> Cheers,
> Mario
> --
> "Debugging is twice as hard as writing the code in the first place.
> Therefore, if you write the code as cleverly as possible, you are, by
> definition, not smart enough to debug it." - Brian W. Kernighan
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



--
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan

Back to the top