Bug 326399 - advice may throw checked exceptions at handler joinpoints in contexts that cannot handle these exceptions
Summary: advice may throw checked exceptions at handler joinpoints in contexts that ca...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-28 07:21 EDT by Eric Bodden CLA
Modified: 2010-09-28 07:21 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Bodden CLA 2010-09-28 07:21:02 EDT
Currently, the following code compiles, but it rather should not. The problem is that the before advice declares to throw a checked exception but is woven into a context that does not handle this exception: there is no try/catch block, and neither does foo declare the Exception in its signature.

import java.io.IOException;

public aspect A {
	
	
	before() throws Exception: handler(IOException) {
		throw new Exception("gotcha!");
	}
	
	public static void foo() {
		try {
			throw new IOException();
		} catch (IOException e) {
			
		}
	}
	
	public static void main(String[] args) {
		foo();
	}

}

The problem is correctly handled for other pointcuts like "call", but not for "handler". (static/pre)initialization pointcuts may be problematic, too.