Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] detecting call to subclass from a constructor

I think that's pretty impossible using plain AspectJ because you would
have to bind the receiver object (this) which is not yet accessible in
constructor joinpoints AFAIK. But maybe there's a workaround which I
don't know of right now.

Eric

On 28/07/07, Mike Schneider <mikepschneider@xxxxxxxxx> wrote:
> How would I implement an aspect to enforce the following rule:
>
> "a constructor cannot call it's own instance methods unless the method
> has been marked final"
>
> Potentially there can be a bug like this:
>        public static class ClassA {
>                public ClassA () {
>                        doStuff();
>                }
>                // Should be final
>                protected void doStuff() {
>                }
>        }
>
>        public static class ClassB extends ClassA {
>                boolean TRUE = true;
>                protected void doStuff() {
>                        if (TRUE == false)
>                                throw new RuntimeException("TRUE == false!");
>                }
>
>        }
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


Back to the top