Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ConstructorExecInitFails.java 895B

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