Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Help capturing new with primitive types

As you probably know, a workaround is to make it into a join point:

public class Malloc {
   public static byte[] bytes(int n) { ... }
}

byte[] buffer = Malloc.bytes(someSize);
...

Sometimes scattered code can be normalized somewhat by delegation, 
alone, or via delegation create a good join point model for aspects.
This works for things that aren't join points, either because 
AspectJ doesn't support that form, or because there is a sequence
of code at issue, e.g.,

byte[] buffer = new byte[someSize];
for (int i = 0; i < someSize; i++) {
   buffer[i] = -1;
}

   public static byte[] bytes(int n, byte initialValue) { ... }

Wes


> ------------Original Message------------
> From: Matthew Webster <matthew_webster@xxxxxxxxxx>
> To: "Mike J. Bell" <ckimyt@xxxxxxxxx>, aspectj-users@xxxxxxxxxxx
> Date: Thu, May-26-2005 1:10 AM
> Subject: Re: [aspectj-users] Help capturing new with primitive types
>
> 
> 
> 
> 
> Mike,
> 
> This is a known restriction:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=77166
> 
> 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/
> 
> "Mike J. Bell" <ckimyt@xxxxxxxxx>@eclipse.org on 25/05/2005 18:44:24
> 
> Please respond to "Mike J. Bell" <ckimyt@xxxxxxxxx>; Please respond to
>        aspectj-users@xxxxxxxxxxx
> 
> Sent by:    aspectj-users-bounces@xxxxxxxxxxx
> 
> 
> To:    aspectj-users@xxxxxxxxxxx
> cc:
> Subject:    [aspectj-users] Help capturing new with primitive types
> 
> 
> This is related to FAQ 10.15, but not completely because I don't really
> want to do any type conversion.
> 
> I have code that looks like the following:
> 
> ...
> // somehow define someSize
> // 1*
> byte[] buffer = new byte[someSize];
> // 2*
> // do something with buffer
> 
> This code is in a WHOLE bunch of different places.
> 
> I want to capture execution of the new call to allocate memory for an 
> array
> of primitive type (in this case byte), and use this as a cutpoint so I 
> can
> add before (1) and after (2) advice for some introspection.
> 
> Any ideas?  Sorry if this is covered somewhere in the FAQ; I couldn't 
> find
> it.
> 
> Thanks,
> Mike
> 
> --
> Mike J. Bell on gmail _______________________________________________
> 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