Program: 168776
Project: 168776
Buggy source:
public void checkAttribute(ManagedType<?> managedType,MetamodelBuildingContext context){
  Class<?> expressionType=getJavaType();
  Class<?> keyType=null;
  Class<?> elementType=null;
  if (fetches.length != 0) {
    ManagedType<?> entityType=context.getEntityMetamodel().getManagedType(getElementType().getJavaType());
    if (entityType == null) {
      context.addError("String_Node_Str" + Arrays.toString(fetches) + "String_Node_Str"+ getLocation()+ "String_Node_Str");
    }
 else {
      ScalarTargetResolvingExpressionVisitor visitor=new ScalarTargetResolvingExpressionVisitor(entityType,context.getEntityMetamodel(),context.getJpqlFunctions());
      for (int i=0; i < fetches.length; i++) {
        final String fetch=fetches[i];
        final String errorLocation;
        if (fetches.length == 1) {
          errorLocation="String_Node_Str";
        }
 else {
          errorLocation="String_Node_Str" + (i + 1) + "String_Node_Str";
        }
        visitor.clear();
        try {
          context.getExpressionFactory().createPathExpression(fetch).accept(visitor);
        }
 catch (        SyntaxErrorException ex) {
          try {
            context.getExpressionFactory().createSimpleExpression(fetch,false);
            context.addError("String_Node_Str" + fetch + "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
          }
 catch (          SyntaxErrorException ex2) {
            context.addError("String_Node_Str" + errorLocation + "String_Node_Str"+ fetch+ "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
          }
        }
catch (        IllegalArgumentException ex) {
          context.addError("String_Node_Str" + errorLocation + "String_Node_Str"+ fetch+ "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
        }
      }
    }
  }
  if (isCollection()) {
    elementType=getElementType().getJavaType();
    if (isUpdatable()) {
    }
 else {
      if (isIndexed()) {
        if (getCollectionType() == PluralAttribute.CollectionType.MAP) {
          expressionType=Map.class;
          keyType=getKeyType().getJavaType();
        }
 else {
          expressionType=List.class;
          keyType=Integer.class;
        }
      }
 else {
        expressionType=Collection.class;
      }
    }
  }
  if (isSubview()) {
    ManagedViewTypeImplementor<?> subviewType=(ManagedViewTypeImplementor<?>)getElementType();
    if (isCollection()) {
      elementType=subviewType.getEntityClass();
    }
 else {
      expressionType=subviewType.getEntityClass();
    }
  }
  if (isKeySubview()) {
    keyType=((ManagedViewTypeImplementor<?>)getKeyType()).getEntityClass();
  }
  if (isCorrelated()) {
    if (isUpdatable()) {
      context.addError("String_Node_Str" + getLocation());
    }
    validateTypesCompatible(managedType,stripThisFromMapping(correlationBasis),Object.class,null,true,context,ExpressionLocation.CORRELATION_BASIS,getLocation());
    if (correlated != null) {
      validateTypesCompatible(context.getEntityMetamodel().managedType(correlated),stripThisFromMapping(correlationResult),expressionType,elementType,true,context,ExpressionLocation.CORRELATION_RESULT,getLocation());
      try {
        context.createMacroAwareExpressionFactory().createBooleanExpression(correlationExpression,false);
      }
 catch (      SyntaxErrorException ex) {
        context.addError("String_Node_Str" + ExpressionLocation.CORRELATION_EXPRESSION + "String_Node_Str"+ correlationExpression+ "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
      }
catch (      IllegalArgumentException ex) {
        context.addError("String_Node_Str" + ExpressionLocation.CORRELATION_EXPRESSION + "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
      }
    }
  }
 else   if (isSubquery() || isQueryParameter()) {
  }
 else {
    boolean subtypesAllowed=!isUpdatable();
    if (!isCollection() && Collection.class.isAssignableFrom(expressionType)) {
      Class<?>[] typeArguments=getTypeArguments();
      elementType=typeArguments[typeArguments.length - 1];
    }
    String mapping=stripThisFromMapping(this.mapping);
    validateTypesCompatible(managedType,mapping,expressionType,elementType,subtypesAllowed,context,ExpressionLocation.MAPPING,getLocation());
    if (isUpdatable() && declaringType.isUpdatable()) {
      UpdatableExpressionVisitor visitor=new UpdatableExpressionVisitor(managedType.getJavaType());
      try {
        context.getExpressionFactory().createPathExpression(mapping).accept(visitor);
        Map<Method,Class<?>[]> possibleTargets=visitor.getPossibleTargets();
        if (possibleTargets.size() > 1) {
          context.addError("String_Node_Str" + getLocation() + "String_Node_Str"+ possibleTargets);
        }
      }
 catch (      SyntaxErrorException ex) {
        try {
          context.getExpressionFactory().createSimpleExpression(mapping,false);
          context.addError("String_Node_Str" + mapping + "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
        }
 catch (        SyntaxErrorException ex2) {
          context.addError("String_Node_Str" + mapping + "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
        }
      }
catch (      IllegalArgumentException ex) {
        context.addError("String_Node_Str" + getLocation() + "String_Node_Str"+ ex.getMessage());
      }
    }
  }
}

Fixed version (ground truth):
public void checkAttribute(ManagedType<?> managedType,MetamodelBuildingContext context){
  Class<?> expressionType=getJavaType();
  Class<?> keyType=null;
  Class<?> elementType=null;
  if (fetches.length != 0) {
    ManagedType<?> entityType=context.getEntityMetamodel().getManagedType(getElementType().getJavaType());
    if (entityType == null) {
      context.addError("String_Node_Str" + Arrays.toString(fetches) + "String_Node_Str"+ getLocation()+ "String_Node_Str");
    }
 else {
      ScalarTargetResolvingExpressionVisitor visitor=new ScalarTargetResolvingExpressionVisitor(entityType,context.getEntityMetamodel(),context.getJpqlFunctions());
      for (int i=0; i < fetches.length; i++) {
        final String fetch=fetches[i];
        final String errorLocation;
        if (fetches.length == 1) {
          errorLocation="String_Node_Str";
        }
 else {
          errorLocation="String_Node_Str" + (i + 1) + "String_Node_Str";
        }
        visitor.clear();
        try {
          context.getExpressionFactory().createPathExpression(fetch).accept(visitor);
        }
 catch (        SyntaxErrorException ex) {
          try {
            context.getExpressionFactory().createSimpleExpression(fetch,false);
            context.addError("String_Node_Str" + fetch + "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
          }
 catch (          SyntaxErrorException ex2) {
            context.addError("String_Node_Str" + errorLocation + "String_Node_Str"+ fetch+ "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
          }
        }
catch (        IllegalArgumentException ex) {
          context.addError("String_Node_Str" + errorLocation + "String_Node_Str"+ fetch+ "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
        }
      }
    }
  }
  if (isCollection()) {
    elementType=getElementType().getJavaType();
    if (isUpdatable()) {
    }
 else {
      if (isIndexed()) {
        if (getCollectionType() == PluralAttribute.CollectionType.MAP) {
          expressionType=Map.class;
          keyType=getKeyType().getJavaType();
        }
 else {
          expressionType=List.class;
          keyType=Integer.class;
        }
      }
 else {
        expressionType=Collection.class;
      }
    }
  }
  if (isSubview()) {
    ManagedViewTypeImplementor<?> subviewType=(ManagedViewTypeImplementor<?>)getElementType();
    if (isCollection()) {
      elementType=subviewType.getEntityClass();
    }
 else {
      expressionType=subviewType.getEntityClass();
    }
  }
  if (isKeySubview()) {
    keyType=((ManagedViewTypeImplementor<?>)getKeyType()).getEntityClass();
  }
  if (isCorrelated()) {
    if (isUpdatable()) {
      context.addError("String_Node_Str" + getLocation());
    }
    validateTypesCompatible(managedType,stripThisFromMapping(correlationBasis),Object.class,null,true,context,ExpressionLocation.CORRELATION_BASIS,getLocation());
    if (correlated != null) {
      validateTypesCompatible(context.getEntityMetamodel().managedType(correlated),stripThisFromMapping(correlationResult),expressionType,elementType,true,context,ExpressionLocation.CORRELATION_RESULT,getLocation());
      try {
        context.createMacroAwareExpressionFactory().createBooleanExpression(correlationExpression,false);
      }
 catch (      SyntaxErrorException ex) {
        context.addError("String_Node_Str" + ExpressionLocation.CORRELATION_EXPRESSION + "String_Node_Str"+ correlationExpression+ "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
      }
catch (      IllegalArgumentException ex) {
        context.addError("String_Node_Str" + ExpressionLocation.CORRELATION_EXPRESSION + "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
      }
    }
  }
 else   if (isSubquery() || isQueryParameter()) {
  }
 else {
    boolean subtypesAllowed=!isUpdatable();
    if (!isCollection() && Collection.class.isAssignableFrom(expressionType)) {
      Class<?>[] typeArguments=getTypeArguments();
      elementType=typeArguments[typeArguments.length - 1];
    }
    if (getElementType().getConvertedType() == null) {
      validateTypesCompatible(possibleTargetTypes,expressionType,elementType,subtypesAllowed,context,ExpressionLocation.MAPPING,getLocation());
    }
    if (isUpdatable() && declaringType.isUpdatable()) {
      UpdatableExpressionVisitor visitor=new UpdatableExpressionVisitor(managedType.getJavaType());
      try {
        context.getExpressionFactory().createPathExpression(mapping).accept(visitor);
        Map<Method,Class<?>[]> possibleTargets=visitor.getPossibleTargets();
        if (possibleTargets.size() > 1) {
          context.addError("String_Node_Str" + getLocation() + "String_Node_Str"+ possibleTargets);
        }
      }
 catch (      SyntaxErrorException ex) {
        try {
          context.getExpressionFactory().createSimpleExpression(mapping,false);
          context.addError("String_Node_Str" + mapping + "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
        }
 catch (        SyntaxErrorException ex2) {
          context.addError("String_Node_Str" + mapping + "String_Node_Str"+ getLocation()+ "String_Node_Str"+ ex.getMessage());
        }
      }
catch (      IllegalArgumentException ex) {
        context.addError("String_Node_Str" + getLocation() + "String_Node_Str"+ ex.getMessage());
      }
    }
  }
}