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


    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9, 10
    • Fix Version/s: 11
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:


      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.
      b. Add support for handing unloaded class in Graal-generated code, including indirections for field offsets. That, I suspect, would be pretty slow.


          Issue Links



              • Assignee:
                dlong Dean Long
                dpochepk Dmitrij Pochepko
              • Votes:
                0 Vote for this issue
                6 Start watching this issue


                • Created: