kusumotolab / kGenProg

A High-performance, High-extensibility and High-portability APR System
MIT License
48 stars 13 forks source link

条件式がnullのfor文があるとkgpが落ちる #732

Closed tt-kuma closed 4 years ago

tt-kuma commented 4 years ago

FLの実験中に発生. 題材中に条件式(optionalConditionExpression)が空のfor文があるとNullPointerExceptionで落ちる. 以下のような題材で再現できる.

package example;

public class ExampleFor {
  public int method() {
    for (int i = 0; ; i++) {
      if(i == 10) {
        break;
      }
    }
    return i;
  }
}

StatementAndConditionVisitorの以下の箇所が原因だと考えられる.

  @Override
  public void endVisit(final ForStatement node) {
    consumeElement(node.getExpression()); // Blockよりも後に入れるためにendVisitで行う
    super.endVisit(node);
  }

条件式が空の場合node.getExpression()はnullになりconsumeElement()内でNullPointerExceptionが発生.