java resource报错但不显示_java – Eclipse中没有出现的try-with-resources中的异常自我抑制错误...

Eclipse拥有自己的编译器并生成不同的输出. Eclipse编译的代码在调用

Throwable.addSuppressed之前检查被抑制的异常是否等于它自己.您可以使用javap工具查看.

请参阅Eclipse编译器输出中的if_acmpeq行.

JDK / javac输出:

public static void main(java.lang.String[]);

Code:

0: new #2 // class java/lang/RuntimeException

3: dup

4: ldc #3 // String My Exception

6: invokespecial #4 // Method java/lang/RuntimeException."":(Ljava/lang/String;)V

9: astore_1

10: new #5 // class TestDoubleThrow$1TestA

13: dup

14: aload_1

15: invokespecial #6 // Method TestDoubleThrow$1TestA."":(Ljava/lang/RuntimeException;)V

18: astore_2

19: aconst_null

20: astore_3

21: aload_1

22: athrow

23: astore 4

25: aload 4

27: astore_3

28: aload 4

30: athrow

31: astore 5

33: aload_2

34: ifnull 63

37: aload_3

38: ifnull 59

41: aload_2

42: invokevirtual #8 // Method TestDoubleThrow$1TestA.close:()V

45: goto 63

48: astore 6

50: aload_3

51: aload 6

53: invokevirtual #9 // Method java/lang/Throwable.addSuppressed:(Ljava/lang/Throwable;)V

56: goto 63

59: aload_2

60: invokevirtual #8 // Method TestDoubleThrow$1TestA.close:()V

63: aload 5

65: athrow

Exception table:

from to target type

21 23 23 Class java/lang/Throwable

41 45 48 Class java/lang/Throwable

21 33 31 any

Eclipse输出:

public static void main(java.lang.String[]);

Code:

0: new #16 // class java/lang/RuntimeException

3: dup

4: ldc #18 // String My Exception

6: invokespecial #20 // Method java/lang/RuntimeException."":(Ljava/lang/String;)V

9: astore_1

10: aconst_null

11: astore_2

12: aconst_null

13: astore_3

14: new #23 // class TestDoubleThrow$1TestA

17: dup

18: aload_1

19: invokespecial #25 // Method TestDoubleThrow$1TestA."":(Ljava/lang/RuntimeException;)V

22: astore 4

24: aload_1

25: athrow

26: astore_2

27: aload 4

29: ifnull 37

32: aload 4

34: invokevirtual #28 // Method TestDoubleThrow$1TestA.close:()V

37: aload_2

38: athrow

39: astore_3

40: aload_2

41: ifnonnull 49

44: aload_3

45: astore_2

46: goto 59

49: aload_2

50: aload_3

51: if_acmpeq 59

54: aload_2

55: aload_3

56: invokevirtual #31 // Method java/lang/Throwable.addSuppressed:(Ljava/lang/Throwable;)V

59: aload_2

60: athrow

Exception table:

from to target type

24 26 26 any

14 39 39 any

我使用的是JDK 8和Eclipse 4.4.

你可能感兴趣的:(java,resource报错但不显示)