

What to do about sun.misc.Unsafe - pjmlp
https://docs.google.com/document/d/1GDm_cAxYInmoHMor-AkStzWvwE9pw6tnz_CebJQxuUE/edit?pli=1

======
sreque
I'm very disappointed with Oracle's decision to remove Unsafe. What are they
trying to accomplish? They aren't serving anyone by removing it. Who benefits
from its removal? What actual user of the JVM or customer of Oracle has ever
said "I really like this 10x performance increase from this library that uses
Unsafe, but I can't sleep at night thinking my program could seg-fault at any
time if something went wrong! Please get rid of Unsafe Oracle! I promise to
buy 10x more hardware from you to make up for the difference!"

Java's "write once run anywhere at all costs" philosophy, combined with "be
safe at all costs", have kept the JVM locked into server-side Linux
applications for a long time, while C# has continued to expand in areas like
the mobile space. If it weren't for Java being propped up by Google, Java
would hardly exist in the mobile world at all.

C# + the CLR has world class native code integration and escape hatches to
drop to unsafe code when performance matters. Java's native integration is
absolutely terrible, but at least it had Unsafe, which provided a pragmatic
tool for achieving excellent performance on the JVM in a number of scenarios.

Now, look at this comment from an Oracle employee:
[http://mail.openjdk.java.net/pipermail/openjfx-
dev/2015-Apri...](http://mail.openjdk.java.net/pipermail/openjfx-
dev/2015-April/017028.html)

"Let me be blunt -- sun.misc.Unsafe must die in a fire. It is -- wait for it
-- Unsafe. It must go..."

That's some very strong language backed by a simple, ridiculous reason; it's
"unsafe". I honestly hope this Oracle employee's ideas die in a fire because
they are out of touch with the needs of actual Java programmers, but my hope
for that is slim at this point.

~~~
bitmapbrother
Did it occur to you at anytime that they might have a replacement for unsafe
in the works? I don't get why you think it's so unreasonable for them to
replace something they consider "unsafe" with alternate solutions that do they
same thing but in a proper and supported manner.

BTW, Java will also get that "world class native code integration" with
Project Panama.

------
derriz
This would be a terrible move and will retard the uptake of Java 9. Why not
leave it as it is or just repackage it until replacements snake their way
through the JSR process and then users can migrate their source.

Java will never bridge the performance gap with C/C++/etc. until it plays nice
with modern architectures where being memory cache friendly is vital for
performance. Unsafe has been shown to allow orders of magnitude speed
improvements for certain tasks.

While I am on the subject could someone explain the point of Jigsaw? It will
deliver nothing to current users and why bother with a cutdown Java on small
devices these days when the cheapest phone has more power than desktops of 10
years ago? It seems to have consumed enormous resources and caused delays
while Java is slipping further behind C# and other modern languages.

~~~
bitmapbrother
Perhaps they have something in mind to replace unsafe? Project Valhalla seems
to address a lot of the reasons why people use unsafe.

[http://www.oracle.com/technetwork/java/jvmls2014taylorrose-2...](http://www.oracle.com/technetwork/java/jvmls2014taylorrose-2265209.pdf)
(Page 40)

There is also PackedObject from IBM. It's an experimental feature in their J9
JVM and it allows improved serialization and I/O of Java objects by allowing
direct access to native/off heap data.

[https://www.ibm.com/developerworks/community/forums/ajax/dow...](https://www.ibm.com/developerworks/community/forums/ajax/download/c577ef63-62aa-496a-a586-9703a762f306/3e254fbb-82d7-4678-95e5-1f6751e896d8/IBM%20Java%20PackedObjects.pdf)

With the introduction of Valhalla, PackedObject and other technologies I think
we'll see the performance gap decrease quite a bit.

------
hakcermani
Is this doc editable ? someone deleted the contents :-( Better to pdf it.

~~~
OJFord
Or just change permission to "anyone with link can...">View

