This post originated from an RSS feed registered with Java Buzz
by Tim Vernum.
Original Post: Announce - Orthodox Type Reflection Library
Feed Title: A word used to describe something
Feed URL: http://blog.adjective.org/feed/category/Development/rss2
Feed Description: Tim's random musings on software development, java, jetty and other such frivolities.
Prior to the release of Java 5, the Java library had 1 class that provided
access to type information at runtime - java.lang.Class. However, with the
introduction of generics in Java 5, this has been extended significantly.
Dealing with all these classes, and working with them at runtime, is overly
complex, and reduces the power of generics.
Orthodox is a library that
makes it easier to work with the Java type system at runtime.
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?
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.