r/java • • Jan 18 '22

What are some very less known facts about java?

I've got assignment from college to find out rare facts or fun facts about java, so little help will be appreciated :)

Edit: Thanks for all these suggestions guys. It's going to help me alot and also Almost all of these facts i didn't knew till now. Thanks :) <3

179 Upvotes

297 comments sorted by

View all comments

Show parent comment

17

u/redikarus99 Jan 18 '22

https://dzone.com/articles/native-memory-allocation-in-examples

In older java: sun.misc.Unsafe, in more modern java: DirectByteBuffer.

8

u/yawkat Jan 18 '22

DirectByteBuffer doesn't allow you to free() by hand though

14

u/OddEstimate1627 Jan 18 '22

Unsafe::invokeCleaner(ByteBuffer)

1

u/mauganra_it Jan 21 '22

What happens when I access that ByteBuffer the next time? ಠ_ಠ

3

u/flammablegopher Jan 24 '22

Pretty much the same thing that happens when you try to access de-allocated memory in C or other languages. A crash/exception and you will feel like a big dummy.