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
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to