narkisr / genericsfaction
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
de677bd
commit de677bdf7bc95ac4ea47df4e1e92efe4c2c71372
tree e36e256f303c7d20a563abca0729ee4310bb2b17
parent 56b6fc08ec541357ebb48420f67ce734ea42df89
tree e36e256f303c7d20a563abca0729ee4310bb2b17
parent 56b6fc08ec541357ebb48420f67ce734ea42df89
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
README.textile | ||
| |
cljtags/ | ||
| |
java-meta/ | ||
| |
playground/ | ||
| |
source-mining/ | ||
| |
validation/ |
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:
- @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
}
- 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 ..

