In Java 5, the type system includes the interfaces:

  • java.lang.reflect.Type
  • java.lang.reflect.ParameterizedType
  • java.lang.reflect.WildcardType
  • java.lang.reflect.TypeVariable
  • java.lang.reflect.GenericArrayType
  • java.lang.reflect.GenericDeclaration

Have you ever tried to use those interfaces? It's not straight forward.

Imagine a class com.example.Bean has a method getList() that returns an object of type java.util.List. You want to know what type of object that list will contain. Is it a list of Objects? A list of Strings? Something else?

If we look at the source code, we might see:

List< ? extends CharSequence > getList() { /* ... */ }

But how do we get access to that information at runtime? You might think it's impossible, due to type erasure, but the information is actually there, it's just that it's hard to get to because of all those different ways of representing a type.

Orthodox makes it easy to get at that information (and much more).

At the moment it's a 0.5 release, because it hasn't had enough real world usage to be sure that the API is right. Since the whole point of orthodox is to put a better API on top of java.lang.reflect.Type, getting the API right is important. And I don't want to declare it a 1.0 release until I'm happy that I've achieved that.

However, don't let the 0.5 tag scare you into thinking it's unstable or untested - I've put it through its paces, and it works like a charm.