Using java-9 build 9-ea + 149 and jol 0.6 .
Running this simple code:
ArrayList<Integer> list = new ArrayList<>(); list.add(12); System.out.println(ClassLayout.parseInstance(list).toPrintable());
Output:
OFFSET SIZE TYPE DESCRIPTION VALUE 0 4 (object header) 01 00 00 00 (00000001 00000000 00000000 00000000) (1) 4 4 (object header) 00 00 00 00 (00000000 00000000 00000000 00000000) (0) 8 4 (object header) 0e 8d 00 f8 (00001110 10001101 00000000 11111000) (-134181618) 12 4 int AbstractList.modCount (access denied) 16 4 int ArrayList.size (access denied) 20 4 Object[] ArrayList.elementData (access denied)
This access denial function comes from the FieldData.java method in the method:
public String safeValue(Object object) { if (refField != null) { try { return ObjectUtils.safeToString(refField.get(object)); } catch (IllegalAccessException iae) { // exception, try again } try { refField.setAccessible(true); return ObjectUtils.safeToString(refField.get(object)); } catch (Exception e) { return "(access denied)"; } } else { return "N/A"; } }
And the actual exception:
It is not possible to make the transient int java.util.AbstractList.modCount protected field available: the java.base module does not "open java.util" for the unnamed @ 479d31f3 module.
I think this is due to the fact that Unsafe features are blocked. The question is how to do this?
I looked at properties such as:
-XaddExports:java.base/sun.security.provider=ALL-UNNAMED
But he canβt really say how he should look.
source share