Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] around advice not matching with finalize method

Hi all,

    I'm trying to write an aspect for controlling every custom classes
loaded. So, i've written a pointcut to exclude th system classes:

    public pointcut SystemExclusions() : !within(weblogic..*) &&
!within(sun..*) && !within(org.apache..*) && !within(com.ibm..*) &&
!within(*..*ogger*..*) 
    && !within(AbstractMonitor+) && !within(glassbox..*) &&
!within(org.aspectj..*) && !within(net.sf.hibernate..*)
    && !within(com.rsa..*) && !within(org.jboss..*) &&
!within(org.eclipse..*) && !within(org.osgi..*) &&
!within(com.bea.console..*)
    && !within(edu.emory.mathcs.util..*) && !within(uk.ltd.getahead.dwr..*)
&& !within(org.hsqldb..*) && !within(org.spring*..*);

    And another one for capturing the classes load:

    /* Clases */
    after() returning(Object o): call(!static Object+.new(..)) && this(*) &&
SystemExclusions()
    {
        //String key = findClassName(thisJoinPointStaticPart.toString());
        String key = o.getClass().getName();
        if(LocalDebug && false) System.err.println("[Pilux-Lucierna***] Se
ha cargado una instancia de la clase: " + key); 
        registerInstanceLoad(key, false);
        iterationsOcurred.increment();
        if (iterationsOcurred.getValue() >= dumpFrequency)
            reportConsoleOperations();
    }

    This is working fine, but for decrease the loaded classes counter, i'm
trying to capture the finalize() execution method, with this advice:

    void around(Object o) : execution(!static * finalize(..)) && this(o)
    {
        String key = o.getClass().getName();
        if(LocalDebug) System.err.println("[Pilux-Lucierna***] Se ha
descargado una instancia de la clase: " + key); 
        registerInstanceLoad(key, true);
        iterationsOcurred.increment();
        if (iterationsOcurred.getValue() >= dumpFrequency)
            reportConsoleOperations();
        proceed(o);
    }

    I've overloaded a finalize() method from a custom class to force a
message console when the gc() calls it, and the method is currently running,
but for any reason is not matching my pointcut. I'm running in an evironment
with several aspects running, I don't know if this matter. Somebody can help
me, please? I'll be very grateful!!!

Thanks!
Regards, Federico.
-- 
View this message in context: http://www.nabble.com/around-advice-not-matching-with-finalize-method-tp23775987p23775987.html
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top