/** * Create and return a new primitive variable * * @param test * @param position * @param recursionDepth * @return * @throws ConstructionFailedException */ private VariableReference createPrimitive(TestCase test, GenericClass clazz, int position, int recursionDepth) throws ConstructionFailedException { // Special case: we cannot instantiate Class<Class<?>> if (clazz.isClass()) { if (clazz.hasWildcardOrTypeVariables()) { logger.debug("Getting generic instantiation of class"); clazz = clazz.getGenericInstantiation(); logger.debug("Chosen: " + clazz); } Type parameterType = clazz.getParameterTypes().get(0); if (!(parameterType instanceof WildcardType) && GenericTypeReflector.erase(parameterType).equals(Class.class)) { throw new ConstructionFailedException( "Cannot instantiate a class with a class"); } } Statement st = PrimitiveStatement.getRandomStatement(test, clazz, position); VariableReference ret = test.addStatement(st, position); ret.setDistance(recursionDepth); return ret; }