[crac] RFR: Fix ArchivedEnumTest.java testsuite regression
Radim Vansa
rvansa at openjdk.org
Mon Sep 4 07:11:11 UTC 2023
On Sun, 3 Sep 2023 14:43:08 GMT, Jan Kratochvil <jkratochvil at openjdk.org> wrote:
> java.lang.RuntimeException: 'object points to a static field that may be reinitialized at runtime' found in stdout
> at jdk.test.lib.process.OutputAnalyzer.shouldNotContain(OutputAnalyzer.java:267)
> at ArchivedEnumTest.main(ArchivedEnumTest.java:49)
> at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
> at java.base/java.lang.reflect.Method.invoke(Method.java:580)
> at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
> at java.base/java.lang.Thread.run(Thread.java:1570)
>
> [1.337s][warning][cds,heap] Archive heap points to a static field that may be reinitialized at runtime:
> [1.337s][warning][cds,heap] Field: jdk/crac/impl/GlobalContext::GLOBAL_CONTEXT_IMPL_NAME
> [1.337s][warning][cds,heap] Value: java.lang.String
> [1.337s][warning][cds,heap] {0x00000000d7561560} - klass: 'java/lang/String'
> [1.337s][warning][cds,heap] - string: ""
> [1.337s][warning][cds,heap] - ---- fields (total size 3 words):
> [1.337s][warning][cds,heap] - private 'hash' 'I' @12 0 (0x00000000)
> [1.337s][warning][cds,heap] - private final 'coder' 'B' @16 0 (0x00)
> [1.338s][warning][cds,heap] - private 'hashIsZero' 'Z' @17 true (0x01)
> [1.338s][warning][cds,heap] - injected 'flags' 'B' @18 1 (0x01)
> [1.338s][warning][cds,heap] - private final 'value' '[B' @20 [B{0x00000000d7561578} (0xd7561578)
> [1.338s][warning][cds,heap] --- trace begin ---
> [1.338s][warning][cds,heap] [ 0] (shared string table)
> [1.338s][warning][cds,heap] [ 1] {0x00000000d7561560} java.lang.String
> [1.338s][warning][cds,heap] --- trace end ---
>
>
> I haven't found a way how to fix [src/java.base/share/classes/jdk/crac/impl/GlobalContext.java](https://github.com/openjdk/crac/blob/crac/src/java.base/share/classes/jdk/crac/impl/GlobalContext.java) not regressing its current static field performance without adding this exception.
Given that the global context is created only once, I think it would be OK to drop the field and obtain the config value in runtime.
However, I wonder if the option really works; looks like this PR is disabling only the error in the test, though the `[B]` option does not really fit (it does not end up as a compile-time-known deterministic value). Can you override this in runtime or would JDK always load the default value?
-------------
PR Comment: https://git.openjdk.org/crac/pull/109#issuecomment-1704728049
More information about the crac-dev
mailing list