code: public static void resetLocalsToFormals(MethodGen mg) {
  
      // Get the parameter types and names.
      @SuppressWarnings("nullness" // The annotation arguments might not be initialized yet.
      // Since the arguments are not executed at run time, there is no null pointer exception.
      )
      Type @SameLen({"argTypes", "mg.getArgumentTypes()"}) [] argTypes = mg.getArgumentTypes();
      @SuppressWarnings("nullness" // The annotation arguments might not be initialized yet.
      // Since the arguments are not executed at run time, there is no null pointer exception.
      )
      String @SameLen({"argTypes", "argNames", "mg.getArgumentTypes()", "mg.getArgumentNames()"}) []
          argNames = mg.getArgumentNames();
  
      // Remove any existing locals
      mg.setMaxLocals(0);
      mg.removeLocalVariables();
  
      // Add a local for the instance variable (this)
      if (!mg.isStatic()) {
        mg.addLocalVariable("this", new ObjectType(mg.getClassName()), null, null);
      }
  
      // Add a local for each parameter
      for (int ii = 0; ii < argNames.length; ii++) {
        mg.addLocalVariable(argNames[ii], argTypes[ii], null, null);
      }
  
      // Reset the current number of locals so that when other locals
      // are added they get added at the correct offset.
      mg.setMaxLocals();
  
      return;
    }
docs: Sets the locals to be the formal parameters. Any other locals are removed. An instruction list
  with at least one instruction must exist.
  
  @param mg the method whose locals to set