Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nknapp/generic-reflection
A tool for handling generic classes at runtime
https://github.com/nknapp/generic-reflection
Last synced: 20 days ago
JSON representation
A tool for handling generic classes at runtime
- Host: GitHub
- URL: https://github.com/nknapp/generic-reflection
- Owner: nknapp
- Created: 2012-01-07T12:13:50.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-07-05T06:50:56.000Z (over 10 years ago)
- Last Synced: 2024-10-06T03:41:35.552Z (about 1 month ago)
- Language: Java
- Homepage:
- Size: 141 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
generic-reflection
==================While generic type information (type parameters as in `List`) is usually removed from java byte-code, there are some situations where it is still available.
When retrieving a field-type, method-return-type or method-parameter-type via reflection
(e.g. by calling [getGenericParameterTypes](http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#getGenericParameterTypes()),
a Type-object is available which contains information about the type parameter.This library currently contains only one class [ResolvedGenericType](src/main/java/org/knappi/opensource/genericreflection/ResolvedGenericType.java).
This class can be used to answer the following question:Given a class
Child
<X,Y>:
1. For a given X and Y what is the direct superclass of `Child` (including generic parameters)?
2. For a given X and Y what are the direct interfaces implemented by `Child` (including generic parameters)?
3. Given `Parent` a transitive generic superclass or generic interface of `Child`, what is T for `Child`?
4. Is `Child` assignable to `Parent`?The class only works in the simple case where type parameters are themselves concrete classes. Generics within type parameters
and parameters that are resolved from elsewhere won't work at the moment. Examples can be found in the test case
[ResolvedGenericTypeTest](src/main/test/org/knappi/opensource/genericreflection/ResolvedGenericTypeTest.java).