Parameterized Types
James Falkner
james.falkner at liferay.com
Tue Oct 27 23:48:46 UTC 2015
Hey all,
Currently @ JavaOne enjoying the Nashorn talks. But I have a question.
Is it possible to create extended classes using parameterized types?
What I want to do is create these:
class SomeClass extends SomeBaseClass<SomeType> {
...
}
I know parameterized types are mostly a compile-time thing, but they are
encoded into the class bytes and can be accessed in Java using:
ParameterizedType t = (ParameterizedType) clazz.getGenericSuperclass();
Type[] types = parameterizedType.getActualTypeArguments();
So I was wondering if it was possible to instantiate a concrete Java
class from Javascript such that it would appear just as though I had
created it as above?
Using Java.type() and Java.extend() doesn't seem to create the class in
the same way as the Java code with Parameterized types. Thanks!
-James
More information about the nashorn-dev
mailing list