Program: 74912
Project: 74912
Buggy source:
/** 
 * Convert a java object to a corresponding Token.  This method is called by the expression language to marshal numeric object into tokens.  If the argument is a token, this function returns it.  If the argument is an array, an array token will be returned.  If the argument is an array of array, then a matrix token will be returned.  If the argument is a Java numeric encapsulation object, e.g. java.lang.Double, then the number is extracted and re-encapsulated in a token.  If no other conversion is possible, then this method will simply return an ObjectToken wrapping the object.
 * @exception IllegalActionException If the selected conversion fails.
 * @return A new token.
 */
public static ptolemy.data.Token convertJavaTypeToToken(Object object) throws ptolemy.kernel.util.IllegalActionException {
  ptolemy.data.Token returnValue=null;
  if (object instanceof ptolemy.data.Token) {
    returnValue=(ptolemy.data.Token)object;
  }
 else   if (object instanceof ptolemy.data.Token[]) {
    returnValue=new ArrayToken((ptolemy.data.Token[])object);
  }
 else   if (object instanceof Boolean) {
    returnValue=new BooleanToken(((Boolean)object).booleanValue());
  }
 else   if (object instanceof Byte) {
    returnValue=new UnsignedByteToken(((Byte)object).byteValue());
  }
 else   if (object instanceof Integer) {
    returnValue=new IntToken(((Integer)object).intValue());
  }
 else   if (object instanceof Long) {
    returnValue=new LongToken(((Long)object).longValue());
  }
 else   if (object instanceof Double) {
    returnValue=new DoubleToken(((Double)object).doubleValue());
  }
 else   if (object instanceof Float) {
    returnValue=new DoubleToken(((Float)object).floatValue());
  }
 else   if (object instanceof Complex) {
    returnValue=new ComplexToken((Complex)object);
  }
 else   if (object instanceof FixPoint) {
    returnValue=new FixToken((FixPoint)object);
  }
 else   if (object instanceof String) {
    returnValue=new StringToken((String)object);
  }
 else   if (object instanceof boolean[][]) {
    returnValue=new BooleanMatrixToken((boolean[][])object);
  }
 else   if (object instanceof int[][]) {
    returnValue=new IntMatrixToken((int[][])object);
  }
 else   if (object instanceof long[][]) {
    returnValue=new LongMatrixToken((long[][])object);
  }
 else   if (object instanceof double[][]) {
    returnValue=new DoubleMatrixToken((double[][])object);
  }
 else   if (object instanceof Complex[][]) {
    returnValue=new ComplexMatrixToken((Complex[][])object);
  }
 else   if (object instanceof FixPoint[][]) {
    returnValue=new FixMatrixToken((FixPoint[][])object);
  }
 else   if (object instanceof double[]) {
    DoubleToken[] temp=new DoubleToken[((double[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new DoubleToken(((double[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof Complex[]) {
    ComplexToken[] temp=new ComplexToken[((Complex[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new ComplexToken(((Complex[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof int[]) {
    IntToken[] temp=new IntToken[((int[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new IntToken(((int[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof long[]) {
    LongToken[] temp=new LongToken[((long[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new LongToken(((long[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof boolean[]) {
    BooleanToken[] temp=new BooleanToken[((long[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new BooleanToken(((boolean[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof String[]) {
    StringToken[] temp=new StringToken[((String[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new StringToken(((String[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof FixPoint[]) {
    FixToken[] temp=new FixToken[((FixPoint[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new FixToken(((FixPoint[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof Object) {
    returnValue=new ObjectToken(object);
  }
 else {
    throw new InternalErrorException("String_Node_Str" + object);
  }
  return returnValue;
}

Fixed version (ground truth):
/** 
 * Convert a java object to a corresponding Token.  This method is called by the expression language to marshal numeric object into tokens.  If the argument is a token, this function returns it.  If the argument is an array, an array token will be returned.  If the argument is an array of array, then a matrix token will be returned.  If the argument is a Java numeric encapsulation object, e.g. java.lang.Double, then the number is extracted and re-encapsulated in a token.  If no other conversion is possible, then this method will simply return an ObjectToken wrapping the object.
 * @exception IllegalActionException If the selected conversion fails.
 * @return A new token.
 */
public static ptolemy.data.Token convertJavaTypeToToken(Object object) throws ptolemy.kernel.util.IllegalActionException {
  ptolemy.data.Token returnValue=null;
  if (object instanceof ptolemy.data.Token) {
    returnValue=(ptolemy.data.Token)object;
  }
 else   if (object instanceof ptolemy.data.Token[]) {
    returnValue=new ArrayToken((ptolemy.data.Token[])object);
  }
 else   if (object instanceof Boolean) {
    returnValue=new BooleanToken(((Boolean)object).booleanValue());
  }
 else   if (object instanceof Byte) {
    returnValue=new UnsignedByteToken(((Byte)object).byteValue());
  }
 else   if (object instanceof Integer) {
    returnValue=new IntToken(((Integer)object).intValue());
  }
 else   if (object instanceof Long) {
    returnValue=new LongToken(((Long)object).longValue());
  }
 else   if (object instanceof Double) {
    returnValue=new DoubleToken(((Double)object).doubleValue());
  }
 else   if (object instanceof Float) {
    returnValue=new DoubleToken(((Float)object).floatValue());
  }
 else   if (object instanceof Complex) {
    returnValue=new ComplexToken((Complex)object);
  }
 else   if (object instanceof FixPoint) {
    returnValue=new FixToken((FixPoint)object);
  }
 else   if (object instanceof String) {
    returnValue=new StringToken((String)object);
  }
 else   if (object instanceof boolean[][]) {
    returnValue=new BooleanMatrixToken((boolean[][])object);
  }
 else   if (object instanceof int[][]) {
    returnValue=new IntMatrixToken((int[][])object);
  }
 else   if (object instanceof long[][]) {
    returnValue=new LongMatrixToken((long[][])object);
  }
 else   if (object instanceof double[][]) {
    returnValue=new DoubleMatrixToken((double[][])object);
  }
 else   if (object instanceof Complex[][]) {
    returnValue=new ComplexMatrixToken((Complex[][])object);
  }
 else   if (object instanceof FixPoint[][]) {
    returnValue=new FixMatrixToken((FixPoint[][])object);
  }
 else   if (object instanceof double[]) {
    DoubleToken[] temp=new DoubleToken[((double[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new DoubleToken(((double[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof Complex[]) {
    ComplexToken[] temp=new ComplexToken[((Complex[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new ComplexToken(((Complex[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof int[]) {
    IntToken[] temp=new IntToken[((int[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new IntToken(((int[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof long[]) {
    LongToken[] temp=new LongToken[((long[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new LongToken(((long[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof boolean[]) {
    BooleanToken[] temp=new BooleanToken[((long[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new BooleanToken(((boolean[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof String[]) {
    StringToken[] temp=new StringToken[((String[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new StringToken(((String[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else   if (object instanceof FixPoint[]) {
    FixToken[] temp=new FixToken[((FixPoint[])object).length];
    for (int j=0; j < temp.length; j++) {
      temp[j]=new FixToken(((FixPoint[])object)[j]);
    }
    returnValue=new ArrayToken(temp);
  }
 else {
    returnValue=new ObjectToken(object);
  }
  return returnValue;
}