public
Description: Making Java Generics meta data available on runtime
Homepage:
Clone URL: git://github.com/narkisr/genericsfaction.git
README.textile

Type erasure removes all type meta data from Java’s byte code, this means that the following is valid in runtime:

public static void addTo(List list, Object value){
    list.add(value);
}

public static void main(String [] args){
List list = new ArrayList();
addTo(list,“not legel”);// there is no way to validated this on runtime
}

This project attempts to make types meta data available in runtime by enriching the AST before the source code gets compiled.

At the moment there are two types of enrichments:

  1. @GenMeta annotation which is added on method input parameters:
public void twoTypeParamsMet(@GenMeta(stringRep = "((Object ()) (Object ()))", classes = { Object.class, Object.class }) Map<Object, Object> map) {
   // method code
}
  1. Proxy meta which is added on initialization expressions (annotation on local variable are not retained) :
 public static void main(String [] args) {
   List<Integer> list = (List <Integer>)MetaProxy.newInstance(new ArrayList<Integer>(),"(Integer ())",new Class []{Integer.class});
 }

Note that meta is added only for resolvable type (no wild card types).

Usage TBD ..