Announcing Squill: Not Another ORM

Tuesday, December 9th, 2008

Remember that post about Typesafe DSLs that had a part one and no follow up? Well, meanwhile Juhan Aasaru and yours truly were joined by Michael Hunger of jexp.de and JEQUEL and together we have created the Squill project that came right out of the ideas in the paper we wrote with Rein Raudjärv. The [...]



Concise EDSL Closures in Java

Monday, May 19th, 2008

This trick was pointed to me (without the ThreadLocal part) by Rein Raudjärv, who saw it used in jMock.
The problem with Java “closures” aka anonymous inner classes being a tad too ugly is a well known one, but this semi-solution seems to be quite unused. Although you can apply the same principle for many [...]



An embedded Java DSL for manipulating hierarchical JavaBeans

Saturday, April 26th, 2008

Just yesterday I was thinking on how to improve the DSLs I’m working on at the moment and got an idea, which wasn’t too useful in the context of SQL, but could be used for something else.
Imagine we have three JavaBeans (I’m omitting getters/setters for readability):
PLAIN TEXT
JAVA:

class Company {

  String name;

  Address address;

  Collection<Employee> employees;

}

 

class [...]



Typesafe ASM — problems solved?

Wednesday, March 26th, 2008

OK, I think I managed to solve both the primitive and the double slot problem introduced in the previous post. Basically I introduced another parametrized class — InvokeBuilder, which builds method invocations. The example now looks like this:
PLAIN TEXT
JAVA:

ClassWriter cw = new ClassWriter(COMPUTE_MAXS);

 

  new ClassBuilder(cw, V1_4, ACC_PUBLIC, “HelloWorld”, “java/lang/Object”, null)   

  .beginMethod(ACC_PUBLIC, “<init>”, [...]



Typesafe DSLs in Java: Part 1 — Typesafe Bytecode

Monday, March 24th, 2008

Domain Specific Languages (DSLs) have been brought to Java under the name of Fluent Interface. However most of them utilize a lot of strings and untyped behavior to make the interface fluent enough. It turns out that using Java 5 and a bag of tricks we can have the compiler to check a lot more. In this post we'll check out how to write Java bytecode using ASM in a typesafe way.