Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Help: annotation introduction not working

I'm trying to recreate this locally but not having much luck.  The
annotations are always there for me.  You could try turning off
pipeline compilation in case that is affecting things - put
X="-Xset:pipelineCompilation=false" in your iajc command.  But I'm not
hopeful that will address it as you are doing binary weaving.  You are
on a recent AspectJ I take it?

Andy

2009/8/24 Matthew Adams <matthew@xxxxxxxxxxxxxxx>
>
> I'm using the ant task iajc to achieve some binary weaving of .class
> files, where I want to introduce not only fields and methods but also
> class-level annotations.
>
> The iajc compiler is emitting messages that say that it is adding the
> annotations, but when I decompile or use reflection against the woven
> classes, there are none on the class.
>
> Anyone know why this might be happening?
>
> Here is my iajc invocation (run from within maven-antrun-plugin):
> <iajc destDir="${project.build.outputDirectory}" source="1.6"
>        target="1.6" debug="true" preserveAllLocals="true"
>        showWeaveInfo="true" verbose="true" classpathref="cp" noimporterror="false">
>        <sourceroots>
>                <pathelement location="${project.build.sourceDirectory}" />
>                <pathelement location="${project.build.sourceDirectory}/../aspect" />
>        </sourceroots>
>        <inpath>
>                <pathelement location="${resource.entity.source.classes.path}" />
>        </inpath>
> </iajc>
>
> Above, classpathref cp evaluates to a path that is
> maven.compile.classpath, and resource.entity.source.classes.path is
> the directory containing the .class files that I'm trying to weave.
>
> The ajc compiler says (package names abbreviated with "org...." to
> protect the innocent):
>     [iajc] ajc [-source, 1.6, -verbose, -target, 1.6, -g, -d,
> C:\dev\ECO\svn\trunk\case\case-rest-resource-entity\target\classes,
> -showWeaveInfo, -preserveAllLocals, -classpath, ...
>     ...
>     [iajc] info Pipelining compilation
>     ...
>     [iajc] info weaver operating in reweavable mode.  Need to verify
> any required types exist.
>     ...
>     [iajc] weaveinfo 'org.....rest.entity.Person' (Person.java) is
> annotated with @XmlRootElement type annotation from
> 'org.....rest.entity.aspects.RestResourceEntityMixin'
> (RestResourceEntityMixin.aj:14)
>     [iajc] weaveinfo 'org.....rest.entity.Person' (Person.java) is
> annotated with @Generated type annotation from
> 'org.....rest.entity.aspects.RestResourceEntityMixin'
> (RestResourceEntityMixin.aj:13)
>     [iajc] weaveinfo 'org.....rest.entity.User' (User.java) is
> annotated with @XmlRootElement type annotation from
> 'org.....rest.entity.aspects.RestResourceEntityMixin'
> (RestResourceEntityMixin.aj:14)
>     [iajc] weaveinfo 'org.....rest.entity.User' (User.java) is
> annotated with @Generated type annotation from
> 'org.....rest.entity.aspects.RestResourceEntityMixin'
> (RestResourceEntityMixin.aj:13)
>
> Below is the aspect that's being applied.  Note interestingly that
> while the @Generated and @XmlRootElements don't appear in the final
> woven .class file, the introduced fields and methods actually do show
> up.
>
> import org.....rest.entity.annotations.Generated;
> import javax.xml.bind.annotation.XmlRootElement;
>
> public aspect RestResourceEntityMixin {
>
>        public static interface Introduced {}
>
>        declare @type: (org.....rest.entity.*) : @Generated;
>        declare @type: (org.....rest.entity.*) : @XmlRootElement;
>
>        declare parents: (@Generated *) implements Introduced;
>
>        private String Introduced.etag;
>        private String Introduced.href;
>
>        public String Introduced.getEtag() {
>                return etag;
>        }
>        public void Introduced.setEtag(String etag) {
>                this.etag = etag;
>        }
>
>        public String Introduced.getHref() {
>                return href;
>        }
>        public void Introduced.setHref(String href) {
>                this.href = href;
>        }
> }
>
> Can anyone help?
>
> Thanks,
> Matthew
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top