Community
Participate
Working Groups
when using intertype declaration, the compiler doesn't check for illegal modifier combinations such as "abstract synchronized". another manifestation of this problem is when using intertype declaration to add a synchronized method to an interface. the problem is more severe in this case because conceptually, this method is not abstract at all. interface Interface {} abstract class Parent {} class Child extends Parent implements Interface {} aspect Bug { // illegal modifier combination not caught by ajc public abstract synchronized void Parent._abstract(); public synchronized void Child._abstract() {} // the following has the same effect, but is easier to miss public /* implicit abstract */ synchronized void Interface._interface() {} // use Child to make java complain: "illegal modifiers: 0x421" // (this corresponds to "public abstract synchronized") public static void main(String[] args) { new Child(); } }
when making an automated test out of this code, notice that the failure only occurs at runtime.
it appears that the test case passes using the latest build.
oops, it isn't fixed after all (fails at runtime). my bad!
now fixed in tree. The abstract synchronized declaration on Parent is correctly disallowed. The synchronized declaration on the interface *is* allowed - it's both the declaration of an interface member and the declaration of the default implementation of that member. The types that receive the default member get a synchronized method, but the interface type of course should not (have the synchronized modifier on its method). And now it doesn't :).