void (Queue<? super Object> mailbox) { LinkedBlockingQueue<String> fromJps = new LinkedBlockingQueue<>(); mailbox.offer(fromJps); // signal that stubs are generated while (true) { try { Object response = fromJps.poll(1, TimeUnit.MINUTES); if (GroovyRtConstants.BUILD_ABORTED.equals(response)) { throw new RuntimeException(GroovyRtConstants.BUILD_ABORTED); } else if (GroovyRtConstants.JAVAC_COMPLETED.equals(response)) { return; // stop waiting and continue compiling } else if (response != null) { throw new RuntimeException("Unknown response: " + response); } } catch (InterruptedException e) { throw new RuntimeException(e); } } }