platypusguy/jacobin

Wrong value printed

Closed this issue · 2 comments

run the code (compiled with Temurin 17, these classes are used with JAVA_HOME for jacobin as well)

With Temurin Output is 42, with Jacobin 0.

final class A {
   static int x = 42;

   public static void main( String argv[]) {
     System.out.println(x);
   }
}

No warning or error message is shown while running jacobin

Thanks for the report. Jumping on it now...

Update: Ah, I see the problem. The Java compiler uses a static initalization block to initialize variable x. Static initializer blocks are a feature we're currently in the midst of implementing (JACOBIN-340 in header of the code commits). I'll leave this open til it's working as expected, then post a note here, and with your permission, fold your example into the test suite.

Thanks again!

We completed the initial implementation of static initialization blocks. And now your test works correctly. Unless you object, we'll move the code into our test suite to make sure there are no regressions. Again, thank you!