Community
Participate
Working Groups
I'm executing the following snippet via AJDT based on 1.5.2 aspectj compiler. When compiled and executed, the target program functions well with the below given aspect. As FA and AbstractFGNode are in the same package, using default access for "nodeCount" should suffice. So, I removed the "public" modifier from the "CAUSE" statement. The compilation succeeded but the execution failed at "EFFECT" statement with the following exception. Unless my reasoning about access modifiers is incorrect, field injection and access should work. I am suspecting this is a bug in the compiler. Aspect ------ package edu.ksu.cis.indus.staticanalyses.flow; import edu.ksu.cis.indus.staticanalyses.flow.FA; import edu.ksu.cis.indus.staticanalyses.flow.AbstractFGNode; public final aspect ProfilingAspect { public static int AbstractFGNode.nodeCount = 0; // CAUSE private pointcut excludingAspect() : !within(ProfilingAspect); private pointcut nodeCreation() : initialization(AbstractFGNode.new(..)); after() : nodeCreation() { AbstractFGNode.nodeCount++; }; private pointcut FAanalyze() : (call(void FA.analyze(..))) && excludingAspect(); void around() : FAanalyze() { proceed(); System.out.println(AbstractFGNode.nodeCount + " number of nodes were created."); // EFFECT }; } Exception --------- Caused by: java.lang.NoSuchFieldError: nodeCount at edu.ksu.cis.indus.staticanalyses.flow.ProfilingAspect.ajc$inlineAccessFieldGet$edu_ksu_cis_indus_staticanalyses_flow_ProfilingAspect$edu_ksu_cis_indus_staticanalyses_flow_AbstractFGNode$nodeCount(ProfilingAspect.aj:1) at edu.ksu.cis.indus.staticanalyses.flow.ProfilingAspect.ajc$around$edu_ksu_cis_indus_staticanalyses_flow_ProfilingAspect$2$5847d8f2(ProfilingAspect.aj:32) at edu.ksu.cis.indus.staticanalyses.flow.AbstractAnalyzer.analyze(AbstractAnalyzer.java:111) at edu.ksu.cis.indus.staticanalyses.dependency.DependencyXMLizerCLI.analyze_aroundBody0(DependencyXMLizerCLI.java:424)
I am trying to recreate this but I dont seem to be able to. Are you able to give me a cut down variant of the ITD'd class? this works fine for me: ---8<---------- package a.b.c; public final aspect ProfilingAspect { static int AbstractFGNode.nodeCount = 0; // CAUSE private pointcut excludingAspect() : !within(ProfilingAspect); private pointcut nodeCreation() : initialization(AbstractFGNode.new(..)); after() : nodeCreation() { AbstractFGNode.nodeCount++; }; public static void m() { System.out.println(AbstractFGNode.nodeCount + " number of nodes were created."); // EFFECT } public static void main(String[] argv) { new Foo(); m(); } } abstract class AbstractFGNode {} class Foo extends AbstractFGNode {} ---8<----------
If it would be easier, then you can the actual ITD'd classes available in binary form (in jar files) from the Indus project (http://indus.projects.cis.ksu.edu).