<div dir="ltr"><div style="font-family:monospace" class="gmail_default"></div><div dir="ltr"><div class="gmail_default" style="font-family:monospace">Whoops, I meant core-libs, not client libs. I always mix up the 2.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Copy pasting below, so that people don't have to read the butchered version that pipermail spits out.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">
<div class="gmail_default" style="font-family:monospace">Hello Amber Dev Team, Client Lib Team, and Compiler Dev Team,</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">In
the vein of smoothing the on-ramp for beginners, one of the biggest
pain points I have found when tutoring beginners is when they start to
learn generics, and then do something like this.</div><div style="font-family:monospace" class="gmail_default"></div><div style="font-family:monospace" class="gmail_default">import java.util.*;<br><br>public class abc<br>{<br><br> public static void main(final String[] args)<br> {<br><br> final Map<String, Integer> cache = new HashMap<>();<br><br> final int result = updateCache(cache, "abc", 123);<br><br> System.out.println(result);<br><br> }<br><br>
public static <String, Integer> Integer updateCache(final
Map<String, Integer> cache, final String key, final int value)<br> {<br><br> return cache.put(key, Integer.valueOf(value));<br><br> }<br><br>}<br></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">$ javac abc.java<br>abc.java:21: error: cannot find symbol<br> return cache.put(key, Integer.valueOf(value));<br> ^<br> symbol: method valueOf(int)<br> location: class Object<br>1 error<br></span></div><div><span style="font-family:monospace"><br></span></div><div class="gmail_default" style="font-family:monospace">This
type of error is the worst because it sends them on the wildest goose
chase. They start coming up with the most eldritch deductions as to what
could possibly be wrong, and they start actively unlearning stuff that
they know to be true. When I finally show them what is wrong, it's
already too late because (1) they start doubting the foundations because
the "clearly correct" solution doesn't work for a non-obvious reason,
and (2) they usually picked up some incorrect assumptions along the way
that neither of us have realized yet.<br></div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">And
the worst part is that, if you removed the "Integer.valueOf", and then
changed the third parameter to be final Integer value instead of final
int value, then the code compiles and works as expected. So, the student
can actually go pretty far before code starts breaking. That is the
absolute worst because they start turning this style of coding into a
habit and then when it finally blows up, all of their progress has to be
undone. They feel defeated, they hate the feature, they lose
motivation, and now I have to work triple time to rebuild all of that.
It's a terrible time for everyone involved.<br></div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Could
we add a lint option that turns this into a warning? Basically says, if
you put an alias for a parameterized type that also happens to be an
exact match for an already imported class, throw a warning upon compile?
Then, this issue can be caught at compile time the second that they
introduce it. When they ask me about the warning, I can immediately
explain the problem, and this entire fiasco is avoided.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Finally,
I also type up this email because this can be kind of easy to miss when
you are quickly cycling back and forth between students, trying to make
sure everyone is good. I don't have that many now, but back when it was
double digits, I distinctly remember falling into this pothole multiple
times.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Any thoughts on this feature?</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Thank you for your time and consideration!</div><font color="#888888"><div class="gmail_default" style="font-family:monospace">David Alayachew</div></font>
</div></div></div>