Program: 83240
Project: 83240
Buggy source:
/** 
 * Return an object containing the value JavaScript object as a specified type.
 * @param value the JavaScript value
 * @param type expected type of the returned object
 * @param msgPrefix a prefix for error/warning messages
 * @return the object reference
 * @throws HostedModeException if the JavaScript object is not assignable tothe supplied type.
 */
public static Object get(JsValue value,Class type,String msgPrefix){
  double doubleVal;
  if (value.isNull()) {
    return null;
  }
  if (value.isUndefined()) {
    throw new HostedModeException(msgPrefix + "String_Node_Str" + type.getName());
  }
  if (value.isWrappedJavaObject()) {
    Object origObject=value.getWrappedJavaObject();
    if (!type.isAssignableFrom(origObject.getClass())) {
      throw new HostedModeException(msgPrefix + "String_Node_Str" + origObject.getClass().getName()+ "String_Node_Str"+ type.getName());
    }
    return origObject;
  }
  if (getJavaScriptObjectSuperclass(type) != null) {
    if (!value.isJavaScriptObject()) {
      throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str"+ type.getName());
    }
    return createJavaScriptObject(value,type);
  }
switch (TypeInfo.classifyType(type)) {
case TypeInfo.TYPE_WRAP_BOOLEAN:
case TypeInfo.TYPE_PRIM_BOOLEAN:
    if (!value.isBoolean()) {
      throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
    }
  return Boolean.valueOf(value.getBoolean());
case TypeInfo.TYPE_WRAP_BYTE:
case TypeInfo.TYPE_PRIM_BYTE:
return new Byte((byte)getIntRange(value,Byte.MIN_VALUE,Byte.MAX_VALUE,"String_Node_Str",msgPrefix));
case TypeInfo.TYPE_WRAP_CHAR:
case TypeInfo.TYPE_PRIM_CHAR:
return new Character((char)getIntRange(value,Character.MIN_VALUE,Character.MAX_VALUE,"String_Node_Str",msgPrefix));
case TypeInfo.TYPE_WRAP_DOUBLE:
case TypeInfo.TYPE_PRIM_DOUBLE:
if (!value.isNumber()) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
}
return new Double(value.getNumber());
case TypeInfo.TYPE_WRAP_FLOAT:
case TypeInfo.TYPE_PRIM_FLOAT:
if (!value.isNumber()) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
}
doubleVal=value.getNumber();
if ((float)(doubleVal - Float.MIN_VALUE) == 0.0f) {
doubleVal=Float.MIN_VALUE;
}
float floatVal=(float)doubleVal;
if (Float.isInfinite(floatVal) && !Double.isInfinite(doubleVal)) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + doubleVal+ "String_Node_Str");
}
return new Float(floatVal);
case TypeInfo.TYPE_WRAP_INT:
case TypeInfo.TYPE_PRIM_INT:
return new Integer(getIntRange(value,Integer.MIN_VALUE,Integer.MAX_VALUE,"String_Node_Str",msgPrefix));
case TypeInfo.TYPE_WRAP_LONG:
case TypeInfo.TYPE_PRIM_LONG:
if (!value.isNumber()) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
}
doubleVal=value.getNumber();
if (doubleVal < Long.MIN_VALUE || doubleVal > Long.MAX_VALUE) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + doubleVal+ "String_Node_Str");
}
long longVal=(long)doubleVal;
if (doubleVal != longVal) {
ModuleSpace.getLogger().log(TreeLogger.WARN,msgPrefix + "String_Node_Str",null);
}
return new Long(longVal);
case TypeInfo.TYPE_WRAP_SHORT:
case TypeInfo.TYPE_PRIM_SHORT:
return new Short((short)getIntRange(value,Short.MIN_VALUE,Short.MAX_VALUE,"String_Node_Str",msgPrefix));
case TypeInfo.TYPE_WRAP_STRING:
if (!value.isString()) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
}
return value.getString();
case TypeInfo.TYPE_USER:
if (value.isString()) {
return value.getString();
}
break;
}
throw new IllegalArgumentException(msgPrefix + "String_Node_Str" + TypeInfo.getSourceRepresentation(type,"String_Node_Str")+ "String_Node_Str"+ value.getTypeString());
}

Fixed version (ground truth):
/** 
 * Return an object containing the value JavaScript object as a specified type.
 * @param value the JavaScript value
 * @param type expected type of the returned object
 * @param msgPrefix a prefix for error/warning messages
 * @return the object reference
 * @throws HostedModeException if the JavaScript object is not assignable tothe supplied type.
 */
public static Object get(JsValue value,Class type,String msgPrefix){
  double doubleVal;
  if (value.isNull()) {
    return null;
  }
  if (value.isUndefined()) {
    throw new HostedModeException(msgPrefix + "String_Node_Str" + type.getName());
  }
  if (value.isWrappedJavaObject()) {
    Object origObject=value.getWrappedJavaObject();
    if (!type.isAssignableFrom(origObject.getClass())) {
      throw new HostedModeException(msgPrefix + "String_Node_Str" + origObject.getClass().getName()+ "String_Node_Str"+ type.getName());
    }
    return origObject;
  }
  if (getJavaScriptObjectSuperclass(type) != null) {
    if (!value.isJavaScriptObject()) {
      throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str"+ type.getName());
    }
    return createJavaScriptObject(value,type);
  }
switch (TypeInfo.classifyType(type)) {
case TypeInfo.TYPE_WRAP_BOOLEAN:
case TypeInfo.TYPE_PRIM_BOOLEAN:
    if (!value.isBoolean()) {
      throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
    }
  return Boolean.valueOf(value.getBoolean());
case TypeInfo.TYPE_WRAP_BYTE:
case TypeInfo.TYPE_PRIM_BYTE:
return new Byte((byte)getIntRange(value,Byte.MIN_VALUE,Byte.MAX_VALUE,"String_Node_Str",msgPrefix));
case TypeInfo.TYPE_WRAP_CHAR:
case TypeInfo.TYPE_PRIM_CHAR:
return new Character((char)getIntRange(value,Character.MIN_VALUE,Character.MAX_VALUE,"String_Node_Str",msgPrefix));
case TypeInfo.TYPE_WRAP_DOUBLE:
case TypeInfo.TYPE_PRIM_DOUBLE:
if (!value.isNumber()) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
}
return new Double(value.getNumber());
case TypeInfo.TYPE_WRAP_FLOAT:
case TypeInfo.TYPE_PRIM_FLOAT:
if (!value.isNumber()) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
}
doubleVal=value.getNumber();
if ((float)(doubleVal - Float.MIN_VALUE) == 0.0f) {
doubleVal=Float.MIN_VALUE;
}
float floatVal=(float)doubleVal;
if (Float.isInfinite(floatVal) && !Double.isInfinite(doubleVal)) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + doubleVal+ "String_Node_Str");
}
return new Float(floatVal);
case TypeInfo.TYPE_WRAP_INT:
case TypeInfo.TYPE_PRIM_INT:
return new Integer(getIntRange(value,Integer.MIN_VALUE,Integer.MAX_VALUE,"String_Node_Str",msgPrefix));
case TypeInfo.TYPE_WRAP_LONG:
case TypeInfo.TYPE_PRIM_LONG:
if (!value.isNumber()) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
}
doubleVal=value.getNumber();
if (doubleVal < Long.MIN_VALUE || doubleVal > Long.MAX_VALUE) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + doubleVal+ "String_Node_Str");
}
long longVal=(long)doubleVal;
if (doubleVal != longVal) {
ModuleSpace.getLogger().log(TreeLogger.WARN,msgPrefix + "String_Node_Str",null);
}
return new Long(longVal);
case TypeInfo.TYPE_WRAP_SHORT:
case TypeInfo.TYPE_PRIM_SHORT:
return new Short((short)getIntRange(value,Short.MIN_VALUE,Short.MAX_VALUE,"String_Node_Str",msgPrefix));
case TypeInfo.TYPE_WRAP_STRING:
if (!value.isString()) {
throw new HostedModeException(msgPrefix + "String_Node_Str" + value.getTypeString()+ "String_Node_Str");
}
return value.getString();
case TypeInfo.TYPE_USER:
if (value.isString()) {
return value.getString();
}
break;
}
throw new IllegalArgumentException(msgPrefix + "String_Node_Str" + TypeInfo.getSourceRepresentation(type)+ "String_Node_Str"+ value.getTypeString());
}