iajc fails to weave aspects from a jar but succeedes from class files

牧云@^-^@ 提交于 2020-01-14 03:13:30

问题


So I defined iajc task for my project that does intertype declarations just fine, then there is a separate jar task that creates a project.jar.

Then there is iajc task for junit test target, this task references the project.jar with the goal of weaving its ITDs into test classes like so:

<aspectpath>
<pathelement path="${dist}/project.jar"/>
<fileset dir="${lib.aspect}">
    <include name="**/*.jar" />
    <include name="**/*.zip" />
</fileset>
</aspectpath>

That does not work - compiler produces errors like class "com....Foo" has to implement method doThings() defined in interface Bar

Then I change the <aspectpath> to this:

<aspectpath>
<pathelement location="${build.dir}"/>
<fileset dir="${lib.aspect}">
    <include name="**/*.jar" />
    <include name="**/*.zip" />
</fileset>
</aspectpath>

which is basically using the intermediate class files generated by the compiler and it works great.

Then I find that if I use the outjar option instead of destdir in my iajc task then that jar can be used in <aspectpath>.

So a question and a comment then:

Q. is there some parameter that would make it work with the regular <jar> task?

C. the fact that I have to use outjar is not documented at all - the option to output a jar is mentioned but nowhere does it say that that is the only way to produce a jar that will work.

来源:https://stackoverflow.com/questions/7035604/iajc-fails-to-weave-aspects-from-a-jar-but-succeedes-from-class-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!