Bug 102212 - [itds] abstract synchronized: compile error expected
Summary: [itds] abstract synchronized: compile error expected
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-29 17:07 EDT by Samuel Gélineau CLA
Modified: 2005-09-02 10:38 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Gélineau CLA 2005-06-29 17:07:44 EDT
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();
  }
}
Comment 1 Samuel Gélineau CLA 2005-07-25 13:34:12 EDT
when making an automated test out of this code, notice that the failure only
occurs at runtime.
Comment 2 Samuel Gélineau CLA 2005-08-10 11:40:23 EDT
it appears that the test case passes using the latest build.
Comment 3 Samuel Gélineau CLA 2005-08-10 11:45:32 EDT
oops, it isn't fixed after all (fails at runtime). my bad!
Comment 4 Adrian Colyer CLA 2005-09-02 10:38:31 EDT
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 :).