Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] IDT in JDK classes (How to enable java..* weaving?)


On Aug 8, 2008, at 5:25 PM, Andy Clement wrote:

I just tried it, seemed ok.

Foo.aj:
interface I {}
aspect Foo {
  declare parents: java..* && !java.lang.Object implements I;
}

ajc -inpath rt.jar -outjar woven_rt.jar Foo.aj -showWeaveInfo

results in loads of messages:
...
Extending interface set for type 'java.nio.ByteOrder' (no debug info available) to include 'I' (Foo.aj)
Extending interface set for type 'java.lang.Runtime' (no debug info available) to include 'I' (Foo.aj)
...


Hi Andy,
   There are some classes missing... e.g. java.lang.String, java.lang.Thread...  Could it be a bug? or did I missunderstood something?

javap -s -c -bootclasspath woven_rt.jar java.lang.String 

Compiled from "String.java"
public final class java.lang.String extends java.lang.Object implements java.io.Serializable,java.lang.Comparable,java.lang.CharSequence{
public static final java.util.Comparator CASE_INSENSITIVE_ORDER;
  Signature: Ljava/util/Comparator;
 ...

However, when I try

  declare parents: java.lang.String && !java.lang.Object implements I;

 you have the correct interface implemented...

Compiled from "String.java"
public final class java.lang.String extends java.lang.Object implements java.io.Serializable,java.lang.Comparable,java.lang.CharSequence,I{
public static final java.util.Comparator CASE_INSENSITIVE_ORDER;
  Signature: Ljava/util/Comparator;
...

Cheers,

Alex





>  Could anybody tell me how to disable this restriction? (e.g. using a correct declare parents _expression_, or on which class in the
> sources of aspectj I could look at, to make a patch that disables this restriction for compile time weaving..)

If you want to weave object or enum or annotation types, change org/aspectj/weaver/patterns/DeclareParents.java method maybeGetNewParent().

As Ron says, it can get ugly.

Andy.

2008/8/8 Alex Villazon <alex.villazon@xxxxxxxxxxx>
Hi,
 I'm trying to add an marker interface to JDK classes... If I use:

   declare parents: * && !java.lang.Object implements myInterface;

then, java.* classes are not woven, which is OK for loadtime weaving but should be enabled for static weaving...(as we would like also to weave JDK classes).

Curiously, classes in javax, com.sun get woven... and also if I explicitely give the class name of a java.* class e.g.

   declare parents: java.lang.String implements myInterface;  // works !!!

Is there a way to force the weaver to weave java.* classes? I tried

   declare parents: java..* && !java.lang.Object implements myInterface;

but does not work... (it simply ignores all classes in java and subpackages). I don't have any error message.

Curiously, if I use:

  declare parents: java.lang.* && !java.lang.Object implements myInterface;

I obtain errors about annotations and enums, which means that the weaver is at least trying to weave..

 MyAspect.java:34 [error] can't use declare parents to make annotation type
 java.lang.Override implemt an interface

 Could anybody tell me how to disable this restriction? (e.g. using a correct declare parents _expression_, or on which class in the sources of aspectj I could look at, to make a patch that disables this restriction for compile time weaving..)

Many thanks,

Alex







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

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


Back to the top