Skip to main content

Blog Archive for forax during August 2006

In forum (fora) and blogs, i have often seen that closures are compared to anonymous classes in order to reject the proposed syntax of closure. In this entry, i try to show up why the closure syntax is such as it is by explaining the differences with the anonymous class syntax. Let me introduce an example that sort a list of integers in reverse order. There are two codes, one written...
Yes, this is another entry about closure :) In the closure proposal, the section "Closure conversion" describes how to use a closure instead of an anonymous class. The rules are : the implemented interface must have one method the closure signature must be a subtype of the method signature So let see if these rules are sufficient to use closures in order to implement AWT/Swing...
It's a recurring problem, you have a code that always generates an exception    public void throwIOException(int code) throws IOException {     throw new IOException(IO.getMessage(code));   }  and you use it in a method like this :    public int read() throws IOException {     int value=readAByte()  ...
I've read the proposal about function types and closures and i have noticed that the invocation of a function type will use the newly introduced bytecode invokedynamic (the gilad blog about invokedynamic) and i think i know why ! So let me introduce a small example of closure, the method transform applies a transformation on each item of an array and store the result in the same array....
While reading the JDBC 4.0 spec, i found a meta protocol mix in the way the spec specifies how to create an empty DataSet using the newly introduced query interface mecanism. But before let me introduce the context : JDBC 4 JDBC 4.0 introduces a new way to map a class to a result of a JDBC Query automagically. It's not a real O/R Mapper like hibernate or the one describes by the EJB3...