fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone {
  6.  
  7. interface TestInterface <U> {
  8. void test (U u);
  9. }
  10.  
  11. static class Test <T extends Test<T>> implements TestInterface<T> {
  12. @Override public void test (T t) {
  13. throw new RuntimeException("My exception");
  14. }
  15. }
  16.  
  17. static class TestA extends Test<TestA> { }
  18. static class TestB extends Test<TestB> { }
  19.  
  20. public static void main (String[] args) throws Exception {
  21.  
  22. try {
  23. Test a = new TestA();
  24. Test b = new TestB();
  25. a.test(b);
  26. } catch (Exception x) {
  27. x.printStackTrace(System.out);
  28. }
  29.  
  30. try {
  31. TestInterface a = new TestA();
  32. Test b = new TestB();
  33. a.test(b);
  34. } catch (Exception x) {
  35. x.printStackTrace(System.out);
  36. }
  37.  
  38. try {
  39. TestInterface a = new TestA();
  40. TestInterface b = new TestB();
  41. a.test(b);
  42. } catch (Exception x) {
  43. x.printStackTrace(System.out);
  44. }
  45.  
  46. }
  47.  
  48. }
Success #stdin #stdout 0.07s 3359744KB
stdin
Standard input is empty
stdout
java.lang.RuntimeException: My exception
	at Ideone$Test.test(Main.java:13)
	at Ideone.main(Main.java:25)
java.lang.RuntimeException: My exception
	at Ideone$Test.test(Main.java:13)
	at Ideone$Test.test(Main.java:11)
	at Ideone.main(Main.java:33)
java.lang.RuntimeException: My exception
	at Ideone$Test.test(Main.java:13)
	at Ideone$Test.test(Main.java:11)
	at Ideone.main(Main.java:41)