[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] limitation: inter-type declaration targets

Following on Chris Bozic's aspectj-users email
"Possible percflow compiler bug" (not yet indexed),
I'd like to confirm what should be required when
declaring methods on library interfaces.  In particular,
it seems to be required that all implementions of the
interface be woven as well.  E.g., this works:

  ajc -outjar lib.jar {aspect-source} {affected-interface}
  ajc -aspectpath "lib.jar" {interfaceImplementations}

The problem is that it would be nice if you do declare
public members on an interface in an aspect, you'd like
to be able to compile against that library using javac:

  ajc -outjar lib.jar {aspect-source} {affected-interface}
  javac -classpath "lib.jar" {interfaceImplementations}
  jar cf app.jar ...

and then run

  java -classpath "lib.jar;aspectjrt.jar;app.jar" ...

or even to weave with other aspects, since the app classes
have never been woven:

  ajc -outjar system.jar
      -classpath "lib.jar;aspectjrt.jar"
      -aspectpath otherAspects.jar
      -injars app.jar

and then run:

  java -classpath "system.jar;lib.jar;aspectjrt.jar;otherAspects.jar"

For sample code, see ajcTests.xml tests refering to


P.S. - Whatever the resolution, it might help to make
it clear somewhere, perhaps in the programming
guide limitations appendix. e.g.,

---- to...
Inter-type declarations such as declare parents  also have
restrictions based on control of the code. If the bytecode
for the target of an inter-type declaration is not available,
then the inter-type declaration is not made on that target.
So, declare parents : String implements MyInterface will
not work for java.lang.String unless java.lang.String is
part of the compile.

---- ... add the line
For inter-type declarations taking a single type, an error
will be signalled if the type is not available at compile
time.  So 'String Foo.toString() { return "foo"; }' will
cause a compile-time error if the type Foo is not available.
---- [not needed since the XLint warning is relatively clear?]

---- ... or perhaps more importantly
For inter-type declarations on interfaces, both the interface
and the implementation must be woven with the aspect.