nus-yam/ex-repair huggingface dataset:
Program: 190756
Project: 190756
Buggy source:
public CElement elementDecl(XSElementDecl decl){
  CElement r=allow(decl,decl.getName());
  if (r == null) {
    QName tagName=new QName(decl.getTargetNamespace(),decl.getName());
    CCustomizations custs=builder.getBindInfo(decl).toCustomizationList();
    if (decl.isGlobal()) {
      if (isCollapsable(decl)) {
        r=new CClassInfo(model,selector.getClassScope(),deriveName(decl),decl.getLocator(),null,tagName,decl,custs);
      }
 else {
        String className=null;
        if (getGlobalBinding().isGenerateElementClass())         className=deriveName(decl);
        CElementInfo cei=new CElementInfo(model,tagName,selector.getClassScope(),className,custs,decl.getLocator());
        selector.boundElements.put(decl,cei);
        stb.refererStack.push(decl);
        cei.initContentType(selector.bindToType(decl.getType()),decl,decl.getDefaultValue());
        stb.refererStack.pop();
        r=cei;
      }
    }
  }
  XSElementDecl top=decl.getSubstAffiliation();
  if (top != null) {
    CElement topci=selector.bindToType(top);
    if (r instanceof CClassInfo && topci instanceof CClassInfo)     ((CClassInfo)r).setBaseClass((CClassInfo)topci);
    if (r instanceof CElementInfo && topci instanceof CElementInfo)     ((CElementInfo)r).setSubstitutionHead((CElementInfo)topci);
  }
  TODO.checkSpec();
  return r;
}

Fixed version (ground truth):
public CElement elementDecl(XSElementDecl decl){
  CElement r=allow(decl,decl.getName());
  if (r == null) {
    QName tagName=new QName(decl.getTargetNamespace(),decl.getName());
    CCustomizations custs=builder.getBindInfo(decl).toCustomizationList();
    if (decl.isGlobal()) {
      if (isCollapsable(decl)) {
        return selector.bindToType(decl.getType().asComplexType(),true);
      }
 else {
        String className=null;
        if (getGlobalBinding().isGenerateElementClass())         className=deriveName(decl);
        CElementInfo cei=new CElementInfo(model,tagName,selector.getClassScope(),className,custs,decl.getLocator());
        selector.boundElements.put(decl,cei);
        stb.refererStack.push(decl);
        cei.initContentType(selector.bindToType(decl.getType()),decl,decl.getDefaultValue());
        stb.refererStack.pop();
        r=cei;
      }
    }
  }
  XSElementDecl top=decl.getSubstAffiliation();
  if (top != null) {
    CElement topci=selector.bindToType(top);
    if (r instanceof CClassInfo && topci instanceof CClassInfo)     ((CClassInfo)r).setBaseClass((CClassInfo)topci);
    if (r instanceof CElementInfo && topci instanceof CElementInfo)     ((CElementInfo)r).setSubstitutionHead((CElementInfo)topci);
  }
  TODO.checkSpec();
  return r;
}
Program: 190757
Project: 190757
Buggy source:
/** 
 * If only one   {@link XSElementDecl} is refering to {@link XSType}, return that element, otherwise null.
 */
private @Nullable XSElementDecl getSoleElementReferer(@NotNull XSType t){
  Set<XSComponent> referer=builder.getReferer(t);
  if (referer.size() != 1)   return null;
  XSComponent r=referer.iterator().next();
  if (r instanceof XSElementDecl)   return (XSElementDecl)r;
 else   return null;
}

Fixed version (ground truth):
/** 
 * If only one global   {@link XSElementDecl} is refering to {@link XSType}, return that element, otherwise null.
 */
private @Nullable XSElementDecl getSoleElementReferer(@NotNull XSType t){
  Set<XSComponent> referer=builder.getReferer(t);
  XSElementDecl sole=null;
  for (  XSComponent r : referer) {
    if (r instanceof XSElementDecl) {
      XSElementDecl x=(XSElementDecl)r;
      if (!x.isGlobal())       continue;
      if (sole == null)       sole=x;
 else       return null;
    }
 else {
      return null;
    }
  }
  return sole;
}
Program: 190758
Project: 190758
Buggy source:
public CElement complexType(XSComplexType type){
  CElement ci=allow(type,type.getName());
  if (ci != null)   return ci;
  BindInfo bi=builder.getBindInfo(type);
  if (type.isGlobal()) {
    if (getGlobalBinding().isSimpleMode()) {
      XSElementDecl referer=getSoleElementReferer(type);
      if (referer != null && isCollapsable(referer)) {
        return null;
      }
    }
    JPackage pkg=selector.getPackage(type.getTargetNamespace());
    return new CClassInfo(model,pkg,deriveName(type),type.getLocator(),getTypeName(type),null,type,bi.toCustomizationList());
  }
 else {
    CElement parentType=selector.isBound(type.getScope());
    String className;
    CClassInfoParent scope;
    if (parentType != null && isCollapsable(type.getScope()))     return null;
    if (parentType != null && parentType instanceof CElementInfo && ((CElementInfo)parentType).hasClass()) {
      scope=parentType;
      className="String_Node_Str";
    }
 else {
      className=builder.getNameConverter().toClassName(type.getScope().getName());
      BISchemaBinding sb=builder.getBindInfo(type.getOwnerSchema()).get(BISchemaBinding.class);
      if (sb != null)       className=sb.mangleAnonymousTypeClassName(className);
      scope=selector.getClassScope();
    }
    return new CClassInfo(model,scope,className,type.getLocator(),null,null,type,bi.toCustomizationList());
  }
}

Fixed version (ground truth):
public CElement complexType(XSComplexType type){
  CElement ci=allow(type,type.getName());
  if (ci != null)   return ci;
  BindInfo bi=builder.getBindInfo(type);
  if (type.isGlobal()) {
    QName tagName=null;
    String className=deriveName(type);
    if (getGlobalBinding().isSimpleMode()) {
      XSElementDecl referer=getSoleElementReferer(type);
      if (referer != null && isCollapsable(referer)) {
        tagName=new QName(referer.getTargetNamespace(),referer.getName());
        className=deriveName(referer);
      }
    }
    JPackage pkg=selector.getPackage(type.getTargetNamespace());
    return new CClassInfo(model,pkg,className,type.getLocator(),getTypeName(type),tagName,type,bi.toCustomizationList());
  }
 else {
    XSElementDecl element=type.getScope();
    if (element.isGlobal() && isCollapsable(element)) {
      return new CClassInfo(model,selector.getClassScope(),deriveName(element),element.getLocator(),null,new QName(element.getTargetNamespace(),element.getName()),element,bi.toCustomizationList());
    }
    CElement parentType=selector.isBound(element);
    String className;
    CClassInfoParent scope;
    if (parentType != null && parentType instanceof CElementInfo && ((CElementInfo)parentType).hasClass()) {
      scope=parentType;
      className="String_Node_Str";
    }
 else {
      className=builder.getNameConverter().toClassName(element.getName());
      BISchemaBinding sb=builder.getBindInfo(type.getOwnerSchema()).get(BISchemaBinding.class);
      if (sb != null)       className=sb.mangleAnonymousTypeClassName(className);
      scope=selector.getClassScope();
    }
    return new CClassInfo(model,scope,className,type.getLocator(),null,null,type,bi.toCustomizationList());
  }
}
Program: 190759
Project: 190759
Buggy source:
/** 
 * Recursively visit ancestors and build up   {@link NamespaceSupport} oject.
 */
private void buildNamespaceSupport(NamespaceSupport nss,Node node){
  if (node.getNodeType() != Node.ELEMENT_NODE)   return;
  buildNamespaceSupport(nss,node.getParentNode());
  nss.pushContext();
  NamedNodeMap atts=node.getAttributes();
  for (int i=0; i < atts.getLength(); i++) {
    Attr a=(Attr)atts.item(i);
    if ("String_Node_Str".equals(a.getPrefix())) {
      nss.declarePrefix(a.getLocalName(),a.getValue());
      continue;
    }
    if ("String_Node_Str".equals(a.getName())) {
      nss.declarePrefix("String_Node_Str",a.getValue());
      continue;
    }
  }
}

Fixed version (ground truth):
/** 
 * Recursively visit ancestors and build up   {@link NamespaceSupport} oject.
 */
private void buildNamespaceSupport(NamespaceSupport nss,Node node){
  if (node == null || node.getNodeType() != Node.ELEMENT_NODE)   return;
  buildNamespaceSupport(nss,node.getParentNode());
  nss.pushContext();
  NamedNodeMap atts=node.getAttributes();
  for (int i=0; i < atts.getLength(); i++) {
    Attr a=(Attr)atts.item(i);
    if ("String_Node_Str".equals(a.getPrefix())) {
      nss.declarePrefix(a.getLocalName(),a.getValue());
      continue;
    }
    if ("String_Node_Str".equals(a.getName())) {
      nss.declarePrefix("String_Node_Str",a.getValue());
      continue;
    }
  }
}
Program: 190760
Project: 190760
Buggy source:
public void setEntityResolver(EntityResolver entityResolver){
  forest.setEntityResolver(entityResolver);
}

Fixed version (ground truth):
public void setEntityResolver(EntityResolver entityResolver){
  forest.setEntityResolver(entityResolver);
  opts.entityResolver=entityResolver;
}
Program: 190761
Project: 190761
Buggy source:
/** 
 * This method can be called after   {@link #startDocument} is calledbut before the marshalling begins, to set the currently in-scope namespace bindings. <p> This method is useful to avoid redundant namespace declarations when the marshalling is producing a sub-document.
 */
public void addInscopeBinding(String nsUri,String prefix){
  nsContext.declareNsUri(nsUri,prefix,false);
}

Fixed version (ground truth):
/** 
 * This method can be called after   {@link #startDocument} is calledbut before the marshalling begins, to set the currently in-scope namespace bindings. <p> This method is useful to avoid redundant namespace declarations when the marshalling is producing a sub-document.
 */
public void addInscopeBinding(String nsUri,String prefix){
  nsContext.put(nsUri,prefix);
}
Program: 190762
Project: 190762
Buggy source:
public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  try {
    flushText();
    int len=atts.getLength();
    serializer.startElement(namespaceURI,localName,getPrefix(qName),null);
    for (int i=0; i < len; i++) {
      String qname=atts.getQName(i);
      if (qname.startsWith("String_Node_Str"))       continue;
      String prefix=getPrefix(qname);
      serializer.getNamespaceContext().declareNamespace(atts.getURI(i),prefix,true);
    }
    for (int i=0; i < prefixMap.size(); i+=2) {
      String prefix=(String)prefixMap.get(i);
      serializer.getNamespaceContext().declareNamespace((String)prefixMap.get(i + 1),prefix,prefix.length() != 0);
    }
    serializer.endNamespaceDecls(null);
    for (int i=0; i < len; i++) {
      if (atts.getQName(i).startsWith("String_Node_Str"))       continue;
      serializer.attribute(atts.getURI(i),atts.getLocalName(i),atts.getValue(i));
    }
    prefixMap.clear();
    serializer.endAttributes();
  }
 catch (  IOException e) {
    throw new SAXException2(e);
  }
catch (  XMLStreamException e) {
    throw new SAXException2(e);
  }
}

Fixed version (ground truth):
public void startElement(String namespaceURI,String localName,String qName,Attributes atts) throws SAXException {
  try {
    flushText();
    int len=atts.getLength();
    serializer.startElement(namespaceURI,localName,getPrefix(qName),null);
    for (int i=0; i < len; i++) {
      String qname=atts.getQName(i);
      if (qname.startsWith("String_Node_Str"))       continue;
      String prefix=getPrefix(qname);
      serializer.getNamespaceContext().declareNamespace(atts.getURI(i),prefix,true);
    }
    for (int i=0; i < prefixMap.size(); i+=2) {
      serializer.getNamespaceContext().put(prefixMap.get(i + 1),prefixMap.get(i));
    }
    serializer.endNamespaceDecls(null);
    for (int i=0; i < len; i++) {
      if (atts.getQName(i).startsWith("String_Node_Str"))       continue;
      serializer.attribute(atts.getURI(i),atts.getLocalName(i),atts.getValue(i));
    }
    prefixMap.clear();
    serializer.endAttributes();
  }
 catch (  IOException e) {
    throw new SAXException2(e);
  }
catch (  XMLStreamException e) {
    throw new SAXException2(e);
  }
}
Program: 190763
Project: 190763
Buggy source:
/** 
 * Puts this new binding into the declared prefixes list without doing any duplicate check. <p> Most of the time   {@link #declareNsUri(String,String,boolean)} shall be used.
 * @param prefix if null, an unique prefix is allocated.
 * @return the index of this new binding.
 */
public int put(String uri,String prefix){
  if (size == nsUris.length) {
    String[] u=new String[nsUris.length * 2];
    String[] p=new String[prefixes.length * 2];
    System.arraycopy(nsUris,0,u,0,nsUris.length);
    System.arraycopy(prefixes,0,p,0,prefixes.length);
    nsUris=u;
    prefixes=p;
  }
  if (prefix == null) {
    if (size == 1)     prefix="String_Node_Str";
 else     prefix=new StringBuilder(5).append("String_Node_Str").append(size).toString();
  }
  nsUris[size]=uri;
  prefixes[size]=prefix;
  return size++;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}.
 * @param prefix if null, an unique prefix is allocated.
 */
public int put(@NotNull String uri,@Nullable String prefix){
  if (size == nsUris.length) {
    String[] u=new String[nsUris.length * 2];
    String[] p=new String[prefixes.length * 2];
    System.arraycopy(nsUris,0,u,0,nsUris.length);
    System.arraycopy(prefixes,0,p,0,prefixes.length);
    nsUris=u;
    prefixes=p;
  }
  if (prefix == null) {
    if (size == 1)     prefix="String_Node_Str";
 else     prefix=new StringBuilder(5).append("String_Node_Str").append(size).toString();
  }
  nsUris[size]=uri;
  prefixes[size]=prefix;
  return size++;
}
Program: 190764
Project: 190764
Buggy source:
private void startElement(){
  nse=nse.push();
  if (!seenRoot) {
    String[] knownUris=nameList.namespaceURIs;
    for (int i=0; i < knownUris.length; i++)     knownUri2prefixIndexMap[i]=nsContext.declareNsUri(knownUris[i],null,false);
    String[] uris=nsContext.getPrefixMapper().getPreDeclaredNamespaceUris();
    if (uris != null) {
      for (      String uri : uris) {
        if (uri != null)         nsContext.declareNsUri(uri,null,false);
      }
    }
    String[] pairs=nsContext.getPrefixMapper().getPreDeclaredNamespaceUris2();
    if (pairs != null) {
      for (int i=0; i < pairs.length; i++) {
        String prefix=pairs[i];
        String nsUri=pairs[i + 1];
        if (prefix != null && nsUri != null)         nsContext.put(nsUri,prefix);
      }
    }
    if (schemaLocation != null || noNsSchemaLocation != null) {
      nsContext.declareNsUri(WellKnownNamespace.XML_SCHEMA_INSTANCE,"String_Node_Str",true);
    }
  }
  nsContext.collectionMode=true;
  textHasAlreadyPrinted=false;
}

Fixed version (ground truth):
private void startElement(){
  nse=nse.push();
  if (!seenRoot) {
    String[] knownUris=nameList.namespaceURIs;
    for (int i=0; i < knownUris.length; i++)     knownUri2prefixIndexMap[i]=nsContext.declareNsUri(knownUris[i],null,false);
    String[] uris=nsContext.getPrefixMapper().getPreDeclaredNamespaceUris();
    if (uris != null) {
      for (      String uri : uris) {
        if (uri != null)         nsContext.declareNsUri(uri,null,false);
      }
    }
    String[] pairs=nsContext.getPrefixMapper().getPreDeclaredNamespaceUris2();
    if (pairs != null) {
      for (int i=0; i < pairs.length; i+=2) {
        String prefix=pairs[i];
        String nsUri=pairs[i + 1];
        if (prefix != null && nsUri != null)         nsContext.put(nsUri,prefix);
      }
    }
    if (schemaLocation != null || noNsSchemaLocation != null) {
      nsContext.declareNsUri(WellKnownNamespace.XML_SCHEMA_INSTANCE,"String_Node_Str",true);
    }
  }
  nsContext.collectionMode=true;
  textHasAlreadyPrinted=false;
}
Program: 190765
Project: 190765
Buggy source:
/** 
 * Receives the root element and determines how to start unmarshalling.
 */
public void childElement(UnmarshallingContext.State state,TagName ea){
  UnmarshallingContext context=state.getContext();
  QName qn=new QName(ea.uri,ea.local);
  state.prev.target=new JAXBElement(qn,context.expectedType.jaxbType,null,null);
  state.receiver=this;
  state.loader=context.expectedType.getLoader(null,true);
}

Fixed version (ground truth):
/** 
 * Receives the root element and determines how to start unmarshalling.
 */
public void childElement(UnmarshallingContext.State state,TagName ea){
  UnmarshallingContext context=state.getContext();
  QName qn=new QName(ea.uri,ea.local);
  state.prev.target=new JAXBElement(qn,context.expectedType.jaxbType,null,null);
  state.receiver=this;
  state.loader=new XsiNilLoader(context.expectedType.getLoader(null,true));
}
Program: 190766
Project: 190766
Buggy source:
public JDefinedClass createClass(JClassContainer parent,int mod,String name,Locator source,ClassType kind){
  try {
    if (parent.isClass())     mod|=JMod.STATIC;
    JDefinedClass r=parent._class(mod,name,kind);
    r.metadata=source;
    return r;
  }
 catch (  JClassAlreadyExistsException e) {
    JDefinedClass cls=e.getExistingClass();
    errorReceiver.error(new SAXParseException(Messages.format(Messages.ERR_CLASSNAME_COLLISION,cls.fullName()),(Locator)cls.metadata));
    errorReceiver.error(new SAXParseException(Messages.format(Messages.ERR_CLASSNAME_COLLISION_SOURCE,name),source));
    if (!name.equals(cls.name())) {
      errorReceiver.error(new SAXParseException(Messages.format(Messages.ERR_CASE_SENSITIVITY_COLLISION,name,cls.name()),null));
    }
    try {
      return parent._class("String_Node_Str" + (ticketMaster++));
    }
 catch (    JClassAlreadyExistsException ee) {
      return ee.getExistingClass();
    }
  }
}

Fixed version (ground truth):
public JDefinedClass createClass(JClassContainer parent,int mod,String name,Locator source,ClassType kind){
  try {
    if (parent.isClass() && kind == ClassType.CLASS)     mod|=JMod.STATIC;
    JDefinedClass r=parent._class(mod,name,kind);
    r.metadata=source;
    return r;
  }
 catch (  JClassAlreadyExistsException e) {
    JDefinedClass cls=e.getExistingClass();
    errorReceiver.error(new SAXParseException(Messages.format(Messages.ERR_CLASSNAME_COLLISION,cls.fullName()),(Locator)cls.metadata));
    errorReceiver.error(new SAXParseException(Messages.format(Messages.ERR_CLASSNAME_COLLISION_SOURCE,name),source));
    if (!name.equals(cls.name())) {
      errorReceiver.error(new SAXParseException(Messages.format(Messages.ERR_CASE_SENSITIVITY_COLLISION,name,cls.name()),null));
    }
    try {
      return parent._class("String_Node_Str" + (ticketMaster++));
    }
 catch (    JClassAlreadyExistsException ee) {
      return ee.getExistingClass();
    }
  }
}
Program: 190767
Project: 190767
Buggy source:
/** 
 * Derived classes can use this method to implement   {@link #calcDrilldown}.
 */
protected List<Property> buildDrilldown(CClassInfo typeBean){
  List<Property> result=new ArrayList<Property>();
  for (  CPropertyInfo p : typeBean.getProperties()) {
    if (p instanceof CElementPropertyInfo) {
      CElementPropertyInfo ep=(CElementPropertyInfo)p;
      List<? extends CTypeRef> ref=ep.getTypes();
      if (ref.size() != 1)       return null;
      result.add(createPropertyImpl(ep,ref.get(0).getTagName()));
    }
 else     if (p instanceof ReferencePropertyInfo) {
      CReferencePropertyInfo rp=(CReferencePropertyInfo)p;
      Collection<CElement> elements=rp.getElements();
      if (elements.size() != 1)       return null;
      CElement ref=elements.iterator().next();
      if (ref instanceof ClassInfo) {
        result.add(createPropertyImpl(rp,ref.getElementName()));
      }
 else {
        CElementInfo eref=(CElementInfo)ref;
        if (!eref.getSubstitutionMembers().isEmpty())         return null;
        ElementAdapter fr;
        if (rp.isCollection())         fr=new ElementCollectionAdapter(parent.outline.getField(rp),eref);
 else         fr=new ElementSingleAdapter(parent.outline.getField(rp),eref);
        result.add(new PropertyImpl(this,fr,eref.getElementName()));
      }
    }
 else     return null;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Derived classes can use this method to implement   {@link #calcDrilldown}.
 */
protected List<Property> buildDrilldown(CClassInfo typeBean){
  List<Property> result=new ArrayList<Property>();
  for (; typeBean != null; typeBean=typeBean.getBaseClass()) {
    for (    CPropertyInfo p : typeBean.getProperties()) {
      if (p instanceof CElementPropertyInfo) {
        CElementPropertyInfo ep=(CElementPropertyInfo)p;
        List<? extends CTypeRef> ref=ep.getTypes();
        if (ref.size() != 1)         return null;
        result.add(createPropertyImpl(ep,ref.get(0).getTagName()));
      }
 else       if (p instanceof ReferencePropertyInfo) {
        CReferencePropertyInfo rp=(CReferencePropertyInfo)p;
        Collection<CElement> elements=rp.getElements();
        if (elements.size() != 1)         return null;
        CElement ref=elements.iterator().next();
        if (ref instanceof ClassInfo) {
          result.add(createPropertyImpl(rp,ref.getElementName()));
        }
 else {
          CElementInfo eref=(CElementInfo)ref;
          if (!eref.getSubstitutionMembers().isEmpty())           return null;
          ElementAdapter fr;
          if (rp.isCollection())           fr=new ElementCollectionAdapter(parent.outline.getField(rp),eref);
 else           fr=new ElementSingleAdapter(parent.outline.getField(rp),eref);
          result.add(new PropertyImpl(this,fr,eref.getElementName()));
        }
      }
 else       return null;
    }
  }
  return result;
}
Program: 190768
Project: 190768
Buggy source:
/** 
 * All the marshal method invocation eventually comes down to this call.
 */
private void write(Object obj,XmlOutput out,Runnable postInitAction) throws JAXBException {
  try {
    if (obj == null)     throw new IllegalArgumentException(Messages.NOT_MARSHALLABLE.format());
    if (schema != null) {
      ValidatorHandler validator=schema.newValidatorHandler();
      validator.setErrorHandler(new FatalAdapter(serializer));
      XMLFilterImpl f=new XMLFilterImpl(){
        public void startPrefixMapping(        String prefix,        String uri) throws SAXException {
          super.startPrefixMapping(prefix.intern(),uri.intern());
        }
      }
;
      f.setContentHandler(validator);
      out=new ForkXmlOutput(new SAXOutput(f),out);
    }
    try {
      prewrite(out,isFragment(),postInitAction);
      serializer.childAsRoot(obj);
      postwrite(out);
    }
 catch (    SAXException e) {
      throw new MarshalException(e);
    }
catch (    IOException e) {
      throw new MarshalException(e);
    }
catch (    XMLStreamException e) {
      throw new MarshalException(e);
    }
 finally {
      serializer.close();
    }
  }
  finally {
    cleanUp();
  }
}

Fixed version (ground truth):
/** 
 * All the marshal method invocation eventually comes down to this call.
 */
private void write(Object obj,XmlOutput out,Runnable postInitAction) throws JAXBException {
  try {
    if (obj == null)     throw new IllegalArgumentException(Messages.NOT_MARSHALLABLE.format());
    if (schema != null) {
      ValidatorHandler validator=schema.newValidatorHandler();
      validator.setErrorHandler(new FatalAdapter(serializer));
      XMLFilterImpl f=new XMLFilterImpl(){
        public void startPrefixMapping(        String prefix,        String uri) throws SAXException {
          super.startPrefixMapping(prefix.intern(),uri.intern());
        }
      }
;
      f.setContentHandler(validator);
      out=new ForkXmlOutput(new SAXOutput(f){
        @Override public void startDocument(        XMLSerializer serializer,        boolean fragment,        int[] nsUriIndex2prefixIndex,        NamespaceContextImpl nsContext) throws SAXException, IOException, XMLStreamException {
          super.startDocument(serializer,false,nsUriIndex2prefixIndex,nsContext);
        }
        @Override public void endDocument(        boolean fragment) throws SAXException, IOException, XMLStreamException {
          super.endDocument(false);
        }
      }
,out);
    }
    try {
      prewrite(out,isFragment(),postInitAction);
      serializer.childAsRoot(obj);
      postwrite(out);
    }
 catch (    SAXException e) {
      throw new MarshalException(e);
    }
catch (    IOException e) {
      throw new MarshalException(e);
    }
catch (    XMLStreamException e) {
      throw new MarshalException(e);
    }
 finally {
      serializer.close();
    }
  }
  finally {
    cleanUp();
  }
}
Program: 190769
Project: 190769
Buggy source:
private void handleEndElement(EndElement event) throws SAXException {
  if (!seenText && context.expectText()) {
    visitor.text("String_Node_Str");
  }
  QName qName=event.getName();
  tagName.uri=fixNull(qName.getNamespaceURI());
  tagName.local=qName.getLocalPart();
  visitor.endElement(tagName);
  for (Iterator i=event.getNamespaces(); i.hasNext(); ) {
    String prefix=fixNull((String)i.next());
    visitor.endPrefixMapping(prefix);
  }
  seenText=false;
}

Fixed version (ground truth):
private void handleEndElement(EndElement event) throws SAXException {
  if (!seenText && context.expectText()) {
    visitor.text("String_Node_Str");
  }
  QName qName=event.getName();
  tagName.uri=fixNull(qName.getNamespaceURI());
  tagName.local=qName.getLocalPart();
  visitor.endElement(tagName);
  for (Iterator<Namespace> i=event.getNamespaces(); i.hasNext(); ) {
    String prefix=fixNull(i.next().getPrefix());
    visitor.endPrefixMapping(prefix);
  }
  seenText=false;
}
Program: 190770
Project: 190770
Buggy source:
@Override protected void generatePackageFiles(ClassTree classtree) throws Exception {
  PackageDoc[] packages=configuration.packages;
  if (packages.length > 1) {
    PackageIndexFrameWriter.generate(configuration);
  }
  PackageDoc prev=null, next;
  for (int i=0; i < packages.length; i++) {
    next=(i + 1 < packages.length && packages[i + 1].name().length() > 0) ? packages[i + 1] : null;
    next=(i + 2 < packages.length && next == null) ? packages[i + 2] : next;
    AbstractBuilder packageSummaryBuilder;
    if (containsArchDocTag(packages[i])) {
      packageSummaryBuilder=CustomPackageSummaryBuilder.getInstance(configuration,packages[i],new CustomPackageWriterImpl(ConfigurationImpl.getInstance(),packages[i],prev,next));
    }
 else {
      packageSummaryBuilder=configuration.getBuilderFactory().getPackageSummaryBuilder(packages[i],prev,next);
    }
    packageSummaryBuilder.build();
    prev=packages[i];
  }
}

Fixed version (ground truth):
@Override protected void generatePackageFiles(ClassTree classtree) throws Exception {
  PackageDoc[] packages=configuration.packages;
  if (packages.length > 1) {
    PackageIndexFrameWriter.generate(configuration);
  }
  PackageDoc prev=null, next;
  for (int i=0; i < packages.length; i++) {
    PackageFrameWriter.generate(configuration,packages[i]);
    next=(i + 1 < packages.length && packages[i + 1].name().length() > 0) ? packages[i + 1] : null;
    next=(i + 2 < packages.length && next == null) ? packages[i + 2] : next;
    AbstractBuilder packageSummaryBuilder;
    if (containsArchDocTag(packages[i])) {
      packageSummaryBuilder=CustomPackageSummaryBuilder.getInstance(configuration,packages[i],new CustomPackageWriterImpl(ConfigurationImpl.getInstance(),packages[i],prev,next));
    }
 else {
      packageSummaryBuilder=configuration.getBuilderFactory().getPackageSummaryBuilder(packages[i],prev,next);
    }
    packageSummaryBuilder.build();
    prev=packages[i];
  }
}
Program: 190771
Project: 190771
Buggy source:
/** 
 * @param assoc non-null if the marshaller is working inside  {@link BinderImpl}.
 */
public MarshallerImpl(JAXBContextImpl c,AssociationMap assoc){
  DatatypeConverter.setDatatypeConverter(DatatypeConverterImpl.theInstance);
  context=c;
  this.assoc=assoc;
  serializer=new XMLSerializer(this);
  c14nSupport=context.c14nSupport;
  try {
    setEventHandler(this);
  }
 catch (  JAXBException e) {
    throw new AssertionError(e);
  }
}

Fixed version (ground truth):
/** 
 * @param assoc non-null if the marshaller is working inside  {@link BinderImpl}.
 */
public MarshallerImpl(JAXBContextImpl c,AssociationMap assoc){
  DatatypeConverter.setDatatypeConverter(DatatypeConverterImpl.theInstance);
  context=c;
  serializer=new XMLSerializer(this);
  c14nSupport=context.c14nSupport;
  try {
    setEventHandler(this);
  }
 catch (  JAXBException e) {
    throw new AssertionError(e);
  }
}
Program: 190772
Project: 190772
Buggy source:
/** 
 * Creates   {@link XmlOutput} from the given {@link Result} object.
 */
final XmlOutput createXmlOutput(Result result) throws JAXBException {
  if (result instanceof SAXResult)   return new SAXOutput(((SAXResult)result).getHandler());
  if (result instanceof DOMResult) {
    final Node node=((DOMResult)result).getNode();
    if (node == null) {
      Document doc=JAXBContextImpl.createDom();
      ((DOMResult)result).setNode(doc);
      return new SAXOutput(new SAX2DOMEx(doc));
    }
 else {
      return new SAXOutput(new SAX2DOMEx(node));
    }
  }
  if (result instanceof StreamResult) {
    StreamResult sr=(StreamResult)result;
    if (sr.getWriter() != null)     return createWriter(sr.getWriter());
 else     if (sr.getOutputStream() != null)     return createWriter(sr.getOutputStream());
 else     if (sr.getSystemId() != null) {
      String fileURL=sr.getSystemId();
      if (fileURL.startsWith("String_Node_Str")) {
        if (fileURL.substring(8).indexOf("String_Node_Str") > 0)         fileURL=fileURL.substring(8);
 else         fileURL=fileURL.substring(7);
      }
      try {
        return createWriter(new FileOutputStream(fileURL));
      }
 catch (      IOException e) {
        throw new MarshalException(e);
      }
    }
  }
  throw new MarshalException(Messages.UNSUPPORTED_RESULT.format());
}

Fixed version (ground truth):
/** 
 * Creates   {@link XmlOutput} from the given {@link Result} object.
 */
final XmlOutput createXmlOutput(Result result) throws JAXBException {
}
Program: 190773
Project: 190773
Buggy source:
/** 
 * All the marshal method invocation eventually comes down to this call.
 */
private void write(Object obj,XmlOutput out,Runnable postInitAction) throws JAXBException {
  if (obj == null)   throw new IllegalArgumentException(Messages.NOT_MARSHALLABLE.format());
  if (schema != null) {
    ValidatorHandler validator=schema.newValidatorHandler();
    validator.setErrorHandler(new FatalAdapter(serializer));
    XMLFilterImpl f=new XMLFilterImpl(){
      public void startPrefixMapping(      String prefix,      String uri) throws SAXException {
        super.startPrefixMapping(prefix.intern(),uri.intern());
      }
    }
;
    f.setContentHandler(validator);
    out=new ForkXmlOutput(new SAXOutput(f),out);
  }
  try {
    prewrite(out,isFragment(),postInitAction);
    serializer.childAsRoot(obj);
    postwrite(out);
  }
 catch (  SAXException e) {
    throw new MarshalException(e);
  }
catch (  IOException e) {
    throw new MarshalException(e);
  }
catch (  XMLStreamException e) {
    throw new MarshalException(e);
  }
 finally {
    serializer.close();
  }
}

Fixed version (ground truth):
/** 
 * All the marshal method invocation eventually comes down to this call.
 */
private void write(Object obj,XmlOutput out,Runnable postInitAction) throws JAXBException {
  try {
    if (obj == null)     throw new IllegalArgumentException(Messages.NOT_MARSHALLABLE.format());
    if (schema != null) {
      ValidatorHandler validator=schema.newValidatorHandler();
      validator.setErrorHandler(new FatalAdapter(serializer));
      XMLFilterImpl f=new XMLFilterImpl(){
        public void startPrefixMapping(        String prefix,        String uri) throws SAXException {
          super.startPrefixMapping(prefix.intern(),uri.intern());
        }
      }
;
      f.setContentHandler(validator);
      out=new ForkXmlOutput(new SAXOutput(f),out);
    }
    try {
      prewrite(out,isFragment(),postInitAction);
      serializer.childAsRoot(obj);
      postwrite(out);
    }
 catch (    SAXException e) {
      throw new MarshalException(e);
    }
catch (    IOException e) {
      throw new MarshalException(e);
    }
catch (    XMLStreamException e) {
      throw new MarshalException(e);
    }
 finally {
      serializer.close();
    }
  }
  finally {
    cleanUp();
  }
}
Program: 190774
Project: 190774
Buggy source:
public String toPackageName(String s){
  return toMixedCaseName(toWordList(s),false);
}

Fixed version (ground truth):
/** 
 * Computes a Java package name from a namespace URI, as specified in the spec.
 * @return null if it fails to derive a package name.
 */
public String toPackageName(String nsUri){
  int idx=nsUri.indexOf(':');
  String scheme="String_Node_Str";
  if (idx >= 0) {
    scheme=nsUri.substring(0,idx);
    if (scheme.equalsIgnoreCase("String_Node_Str") || scheme.equalsIgnoreCase("String_Node_Str"))     nsUri=nsUri.substring(idx + 1);
  }
  ArrayList<String> tokens=tokenize(nsUri,"String_Node_Str");
  if (tokens.size() == 0) {
    return null;
  }
  if (tokens.size() > 1) {
    String lastToken=tokens.get(tokens.size() - 1);
    idx=lastToken.lastIndexOf('.');
    if (idx > 0) {
      lastToken=lastToken.substring(0,idx);
      tokens.set(tokens.size() - 1,lastToken);
    }
  }
  String domain=tokens.get(0);
  idx=domain.indexOf(':');
  if (idx >= 0)   domain=domain.substring(0,idx);
  ArrayList<String> r=reverse(tokenize(domain,scheme.equals("String_Node_Str") ? "String_Node_Str" : "String_Node_Str"));
  if (r.get(r.size() - 1).equalsIgnoreCase("String_Node_Str")) {
    r.remove(r.size() - 1);
  }
  tokens.addAll(1,r);
  tokens.remove(0);
  for (int i=0; i < tokens.size(); i++) {
    String token=tokens.get(i);
    token=removeIllegalIdentifierChars(token);
    if (!NameUtil.isJavaIdentifier(token)) {
      token='_' + token;
    }
    tokens.set(i,token.toLowerCase());
  }
  return combine(tokens,'.');
}
Program: 190775
Project: 190775
Buggy source:
/** 
 * Computes the namespace URI -> package name conversion as specified by the JAXB spec.
 * @param namespaceUri Namespace URI. Can be empty, but must not be null.
 * @return A Java package name (e.g., "foo.bar"). "" to represent the root package. This method returns null if the method fails to derive the package name (there are certain namespace URIs with which this algorithm does not work --- such as ":::" as the URI.)
 */
public static String getDefaultPackageName(String namespaceUri){
  if (namespaceUri == null)   throw new IllegalArgumentException();
  return Util.getPackageNameFromNamespaceURI(namespaceUri);
}

Fixed version (ground truth):
/** 
 * Computes the namespace URI -> package name conversion as specified by the JAXB spec.
 * @param namespaceUri Namespace URI. Can be empty, but must not be null.
 * @return A Java package name (e.g., "foo.bar"). "" to represent the root package. This method returns null if the method fails to derive the package name (there are certain namespace URIs with which this algorithm does not work --- such as ":::" as the URI.)
 */
public static String getDefaultPackageName(String namespaceUri){
  if (namespaceUri == null)   throw new IllegalArgumentException();
  return NameConverter.standard.toPackageName(namespaceUri);
}
Program: 190776
Project: 190776
Buggy source:
/** 
 * Gets the Java package to which classes from this namespace should go. <p> Usually, the getOuterClass method should be used to determine where to put a class.
 */
public JPackage getPackage(String targetNamespace){
  XSSchema s=Ring.get(XSSchemaSet.class).getSchema(targetNamespace);
  BISchemaBinding sb=builder.getBindInfo(s).get(BISchemaBinding.class);
  String name=null;
  if (builder.defaultPackage1 != null)   name=builder.defaultPackage1;
  if (name == null && sb != null && sb.getPackageName() != null)   name=sb.getPackageName();
  if (name == null && builder.defaultPackage2 != null)   name=builder.defaultPackage2;
  if (name == null)   name=Util.getPackageNameFromNamespaceURI(targetNamespace);
  if (name == null)   name="String_Node_Str";
  if (checkedPackageNames.add(name)) {
    if (!JJavaName.isJavaPackageName(name))     getErrorReporter().error(s.getLocator(),Messages.ERR_INCORRECT_PACKAGE_NAME,targetNamespace,name);
  }
  return Ring.get(JCodeModel.class)._package(name);
}

Fixed version (ground truth):
/** 
 * Gets the Java package to which classes from this namespace should go. <p> Usually, the getOuterClass method should be used to determine where to put a class.
 */
public JPackage getPackage(String targetNamespace){
  XSSchema s=Ring.get(XSSchemaSet.class).getSchema(targetNamespace);
  BISchemaBinding sb=builder.getBindInfo(s).get(BISchemaBinding.class);
  String name=null;
  if (builder.defaultPackage1 != null)   name=builder.defaultPackage1;
  if (name == null && sb != null && sb.getPackageName() != null)   name=sb.getPackageName();
  if (name == null && builder.defaultPackage2 != null)   name=builder.defaultPackage2;
  if (name == null)   name=builder.getNameConverter().toPackageName(targetNamespace);
  if (name == null)   name="String_Node_Str";
  if (checkedPackageNames.add(name)) {
    if (!JJavaName.isJavaPackageName(name))     getErrorReporter().error(s.getLocator(),Messages.ERR_INCORRECT_PACKAGE_NAME,targetNamespace,name);
  }
  return Ring.get(JCodeModel.class)._package(name);
}
Program: 190777
Project: 190777
Buggy source:
public void addGlobalElement(TypeRef<T,C> tref){
  elementDecls.put(tref.getTagName().getLocalPart(),new ElementWithType(false,tref.getTarget()));
}

Fixed version (ground truth):
public void addGlobalElement(TypeRef<T,C> tref){
  elementDecls.put(tref.getTagName().getLocalPart(),new ElementWithType(false,tref.getTarget()));
  addDependencyTo(tref.getTarget().getTypeName());
}
Program: 190778
Project: 190778
Buggy source:
private void addDependencyTo(QName qname){
  if (qname == null)   return;
  String nsUri=qname.getNamespaceURI();
  if (uri.equals(nsUri) || nsUri.equals(XML_SCHEMA))   return;
  depends.add(getNamespace(nsUri));
}

Fixed version (ground truth):
private void addDependencyTo(@Nullable QName qname){
  if (qname == null)   return;
  String nsUri=qname.getNamespaceURI();
  if (uri.equals(nsUri) || nsUri.equals(XML_SCHEMA))   return;
  depends.add(getNamespace(nsUri));
}
Program: 190779
Project: 190779
Buggy source:
public Class loadClass(String s){
  return null;
}

Fixed version (ground truth):
protected synchronized Class loadClass(String name,boolean resolve) throws ClassNotFoundException {
  if (matchesPrefix(name))   throw new ClassNotFoundException();
  return super.loadClass(name,resolve);
}
Program: 190780
Project: 190780
Buggy source:
protected MaskingClassLoader(ClassLoader parent){
  super(parent);
}

Fixed version (ground truth):
public MaskingClassLoader(ClassLoader parent,List prefixList){
  super(parent);
  this.prefixList=(String[])prefixList.toArray(new String[prefixList.size()]);
}
Program: 190781
Project: 190781
Buggy source:
protected ParallelWorldClassLoader(ClassLoader parent,String prefix){
  super(parent);
  this.prefix=prefix;
  packagePrefixes=getPackagePrefixes();
}

Fixed version (ground truth):
protected ParallelWorldClassLoader(ClassLoader parent,String prefix){
  super(parent);
  this.prefix=prefix;
}
Program: 190782
Project: 190782
Buggy source:
protected URL findResource(String name){
  return getParent().getResource(prefix.concat(name));
}

Fixed version (ground truth):
protected URL findResource(String name){
  return getParent().getResource(prefix + '/' + name);
}
Program: 190783
Project: 190783
Buggy source:
protected Enumeration findResources(String name) throws IOException {
  return getParent().getResources(prefix.concat(name));
}

Fixed version (ground truth):
protected Enumeration findResources(String name) throws IOException {
  return getParent().getResources(prefix + '.' + name);
}
Program: 190784
Project: 190784
Buggy source:
public void execute() throws BuildException {
  ClassLoader cl;
  Class driver;
  try {
    if (source.equals("String_Node_Str")) {
      cl=XJCTask.class.getClassLoader();
      driver=cl.loadClass("String_Node_Str");
    }
 else {
      cl=new ParallelWorldClassLoader(MaskingClassLoader.class.getClassLoader(),source);
      driver=cl.loadClass("String_Node_Str");
    }
    Task t=(Task)driver.newInstance();
    t.setProject(getProject());
    t.setTaskName(getTaskName());
    root.configure(t);
    t.execute();
  }
 catch (  UnsupportedClassVersionError e) {
    throw new BuildException("String_Node_Str");
  }
catch (  ClassNotFoundException e) {
    throw new BuildException(e);
  }
catch (  InstantiationException e) {
    throw new BuildException(e);
  }
catch (  IllegalAccessException e) {
    throw new BuildException(e);
  }
}

Fixed version (ground truth):
public void execute() throws BuildException {
  ClassLoader cl;
  Class driver;
  try {
    if (source.equals("String_Node_Str")) {
      cl=XJCTask.class.getClassLoader();
      driver=cl.loadClass("String_Node_Str");
    }
 else {
      cl=new ParallelWorldClassLoader(new MaskingClassLoader(getClass().getClassLoader(),maskedPackages),source);
      driver=cl.loadClass("String_Node_Str");
    }
    Task t=(Task)driver.newInstance();
    t.setProject(getProject());
    t.setTaskName(getTaskName());
    root.configure(t);
    t.execute();
  }
 catch (  UnsupportedClassVersionError e) {
    throw new BuildException("String_Node_Str");
  }
catch (  ClassNotFoundException e) {
    throw new BuildException(e);
  }
catch (  InstantiationException e) {
    throw new BuildException(e);
  }
catch (  IllegalAccessException e) {
    throw new BuildException(e);
  }
}
Program: 190785
Project: 190785
Buggy source:
private void generateInternalGetter(){
  internalGetter=outline.implClass.method(JMod.PROTECTED,listT,"String_Node_Str" + prop.getName(true));
  if (!eagerInstanciation) {
    fixNullRef(internalGetter.body());
  }
 else {
    field.init(newCoreList());
  }
  internalGetter.body()._return(field);
}

Fixed version (ground truth):
private void generateInternalGetter(){
  internalGetter=outline.implClass.method(JMod.PROTECTED,listT,"String_Node_Str" + prop.getName(true));
  if (!eagerInstanciation) {
    fixNullRef(internalGetter.body());
  }
  internalGetter.body()._return(field);
}
Program: 190786
Project: 190786
Buggy source:
protected final void generate(){
  field=outline.implClass.field(JMod.PROTECTED,getCoreListType(),prop.getName(false));
  annotate(field);
  generateAccessors();
}

Fixed version (ground truth):
protected final void generate(){
  field=outline.implClass.field(JMod.PROTECTED,listT,prop.getName(false));
  if (eagerInstanciation)   field.init(newCoreList());
  annotate(field);
  generateAccessors();
}
Program: 190787
Project: 190787
Buggy source:
/** 
 * Performs the schema correctness check by using JAXP 1.3. <p> This is "weak", because   {@link SchemaFactory#newSchema(Source[])}doesn't handle inclusions very correctly (it ends up parsing it from its original source, not in this tree), and because it doesn't handle two documents for the same namespace very well. <p> We should eventually fix JAXP (and Xerces), but meanwhile this weaker and potentially wrong correctness check is still better than nothing when used inside JAX-WS (JAXB CLI and Ant does a better job of checking this.) <p> To receive errors, use   {@link SchemaFactory#setErrorHandler(ErrorHandler)}.
 */
public void weakSchemaCorrectnessCheck(SchemaFactory sf){
  SAXSource[] sources=new SAXSource[getRootDocuments().size()];
  int i=0;
  for (  String systemId : getRootDocuments()) {
    sources[i]=createSAXSource(systemId);
    try {
      sources[i].getXMLReader().setFeature("String_Node_Str",true);
    }
 catch (    SAXException e) {
      throw new AssertionError(e);
    }
  }
  try {
    sf.newSchema(sources);
  }
 catch (  SAXException e) {
  }
}

Fixed version (ground truth):
/** 
 * Performs the schema correctness check by using JAXP 1.3. <p> This is "weak", because   {@link SchemaFactory#newSchema(Source[])}doesn't handle inclusions very correctly (it ends up parsing it from its original source, not in this tree), and because it doesn't handle two documents for the same namespace very well. <p> We should eventually fix JAXP (and Xerces), but meanwhile this weaker and potentially wrong correctness check is still better than nothing when used inside JAX-WS (JAXB CLI and Ant does a better job of checking this.) <p> To receive errors, use   {@link SchemaFactory#setErrorHandler(ErrorHandler)}.
 */
public void weakSchemaCorrectnessCheck(SchemaFactory sf){
  SAXSource[] sources=new SAXSource[getRootDocuments().size()];
  int i=0;
  for (  String systemId : getRootDocuments()) {
    sources[i]=createSAXSource(systemId);
    try {
      sources[i].getXMLReader().setFeature("String_Node_Str",true);
    }
 catch (    SAXException e) {
      throw new AssertionError(e);
    }
    i++;
  }
  try {
    sf.newSchema(sources);
  }
 catch (  SAXException e) {
  }
}
Program: 190788
Project: 190788
Buggy source:
public static final void handleGenericException(Exception e,boolean canRecover) throws SAXException {
  reportError(e.getMessage(),e,canRecover);
}

Fixed version (ground truth):
public static void handleGenericException(Exception e,boolean canRecover) throws SAXException {
  reportError(e.getMessage(),e,canRecover);
}
Program: 190789
Project: 190789
Buggy source:
public static final void reportError(String msg,Exception nested,boolean canRecover) throws SAXException {
  UnmarshallingContext context=UnmarshallingContext.getInstance();
  context.handleEvent(new ValidationEventImpl(canRecover ? ValidationEvent.ERROR : ValidationEvent.FATAL_ERROR,msg,context.getLocator().getLocation(),nested),canRecover);
}

Fixed version (ground truth):
public static void reportError(String msg,Exception nested,boolean canRecover) throws SAXException {
  UnmarshallingContext context=UnmarshallingContext.getInstance();
  context.handleEvent(new ValidationEventImpl(canRecover ? ValidationEvent.ERROR : ValidationEvent.FATAL_ERROR,msg,context.getLocator().getLocation(),nested),canRecover);
}
Program: 190790
Project: 190790
Buggy source:
/** 
 * This method is called by the generated derived class when a datatype parse method throws an exception.
 */
protected static final void handleParseConversionException(UnmarshallingContext.State state,Exception e) throws SAXException {
  if (e instanceof RuntimeException)   throw (RuntimeException)e;
  state.getContext().handleError(e);
}

Fixed version (ground truth):
/** 
 * This method is called by the generated derived class when a datatype parse method throws an exception.
 */
protected static void handleParseConversionException(UnmarshallingContext.State state,Exception e) throws SAXException {
  state.getContext().handleError(e);
}
Program: 190791
Project: 190791
Buggy source:
public JClass getAdapterClass(JCodeModel cm){
  if (adapterClass1 == null)   adapterClass1=cm.ref(adapterClass2);
  return adapterClass1;
}

Fixed version (ground truth):
public JClass getAdapterClass(Outline o){
  if (adapterClass1 == null)   adapterClass1=o.getCodeModel().ref(adapterClass2);
  return adapterType.toType(o,Aspect.EXPOSED);
}
Program: 190792
Project: 190792
Buggy source:
public JExpression createConstant(Outline outline,XmlString lexical){
  if (isCollection())   return null;
  if (adapter == null)   return coreType.createConstant(outline,lexical);
  JExpression cons=coreType.createConstant(outline,lexical);
  Class<? extends XmlAdapter> atype=adapter.getAdapterIfKnown();
  if (cons instanceof JStringLiteral && atype != null) {
    JStringLiteral scons=(JStringLiteral)cons;
    XmlAdapter a=ClassFactory.create(atype);
    try {
      Object value=a.unmarshal(scons.str);
      if (value instanceof String) {
        return JExpr.lit((String)value);
      }
    }
 catch (    Exception e) {
    }
  }
  return JExpr._new(adapter.getAdapterClass(outline.getCodeModel())).invoke("String_Node_Str").arg(cons);
}

Fixed version (ground truth):
public JExpression createConstant(Outline outline,XmlString lexical){
  if (isCollection())   return null;
  if (adapter == null)   return coreType.createConstant(outline,lexical);
  JExpression cons=coreType.createConstant(outline,lexical);
  Class<? extends XmlAdapter> atype=adapter.getAdapterIfKnown();
  if (cons instanceof JStringLiteral && atype != null) {
    JStringLiteral scons=(JStringLiteral)cons;
    XmlAdapter a=ClassFactory.create(atype);
    try {
      Object value=a.unmarshal(scons.str);
      if (value instanceof String) {
        return JExpr.lit((String)value);
      }
    }
 catch (    Exception e) {
    }
  }
  return JExpr._new(adapter.getAdapterClass(outline)).invoke("String_Node_Str").arg(cons);
}