public static Expression initializeStaticField( FieldInfo staticField, ClassInfo ci, ThreadInfo ti, String suffix) { Expression sym_v = null; String name = ""; name = staticField.getName(); String fullName = ci.getName() + "." + name + suffix; // + "_init"; if (staticField instanceof IntegerFieldInfo || staticField instanceof LongFieldInfo) { sym_v = new SymbolicInteger(fullName); } else if (staticField instanceof FloatFieldInfo || staticField instanceof DoubleFieldInfo) { sym_v = new SymbolicReal(fullName); } else if (staticField instanceof ReferenceFieldInfo) { if (staticField.getType().equals("java.lang.String")) sym_v = new StringSymbolic(fullName); else sym_v = new SymbolicInteger(fullName); } else if (staticField instanceof BooleanFieldInfo) { // treat boolean as an integer with range [0,1] sym_v = new SymbolicInteger(fullName, 0, 1); } StaticElementInfo sei = ci.getModifiableStaticElementInfo(); if (sei == null) { ci.registerClass(ti); sei = ci.getStaticElementInfo(); } if (sei.getFieldAttr(staticField) == null) { sei.setFieldAttr(staticField, sym_v); } return sym_v; }
public static Expression initializeInstanceField( FieldInfo field, ElementInfo eiRef, String refChain, String suffix) { Expression sym_v = null; String name = ""; name = field.getName(); String fullName = refChain + "." + name + suffix; if (field instanceof IntegerFieldInfo || field instanceof LongFieldInfo) { sym_v = new SymbolicInteger(fullName); } else if (field instanceof FloatFieldInfo || field instanceof DoubleFieldInfo) { sym_v = new SymbolicReal(fullName); } else if (field instanceof ReferenceFieldInfo) { if (field.getType().equals("java.lang.String")) sym_v = new StringSymbolic(fullName); else sym_v = new SymbolicInteger(fullName); } else if (field instanceof BooleanFieldInfo) { // treat boolean as an integer with range [0,1] sym_v = new SymbolicInteger(fullName, 0, 1); } eiRef.setFieldAttr(field, sym_v); return sym_v; }
protected Object createStringObject(int JPFRef, MJIEnv env, FeatureExpr ctx) throws ConversionException { DynamicElementInfo str = (DynamicElementInfo) env.getHeap().get(JPFRef); if (!str.getClassInfo().isStringClassInfo()) { throw new ConversionException(); } FieldInfo fi = str.getFieldInfo("value"); int fieldValueRef = str.getFields().getReferenceValue(fi.getStorageOffset()).getValue(); // this is String.value which is of type of char[] Object value = this.getJVMObj(fieldValueRef, env, ctx); // In case that value is of the type One Object JVMObj; if (value instanceof Conditional) JVMObj = new String((char[]) ((Conditional<?>) value).simplify(ctx).getValue()); else { System.out.println("Warning from JPF2JVMConverter.java L244, JVMObj is not One"); JVMObj = new String((char[]) value); } ConverterBase.objMapJPF2JVM.put(JPFRef, JVMObj); return JVMObj; }