gt:         Object applet = env.get(Context.APPLET);
context: /*
   * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this
   * particular file as subject to the "Classpath" exception as provided
   * by Oracle in the LICENSE file that accompanied this code.
   *
   * This code is distributed in the hope that it will be useful, but WITHOUT
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   * version 2 for more details (a copy is included in the LICENSE file that
   * accompanied this code).
   *
   * You should have received a copy of the GNU General Public License version
   * 2 along with this work; if not, write to the Free Software Foundation,
   * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   *
   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   * or visit www.oracle.com if you need additional information or have any
   * questions.
   */
  
  package com.sun.naming.internal;
  
  import java.io.InputStream;
  import java.io.IOException;
  import java.lang.ref.WeakReference;
  import java.lang.reflect.Method;
  import java.lang.reflect.InvocationTargetException;
  import java.util.HashMap;
  import java.util.Hashtable;
  import java.util.Map;
  import java.util.Properties;
  import java.util.StringTokenizer;
  import java.util.List;
  import java.util.ArrayList;
  import java.util.WeakHashMap;
  
  import javax.naming.*;
  
  /**
    * The ResourceManager class facilitates the reading of JNDI resource files.
    *
    * @author Rosanna Lee
    * @author Scott Seligman
    */
  
  public final class ResourceManager {
  
      /*
       * Name of provider resource files (without the package-name prefix.)
       */
      private static final String PROVIDER_RESOURCE_FILE_NAME =
              "jndiprovider.properties";
  
      /*
       * Name of application resource files.
       */
      private static final String APP_RESOURCE_FILE_NAME = "jndi.properties";
  
      /*
       * Name of properties file in <java.home>/lib.
       */
      private static final String JRELIB_PROPERTY_FILE_NAME = "jndi.properties";
  
      /*
       * Internal environment property, that when set to "true", disables
       * application resource files lookup to prevent recursion issues
       * when validating signed JARs.
       */
      private static final String DISABLE_APP_RESOURCE_FILES =
          "com.sun.naming.disable.app.resource.files";
  
      /*
       * The standard JNDI properties that specify colon-separated lists.
       */
      private static final String[] listProperties = {
          Context.OBJECT_FACTORIES,
          Context.URL_PKG_PREFIXES,
          Context.STATE_FACTORIES,
          // The following shouldn't create a runtime dependence on ldap package.
          javax.naming.ldap.LdapContext.CONTROL_FACTORIES
      };
  
      private static final VersionHelper helper =
              VersionHelper.getVersionHelper();
  
      /*
       * A cache of the properties that have been constructed by
       * the ResourceManager.  A Hashtable from a provider resource
       * file is keyed on a class in the resource file's package.
       * One from application resource files is keyed on the thread's
       * context class loader.
       */
      // WeakHashMap<Class | ClassLoader, Hashtable>
      private static final WeakHashMap<Object, Hashtable<? super String, Object>>
              propertiesCache = new WeakHashMap<>(11);
  
      /*
       * A cache of factory objects (ObjectFactory, StateFactory, ControlFactory).
       *
       * A two-level cache keyed first on context class loader and then
       * on propValue.  Value is a list of class or factory objects,
       * weakly referenced so as not to prevent GC of the class loader.
       * Used in getFactories().
       */
      private static final
          WeakHashMap<ClassLoader, Map<String, List<NamedWeakReference<Object>>>>
              factoryCache = new WeakHashMap<>(11);
  
      /*
       * A cache of URL factory objects (ObjectFactory).
       *
       * A two-level cache keyed first on context class loader and then
       * on classSuffix+propValue.  Value is the factory itself (weakly
       * referenced so as not to prevent GC of the class loader) or
       * NO_FACTORY if a previous search revealed no factory.  Used in
       * getFactory().
       */
      private static final
          WeakHashMap<ClassLoader, Map<String, WeakReference<Object>>>
              urlFactoryCache = new WeakHashMap<>(11);
      private static final WeakReference<Object> NO_FACTORY =
              new WeakReference<>(null);
  
      /**
       * A class to allow JNDI properties be specified as applet parameters
       * without creating a static dependency on java.applet.
       */
      private static class AppletParameter {
          private static final Class<?> clazz = getClass("java.applet.Applet");
          private static final Method getMethod =
              getMethod(clazz, "getParameter", String.class);
          private static Class<?> getClass(String name) {
              try {
                  return Class.forName(name, true, null);
              } catch (ClassNotFoundException e) {
                  return null;
              }
          }
          private static Method getMethod(Class<?> clazz,
                                          String name,
                                          Class<?>... paramTypes)
          {
              if (clazz != null) {
                  try {
                      return clazz.getMethod(name, paramTypes);
                  } catch (NoSuchMethodException e) {
                      throw new AssertionError(e);
                  }
              } else {
                  return null;
              }
          }
  
          /**
           * Returns the value of the applet's named parameter.
           */
          static Object get(Object applet, String name) {
              // if clazz is null then applet cannot be an Applet.
              if (clazz == null || !clazz.isInstance(applet))
                  throw new ClassCastException(applet.getClass().getName());
              try {
                  return getMethod.invoke(applet, name);
              } catch (InvocationTargetException |
                       IllegalAccessException e) {
                  throw new AssertionError(e);
              }
          }
      }
  
      // There should be no instances of this class.
      private ResourceManager() {
      }
  
  
      // ---------- Public methods ----------
  
      /*
       * Given the environment parameter passed to the initial context
       * constructor, returns the full environment for that initial
       * context (never null).  This is based on the environment
       * parameter, the applet parameters (where appropriate), the
       * system properties, and all application resource files.
       *
       * <p> This method will modify <tt>env</tt> and save
       * a reference to it.  The caller may no longer modify it.
       *
       * @param env       environment passed to initial context constructor.
       *                  Null indicates an empty environment.
       *
       * @throws NamingException if an error occurs while reading a
       *          resource file
       */
      @SuppressWarnings("unchecked")
      public static Hashtable<?, ?> getInitialEnvironment(
              Hashtable<?, ?> env)
              throws NamingException
      {
          String[] props = VersionHelper.PROPS;   // system/applet properties
          if (env == null) {
              env = new Hashtable<>(11);
          }
  