Bug 29105 - Intertype declaration exceptions are not checked at compile time
Summary: Intertype declaration exceptions are not checked at compile time
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 29106 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-01-07 14:14 EST by Doug Orleans CLA
Modified: 2003-01-07 16:39 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Orleans CLA 2003-01-07 14:14:42 EST
I'm using ajc 1.1b2 (the Version select box on this bug page only lets me select "unspecified").

If I have an intertype method declaration that throws a checked exception, and then call it without handing that exception, ajc will not complain, but the exception will be thrown at runtime.  Example:

class Foo {
  public static void main(String args[]) {
    Foo.bomb();
  }
}

aspect Bomb {
  public static void Foo.bomb() throws Exception {
    throw new Exception("KABOOM");
  }
}

Compiling these two files with ajc produces no compilation errors.
If instead I define bomb() directly in Foo, ajc complains as it should:

/home/dougo/daj/scratch/Foo.java:3: Unhandled exception type java.lang.Exception

I notice that the documentation for intertype declarations (member introductions) says:
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/apbs04.html#d0e5340

Modifiers Type TypePattern . Id(Formals) { Body }

Does this mean that "throws Exception" is not (yet) supported?  Or just a documentation oversight?

--Doug
Comment 1 Jim Hugunin CLA 2003-01-07 15:58:01 EST
fixed in current cvs tree, added as testcase to 
tests/bugs/ExceptionsOnInters.java

BTW - Having both this bug and 29106 both submitted was very helpful even 
though they were marked as duplicates are examining the root cause.
Comment 2 Jim Hugunin CLA 2003-01-07 16:39:38 EST
*** Bug 29106 has been marked as a duplicate of this bug. ***