Source:
Object lookup(final RemoteContext context, final Name name, final boolean preserveLinks) throws NamingException { final BlockingInvocation invocation = tracker.addInvocation(BlockingInvocation::new); try { try (MessageOutputStream messageOutputStream = tracker.allocateMessage(invocation)) { messageOutputStream.writeByte(preserveLinks ? Protocol.CMD_LOOKUP_LINK : Protocol.CMD_LOOKUP); writeId(messageOutputStream, invocation.getIndex()); if (version == 1) { try (Marshaller marshaller = createMarshaller(messageOutputStream)) { marshaller.writeByte(Protocol.P_NAME); marshaller.writeObject(name); } } else { messageOutputStream.writeUTF(NamingUtils.toCompositeName(name).toString()); } } final BlockingInvocation.Response response = invocation.getResponse(); try (MessageInputStream is = response.getInputStream()) { final int result = is.readUnsignedByte(); if (result == Protocol.SUCCESS) { final int parameterType = is.readUnsignedByte(); if (parameterType == Protocol.P_CONTEXT) { return new RelativeFederatingContext(new FastHashtable<>(context.getEnvironment()), context, NamingUtils.toCompositeName(name)); } else if (parameterType != Protocol.P_OBJECT) { throw Messages.log.invalidResponse(); } try (Unmarshaller unmarshaller = createUnmarshaller(is)) { return unmarshaller.readObject(); } } else if (result == Protocol.FAILURE) { final int parameterType = is.readUnsignedByte(); if (parameterType != Protocol.P_EXCEPTION) { throw Messages.log.unexpectedResponseParameter(); } try (Unmarshaller unmarshaller = createUnmarshaller(is)) { final Exception exception = unmarshaller.readObject(Exception.class); throw namingException("Failed to lookup", exception); } } else { throw Messages.log.outcomeNotUnderstood(); } } } catch (ClassNotFoundException | IOException e) { throw Messages.log.operationFailed(e); } catch (InterruptedException e) { invocation.cancel(); Thread.currentThread().interrupt(); throw Messages.log.operationInterrupted(); } }

Target:
Object lookup(final RemoteContext context, final Name name, final boolean preserveLinks) throws NamingException { final BlockingInvocation invocation = tracker.addInvocation(BlockingInvocation::new); try { try (MessageOutputStream messageOutputStream = tracker.allocateMessage(invocation)) { messageOutputStream.writeByte(preserveLinks ? Protocol.CMD_LOOKUP_LINK : Protocol.CMD_LOOKUP); writeId(messageOutputStream, invocation.getIndex()); if (version == 1) { try (Marshaller marshaller = createMarshaller(messageOutputStream)) { marshaller.writeByte(Protocol.P_NAME); marshaller.writeObject(name); } } else { messageOutputStream.writeUTF(NamingUtils.toCompositeName(name).toString()); } } final BlockingInvocation.Response response = invocation.getResponse(); try (MessageInputStream is = response.getInputStream()) { final int parameterType = is.readUnsignedByte(); if (parameterType == Protocol.P_CONTEXT) { return new RelativeFederatingContext(new FastHashtable<>(context.getEnvironment()), context, NamingUtils.toCompositeName(name)); } else if (parameterType == Protocol.P_OBJECT) { try (Unmarshaller unmarshaller = createUnmarshaller(is)) { return unmarshaller.readObject(); } } else if (parameterType == Protocol.P_EXCEPTION) { try (Unmarshaller unmarshaller = createUnmarshaller(is)) { final Exception exception = unmarshaller.readObject(Exception.class); throw namingException("Failed to lookup", exception); } } else { throw Messages.log.invalidResponse(); } } } catch (ClassNotFoundException | IOException e) { throw Messages.log.operationFailed(e); } catch (InterruptedException e) { invocation.cancel(); Thread.currentThread().interrupt(); throw Messages.log.operationInterrupted(); } }