/** * Constructs a new debugger tester instance with a pre-set context builder. * * @param contextBuilder a pre-set context builder. Only out and err streams are set on this * builder prior the {@link Context} instance creation. * * @see #DebuggerTester() * @since 0.31 */ public DebuggerTester(Context.Builder contextBuilder) { this.newEvent = new ArrayBlockingQueue<>(1); this.executing = new Semaphore(0); this.initialized = new Semaphore(0); final AtomicReference<Engine> engineRef = new AtomicReference<>(); final AtomicReference<Throwable> error = new AtomicReference<>(); this.executingLoop = new ExecutingLoop(contextBuilder, engineRef, error); this.evalThread = new Thread(executingLoop); this.evalThread.start(); try { initialized.acquire(); } catch (InterruptedException e) { throw new AssertionError(e); } this.engine = engineRef.get(); if (error.get() != null) { throw new AssertionError("Engine initialization failed", error.get()); } }
/** * Constructs a new debugger tester instance with a pre-set context builder. * * @param contextBuilder a pre-set context builder. Only out and err streams are set on this * builder prior the {@link Context} instance creation. * * @see #DebuggerTester() * @since 0.31 */ public DebuggerTester(Context.Builder contextBuilder) { this.newEvent = new ArrayBlockingQueue<>(1); this.executing = new Semaphore(0); this.initialized = new Semaphore(0); final AtomicReference<Engine> engineRef = new AtomicReference<>(); final AtomicReference<Throwable> error = new AtomicReference<>(); this.executingLoop = new ExecutingLoop(contextBuilder, engineRef, error); this.evalThread = new Thread(executingLoop); this.evalThread.start(); try { initialized.acquire(); } catch (InterruptedException e) { throw new AssertionError(e); } this.engine = engineRef.get(); if (error.get() != null) { throw new AssertionError("Engine initialization failed", error.get()); } }