Package gov.nasa.jpf.vm

Examples of gov.nasa.jpf.vm.FieldInfo


        boolean isStatic = ((Modifier.toString(fld[i].getModifiers())).indexOf("static") != -1);
        boolean isFinal = ((Modifier.toString(fld[i].getModifiers())).indexOf("final") != -1);

        // Provide access to private and final fields
        fld[i].setAccessible(true);
        FieldInfo fi = sei.getFieldInfo(fld[i].getName());

        // For class only set the values of static fields
        if (fi != null && isStatic) {
          /**
           * Why we check for !(isFinal)?
           *
           * We do not set the value for "static final" fields. But we take
           * care of "non-static final" fields.
           *
           * static final fields can be initialized at the declaration time,
           * OW it MUST be initialized inside the static block. By using
           * Class.forName() the class is initialized. Since when the class
           * is initialized the static blocks are executed, the static final
           * fields of object returned by Class.forName() have already have
           * the right values and we do not need to update their value.
           *
           * Non-static final fields can be initialized at the declaration
           * time. But if the non-static field is final blank, it MUST be
           * initialized in the constructor. By using Class.newInstance()
           * the class is instantiated as if by a new expression with an
           * empty argument list. If the object represented by JPFRef
           * created using different constructor, the value of final blank
           * fields might be different when using the constructor with an
           * empty argument list. Therefore the values of non-static final
           * fields have to be set.
           */
          if (!isFinal) {
            // If the current field is of reference type
            if (fi.isReference()) {
              int fieldValueRef = sei.getFields().getReferenceValue(fi.getStorageOffset());
              Object JVMField = obtainJVMObj(fieldValueRef, env);
              try {
                fld[i].set(null, JVMField);
              } catch (IllegalArgumentException e) {
                e.printStackTrace();
View Full Code Here


        // It is true if the field is declared as static.
        boolean isNonStaticField = ((Modifier.toString(fld[i].getModifiers())).indexOf("static") == -1);

        // Provide access to private and final fields
        fld[i].setAccessible(true);
        FieldInfo fi = JPFCl.getInstanceField(fld[i].getName());

        if (fi != null && isNonStaticField) {
          // Field is of reference type
          if (fi.isReference()) {
            int fieldValueRef = dei.getFields().getReferenceValue(fi.getStorageOffset());
            Object JVMField = obtainJVMObj(fieldValueRef, env);

            try {
              fld[i].set(JVMObj, JVMField);
            } catch (IllegalArgumentException e) {
View Full Code Here

    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());

    // this is String.value which is of type of char[]
    Object value = this.getJVMObj(fieldValueRef, env);
    Object JVMObj = new String((char[])value);
    ConverterBase.objMapJPF2JVM.put(JPFRef, JVMObj);
View Full Code Here

      boolean isStatic = ((Modifier.toString(fld[i].getModifiers())).indexOf("static") != -1);
      boolean isFinal = ((Modifier.toString(fld[i].getModifiers())).indexOf("final") != -1);

      // Provide access to private and final fields
      fld[i].setAccessible(true);
      FieldInfo fi = sei.getFieldInfo(fld[i].getName());

      // Provide access to private and final fields
      if (fi != null){
        if (isStatic && !isFinal){
          // If the current field is of reference type
          if (fi.isReference()){
            int JPFfldValue = MJIEnv.NULL;
            Object JVMfldValue = null;

            try{
              // retrieving the value of the field in JVM
              JVMfldValue = fld[i].get(JVMCls);
            } catch (IllegalAccessException e2){
              e2.printStackTrace();
            }

            JPFfldValue = sei.getReferenceField(fi);

            if (JVMfldValue == null){
              JPFfldValue = MJIEnv.NULL;
            } else if (JPFfldValue == MJIEnv.NULL || ConverterBase.objMapJPF2JVM.get(JPFfldValue) != JVMfldValue){
              JPFfldValue = obtainJPFObj(JVMfldValue, env);
            } else if (ConverterBase.objMapJPF2JVM.get(JPFfldValue) == JVMfldValue){
              updateJPFObj(JVMfldValue, JPFfldValue, env);
            } else{
              throw new ConversionException("Unconsidered case observed! - JVM2JPF.getJPFCls()");
            }
            sei.setReferenceField(fi, JPFfldValue);
          }
          // If the current field is of primitive type
          else{
            try{
              Utilities.setJPFPrimitiveField(sei, fi.getStorageOffset(), fld[i], JVMCls);
            } catch (IllegalAccessException e){
              e.printStackTrace();
            }
          }
        }
View Full Code Here

      Field fld[] = JVMCl.getDeclaredFields();

      for (int i = 0; i < fld.length; i++){
        // Check if the field is declared as non-static
        boolean isNonStaticField = ((Modifier.toString(fld[i].getModifiers())).indexOf("static") == -1);
        FieldInfo fi = JPFCl.getInstanceField(fld[i].getName());
        fld[i].setAccessible(true);

        if (fi != null && isNonStaticField){
          // If the current field is of reference type
          if (fi.isReference()){
            int JPFfldValue = MJIEnv.NULL;
            Object JVMfldValue = null;

            try{
              // retrieving the value of the field in JVM
              JVMfldValue = fld[i].get(JVMObj);
            } catch (IllegalAccessException e2){
              e2.printStackTrace();
            }

            JPFfldValue = dei.getReferenceField(fi);

            if (JVMfldValue == null){
              JPFfldValue = MJIEnv.NULL;
            } else if (JPFfldValue == MJIEnv.NULL || ConverterBase.objMapJPF2JVM.get(JPFfldValue) != JVMfldValue){
              JPFfldValue = obtainJPFObj(JVMfldValue, env);
            } else if (ConverterBase.objMapJPF2JVM.get(JPFfldValue) == JVMfldValue){
              updateJPFObj(JVMfldValue, JPFfldValue, env);
            } else{
              throw new ConversionException("Unconsidered case observed! - JVM2JPF.updateObj()");
            }
            dei.setReferenceField(fi, JPFfldValue);
          }
          // If the current field is of primitive type
          else{
            try{
              Utilities.setJPFPrimitiveField(dei, fi.getStorageOffset(), fld[i], JVMObj);
            } catch (IllegalAccessException e){
              e.printStackTrace();
            }
          }
        }
View Full Code Here

TOP

Related Classes of gov.nasa.jpf.vm.FieldInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.