gt:         if (wrappers == null) {
context: /*
   * Copyright (c) 2013, 2014, 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 sun.management;
  
  import com.sun.management.DiagnosticCommandMBean;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
  import java.security.Permission;
  import java.util.*;
  import javax.management.*;
  
  /**
   * Implementation class for the diagnostic commands subsystem.
   *
   * @since 1.8
   */
  class DiagnosticCommandImpl extends NotificationEmitterSupport
      implements DiagnosticCommandMBean {
  
      private final VMManagement jvm;
      private volatile Map<String, Wrapper> wrappers = null;
      private static final String strClassName = "".getClass().getName();
      private static final String strArrayClassName = String[].class.getName();
      private final boolean isSupported;
  
      @Override
      public Object getAttribute(String attribute) throws AttributeNotFoundException,
          MBeanException, ReflectionException {
          throw new AttributeNotFoundException(attribute);
      }
  
      @Override
      public void setAttribute(Attribute attribute) throws AttributeNotFoundException,
          InvalidAttributeValueException, MBeanException, ReflectionException {
          throw new AttributeNotFoundException(attribute.getName());
      }
  
      @Override
      public AttributeList getAttributes(String[] attributes) {
          return new AttributeList();
      }
  
      @Override
      public AttributeList setAttributes(AttributeList attributes) {
          return new AttributeList();
      }
  
      private class Wrapper {
  
          String name;
          String cmd;
          DiagnosticCommandInfo info;
          Permission permission;
  
          Wrapper(String name, String cmd, DiagnosticCommandInfo info)
                  throws InstantiationException {
              this.name = name;
              this.cmd = cmd;
              this.info = info;
              this.permission = null;
              Exception cause = null;
              if (info.getPermissionClass() != null) {
                  try {
                      Class<?> c = Class.forName(info.getPermissionClass());
                      if (info.getPermissionAction() == null) {
                          try {
                              Constructor<?> constructor = c.getConstructor(String.class);
                              permission = (Permission) constructor.newInstance(info.getPermissionName());
  
                          } catch (InstantiationException | IllegalAccessException
                                  | IllegalArgumentException | InvocationTargetException
                                  | NoSuchMethodException | SecurityException ex) {
                              cause = ex;
                          }
                      }
                      if (permission == null) {
                          try {
                              Constructor<?> constructor = c.getConstructor(String.class, String.class);
                              permission = (Permission) constructor.newInstance(
                                      info.getPermissionName(),
                                      info.getPermissionAction());
                          } catch (InstantiationException | IllegalAccessException
                                  | IllegalArgumentException | InvocationTargetException
                                  | NoSuchMethodException | SecurityException ex) {
                              cause = ex;
                          }
                      }
                  } catch (ClassNotFoundException ex) { }
                  if (permission == null) {
                      InstantiationException iex =
                              new InstantiationException("Unable to instantiate required permission");
                      iex.initCause(cause);
                  }
              }
          }
  
          public String execute(String[] args) {
              if (permission != null) {
                  SecurityManager sm = System.getSecurityManager();
                  if (sm != null) {
                      sm.checkPermission(permission);
                  }
              }
              if(args == null) {
                  return executeDiagnosticCommand(cmd);
              } else {
                  StringBuilder sb = new StringBuilder();
                  sb.append(cmd);
                  for(int i=0; i<args.length; i++) {
                      if(args[i] == null) {
                          throw new IllegalArgumentException("Invalid null argument");
                      }
                      sb.append(" ");
                      sb.append(args[i]);
                  }
                  return executeDiagnosticCommand(sb.toString());
              }
          }
      }
  
      DiagnosticCommandImpl(VMManagement jvm) {
          this.jvm = jvm;
          isSupported = jvm.isRemoteDiagnosticCommandsSupported();
      }
  
      private static class OperationInfoComparator implements Comparator<MBeanOperationInfo> {
          @Override
          public int compare(MBeanOperationInfo o1, MBeanOperationInfo o2) {
              return o1.getName().compareTo(o2.getName());
          }
      }
  
      @Override
      public MBeanInfo getMBeanInfo() {
          SortedSet<MBeanOperationInfo> operations = new TreeSet<>(new OperationInfoComparator());
          Map<String, Wrapper> wrappersmap;
          if (!isSupported) {
              wrappersmap = Collections.emptyMap();
          } else {
              try {
                  String[] command = getDiagnosticCommands();
                  DiagnosticCommandInfo[] info = getDiagnosticCommandInfo(command);
                  MBeanParameterInfo stringArgInfo[] = new MBeanParameterInfo[]{
                      new MBeanParameterInfo("arguments", strArrayClassName,
                      "Array of Diagnostic Commands Arguments and Options")
                  };
                  wrappersmap = new HashMap<>();
                  for (int i = 0; i < command.length; i++) {
                      String name = transform(command[i]);
                      try {
                          Wrapper w = new Wrapper(name, command[i], info[i]);
                          wrappersmap.put(name, w);
                          operations.add(new MBeanOperationInfo(
                                  w.name,
                                  w.info.getDescription(),
                                  (w.info.getArgumentsInfo() == null
                                      || w.info.getArgumentsInfo().isEmpty())
                                      ? null : stringArgInfo,
                                  strClassName,
                                  MBeanOperationInfo.ACTION_INFO,
                                  commandDescriptor(w)));
                      } catch (InstantiationException ex) {
                          // If for some reasons the creation of a diagnostic command
                          // wrappers fails, the diagnostic command is just ignored
                          // and won't appear in the DynamicMBean
                      }
                  }
              } catch (IllegalArgumentException | UnsupportedOperationException e) {
                  wrappersmap = Collections.emptyMap();
              }
          }
          wrappers =  Collections.unmodifiableMap(wrappersmap);
          HashMap<String, Object> map = new HashMap<>();
          map.put("immutableInfo", "false");
          map.put("interfaceClassName","com.sun.management.DiagnosticCommandMBean");
          map.put("mxbean", "false");
          Descriptor desc = new ImmutableDescriptor(map);
          return new MBeanInfo(
                  this.getClass().getName(),
                  "Diagnostic Commands",
                  null, // attributes
                  null, // constructors
                  operations.toArray(new MBeanOperationInfo[operations.size()]), // operations
                  getNotificationInfo(), // notifications
                  desc);
      }
  
      @Override
      public Object invoke(String actionName, Object[] params, String[] signature)
              throws MBeanException, ReflectionException {
          if (!isSupported) {
              throw new UnsupportedOperationException();
          }
  