<html> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> </head> <body bgcolor="#FFFFFF" text="#000000"> Le 18/10/14 04:40, Werner Keil a écrit :<br> <blockquote cite="mid:CAAGawe26FyBi+bKWDpKJtDnnK2p60QWvdRx= " type="cite"> <div dir="ltr">I asked the guys from the Eclipse IoT project how they feel about having to cast based on the current wildcard, if they have a strong opinion, we'll see.</div> </blockquote> <p>Werner, can we see the question that you asked to them? I would like to check if you finally understood the problem.</p> <br> <blockquote cite="mid:CAAGawe26FyBi+bKWDpKJtDnnK2p60QWvdRx= " type="cite"> <div dir="ltr">While asType() causes fewer problems now under SE 8, seems, it never preserved the target type either<img src="cid:part1.06030707.06070008@geomatys.fr" goomoji="35F" style="margin: 0px 0.2ex; vertical-align: middle;"><br> </div> </blockquote> What do you mean? The JScience 5 code that you pasted shows that <tt>asType(Class)</tt> does its job, which is to throw a <tt>ClassCastException</tt> at runtime if the type is wrong. The <tt>asType(Class)</tt> purpose has never been to provide compile-time safety. <div class="gmail_extra"><br> </div> <blockquote cite="mid:CAAGawe26FyBi+bKWDpKJtDnnK2p60QWvdRx= " type="cite"> <div dir="ltr"> <div class="gmail_extra">Running a ReflectionDemo to get the actual generic type Q (this would only work with a trick of storing it in the constructor, but that required concrete classes for every case, no <?> or so)</div> </div> </blockquote> What are you trying to do with this ReflectionDemo? It has nothing to do with what I suggested (<tt>java.lang.reflect.Proxy</tt> as a way to provide Quantity implementations for all subtypes).<br> <br> <blockquote cite="mid:CAAGawe26FyBi+bKWDpKJtDnnK2p60QWvdRx= " type="cite"> <div dir="ltr">Naively speaking, one could have expected anotherUnit to have an actual type argument of Volume, but it it Q instead.</div> </blockquote> So you are just starting to discover the meaning of "type erasure", at last.<br> <br> <blockquote cite="mid:CAAGawe26FyBi+bKWDpKJtDnnK2p60QWvdRx= " type="cite"> <div dir="ltr"> <div class="gmail_extra"> <div class="gmail_extra"> <div>Is that, how asType() should work?</div> </div> </div> </div> </blockquote> No reflection. Only something like a <tt>Map<Class<Quantity<?>>, Dimension></tt> somewhere. Or a <tt>Map<Class<Quantity<?>>, Unit<?>></tt> where the unit is the system unit (not all possible units of that quantity - only the system unit). Unit compatible with that one are considered valid.<br> <br> Anyway, this is an implementation question, while UNITSOFMEASUREMENT-62 is a Java language problem.<br> <br> <br> <blockquote cite="mid:CAAGawe26FyBi+bKWDpKJtDnnK2p60QWvdRx= " type="cite"> <div dir="ltr"> <div class="gmail_extra"> <div>Let's see, what the Eclipse stakeholders say, I hope the question did not scare them?<img src="cid:part2.02040802.07050008@geomatys.fr" goomoji="329" style="margin: 0px 0.2ex; vertical-align: middle;"></div> </div> </div> </blockquote> It depends how you explained the problem to them, which I would like to see...<br> <br> Martin<br> <br> </body> </html>
Attachment:
gif_9WG4ZbOJ3.gif
Description: GIF image
Attachment:
gifVWP5A3wX77.gif
Description: GIF image