Program: 44163
Project: 44163
Buggy source:
private void parseObjectInto(ParseContext cx,JSONTokenizer tokenizer) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  boolean containerIsMap=Map.class.isAssignableFrom(cx.target.getClass());
  boolean containerIsDynAttrs=DynamicProperties.class.isAssignableFrom(cx.target.getClass());
  boolean first=true;
  while (true) {
    Token key;
    if (first) {
      key=tokenizer.expectNext(TokenType.STRING,TokenType.BRACE_CLOSE);
    }
 else {
      key=tokenizer.expectNext(TokenType.COMMA,TokenType.BRACE_CLOSE);
    }
    if (key.type() == TokenType.BRACE_CLOSE) {
      break;
    }
    if (!first) {
      key=tokenizer.expectNext(TokenType.STRING);
    }
    String jsonName=(String)key.value();
    String name=getPropertyNameFromAnnotation(cx.target,jsonName);
    if (name.length() == 0) {
      throw new JSONParseException("String_Node_Str");
    }
    tokenizer.expectNext(TokenType.COLON);
    Token valueToken=tokenizer.next();
    TokenType valueType=valueToken.type();
    boolean isProperty=PropertyUtils.isWriteable(cx.target,name);
    Method addMethod=getAddMethod(cx.target,name);
    if (!(isProperty || containerIsMap || containerIsDynAttrs|| addMethod != null)) {
      throw new JSONParseException("String_Node_Str" + name + "String_Node_Str"+ cx.target.getClass());
    }
    Object value;
    if (valueType.isPrimitive()) {
      value=valueToken.value();
    }
 else {
      Object newTarget=null;
      if (valueType == TokenType.BRACE_OPEN) {
        Class memberType=null;
        if (isProperty) {
          memberType=getTypeHintFromAnnotation(cx,name);
        }
        newTarget=createNewTargetInstance(cx.getMemberType(),cx.getParsePathInfo(jsonName),tokenizer,name,true);
        parseObjectInto(cx.push(newTarget,memberType,"String_Node_Str" + name),tokenizer);
      }
 else       if (valueType == TokenType.BRACKET_OPEN) {
        if (isProperty || containerIsMap) {
          newTarget=createNewTargetInstance(cx.getMemberType(),cx.getParsePathInfo(jsonName),tokenizer,name,false);
          Class memberType=getTypeHintFromAnnotation(cx,name);
          parseArrayInto(cx.push(newTarget,memberType,"String_Node_Str" + name),tokenizer);
        }
 else {
          if (addMethod != null) {
            Class memberType=addMethod.getParameterTypes()[0];
            List temp=new ArrayList();
            parseArrayInto(cx.push(temp,memberType,"String_Node_Str" + name),tokenizer);
            for (            Object o : temp) {
              addMethod.invoke(cx.target,o);
            }
            continue;
          }
 else {
            throw new JSONParseException("String_Node_Str" + name + "String_Node_Str"+ cx.target);
          }
        }
      }
 else {
        throw new JSONParseException("String_Node_Str" + valueToken);
      }
      value=newTarget;
    }
    if (isProperty) {
      try {
        Class targetClass=PropertyUtils.getPropertyType(cx.target,name);
        PropertyUtils.setProperty(cx.target,name,convertValueTo(value,targetClass));
      }
 catch (      IllegalAccessException e) {
        throw ExceptionWrapper.wrap(e);
      }
catch (      InvocationTargetException e) {
        throw ExceptionWrapper.wrap(e);
      }
catch (      NoSuchMethodException e) {
        throw ExceptionWrapper.wrap(e);
      }
    }
 else     if (containerIsMap) {
      ((Map)cx.target).put(name,value);
    }
 else     if (containerIsDynAttrs) {
      ((DynamicProperties)cx.target).setProperty(name,value);
    }
 else {
      throw new JSONParseException("String_Node_Str" + name + "String_Node_Str"+ cx.target);
    }
    first=false;
  }
}

Fixed version (ground truth):
private void parseObjectInto(ParseContext cx,JSONTokenizer tokenizer) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  boolean containerIsMap=Map.class.isAssignableFrom(cx.target.getClass());
  boolean containerIsDynAttrs=cx.target instanceof DynamicProperties;
  boolean first=true;
  while (true) {
    Token key;
    if (first) {
      key=tokenizer.expectNext(TokenType.STRING,TokenType.BRACE_CLOSE);
    }
 else {
      key=tokenizer.expectNext(TokenType.COMMA,TokenType.BRACE_CLOSE);
    }
    if (key.type() == TokenType.BRACE_CLOSE) {
      break;
    }
    if (!first) {
      key=tokenizer.expectNext(TokenType.STRING);
    }
    String jsonName=(String)key.value();
    String name=getPropertyNameFromAnnotation(cx.target,jsonName);
    if (name.length() == 0) {
      throw new JSONParseException("String_Node_Str");
    }
    tokenizer.expectNext(TokenType.COLON);
    Token valueToken=tokenizer.next();
    TokenType valueType=valueToken.type();
    boolean isProperty=PropertyUtils.isWriteable(cx.target,name);
    Method addMethod=getAddMethod(cx.target,name);
    if (!(isProperty || containerIsMap || containerIsDynAttrs|| addMethod != null)) {
      throw new JSONParseException("String_Node_Str" + name + "String_Node_Str"+ cx.target.getClass());
    }
    Object value;
    if (valueType.isPrimitive()) {
      value=valueToken.value();
    }
 else {
      Object newTarget=null;
      if (valueType == TokenType.BRACE_OPEN) {
        Class memberType=null;
        if (isProperty) {
          memberType=getTypeHintFromAnnotation(cx,name);
        }
        newTarget=createNewTargetInstance(cx.getMemberType(),cx.getParsePathInfo(jsonName),tokenizer,name,true);
        parseObjectInto(cx.push(newTarget,memberType,"String_Node_Str" + name),tokenizer);
      }
 else       if (valueType == TokenType.BRACKET_OPEN) {
        if (isProperty || containerIsMap || containerIsDynAttrs) {
          newTarget=createNewTargetInstance(cx.getMemberType(),cx.getParsePathInfo(jsonName),tokenizer,name,false);
          Class memberType=getTypeHintFromAnnotation(cx,name);
          parseArrayInto(cx.push(newTarget,memberType,"String_Node_Str" + name),tokenizer);
        }
 else {
          if (addMethod != null) {
            Class memberType=addMethod.getParameterTypes()[0];
            List temp=new ArrayList();
            parseArrayInto(cx.push(temp,memberType,"String_Node_Str" + name),tokenizer);
            for (            Object o : temp) {
              addMethod.invoke(cx.target,o);
            }
            continue;
          }
 else {
            throw new JSONParseException("String_Node_Str" + name + "String_Node_Str"+ cx.target);
          }
        }
      }
 else {
        throw new JSONParseException("String_Node_Str" + valueToken);
      }
      value=newTarget;
    }
    if (isProperty) {
      try {
        Class targetClass=PropertyUtils.getPropertyType(cx.target,name);
        PropertyUtils.setProperty(cx.target,name,convertValueTo(value,targetClass));
      }
 catch (      IllegalAccessException e) {
        throw ExceptionWrapper.wrap(e);
      }
catch (      InvocationTargetException e) {
        throw ExceptionWrapper.wrap(e);
      }
catch (      NoSuchMethodException e) {
        throw ExceptionWrapper.wrap(e);
      }
    }
 else     if (containerIsMap) {
      ((Map)cx.target).put(name,value);
    }
 else     if (containerIsDynAttrs) {
      ((DynamicProperties)cx.target).setProperty(name,value);
    }
 else {
      throw new JSONParseException("String_Node_Str" + name + "String_Node_Str"+ cx.target);
    }
    first=false;
  }
}