aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs/ConvertToUnchecked.java
blob: 966bc69d3ae50ba6b744ef36718d6e95f0413d10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import org.aspectj.testing.Tester;

/** Bugzilla Bug 34925  
   compiler crash on yesterday's rc1 build 
 */
import java.io.*;

public aspect ConvertToUnchecked {
	
	public static void main(String[] args) {
		try {
			Foo foo = new Foo("hello");
			Tester.check(false, "shouldn't get here");
		} catch (PersistenceException pe) {
		}
	}
	
    // convert IOExceptions in Foo to PersistenceException
    pointcut module() : within(Foo);
  
	after() throwing (IOException e) : module() {
	   throw new PersistenceException(e);
	}
    declare soft: (IOException): module();
}

class PersistenceException extends RuntimeException 
{
	Throwable cause;
  public PersistenceException(Throwable cause) {
    this.cause = cause;
  }
}


class Root {
	Root(String s) /*throws IOException*/ {
	}
}

class Foo extends Root {
	Foo(String s) {
		super(s);
	}
	
	static {
		if (false) {
			getFile();
			throw new IOException("bar");
		}
		
	}
	
	{
		if (false) throw new IOException("bar");
	}
	
	File f = getFile();
	
	static File getFile() throws IOException {
		throw new IOException("bad");
	}
	
	
	public void m() {
		throw new IOException("hi");
	}
}