// returns null if we don't have anything free
 private static synchronized Class getFreeVMImplClass() {
   while (!freeVMClasses.isEmpty()) {
     SoftReference ref = (SoftReference) freeVMClasses.remove(0);
     Object o = ref.get();
     if (o != null) {
       if (DEBUG) {
         System.out.println("re-using loaded VirtualMachineImpl");
       }
       return (Class) o;
     }
   }
   return null;
 }
Example #2
0
 private ObjectMapper mapper() {
   if (mapperRef == null) {
     mapperRef = new SoftReference<ObjectMapper>(new ObjectMapper());
   }
   ObjectMapper mapper = mapperRef.get();
   if (mapper == null) {
     mapper = new ObjectMapper();
     mapperRef = new SoftReference<ObjectMapper>(mapper);
   }
   return mapper;
 }