Program: 80790
Project: 80790
Buggy source:
/** 
 * @param < T >
 * @param type
 * @return
 * @throws Exception
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) private <T>T parseFromCurrentLocation(Class<T> type,Class<?> componentType) throws Exception {
  Mirror<T> me=Mirror.me(type);
switch (cursor) {
case -1:
    return null;
case '[':
  Class<?> compType=componentType;
boolean reurnAsList=true;
List list=null;
if (null == type) {
list=new LinkedList();
}
 else if (type.isArray()) {
list=new LinkedList();
reurnAsList=false;
compType=type.getComponentType();
}
 else if (List.class.isAssignableFrom(type)) {
reurnAsList=true;
if (me.is(List.class)) list=new LinkedList();
 else list=(List)me.born();
}
 else {
throw makeError(String.format("String_Node_Str",type.getName()));
}
nextChar();
skipCommentsAndBlank();
while (cursor != -1 && cursor != ']') {
Object o=parseFromCurrentLocation(compType,null);
list.add(o);
skipCommentsAndBlank();
if (cursor == ']') break;
if (cursor != ',') throw makeError("String_Node_Str");
nextChar();
skipCommentsAndBlank();
}
nextChar();
if (reurnAsList) return (T)list;
Object ary=Array.newInstance(compType,list.size());
int i=0;
for (Iterator it=list.iterator(); it.hasNext(); ) Array.set(ary,i++,Castors.me().castTo(it.next(),compType));
return (T)ary;
case '{':
nextChar();
skipCommentsAndBlank();
if (Map.class == type) me=(Mirror<T>)Mirror.me(TreeMap.class);
if (null == me || Map.class.isAssignableFrom(type)) {
Map<String,Object> map=null == me ? new TreeMap<String,Object>() : (Map<String,Object>)me.born();
while (cursor != -1 && cursor != '}') {
String name=readFieldName();
Object value=parseFromJson(componentType,null);
map.put(name,value);
if (!findNextNamePair()) break;
}
nextChar();
return (T)map;
}
T obj=me.born();
while (cursor != -1 && cursor != '}') {
Field f=me.getField(readFieldName());
Class<?> ft=f.getType();
Class<?> eleType=null;
if (List.class.isAssignableFrom(ft)) {
Class<?>[] ts=Mirror.getGenericTypes(f);
if (ts.length > 0) eleType=ts[0];
}
 else if (Map.class.isAssignableFrom(ft)) {
Class<?>[] ts=Mirror.getGenericTypes(f);
if (ts.length > 1) eleType=ts[1];
}
Object value=parseFromJson(f.getType(),eleType);
me.setValue(obj,f,value);
if (!findNextNamePair()) break;
}
nextChar();
return obj;
case 'u':
if ('n' != (char)nextChar() & 'd' != (char)nextChar() & 'e' != (char)nextChar() & 'f' != (char)nextChar() & 'i' != (char)nextChar() & 'n' != (char)nextChar() & 'e' != (char)nextChar() & 'd' != (char)nextChar()) throw makeError("String_Node_Str");
nextChar();
return null;
case 'n':
if ('u' != (char)nextChar() & 'l' != (char)nextChar() & 'l' != (char)nextChar()) throw makeError("String_Node_Str");
nextChar();
return null;
case '\'':
case '"':
StringBuilder vs=readString();
String value=vs.toString();
if (null == me || me.is(String.class)) return (T)value;
return Castors.me().castTo(value,me.getType());
case 't':
if ('u' != (char)nextChar() & 'r' != (char)nextChar() & 'e' != (char)nextChar()) throw makeError("String_Node_Str");
if (null != type && !Mirror.me(type).isBoolean()) throw makeError("String_Node_Str");
nextChar();
return (T)Boolean.valueOf(true);
case 'f':
if ('a' != (char)nextChar() & 'l' != (char)nextChar() & 's' != (char)nextChar() & 'e' != (char)nextChar()) throw makeError("String_Node_Str");
if (null != type && !Mirror.me(type).isBoolean()) throw makeError("String_Node_Str");
nextChar();
return (T)Boolean.valueOf(false);
case '.':
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
StringBuilder sb=new StringBuilder();
do {
sb.append((char)cursor);
nextChar();
}
 while (cursor != ' ' && cursor != -1 && cursor != ',' && cursor != ']' && cursor != '}' && cursor != '/');
String numValue=Strings.trim(sb);
if (null != me) {
if (me.isInt()) {
return (T)Integer.valueOf(numValue);
}
 else if (me.isLong()) {
return (T)Long.valueOf(numValue);
}
 else if (me.isFloat()) {
return (T)Float.valueOf(numValue);
}
 else if (me.isDouble()) {
return (T)Double.valueOf(numValue);
}
 else if (me.isByte()) {
return (T)Byte.valueOf(numValue);
}
}
if (null == me || me.isNumber() || me.is(Object.class)) {
char lastChar=Character.toUpperCase(numValue.charAt(numValue.length() - 1));
if (numValue.indexOf('.') >= 0) {
if (lastChar == 'F') return (T)Float.valueOf(numValue.substring(0,numValue.length() - 1));
 else return (T)Double.valueOf(numValue);
}
 else {
if (lastChar == 'L') return (T)Long.valueOf(numValue.substring(0,numValue.length() - 1));
 else return (T)Integer.valueOf(numValue);
}
}
throw makeError("String_Node_Str");
case 'v':
while (-1 != nextChar()) if ('{' == cursor) return parseFromCurrentLocation(type,componentType);
default :
throw makeError("String_Node_Str");
}
}

Fixed version (ground truth):
/** 
 * @param < T >
 * @param type
 * @return
 * @throws Exception
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) private <T>T parseFromCurrentLocation(Class<T> type,Class<?> componentType) throws Exception {
  Mirror<T> me=Mirror.me(type);
switch (cursor) {
case -1:
    return null;
case '[':
  Class<?> compType=componentType;
boolean reurnAsList=true;
List list=null;
if (null == type) {
list=new LinkedList();
}
 else if (type.isArray()) {
list=new LinkedList();
reurnAsList=false;
compType=type.getComponentType();
}
 else if (List.class.isAssignableFrom(type)) {
reurnAsList=true;
if (me.is(List.class)) list=new LinkedList();
 else list=(List)me.born();
}
 else {
throw makeError(String.format("String_Node_Str",type.getName()));
}
nextChar();
skipCommentsAndBlank();
while (cursor != -1 && cursor != ']') {
Object o=parseFromCurrentLocation(compType,null);
list.add(o);
skipCommentsAndBlank();
if (cursor == ']') break;
if (cursor != ',') throw makeError("String_Node_Str");
nextChar();
skipCommentsAndBlank();
}
nextChar();
if (reurnAsList) return (T)list;
Object ary=Array.newInstance(compType,list.size());
int i=0;
for (Iterator it=list.iterator(); it.hasNext(); ) Array.set(ary,i++,Castors.me().castTo(it.next(),compType));
return (T)ary;
case '{':
nextChar();
skipCommentsAndBlank();
if (Map.class == type) me=(Mirror<T>)Mirror.me(TreeMap.class);
if (null == me || Map.class.isAssignableFrom(type)) {
Map<String,Object> map=null == me ? new TreeMap<String,Object>() : (Map<String,Object>)me.born();
while (cursor != -1 && cursor != '}') {
String name=readFieldName();
Object value=parseFromJson(componentType,null);
map.put(name,value);
if (!findNextNamePair()) break;
}
nextChar();
return (T)map;
}
T obj=me.born();
while (cursor != -1 && cursor != '}') {
Field f=null;
Class<?> ft=null;
Class<?> eleType=null;
try {
f=me.getField(readFieldName());
ft=f.getType();
}
 catch (NoSuchFieldException e) {
}
if (null != ft) {
if (List.class.isAssignableFrom(ft)) {
Class<?>[] ts=Mirror.getGenericTypes(f);
if (ts.length > 0) eleType=ts[0];
}
 else if (Map.class.isAssignableFrom(ft)) {
Class<?>[] ts=Mirror.getGenericTypes(f);
if (ts.length > 1) eleType=ts[1];
}
}
Object value=parseFromJson(ft,eleType);
if (null != f) me.setValue(obj,f,value);
if (!findNextNamePair()) break;
}
nextChar();
return obj;
case 'u':
if ('n' != (char)nextChar() & 'd' != (char)nextChar() & 'e' != (char)nextChar() & 'f' != (char)nextChar() & 'i' != (char)nextChar() & 'n' != (char)nextChar() & 'e' != (char)nextChar() & 'd' != (char)nextChar()) throw makeError("String_Node_Str");
nextChar();
return null;
case 'n':
if ('u' != (char)nextChar() & 'l' != (char)nextChar() & 'l' != (char)nextChar()) throw makeError("String_Node_Str");
nextChar();
return null;
case '\'':
case '"':
StringBuilder vs=readString();
String value=vs.toString();
if (null == me || me.is(String.class)) return (T)value;
return Castors.me().castTo(value,me.getType());
case 't':
if ('u' != (char)nextChar() & 'r' != (char)nextChar() & 'e' != (char)nextChar()) throw makeError("String_Node_Str");
if (null != type && !Mirror.me(type).isBoolean()) throw makeError("String_Node_Str");
nextChar();
return (T)Boolean.valueOf(true);
case 'f':
if ('a' != (char)nextChar() & 'l' != (char)nextChar() & 's' != (char)nextChar() & 'e' != (char)nextChar()) throw makeError("String_Node_Str");
if (null != type && !Mirror.me(type).isBoolean()) throw makeError("String_Node_Str");
nextChar();
return (T)Boolean.valueOf(false);
case '.':
case '-':
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
StringBuilder sb=new StringBuilder();
do {
sb.append((char)cursor);
nextChar();
}
 while (cursor != ' ' && cursor != -1 && cursor != ',' && cursor != ']' && cursor != '}' && cursor != '/');
String numValue=Strings.trim(sb);
if (null != me) {
if (me.isInt()) {
return (T)Integer.valueOf(numValue);
}
 else if (me.isLong()) {
return (T)Long.valueOf(numValue);
}
 else if (me.isFloat()) {
return (T)Float.valueOf(numValue);
}
 else if (me.isDouble()) {
return (T)Double.valueOf(numValue);
}
 else if (me.isByte()) {
return (T)Byte.valueOf(numValue);
}
}
if (null == me || me.isNumber() || me.is(Object.class)) {
char lastChar=Character.toUpperCase(numValue.charAt(numValue.length() - 1));
if (numValue.indexOf('.') >= 0) {
if (lastChar == 'F') return (T)Float.valueOf(numValue.substring(0,numValue.length() - 1));
 else return (T)Double.valueOf(numValue);
}
 else {
if (lastChar == 'L') return (T)Long.valueOf(numValue.substring(0,numValue.length() - 1));
 else return (T)Integer.valueOf(numValue);
}
}
throw makeError("String_Node_Str");
case 'v':
while (-1 != nextChar()) if ('{' == cursor) return parseFromCurrentLocation(type,componentType);
default :
throw makeError("String_Node_Str");
}
}