Program: 39671
Project: 39671
Buggy source:
private TypeMapping _build(){
  NodeMapping nodeMapping=javaClass.getDeclaredAnnotation(NodeMapping.class);
  if (nodeMapping == null) {
    throw new IllegalStateException("String_Node_Str" + javaClass + "String_Node_Str");
  }
  String primaryNodeTypeName=nodeMapping.name();
  Set<PropertyMapping> propertyMappings=new HashSet<PropertyMapping>();
  Set<MethodMapping> methodMappings=new HashSet<MethodMapping>();
  BeanInfo info=new BeanInfo(javaClass);
  Mixin mixin=new AnnotationIntrospector<Mixin>(Mixin.class).resolve(javaClass);
  Set<String> mixinNames=new HashSet<String>();
  if (mixin != null) {
    for (    String mixinName : mixin.name()) {
      mixinNames.add(mixinName);
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(Property.class)) {
    Property propertyAnnotation=propertyInfo.getAnnotation(Property.class);
    ValueInfo value;
    if (propertyInfo instanceof SingleValuedPropertyInfo) {
      SingleValuedPropertyInfo svp=(SingleValuedPropertyInfo)propertyInfo;
      value=svp.getValue();
    }
 else     if (propertyInfo instanceof MultiValuedPropertyInfo) {
      MultiValuedPropertyInfo mvp=(MultiValuedPropertyInfo)propertyInfo;
      value=mvp.getElementValue();
    }
 else {
      throw new IllegalStateException();
    }
    if (value instanceof SimpleValueInfo) {
      JCRPropertyMapping memberMapping=new JCRPropertyMapping(propertyAnnotation.name());
      SimpleMapping<JCRPropertyMapping> simpleMapping=new SimpleMapping<JCRPropertyMapping>(memberMapping);
      PropertyMapping<SimpleMapping<JCRPropertyMapping>> propertyMapping=new PropertyMapping<SimpleMapping<JCRPropertyMapping>>(propertyInfo,simpleMapping);
      propertyMappings.add(propertyMapping);
    }
 else {
      throw new IllegalStateException("String_Node_Str" + value);
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(Properties.class)) {
    Properties propertyAnnotation=propertyInfo.getAnnotation(Properties.class);
    if (propertyInfo instanceof MapPropertyInfo) {
      MapPropertyInfo mapPropertyInfo=(MapPropertyInfo)propertyInfo;
      PropertyMapMapping simpleMapping=new PropertyMapMapping();
      PropertyMapping<PropertyMapMapping> propertyMapping=new PropertyMapping<PropertyMapMapping>(mapPropertyInfo,simpleMapping);
      propertyMappings.add(propertyMapping);
    }
 else {
      throw new IllegalStateException();
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties()) {
    NodeAttributeType nat=null;
    if (propertyInfo.getAnnotation(Name.class) != null) {
      nat=NodeAttributeType.NAME;
    }
 else     if (propertyInfo.getAnnotation(Id.class) != null) {
      nat=NodeAttributeType.ID;
    }
 else     if (propertyInfo.getAnnotation(Path.class) != null) {
      if (propertyInfo.getAnnotation(Property.class) == null) {
        nat=NodeAttributeType.PATH;
      }
    }
 else     if (propertyInfo.getAnnotation(WorkspaceName.class) != null) {
      nat=NodeAttributeType.WORKSPACE_NAME;
    }
    if (nat != null) {
      if (propertyInfo instanceof SingleValuedPropertyInfo) {
        SingleValuedPropertyInfo svpi=(SingleValuedPropertyInfo)propertyInfo;
        ValueInfo vi=svpi.getValue();
        if (vi instanceof SimpleValueInfo) {
          SimpleValueInfo svi=(SimpleValueInfo)vi;
          JCRNodeAttributeMapping memberMapping=new JCRNodeAttributeMapping(nat);
          SimpleType simpleType=svi.getSimpleType();
          if (nat == NodeAttributeType.PATH) {
            if (simpleType != SimpleType.PATH) {
              throw new IllegalStateException("String_Node_Str" + simpleType + "String_Node_Str");
            }
          }
 else {
            if (simpleType != SimpleType.STRING) {
              throw new IllegalStateException("String_Node_Str" + simpleType + "String_Node_Str");
            }
          }
          SimpleMapping<JCRNodeAttributeMapping> simpleMapping=new SimpleMapping<JCRNodeAttributeMapping>(memberMapping);
          PropertyMapping<SimpleMapping<JCRNodeAttributeMapping>> propertyMapping=new PropertyMapping<SimpleMapping<JCRNodeAttributeMapping>>(propertyInfo,simpleMapping);
          propertyMappings.add(propertyMapping);
        }
 else {
          throw new IllegalStateException();
        }
      }
 else {
        throw new IllegalStateException();
      }
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(OneToOne.class)) {
    if (propertyInfo instanceof SingleValuedPropertyInfo) {
      SingleValuedPropertyInfo svpi=(SingleValuedPropertyInfo)propertyInfo;
      ValueInfo vi=svpi.getValue();
      if (vi instanceof BeanValueInfo) {
        BeanValueInfo bvi=(BeanValueInfo)vi;
        ClassTypeInfo typeInfo=bvi.getTypeInfo();
        OneToOne oneToOneAnn=propertyInfo.getAnnotation(OneToOne.class);
        RelationshipMapping hierarchyMapping;
        MappedBy mappedBy=propertyInfo.getAnnotation(MappedBy.class);
        if (mappedBy != null) {
          hierarchyMapping=new NamedOneToOneMapping(typeInfo,mappedBy.value(),RelationshipType.HIERARCHIC,true);
        }
 else {
          RelatedMappedBy relatedMappedBy=propertyInfo.getAnnotation(RelatedMappedBy.class);
          if (relatedMappedBy != null) {
            hierarchyMapping=new NamedOneToOneMapping(typeInfo,relatedMappedBy.value(),RelationshipType.HIERARCHIC,false);
          }
 else {
            throw new IllegalStateException("String_Node_Str" + propertyInfo + "String_Node_Str"+ info);
          }
        }
        PropertyMapping<RelationshipMapping> oneToOneMapping=new PropertyMapping<RelationshipMapping>(propertyInfo,hierarchyMapping);
        propertyMappings.add(oneToOneMapping);
      }
 else {
        throw new IllegalStateException();
      }
    }
 else {
      throw new IllegalStateException();
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(OneToMany.class)) {
    OneToMany oneToManyAnn=propertyInfo.getAnnotation(OneToMany.class);
    if (propertyInfo instanceof MultiValuedPropertyInfo) {
      MultiValuedPropertyInfo multiValuedProperty=(MultiValuedPropertyInfo)propertyInfo;
      if (multiValuedProperty instanceof MapPropertyInfo) {
        MapPropertyInfo mapProperty=(MapPropertyInfo)multiValuedProperty;
        if (!(mapProperty.getKeyValue() instanceof SimpleValueInfo)) {
          throw new IllegalStateException("String_Node_Str" + mapProperty.getKeyValue());
        }
        SimpleValueInfo svi=(SimpleValueInfo)mapProperty.getKeyValue();
        if (svi.getSimpleType() != SimpleType.STRING) {
          throw new IllegalStateException();
        }
      }
      ValueInfo beanElementType=multiValuedProperty.getElementValue();
      if (beanElementType instanceof BeanValueInfo) {
        BeanValueInfo bvi=(BeanValueInfo)beanElementType;
        OneToManyMapping mapping;
        RelationshipType type=oneToManyAnn.type();
        if (type == RelationshipType.HIERARCHIC) {
          MappedBy mappedBy=propertyInfo.getAnnotation(MappedBy.class);
          if (mappedBy != null) {
            throw new IllegalStateException();
          }
          mapping=new OneToManyMapping(bvi.getTypeInfo(),RelationshipType.HIERARCHIC);
        }
 else {
          RelatedMappedBy mappedBy=propertyInfo.getAnnotation(RelatedMappedBy.class);
          if (mappedBy == null) {
            throw new IllegalStateException();
          }
          mapping=new NamedOneToManyMapping(bvi.getTypeInfo(),mappedBy.value(),type);
        }
        PropertyMapping<OneToManyMapping> oneToManyMapping=new PropertyMapping<OneToManyMapping>(propertyInfo,mapping);
        propertyMappings.add(oneToManyMapping);
      }
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(ManyToOne.class)) {
    if (propertyInfo instanceof SingleValuedPropertyInfo) {
      SingleValuedPropertyInfo svpi=(SingleValuedPropertyInfo)propertyInfo;
      ValueInfo vi=svpi.getValue();
      if (vi instanceof BeanValueInfo) {
        BeanValueInfo bvi=(BeanValueInfo)vi;
        ManyToOne manyToOneAnn=propertyInfo.getAnnotation(ManyToOne.class);
        RelationshipType type=manyToOneAnn.type();
        if (type == RelationshipType.HIERARCHIC) {
          RelationshipMapping hierarchyMapping=new ManyToOneMapping(bvi.getTypeInfo(),RelationshipType.HIERARCHIC);
          PropertyMapping<RelationshipMapping> manyToOneMapping=new PropertyMapping<RelationshipMapping>(propertyInfo,hierarchyMapping);
          propertyMappings.add(manyToOneMapping);
        }
 else {
          MappedBy mappedBy=propertyInfo.getAnnotation(MappedBy.class);
          if (mappedBy == null) {
            throw new IllegalStateException();
          }
          NamedManyToOneMapping referenceMapping=new NamedManyToOneMapping(bvi.getTypeInfo(),mappedBy.value(),type);
          PropertyMapping<NamedManyToOneMapping> manyToOneMapping=new PropertyMapping<NamedManyToOneMapping>(propertyInfo,referenceMapping);
          propertyMappings.add(manyToOneMapping);
        }
      }
    }
 else {
      throw new IllegalStateException();
    }
  }
  ClassIntrospector introspector=new ClassIntrospector(javaClass);
  for (  MethodInfo method : introspector.resolveMethods(Create.class)) {
    if (!method.isStatic()) {
      List<TypeInfo> parameterTypes=method.getParameterTypes();
      if (parameterTypes.size() < 2) {
        if (parameterTypes.size() == 1) {
          TypeInfo argTI=parameterTypes.get(0);
          if (argTI instanceof ClassTypeInfo) {
            ClassTypeInfo argCTI=(ClassTypeInfo)argTI;
            if (!argCTI.getName().equals(String.class.getName())) {
              throw new IllegalStateException();
            }
          }
 else {
            throw new IllegalStateException();
          }
        }
        ClassTypeInfo cti=(ClassTypeInfo)javaClass.resolve(method.getReturnType());
        methodMappings.add(new CreateMapping(method,cti));
      }
 else {
        throw new IllegalStateException();
      }
    }
  }
  for (  MethodInfo method : introspector.resolveMethods(Destroy.class)) {
    if (!method.isStatic()) {
      List<TypeInfo> parameterTypes=method.getParameterTypes();
      if (parameterTypes.size() != 0) {
        throw new IllegalStateException();
      }
      if (!(method.getReturnType() instanceof VoidTypeInfo)) {
        throw new IllegalStateException();
      }
      methodMappings.add(new DestroyMapping(method));
    }
  }
  for (  MethodInfo method : introspector.resolveMethods(FindById.class)) {
    if (!method.isStatic()) {
      List<TypeInfo> parameterTypes=method.getParameterTypes();
      if (parameterTypes.size() == 1) {
        TypeInfo argTI=parameterTypes.get(0);
        if (argTI instanceof ClassTypeInfo) {
          ClassTypeInfo argCTI=(ClassTypeInfo)argTI;
          if (argCTI.getName().equals(String.class.getName())) {
            ClassTypeInfo cti=(ClassTypeInfo)javaClass.resolve(method.getReturnType());
            methodMappings.add(new FindByIdMapping(method,cti));
          }
 else {
            throw new IllegalStateException();
          }
        }
 else {
          throw new IllegalStateException();
        }
      }
    }
  }
  return new TypeMapping(javaClass,propertyMappings,methodMappings,primaryNodeTypeName,mixinNames);
}

Fixed version (ground truth):
private TypeMapping _build(){
  NodeMapping nodeMapping=javaClass.getDeclaredAnnotation(NodeMapping.class);
  if (nodeMapping == null) {
    throw new IllegalStateException("String_Node_Str" + javaClass + "String_Node_Str");
  }
  String primaryNodeTypeName=nodeMapping.name();
  Set<PropertyMapping> propertyMappings=new HashSet<PropertyMapping>();
  Set<MethodMapping> methodMappings=new HashSet<MethodMapping>();
  BeanInfo info=new BeanInfo(javaClass);
  Mixin mixin=new AnnotationIntrospector<Mixin>(Mixin.class).resolve(javaClass);
  Set<String> mixinNames=new HashSet<String>();
  if (mixin != null) {
    for (    String mixinName : mixin.name()) {
      mixinNames.add(mixinName);
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(Property.class)) {
    Property propertyAnnotation=propertyInfo.getAnnotation(Property.class);
    ValueInfo value;
    if (propertyInfo instanceof SingleValuedPropertyInfo) {
      SingleValuedPropertyInfo svp=(SingleValuedPropertyInfo)propertyInfo;
      value=svp.getValue();
    }
 else     if (propertyInfo instanceof MultiValuedPropertyInfo) {
      MultiValuedPropertyInfo mvp=(MultiValuedPropertyInfo)propertyInfo;
      value=mvp.getElementValue();
    }
 else {
      throw new IllegalStateException();
    }
    if (value instanceof SimpleValueInfo) {
      JCRPropertyMapping memberMapping=new JCRPropertyMapping(propertyAnnotation.name());
      SimpleMapping<JCRPropertyMapping> simpleMapping=new SimpleMapping<JCRPropertyMapping>(memberMapping);
      PropertyMapping<SimpleMapping<JCRPropertyMapping>> propertyMapping=new PropertyMapping<SimpleMapping<JCRPropertyMapping>>(propertyInfo,simpleMapping);
      propertyMappings.add(propertyMapping);
    }
 else {
      throw new IllegalStateException("String_Node_Str" + value);
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(Properties.class)) {
    Properties propertyAnnotation=propertyInfo.getAnnotation(Properties.class);
    if (propertyInfo instanceof MapPropertyInfo) {
      MapPropertyInfo mapPropertyInfo=(MapPropertyInfo)propertyInfo;
      PropertyMapMapping simpleMapping=new PropertyMapMapping();
      PropertyMapping<PropertyMapMapping> propertyMapping=new PropertyMapping<PropertyMapMapping>(mapPropertyInfo,simpleMapping);
      propertyMappings.add(propertyMapping);
    }
 else {
      throw new IllegalStateException();
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties()) {
    NodeAttributeType nat=null;
    if (propertyInfo.getAnnotation(Name.class) != null) {
      nat=NodeAttributeType.NAME;
    }
 else     if (propertyInfo.getAnnotation(Id.class) != null) {
      nat=NodeAttributeType.ID;
    }
 else     if (propertyInfo.getAnnotation(Path.class) != null) {
      if (propertyInfo.getAnnotation(Property.class) == null) {
        nat=NodeAttributeType.PATH;
      }
    }
 else     if (propertyInfo.getAnnotation(WorkspaceName.class) != null) {
      nat=NodeAttributeType.WORKSPACE_NAME;
    }
    if (nat != null) {
      if (propertyInfo instanceof SingleValuedPropertyInfo) {
        SingleValuedPropertyInfo svpi=(SingleValuedPropertyInfo)propertyInfo;
        ValueInfo vi=svpi.getValue();
        if (vi instanceof SimpleValueInfo) {
          SimpleValueInfo svi=(SimpleValueInfo)vi;
          JCRNodeAttributeMapping memberMapping=new JCRNodeAttributeMapping(nat);
          SimpleType simpleType=svi.getSimpleType();
          if (nat == NodeAttributeType.PATH) {
            if (simpleType != SimpleType.PATH) {
              throw new IllegalStateException("String_Node_Str" + simpleType + "String_Node_Str");
            }
          }
 else {
            if (simpleType != SimpleType.STRING) {
              throw new IllegalStateException("String_Node_Str" + simpleType + "String_Node_Str");
            }
          }
          SimpleMapping<JCRNodeAttributeMapping> simpleMapping=new SimpleMapping<JCRNodeAttributeMapping>(memberMapping);
          PropertyMapping<SimpleMapping<JCRNodeAttributeMapping>> propertyMapping=new PropertyMapping<SimpleMapping<JCRNodeAttributeMapping>>(propertyInfo,simpleMapping);
          propertyMappings.add(propertyMapping);
        }
 else {
          throw new IllegalStateException();
        }
      }
 else {
        throw new IllegalStateException();
      }
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(OneToOne.class)) {
    if (propertyInfo instanceof SingleValuedPropertyInfo) {
      SingleValuedPropertyInfo svpi=(SingleValuedPropertyInfo)propertyInfo;
      ValueInfo vi=svpi.getValue();
      if (vi instanceof BeanValueInfo) {
        BeanValueInfo bvi=(BeanValueInfo)vi;
        ClassTypeInfo typeInfo=bvi.getTypeInfo();
        OneToOne oneToOneAnn=propertyInfo.getAnnotation(OneToOne.class);
        RelationshipMapping hierarchyMapping;
        MappedBy mappedBy=propertyInfo.getAnnotation(MappedBy.class);
        if (mappedBy != null) {
          hierarchyMapping=new NamedOneToOneMapping(typeInfo,mappedBy.value(),RelationshipType.HIERARCHIC,true);
        }
 else {
          RelatedMappedBy relatedMappedBy=propertyInfo.getAnnotation(RelatedMappedBy.class);
          if (relatedMappedBy != null) {
            hierarchyMapping=new NamedOneToOneMapping(typeInfo,relatedMappedBy.value(),RelationshipType.HIERARCHIC,false);
          }
 else {
            throw new IllegalStateException("String_Node_Str" + propertyInfo + "String_Node_Str"+ info);
          }
        }
        PropertyMapping<RelationshipMapping> oneToOneMapping=new PropertyMapping<RelationshipMapping>(propertyInfo,hierarchyMapping);
        propertyMappings.add(oneToOneMapping);
      }
 else {
        throw new IllegalStateException();
      }
    }
 else {
      throw new IllegalStateException();
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(OneToMany.class)) {
    OneToMany oneToManyAnn=propertyInfo.getAnnotation(OneToMany.class);
    if (propertyInfo instanceof MultiValuedPropertyInfo) {
      MultiValuedPropertyInfo multiValuedProperty=(MultiValuedPropertyInfo)propertyInfo;
      if (multiValuedProperty instanceof MapPropertyInfo) {
        MapPropertyInfo mapProperty=(MapPropertyInfo)multiValuedProperty;
        if (!(mapProperty.getKeyValue() instanceof SimpleValueInfo)) {
          throw new IllegalStateException("String_Node_Str" + mapProperty.getKeyValue());
        }
        SimpleValueInfo svi=(SimpleValueInfo)mapProperty.getKeyValue();
        if (svi.getSimpleType() != SimpleType.STRING) {
          throw new IllegalStateException();
        }
      }
      ValueInfo beanElementType=multiValuedProperty.getElementValue();
      if (beanElementType instanceof BeanValueInfo) {
        BeanValueInfo bvi=(BeanValueInfo)beanElementType;
        OneToManyMapping mapping;
        RelationshipType type=oneToManyAnn.type();
        if (type == RelationshipType.HIERARCHIC) {
          MappedBy mappedBy=propertyInfo.getAnnotation(MappedBy.class);
          if (mappedBy != null) {
            throw new IllegalStateException();
          }
          mapping=new OneToManyMapping(bvi.getTypeInfo(),RelationshipType.HIERARCHIC);
        }
 else {
          RelatedMappedBy mappedBy=propertyInfo.getAnnotation(RelatedMappedBy.class);
          if (mappedBy == null) {
            throw new IllegalStateException();
          }
          mapping=new NamedOneToManyMapping(bvi.getTypeInfo(),mappedBy.value(),type);
        }
        PropertyMapping<OneToManyMapping> oneToManyMapping=new PropertyMapping<OneToManyMapping>(propertyInfo,mapping);
        propertyMappings.add(oneToManyMapping);
      }
    }
  }
  for (  PropertyInfo propertyInfo : info.getProperties(ManyToOne.class)) {
    if (propertyInfo instanceof SingleValuedPropertyInfo) {
      SingleValuedPropertyInfo svpi=(SingleValuedPropertyInfo)propertyInfo;
      ValueInfo vi=svpi.getValue();
      if (vi instanceof BeanValueInfo) {
        BeanValueInfo bvi=(BeanValueInfo)vi;
        ManyToOne manyToOneAnn=propertyInfo.getAnnotation(ManyToOne.class);
        RelationshipType type=manyToOneAnn.type();
        if (type == RelationshipType.HIERARCHIC) {
          RelationshipMapping hierarchyMapping=new ManyToOneMapping(bvi.getTypeInfo(),RelationshipType.HIERARCHIC);
          PropertyMapping<RelationshipMapping> manyToOneMapping=new PropertyMapping<RelationshipMapping>(propertyInfo,hierarchyMapping);
          propertyMappings.add(manyToOneMapping);
        }
 else {
          MappedBy mappedBy=propertyInfo.getAnnotation(MappedBy.class);
          if (mappedBy == null) {
            throw new IllegalStateException();
          }
          NamedManyToOneMapping referenceMapping=new NamedManyToOneMapping(bvi.getTypeInfo(),mappedBy.value(),type);
          PropertyMapping<NamedManyToOneMapping> manyToOneMapping=new PropertyMapping<NamedManyToOneMapping>(propertyInfo,referenceMapping);
          propertyMappings.add(manyToOneMapping);
        }
      }
    }
 else {
      throw new IllegalStateException();
    }
  }
  MethodIntrospector introspector=new MethodIntrospector(HierarchyScope.ALL);
  for (  MethodInfo method : introspector.resolveMethods(javaClass,Create.class)) {
    if (!method.isStatic()) {
      List<TypeInfo> parameterTypes=method.getParameterTypes();
      if (parameterTypes.size() < 2) {
        if (parameterTypes.size() == 1) {
          TypeInfo argTI=parameterTypes.get(0);
          if (argTI instanceof ClassTypeInfo) {
            ClassTypeInfo argCTI=(ClassTypeInfo)argTI;
            if (!argCTI.getName().equals(String.class.getName())) {
              throw new IllegalStateException();
            }
          }
 else {
            throw new IllegalStateException();
          }
        }
        ClassTypeInfo cti=(ClassTypeInfo)javaClass.resolve(method.getReturnType());
        methodMappings.add(new CreateMapping(method,cti));
      }
 else {
        throw new IllegalStateException();
      }
    }
  }
  for (  MethodInfo method : introspector.resolveMethods(javaClass,Destroy.class)) {
    if (!method.isStatic()) {
      List<TypeInfo> parameterTypes=method.getParameterTypes();
      if (parameterTypes.size() != 0) {
        throw new IllegalStateException();
      }
      if (!(method.getReturnType() instanceof VoidTypeInfo)) {
        throw new IllegalStateException();
      }
      methodMappings.add(new DestroyMapping(method));
    }
  }
  for (  MethodInfo method : introspector.resolveMethods(javaClass,FindById.class)) {
    if (!method.isStatic()) {
      List<TypeInfo> parameterTypes=method.getParameterTypes();
      if (parameterTypes.size() == 1) {
        TypeInfo argTI=parameterTypes.get(0);
        if (argTI instanceof ClassTypeInfo) {
          ClassTypeInfo argCTI=(ClassTypeInfo)argTI;
          if (argCTI.getName().equals(String.class.getName())) {
            ClassTypeInfo cti=(ClassTypeInfo)javaClass.resolve(method.getReturnType());
            methodMappings.add(new FindByIdMapping(method,cti));
          }
 else {
            throw new IllegalStateException();
          }
        }
 else {
          throw new IllegalStateException();
        }
      }
    }
  }
  return new TypeMapping(javaClass,propertyMappings,methodMappings,primaryNodeTypeName,mixinNames);
}