Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Custom Autoboxing

Hi Everyone,

    I'm new to the list, so I apologize if this is the wrong place to ask
such questions. I have searched the list, and googled around, but have not
found any information about my question yet.

I'm wondering if it is possible to implement some sort of custom autoboxing
using aspectj. For example sake, lets say:

  MyBoolean b = true;

Where MyBoolean is a custom implementation of essentially java.lang.Boolean
(I know this is pretty pointless, but its just for example sake).

Intuitively, it seems like this should be completely possible, as I could
declare a pointcut on the set of MyBoolean, and then declare around advice
which takes the boolean and returns a MyBoolean. The problem, however, is I
still get a compiler error that "boolean is not assignable to MyBoolean".

So I'm wondering if anyone point me in the right direction if 1) what I'm
saying is even possible and 2) if so, what I'm missing.


 Thanks,
     Keith


Here is a quick aspect I've written to test this:

    pointcut setBool(boolean newval): set(MyBoolean *) && args(newval);

   MyBoolean around(boolean val) : setBool(val) 

    {
        
       return new MyBoolean(val);

    };




Back to the top