/test/kilim/test/ex/ExInvalid.java

http://github.com/kilim/kilim · Java · 80 lines · 63 code · 9 blank · 8 comment · 0 complexity · 3c387dcee9b42c18938cfa636e7d2ec6 MD5 · raw file

  1. package kilim.test.ex;
  2. import kilim.Pausable;
  3. import kilim.Task;
  4. // Just a ununsed public class to make it easy to have a bunch of related test
  5. // classes in one file
  6. public class ExInvalid {
  7. }
  8. class ExInvalidConstructor {
  9. ExInvalidConstructor() throws Pausable {}
  10. }
  11. class ExInvalidConstructor2 {
  12. ExInvalidConstructor2() throws Exception {
  13. Task.sleep(1000);
  14. }
  15. }
  16. class ExInvalidConstructor3 {
  17. ExInvalidConstructor3() throws Pausable {
  18. Task.sleep(1000);
  19. }
  20. }
  21. class ExInvalidStaticBlock {
  22. static void foo() throws Pausable {}
  23. static {
  24. try { foo(); }
  25. catch (Exception ex) {}
  26. }
  27. }
  28. class ExInvalidCallP_NP {
  29. void foo() throws Pausable {}
  30. void bar() throws Exception {
  31. foo();
  32. }
  33. }
  34. // illegal to override a non-pausable method with a pausable one
  35. class ExNPSuper {
  36. void foo() throws Exception {}
  37. }
  38. class ExInvalidPDerived extends ExNPSuper {
  39. void foo() throws Pausable {}
  40. }
  41. //illegal to override a pausable method with a non-pausable one
  42. class ExPSuper {
  43. void foo() throws Pausable {}
  44. }
  45. class ExInvalidNPDerived extends ExPSuper {
  46. void foo() {
  47. }
  48. }
  49. //------------------------------------------------
  50. // Illegal to override an pausable interface method with a non-pausable one
  51. interface ExPFoo {
  52. void foo() throws Pausable;
  53. }
  54. interface ExInvalidNPFace extends ExPFoo {
  55. void foo();
  56. }
  57. class ExInvalidNPImp implements ExPFoo {
  58. public void foo() {
  59. }
  60. }
  61. //------------------------------------------------
  62. //Illegal to override a non-pausable interface method with a pausable one
  63. interface ExNPFoo {
  64. void foo() throws Exception;
  65. }
  66. class ExInvalidPImp implements ExNPFoo {
  67. public void foo() throws Pausable {}
  68. }
  69. interface ExInvalidPFace extends ExNPFoo {
  70. void foo() throws Pausable;
  71. }