creates an instance of testType (if it isn't Object.class or null) or fallbackType
198280
private <T> T newInstance(final Constructor<T> tryMe, final Class<T> fallbackType) {
        if (tryMe != null) {
            tryMe.setAccessible(true);
            try {
                return tryMe.newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return createInstance(fallbackType);
    }
66716
private static <T> T createInstance(Constructor<T> constructor, Object... arguments) throws Exception {
        if (constructor == null) {
            throw new IllegalArgumentException("Constructor cannot be null");
        }
        constructor.setAccessible(true);

        T createdObject = null;
        try {
            if (constructor.isVarArgs()) {
                Class<?>[] parameterTypes = constructor.getParameterTypes();
                final int varArgsIndex = parameterTypes.length - 1;
                Class<?> varArgsType = parameterTypes[varArgsIndex].getComponentType();
                Object varArgsArrayInstance = createAndPopulateVarArgsArray(varArgsType, varArgsIndex, arguments);
                Object[] completeArgumentList = new Object[parameterTypes.length];
                System.arraycopy(arguments, 0, completeArgumentList, 0, varArgsIndex);
                completeArgumentList[completeArgumentList.length - 1] = varArgsArrayInstance;
                createdObject = constructor.newInstance(completeArgumentList);
            } else {
                createdObject = constructor.newInstance(arguments);
            }
        } catch (InvocationTargetException e) {
            Throwable cause = e.getCause();
            if (cause instanceof Exception) {
                throw (Exception) cause;
            } else if (cause instanceof Error) {
                throw (Error) cause;
            }
        }
        return createdObject;
    }
197579
def new_eventtype(self, test_type_str=None):
        """"""
        if self.annot is None:  # remove if buttons are disabled
            self.parent.statusBar().showMessage('No score file loaded')
            return

        if test_type_str:
            answer = test_type_str, True
        else:
            answer = QInputDialog.getText(self, 'New Event Type',
                                          'Enter new event\'s name')
        if answer[1]:
            self.annot.add_event_type(answer[0])
            self.display_eventtype()
            n_eventtype = self.idx_eventtype.count()
            self.idx_eventtype.setCurrentIndex(n_eventtype - 1)
            
        return answer
755168
@Override
    public Object createExample() {
        AnnotationDto result = new AnnotationDto();
        Map<String, String> sampleFields = new HashMap<>();

        fields.put("fieldName", "fieldValue");
        result.setFields(sampleFields);
        result.setId("datasourceSpecificUniqueID");
        result.setMetric("metric");
        result.setScope("scope");
        result.setSource("splunk");

        Map<String, String> sampleTags = new HashMap<>();

        sampleTags.put("tagk", "tagv");
        result.setTags(sampleTags);
        result.setTimestamp(System.currentTimeMillis());
        result.setType("erelease");
        return result;
    }
1001539
def initChild(cls, obj, name, subContext, parent = None):
    """"""
    addr = statsId(obj)
    if addr not in cls.containerMap:
      if not parent:
        # Find out the parent of the calling object by going back through the call stack until a self != this.
        f = inspect.currentframe()
        while not cls.__getSelf(f):
          f = f.f_back
        this = cls.__getSelf(f)
        f = f.f_back
        while cls.__getSelf(f) == this or not cls.__getSelf(f):
          f = f.f_back
        parent = cls.__getSelf(f)

      # Default subcontext to an autoincrementing ID.
      if subContext is None:
        cls.subId += 1
        subContext = cls.subId

      if subContext is not '':
        path = '%s/%s' % (name, subContext)
      else:
        path = name

      # Now that we have the name, create an entry for this object.
      cls.parentMap[addr] = parent
      container = cls.getContainerForObject(statsId(parent))
      if not container and isinstance(parent, unittest.TestCase):
        cls.init(parent, '/test-case')
      cls.containerMap[addr] = cls.__getStatContainer(path, cls.getContainerForObject(statsId(parent)))
    return cls.containerMap[addr]
248105
@Nullable
  private static ObjectType getSuperClassInstanceIfFinal(@Nullable JSType type) {
    if (type == null) {
      return null;
    }

    ObjectType obj = type.toObjectType();
    FunctionType ctor = (obj == null) ? null : obj.getSuperClassConstructor();
    JSDocInfo doc = (ctor == null) ? null : ctor.getJSDocInfo();
    if (doc != null && doc.isFinal()) {
      return ctor.getInstanceType();
    }

    return null;
  }
276328
function ObjectInstance(
      parent, id, category, name, creationTs, opt_baseTypeName) {
    tr.model.Event.call(this);
    this.parent = parent;
    this.id = id;
    this.category = category;
    this.baseTypeName = opt_baseTypeName ? opt_baseTypeName : name;
    this.name = name;
    this.creationTs = creationTs;
    this.creationTsWasExplicit = false;
    this.deletionTs = Number.MAX_VALUE;
    this.deletionTsWasExplicit = false;
    this.colorId = 0;
    this.bounds = new tr.b.Range();
    this.snapshots = [];
    this.hasImplicitSnapshots = false;
  }
1246403
function createCombi (types, options) {
    var tests = types.map(function (type) {
      return ducktype(type).test;
    });

    return new DuckType({
      name: options && options.name || null,
      test: function test (object) {
        for (var i = 0, ii = tests.length; i < ii; i++) {
          if (tests[i](object)) {
            return true;
          }
        }
        return false;
      }
    });
  }
543194
function () {
                    var args = [];
                    for (var _i = 0; _i < arguments.length; _i++) {
                        args[_i] = arguments[_i];
                    }
                    this.testCategory = name;
                    return construct(original, args);
                }
543695
private MetaHolder createCopy(MetaHolder source, ExecutionType executionType) {
        return MetaHolder.builder()
                .obj(source.getObj())
                .method(source.getMethod())
                .ajcMethod(source.getAjcMethod())
                .fallbackExecutionType(source.getFallbackExecutionType())
                .extendedFallback(source.isExtendedFallback())
                .extendedParentFallback(source.isExtendedParentFallback())
                .executionType(executionType)
                .args(source.getArgs())
                .observable(source.isObservable())
                .observableExecutionMode(source.getObservableExecutionMode())
                .defaultCollapserKey(source.getDefaultCollapserKey())
                .defaultCommandKey(source.getDefaultCommandKey())
                .defaultGroupKey(source.getDefaultGroupKey())
                .defaultThreadPoolKey(source.getDefaultThreadPoolKey())
                .defaultProperties(source.getDefaultProperties().orNull())
                .hystrixCollapser(source.getHystrixCollapser())
                .hystrixCommand(source.getHystrixCommand()).build();
    }
1207850
static JSType createType(boolean shouldCreate, JSTypeRegistry registry, JSTypeNative typeName) {
    if (!shouldCreate) {
      return null;
    }
    return registry.getNativeType(typeName);
  }
806421
@Override
    public Object createExample() {
        MetricDto result = new MetricDto();
        Map<Long, Double> dps = new TreeMap<>();

        dps.put(System.currentTimeMillis(), 1.2);
        result.setDatapoints(dps);
        result.setDisplayName("A description of the metric");
        result.setMetric("metric");
        result.setScope("scope");

        Map<String, String> sampleTags = new HashMap<>();

        sampleTags.put("tagk", "tagv");
        result.setTags(sampleTags);
        result.setUnits("ms");
        return result;
    }
1304112
def assertinstance(obj, types):
    
    if isinstance(obj, types):
        return obj
    raise TypeError('{} must be instance of {}'.format(obj, types))
525628
function createPrototype (type, options) {
    return new DuckType({
      name: options && options.name || null,
      test: function test (object) {
        return (object instanceof type);
      }
    });
  }
219971
@Override
  public <V> MethodVault<V> newMethod(Class<?> type, 
                                      String methodName,
                                      Class<?> []paramTypes)
  {
    Objects.requireNonNull(type);
    
    MethodVault<V> method = newMethodRec(type, methodName, paramTypes);

    if (method != null) {
      return method;
    }
    
    throw new IllegalStateException(L.l("Unknown method {0}.{1} {2}",
                                        type.getSimpleName(),
                                        methodName,
                                        Arrays.asList(paramTypes)));
  }
777037
public static void initialize(Object backend,
            BackendInstanceSpec backendInstanceSpec)  {
        assert backend != null : "backend cannot be null";
        assert backendInstanceSpec != null :
            "backendInstanceSpec cannot be null";
        for (Method method : backend.getClass().getMethods()) {
            if (method.isAnnotationPresent(BackendProperty.class)) {
                try {
                    BackendProperty annotation =
                            method.getAnnotation(BackendProperty.class);
                    String propertyName = propertyName(annotation, method);
                    Object propertyValue =
                            backendInstanceSpec.getProperty(propertyName);
                    if (propertyValue != null) {
                            method.invoke(backend,
                                    new Object[]{propertyValue
                                });
                    }
                } catch (IllegalAccessException | InvalidPropertyNameException | InvocationTargetException ex) {
                    throw new AssertionError(ex);
                }
            }
        }
    }
382426
@SuppressWarnings("rawtypes")
	public static Object instantiate(Class<?> type) throws Exception {
		if (type.isAssignableFrom(ArrayList.class))
			return new ArrayList();
		if (type.isAssignableFrom(LinkedList.class))
			return new LinkedList();
		if (type.isAssignableFrom(HashSet.class))
			return new HashSet();
		if (type.isAssignableFrom(HashMap.class))
			return new HashMap();
		return type.newInstance();
	}