我是一名 .net 开发人员。最近,我对比较 Java 和 C# 产生了兴趣。我发现 Java 的 try-with-resources 相当于 C# 的 using 块。但是,我并不能完全理解它。我知道 C# 的 using 块是一种语言特性,编译器会为其生成代码。我想更深入地了解 try-with-resources,并有一些问题:
Is it a langauge feature similar to C#'s using block?
What is the equivalent JDK 6 code for the following:
try(SomeResource resource = new SomeResource()) { //Some logic }
What is the equivalent JDK 6 code for the following:
try(SomeResource resource = new SomeResource()) { //Some logic } catch(SomeException ex) { }
What is Java equivalent of C#'s Reflector or ILSpy tool? i.e. tool to disassemble Java byte code class files and view Java code of it.