Program: 6245
Project: 6245
Buggy source:
public ContextMap<CallString,Map<Location,ValueMapping>> transfer(InstructionHandle stmt,FlowEdge edge,ContextMap<CallString,Map<Location,ValueMapping>> input,Interpreter<CallString,Map<Location,ValueMapping>> interpreter,Map<InstructionHandle,ContextMap<CallString,Map<Location,ValueMapping>>> state){
  Context context=new Context(input.getContext());
  HashMap<Location,ValueMapping> in=(HashMap<Location,ValueMapping>)input.get(context.callString);
  ContextMap<CallString,Map<Location,ValueMapping>> retval=new ContextMap<CallString,Map<Location,ValueMapping>>(context,input);
  HashMap<Location,ValueMapping> result=new HashMap<Location,ValueMapping>();
  retval.put(context.callString,result);
  Instruction instruction=stmt.getInstruction();
  if (stmt.hasTargeters() && context.method.startsWith("String_Node_Str")) {
    for (int i=0; i < stmt.getTargeters().length; i++) {
      InstructionTargeter targeter=stmt.getTargeters()[i];
      if (targeter instanceof BranchInstruction) {
        checkScope(context,stmt);
        break;
      }
    }
  }
switch (instruction.getOpcode()) {
case Constants.ICONST_M1:
case Constants.ICONST_0:
case Constants.ICONST_1:
case Constants.ICONST_2:
case Constants.ICONST_3:
case Constants.ICONST_4:
case Constants.ICONST_5:
case Constants.BIPUSH:
case Constants.SIPUSH:
{
      ConstantPushInstruction instr=(ConstantPushInstruction)instruction;
      result=new HashMap<Location,ValueMapping>(in);
      retval.put(context.callString,result);
      int value=instr.getValue().intValue();
      result.put(new Location(context.stackPtr),new ValueMapping(value));
    }
  break;
case Constants.ACONST_NULL:
result=in;
retval.put(context.callString,result);
break;
case Constants.LDC:
case Constants.LDC_W:
{
LDC instr=(LDC)instruction;
result=new HashMap<Location,ValueMapping>(in);
retval.put(context.callString,result);
Type type=instr.getType(context.constPool);
if (type.equals(Type.INT)) {
Integer value=(Integer)instr.getValue(context.constPool);
result.put(new Location(context.stackPtr),new ValueMapping(value.intValue()));
}
 else if (type.equals(Type.STRING)) {
String value=(String)instr.getValue(context.constPool);
String name="String_Node_Str";
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
result.put(new Location(name + "String_Node_Str"),new ValueMapping(value.length()));
}
}
break;
case Constants.LDC2_W:
result=in;
retval.put(context.callString,result);
break;
case Constants.ISTORE_0:
case Constants.ISTORE_1:
case Constants.ISTORE_2:
case Constants.ISTORE_3:
case Constants.ISTORE:
{
StoreInstruction instr=(StoreInstruction)instruction;
int index=instr.getIndex();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1 && l.stackLoc != index) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
ValueMapping v=new ValueMapping(in.get(l),true);
if (in.get(l).source == null || in.get(l).source.stackLoc != index) {
v.defscope=ValueMapping.scope;
}
result.put(new Location(index),v);
}
}
}
break;
case Constants.ASTORE_0:
case Constants.ASTORE_1:
case Constants.ASTORE_2:
case Constants.ASTORE_3:
case Constants.ASTORE:
result=in;
retval.put(context.callString,result);
break;
case Constants.ILOAD_0:
case Constants.ILOAD_1:
case Constants.ILOAD_2:
case Constants.ILOAD_3:
case Constants.ILOAD:
{
LoadInstruction instr=(LoadInstruction)instruction;
filterSet(in,result,context.stackPtr);
int index=instr.getIndex();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == index) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.source=l;
result.put(new Location(context.stackPtr),m);
}
}
}
break;
case Constants.ALOAD_0:
case Constants.ALOAD_1:
case Constants.ALOAD_2:
case Constants.ALOAD_3:
case Constants.ALOAD:
result=in;
retval.put(context.callString,result);
break;
case Constants.ARRAYLENGTH:
{
filterSet(in,result,context.stackPtr - 1);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 1);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String arrayName=i.next();
ValueMapping m=in.get(new Location(arrayName + "String_Node_Str"));
if (m != null) {
ValueMapping value=new ValueMapping(m,false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
if (!valid) {
result.put(new Location(context.stackPtr - 1),new ValueMapping());
}
}
break;
case Constants.PUTFIELD:
{
PUTFIELD instr=(PUTFIELD)instruction;
int fieldSize=instr.getFieldType(context.constPool).getSize();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - 1 - fieldSize) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
String f=fieldName.substring(fieldName.lastIndexOf("String_Node_Str"),fieldName.length());
String strippedName;
if (fieldName.indexOf("String_Node_Str") >= 0) {
strippedName=fieldName.split("String_Node_Str")[0] + f;
}
 else {
strippedName=fieldName;
}
if (p.containsField(strippedName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(fieldName),new ValueMapping(in.get(l),false));
}
}
}
}
}
break;
case Constants.GETFIELD:
{
GETFIELD instr=(GETFIELD)instruction;
filterSet(in,result,context.stackPtr - 1);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 1);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
String f=fieldName.substring(fieldName.lastIndexOf("String_Node_Str"),fieldName.length());
String strippedName;
if (fieldName.indexOf("String_Node_Str") >= 0) {
strippedName=fieldName.split("String_Node_Str")[0] + f;
}
 else {
strippedName=fieldName;
}
if (p.containsField(strippedName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(fieldName)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
}
if (!valid && !(instr.getFieldType(context.constPool) instanceof ReferenceType)) {
result.put(new Location(context.stackPtr - 1),new ValueMapping());
}
}
break;
case Constants.PUTSTATIC:
{
PUTSTATIC instr=(PUTSTATIC)instruction;
int fieldSize=instr.getFieldType(context.constPool).getSize();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - fieldSize) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
if (p.containsField(fieldName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.stackLoc < 0 && !receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(fieldName),new ValueMapping(in.get(l),false));
}
}
}
}
}
break;
case Constants.GETSTATIC:
{
GETSTATIC instr=(GETSTATIC)instruction;
result=new HashMap<Location,ValueMapping>(in);
retval.put(context.callString,result);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr);
boolean valid=false;
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
if (p.containsField(fieldName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(fieldName)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid && !(instr.getFieldType(context.constPool) instanceof ReferenceType)) {
result.put(new Location(context.stackPtr),new ValueMapping());
}
}
break;
case Constants.IASTORE:
case Constants.CASTORE:
case Constants.SASTORE:
case Constants.BASTORE:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - 3) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String name=i.next();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name),new ValueMapping(in.get(l),false));
}
}
}
}
break;
case Constants.AASTORE:
{
filterSet(in,result,context.stackPtr - 3);
}
break;
case Constants.IALOAD:
case Constants.CALOAD:
case Constants.SALOAD:
case Constants.BALOAD:
{
filterSet(in,result,context.stackPtr - 2);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 2);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String name=i.next();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(name)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid) {
result.put(new Location(context.stackPtr - 2),new ValueMapping(0));
}
}
break;
case Constants.AALOAD:
{
filterSet(in,result,context.stackPtr - 2);
}
break;
case Constants.DUP:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
result.put(l,in.get(l));
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.DUP_X1:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr - 2),new ValueMapping(in.get(l),true));
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
if (l.stackLoc == context.stackPtr - 2) {
result.put(new Location(context.stackPtr - 1),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.DUP2:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
result.put(l,in.get(l));
if (l.stackLoc == context.stackPtr - 2) {
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr + 1),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.POP:
{
filterSet(in,result,context.stackPtr - 1);
}
break;
case Constants.POP2:
{
filterSet(in,result,context.stackPtr - 2);
}
break;
case Constants.IINC:
{
IINC instr=(IINC)instruction;
int index=instr.getIndex();
int increment=instr.getIncrement();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr) {
result.put(l,in.get(l));
}
if (l.stackLoc == index) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.add(increment);
m.constrained.add(increment);
Interval operand=new Interval(increment,increment);
if (m.increment != null && !m.softinc) {
m.increment.join(operand);
}
 else if (m.increment != null && m.softinc) {
if ((m.increment.getLb() < 0 && operand.getUb() > 0) || (m.increment.getUb() > 0 && operand.getLb() < 0)) {
m.increment.join(operand);
}
 else {
m.increment=operand;
}
m.softinc=false;
}
 else {
m.increment=operand;
m.softinc=false;
}
result.put(l,m);
}
}
}
break;
case Constants.IADD:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.add(operand);
m.constrained.add(operand);
if (m.increment != null && !m.softinc) {
m.increment.join(operand);
}
 else if (m.increment != null && m.softinc) {
if ((m.increment.getLb() < 0 && operand.getUb() > 0) || (m.increment.getUb() > 0 && operand.getLb() < 0)) {
m.increment.join(operand);
}
 else {
m.increment=operand;
}
m.softinc=false;
}
 else {
m.increment=operand;
m.softinc=false;
}
result.put(l,m);
}
}
}
break;
case Constants.ISUB:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.sub(operand);
m.constrained.sub(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.INEG:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 1) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.neg();
m.constrained.neg();
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.IUSHR:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.ushr(operand);
m.constrained.ushr(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.ISHR:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.shr(operand);
m.constrained.shr(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.IAND:
case Constants.IOR:
case Constants.IXOR:
case Constants.IMUL:
case Constants.IDIV:
case Constants.IREM:
case Constants.ISHL:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping();
result.put(l,m);
}
}
}
break;
case Constants.I2B:
case Constants.I2C:
case Constants.I2S:
result=in;
retval.put(context.callString,result);
break;
case Constants.MONITORENTER:
result=in;
retval.put(context.callString,result);
context.syncLevel++;
break;
case Constants.MONITOREXIT:
result=in;
retval.put(context.callString,result);
context.syncLevel--;
if (context.syncLevel < 0) {
System.err.println("String_Node_Str");
System.exit(-1);
}
break;
case Constants.CHECKCAST:
result=in;
retval.put(context.callString,result);
break;
case Constants.INSTANCEOF:
{
filterSet(in,result,context.stackPtr - 1);
ValueMapping bool=new ValueMapping();
bool.assigned.setLb(0);
bool.assigned.setUb(1);
result.put(new Location(context.stackPtr - 1),bool);
}
break;
case Constants.NEW:
{
result=in;
retval.put(context.callString,result);
}
break;
case Constants.NEWARRAY:
{
NEWARRAY instr=(NEWARRAY)instruction;
String name=instr.getType().toString();
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
filterSet(in,result,context.stackPtr - 1);
boolean valid=false;
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
recordSize(stmt,context,in.get(l).assigned);
valid=true;
}
}
if (!valid) {
ValueMapping v=new ValueMapping();
result.put(new Location(name + "String_Node_Str"),v);
recordSize(stmt,context,v.assigned);
}
}
break;
case Constants.ANEWARRAY:
{
ANEWARRAY instr=(ANEWARRAY)instruction;
String name=instr.getType(context.constPool).toString() + "String_Node_Str";
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
filterSet(in,result,context.stackPtr - 1);
boolean valid=false;
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
recordSize(stmt,context,in.get(l).assigned);
valid=true;
}
}
if (!valid) {
ValueMapping v=new ValueMapping();
result.put(new Location(name + "String_Node_Str"),v);
recordSize(stmt,context,v.assigned);
}
}
break;
case Constants.MULTIANEWARRAY:
{
MULTIANEWARRAY instr=(MULTIANEWARRAY)instruction;
int dim=instr.getDimensions();
filterSet(in,result,context.stackPtr - dim);
String type=instr.getType(context.constPool).toString();
type=type.substring(0,type.indexOf("String_Node_Str"));
Interval[] size=new Interval[dim];
for (int i=1; i <= dim; i++) {
String name=type;
for (int k=0; k < i; k++) {
name+="String_Node_Str";
}
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
boolean valid=false;
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.stackLoc == context.stackPtr - i) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
if (size[i - 1] != null) {
size[i - 1].join(in.get(l).assigned);
}
 else {
size[i - 1]=in.get(l).assigned;
}
valid=true;
}
}
if (!valid) {
ValueMapping v=new ValueMapping();
result.put(new Location(name + "String_Node_Str"),v);
size[i - 1]=v.assigned;
}
}
recordSize(stmt,context,size);
}
break;
case Constants.GOTO:
result=in;
retval.put(context.callString,result);
break;
case Constants.IFNULL:
case Constants.IFNONNULL:
{
checkScope(context,stmt);
filterSet(in,result,context.stackPtr - 1);
}
break;
case Constants.IF_ACMPEQ:
case Constants.IF_ACMPNE:
{
checkScope(context,stmt);
filterSet(in,result,context.stackPtr - 2);
}
break;
case Constants.IFEQ:
case Constants.IFNE:
case Constants.IFLT:
case Constants.IFGE:
case Constants.IFLE:
case Constants.IFGT:
checkScope(context,stmt);
doIf(stmt,edge,context,in,result);
break;
case Constants.IF_ICMPEQ:
case Constants.IF_ICMPNE:
case Constants.IF_ICMPLT:
case Constants.IF_ICMPGE:
case Constants.IF_ICMPGT:
case Constants.IF_ICMPLE:
checkScope(context,stmt);
doIfIcmp(stmt,edge,context,in,result);
break;
case Constants.LOOKUPSWITCH:
case Constants.TABLESWITCH:
result=in;
retval.put(context.callString,result);
break;
case Constants.INVOKEVIRTUAL:
case Constants.INVOKEINTERFACE:
case Constants.INVOKESTATIC:
case Constants.INVOKESPECIAL:
{
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
if (receivers == null) {
System.out.println(context.method + "String_Node_Str" + instruction.toString(context.constPool.getConstantPool())+ "String_Node_Str");
result=in;
break;
}
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String methodName=i.next();
doInvoke(methodName,stmt,context,input,interpreter,state,retval);
}
}
break;
case Constants.ARETURN:
case Constants.RETURN:
{
filterSet(in,result,0);
}
break;
case Constants.IRETURN:
{
filterSet(in,result,0);
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(0),new ValueMapping(in.get(l),false));
}
}
}
break;
default :
result=in;
retval.put(context.callString,result);
break;
}
context.stackPtr+=instruction.produceStack(context.constPool) - instruction.consumeStack(context.constPool);
return retval;
}

Fixed version (ground truth):
public ContextMap<CallString,Map<Location,ValueMapping>> transfer(InstructionHandle stmt,FlowEdge edge,ContextMap<CallString,Map<Location,ValueMapping>> input,Interpreter<CallString,Map<Location,ValueMapping>> interpreter,Map<InstructionHandle,ContextMap<CallString,Map<Location,ValueMapping>>> state){
  Context context=new Context(input.getContext());
  HashMap<Location,ValueMapping> in=(HashMap<Location,ValueMapping>)input.get(context.callString);
  ContextMap<CallString,Map<Location,ValueMapping>> retval=new ContextMap<CallString,Map<Location,ValueMapping>>(context,input);
  HashMap<Location,ValueMapping> result=new HashMap<Location,ValueMapping>();
  retval.put(context.callString,result);
  Instruction instruction=stmt.getInstruction();
switch (instruction.getOpcode()) {
case Constants.ICONST_M1:
case Constants.ICONST_0:
case Constants.ICONST_1:
case Constants.ICONST_2:
case Constants.ICONST_3:
case Constants.ICONST_4:
case Constants.ICONST_5:
case Constants.BIPUSH:
case Constants.SIPUSH:
{
      ConstantPushInstruction instr=(ConstantPushInstruction)instruction;
      result=new HashMap<Location,ValueMapping>(in);
      retval.put(context.callString,result);
      int value=instr.getValue().intValue();
      result.put(new Location(context.stackPtr),new ValueMapping(value));
    }
  break;
case Constants.ACONST_NULL:
result=in;
retval.put(context.callString,result);
break;
case Constants.LDC:
case Constants.LDC_W:
{
LDC instr=(LDC)instruction;
result=new HashMap<Location,ValueMapping>(in);
retval.put(context.callString,result);
Type type=instr.getType(context.constPool);
if (type.equals(Type.INT)) {
Integer value=(Integer)instr.getValue(context.constPool);
result.put(new Location(context.stackPtr),new ValueMapping(value.intValue()));
}
 else if (type.equals(Type.STRING)) {
String value=(String)instr.getValue(context.constPool);
String name="String_Node_Str";
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
result.put(new Location(name + "String_Node_Str"),new ValueMapping(value.length()));
}
}
break;
case Constants.LDC2_W:
result=in;
retval.put(context.callString,result);
break;
case Constants.ISTORE_0:
case Constants.ISTORE_1:
case Constants.ISTORE_2:
case Constants.ISTORE_3:
case Constants.ISTORE:
{
StoreInstruction instr=(StoreInstruction)instruction;
int index=instr.getIndex();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1 && l.stackLoc != index) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
ValueMapping v=new ValueMapping(in.get(l),true);
if (in.get(l).source == null || in.get(l).source.stackLoc != index) {
v.defscope=ValueMapping.scope;
}
result.put(new Location(index),v);
}
}
}
break;
case Constants.ASTORE_0:
case Constants.ASTORE_1:
case Constants.ASTORE_2:
case Constants.ASTORE_3:
case Constants.ASTORE:
result=in;
retval.put(context.callString,result);
break;
case Constants.ILOAD_0:
case Constants.ILOAD_1:
case Constants.ILOAD_2:
case Constants.ILOAD_3:
case Constants.ILOAD:
{
LoadInstruction instr=(LoadInstruction)instruction;
filterSet(in,result,context.stackPtr);
int index=instr.getIndex();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == index) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.source=l;
result.put(new Location(context.stackPtr),m);
}
}
}
break;
case Constants.ALOAD_0:
case Constants.ALOAD_1:
case Constants.ALOAD_2:
case Constants.ALOAD_3:
case Constants.ALOAD:
result=in;
retval.put(context.callString,result);
break;
case Constants.ARRAYLENGTH:
{
filterSet(in,result,context.stackPtr - 1);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 1);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String arrayName=i.next();
ValueMapping m=in.get(new Location(arrayName + "String_Node_Str"));
if (m != null) {
ValueMapping value=new ValueMapping(m,false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
if (!valid) {
result.put(new Location(context.stackPtr - 1),new ValueMapping());
}
}
break;
case Constants.PUTFIELD:
{
PUTFIELD instr=(PUTFIELD)instruction;
int fieldSize=instr.getFieldType(context.constPool).getSize();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - 1 - fieldSize) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
String f=fieldName.substring(fieldName.lastIndexOf("String_Node_Str"),fieldName.length());
String strippedName;
if (fieldName.indexOf("String_Node_Str") >= 0) {
strippedName=fieldName.split("String_Node_Str")[0] + f;
}
 else {
strippedName=fieldName;
}
if (p.containsField(strippedName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(fieldName),new ValueMapping(in.get(l),false));
}
}
}
}
}
break;
case Constants.GETFIELD:
{
GETFIELD instr=(GETFIELD)instruction;
filterSet(in,result,context.stackPtr - 1);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 1);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
String f=fieldName.substring(fieldName.lastIndexOf("String_Node_Str"),fieldName.length());
String strippedName;
if (fieldName.indexOf("String_Node_Str") >= 0) {
strippedName=fieldName.split("String_Node_Str")[0] + f;
}
 else {
strippedName=fieldName;
}
if (p.containsField(strippedName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(fieldName)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
}
if (!valid && !(instr.getFieldType(context.constPool) instanceof ReferenceType)) {
result.put(new Location(context.stackPtr - 1),new ValueMapping());
}
}
break;
case Constants.PUTSTATIC:
{
PUTSTATIC instr=(PUTSTATIC)instruction;
int fieldSize=instr.getFieldType(context.constPool).getSize();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - fieldSize) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
if (p.containsField(fieldName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.stackLoc < 0 && !receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(fieldName),new ValueMapping(in.get(l),false));
}
}
}
}
}
break;
case Constants.GETSTATIC:
{
GETSTATIC instr=(GETSTATIC)instruction;
result=new HashMap<Location,ValueMapping>(in);
retval.put(context.callString,result);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr);
boolean valid=false;
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String fieldName=i.next();
if (p.containsField(fieldName)) {
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(fieldName)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid && !(instr.getFieldType(context.constPool) instanceof ReferenceType)) {
result.put(new Location(context.stackPtr),new ValueMapping());
}
}
break;
case Constants.IASTORE:
case Constants.CASTORE:
case Constants.SASTORE:
case Constants.BASTORE:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc >= 0 && l.stackLoc < context.stackPtr - 3) {
result.put(l,in.get(l));
}
}
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String name=i.next();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (!receivers.containsKey(l.heapLoc)) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name),new ValueMapping(in.get(l),false));
}
}
}
}
break;
case Constants.AASTORE:
{
filterSet(in,result,context.stackPtr - 3);
}
break;
case Constants.IALOAD:
case Constants.CALOAD:
case Constants.SALOAD:
case Constants.BALOAD:
{
filterSet(in,result,context.stackPtr - 2);
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
Location location=new Location(context.stackPtr - 2);
boolean valid=false;
if (receivers != null) {
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String name=i.next();
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.heapLoc.equals(name)) {
ValueMapping value=new ValueMapping(in.get(l),false);
value.join(result.get(location));
result.put(location,value);
valid=true;
}
}
}
}
if (!valid) {
result.put(new Location(context.stackPtr - 2),new ValueMapping(0));
}
}
break;
case Constants.AALOAD:
{
filterSet(in,result,context.stackPtr - 2);
}
break;
case Constants.DUP:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
result.put(l,in.get(l));
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.DUP_X1:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr - 2),new ValueMapping(in.get(l),true));
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
if (l.stackLoc == context.stackPtr - 2) {
result.put(new Location(context.stackPtr - 1),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.DUP2:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
result.put(l,in.get(l));
if (l.stackLoc == context.stackPtr - 2) {
result.put(new Location(context.stackPtr),new ValueMapping(in.get(l),true));
}
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(context.stackPtr + 1),new ValueMapping(in.get(l),true));
}
}
}
break;
case Constants.POP:
{
filterSet(in,result,context.stackPtr - 1);
}
break;
case Constants.POP2:
{
filterSet(in,result,context.stackPtr - 2);
}
break;
case Constants.IINC:
{
IINC instr=(IINC)instruction;
int index=instr.getIndex();
int increment=instr.getIncrement();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr) {
result.put(l,in.get(l));
}
if (l.stackLoc == index) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.add(increment);
m.constrained.add(increment);
Interval operand=new Interval(increment,increment);
if (m.increment != null && !m.softinc) {
m.increment.join(operand);
}
 else if (m.increment != null && m.softinc) {
if ((m.increment.getLb() < 0 && operand.getUb() > 0) || (m.increment.getUb() > 0 && operand.getLb() < 0)) {
m.increment.join(operand);
}
 else {
m.increment=operand;
}
m.softinc=false;
}
 else {
m.increment=operand;
m.softinc=false;
}
result.put(l,m);
}
}
}
break;
case Constants.IADD:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.add(operand);
m.constrained.add(operand);
if (m.increment != null && !m.softinc) {
m.increment.join(operand);
}
 else if (m.increment != null && m.softinc) {
if ((m.increment.getLb() < 0 && operand.getUb() > 0) || (m.increment.getUb() > 0 && operand.getLb() < 0)) {
m.increment.join(operand);
}
 else {
m.increment=operand;
}
m.softinc=false;
}
 else {
m.increment=operand;
m.softinc=false;
}
result.put(l,m);
}
}
}
break;
case Constants.ISUB:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.sub(operand);
m.constrained.sub(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.INEG:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 1) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 1) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.neg();
m.constrained.neg();
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.IUSHR:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.ushr(operand);
m.constrained.ushr(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.ISHR:
{
Interval operand=new Interval();
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
operand=in.get(l).assigned;
}
}
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping(in.get(l),true);
m.assigned.shr(operand);
m.constrained.shr(operand);
m.increment=new Interval();
result.put(l,m);
}
}
}
break;
case Constants.IAND:
case Constants.IOR:
case Constants.IXOR:
case Constants.IMUL:
case Constants.IDIV:
case Constants.IREM:
case Constants.ISHL:
{
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc < context.stackPtr - 2) {
result.put(l,in.get(l));
}
 else if (l.stackLoc == context.stackPtr - 2) {
ValueMapping m=new ValueMapping();
result.put(l,m);
}
}
}
break;
case Constants.I2B:
case Constants.I2C:
case Constants.I2S:
result=in;
retval.put(context.callString,result);
break;
case Constants.MONITORENTER:
result=in;
retval.put(context.callString,result);
context.syncLevel++;
break;
case Constants.MONITOREXIT:
result=in;
retval.put(context.callString,result);
context.syncLevel--;
if (context.syncLevel < 0) {
System.err.println("String_Node_Str");
System.exit(-1);
}
break;
case Constants.CHECKCAST:
result=in;
retval.put(context.callString,result);
break;
case Constants.INSTANCEOF:
{
filterSet(in,result,context.stackPtr - 1);
ValueMapping bool=new ValueMapping();
bool.assigned.setLb(0);
bool.assigned.setUb(1);
result.put(new Location(context.stackPtr - 1),bool);
}
break;
case Constants.NEW:
{
result=in;
retval.put(context.callString,result);
}
break;
case Constants.NEWARRAY:
{
NEWARRAY instr=(NEWARRAY)instruction;
String name=instr.getType().toString();
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
filterSet(in,result,context.stackPtr - 1);
boolean valid=false;
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
recordSize(stmt,context,in.get(l).assigned);
valid=true;
}
}
if (!valid) {
ValueMapping v=new ValueMapping();
result.put(new Location(name + "String_Node_Str"),v);
recordSize(stmt,context,v.assigned);
}
}
break;
case Constants.ANEWARRAY:
{
ANEWARRAY instr=(ANEWARRAY)instruction;
String name=instr.getType(context.constPool).toString() + "String_Node_Str";
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
filterSet(in,result,context.stackPtr - 1);
boolean valid=false;
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
recordSize(stmt,context,in.get(l).assigned);
valid=true;
}
}
if (!valid) {
ValueMapping v=new ValueMapping();
result.put(new Location(name + "String_Node_Str"),v);
recordSize(stmt,context,v.assigned);
}
}
break;
case Constants.MULTIANEWARRAY:
{
MULTIANEWARRAY instr=(MULTIANEWARRAY)instruction;
int dim=instr.getDimensions();
filterSet(in,result,context.stackPtr - dim);
String type=instr.getType(context.constPool).toString();
type=type.substring(0,type.indexOf("String_Node_Str"));
Interval[] size=new Interval[dim];
for (int i=1; i <= dim; i++) {
String name=type;
for (int k=0; k < i; k++) {
name+="String_Node_Str";
}
name+="String_Node_Str" + context.method + "String_Node_Str"+ stmt.getPosition();
boolean valid=false;
for (Iterator<Location> k=in.keySet().iterator(); k.hasNext(); ) {
Location l=k.next();
if (l.stackLoc == context.stackPtr - i) {
result.put(new Location(name + "String_Node_Str"),in.get(l));
if (size[i - 1] != null) {
size[i - 1].join(in.get(l).assigned);
}
 else {
size[i - 1]=in.get(l).assigned;
}
valid=true;
}
}
if (!valid) {
ValueMapping v=new ValueMapping();
result.put(new Location(name + "String_Node_Str"),v);
size[i - 1]=v.assigned;
}
}
recordSize(stmt,context,size);
}
break;
case Constants.GOTO:
result=in;
retval.put(context.callString,result);
break;
case Constants.IFNULL:
case Constants.IFNONNULL:
{
checkScope(context,stmt);
filterSet(in,result,context.stackPtr - 1);
}
break;
case Constants.IF_ACMPEQ:
case Constants.IF_ACMPNE:
{
checkScope(context,stmt);
filterSet(in,result,context.stackPtr - 2);
}
break;
case Constants.IFEQ:
case Constants.IFNE:
case Constants.IFLT:
case Constants.IFGE:
case Constants.IFLE:
case Constants.IFGT:
checkScope(context,stmt);
doIf(stmt,edge,context,in,result);
break;
case Constants.IF_ICMPEQ:
case Constants.IF_ICMPNE:
case Constants.IF_ICMPLT:
case Constants.IF_ICMPGE:
case Constants.IF_ICMPGT:
case Constants.IF_ICMPLE:
checkScope(context,stmt);
doIfIcmp(stmt,edge,context,in,result);
break;
case Constants.LOOKUPSWITCH:
case Constants.TABLESWITCH:
result=in;
retval.put(context.callString,result);
break;
case Constants.INVOKEVIRTUAL:
case Constants.INVOKEINTERFACE:
case Constants.INVOKESTATIC:
case Constants.INVOKESPECIAL:
{
DFAAppInfo p=interpreter.getProgram();
ContextMap<String,String> receivers=p.getReceivers().get(stmt);
if (receivers == null) {
System.out.println(context.method + "String_Node_Str" + instruction.toString(context.constPool.getConstantPool())+ "String_Node_Str");
result=in;
break;
}
for (Iterator<String> i=receivers.keySet().iterator(); i.hasNext(); ) {
String methodName=i.next();
doInvoke(methodName,stmt,context,input,interpreter,state,retval);
}
}
break;
case Constants.ARETURN:
case Constants.RETURN:
{
filterSet(in,result,0);
}
break;
case Constants.IRETURN:
{
filterSet(in,result,0);
for (Iterator<Location> i=in.keySet().iterator(); i.hasNext(); ) {
Location l=i.next();
if (l.stackLoc == context.stackPtr - 1) {
result.put(new Location(0),new ValueMapping(in.get(l),false));
}
}
}
break;
default :
result=in;
retval.put(context.callString,result);
break;
}
context.stackPtr+=instruction.produceStack(context.constPool) - instruction.consumeStack(context.constPool);
return retval;
}