[crac] RFR: Fix ArchivedEnumTest.java testsuite regression [v2]

Anton Kozlov akozlov at openjdk.org
Tue Sep 5 07:05:09 UTC 2023


On Mon, 4 Sep 2023 12:02:48 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.
>
> Jan Kratochvil has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Use only local variables.
>    - suggested by Radim Vansa

src/java.base/share/classes/jdk/crac/impl/GlobalContext.java line 8:

> 6: 
> 7: public class GlobalContext {
> 8:     private static final String GLOBAL_CONTEXT_IMPL_PROP = "jdk.crac.globalContext.impl";

GLOBAL_CONTEXT_IMPL_PROP can be here, no need to make it local

src/java.base/share/classes/jdk/crac/impl/GlobalContext.java line 10:

> 8:     public static Context<Resource> createGlobalContextImpl() {
> 9:         String impl_prop = "jdk.crac.globalContext.impl";
> 10:         String impl_name = GetPropertyAction.privilegedGetProperty(impl_prop, "");

impl_name -> implName

-------------

PR Review Comment: https://git.openjdk.org/crac/pull/109#discussion_r1315456109
PR Review Comment: https://git.openjdk.org/crac/pull/109#discussion_r1315454565


More information about the crac-dev mailing list