Beispiel #1
0
  /**
   * Returns a new JVM Class object corresponding to the given JPF class. If such a Class object
   * already exists, it is returned. Otherwise a new one is created.
   */
  protected Class<?> getJVMCls(int JPFRef, MJIEnv env, FeatureExpr ctx) throws ConversionException {
    Class<?> JVMCls = null;
    if (JPFRef != MJIEnv.NULL) {
      // First check if the class object has been already created.
      JVMCls = ConverterBase.classMapJPF2JVM.get(JPFRef);

      /**
       * If the Class object has not been created & the given JPF class is not NULL, the
       * corresponding JVM class object is created from JPFRef
       */
      if (JVMCls == null) {
        ClassInfo ci = env.getReferredClassInfo(ctx, JPFRef);

        // Used to store static fields
        StaticElementInfo sei = ci.getStaticElementInfo();

        try {
          JVMCls = loadClass(sei.getClassInfo().getName(), env, ctx);
          ConverterBase.classMapJPF2JVM.put(JPFRef, JVMCls);
        } catch (ClassNotFoundException e) {
          throw new NoClassDefFoundError(sei.getClassInfo().getName());
        }

        assert (JVMCls.getName() != ci.getName());

        setStaticFields(JVMCls, sei, env, ctx);
      }
    }
    return JVMCls;
  }