Program: 74230
Project: 74230
Buggy source:
/** 
 * If the transferrable object is recognized as a Ptolemy II object, then use the MoML description of the object to create a new instance of the object at the drop location. If the drop location is on top of an icon representing an instance of NamedObj, then make that instance the container of the new object. Otherwise, make the model associated with the graph the container. This is called when the drag operation has terminated with a drop on the operable part of the drop site for the DropTarget registered with this listener.
 * @param dtde The drop event.
 */
public void drop(DropTargetDropEvent dtde){
  for (int i=0; i < _additionalListeners.size(); i++) {
    DropTargetListener l=(DropTargetListener)_additionalListeners.elementAt(i);
    l.drop(dtde);
  }
  if (_highlighted != null) {
    _highlighter.renderDeselected(_highlightedFigure);
    _highlighted=null;
    _highlightedFigure=null;
  }
  Point2D originalPoint=SnapConstraint.constrainPoint(dtde.getLocation());
  NamedObj container=_getObjectUnder(originalPoint);
  GraphPane pane=((JGraph)getComponent()).getGraphPane();
  if ((container == null) || !_dropIntoEnabled) {
    GraphController controller=pane.getGraphController();
    GraphModel model=controller.getGraphModel();
    container=(NamedObj)model.getRoot();
  }
  Point2D transformedPoint=new Point2D.Double();
  pane.getTransformContext().getInverseTransform().transform(originalPoint,transformedPoint);
  Iterator iterator=null;
  List dropObjects=null;
  if (dtde.isDataFlavorSupported(PtolemyTransferable.namedObjFlavor)) {
    try {
      dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
      dropObjects=(List)dtde.getTransferable().getTransferData(PtolemyTransferable.namedObjFlavor);
      iterator=dropObjects.iterator();
    }
 catch (    Exception e) {
      MessageHandler.error("String_Node_Str" + dtde,e);
      return;
    }
  }
 else {
    dtde.rejectDrop();
  }
  if (iterator == null) {
    return;
  }
  StringBuffer moml=new StringBuffer();
  while (iterator.hasNext()) {
    final NamedObj dropObj=(NamedObj)iterator.next();
    final String name;
    if (dropObj instanceof Singleton) {
      name=dropObj.getName();
    }
 else {
      name=container.uniqueName(dropObj.getName());
    }
    Point2D newPoint=SnapConstraint.constrainPoint(transformedPoint);
    boolean lsidFlag=true;
    try {
      String lsidString=((StringAttribute)(dropObj.getAttribute("String_Node_Str"))).getExpression();
      if ((lsidString == null) || (lsidString.equals("String_Node_Str")))       lsidFlag=false;
    }
 catch (    Exception eee) {
      lsidFlag=false;
    }
    String result="String_Node_Str";
    String rootNodeName=dropObj.getElementName();
    Object object=null;
    StringAttribute alternateGetMomlActionAttribute=null;
    alternateGetMomlActionAttribute=(StringAttribute)dropObj.getAttribute("String_Node_Str");
    if (alternateGetMomlActionAttribute == null && lsidFlag) {
      Configuration config=null;
      List configsList=Configuration.configurations();
      for (Iterator it=configsList.iterator(); it.hasNext(); ) {
        config=(Configuration)it.next();
        if (config != null) {
          break;
        }
      }
      if (config == null) {
        throw new KernelRuntimeException(dropObj,"String_Node_Str" + "String_Node_Str" + configsList.size() + "String_Node_Str");
      }
      alternateGetMomlActionAttribute=(StringAttribute)config.getAttribute("String_Node_Str");
    }
    if (alternateGetMomlActionAttribute != null) {
      String alternateGetMomlClassName=alternateGetMomlActionAttribute.getExpression();
      try {
        Class getMomlClass=Class.forName(alternateGetMomlClassName);
        object=getMomlClass.newInstance();
        try {
          Method getMomlMethod=getMomlClass.getMethod("String_Node_Str",new Class[]{NamedObj.class,String.class});
          result=(String)getMomlMethod.invoke(object,new Object[]{dropObj,name});
        }
 catch (        NoSuchMethodException e) {
          Method getMomlMethod=getMomlClass.getMethod("String_Node_Str",new Class[]{NamedObj.class});
          result=(String)getMomlMethod.invoke(object,new Object[]{dropObj});
          int int1=1;
          int int2=result.indexOf("String_Node_Str");
          rootNodeName=result.substring(int1,int2);
          int1=result.indexOf("String_Node_Str",1);
          int2=result.indexOf("String_Node_Str",int1 + 1);
          result=result.substring(0,int1 + 1) + name + result.substring(int2,result.length());
        }
        moml.append(result);
      }
 catch (      Exception w) {
        System.out.println("String_Node_Str");
      }
    }
 else {
      moml.append("String_Node_Str");
      result=dropObj.exportMoML(name);
      moml.append(result);
      moml.append("String_Node_Str" + rootNodeName + "String_Node_Str"+ name+ "String_Node_Str");
      moml.append("String_Node_Str" + "String_Node_Str");
      moml.append((int)newPoint.getX());
      moml.append("String_Node_Str");
      moml.append((int)newPoint.getY());
      moml.append("String_Node_Str" + rootNodeName + "String_Node_Str");
      moml.append("String_Node_Str");
    }
  }
  if (container instanceof DropTargetHandler) {
    try {
      ((DropTargetHandler)container).dropObject(container,dropObjects,moml.toString());
    }
 catch (    IllegalActionException e) {
      MessageHandler.error("String_Node_Str" + container.getName() + "String_Node_Str",e);
    }
  }
 else {
    moml.insert(0,"String_Node_Str");
    moml.append("String_Node_Str");
    MoMLChangeRequest request=new MoMLChangeRequest(this,container,moml.toString());
    request.setUndoable(true);
    container.requestChange(request);
  }
  dtde.dropComplete(true);
  JComponent comp=(JComponent)getComponent();
  if (comp != null) {
    ToolTipManager.sharedInstance().registerComponent(comp);
  }
}

Fixed version (ground truth):
/** 
 * If the transferrable object is recognized as a Ptolemy II object, then use the MoML description of the object to create a new instance of the object at the drop location. If the drop location is on top of an icon representing an instance of NamedObj, then make that instance the container of the new object. Otherwise, make the model associated with the graph the container. This is called when the drag operation has terminated with a drop on the operable part of the drop site for the DropTarget registered with this listener.
 * @param dtde The drop event.
 */
public void drop(DropTargetDropEvent dtde){
  for (int i=0; i < _additionalListeners.size(); i++) {
    DropTargetListener l=(DropTargetListener)_additionalListeners.elementAt(i);
    l.drop(dtde);
  }
  if (_highlighted != null) {
    _highlighter.renderDeselected(_highlightedFigure);
    _highlighted=null;
    _highlightedFigure=null;
  }
  Point2D originalPoint=SnapConstraint.constrainPoint(dtde.getLocation());
  NamedObj container=_getObjectUnder(originalPoint);
  GraphPane pane=((JGraph)getComponent()).getGraphPane();
  if ((container == null) || !_dropIntoEnabled) {
    GraphController controller=pane.getGraphController();
    GraphModel model=controller.getGraphModel();
    container=(NamedObj)model.getRoot();
  }
  Point2D transformedPoint=new Point2D.Double();
  pane.getTransformContext().getInverseTransform().transform(originalPoint,transformedPoint);
  Iterator iterator=null;
  List dropObjects=null;
  if (dtde.isDataFlavorSupported(PtolemyTransferable.namedObjFlavor)) {
    try {
      dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
      dropObjects=(List)dtde.getTransferable().getTransferData(PtolemyTransferable.namedObjFlavor);
      iterator=dropObjects.iterator();
    }
 catch (    Exception e) {
      MessageHandler.error("String_Node_Str" + dtde,e);
      return;
    }
  }
 else {
    dtde.rejectDrop();
  }
  if (iterator == null) {
    return;
  }
  StringBuffer moml=new StringBuffer();
  while (iterator.hasNext()) {
    final NamedObj dropObj=(NamedObj)iterator.next();
    final String name;
    if (dropObj instanceof Singleton) {
      name=dropObj.getName();
    }
 else {
      name=container.uniqueName(dropObj.getName());
    }
    Point2D newPoint=SnapConstraint.constrainPoint(transformedPoint);
    boolean lsidFlag=true;
    try {
      String lsidString=((StringAttribute)(dropObj.getAttribute("String_Node_Str"))).getExpression();
      if ((lsidString == null) || (lsidString.equals("String_Node_Str")))       lsidFlag=false;
    }
 catch (    Exception eee) {
      lsidFlag=false;
    }
    String result="String_Node_Str";
    String rootNodeName=dropObj.getElementName();
    Object object=null;
    StringAttribute alternateGetMomlActionAttribute=null;
    alternateGetMomlActionAttribute=(StringAttribute)dropObj.getAttribute("String_Node_Str");
    if (alternateGetMomlActionAttribute == null && lsidFlag) {
      Configuration config=null;
      List configsList=Configuration.configurations();
      for (Iterator it=configsList.iterator(); it.hasNext(); ) {
        config=(Configuration)it.next();
        if (config != null) {
          break;
        }
      }
      if (config == null) {
        throw new KernelRuntimeException(dropObj,"String_Node_Str" + "String_Node_Str" + configsList.size() + "String_Node_Str");
      }
      alternateGetMomlActionAttribute=(StringAttribute)config.getAttribute("String_Node_Str");
    }
    if (alternateGetMomlActionAttribute != null) {
      String alternateGetMomlClassName=alternateGetMomlActionAttribute.getExpression();
      try {
        Class getMomlClass=Class.forName(alternateGetMomlClassName);
        object=getMomlClass.newInstance();
        try {
          Method getMomlMethod=getMomlClass.getMethod("String_Node_Str",new Class[]{NamedObj.class,String.class});
          result=(String)getMomlMethod.invoke(object,new Object[]{dropObj,name});
        }
 catch (        NoSuchMethodException e) {
          Method getMomlMethod=getMomlClass.getMethod("String_Node_Str",new Class[]{NamedObj.class});
          result=(String)getMomlMethod.invoke(object,new Object[]{dropObj});
          int int1=1;
          int int2=result.indexOf("String_Node_Str");
          rootNodeName=result.substring(int1,int2);
          int1=result.indexOf("String_Node_Str",1);
          int2=result.indexOf("String_Node_Str",int1 + 1);
          result=result.substring(0,int1 + 1) + name + result.substring(int2,result.length());
        }
        moml.append("String_Node_Str");
        moml.append(result);
      }
 catch (      Exception w) {
        System.out.println("String_Node_Str");
      }
    }
 else {
      moml.append("String_Node_Str");
      result=dropObj.exportMoML(name);
      moml.append(result);
    }
    moml.append("String_Node_Str" + rootNodeName + "String_Node_Str"+ name+ "String_Node_Str");
    moml.append("String_Node_Str" + "String_Node_Str");
    moml.append((int)newPoint.getX());
    moml.append("String_Node_Str");
    moml.append((int)newPoint.getY());
    moml.append("String_Node_Str" + rootNodeName + "String_Node_Str");
    moml.append("String_Node_Str");
  }
  if (container instanceof DropTargetHandler) {
    try {
      ((DropTargetHandler)container).dropObject(container,dropObjects,moml.toString());
    }
 catch (    IllegalActionException e) {
      MessageHandler.error("String_Node_Str" + container.getName() + "String_Node_Str",e);
    }
  }
 else {
    moml.insert(0,"String_Node_Str");
    moml.append("String_Node_Str");
    MoMLChangeRequest request=new MoMLChangeRequest(this,container,moml.toString());
    request.setUndoable(true);
    container.requestChange(request);
  }
  dtde.dropComplete(true);
  JComponent comp=(JComponent)getComponent();
  if (comp != null) {
    ToolTipManager.sharedInstance().registerComponent(comp);
  }
}