RFR(XS): 8031427: AllocObject and Unsafe.allocateInstance segfault for primitive types

Gilles Duboscq duboscq at ssw.jku.at
Thu Jan 9 04:58:15 PST 2014


Hello,

As i wrote in a bug report [1]:
Currently, calling AllocObject or Unsafe.allocateInstance with a primitive
type (e.g. unsafe.allocateInstance(int.class)) leads to a segmentation
fault because Classes representing primitive types do not have an
associated Klass.

While AllocObject or allocateInstance should in principle never be called
with a Class representing a primitive, it should probably not crash in such
a case since it throws sensible exceptions for many other invalid arguments
(interfaces, abstract types, arrays, j.l.Class).

The proposed fix [2] just throws an InstantiationException if the Klass is
NULL.

-Gilles

[1] https://bugs.openjdk.java.net/browse/JDK-8031427
[2] http://lafo.ssw.uni-linz.ac.at/alloc_object.diff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20140109/0eec9b6e/attachment-0001.html 


More information about the hotspot-runtime-dev mailing list