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.

ConstructorExecInitFails.java 732B

1234567891011121314151617181920212223242526
  1. import org.aspectj.testing.*;
  2. /**
  3. * -usejavac mode: no error
  4. * not -usejavac mode: VerifyError
  5. */
  6. public class ConstructorExecInitFails {
  7. public static void main(String[] args) {
  8. try {
  9. new ConstructorExecInitFails();
  10. } catch (ExceptionInInitializerError e) {
  11. return;
  12. }
  13. Tester.checkFailed("shouldn't be able to run");
  14. }
  15. }
  16. /** @testcase after returning from initialization and after executing constructor */
  17. aspect A {
  18. after (Object target) : execution(*.new(..)) && target(target) {
  19. Tester.checkFailed("shouldn't be able to run");
  20. }
  21. after () returning (Object target) : initialization(new(..)) {
  22. Tester.checkFailed("shouldn't be able to run");
  23. }
  24. }