Bug 209944 - No full qualified class names in pointcut and advise?
Summary: No full qualified class names in pointcut and advise?
Status: RESOLVED WORKSFORME
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-15 09:10 EST by Kai Hofmann CLA
Modified: 2008-07-13 11:43 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Hofmann CLA 2007-11-15 09:10:32 EST
I wrote the following pointcut/aspect:


  pointcut methodCallConvert(java.sql.Date datein) : // <-- java.sql can not resolved to a type
   call(public static java.util.Date oracle.toplink.internal.helper.Helper.utilDateFromSQLDate(java.sql.Date)) && args(datein);


  after(java.sql.Date datein) returning(java.util.Date dateout) : // <-- java.sql can not resolved to a type (2 times)
   methodCallReflectionSetter(datein)
   {
    Signature sig = thisJoinPointStaticPart.getSignature();

    _logger.logp(Level.INFO,sig.getDeclaringType().getName(),sig.getName(),"DateConvert: " + datein.toString() + " -> " + dateout.toString());
   }


Its not understandable to me, why the error message is "java.sql can not resolved to a type" appears here.
Writing a aspect for testing a java.sql.Date to java.util.Date function will be impossible in this way, because only importing one of these will not help here :(
Comment 1 Andrew Clement CLA 2007-11-15 12:00:16 EST
Have you put the jar file containing the sql types on your classpath when compiling the aspect?  The references in the aspect are resolved relative to your classpath.  It is perfectly possible to put fully qualified types in the pointcuts.
Comment 2 Kai Hofmann CLA 2007-11-16 02:05:44 EST
Yes, I have the java runtime libraries like rt.jar etc. in my classpath - in windows as well as in the eclipse project settings.
I wonder, why it works when using:

import java.util.Date;


and then only using Date, while using java.util.Date directly will result into the described error message. Looks like a bug to me.
Comment 3 Andrew Clement CLA 2007-11-16 11:58:03 EST
I just compiled this program:

public aspect Foo {
  pointcut p1(java.util.Date d ): call(* *(..)) && args(d);
  pointcut p2(java.sql.Date d ): call(* *(..)) && args(d);
  after(java.sql.Date d1) returning(java.util.Date d2): p2(d1) {}
}

with AspectJ1.5.3 and the latest dev build (in case it was a regression) but it works fine.  This works too:

import java.util.Date;

public aspect Foo {
  pointcut p1(Date d ): call(* *(..)) && args(d);
  pointcut p2(java.sql.Date d ): call(* *(..)) && args(d);
  after(java.sql.Date d1) returning(Date d2): p2(d1) {}
}

and this

import java.sql.Date;

public aspect Foo {
  pointcut p1(java.util.Date d ): call(* *(..)) && args(d);
  pointcut p2(Date d ): call(* *(..)) && args(d);
  after(Date d1) returning(java.util.Date d2): p2(d1) {}
}

It may be a bug but I'm trying to understand what you are doing differently to me - can you include a minimal test program that includes no other types (like the toplink types) and I'll try and fix it if I can get it to fail?

I presume you can run 'javap java.sql.Date' and 'javap java.util.Date' on the command line no problem?

Are you able to try building it outside of eclipse?  Can you tell me exactly which version of AJDT/AspectJ you are using? 
Comment 4 Andrew Clement CLA 2008-07-13 11:43:18 EDT
no reply for 6 months, please reopen if still a problem.