Program: 19583
Project: 19583
Buggy source:
private Rule convert(JSGFRule rule){
  if (rule instanceof JSGFRuleName) {
    JSGFRuleName ruleName=(JSGFRuleName)rule;
    return new RuleName(ruleName.getRuleName());
  }
  if (rule instanceof JSGFRuleAlternatives) {
    JSGFRuleAlternatives ruleAlternatives=(JSGFRuleAlternatives)rule;
    Rule[] subrules=new Rule[ruleAlternatives.getRules().size()];
    int i=0;
    for (    JSGFRule subrule : ruleAlternatives.getRules()) {
      subrules[i]=convert(subrule);
      i++;
    }
    float[] weights=null;
    if (ruleAlternatives.getWeights() != null) {
      weights=new float[ruleAlternatives.getWeights().size()];
      i=0;
      for (      Float f : ruleAlternatives.getWeights()) {
        weights[i]=f;
        i++;
      }
    }
    return new RuleAlternatives(subrules,weights);
  }
  if (rule instanceof JSGFRuleSequence) {
    JSGFRuleSequence ruleSequence=(JSGFRuleSequence)rule;
    Rule[] subrules=new Rule[ruleSequence.getRules().size()];
    int i=0;
    for (    JSGFRule subrule : ruleSequence.getRules()) {
      subrules[i]=convert(subrule);
      i++;
    }
    return new RuleSequence(subrules);
  }
  if (rule instanceof JSGFRuleCount) {
    JSGFRuleCount ruleCount=(JSGFRuleCount)rule;
    return new RuleCount(convert(ruleCount.getRule()),ruleCount.getCount());
  }
  if (rule instanceof JSGFRuleTag) {
    JSGFRuleTag ruleTag=(JSGFRuleTag)rule;
    return new RuleTag(convert(ruleTag.getRule()),ruleTag.getTag());
  }
  if (rule instanceof JSGFRuleToken) {
    JSGFRuleToken ruleToken=(JSGFRuleToken)rule;
    return new RuleToken(ruleToken.getText());
  }
  System.out.println("String_Node_Str" + rule.getClass());
  return null;
}

Fixed version (ground truth):
private Rule convert(JSGFRule rule){
  if (rule == null)   return null;
  if (rule instanceof JSGFRuleName) {
    if (rule == JSGFRuleName.NULL)     return RuleName.NULL;
    if (rule == JSGFRuleName.VOID)     return RuleName.NULL;
    JSGFRuleName ruleName=(JSGFRuleName)rule;
    return new RuleName(ruleName.getRuleName());
  }
  if (rule instanceof JSGFRuleAlternatives) {
    JSGFRuleAlternatives ruleAlternatives=(JSGFRuleAlternatives)rule;
    Rule[] subrules=new Rule[ruleAlternatives.getRules().size()];
    int i=0;
    for (    JSGFRule subrule : ruleAlternatives.getRules()) {
      subrules[i]=convert(subrule);
      i++;
    }
    float[] weights=null;
    if (ruleAlternatives.getWeights() != null) {
      weights=new float[ruleAlternatives.getWeights().size()];
      i=0;
      for (      Float f : ruleAlternatives.getWeights()) {
        weights[i]=f;
        i++;
      }
    }
    return new RuleAlternatives(subrules,weights);
  }
  if (rule instanceof JSGFRuleSequence) {
    JSGFRuleSequence ruleSequence=(JSGFRuleSequence)rule;
    Rule[] subrules=new Rule[ruleSequence.getRules().size()];
    int i=0;
    for (    JSGFRule subrule : ruleSequence.getRules()) {
      subrules[i]=convert(subrule);
      i++;
    }
    return new RuleSequence(subrules);
  }
  if (rule instanceof JSGFRuleCount) {
    JSGFRuleCount ruleCount=(JSGFRuleCount)rule;
    return new RuleCount(convert(ruleCount.getRule()),ruleCount.getCount());
  }
  if (rule instanceof JSGFRuleTag) {
    JSGFRuleTag ruleTag=(JSGFRuleTag)rule;
    return new RuleTag(convert(ruleTag.getRule()),ruleTag.getTag());
  }
  if (rule instanceof JSGFRuleToken) {
    JSGFRuleToken ruleToken=(JSGFRuleToken)rule;
    return new RuleToken(ruleToken.getText());
  }
  System.out.println("String_Node_Str" + rule.getClass());
  return null;
}