Пример #1
0
  protected static final ObjectContainer openMemoryFile1(MemoryFile memoryFile) {
    synchronized (Db4o.lock) {
      if (memoryFile == null) {
        memoryFile = new MemoryFile();
      }
      ObjectContainer oc = null;
      if (Deploy.debug) {
        System.out.println("db4o Debug is ON");
        oc = new YapMemoryFile(memoryFile);

        // intentionally no exception handling,
        // in order to follow uncaught errors
      } else {
        try {
          oc = new YapMemoryFile(memoryFile);
        } catch (Throwable t) {
          Messages.logErr(i_config, 4, "Memory File", t);
          return null;
        }
      }
      if (oc != null) {
        Platform4.postOpen(oc);
        Messages.logMsg(i_config, 5, "Memory File");
      }
      return oc;
    }
  }
 private byte[] readName(LatinStringIO sio, ByteArrayBuffer reader) {
   if (Deploy.debug) {
     reader.readBegin(Const4.YAPCLASS);
   }
   int len = reader.readInt();
   len = len * sio.bytesPerChar();
   byte[] nameBytes = new byte[len];
   System.arraycopy(reader._buffer, reader._offset, nameBytes, 0, len);
   nameBytes = Platform4.updateClassName(nameBytes);
   reader.incrementOffset(len);
   return nameBytes;
 }
Пример #3
0
 protected void setSodaTestOn(STClass[] classes) {
   for (int i = 0; i < classes.length; i++) {
     try {
       Field field = classes[i].getClass().getDeclaredField("st");
       try {
         Platform4.setAccessible(field);
       } catch (Throwable t) {
         // JDK 1.x has no setAccessible
       }
       field.set(classes[i], this);
     } catch (Exception e) {
       System.err.println("Add the following line to Class " + classes[i].getClass().getName());
       System.err.println("public static transient SodaTest st;");
     }
   }
 }
Пример #4
0
  /**
   * Search for slot that corresponds to class. <br>
   * If not found add it. <br>
   * Constrain it. <br>
   */
  public Constraint constrain(Object example) {
    synchronized (streamLock()) {
      ReflectClass claxx = reflectClassForClass(example);
      if (claxx != null) {
        return addClassConstraint(claxx);
      }

      QConEvaluation eval = Platform4.evaluationCreate(_trans, example);
      if (eval != null) {
        return addEvaluationToAllConstraints(eval);
      }

      Collection4 constraints = new Collection4();
      addConstraint(constraints, example);
      return toConstraint(constraints);
    }
  }
  public static ReflectConstructorSpec createConstructor(
      final ConstructorAwareReflectClass claxx,
      Class clazz,
      ReflectorConfiguration config,
      ReflectConstructor[] constructors) {

    if (claxx == null) {
      return ReflectConstructorSpec.INVALID_CONSTRUCTOR;
    }

    if (claxx.isAbstract() || claxx.isInterface()) {
      return ReflectConstructorSpec.INVALID_CONSTRUCTOR;
    }

    if (!Platform4.callConstructor()) {
      boolean skipConstructor = !config.callConstructor(claxx);
      if (!claxx.isCollection()) {
        ReflectConstructor serializableConstructor =
            skipConstructor(claxx, skipConstructor, config.testConstructors());
        if (serializableConstructor != null) {
          return new ReflectConstructorSpec(serializableConstructor, null);
        }
      }
    }

    if (!config.testConstructors()) {
      return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null);
    }

    if (ReflectPlatform.createInstance(clazz) != null) {
      return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null);
    }

    Tree sortedConstructors = sortConstructorsByParamsCount(constructors);
    return findConstructor(claxx, sortedConstructors);
  }
Пример #6
0
 private static final Object initialize() {
   Platform4.getDefaultConfiguration(i_config);
   return new Object();
 }
Пример #7
0
 protected static boolean jdkOK(Object obj) {
   return Platform4.jdk().ver() >= 2 || STClass1.class.isAssignableFrom(obj.getClass());
 }