Tag Archives: java7

Prefer try-with-resources over try-finally

The try-finally construction in Java is often used to close the resources. Finally block will be always executed, so no matter what has happened in the ‘try’ block, the file or connection will always be closed. However, since Java7, there is an easier and more succinct way to do it – try-with-resources. Not only does […]

Read more

Java invokedynamic

Invokedynamic is a JVM bytecode instruction for invoking methods, which facilitates runtime type checking. Before invokedynamic was introduced in Java 1.7, we had 4 opcodes for calling methods: invokevirtual – used for public and protected instance methods invokestatic – used for static methods invokeinterface – used for methods call through an interface invokespecial – used […]

Read more