r/programming • • 4d ago

Java4Shell is a reason to use Java

https://mccue.dev/pages/11-18-26-java4shell
44 Upvotes

50 comments sorted by

View all comments

61

u/BenchEmbarrassed7316 4d ago

What a nonsense.

tldr: A vulnerability was found in Java. Java isn't much slower than C++. So, use Java.

72

u/bowbahdoe 4d ago • Popcorn

I would say its closer to

tldr:

  • A vulnerability was found in the C++ code behind Java.
  • We need to fix that and audit that C++ pretty deeply
  • But Java code is usually immune to these kinds of problems.
  • And auditing one C++ codebase is easier than auditing N dependencies
  • So use Java

29

u/bowbahdoe 4d ago

With the corollary that

  • Other GC'ed languages are less immune to these kinds of problems because of their "seamless" support for calling C++.

Which is the part that people seem to be taking exception to.

4

u/coderemover 2d ago edited 2d ago

Java is not immune to those problems. It has its own share of problems. And maybe C++ has some problems that Java doesn’t have, but that part is solved by Rust. And Rust is generally safer than Java.

-1

u/Virviil 2d ago edited 2d ago

Its statements contradicts themselves.

If dependencies are NOT allowed not use native code - they are slow and so my Java program is. If dependencies ARE allowed - Java is the same “vulnerable” as other languages.
If dependencies turring-full compiles JIT into native - it’s impossible to audit

1

u/bowbahdoe 1d ago

Well take for context that the response above is framed by the way the first person framed it. 

If dependencies are NOT allowed to use native code

  • They are pure Java and are optimized like the rest of your program. Probably worst case it's like 2.5x slower or something. It's not Python where it's 50x (and like I alluded, sometimes it's 1x or 0.9x. really depends on the code)

If dependencies are allowed to use native code

  • You have to explicitly add a flag to enable it, so at least you are aware that you have a different risk profile than pure Java
  • You can have that flag be per-library so you know exactly what you need to audit deeply to have confidence you don't have buffer overflows

And in both situations 

  • you need to trust the native code in the VM. But at least that's only one "thing." Let's audit it more, of course. Or find ways to make it safer by construction. But it does make it so most people don't need to go to these depths.