lundi 23 février 2015

Java erased -> compile time type alignment - or Java Library/Framework code transitioning to application logic



I am Working on a configuration scenario for a complex distributed OSGi system.


I need to make the following transition at runtime on Java 7 (this code below is incorrect):



void someFrameworkMethod(...) {
....
// arg 2 is of type Object
// service is of type SimpleStrongTypedManagedService<?>
updateSimple( service, entry.getValue(), desc.getClazz());
....
}

private <T> void updateSimple( SimpleStrongTypedManagedService<T> service,
T value,
Class<T> clazz) {
...
}


I have access to the clazz in question. Are there any tricks to get the compiler to "read my mind"(what I am trying to do above) or am I going to have to do reflection / MethodHandle trickery ?




Aucun commentaire:

Enregistrer un commentaire