<div dir="ltr"><div><div><div><div>OK, that's another edge case then.</div><br>> The use of raw type like <span style="font-family:monospace">Foo</span> "rawifies" all the methods in class Foo.<br><br></div>I can't help but think this is a weird default but I am sure there are excellent reasons why this solution was chosen, so I am not going to argue about it.<br></div>At least, this is a good nudge to make people write the right code since it's easy to work around :)<br><br></div>Thank you!<div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Jun 10, 2025 at 6:07 PM Archie Cobbs <<a href="mailto:archie.cobbs@gmail.com">archie.cobbs@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Following up on what Maurizio said. There is an important difference between <span style="font-family:monospace">Foo</span> and <span style="font-family:monospace">Foo<?></span>.  The use of raw type like <span style="font-family:monospace">Foo</span> "rawifies" all the methods in class Foo.</div><div><br></div><div>Here's a simpler reproducer:</div><div><br></div><div style="margin-left:40px"><span style="font-family:monospace">import java.net.http.HttpResponse;<br>import java.util.Optional;<br>import javax.net.ssl.SSLSession;<br><br>public class Main2 {<br>    void m1(HttpResponse r) {<br>        Optional<SSLSession> s = r.sslSession();  // unchecked warning here<br>    }<br>    void m2(HttpResponse<?> r) {<br>        Optional<SSLSession> s = r.sslSession();  // no warning here<br>    }<br>}<br></span></div><div><br></div><div>See also <a href="https://stackoverflow.com/a/11007894/263801" target="_blank">this stackoverflow answer</a>.</div><div><br></div><div>-Archie</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 10, 2025 at 10:51 AM Jean-Noël Rouvignac <<a href="mailto:jean-noel.rouvignac@pingidentity.com" target="_blank">jean-noel.rouvignac@pingidentity.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,</div><div><br></div><div>When doing refactorings to take advantage of newer Java features, I hit a new and weird edge case. I trimmed down the code several times, and ended up with the following tiny reproducer, and I don't understand what javac is complaining about even with javac 24:<br><div><div><br></div><div>(Note: unlike the original code, this reproducer is very contrived, 
so there's no need to make comments on how bad it is: I fully agree)</div></div><br>```java<br>1 import java.util.ArrayList;<br>import java.util.List;<br>import java.util.stream.Collectors;<br><br>public class Main {<br>    private static final class Child<T> {<br>        public List<String> getValues() {<br>            return new ArrayList<>();<br>        }<br>    }<br><br>    @SuppressWarnings("unchecked")<br>    private static String getString1(Child c) {<br>        // Compilation error:<br>        // Main.java:16: error: incompatible types: Object cannot be converted to String<br>        return c.getValues().stream().collect(Collectors.joining());<br>    }<br><br>    private static String getString2(Child c) {<br>        // Compilation error:<br>        // Main.java:27: warning: [unchecked] unchecked conversion<br>        //        List<String> values = c.getValues();<br>        //                                         ^<br>        //  required: List<String><br>        //  found:    List<br>        //1 warning<br>        List<String> values = c.getValues();<br>        return values.stream().collect(Collectors.joining());<br>    }<br>}<br>```<br><br>It turns out IntelliJ is a bit more eloquent than javac, and when hovering over the warning on `c.getValues()` at the line with `List<String> values = c.getValues();`, it reports the following:<br><br>>    Unchecked assignment: 'java.util.List' to 
'java.util.List<java.lang.String>'. Reason: 'c' has raw type, so 
result of getValues is erased <br><br></div><div>Is it possible that javac is doing early type erasure when analysing this code, erasing a bit too much? Even if the code uses `Child` without type argument, I would expect the return type of `getValues()` to be well defined as `List<String>`?<br><br></div><div>What do you think?<br></div><div>I am sure there is some rational explanation that I missed for this behaviour. I could not find a JBS issue showing the same case as here.</div><div><br></div><div>Thank you,</div><div>Jean-Noël Rouvignac</div></div>

<br>
<i style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background:rgb(255,255,255);font-family:proxima-nova-zendesk,system-ui,-apple-system,system-ui,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif;color:rgb(85,85,85)"><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background:transparent;font-family:proxima-nova-zendesk,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif;font-weight:600"><font size="2">CONFIDENTIALITY NOTICE: This email may contain confidential and privileged material for the sole use of the intended recipient(s). Any review, use, distribution or disclosure by others is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by e-mail and delete the message and any file attachments from your computer. Thank you.</font></span></i></blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div>
</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><table style="border-collapse:collapse;padding:0px;margin:0px"><tbody><tr><td style="width:113px"><a href="https://www.pingidentity.com/" target="_blank"></a><a href="https://www.pingidentity.com/" target="_blank"></a><a href="https://www.pingidentity.com/" target="_blank"><img alt="Ping Identity" src="https://www.pingidentity.com//content/dam/picr/img/em/ping-logo.png"></a></td><td><table><tbody><tr><td style="vertical-align:top"><span style="color:rgb(230,29,60);display:inline-block;margin-bottom:3px;font-family:arial,helvetica,sans-serif;font-weight:bold;font-size:14px">Jean-Noel Rouvignac</span><br><span style="display:inline-block;margin-bottom:2px;font-family:arial,helvetica,sans-serif;font-size:14px">Senior Principal Software Engineer</span><br><span style="font-family:arial,helvetica,sans-serif;font-size:14px;display:inline-block;margin-bottom:3px"><font color="#1530f9"><a href="mailto:jean-noel.rouvignac@pingidentity.com" target="_blank">jean-noel.rouvignac@pingidentity.com</a></font><br><span style="display:inline-block;margin-bottom:2px"></span><br style="font-family:Times;font-size:medium"><span style="display:inline-block;margin-bottom:2px"></span></span></td></tr></tbody></table></td></tr><tr><td colspan="2"><table style="border-collapse:collapse;border:medium;margin:8px 0px 0px;width:408.938px"><tbody><tr style="height:40px;border-top:1px solid rgb(211,211,211);border-bottom:1px solid rgb(211,211,211)"><td style="font-family:arial,helvetica,sans-serif;font-size:14px;font-weight:bold;color:rgb(64,71,75)"><a href="https://www.pingidentity.com/en/events/youniverse.html" target="_blank"></a><a href="https://www.pingidentity.com/en/events/youniverse.html" target="_blank"></a><a href="https://www.pingidentity.com/en/events/youniverse.html" target="_blank"></a><a href="https://www.pingidentity.com/en/gartner-magic-quadrant-access-management.html?utm_medium=email" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/virtualsummit.html?utm_source=sales&utm_medium=email&utm_campaign=VFE-GLOBAL-2025.03.18-19-PingVirtualEvent" target="_blank"></a><a href="https://www.pingidentity.com/en/events/youniverse.html" target="_blank"><img style="height: 106px; width: 410px;" src="https://www.pingidentity.com/content/dam/picr/img/em/2025-YOUniverse-EmailSig.jpg"></a><br><div style="padding:0px;margin:0px"><table style="border-collapse:collapse;padding:0px;margin:0px"><tbody><tr><td colspan="2"><table style="border-collapse:collapse;border:medium;margin:8px 0px 0px;width:408.938px"><tbody><tr style="height:40px;border-top:1px solid rgb(211,211,211);border-bottom:1px solid rgb(211,211,211)"><td style="font-size:14px;font-weight:bold;color:rgb(64,71,75)">Connect with us:</td><td style="padding:4px 0px 0px 20px"><a href="https://www.glassdoor.com/Overview/Working-at-Ping-Identity-EI_IE380907.11,24.htm" title="Ping on Glassdoor" style="margin-right:16px;display:inline-block" target="_blank"><img src="https://www.pingidentity.com/content/dam/picr/img/em/social-glassdoor.png" alt="Glassdoor logo" style="border: medium; margin: 0px; display: inline-block;"></a><a href="https://www.linkedin.com/company/21870" title="Ping on LinkedIn" style="margin-right:16px;display:inline-block" target="_blank"><img src="https://www.pingidentity.com//content/dam/picr/img/em/social-linkedin.png" alt="LinkedIn logo" style="border: medium; margin: 0px; display: inline-block;"></a><a href="https://twitter.com/pingidentity" title="Ping on Twitter" style="margin-right:16px;display:inline-block" target="_blank"><img src="https://www.pingidentity.com//content/dam/picr/img/em/social-twitter.png" alt="Twitter logo" style="border: medium; margin: 0px; display: inline-block;"></a><a href="https://www.youtube.com/user/PingIdentityTV" title="Ping on YouTube" style="margin-right:16px;display:inline-block" target="_blank"><img src="https://www.pingidentity.com//content/dam/picr/img/em/social-youtube.png" alt="YouTube logo" style="border: medium; margin: 0px; display: inline-block;"></a><a href="https://www.pingidentity.com/en/blog.html" title="Ping Blog" style="margin-right:16px;display:inline-block" target="_blank"><img src="https://www.pingidentity.com//content/dam/picr/img/em/social-blog.png" alt="Blog logo" style="border: medium; margin: 0px; display: inline-block;"></a></td></tr></tbody></table></td></tr></tbody></table><div style="padding:0px;margin:0px"><span style="font-family:Arial,sans-serif;font-size:12px"><font color="#787878">To view our privacy policy, click </font><a href="https://www.pingidentity.com/en/legal/privacy.html" style="text-decoration:underline" target="_blank"><font color="#1255cd">here</font></a><br></span></div><div style="padding:0px;margin:0px"><span style="font-family:Arial,sans-serif;font-size:12px"><font color="#787878">To stop receiving these emails, click </font><a href="https://4.pingidentity.com/PreferenceCenter.html" style="text-decoration:underline" target="_blank"><font color="#1255cd">here</font></a></span></div></div></td></tr></tbody></table></td></tr></tbody></table></div>

<br>
<i style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background:rgb(255,255,255);font-family:proxima-nova-zendesk,system-ui,-apple-system,system-ui,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif;color:rgb(85,85,85)"><span style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background:transparent;font-family:proxima-nova-zendesk,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",Arial,sans-serif;font-weight:600"><font size="2">CONFIDENTIALITY NOTICE: This email may contain confidential and privileged material for the sole use of the intended recipient(s). Any review, use, distribution or disclosure by others is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by e-mail and delete the message and any file attachments from your computer. Thank you.</font></span></i>