Skip to content

native-image does not respect ConstantValue, if initialized at run-time #6912

@Vukooo

Description

@Vukooo

Describe the issue
If a class defines their initial value of a static field with the "ConstantValue" attribute, svm evaluates the field to null, if the class get's initialized at runtime. If the class get's initialized at build time, it works fine.

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. git clone https://github.com/Vukooo/NativeImageFinallyReproducer -b bug-constantvalue
  2. sh run_not_working.sh // Null will be printed
  3. sh run_working.sh // "INITIAL-VALUE" will be correctly printed

Describe GraalVM and your environment:

  • GraalVM version: GraalVM Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12)
  • JDK major version: 17
  • OS: macOS Ventura
  • Architecture: arm64

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions