[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] java.lang.VerifyError with weaved call to protected super-aspect method

Ack!

Thank you very much for bringing this to our attention with a
most succinct test case.  I've gone ahead and added it to CVS:

   tests/bugs/protectedvf/...
   tests/ajcTestFailing.xml

(I hope you don't mind.)

Would you like to submit a bug, or shall I?  If you do,
please refer to the test case in bugs/protectedvf.

Wes

Daniel McAllansmith wrote:

I get a java.lang.VerifyError at runtime complaining about 'Bad access to protected data' when advice on a sub-aspect that calls a protected method on the super-aspect is woven into a class.
However another call to the same method woven into the same class but due to advice declared in the super-aspect works fine.


It seems to me that both should work.

I've had a quick look in the bug tracker but can't find anything.

I am using version 1.1.1 of the compiler. The aspects were woven into precompiled (by javac) classes.
The verify error occurs under both sun's 1.4 and blackdowns 1.3 VMs.


Following is a stack trace and some test files are attached.

Thanks
Daniel




Exception in thread "main" java.lang.VerifyError: (class: com/spinsoftware/test/p1/ConcreteTest, method: ajc$inlineAccessMethod$com_spinsoftware_test_p1_ConcreteTest$com_spinsoftware_test_p2_AbstractTest$getField signature: (Lcom/spinsoftware/test/p2/AbstractTest;)I) Bad access to protected data
at com.spinsoftware.test.Driver.doStuff(Driver.java)
at com.spinsoftware.test.Driver.main(Driver.java:18)



------------------------------------------------------------------------

package com.spinsoftware.test;

public class Driver{

	public static void main(String[] args) {
		Driver d = new Driver();
		d.doStuff();
		d.doOtherStuff();
	}

	private void doOtherStuff() {
		System.out.println("doing other stuff");
	}

	private void doStuff() {
		System.out.println("doing stuff");
	}
}


------------------------------------------------------------------------

package com.spinsoftware.test.p1;

import com.spinsoftware.test.p2.AbstractTest;
import com.spinsoftware.test.Driver;

final aspect ConcreteTest extends AbstractTest {

	protected pointcut pc(): execution(* Driver.doStuff());

	protected pointcut pc2(): execution(* Driver.doOtherStuff());

	Object around(): pc2() {
		System.out.println("adding to the other stuff");
		/*If we comment out the next line we don't get a verify error.*/
		System.out.println("The value of the field when replacing is " + getField());
		return proceed();
	}

	protected void hook() {
		/*This doesn't cause a verify error seemably because the advice calling it is in AbstractTest*/
		System.out.println("The value of the field is " + getField());
	}
}


------------------------------------------------------------------------

package com.spinsoftware.test.p2;

public abstract aspect AbstractTest {

	private int field;

	protected abstract pointcut pc();

	Object around(): pc() {
		this.field++;
		hook();
		return proceed();
	}

	protected final int getField() {
		return this.field;
	}

	protected abstract void hook();
}