Create a class definition
@param s The serializable
@param clz The class
@return The definition
977638
public static ClassDefinition createClassDefinition(Serializable s, Class<?> clz)
   {
      if (s == null || clz == null)
         return null;

      String name = clz.getName();
      long serialVersionUID = 0L;
      byte[] data = null;

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      InputStream is = null;
      try
      {
         try
         {
            Field svuf = getSerialVersionUID(clz);
            if (svuf != null)
               serialVersionUID = (long)svuf.get(s);
         }
         catch (Throwable t)
         {
            // No serialVersionUID value
         }

         String clzName = name.replace('.', '/') + ".class";

         is = SecurityActions.getClassLoader(s.getClass()).getResourceAsStream(clzName);
         int i = is.read();
         while (i != -1)
         {
            baos.write(i);
            i = is.read();
         }

         data = baos.toByteArray();

         return new ClassDefinition(name, serialVersionUID, data);
      }
      catch (Throwable t)
      {
         // Ignore
      }
      finally
      {
         if (is != null)
         {
            try
            {
               is.close();
            }
            catch (IOException ioe)
            {
               // Ignore
            }
         }
      }
      return null;
   }
343431
public static <T> T newInstance(final Class<T> clazz) {
        try {
            return clazz.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new ClassApiException(e);
        }
    }
95727
public static <T extends JsonBuilder> T create(Class<T> clz, String payload) {
    T ret = create(clz);
    ret.load(payload);
    return ret;
  }
1028176
private static Class<?>[] getFields(Class<?> clz)
   {
      List<Class<?>> result = new ArrayList<Class<?>>();

      Class<?> c = clz;
      while (!c.equals(Object.class))
      {
         try
         {
            Field[] fields = SecurityActions.getDeclaredFields(c);
            if (fields.length > 0)
            {
               for (Field f : fields)
               {
                  Class<?> defClz = f.getType();
                  String defClzName = defClz.getName();

                  if (!defClz.isPrimitive() && !defClz.isArray() && 
                      !defClzName.startsWith("java") && !defClzName.startsWith("javax") && !result.contains(defClz))
                  {
                     if (trace)
                        log.tracef("Adding field: %s", defClzName);
                     
                     result.add(defClz);
                  }
               }
            }
         }
         catch (Throwable t)
         {
            // Ignore
         }

         c = c.getSuperclass();
      }

      return result.toArray(new Class<?>[result.size()]);
   }
617241
public <T extends InteractionAwareFixture> T create(Class<T> clazz) {
        return create(clazz, null, null);
    }
463732
public static Class loadClass(ClassLoader cl, String className) throws ClassException {

	Set<Throwable> exceptions = new HashSet<Throwable>();
	Class clazz = loadClass(cl, className, null, exceptions);

	if (clazz != null) return clazz;

	String msg = "cannot load class through its string name, because no definition for the class with the specified name [" + className + "] could be found";

	if (!exceptions.isEmpty()) {

	    StringBuilder detail = new StringBuilder();
	    Iterator<Throwable> it = exceptions.iterator();
	    Throwable t;
	    while (it.hasNext()) {
		t = it.next();
		detail.append(t.getClass().getName()).append(':').append(t.getMessage()).append(';');
	    }
	    throw new ClassException(msg + " caused by (" + detail.toString() + ")");
	}
	throw new ClassException(msg);
    }
1161306
public static AnnotationInfo.Builder createAnnotation(Class<? extends Annotation> clazz) {
        return AnnotationInfo.builder(valueFormatter).name(clazz);
    }
1080813
public <T extends Entity<ID>, ID extends Serializable> T newInstance(final Class<T> clazz, final ID id) {
    EntityType type = getEntityType(clazz);
    @SuppressWarnings("unchecked")
    T entity = (T) type.newInstance();
    try {
      PropertyUtils.setProperty(entity, type.getIdName(), id);
    } catch (Exception e) {
      logger.error("initialize {} with id {} error", clazz, id);
    }
    return entity;
  }
174107
public static <T> T newInstance(final Class<T> klazz) {
    try {
      return klazz.getConstructor().newInstance();
    } catch (Exception ex) {
      throw new Error(String.format("Can't create instance of %s for error %s", klazz.getCanonicalName(), ex.getMessage()), ex);
    }
  }
248935
public static Class toArrayClass(Class clazz) {
	return java.lang.reflect.Array.newInstance(clazz, 0).getClass();
    }
1159018
private static void appendDescriptor(final StringBuilder stringBuilder, final Class<?> clazz) {
    Class<?> currentClass = clazz;
    while (currentClass.isArray()) {
      stringBuilder.append('[');
      currentClass = currentClass.getComponentType();
    }
    if (currentClass.isPrimitive()) {
      char descriptor;
      if (currentClass == Integer.TYPE) {
        descriptor = 'I';
      } else if (currentClass == Void.TYPE) {
        descriptor = 'V';
      } else if (currentClass == Boolean.TYPE) {
        descriptor = 'Z';
      } else if (currentClass == Byte.TYPE) {
        descriptor = 'B';
      } else if (currentClass == Character.TYPE) {
        descriptor = 'C';
      } else if (currentClass == Short.TYPE) {
        descriptor = 'S';
      } else if (currentClass == Double.TYPE) {
        descriptor = 'D';
      } else if (currentClass == Float.TYPE) {
        descriptor = 'F';
      } else if (currentClass == Long.TYPE) {
        descriptor = 'J';
      } else {
        throw new AssertionError();
      }
      stringBuilder.append(descriptor);
    } else {
      stringBuilder.append('L');
      String name = currentClass.getName();
      int nameLength = name.length();
      for (int i = 0; i < nameLength; ++i) {
        char car = name.charAt(i);
        stringBuilder.append(car == '.' ? '/' : car);
      }
      stringBuilder.append(';');
    }
  }
936937
public <T extends AbstractJaxb> void addCssClass(String clazz) {
        List<String> classList = this.getCssClass();
        if (!this.hasCssClass(clazz)) {
            classList.add(clazz);
        }
    }
600349
public static <T extends Serializable> T newSerializableInstance(Class<T> clazz) {
      return OBJENESIS_SERIALIZER.newInstance(clazz);
   }
694716
public static <T> T newInstance(Class<T> clazz) throws ClassInstantiationException {
        if (clazz == null) {
            return null;
        }

        try {
            return clazz.newInstance();
        } catch (Exception e) {
            throw new ClassInstantiationException("Failed to instantiate class: " + clazz.getName(), e);
        }
    }
1060777
@SuppressWarnings("unchecked")
    public <P> P createBean(final Class<P> clazz) {
        return (P) beanFactory.create(clazz);
    }
1060241
public static Class<?>[] getAllSuperClasses(Class<?> clz) {
    List<Class<?>> list = new ArrayList<>();
    while ((clz = clz.getSuperclass()) != null) {
      list.add(clz);
    }
    return list.toArray(new Class<?>[list.size()]);
  }
964830
protected final Definition bean(Class<?> clazz) {
    Definition def = new Definition(clazz.getName(), clazz, Scope.SINGLETON.toString());
    def.beanName = clazz.getName() + "#" + Math.abs(System.identityHashCode(def));
    return def;
  }