Program: 186919
Project: 186919
Buggy source:
/** 
 * Create a new constantInfo from a BCEL constant. If the constantpool contains invalid data, a   {@link JavaClassFormatError} is thrown.
 * @param cp the constantpool used to resolve the index references.
 * @param constant the BCEL constant to convert
 * @return a new ConstantInfo containing the constant value.
 */
public static ConstantInfo createFromConstant(ConstantPool cp,Constant constant){
  Signature sig;
  MethodRef methodRef;
  ConstantNameAndType nRef;
  AppInfo appInfo=AppInfo.getSingleton();
  byte tag=constant.getTag();
switch (tag) {
case Constants.CONSTANT_Class:
    ClassRef classRef=appInfo.getClassRef(((ConstantClass)constant).getBytes(cp));
  return new ConstantClassInfo(classRef);
case Constants.CONSTANT_Fieldref:
ConstantFieldref fRef=(ConstantFieldref)constant;
nRef=(ConstantNameAndType)cp.getConstant(fRef.getNameAndTypeIndex());
sig=new Signature(fRef.getClass(cp),nRef.getName(cp),Descriptor.parse(nRef.getSignature(cp)));
FieldRef fieldRef=appInfo.getFieldRef(sig);
return new ConstantFieldInfo(fieldRef);
case Constants.CONSTANT_Methodref:
ConstantInterfaceMethodref mRef=(ConstantInterfaceMethodref)constant;
nRef=(ConstantNameAndType)cp.getConstant(mRef.getNameAndTypeIndex());
sig=new Signature(mRef.getClass(cp),nRef.getName(cp),Descriptor.parse(nRef.getSignature(cp)));
methodRef=appInfo.getMethodRef(sig,false);
return new ConstantMethodInfo(methodRef);
case Constants.CONSTANT_InterfaceMethodref:
ConstantInterfaceMethodref imRef=(ConstantInterfaceMethodref)constant;
nRef=(ConstantNameAndType)cp.getConstant(imRef.getNameAndTypeIndex());
sig=new Signature(imRef.getClass(cp),nRef.getName(cp),Descriptor.parse(nRef.getSignature(cp)));
methodRef=appInfo.getMethodRef(sig,true);
return new ConstantMethodInfo(methodRef);
case Constants.CONSTANT_String:
return new ConstantStringInfo(((ConstantString)constant).getBytes(cp),false);
case Constants.CONSTANT_Integer:
return new ConstantIntegerInfo(((ConstantInteger)constant).getBytes());
case Constants.CONSTANT_Float:
return new ConstantFloatInfo(((ConstantFloat)constant).getBytes());
case Constants.CONSTANT_Long:
return new ConstantLongInfo(((ConstantLong)constant).getBytes());
case Constants.CONSTANT_Double:
return new ConstantDoubleInfo(((ConstantDouble)constant).getBytes());
case Constants.CONSTANT_NameAndType:
String name=((ConstantNameAndType)constant).getName(cp);
String signature=((ConstantNameAndType)constant).getSignature(cp);
return new ConstantNameAndTypeInfo(new Signature(name,Descriptor.parse(signature)));
case Constants.CONSTANT_Utf8:
return new ConstantStringInfo(((ConstantUtf8)constant).getBytes(),true);
default :
throw new JavaClassFormatError("String_Node_Str" + tag);
}
}

Fixed version (ground truth):
/** 
 * Create a new constantInfo from a BCEL constant. If the constantpool contains invalid data, a   {@link JavaClassFormatError} is thrown.
 * @param cp the constantpool used to resolve the index references.
 * @param constant the BCEL constant to convert
 * @return a new ConstantInfo containing the constant value.
 */
public static ConstantInfo createFromConstant(ConstantPool cp,Constant constant){
  Signature sig;
  MethodRef methodRef;
  ConstantNameAndType nRef;
  AppInfo appInfo=AppInfo.getSingleton();
  byte tag=constant.getTag();
switch (tag) {
case Constants.CONSTANT_Class:
    ClassRef classRef=appInfo.getClassRef(((ConstantClass)constant).getBytes(cp));
  return new ConstantClassInfo(classRef);
case Constants.CONSTANT_Fieldref:
ConstantFieldref fRef=(ConstantFieldref)constant;
nRef=(ConstantNameAndType)cp.getConstant(fRef.getNameAndTypeIndex());
sig=new Signature(fRef.getClass(cp),nRef.getName(cp),Descriptor.parse(nRef.getSignature(cp)));
FieldRef fieldRef=appInfo.getFieldRef(sig);
return new ConstantFieldInfo(fieldRef);
case Constants.CONSTANT_Methodref:
ConstantMethodref mRef=(ConstantMethodref)constant;
nRef=(ConstantNameAndType)cp.getConstant(mRef.getNameAndTypeIndex());
sig=new Signature(mRef.getClass(cp),nRef.getName(cp),Descriptor.parse(nRef.getSignature(cp)));
methodRef=appInfo.getMethodRef(sig,false);
return new ConstantMethodInfo(methodRef);
case Constants.CONSTANT_InterfaceMethodref:
ConstantInterfaceMethodref imRef=(ConstantInterfaceMethodref)constant;
nRef=(ConstantNameAndType)cp.getConstant(imRef.getNameAndTypeIndex());
sig=new Signature(imRef.getClass(cp),nRef.getName(cp),Descriptor.parse(nRef.getSignature(cp)));
methodRef=appInfo.getMethodRef(sig,true);
return new ConstantMethodInfo(methodRef);
case Constants.CONSTANT_String:
return new ConstantStringInfo(((ConstantString)constant).getBytes(cp),false);
case Constants.CONSTANT_Integer:
return new ConstantIntegerInfo(((ConstantInteger)constant).getBytes());
case Constants.CONSTANT_Float:
return new ConstantFloatInfo(((ConstantFloat)constant).getBytes());
case Constants.CONSTANT_Long:
return new ConstantLongInfo(((ConstantLong)constant).getBytes());
case Constants.CONSTANT_Double:
return new ConstantDoubleInfo(((ConstantDouble)constant).getBytes());
case Constants.CONSTANT_NameAndType:
String name=((ConstantNameAndType)constant).getName(cp);
String signature=((ConstantNameAndType)constant).getSignature(cp);
return new ConstantNameAndTypeInfo(new Signature(name,Descriptor.parse(signature)));
case Constants.CONSTANT_Utf8:
return new ConstantStringInfo(((ConstantUtf8)constant).getBytes(),true);
default :
throw new JavaClassFormatError("String_Node_Str" + tag);
}
}