You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ConvertToUnchecked.java 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import org.aspectj.testing.Tester;
  2. /** Bugzilla Bug 34925
  3. compiler crash on yesterday's rc1 build
  4. */
  5. import java.io.*;
  6. public aspect ConvertToUnchecked {
  7. public static void main(String[] args) {
  8. try {
  9. Foo foo = new Foo("hello");
  10. Tester.check(false, "shouldn't get here");
  11. } catch (PersistenceException pe) {
  12. }
  13. }
  14. // convert IOExceptions in Foo to PersistenceException
  15. pointcut module() : within(Foo);
  16. after() throwing (IOException e) : module() {
  17. throw new PersistenceException(e);
  18. }
  19. declare soft: (IOException): module();
  20. }
  21. class PersistenceException extends RuntimeException
  22. {
  23. Throwable cause;
  24. public PersistenceException(Throwable cause) {
  25. this.cause = cause;
  26. }
  27. }
  28. class Root {
  29. Root(String s) /*throws IOException*/ {
  30. }
  31. }
  32. class Foo extends Root {
  33. Foo(String s) {
  34. super(s);
  35. }
  36. static {
  37. if (false) {
  38. getFile();
  39. throw new IOException("bar");
  40. }
  41. }
  42. {
  43. if (false) throw new IOException("bar");
  44. }
  45. File f = getFile();
  46. static File getFile() throws IOException {
  47. throw new IOException("bad");
  48. }
  49. public void m() {
  50. throw new IOException("hi");
  51. }
  52. }