[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [aspectj-users] Re: Re: Array Constructor Pointcut ?
|
This was intended to be a language restriction. The compiler bug is that
we're not signaling an error for the syntax "call(String[].new(..))". Array
types don't have constructors, initializers, or static initializers in Java.
I've to submitted a bug report so we catch that illegal syntax (and the
other illegal syntax David Pearce found *smile*).
As Matt correctly says, there is an anewarray/newarray bytecode representing
array construction, so capturing array construction as a join point is
technically feasible. If someone has a good use case for "array constructor
join points" (which would be call-site-like things in the same way as field
references are) then he or she should submit it as a feature request to
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ.
-erik
-----Original Message-----
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Matthew Webster
Sent: Thursday, June 17, 2004 8:10am
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] Re: Re: Array Constructor Pointcut ?
The fact that the following code compiles suggests that this is not a
language restriction:
public aspect Aspect {
pointcut initArray () :
call(String[].new(..));
after () : initArray() {
System.err.println("? " + thisJoinPoint
.getSignature().getName());
}
pointcut all () :
within(Test);
after () : all() {
System.err.println("? " + thisJoinPoint);
}
}
public class Test {
public static void main(String[] args) {
String s = new String("Hello");
String[] sa = new String[1];
int[] ia = new int[1];
}
}
However the output indicated the array construction join point is not
recognized by AspectJ although there is a bytecode associated with it
(newarray/anewarray):
? staticinitialization(Test.<clinit>)
? call(java.lang.String(String))
? execution(void Test.main(String[]))
This is probably a complier bug.
Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester, SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/