空循环是否在其条件下被死代码消除捕获到副作用?

Are empty loops with side effects in it's condition caught by dead code elimination?

给定以下代码

var cachedInt = new ArrayBlockingQueue<Integer>(xxxxx);

while(true){
   while(cachedInt.offer(randomProvider.nextInt()));
   latch.await();
}

jvm 最终是否会消除 while 循环,因为它没有主体,或者它是否识别条件的副作用并保留循环?

不,jvm 不会 "optimize" 您的方法调用。您的条件将 运行 重复,直到它 returns 错误并且副作用将正常发生。