3 ms·
After 20 years, first in Java and then in Scala I've been tortured by this error message. Some years ago they fixed ClassCastException which for a long time als
by _Codemonkeyism 8y ago
After 20 years, first in Java and then in Scala I've been tortured by this error message. Some years ago they fixed ClassCastException which for a long time also didn't tell you what was wrong. There are some others if I remember correctly with bad error messages, like NumberFormatException. In general error messages on the JVM are very bad, wish they would take a look at Elm error messages.
I've left this year the JVM for TS, but glad for everyone who uses the JVM.
- hnthroaway1926 8y agoThe default compiler options for java provide a lot of information on null pointer exceptions. I'm sort of blown away that so many on this thread are confounded by NPEs, in my view they are dead simple to track down if you have access to the source.
- _Codemonkeyism 8y agoAs I'm running a legacy larger Scala app, what would that compiler options be? e.g. for the line service.withName(customer.getName().firstName); with a NPE in line 25?
- hnthroaway1926 8y agoBreak out the line into multiple lines... String s = customer.getName().firstName; service.withName(s);
- wtetzner 8y agoSo the answer is rewrite your code to work around tooling deficiencies? I'd prefer this be fixed in the JVM, so you can decide to write your code in the way that's most readable, and not be forced to write it a certain way because the tools suck.
- _Codemonkeyism 8y agoYes, this is what I'll need to do every time, which is crazy to adapt your code to the tools and then back again. And it's even val n = customer.getName() val f = n.firstName service.withname(f) Gladly with Some/None NPEs happen seldom with Scala but they do from interfacing with Java libs from time to time.