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.

InstanceOf.java 1.4KB

1234567891011121314151617181920212223242526272829303132
  1. import org.aspectj.testing.Tester;
  2. public class InstanceOf {
  3. public static void main(String[] args) {
  4. Tester.expectEvent("instanceOf");
  5. new TargetClass().instanceOf();
  6. Tester.checkAllEvents();
  7. }
  8. }
  9. aspect InstanceOfAspect {
  10. /** @testcase Introduced type unavailable to instanceof expressions in introduced methods */
  11. public void TargetClass.instanceOf() {
  12. /* expecting compiler error,
  13. but only getting compiler warnings and generated class?
  14. -> needs work
  15. */
  16. // -------- RuntimeException: "Unsupported emit on NotFoundType" Type.java:460
  17. if (!((getboolean()) instanceof boolean)) { Util.fail("boolean"); }
  18. if (!((getchar()) instanceof char)) { Util.fail("char"); }
  19. if (!((getbyte()) instanceof byte)) { Util.fail("byte"); }
  20. if (!((getshort()) instanceof short)) { Util.fail("short"); }
  21. if (!((getint()) instanceof int)) { Util.fail("int"); }
  22. if (!((getlong()) instanceof long)) { Util.fail("long"); }
  23. if (!((getfloat()) instanceof float)) { Util.fail("float"); }
  24. if (!((getdouble()) instanceof double)) { Util.fail("double"); }
  25. // ------ todo: expecting error, get RuntimeException
  26. //if (!((doVoid()) instanceof Void)) { Tester.check(false,"void"); }
  27. Util.signal("instanceOf");
  28. }
  29. }