{}
run-icon
Main.java
public class BootSequence { public static class Bootloader { public static final KeyStore keyStore = new KeyStore(); static { // Call to trigger KeyStore's static initializer keyStore.observeFinalVariable(); } } public static class KeyStore { public static final KeyStore cachedKeyStore; static { cachedKeyStore = Bootloader.keyStore; } public void observeFinalVariable() {} } public static void main(String[] args) { // Trigger static initializer in Bootloader which // cascades to trigger KeyStore's static initializer System.out.println(Bootloader.keyStore); // Current value // So what value did we observe? System.out.println(KeyStore.cachedKeyStore); // Value that KeyStore saw } }
Output