public static XMLLib extractFromScopeOrNull(Scriptable scope) { ScriptableObject so = ScriptRuntime.getLibraryScopeOrNull(scope); if (so == null) { // If librray is not yet initialized, return null return null; } // Ensure lazily initialization of real XML library instance // which is done on first access to XML property ScriptableObject.getProperty(so, "XML"); return (XMLLib) so.getAssociatedValue(XML_LIB_KEY); }