Object (int sessionId, int id) { if (sessionId != NO_SESSION_ID) { WeakReference<Object> adhocReference = adhocReferenceMap.get(id); if (adhocReference != null) { return dereference(adhocReference, id); } // first lookup in session Session session = sessions.get(sessionId); if (session == null) { throw new IllegalStateException("No such session " + sessionId); } return session.findReference(id); } WeakReference<Object> reference = adhocReferenceMap.get(id); if (reference == null) throw new IllegalStateException("No such variable " + id); return dereference(reference, id); }