Skip to main content

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

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!");
		}
		
	}


Back to the top