Program: 64068
Project: 64068
Buggy source:
/** 
 * Visit the class byte-codes and modify to weave Persistence interfaces. This add PersistenceWeaved, PersistenceWeavedLazy, PersistenceWeavedChangeTracking, PersistenceEntity, ChangeTracker. The new interfaces are pass to the super weaver.
 */
@Override public void visit(int version,int access,String name,String signature,String superName,String[] interfaces){
  this.computeSVUID=(access & Opcodes.ACC_INTERFACE) == 0;
  if (computeSVUID) {
    this.name=name;
    this.access=access;
    this.interfaces=interfaces;
  }
  boolean weaveCloneable=true;
  for (int index=0; index < interfaces.length; index++) {
    String existingInterface=interfaces[index];
    if (PERSISTENCE_WEAVED_SHORT_SIGNATURE.equals(existingInterface)) {
      this.alreadyWeaved=true;
      super.visit(version,access,name,signature,superName,interfaces);
      return;
    }
 else     if (CT_SHORT_SIGNATURE.equals(existingInterface)) {
      classDetails.setShouldWeaveChangeTracking(false);
    }
 else     if (CLONEABLE_SHORT_SIGNATURE.equals(existingInterface)) {
      weaveCloneable=false;
    }
  }
  int newInterfacesLength=interfaces.length;
  int cloneableIndex=0;
  weaveCloneable=classDetails.shouldWeaveInternal() && weaveCloneable && (classDetails.getSuperClassDetails() == null);
  if (weaveCloneable) {
    cloneableIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceWeavedIndex=newInterfacesLength;
  newInterfacesLength++;
  int persistenceEntityIndex=0;
  boolean persistenceEntity=classDetails.shouldWeaveInternal() && (classDetails.getSuperClassDetails() == null) && (!classDetails.isEmbedable());
  if (persistenceEntity) {
    persistenceEntityIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceObjectIndex=0;
  boolean persistenceObject=classDetails.shouldWeaveInternal();
  if (persistenceObject) {
    persistenceObjectIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int fetchGroupTrackerIndex=0;
  boolean fetchGroupTracker=classDetails.shouldWeaveFetchGroups() && (classDetails.getSuperClassDetails() == null);
  if (fetchGroupTracker) {
    fetchGroupTrackerIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceWeavedFetchGroupsIndex=0;
  if (classDetails.shouldWeaveFetchGroups()) {
    persistenceWeavedFetchGroupsIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceWeavedLazyIndex=0;
  if (classDetails.shouldWeaveValueHolders()) {
    persistenceWeavedLazyIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  boolean changeTracker=!classDetails.doesSuperclassWeaveChangeTracking() && classDetails.shouldWeaveChangeTracking();
  int persistenceWeavedChangeTrackingIndex=0;
  int changeTrackerIndex=0;
  if (changeTracker) {
    changeTrackerIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  if (classDetails.shouldWeaveChangeTracking()) {
    persistenceWeavedChangeTrackingIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceWeavedRestIndex=0;
  boolean weaveRest=classDetails.shouldWeaveREST() && classDetails.getSuperClassDetails() == null;
  if (weaveRest) {
    persistenceWeavedRestIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  String[] newInterfaces=new String[newInterfacesLength];
  System.arraycopy(interfaces,0,newInterfaces,0,interfaces.length);
  newInterfaces[persistenceWeavedIndex]=PERSISTENCE_WEAVED_SHORT_SIGNATURE;
  weaved=true;
  if (weaveCloneable) {
    newInterfaces[cloneableIndex]=CLONEABLE_SHORT_SIGNATURE;
  }
  if (persistenceEntity) {
    newInterfaces[persistenceEntityIndex]=PERSISTENCE_ENTITY_SHORT_SIGNATURE;
  }
  if (persistenceObject) {
    newInterfaces[persistenceObjectIndex]=PERSISTENCE_OBJECT_SHORT_SIGNATURE;
  }
  if (fetchGroupTracker) {
    newInterfaces[fetchGroupTrackerIndex]=FETCHGROUP_TRACKER_SHORT_SIGNATURE;
  }
  if (classDetails.shouldWeaveFetchGroups()) {
    newInterfaces[persistenceWeavedFetchGroupsIndex]=WEAVED_FETCHGROUPS_SHORT_SIGNATURE;
  }
  if (classDetails.shouldWeaveValueHolders()) {
    newInterfaces[persistenceWeavedLazyIndex]=TW_LAZY_SHORT_SIGNATURE;
  }
  if (changeTracker) {
    newInterfaces[changeTrackerIndex]=CT_SHORT_SIGNATURE;
  }
  if (classDetails.shouldWeaveChangeTracking()) {
    newInterfaces[persistenceWeavedChangeTrackingIndex]=TW_CT_SHORT_SIGNATURE;
  }
  if (weaveRest) {
    newInterfaces[persistenceWeavedRestIndex]=WEAVED_REST_LAZY_SHORT_SIGNATURE;
  }
  cv.visit(version,access,name,signature,superName,newInterfaces);
}

Fixed version (ground truth):
/** 
 * Visit the class byte-codes and modify to weave Persistence interfaces. This add PersistenceWeaved, PersistenceWeavedLazy, PersistenceWeavedChangeTracking, PersistenceEntity, ChangeTracker. The new interfaces are pass to the super weaver.
 */
@Override public void visit(int version,int access,String name,String signature,String superName,String[] interfaces){
  this.computeSVUID=(access & Opcodes.ACC_INTERFACE) == 0;
  if (computeSVUID) {
    this.name=name;
    this.access=access;
    this.interfaces=interfaces;
  }
  boolean weaveCloneable=true;
  for (int index=0; index < interfaces.length; index++) {
    String existingInterface=interfaces[index];
    if (PERSISTENCE_WEAVED_SHORT_SIGNATURE.equals(existingInterface)) {
      this.alreadyWeaved=true;
      super.visit(version,access,name,signature,superName,interfaces);
      return;
    }
 else     if (CT_SHORT_SIGNATURE.equals(existingInterface)) {
      classDetails.setShouldWeaveChangeTracking(false);
    }
 else     if (CLONEABLE_SHORT_SIGNATURE.equals(existingInterface)) {
      weaveCloneable=false;
    }
  }
  int newInterfacesLength=interfaces.length;
  int cloneableIndex=0;
  weaveCloneable=classDetails.shouldWeaveInternal() && weaveCloneable && (classDetails.getSuperClassDetails() == null);
  if (weaveCloneable) {
    cloneableIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceWeavedIndex=newInterfacesLength;
  newInterfacesLength++;
  int persistenceEntityIndex=0;
  boolean persistenceEntity=classDetails.shouldWeaveInternal() && (classDetails.getSuperClassDetails() == null) && (!classDetails.isEmbedable());
  if (persistenceEntity) {
    persistenceEntityIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceObjectIndex=0;
  boolean persistenceObject=classDetails.shouldWeaveInternal();
  if (persistenceObject) {
    persistenceObjectIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int fetchGroupTrackerIndex=0;
  boolean fetchGroupTracker=classDetails.shouldWeaveFetchGroups() && (classDetails.getSuperClassDetails() == null);
  if (fetchGroupTracker) {
    fetchGroupTrackerIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceWeavedFetchGroupsIndex=0;
  if (classDetails.shouldWeaveFetchGroups()) {
    persistenceWeavedFetchGroupsIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceWeavedLazyIndex=0;
  if (classDetails.shouldWeaveValueHolders()) {
    persistenceWeavedLazyIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  boolean changeTracker=!classDetails.doesSuperclassWeaveChangeTracking() && classDetails.shouldWeaveChangeTracking();
  int persistenceWeavedChangeTrackingIndex=0;
  int changeTrackerIndex=0;
  if (changeTracker) {
    changeTrackerIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  if (classDetails.shouldWeaveChangeTracking()) {
    persistenceWeavedChangeTrackingIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  int persistenceWeavedRestIndex=0;
  boolean weaveRest=classDetails.shouldWeaveREST() && classDetails.getSuperClassDetails() == null;
  if (weaveRest) {
    persistenceWeavedRestIndex=newInterfacesLength;
    newInterfacesLength++;
  }
  String[] newInterfaces=new String[newInterfacesLength];
  System.arraycopy(interfaces,0,newInterfaces,0,interfaces.length);
  newInterfaces[persistenceWeavedIndex]=PERSISTENCE_WEAVED_SHORT_SIGNATURE;
  weaved=true;
  if (weaveCloneable) {
    newInterfaces[cloneableIndex]=CLONEABLE_SHORT_SIGNATURE;
  }
  if (persistenceEntity) {
    newInterfaces[persistenceEntityIndex]=PERSISTENCE_ENTITY_SHORT_SIGNATURE;
  }
  if (persistenceObject) {
    newInterfaces[persistenceObjectIndex]=PERSISTENCE_OBJECT_SHORT_SIGNATURE;
  }
  if (fetchGroupTracker) {
    newInterfaces[fetchGroupTrackerIndex]=FETCHGROUP_TRACKER_SHORT_SIGNATURE;
  }
  if (classDetails.shouldWeaveFetchGroups()) {
    newInterfaces[persistenceWeavedFetchGroupsIndex]=WEAVED_FETCHGROUPS_SHORT_SIGNATURE;
  }
  if (classDetails.shouldWeaveValueHolders()) {
    newInterfaces[persistenceWeavedLazyIndex]=TW_LAZY_SHORT_SIGNATURE;
  }
  if (changeTracker) {
    newInterfaces[changeTrackerIndex]=CT_SHORT_SIGNATURE;
  }
  if (classDetails.shouldWeaveChangeTracking()) {
    newInterfaces[persistenceWeavedChangeTrackingIndex]=TW_CT_SHORT_SIGNATURE;
  }
  if (weaveRest) {
    newInterfaces[persistenceWeavedRestIndex]=WEAVED_REST_LAZY_SHORT_SIGNATURE;
  }
  String newSignature=null;
  if (signature != null) {
    StringBuffer newSignatureBuf=new StringBuffer();
    newSignatureBuf.append(signature);
    for (int i=interfaces.length; i < newInterfaces.length; i++) {
      newSignatureBuf.append("String_Node_Str" + newInterfaces[i] + "String_Node_Str");
    }
    newSignature=newSignatureBuf.toString();
  }
  cv.visit(version,access,name,newSignature,superName,newInterfaces);
}