Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8146201

[AOT] Class static initializers that are not pure should not be executed during static compilation

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • 9, 10
    • hotspot
    • b07

      Currently, an aot compiler loads every class it should compile and clinit is executed. This is not safe in cases when it's not pure (depends/mutates external state and/or produces i/o). Static analysis should be performed to exclude such methods from running at static compilation time.

      Another option, to support not running static initializers at all, would require to either:
      a. Adding a class loading mode to the VM, that doesn't run static initializers. That would give us constant field offsets, but no static folding though fields. One has to be careful to not mixup initialized and uninitialized classes. May be it's all doable through careful laziness - getting things like field offsets should not require initializing a class. It's not quite clear to me how to do that yet. Btw, it's also possible that the AOT compiler would require some classes with side-effecting static initializers for it to function, let's hope that doesn't happen.
      or
      b. Add support for handing unloaded class in Graal-generated code, including indirections for field offsets. That, I suspect, would be pretty slow.

            dlong Dean Long
            dpochepk Dmitrij Pochepko
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: