[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Problem with static intertype declaration and interface

On the good news front, the AspectJ compiler in CVS HEAD (and for 1.2) now catches this error at compile time.

> ------------Original Message------------
> From: Bo Yi <boyi@xxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Cc: "'aspectj-users@xxxxxxxxxxx'" <aspectj-users@xxxxxxxxxxx>, aspectj-users-admin@xxxxxxxxxxx
> Date: Thu, Mar-25-2004 8:10 AM
> Subject: Re: [aspectj-users] Problem with static intertype declaration and interface
> 
> 
> 
> 
> 
> Hello Wolvers,
> 
> This is a Java error rather than Aspect error.
> 
> AspectJ allows add intertype declaration but the declaration must be a
> valid java declaration in case it is added locally to the java class.
> In your sample you tried to add a PRIVATE method with IMPLEMENTATION into
> an interface. This is not valid in terms of Java. The java error message
> indicated private is not a valid modifier to an interface method.
> 
> Best,
> 
> Bo
> ----------------------------------------------------------
>   Dr. Bo Yi
>   WAS L3 Support
>   IBM Toronto Lab
>   A2-713/Q2Z/8200/MKM
>   8200 Warden Ave. Markham ONT. L6G 1C7
>   Phone: 905-413-4819
>   Tie Line: 969-4819
>   E-Mail: boyi@xxxxxxxxxx
> 
> 
> 
> |---------+------------------------------->
> |         |           "Wolvers, B. (Bas)" |
> |         |           <Bas.Wolvers@AkzoNob|
> |         |           el.com>             |
> |         |           Sent by:            |
> |         |           aspectj-users-admin@|
> |         |           eclipse.org         |
> |         |                               |
> |         |                               |
> |         |           03/24/2004 04:12 AM |
> |         |           Please respond to   |
> |         |           aspectj-users       |
> |---------+------------------------------->
>   >-----------------------------------------------------------------------------------------------------------------------|
>   |                                                                                                                       |
>   |       To:       "'aspectj-users@xxxxxxxxxxx'" <aspectj-users@xxxxxxxxxxx>                                             |
>   |       cc:                                                                                                             |
>   |       Subject:  [aspectj-users] Problem with static intertype declaration and interface                               |
>   |                                                                                                                       |
>   |                                                                                                                       |
>   >-----------------------------------------------------------------------------------------------------------------------|
> 
> 
> 
> Please have a look at the following code:
> 
> package untitled4;
> public interface Interface1{}
> 
> package untitled4;
> class Untitled1
> {
>     public static void main(String args[])
>     {
>     }
> }
> 
> package untitled4;
> aspect aAspect
> {
>   declare parents : Untitled1 implements Interface1;
> 
>   private static String Untitled1.aString = getString();
> 
>   private static final String Interface1.getString()
>   {
>       return "AString";
>   }
> }
> 
> When I run this code the following exception occurs:
> java.lang.ClassFormatError: untitled4/Interface1 (Illegal method modifiers:
> 0x409)
>              at java.lang.ClassLoader.defineClass0(Native Method)
>              at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
>              at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
>              at
> java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
>              at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
>              at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
>              at java.security.AccessController.doPrivileged(Native Method)
>              at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
>              at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
>              at
> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
>              at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
>              at
> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
>              at java.lang.ClassLoader.defineClass0(Native Method)
>              at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
>              at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
>              at
> java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
>              at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
>              at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
>              at java.security.AccessController.doPrivileged(Native Method)
>              at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
>              at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
>              at
> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
>              at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
>              at
> java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
> Exception in thread "main"
> 
> Questions:
> - Why does the error occur? (The ajc compiler doesn't give an error or
> warning) Is this a aspectJ bug?
> 
> - Why is it not possible to intertype a static field to an interface.
> (I want to add a static field to more then one class, the classes
> implements
> the same interface)
> 
> Greetings,
> 
> Bas
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
> 
>