Program: 65136
Project: 65136
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) {
          int nsIndex=localName.indexOf(namespaceSeparator);
          if (nsIndex > -1) {
            String prefix=localName.substring(0,nsIndex);
            localName=localName.substring(nsIndex + 1);
            uri=namespaces.resolveNamespacePrefix(prefix);
          }
          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);
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);
for (int x=0, size=tree.getChildCount(); 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) {
          int nsIndex=localName.indexOf(namespaceSeparator);
          if (nsIndex > -1) {
            String prefix=localName.substring(0,nsIndex);
            localName=localName.substring(nsIndex + 1);
            uri=namespaces.resolveNamespacePrefix(prefix);
          }
          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));
}
}
}
}