nus-yam/ex-repair huggingface dataset:
Program: 74888
Project: 74888
Buggy source:
/** 
 * Output the Java source from the current AST with   {@link ASTFormatter}.
 * @param writer The writer where the output is written to.
 */
protected void _outputSource(Writer writer,String fileName) throws IOException {
  FileInputStream stream=new FileInputStream(fileName);
  ASTFormatter formatter=new ASTFormatter(writer,stream);
  _ast.accept(formatter);
  stream.close();
}

Fixed version (ground truth):
/** 
 * Output the Java source from the current AST with   {@link ASTFormatter}.
 * @param writer The writer where the output is written to.
 * @param fileName The file name of the writer.
 * @exception IOException If error occurs while writing to the writer.
 */
protected void _outputSource(Writer writer,String fileName) throws IOException {
  FileInputStream stream=new FileInputStream(fileName);
  ASTFormatter formatter=new ASTFormatter(writer,stream);
  _ast.accept(formatter);
  stream.close();
}
Program: 74889
Project: 74889
Buggy source:
/** 
 * Create a type with a full name of a primitive type or a class. Users cannot directly create a type object with <tt>new</tt>. Instead, they should always use this function. <p> They full name of the type given can be any of the primitive types as well as <tt>null</tt> or <tt>void</tt>. When it is the name of an array type, both source representation (as "<tt>char[]</tt>") or run-time representation (as "<tt>[C<tt>") are accepted.
 * @param fullName The full name of the type.
 * @return The type object with the given name. No error is returned whenthe name is incorrect.
 */
public static Type createType(String fullName){
  fullName=toArrayType(fullName);
  if (_typeObjects.containsKey(fullName)) {
    return (Type)_typeObjects.get(fullName);
  }
 else {
    Type type;
    if (PRIMITIVE_TYPES.containsKey(fullName)) {
      type=(Type)PRIMITIVE_TYPES.get(fullName);
    }
 else {
      type=new Type(fullName);
    }
    _typeObjects.put(fullName,type);
    return type;
  }
}

Fixed version (ground truth):
/** 
 * Create a type with a full name of a primitive type or a class. Users cannot directly create a type object with <tt>new</tt>. Instead, they should always use this function. <p> They full name of the type given can be any of the primitive types as well as <tt>null</tt> or <tt>void</tt>. When it is the name of an array type, both source representation (as "<tt>char[]</tt>") or run-time representation (as "<tt>[C</tt>") are accepted.
 * @param fullName The full name of the type.
 * @return The type object with the given name. No error is returned whenthe name is incorrect.
 */
public static Type createType(String fullName){
  fullName=toArrayType(fullName);
  if (_typeObjects.containsKey(fullName)) {
    return (Type)_typeObjects.get(fullName);
  }
 else {
    Type type;
    if (PRIMITIVE_TYPES.containsKey(fullName)) {
      type=(Type)PRIMITIVE_TYPES.get(fullName);
    }
 else {
      type=new Type(fullName);
    }
    _typeObjects.put(fullName,type);
    return type;
  }
}
Program: 74890
Project: 74890
Buggy source:
/** 
 * Get the owner associated with an AST node, if it is resolved as a field or method. The owner is the type that the field or method belongs to.
 * @param node The node with an owner associated with it.
 * @return The owner. <tt>null</tt> if the node is not a classmember or there is no owner associated with it.
 */
public static Type getOwner(ASTNode node){
  return (Type)node.getProperty("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Get the owner associated with an AST node, if it is resolved as a field or method. The owner is the type that the field or method belongs to.
 * @param node The node with an owner associated with it.
 * @return The owner. <tt>null</tt> if the node is not a classmember or there is no owner associated with it.
 * @see #setOwner(ASTNode,Type)
 */
public static Type getOwner(ASTNode node){
  return (Type)node.getProperty("String_Node_Str");
}
Program: 74891
Project: 74891
Buggy source:
/** 
 * Set the owner associated with an AST node, if it is resolved as a field or method. The owner is the type that the field or method belongs to.
 * @param node The node with an owner associated with it.
 * @param owner The type of the owner.
 * @see #setOwner(ASTNode,Type)
 */
public static void setOwner(ASTNode node,Type owner){
  node.setProperty("String_Node_Str",owner);
}

Fixed version (ground truth):
/** 
 * Set the owner associated with an AST node, if it is resolved as a field or method. The owner is the type that the field or method belongs to.
 * @param node The node with an owner associated with it.
 * @param owner The type of the owner.
 * @see #getOwner(ASTNode)
 */
public static void setOwner(ASTNode node,Type owner){
  node.setProperty("String_Node_Str",owner);
}
Program: 74892
Project: 74892
Buggy source:
/** 
 * Count the number of dimensions of an array type.
 * @return The number of dimensions (>0) if the type is an array;otherwise, return 0 (scalar).
 * @see #dimensions()
 */
public static int dimensions(String type){
  int bracketPos=type.indexOf("String_Node_Str");
  int dim=0;
  while (bracketPos >= 0) {
    dim++;
    bracketPos=type.indexOf("String_Node_Str",bracketPos + 1);
  }
  return dim;
}

Fixed version (ground truth):
/** 
 * Count the number of dimensions of an array type.
 * @param type The array type.
 * @return The number of dimensions (>0) if the type is an array;otherwise, return 0 (scalar).
 * @see #dimensions()
 */
public static int dimensions(String type){
  int bracketPos=type.indexOf("String_Node_Str");
  int dim=0;
  while (bracketPos >= 0) {
    dim++;
    bracketPos=type.indexOf("String_Node_Str",bracketPos + 1);
  }
  return dim;
}
Program: 74893
Project: 74893
Buggy source:
/** 
 * Construct an analyzer with with an array of explicit class paths for its class loader (an instanceof   {@link LocalClassLoader}).
 */
public TypeAnalyzer(String[] classPaths){
  _state.setClassLoader(new LocalClassLoader(classPaths));
}

Fixed version (ground truth):
/** 
 * Construct an analyzer with with an array of explicit class paths for its class loader (an instanceof   {@link LocalClassLoader}).
 * @param classPaths The class paths.
 */
public TypeAnalyzer(String[] classPaths){
  _state.setClassLoader(new LocalClassLoader(classPaths));
}
Program: 74894
Project: 74894
Buggy source:
/** 
 * Set the current scope to be a class scope (a scope opened by a class declaration).
 * @param scope The scope to be set.
 * @see #unsetClassScope()
 */
public void setClassScope(){
  _classScopes.add(new Integer(_variableStack.size() - 1));
}

Fixed version (ground truth):
/** 
 * Set the current scope to be a class scope (a scope opened by a class declaration).
 * @see #unsetClassScope()
 */
public void setClassScope(){
  _classScopes.add(new Integer(_variableStack.size() - 1));
}
Program: 74895
Project: 74895
Buggy source:
/** 
 * Get the current class (the class currently being inspected).
 * @param currentClass The current class, or <tt>null</tt> if thereis no current class.
 * @see #setCurrentClass(Class)
 */
public void setCurrentClass(Class currentClass){
  _currentClass=currentClass;
}

Fixed version (ground truth):
/** 
 * Get the current class (the class currently being inspected).
 * @param currentClass The current class, or <tt>null</tt> if thereis no current class.
 * @see #getCurrentClass()
 */
public void setCurrentClass(Class currentClass){
  _currentClass=currentClass;
}
Program: 74896
Project: 74896
Buggy source:
/** 
 * Unset the current scope as a class scope (a scope opened by a class declaration). <p> A class scope should be unset when removed from the scope stack.
 * @param scope The scope to be set.
 * @see #setClassScope()
 */
public void unsetClassScope(){
  _classScopes.remove(new Integer(_variableStack.size() - 1));
}

Fixed version (ground truth):
/** 
 * Unset the current scope as a class scope (a scope opened by a class declaration). <p> A class scope should be unset when removed from the scope stack.
 * @see #setClassScope()
 */
public void unsetClassScope(){
  _classScopes.remove(new Integer(_variableStack.size() - 1));
}
Program: 74898
Project: 74898
Buggy source:
/** 
 * Get the shortest possible name of the a class. If there is no conflict, the class is first imported, and only the simple class is returned; otherwise, the its full name is returned.
 * @param name The full class name.
 * @param loader The class loader used to test importation conflicts.
 * @param root The root of the AST. If there is no conflict and the classhas not been imported yet, a new  {@link ImportDeclaration} is added toit.
 * @return The shortest possible class name.
 */
public static String getClassName(String name,TypeAnalyzerState state,CompilationUnit root){
  int dimensions=Type.dimensions(name);
  if (dimensions > 0) {
    name=Type.getElementType(name);
  }
  name=_getNonarrayClassName(name,state,root);
  if (dimensions > 0) {
    Type type=Type.createType(name);
    for (int i=0; i < dimensions; i++) {
      type=type.addOneDimension();
    }
    name=type.getName();
  }
  return name;
}

Fixed version (ground truth):
/** 
 * Get the shortest possible name of the a class. If there is no conflict, the class is first imported, and only the simple class is returned; otherwise, the its full name is returned.
 * @param name The full class name.
 * @param state The state of the type analyzer.
 * @param root The root of the AST. If there is no conflict and the classhas not been imported yet, a new  {@link ImportDeclaration} is added toit.
 * @return The shortest possible class name.
 */
public static String getClassName(String name,TypeAnalyzerState state,CompilationUnit root){
  int dimensions=Type.dimensions(name);
  if (dimensions > 0) {
    name=Type.getElementType(name);
  }
  name=_getNonarrayClassName(name,state,root);
  if (dimensions > 0) {
    Type type=Type.createType(name);
    for (int i=0; i < dimensions; i++) {
      type=type.addOneDimension();
    }
    name=type.getName();
  }
  return name;
}
Program: 74899
Project: 74899
Buggy source:
/** 
 * Execute actions after the AST is traversed. (Not necessary for this rule.)
 * @param root The root of the AST.
 */
public void afterTraverse(TypeAnalyzer analyzer,CompilationUnit root){
}

Fixed version (ground truth):
/** 
 * Execute actions after the AST is traversed. (Not necessary for this rule.)
 * @param analyzer The type analyzer.
 * @param root The root of the AST.
 */
public void afterTraverse(TypeAnalyzer analyzer,CompilationUnit root){
}
Program: 74900
Project: 74900
Buggy source:
/** 
 * Rename the occurance of package names after the AST is traversed. The transformer implemented for this rule traverses the AST once again and looks up package names that need to be changed. <p> Due to the change of the package that the class belongs to, originally accessible classes in the same package may becomes inaccessable. This transformer explicitly imports those classes when necessary. Unfortunately, protected classes originally in the same package may not be imported, and protected members of other classes in that package are no longer accessible. It is the user's responsibility to ensure that those cases do not happen.
 * @param root The root of the AST.
 */
public void afterTraverse(TypeAnalyzer analyzer,CompilationUnit root){
  if ((_prefix != null) && (_prefix.length() > 0)) {
    root.accept(new Renamer(analyzer.getState()));
    PackageDeclaration packageDeclaration=root.getPackage();
    AST ast=root.getAST();
    if (packageDeclaration == null) {
      packageDeclaration=ast.newPackageDeclaration();
      packageDeclaration.setName(AbstractTransformer.createName(ast,_prefix));
      root.setPackage(packageDeclaration);
    }
  }
}

Fixed version (ground truth):
/** 
 * Rename the occurance of package names after the AST is traversed. The transformer implemented for this rule traverses the AST once again and looks up package names that need to be changed. <p> Due to the change of the package that the class belongs to, originally accessible classes in the same package may becomes inaccessable. This transformer explicitly imports those classes when necessary. Unfortunately, protected classes originally in the same package may not be imported, and protected members of other classes in that package are no longer accessible. It is the user's responsibility to ensure that those cases do not happen.
 * @param analyzer The type analyzer.
 * @param root The root of the AST.
 */
public void afterTraverse(TypeAnalyzer analyzer,CompilationUnit root){
  if ((_prefix != null) && (_prefix.length() > 0)) {
    root.accept(new Renamer(analyzer.getState()));
    PackageDeclaration packageDeclaration=root.getPackage();
    AST ast=root.getAST();
    if (packageDeclaration == null) {
      packageDeclaration=ast.newPackageDeclaration();
      packageDeclaration.setName(AbstractTransformer.createName(ast,_prefix));
      root.setPackage(packageDeclaration);
    }
  }
}
Program: 74901
Project: 74901
Buggy source:
public void filterEndElement(NamedObj container,String elementName){
  if ((elementName.equals("String_Node_Str") || elementName.equals("String_Node_Str")) && container.getClassName() != null) {
    _classStack.pop();
  }
}

Fixed version (ground truth):
public void filterEndElement(NamedObj container,String elementName){
  if ((elementName.equals("String_Node_Str") || elementName.equals("String_Node_Str")) && container != null && container.getClassName() != null) {
    _classStack.pop();
  }
}
Program: 74902
Project: 74902
Buggy source:
/** 
 * Add the bits from the input port and output the high bit and low bit if they can be determined.
 * @exception IllegalActionException If there is no director,if there are not exactly three channels connected to the input, or if invalid inputs are received.
 */
public void fire() throws IllegalActionException {
  super.fire();
  int numKnown=0;
  int numOnes=0;
  int width=inputBits.getWidth();
  if (width != 3) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  for (int i=0; i < width; i++) {
    if (inputBits.isKnown(i)) {
      numKnown++;
      if (inputBits.hasToken(i)) {
        int value=((IntToken)inputBits.get(i)).intValue();
        if ((value != 0) && (value != 1)) {
          throw new IllegalActionException(this,"String_Node_Str");
        }
        if (value == 1) {
          numOnes++;
        }
      }
    }
  }
  IntToken high=null;
  IntToken low=null;
  if (numKnown == 3) {
    if ((numOnes == 0) || (numOnes == 2)) {
      low=new IntToken(0);
    }
 else {
      low=new IntToken(1);
    }
  }
  if ((numKnown - numOnes) >= 2) {
    high=new IntToken(0);
  }
  if (numOnes >= 2) {
    high=new IntToken(1);
  }
  if (high != null) {
    highBit.send(0,high);
  }
  if (low != null) {
    lowBit.send(0,low);
  }
}

Fixed version (ground truth):
/** 
 * Add the bits from the input port and output the high bit and low bit if they can be determined.
 * @exception IllegalActionException If there is no director,if there are not exactly three channels connected to the input, or if invalid inputs are received.
 */
public void fire() throws IllegalActionException {
  super.fire();
  int numKnown=0;
  int numOnes=0;
  int width=inputBits.getWidth();
  if (width != 3) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  for (int i=0; i < width; i++) {
    if (inputBits.isKnown(i)) {
      numKnown++;
      if (inputBits.hasToken(i)) {
        int value=((IntToken)inputBits.get(i)).intValue();
        if ((value != 0) && (value != 1)) {
          throw new IllegalActionException(this,"String_Node_Str");
        }
        if (value == 1) {
          numOnes++;
        }
      }
    }
  }
  IntToken high=null;
  IntToken low=null;
  if (numKnown == 3) {
    if ((numOnes == 0) || (numOnes == 2)) {
      low=new IntToken(0);
    }
 else {
      low=new IntToken(1);
    }
  }
  if (numKnown >= 2) {
    if (numOnes >= 2) {
      high=new IntToken(1);
    }
 else {
      high=new IntToken(0);
    }
  }
  if (high != null) {
    highBit.send(0,high);
  }
  if (low != null) {
    lowBit.send(0,low);
  }
}
Program: 74903
Project: 74903
Buggy source:
/** 
 * Overrride the superclass to keep track of receivers that are created during preinitialize().
 * @exception IllegalActionException If the preinitialize() method ofone of the associated actors throws it.
 */
public void preinitialize() throws IllegalActionException {
  _receivers.clear();
  super.preinitialize();
}

Fixed version (ground truth):
/** 
 * Overrride the superclass to keep track of receivers that are created during preinitialize().
 * @exception IllegalActionException If the preinitialize() method ofone of the associated actors throws it.
 */
public void preinitialize() throws IllegalActionException {
  super.preinitialize();
}
Program: 74904
Project: 74904
Buggy source:
/** 
 * Reset current sequence number to the value given by the <i>startingSequenceNumber</i> parameter.
 * @exception IllegalActionException If accessing the<i>startingSequenceNumber</i> parameter causes an exception.
 */
public void initialize() throws IllegalActionException {
  _fireProducedOutput=false;
  _nextSequenceNumber=((IntToken)startingSequenceNumber.getToken()).intValue();
}

Fixed version (ground truth):
/** 
 * Reset current sequence number to the value given by the <i>startingSequenceNumber</i> parameter.
 * @exception IllegalActionException If accessing the<i>startingSequenceNumber</i> parameter causes an exception.
 */
public void initialize() throws IllegalActionException {
  _fireProducedOutput=false;
  _nextSequenceNumber=((IntToken)startingSequenceNumber.getToken()).intValue();
  _pending.clear();
}
Program: 74905
Project: 74905
Buggy source:
/** 
 * Construct a union by assigning the label value given by the children nodes.
 * @param node The union constructor node.
 * @exception IllegalActionException If an evaluation error occurs.
 */
public void visitUnionConstructNode(ASTPtUnionConstructNode node) throws IllegalActionException {
  if (node.isConstant() && node.isEvaluated()) {
    _evaluatedChildToken=node.getToken();
    return;
  }
  ptolemy.data.Token[] tokens=_evaluateAllChildren(node);
  int numChildren=node.jjtGetNumChildren();
  _assert(node.getLabelNames().size() == numChildren,node,"String_Node_Str" + "String_Node_Str");
  String[] labels=(String[])node.getLabelNames().toArray(new String[numChildren]);
  _assert(labels.length == 1,node,"String_Node_Str");
  _evaluatedChildToken=(new UnionToken(labels[0],tokens[0]));
  if (node.isConstant()) {
    node.setToken(_evaluatedChildToken);
  }
}

Fixed version (ground truth):
/** 
 * Construct a union by assigning the label value given by the children nodes.
 * @param node The union constructor node.
 * @exception IllegalActionException If an evaluation error occurs.
 */
public void visitUnionConstructNode(ASTPtUnionConstructNode node) throws IllegalActionException {
  if (node.isConstant() && node.isEvaluated()) {
    _evaluatedChildToken=node.getToken();
    return;
  }
  ptolemy.data.Token[] tokens=_evaluateAllChildren(node);
  int numChildren=node.jjtGetNumChildren();
  _assert(node.getLabelNames().size() == numChildren,node,"String_Node_Str" + "String_Node_Str");
  String[] labels=(String[])node.getLabelNames().toArray(new String[numChildren]);
  if (labels.length > 0) {
    _evaluatedChildToken=(new UnionToken(labels[0],tokens[0]));
  }
  _evaluatedChildToken=(new UnionToken(labels[0],tokens[0]));
  if (node.isConstant()) {
    node.setToken(_evaluatedChildToken);
  }
}
Program: 74907
Project: 74907
Buggy source:
/** 
 * Trace the evaluation of the parse tree with the specified root node using the specified scope to resolve the values of variables.
 * @param node The root of the parse tree.
 * @param scope The scope for evaluation.
 * @return The trace of the evaluation.
 * @exception IllegalActionException If an error occurs duringevaluation.
 */
public String traceParseTreeEvaluation(ASTPtRootNode node,ParserScope scope) throws IllegalActionException {
  _scope=scope;
  _trace=new StringBuffer();
  _depth=0;
  _traceEnter(node);
  try {
    node.visit(this);
    _traceLeave(node);
  }
 catch (  Exception ex) {
    _trace(ex.toString());
  }
  _scope=null;
  String trace=_trace.toString();
  _trace=null;
  return trace;
}

Fixed version (ground truth):
/** 
 * Trace the evaluation of the parse tree with the specified root node using the specified scope to resolve the values of variables.
 * @param node The root of the parse tree.
 * @param scope The scope for evaluation.
 * @return The trace of the evaluation.
 * @exception IllegalActionException If an error occurs duringevaluation.
 */
public String traceParseTreeEvaluation(ASTPtRootNode node,ParserScope scope) throws IllegalActionException {
  _scope=scope;
  _trace=new StringBuffer();
  _depth=0;
  _traceEnter(node);
  try {
    node.visit(this);
    _traceLeave(node);
  }
 catch (  Exception ex) {
    _trace(KernelException.stackTraceToString(ex));
  }
  _scope=null;
  String trace=_trace.toString();
  _trace=null;
  return trace;
}
Program: 74909
Project: 74909
Buggy source:
private void _initORB(String[] args) throws IllegalActionException {
  try {
    _orb=ORB.init(args,null);
    _debug(getName(),"String_Node_Str");
    org.omg.CORBA.Object objRef=_orb.resolve_initial_references("String_Node_Str");
    NamingContext ncRef=NamingContextHelper.narrow(objRef);
    if (ncRef != null) {
      _debug(getName(),"String_Node_Str");
    }
    NameComponent namecomp=new NameComponent(((StringToken)remoteConsumerName.getToken()).stringValue(),"String_Node_Str");
    _debug(getName(),"String_Node_Str",(remoteConsumerName.getToken()).toString());
    NameComponent[] path={namecomp};
    while (!_stopRequested) {
      try {
        _debug("String_Node_Str");
        _remoteConsumer=ptolemy.actor.corba.CorbaIOUtil.pushConsumerHelper.narrow(ncRef.resolve(path));
        _debug("String_Node_Str");
        if (_remoteConsumer instanceof pushConsumer) {
          _debug("String_Node_Str");
          break;
        }
        try {
          Thread.sleep(1000);
        }
 catch (        InterruptedException e) {
          _debug("String_Node_Str" + "String_Node_Str");
        }
      }
 catch (      Exception exp) {
        _debug("String_Node_Str");
        try {
          Thread.sleep(1000);
        }
 catch (        InterruptedException ex1) {
          _debug("String_Node_Str" + "String_Node_Str");
        }
      }
    }
  }
 catch (  UserException ex) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ ex.getMessage());
  }
}

Fixed version (ground truth):
private void _initORB(String[] args) throws IllegalActionException {
  try {
    _orb=ORB.init(args,null);
    _debug(getName(),"String_Node_Str");
    org.omg.CORBA.Object objRef=_orb.resolve_initial_references("String_Node_Str");
    NamingContext ncRef=NamingContextHelper.narrow(objRef);
    if (ncRef != null) {
      _debug(getName(),"String_Node_Str");
    }
    NameComponent namecomp=new NameComponent(((StringToken)remoteConsumerName.getToken()).stringValue(),"String_Node_Str");
    _debug(getName(),"String_Node_Str",(remoteConsumerName.getToken()).toString());
    NameComponent[] path={namecomp};
    while (!_stopRequested) {
      try {
        _debug("String_Node_Str");
        _remoteConsumer=ptolemy.actor.corba.CorbaIOUtil.pushConsumerHelper.narrow(ncRef.resolve(path));
        _debug("String_Node_Str");
        _debug("String_Node_Str");
        break;
      }
 catch (      Exception exp) {
        _debug("String_Node_Str");
        try {
          Thread.sleep(1000);
        }
 catch (        InterruptedException ex1) {
          _debug("String_Node_Str" + "String_Node_Str");
        }
      }
    }
  }
 catch (  UserException ex) {
    throw new IllegalActionException(this,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ ex.getMessage());
  }
}
Program: 74911
Project: 74911
Buggy source:
/** 
 * Return true if type2 is a subtype of type1.
 */
public static boolean isSubtypeOf(Type type1,Type type2){
  if (type1 instanceof RefType && type2 instanceof RefType) {
    SootClass class1=((RefType)type1).getSootClass();
    SootClass class2=((RefType)type2).getSootClass();
    return derivesFrom(class1,class2);
  }
 else   if (type1 instanceof Type && type2 instanceof RefType) {
    Type elementType1=((ArrayType)type1).baseType;
    Type elementType2=((ArrayType)type2).baseType;
    return isSubtypeOf(elementType1,elementType2);
  }
 else {
    return type1.equals(type2);
  }
}

Fixed version (ground truth):
/** 
 * Return true if type2 is a subtype of type1.
 */
public static boolean isSubtypeOf(Type type1,Type type2){
  if (type1 instanceof RefType && type2 instanceof RefType) {
    SootClass class1=((RefType)type1).getSootClass();
    SootClass class2=((RefType)type2).getSootClass();
    return derivesFrom(class1,class2);
  }
 else   if (type2 instanceof RefType) {
    Type elementType1=((ArrayType)type1).baseType;
    Type elementType2=((ArrayType)type2).baseType;
    return isSubtypeOf(elementType1,elementType2);
  }
 else {
    return type1.equals(type2);
  }
}
Program: 74913
Project: 74913
Buggy source:
/** 
 * Invoke prefire() on all DYNAMIC_ACTORS, such as integrators, and emit their current states. Return true if all the prefire() methods return true and stop() is not called. Otherwise, return false.
 * @return True if all dynamic actors return true from their prefire()methods and stop() is called.
 * @exception IllegalActionException If scheduler throws it, or dynamicactors throw it in their prefire() method, or they can not be prefired.
 */
public boolean prefire() throws IllegalActionException {
  Schedule schedule=(Schedule)getScheduler().getSchedule();
  Iterator actors=schedule.actorIterator();
  boolean ready=true;
  while (actors.hasNext() && !_stopRequested) {
    Actor actor=(Actor)actors.next();
    if (_debugging && _verbose) {
      _debug("String_Node_Str" + ((Nameable)actor).getName());
    }
    ready&=actor.prefire();
    if (_debugging && _verbose) {
      _debug("String_Node_Str" + ((Nameable)actor).getName() + "String_Node_Str"+ ready);
    }
  }
  return ready && !_stopRequested;
}

Fixed version (ground truth):
/** 
 * Invoke prefire() on all DYNAMIC_ACTORS, such as integrators, and emit their current states. Return true if all the prefire() methods return true and stop() is not called. Otherwise, return false.
 * @return True if all dynamic actors return true from their prefire()methods and stop() is called.
 * @exception IllegalActionException If scheduler throws it, or dynamicactors throw it in their prefire() method, or they can not be prefired.
 */
public boolean prefire() throws IllegalActionException {
  Schedule schedule=getScheduler().getSchedule();
  Iterator actors=schedule.actorIterator();
  boolean ready=true;
  while (actors.hasNext() && !_stopRequested) {
    Actor actor=(Actor)actors.next();
    if (_debugging && _verbose) {
      _debug("String_Node_Str" + ((Nameable)actor).getName());
    }
    ready&=actor.prefire();
    if (_debugging && _verbose) {
      _debug("String_Node_Str" + ((Nameable)actor).getName() + "String_Node_Str"+ ready);
    }
  }
  return ready && !_stopRequested;
}
Program: 74914
Project: 74914
Buggy source:
/** 
 * Return error tolerance used for detecting enabled transitions.
 * @return The error tolerance used for detecting enabled transitions.
 */
public final double getErrorTolerance(){
  CTGeneralDirector executiveDirector=getExecutiveCTGeneralDirector();
  return ((CTGeneralDirector)executiveDirector).getErrorTolerance();
}

Fixed version (ground truth):
/** 
 * Return error tolerance used for detecting enabled transitions.
 * @return The error tolerance used for detecting enabled transitions.
 */
public final double getErrorTolerance(){
  CTGeneralDirector executiveDirector=getExecutiveCTGeneralDirector();
  return executiveDirector.getErrorTolerance();
}
Program: 74916
Project: 74916
Buggy source:
/** 
 * Initialize the integrator. Check for the existence of director and ODE solver. Update initial state parameter. Set the initial state to the tentative state and the state. Set tentative derivative to 0.0. Clear the history.
 * @exception IllegalActionException If there's no director,or, the director is not a CT director, or the director has no ODE solver, or thrown in the super class, or the initialState parameter does not contain a valid token.
 */
public void initialize() throws IllegalActionException {
  HSDirector dir=(HSDirector)getDirector();
  if (dir == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
 else   if (!(dir instanceof CTGeneralDirector)) {
    throw new IllegalActionException("String_Node_Str" + "String_Node_Str");
  }
  ODESolver solver=dir.getCurrentODESolver();
  if (solver == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  super.initialize();
  _tentativeState=((DoubleToken)initialState.getToken()).doubleValue();
  _state=_tentativeState;
  _storedState=_state;
  _derivative=0.0;
  if (_debugging) {
    _debug(getName(),"String_Node_Str" + _state + "String_Node_Str"+ _derivative);
  }
  _history.clear();
}

Fixed version (ground truth):
/** 
 * Initialize the integrator. Check for the existence of director and ODE solver. Update initial state parameter. Set the initial state to the tentative state and the state. Set tentative derivative to 0.0. Clear the history.
 * @exception IllegalActionException If there's no director,or, the director is not a CT director, or the director has no ODE solver, or thrown in the super class, or the initialState parameter does not contain a valid token.
 */
public void initialize() throws IllegalActionException {
  HSDirector director=(HSDirector)getDirector();
  if (director == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  ODESolver solver=director.getCurrentODESolver();
  if (solver == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  super.initialize();
  _tentativeState=((DoubleToken)initialState.getToken()).doubleValue();
  _state=_tentativeState;
  _storedState=_state;
  _derivative=0.0;
  if (_debugging) {
    _debug(getName(),"String_Node_Str" + _state + "String_Node_Str"+ _derivative);
  }
  _history.clear();
}
Program: 74917
Project: 74917
Buggy source:
/** 
 * Construct an SRReceiver with unknown state and the given director.
 * @param director The director of this receiver.
 */
public SRReceiver(SRDirector director){
  super((FPDirector)director);
}

Fixed version (ground truth):
/** 
 * Construct an SRReceiver with unknown state and the given director.
 * @param director The director of this receiver.
 */
public SRReceiver(SRDirector director){
  super(director);
}
Program: 74919
Project: 74919
Buggy source:
private void _initializeLocalVariables() throws IllegalActionException {
  _errorTolerance=((DoubleToken)errorTolerance.getToken()).doubleValue();
  _initStepSize=((DoubleToken)initStepSize.getToken()).doubleValue();
  _maxIterations=((IntToken)maxIterations.getToken()).intValue();
  _maxStepSize=((DoubleToken)maxStepSize.getToken()).doubleValue();
  _minStepSize=((DoubleToken)minStepSize.getToken()).doubleValue();
  _valueResolution=((DoubleToken)valueResolution.getToken()).doubleValue();
  _currentSolver=null;
  _prefiredActors=new HashSet();
  _currentStepSize=_initStepSize;
  _suggestedNextStepSize=_initStepSize;
  _discretePhase=true;
  _executionPhase=CTExecutionPhase.UNKNOWN_PHASE;
  if (_debugging) {
    _debug(getFullName(),"String_Node_Str");
  }
  TotallyOrderedSet breakpoints=getBreakPoints();
  if (breakpoints != null) {
    breakpoints.clear();
  }
 else {
    _breakpoints=new TotallyOrderedSet(new GeneralComparator());
  }
}

Fixed version (ground truth):
private void _initializeLocalVariables() throws IllegalActionException {
  _errorTolerance=((DoubleToken)errorTolerance.getToken()).doubleValue();
  _initStepSize=((DoubleToken)initStepSize.getToken()).doubleValue();
  _maxIterations=((IntToken)maxIterations.getToken()).intValue();
  _maxStepSize=((DoubleToken)maxStepSize.getToken()).doubleValue();
  _minStepSize=((DoubleToken)minStepSize.getToken()).doubleValue();
  _valueResolution=((DoubleToken)valueResolution.getToken()).doubleValue();
  _currentSolver=null;
  _prefiredActors=new HashSet();
  _currentStepSize=_initStepSize;
  _suggestedNextStepSize=_initStepSize;
  _discretePhase=true;
  if (_debugging) {
    _debug(getFullName(),"String_Node_Str");
  }
  if (_breakpoints != null) {
    _breakpoints.clear();
  }
 else {
    _breakpoints=new TotallyOrderedSet(new GeneralComparator());
  }
}
Program: 74920
Project: 74920
Buggy source:
/** 
 * Override the fire() method of the super class. This method is abstract in this abstract base class. The derived classes need to override this method for concrete implementation.
 */
public abstract void fire() throws IllegalActionException ;

Fixed version (ground truth):
/** 
 * Override the fire() method of the super class. This method is abstract in this abstract base class. The derived classes need to override this method for concrete implementation.
 */
public void fire() throws IllegalActionException {
}
Program: 74921
Project: 74921
Buggy source:
/** 
 * Return a new CTReceiver.
 * @return A new CTReceiver.
 */
public Receiver newReceiver(){
  return new CTReceiver();
}

Fixed version (ground truth):
/** 
 * Return a new CTReceiver.
 * @return A new CTReceiver.
 */
public Receiver newReceiver(){
  Receiver receiver=new ContReceiver(this);
  if (_receivers == null) {
    _receivers=new LinkedList();
  }
  _receivers.add(receiver);
  return receiver;
}
Program: 74922
Project: 74922
Buggy source:
/** 
 * Preinitialize the model for an execution. This method is called only once for each simulation. The schedule is invalidated, statistical variables and the breakpoint table are cleared, all actors are preinitialized. If this director does not have a container and a scheduler, or the director does not fit in this level of hierarchy, an IllegalActionException will be thrown. <p> Note, however, time does not have a meaning when actors are preinitialized. So actors must not use a notion of time in their preinitialize() methods.
 * @exception IllegalActionException If this director has nocontainer, or this director does not fit this level of hierarchy, or there is no scheduler.
 */
public void preinitialize() throws IllegalActionException {
  if (_debugging) {
    _debug(getFullName(),"String_Node_Str");
  }
  Nameable nameable=getContainer();
  if (!(nameable instanceof CompositeActor)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  CompositeActor container=(CompositeActor)nameable;
  if (container.getContainer() != null) {
    if (!canBeInsideDirector()) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
  }
 else {
    if (!canBeTopLevelDirector()) {
      throw new IllegalActionException(this,"String_Node_Str");
    }
  }
  CTScheduler scheduler=(CTScheduler)getScheduler();
  if (scheduler == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  scheduler.setValid(false);
  _initializeLocalVariables();
  super.preinitialize();
  _startTime=new Time(this,_startTimeValue);
  _stopTime=new Time(this,_stopTimeValue);
  _iterationBeginTime=_startTime;
  _iterationEndTime=_stopTime;
}

Fixed version (ground truth):
/** 
 * Preinitialize the model for an execution. This method is called only once for each simulation. The schedule is invalidated, statistical variables and the breakpoint table are cleared, all actors are preinitialized. If this director does not have a container and a scheduler, or the director does not fit in this level of hierarchy, an IllegalActionException will be thrown. <p> Note, however, time does not have a meaning when actors are preinitialized. So actors must not use a notion of time in their preinitialize() methods.
 * @exception IllegalActionException If this director has nocontainer, or this director does not fit this level of hierarchy, or there is no scheduler.
 */
public void preinitialize() throws IllegalActionException {
  if (_debugging) {
    _debug(getFullName(),"String_Node_Str");
  }
  Nameable nameable=getContainer();
  if (!(nameable instanceof CompositeActor)) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  ContScheduler ContScheduler=(ContScheduler)getScheduler();
  if (ContScheduler == null) {
    throw new IllegalActionException(this,"String_Node_Str");
  }
  ContScheduler.setValid(false);
  _initializeLocalVariables();
  super.preinitialize();
  _startTime=new Time(this,_startTimeValue);
  _stopTime=new Time(this,_stopTimeValue);
  _iterationBeginTime=_startTime;
  _iterationEndTime=_stopTime;
}
Program: 74923
Project: 74923
Buggy source:
/** 
 * If the stop() method has not been called and all the actors return true at postfire, return true. Otherwise, return false. If this director is not at the top level and the breakpoint table is not empty, request a refiring at the first breakpoint.
 * @return True if the Director wants to be fired again in the future.
 * @exception IllegalActionException If refiring can not be granted.
 */
public boolean postfire() throws IllegalActionException {
  if (!_isTopLevel() && (getBreakPoints().size() > 0)) {
    Time time=(Time)getBreakPoints().removeFirst();
    CompositeActor container=(CompositeActor)getContainer();
    container.getExecutiveDirector().fireAt(container,time);
  }
  boolean postfireReturns=_postfireReturns && !_stopRequested;
  if (_debugging && _verbose) {
    _debug("String_Node_Str" + postfireReturns + "String_Node_Str"+ getModelTime());
  }
  return postfireReturns;
}

Fixed version (ground truth):
/** 
 * If the stop() method has not been called and all the actors return true at postfire, return true. Otherwise, return false. If this director is not at the top level and the breakpoint table is not empty, request a refiring at the first breakpoint.
 * @return True if the Director wants to be fired again in the future.
 * @exception IllegalActionException If refiring can not be granted.
 */
public boolean postfire() throws IllegalActionException {
  if (!_isTopLevel() && (_breakpoints.size() > 0)) {
    Time time=(Time)_breakpoints.removeFirst();
    CompositeActor container=(CompositeActor)getContainer();
    container.getExecutiveDirector().fireAt(container,time);
  }
  boolean postfireReturns=_postfireReturns && !_stopRequested;
  if (_debugging && _verbose) {
    _debug("String_Node_Str" + postfireReturns + "String_Node_Str"+ getModelTime());
  }
  return postfireReturns;
}
Program: 74924
Project: 74924
Buggy source:
/** 
 * Generate fire code The method generate code that loops through each INPUT [multi-ports] and combine (add or subtract) them. The result code is put into the given code buffer
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
public String generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(super.generateFireCode());
  ptolemy.actor.lib.AddSubtract actor=(ptolemy.actor.lib.AddSubtract)getComponent();
  StringBuffer codeBuffer=new StringBuffer();
  codeBuffer.append("String_Node_Str");
  codeBuffer.append("String_Node_Str");
  for (int i=0; i < actor.plus.getWidth(); i++) {
    codeBuffer.append("String_Node_Str" + i + "String_Node_Str");
    if (i < (actor.plus.getWidth() - 1)) {
      codeBuffer.append("String_Node_Str");
    }
 else     if (actor.minus.getWidth() > 0) {
      codeBuffer.append("String_Node_Str");
    }
  }
  for (int i=0; i < actor.minus.getWidth(); i++) {
    codeBuffer.append("String_Node_Str" + i + "String_Node_Str");
    if (i < (actor.minus.getWidth() - 1)) {
      codeBuffer.append("String_Node_Str");
    }
  }
  codeBuffer.append("String_Node_Str");
  code.append(processCode(codeBuffer.toString()));
  return code.toString();
}

Fixed version (ground truth):
/** 
 * Generate fire code The method generate code that loops through each INPUT [multi-ports] and combine (add or subtract) them. The result code is put into the given code buffer
 * @return The generated code.
 * @exception IllegalActionException If the code stream encounters anerror in processing the specified code block(s).
 */
public String generateFireCode() throws IllegalActionException {
  StringBuffer code=new StringBuffer();
  code.append(super.generateFireCode());
  ptolemy.actor.lib.AddSubtract actor=(ptolemy.actor.lib.AddSubtract)getComponent();
  StringBuffer codeBuffer=new StringBuffer();
  codeBuffer.append("String_Node_Str");
  codeBuffer.append("String_Node_Str");
  for (int i=0; i < actor.plus.getWidth(); i++) {
    codeBuffer.append("String_Node_Str" + i + "String_Node_Str");
    if (i < (actor.plus.getWidth() - 1)) {
      codeBuffer.append("String_Node_Str");
    }
  }
  if (actor.minus.getWidth() > 0) {
    codeBuffer.append("String_Node_Str");
  }
  for (int i=0; i < actor.minus.getWidth(); i++) {
    codeBuffer.append("String_Node_Str" + i + "String_Node_Str");
    if (i < (actor.minus.getWidth() - 1)) {
      codeBuffer.append("String_Node_Str");
    }
  }
  codeBuffer.append("String_Node_Str");
  code.append(processCode(codeBuffer.toString()));
  return code.toString();
}
Program: 74928
Project: 74928
Buggy source:
/** 
 * Override the base class to ensure that the _default member points to the default refinement.
 * @return A new Case.
 * @exception CloneNotSupportedException If any of the attributescannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Case newObject=(Case)super.clone();
  newObject._default=(Refinement)newObject.getEntity("String_Node_Str");
  return newObject;
}

Fixed version (ground truth):
/** 
 * Override the base class to ensure that the _default member points to the default refinement.
 * @return A new Case.
 * @exception CloneNotSupportedException If any of the attributescannot be cloned.
 */
public Object clone(Workspace workspace) throws CloneNotSupportedException {
  Case newObject=(Case)super.clone(workspace);
  newObject._default=(Refinement)newObject.getEntity("String_Node_Str");
  return newObject;
}
Program: 74930
Project: 74930
Buggy source:
/** 
 * Override the base class to create the transition associated with this refinement if the argument is an instance of Refinement.
 * @param entity Entity to contain.
 * @exception IllegalActionException If the entity has no name, or theaction would result in a recursive containment structure.
 * @exception NameDuplicationException If the name collides with a namealready in the entity.
 */
protected void _addEntity(ComponentEntity entity) throws IllegalActionException, NameDuplicationException {
  super._addEntity(entity);
  if (entity instanceof Refinement) {
    String controlValue=entity.getName();
    if (_controller.getRelation(controlValue) == null) {
      Transition transition=(Transition)_controller.newRelation(controlValue);
      transition.guardExpression.setExpression("String_Node_Str" + controlValue);
      transition.refinementName.setExpression(controlValue);
      transition.preemptive.setToken(BooleanToken.TRUE);
      if (controlValue.equals("String_Node_Str")) {
        transition.defaultTransition.setToken(BooleanToken.TRUE);
      }
      _state.incomingPort.link(transition);
      _state.outgoingPort.link(transition);
    }
  }
}

Fixed version (ground truth):
/** 
 * Override the base class to create the transition associated with this refinement if the argument is an instance of Refinement.
 * @param entity Entity to contain.
 * @exception IllegalActionException If the entity has no name, or theaction would result in a recursive containment structure.
 * @exception NameDuplicationException If the name collides with a namealready in the entity.
 */
protected void _addEntity(ComponentEntity entity) throws IllegalActionException, NameDuplicationException {
  super._addEntity(entity);
  if (entity instanceof Refinement) {
    String controlValue=entity.getName();
    if (_controller.getRelation(controlValue) == null) {
      Transition transition=(Transition)_controller.newRelation(controlValue);
      transition.guardExpression.setExpression("String_Node_Str" + controlValue);
      transition.refinementName.setExpression(controlValue);
      transition.preemptive.setToken(BooleanToken.TRUE);
      if (controlValue.equals("String_Node_Str")) {
        transition.defaultTransition.setToken(BooleanToken.TRUE);
      }
      _state.incomingPort.link(transition);
      _state.outgoingPort.link(transition);
    }
    if (_default != null) {
      _default.moveToLast();
    }
  }
}
Program: 74931
Project: 74931
Buggy source:
/** 
 * Initialize the model with a single state.
 */
private void _init() throws IllegalActionException, NameDuplicationException {
  _state=new State(_controller,"String_Node_Str");
  _controller.initialStateName.setExpression("String_Node_Str");
  directorClass.setVisibility(Settable.EXPERT);
  control=new PortParameter(this,"String_Node_Str");
  control.setExpression("String_Node_Str");
  ParameterPort port=control.getPort();
  StringAttribute controlCardinal=new StringAttribute(port,"String_Node_Str");
  controlCardinal.setExpression("String_Node_Str");
  Refinement refinement=new Refinement(this,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Initialize the model with a single state.
 */
private void _init() throws IllegalActionException, NameDuplicationException {
  _state=new State(_controller,"String_Node_Str");
  _controller.initialStateName.setExpression("String_Node_Str");
  directorClass.setVisibility(Settable.EXPERT);
  control=new PortParameter(this,"String_Node_Str");
  control.setExpression("String_Node_Str");
  ParameterPort port=control.getPort();
  StringAttribute controlCardinal=new StringAttribute(port,"String_Node_Str");
  controlCardinal.setExpression("String_Node_Str");
  _default=new Refinement(this,"String_Node_Str");
}
Program: 74932
Project: 74932
Buggy source:
/** 
 * Create a case action with label "Add Case". 
 */
public AddCaseAction(){
  super("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Create a case action with label "Add Case". 
 */
public AddCaseAction(){
  super("String_Node_Str");
  putValue(MNEMONIC_KEY,new Integer(KeyEvent.VK_A));
}
Program: 74934
Project: 74934
Buggy source:
/** 
 * Create the menus that are used by this frame. It is essential that _createGraphPane() be called before this.
 */
protected void _addMenus(){
  super._addMenus();
  _caseMenu=new JMenu("String_Node_Str");
  _caseMenu.setMnemonic(KeyEvent.VK_C);
  _menubar.add(_caseMenu);
  GUIUtilities.addHotKey(_getRightComponent(),_addCaseAction);
  GUIUtilities.addMenuItem(_caseMenu,_addCaseAction);
}

Fixed version (ground truth):
/** 
 * Create the menus that are used by this frame. It is essential that _createGraphPane() be called before this.
 */
protected void _addMenus(){
  super._addMenus();
  _caseMenu=new JMenu("String_Node_Str");
  _caseMenu.setMnemonic(KeyEvent.VK_C);
  _menubar.add(_caseMenu);
  GUIUtilities.addHotKey(_getRightComponent(),_addCaseAction);
  GUIUtilities.addMenuItem(_caseMenu,_addCaseAction);
  GUIUtilities.addHotKey(_getRightComponent(),_removeCaseAction);
  GUIUtilities.addMenuItem(_caseMenu,_removeCaseAction);
}