Program: 64653
Project: 64653
Buggy source:
private void parse(Tree tree) throws SAXException {
  if (tree == null) {
    return;
  }
switch (tree.getType()) {
case JSONLexer.PAIR:
{
      Tree valueTree=tree.getChild(1);
      if (valueTree.getType() == JSONLexer.ARRAY) {
        parse(valueTree);
      }
 else {
        Tree stringTree=tree.getChild(0);
        String qualifiedName=stringTree.getText().substring(1,stringTree.getText().length() - 1);
        String localName=qualifiedName;
        if (attributePrefix != null && qualifiedName.startsWith(attributePrefix)) {
          break;
        }
        String uri=XMLConstants.EMPTY_STRING;
        if (namespaceAware && namespaces != null && localName.length() > 1) {
          int nsIndex=localName.indexOf(namespaceSeparator,1);
          String prefix=XMLConstants.EMPTY_STRING;
          if (nsIndex > -1) {
            prefix=localName.substring(0,nsIndex);
            localName=localName.substring(nsIndex + 1);
          }
          uri=namespaces.resolveNamespacePrefix(prefix);
          if (uri == null) {
            localName=qualifiedName;
            uri=namespaces.getDefaultNamespaceURI();
          }
          if (localName.equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE) && uri.equals(XMLConstants.SCHEMA_INSTANCE_URL)) {
            break;
          }
        }
        if (contentHandler instanceof XMLRootRecord || contentHandler instanceof DeferredContentHandler) {
          if (!namespaceAware && localName.equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE)) {
            break;
          }
          if (textWrapper != null && textWrapper.equals(localName)) {
            parse(valueTree);
            break;
          }
        }
 else         if (contentHandler instanceof UnmarshalRecord && ((UnmarshalRecord)contentHandler).getXPathNode() != null) {
          if (!namespaceAware && localName.equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE) && !((UnmarshalRecord)contentHandler).getXPathNode().hasTypeChild()) {
            break;
          }
          boolean isTextValue=isTextValue(localName);
          if (isTextValue) {
            parse(valueTree);
            break;
          }
        }
        contentHandler.startElement(uri,localName,localName,attributes.setTree(valueTree,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
        parse(valueTree);
        contentHandler.endElement(uri,localName,localName);
      }
      break;
    }
case JSONLexer.STRING:
{
    String string=string(tree.getChild(0).getText());
    contentHandler.characters(string);
    break;
  }
case JSONLexer.NUMBER:
{
  contentHandler.characters(tree.getChild(0).getText());
  break;
}
case JSONLexer.TRUE:
{
contentHandler.characters(TRUE);
break;
}
case JSONLexer.FALSE:
{
contentHandler.characters(FALSE);
break;
}
case JSONLexer.NULL:
{
break;
}
case JSONLexer.ARRAY:
{
Tree parentStringTree=tree.getParent().getChild(0);
String parentLocalName=parentStringTree.getText().substring(1,parentStringTree.getText().length() - 1);
if (attributePrefix != null && parentLocalName.startsWith(attributePrefix)) {
break;
}
String uri=XMLConstants.EMPTY_STRING;
if (namespaceAware && namespaces != null) {
int nsIndex=parentLocalName.indexOf(namespaceSeparator);
if (nsIndex > -1) {
String prefix=parentLocalName.substring(0,nsIndex);
parentLocalName=parentLocalName.substring(nsIndex + 1);
uri=namespaces.resolveNamespacePrefix(prefix);
}
}
boolean isTextValue=isTextValue(parentLocalName);
int size=tree.getChildCount();
if (size == 0) {
if (contentHandler instanceof UnmarshalRecord) {
UnmarshalRecord ur=(UnmarshalRecord)contentHandler;
XPathNode node=ur.getNonAttributeXPathNode(uri,parentLocalName,parentLocalName,null);
if (node != null) {
NodeValue nv=node.getNodeValue();
if (nv == null && node.getTextNode() != null) {
  nv=node.getTextNode().getUnmarshalNodeValue();
}
if (nv != null && nv.isContainerValue()) {
  ur.getContainerInstance(((ContainerValue)nv));
}
}
}
}
for (int x=0; x < size; x++) {
CommonTree nextChildTree=(CommonTree)tree.getChild(x);
if (!isTextValue) {
contentHandler.startElement(uri,parentLocalName,parentLocalName,attributes.setTree(nextChildTree,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
}
parse(nextChildTree);
if (!isTextValue) {
contentHandler.endElement(uri,parentLocalName,parentLocalName);
}
}
break;
}
default :
{
for (int x=0, size=tree.getChildCount(); x < size; x++) {
parse((CommonTree)tree.getChild(x));
}
}
}
}

Fixed version (ground truth):
private void parse(Tree tree) throws SAXException {
  if (tree == null) {
    return;
  }
switch (tree.getType()) {
case JSONLexer.PAIR:
{
      Tree valueTree=tree.getChild(1);
      if (valueTree.getType() == JSONLexer.ARRAY) {
        parse(valueTree);
      }
 else {
        Tree stringTree=tree.getChild(0);
        String qualifiedName=stringTree.getText().substring(1,stringTree.getText().length() - 1);
        String localName=qualifiedName;
        if (attributePrefix != null && qualifiedName.startsWith(attributePrefix)) {
          break;
        }
        String uri=XMLConstants.EMPTY_STRING;
        if (namespaceAware && namespaces != null) {
          if (localName.length() > 2) {
            int nsIndex=localName.indexOf(namespaceSeparator,1);
            String prefix=XMLConstants.EMPTY_STRING;
            if (nsIndex > -1) {
              prefix=localName.substring(0,nsIndex);
            }
            uri=namespaces.resolveNamespacePrefix(prefix);
            if (uri == null) {
              uri=namespaces.getDefaultNamespaceURI();
            }
 else {
              localName=localName.substring(nsIndex + 1);
            }
            if (localName.equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE) && uri.equals(XMLConstants.SCHEMA_INSTANCE_URL)) {
              break;
            }
          }
 else {
            uri=namespaces.getDefaultNamespaceURI();
          }
        }
        if (contentHandler instanceof XMLRootRecord || contentHandler instanceof DeferredContentHandler) {
          if (!namespaceAware && localName.equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE)) {
            break;
          }
          if (textWrapper != null && textWrapper.equals(localName)) {
            parse(valueTree);
            break;
          }
        }
 else         if (contentHandler instanceof UnmarshalRecord && ((UnmarshalRecord)contentHandler).getXPathNode() != null) {
          if (!namespaceAware && localName.equals(XMLConstants.SCHEMA_TYPE_ATTRIBUTE) && !((UnmarshalRecord)contentHandler).getXPathNode().hasTypeChild()) {
            break;
          }
          boolean isTextValue=isTextValue(localName);
          if (isTextValue) {
            parse(valueTree);
            break;
          }
        }
        contentHandler.startElement(uri,localName,localName,attributes.setTree(valueTree,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
        parse(valueTree);
        contentHandler.endElement(uri,localName,localName);
      }
      break;
    }
case JSONLexer.STRING:
{
    String string=string(tree.getChild(0).getText());
    contentHandler.characters(string);
    break;
  }
case JSONLexer.NUMBER:
{
  contentHandler.characters(tree.getChild(0).getText());
  break;
}
case JSONLexer.TRUE:
{
contentHandler.characters(TRUE);
break;
}
case JSONLexer.FALSE:
{
contentHandler.characters(FALSE);
break;
}
case JSONLexer.NULL:
{
break;
}
case JSONLexer.ARRAY:
{
Tree parentStringTree=tree.getParent().getChild(0);
String parentLocalName=parentStringTree.getText().substring(1,parentStringTree.getText().length() - 1);
if (attributePrefix != null && parentLocalName.startsWith(attributePrefix)) {
break;
}
String uri=XMLConstants.EMPTY_STRING;
if (namespaceAware && namespaces != null) {
if (parentLocalName.length() > 2) {
int nsIndex=parentLocalName.indexOf(namespaceSeparator,1);
if (nsIndex > -1) {
String prefix=parentLocalName.substring(0,nsIndex);
uri=namespaces.resolveNamespacePrefix(prefix);
}
if (uri == null) {
uri=namespaces.getDefaultNamespaceURI();
}
 else {
parentLocalName=parentLocalName.substring(nsIndex + 1);
}
}
 else {
uri=namespaces.getDefaultNamespaceURI();
}
}
boolean isTextValue=isTextValue(parentLocalName);
int size=tree.getChildCount();
if (size == 0) {
if (contentHandler instanceof UnmarshalRecord) {
UnmarshalRecord ur=(UnmarshalRecord)contentHandler;
XPathNode node=ur.getNonAttributeXPathNode(uri,parentLocalName,parentLocalName,null);
if (node != null) {
NodeValue nv=node.getNodeValue();
if (nv == null && node.getTextNode() != null) {
  nv=node.getTextNode().getUnmarshalNodeValue();
}
if (nv != null && nv.isContainerValue()) {
  ur.getContainerInstance(((ContainerValue)nv));
}
}
}
}
for (int x=0; x < size; x++) {
CommonTree nextChildTree=(CommonTree)tree.getChild(x);
if (!isTextValue) {
contentHandler.startElement(uri,parentLocalName,parentLocalName,attributes.setTree(nextChildTree,attributePrefix,namespaces,namespaceSeparator,namespaceAware));
}
parse(nextChildTree);
if (!isTextValue) {
contentHandler.endElement(uri,parentLocalName,parentLocalName);
}
}
break;
}
default :
{
for (int x=0, size=tree.getChildCount(); x < size; x++) {
parse((CommonTree)tree.getChild(x));
}
}
}
}