At school we were assigned the task to do Huffman's algorithm. Since I am way ahead of all the others, I made a GUI for that. (Btw, we use BlueJ for Java, it's just painful)
Now... I made a JTextField to put the output, which would be any character from 0x0 to 0xFFFF, into it.
Apparently, there is a bug in the setText method, which throws random NullPointerExceptions right into your face if you give it those Unicode characters.
So I looked it up:
It was a Bug, in JDK 1.6.something, where putting a 0xFFFF together with a 0x10000 would cause this. Now you may think, do we still have 1.6? No, we have 1.8 v171, WHY THE FUCK DOES THIS SHIT GIVE ME A NPE?! THE WORST PART IS I CAN'T DO ANYTHING ABOUT IT!
1. NPE, nothing else happens
2. The Text box just gets invisible, but the border stays visible + NPE
3. The box completely disappears + NPE

Try-catching it doesn't do anything, everytime I fill the box with text, one of those options happens, and the box was never to be seen again! NOT EVEN CREATING A NEW TEXT BOX AND ADDING IT TO MY WINDOW WORKS.

  • 1
    Did you try running in a terminal to see the output or stacktrace?
  • 1
    I guess that even with the textbox working as intended you would not always get usable results by directly putting binary data in there.
    Maybe you could use base64 to encode it before printing it as text
  • 1
    @-Tor yes, but it is Java internal. That doesn't help me

    @SanitizedOutput the reason I did this Text box was to show there will be random characters after encoding
  • 4
    Time to try out JavaFX or Swing and create a bug report to give to your teacher as the excuse :)
  • 1
    @Proximyst I really like javaFX :D
  • 0
    While I hate Java in general. I do like javafx, with the Jfoenix library added
  • 0
    @KasperNS Why do you hate Java?
  • 0
    @Unoriginal it's kinda like the iPhone of programming languages. It's not inherently bad, in fact it's actually really good, and can do a lot of great things.

    There are just so many alternatives, with better support, more features, and easier to use. And you can't even argue about cross platform any more, since most backend technologies can be run on anything.

    But the main reason I don't like Java, is that it's going to be commercialized from next year. No more free development in Java. You need to have a license to deploy
  • 0
    @KasperNS That's not true. Java is still free and open source. Oracle's JFK se8 is the only thing going commercially. Which it already was anyway. There are still openjdk and a handful of other implementations of free java.

    Java is free. Myths need to stop 🤦‍♂️
  • 0
    @-Tor okay sorry, I had misunderstood it then. However my other points still stand I believe
  • 0
    @KasperNS No need for apologies. The whole world is buzz with this lie right now 🤷‍♂️.

    As for the other points, I think it could be up to opinion. It is true now days you "can" get things to run pretty much anywhere. But the difference is that if I make a java program executable I can give that to someone on Mac windows or linux. If I was using something like c++ I'd have to compile to different architectures and make a handful of different executables and such. For os and architecture. So... not as easy.

    More features is arguable too I think. But maybe different features makes more sense? It is possible there are lots of other cool technologies that java doesn't do! This is tech 👌.
  • 0
    @Proximyst I might be being stupid because I haven't had my coffee yet but isn't JTextField Swing?
Your Job Suck?
Get a Better Job
Add Comment