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.

ErroneousExceptionConversion.java 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // pr 44587
  2. import org.aspectj.testing.Tester;
  3. import org.aspectj.lang.NoAspectBoundException;
  4. public class ErroneousExceptionConversion {
  5. public static void main(String[] args) {
  6. try {
  7. new ErroneousExceptionConversion();
  8. Tester.checkFailed("Wanted an exception in initializer error");
  9. } catch (NoAspectBoundException nabEx) {
  10. // good
  11. // check nabEx.getCause instanceof RuntimeException and has explanation "boom..."
  12. Throwable cause = nabEx.getCause();
  13. if (!(cause instanceof RuntimeException)) {
  14. Tester.checkFailed("Should have a RuntimeException as cause");
  15. }
  16. } catch(Throwable t) {
  17. Tester.checkFailed("Wanted an ExceptionInInitializerError but got " + t);
  18. }
  19. }
  20. }
  21. aspect A {
  22. int ErroneousExceptionConversion.someField = throwIt();
  23. public static int throwIt() {
  24. throw new RuntimeException("Exception during aspect initialization");
  25. }
  26. public A() {
  27. System.err.println("boom in 5...");
  28. throw new RuntimeException("boom");
  29. }
  30. // if I change this to execution the test passes...
  31. after() throwing : initialization(ErroneousExceptionConversion.new(..)) {
  32. System.out.println("After throwing");
  33. }
  34. }