[英]Is jol a little broken under Java9?
Using java-9 build 9-ea+149 and jol 0.6 . 使用java-9构建9-ea + 149和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 denied part comes from FieldData.java in the method: 此访问被拒绝的部分来自FieldData.java中的方法:
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 is : 实际的例外是:
Unable to make field protected transient int java.util.AbstractList.modCount accessible: module java.base does not "opens java.util" to unnamed module @479d31f3.
无法使受字段保护的瞬态int java.util.AbstractList.modCount可以访问:模块java.base不会“打开java.util”到未命名的模块@ 479d31f3。
I think that this has to do with Unsafe features being locked down. 我认为这与不安全功能被锁定有关。 The question is how do I get this to run?
问题是如何使它运行?
I've looked at properties like : 我看过像这样的属性:
-XaddExports:java.base/sun.security.provider=ALL-UNNAMED
But can't really tell what it is supposed to look like. 但是无法真正说出它的外观。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.