Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Multiple Method Introductions: patterns?

If this

> Modifiers Type TypePattern . Id(Formals) { Body }

is on the web site, we need to change it.  Since 1.1, it's

> Modifiers Type Type . Id(Formals) { Body }

as seen in the quick-reference pdf of the 1.1.1 docs.

The rationale is stated in the README-11.html: that ITD of
members now must have a single concrete type at the time
they are compiled, since they may be woven later.

If there's no common type reference to the field, you can
implement getInputSource for each class:

    public InputSource Foo.getInputSource() {
         return source; // defined in Foo
    }

    public InputSource Bar.getInputSource() {
         return inputSource;  // defined in Bar
    }

HTH -
Wes

Jeff Dalton wrote:

First, thank you to Wes and Ramnivas for the suggestions.

This would be great, however, there is no getInputSource() method.  I need
to get directly into the class and access its member variable inputSource.

Let me explain the problem.   First, here are the two definitions of the
types found on the AJ website:

declare parents: TypePattern implements TypeList;
Modifiers Type TypePattern . Id(Formals) { Body }

My question is this, why is the following legal:

declare parents: (org.apache.cocoon.generation.TextGenerator ||
org.apache.cocoon.generation.asciiart.AsciiArtSVGGenerator) implements
CacheableProcessingComponent;

While this is invalid:
public Serializable (org.apache.cocoon.generation.TextGenerator ||
org.apache.cocoon.generation.asciiart.AsciiArtSVGGenerator).generateKey() {
    return this.inputSource.getURI();
}

According to the rules defined above, the second should be legal, but it is
not.  Is this a bug or am I missing something?

If I am trying to encapsulate this method into an aspect from lots of
different disparate classes, it does me no good to simply move the method
declaration into an aspect when the same method already exists in it! ... I
now have unnecessary code duplication in my aspect.

Thanks,

Jeff

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top