r/java • u/candrewswpi • Apr 26 '21
Fixing a Bug in Java
https://candrews.integralblue.com/2021/04/fixing-a-bug-in-java/11
u/agentoutlier Apr 26 '21
I can't believe I ran into this bug in manner very similar to the author and just assumed it was the expected behavior. I didn't bother to go read the actual doc of getResource to check and didn't think much of it partly because it was a RuntimeException (IllegalArgument).
IIRC I just wrapped getResource so that if it returned null or threw any exception (which is a bad idea but whatever) I would throw IOException as it fit in to what I was doing at that time.
4
u/jokubolakis Apr 26 '21
It's interesting, how many bugs we may let through, by just treating this sort of stuff as "as intended". Very nice that the author dug deeper
1
u/amblins Apr 26 '21
I was just thinking the same thing. There's a few instances where we have services that clone other projects into directories specified by application.yml properties and I've always directed people running it on windows to use double backslashes (I probably found that from this issue).
5
u/jack104 Apr 26 '21
Great read, I really liked the link to the testing on windows without windows article.
4
u/AryanPandey Apr 26 '21
thanks, just bookmarked it, i also wanted to contribute in openJDK in future, kinda like dream.
3
u/sansp00 Apr 26 '21
I've stumbled upon this bug a couple of times, never had time to fully investigate it and assumed either the me/coder did not do it properly or the framework (Spring or other) wasn't working properly. Never dug deeper to figure out it was actually a JVM bug. Thumbs up to the author to get to the bottom of this, it is great work work (dirty work, but still great).
2
2
u/DaddyLcyxMe Apr 26 '21
btw, windows provides evaluation vm images for developers. saying this to help out any potential users who need to test something on windows without a windows box
2
3
u/StochasticTinkr Apr 26 '21
Side note: The bug being around since 1.2, and that being 22 years ago... I learned Java when 1.2 was the latest version and now I feel old.
37
u/AndrewHaley13 Apr 26 '21
Thanks, you've done a great job of explaining what you have to do. And yes, we know that the bug-reporting process leaves quite a lot to be desired. You could probably have saved some time by approaching the core-libs-dev list at the start, but that's the only thing that might have worked better. Nice one.