code: public static String getEnvironmentName(ClassLoader loader)
    {
      for (; loader != null; loader = loader.getParent()) {
        if (loader instanceof EnvironmentClassLoader) {
          String name = ((EnvironmentClassLoader) loader).getId();
  
          if (name != null)
            return name;
          else
            return "";
        }
      }
  
      return Thread.currentThread().getContextClassLoader().toString();
    }
docs: Returns the environment name.