Description of problem: If you run the code below, the JVM locks up. The Eclipse debugger is not even able to stop the locked-up thread, or determine where it is stuck. If you change the value of either of the static boolean fields, the code completes as expected. The problem seems to be that some part of the Java 8 lambda system is not properly initialized until just before the main method is called. Version-Release number of selected component (if applicable): java-1.8.0-openjdk-1.8.0.111-5.b16.fc25.x86_64 Also present in upstream Oracle jdk1.8.0_121-1.8.0_121-fcs.x86_64 How reproducible: 100% Steps to Reproduce: Run the following code with both static fields set to true. (If either or both is false, the code runs fine.) import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class LambdaBug { // Code will hang after "Entering startUp()" if and both these are true private static final boolean RUN_AS_STATIC_INITIALIZER = true; private static final boolean RUN_USING_LAMBDA = true; static { if (RUN_AS_STATIC_INITIALIZER) { startUp(); } } private static void startUp() { System.out.println("Entering startUp()"); ExecutorService es = Executors.newSingleThreadExecutor(); try { Callable<Void> callable; if (RUN_USING_LAMBDA) { callable = () -> { System.out.println("Lambda executed"); return null; }; } else { callable = new Callable<Void>() { @Override public Void call() throws Exception { System.out.println("Inner class method executed"); return null; } }; } es.submit(callable).get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } finally { es.shutdown(); } System.out.println("Exiting startUp()"); } public static void main(String[] args) { if (!RUN_AS_STATIC_INITIALIZER) { startUp(); } System.out.println("Exiting main"); } } Actual results: Code locks up, if run as shown above. Expected results: Code should run to completion (which it does if either of the static boolean fields' values are changed). Additional info: This bug is also present in the upstream Oracle JDK, but I do not have an OpenJDK Author role, so I can't file a bug in the Jira system.
The upstream bug report I filed was accepted in the Oracle bug tracker: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8173252 This appears to be a deadlock, as explained here: http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-January/046060.html
After further discussion on the core-libs-dev mailing list, it appears that this is expected behavior.