Try to get a more specific class instead of using the Collection interface
i.e., invokevirtual is significantly faster then invokeinterface.
191161
private Class getCollectionType()
  {
    Class collectionType = Collection.class;
    IParsedElement parent = getParsedElement().getParent();
    if( parent instanceof NewExpression )
    {
      IType newType = ((NewExpression)parent).getType();
      IJavaClassInfo classInfo = IRTypeResolver.getJavaBackedClass(newType);
      Class javaBackedClass = classInfo != null ? classInfo.getBackingClass() : null;
      if( classInfo != null && javaBackedClass != null )
      {
        collectionType = javaBackedClass;
      }
      else if( JavaTypes.getJreType(AbstractCollection.class).isAssignableFrom( newType ) )
      {
        collectionType = AbstractCollection.class;
      }
    }
    return collectionType;
  }
1107844
@SuppressWarnings("unchecked")
    public static Collection<Object> getCollectionObj(Class<?> clazz) {
        if (clazz.isInterface()) {
            if (clazz.isAssignableFrom(List.class))
                return new ArrayList<>();
            else if (clazz.isAssignableFrom(Set.class))
                return new HashSet<>();
            else if (clazz.isAssignableFrom(Queue.class))
                return new ArrayDeque<>();
            else if (clazz.isAssignableFrom(SortedSet.class))
                return new TreeSet<>();
            else if (clazz.isAssignableFrom(BlockingQueue.class))
                return new LinkedBlockingDeque<>();
            else
                return null;
        } else {
            Collection<Object> collection = null;
            try {
                collection = (Collection<Object>) clazz.newInstance();
            } catch (Exception e) {
                System.err.println("new collection instance exception, " + e.getMessage());
            }
            return collection;
        }
    }
621056
private static Class<?> getProxyClass0(ClassLoader loader,
                                           Class<?>... interfaces) {
        if (interfaces.length > 65535) {
            throw new IllegalArgumentException("interface limit exceeded");
        }

        Class<?> proxyClass = null;

        /* collect interface names to use as key for proxy class cache */
        String[] interfaceNames = new String[interfaces.length];

        // for detecting duplicates
        Set<Class<?>> interfaceSet = new HashSet<>();

        for (int i = 0; i < interfaces.length; i++) {
            /*
             * Verify that the class loader resolves the name of this
             * interface to the same Class object.
             */
            String interfaceName = interfaces[i].getName();
            Class<?> interfaceClass = null;
            try {
                interfaceClass = Class.forName(interfaceName, false, loader);
            } catch (ClassNotFoundException e) {
            }
            if (interfaceClass != interfaces[i]) {
                throw new IllegalArgumentException(
                    interfaces[i] + " is not visible from class loader");
            }

            /*
             * Verify that the Class object actually represents an
             * interface.
             */
            if (!interfaceClass.isInterface()) {
                throw new IllegalArgumentException(
                    interfaceClass.getName() + " is not an interface");
            }

            /*
             * Verify that this interface is not a duplicate.
             */
            if (interfaceSet.contains(interfaceClass)) {
                throw new IllegalArgumentException(
                    "repeated interface: " + interfaceClass.getName());
            }
            interfaceSet.add(interfaceClass);

            interfaceNames[i] = interfaceName;
        }

        /*
         * Using string representations of the proxy interfaces as
         * keys in the proxy class cache (instead of their Class
         * objects) is sufficient because we require the proxy
         * interfaces to be resolvable by name through the supplied
         * class loader, and it has the advantage that using a string
         * representation of a class makes for an implicit weak
         * reference to the class.
         */
        List<String> key = Arrays.asList(interfaceNames);

        /*
         * Find or create the proxy class cache for the class loader.
         */
        Map<List<String>, Object> cache;
        synchronized (loaderToCache) {
            cache = loaderToCache.get(loader);
            if (cache == null) {
                cache = new HashMap<>();
                loaderToCache.put(loader, cache);
            }
            /*
             * This mapping will remain valid for the duration of this
             * method, without further synchronization, because the mapping
             * will only be removed if the class loader becomes unreachable.
             */
        }

        /*
         * Look up the list of interfaces in the proxy class cache using
         * the key.  This lookup will result in one of three possible
         * kinds of values:
         *     null, if there is currently no proxy class for the list of
         *         interfaces in the class loader,
         *     the pendingGenerationMarker object, if a proxy class for the
         *         list of interfaces is currently being generated,
         *     or a weak reference to a Class object, if a proxy class for
         *         the list of interfaces has already been generated.
         */
        synchronized (cache) {
            /*
             * Note that we need not worry about reaping the cache for
             * entries with cleared weak references because if a proxy class
             * has been garbage collected, its class loader will have been
             * garbage collected as well, so the entire cache will be reaped
             * from the loaderToCache map.
             */
            do {
                Object value = cache.get(key);
                if (value instanceof Reference) {
                    proxyClass = (Class<?>) ((Reference<?>) value).get();
                }
                if (proxyClass != null) {
                    // proxy class already generated: return it
                    return proxyClass;
                } else if (value == pendingGenerationMarker) {
                    // proxy class being generated: wait for it
                    try {
                        cache.wait();
                    } catch (InterruptedException e) {
                        /*
                         * The class generation that we are waiting for should
                         * take a small, bounded time, so we can safely ignore
                         * thread interrupts here.
                         */
                    }
                    continue;
                } else {
                    /*
                     * No proxy class for this list of interfaces has been
                     * generated or is being generated, so we will go and
                     * generate it now.  Mark it as pending generation.
                     */
                    cache.put(key, pendingGenerationMarker);
                    break;
                }
            } while (true);
        }

        try {
            String proxyPkg = null;     // package to define proxy class in

            /*
             * Record the package of a non-public proxy interface so that the
             * proxy class will be defined in the same package.  Verify that
             * all non-public proxy interfaces are in the same package.
             */
            for (int i = 0; i < interfaces.length; i++) {
                int flags = interfaces[i].getModifiers();
                if (!Modifier.isPublic(flags)) {
                    String name = interfaces[i].getName();
                    int n = name.lastIndexOf('.');
                    String pkg = ((n == -1) ? "" : name.substring(0, n + 1));
                    if (proxyPkg == null) {
                        proxyPkg = pkg;
                    } else if (!pkg.equals(proxyPkg)) {
                        throw new IllegalArgumentException(
                            "non-public interfaces from different packages");
                    }
                }
            }

            if (proxyPkg == null) {
                // if no non-public proxy interfaces, use the default package.
                proxyPkg = "";
            }

            {
                // Android-changed: Generate the proxy directly instead of calling
                // through to ProxyGenerator.
                /* J2ObjC removed.
                List<Method> methods = getMethods(interfaces);
                Collections.sort(methods, ORDER_BY_SIGNATURE_AND_SUBTYPE);
                validateReturnTypes(methods);
                List<Class<?>[]> exceptions = deduplicateAndGetExceptions(methods);

                Method[] methodsArray = methods.toArray(new Method[methods.size()]);
                Class<?>[][] exceptionsArray = exceptions.toArray(new Class<?>[exceptions.size()][]);
                */

                /*
                 * Choose a name for the proxy class to generate.
                 */
                final long num;
                synchronized (nextUniqueNumberLock) {
                    num = nextUniqueNumber++;
                }
                String proxyName = proxyPkg + proxyClassNamePrefix + num;

                proxyClass = generateProxy(proxyName, interfaces, loader);
            }
            // add to set of all generated proxy classes, for isProxyClass
            proxyClasses.put(proxyClass, null);

        } finally {
            /*
             * We must clean up the "pending generation" state of the proxy
             * class cache entry somehow.  If a proxy class was successfully
             * generated, store it in the cache (with a weak reference);
             * otherwise, remove the reserved entry.  In all cases, notify
             * all waiters on reserved entries in this cache.
             */
            synchronized (cache) {
                if (proxyClass != null) {
                    cache.put(key, new WeakReference<Class<?>>(proxyClass));
                } else {
                    cache.remove(key);
                }
                cache.notifyAll();
            }
        }
        return proxyClass;
    }
239301
@PerformanceSensitive
    public Class<?> getCallerClass(final int depth) {
        if (depth < 0) {
            throw new IndexOutOfBoundsException(Integer.toString(depth));
        }
        // note that we need to add 1 to the depth value to compensate for this method, but not for the Method.invoke
        // since Reflection.getCallerClass ignores the call to Method.invoke()
        try {
            return (Class<?>) GET_CALLER_CLASS.invoke(null, depth + 1 + JDK_7u25_OFFSET);
        } catch (final Exception e) {
            // theoretically this could happen if the caller class were native code
            // TODO: return Object.class
            return null;
        }
    }
1327081
@SuppressWarnings("javadoc")
    public static <T> T getSingleService(Class<T> serviceInterface) throws IllegalStateException {
        // Cached single service values are derived from the values cached when checking
        // for multiple services
        T rval = null;
        Set<T> services = getServices(serviceInterface);
        
        if (services.size() > 1) {
            throw new IllegalStateException("Multiple implementations found of " + serviceInterface); //$NON-NLS-1$
        } else if (!services.isEmpty()) {
            rval = services.iterator().next();
        }
        return rval;
    }
802863
public static Class<?> getCollectionClass (Class<?> clazz)
    {
        if (Streamable.class.isAssignableFrom(clazz)) {
            // the class is natively streamable, let's ignore it
            return null;
        }
        for (Class<?> collClass : BasicStreamers.CollectionStreamer.SPECIFICITY_ORDER) {
            if (collClass.isAssignableFrom(clazz)) {
                return collClass;
            }
        }
        return null;
    }
519196
public static MetaClass getMetaClass(Object obj) {
        MetaClass mc = InvokerHelper.getMetaClass(obj);
        return new HandleMetaClass(mc, obj);
    }
147647
private Object invoke(String methodName, Object returnValueIfNonExistent,
                          Class<?>[] paramTypes, Object[] params)
        throws DocletInvokeException {
            Method meth;
            try {
                meth = docletClass.getMethod(methodName, paramTypes);
            } catch (NoSuchMethodException exc) {
                if (returnValueIfNonExistent == null) {
                    messager.error(Messager.NOPOS, "main.doclet_method_not_found",
                                   docletClassName, methodName);
                    throw new DocletInvokeException();
                } else {
                    return returnValueIfNonExistent;
                }
            } catch (SecurityException exc) {
                messager.error(Messager.NOPOS, "main.doclet_method_not_accessible",
                               docletClassName, methodName);
                throw new DocletInvokeException();
            }
            if (!Modifier.isStatic(meth.getModifiers())) {
                messager.error(Messager.NOPOS, "main.doclet_method_must_be_static",
                               docletClassName, methodName);
                throw new DocletInvokeException();
            }
            ClassLoader savedCCL =
                Thread.currentThread().getContextClassLoader();
            try {
                if (appClassLoader != null) // will be null if doclet class provided via API
                    Thread.currentThread().setContextClassLoader(appClassLoader);
                return meth.invoke(null , params);
            } catch (IllegalArgumentException exc) {
                messager.error(Messager.NOPOS, "main.internal_error_exception_thrown",
                               docletClassName, methodName, exc.toString());
                throw new DocletInvokeException();
            } catch (IllegalAccessException exc) {
                messager.error(Messager.NOPOS, "main.doclet_method_not_accessible",
                               docletClassName, methodName);
                throw new DocletInvokeException();
            } catch (NullPointerException exc) {
                messager.error(Messager.NOPOS, "main.internal_error_exception_thrown",
                               docletClassName, methodName, exc.toString());
                throw new DocletInvokeException();
            } catch (InvocationTargetException exc) {
                Throwable err = exc.getTargetException();
                if (apiMode)
                    throw new ClientCodeException(err);
                if (err instanceof java.lang.OutOfMemoryError) {
                    messager.error(Messager.NOPOS, "main.out.of.memory");
                } else {
                    messager.error(Messager.NOPOS, "main.exception_thrown",
                               docletClassName, methodName, exc.toString());
                    exc.getTargetException().printStackTrace();
                }
                throw new DocletInvokeException();
            } finally {
                Thread.currentThread().setContextClassLoader(savedCCL);
            }
    }
1036912
def next_object(self):
        """"""
        grid_out = super(self.__class__, self).next_object()
        if grid_out:
            grid_out_class = create_class_with_framework(
                AgnosticGridOut, self._framework, self.__module__)

            return grid_out_class(self.collection, delegate=grid_out)
        else:
            # Exhausted.
            return None
522912
public FastMethod getFastMethod(Class<?> clazz, String methodName, Object... parameter) {
        if (parameter == null) {
            return getFastMethod(clazz, methodName);
        }

        Class[] types = new Class[parameter.length];
        for (int i = 0; i < parameter.length; i++) {
            types[i] = parameter.getClass();
        }

        return getFastMethod(clazz, methodName, types);
    }
1198077
private InvocationMethod tryGetMethod(final InvokerKey key) {
        InvocationMethod invocationMethod = null;
        try {
            invocationMethod = invocationMethods.get(key);
        } catch (Exception ex) {
            LOG.warn("Error fetching method to invoke method {}", key, ex);
        }

        return invocationMethod;
    }
452252
private static Class<ElasticsearchClient> findClass(int version) throws ClassNotFoundException {
        String className = "fr.pilato.elasticsearch.crawler.fs.client.v" + version + ".ElasticsearchClientV" + version;
        logger.trace("Trying to find a class named [{}]", className);
        Class<?> aClass = Class.forName(className);
        boolean isImplementingInterface = ElasticsearchClient.class.isAssignableFrom(aClass);
        if (!isImplementingInterface) {
            throw new IllegalArgumentException("Class " + className + " does not implement " + ElasticsearchClient.class.getName() + " interface");
        }

        return (Class<ElasticsearchClient>) aClass;
    }
79063
def get_managed_object(handle, class_id, params, inMo=None, in_heir=False,
                       dump=False):
    
    return handle.GetManagedObject(inMo, class_id, params,
                      inHierarchical=in_heir,
                      dumpXml=dump)
562088
public Object getRealObjectIfMaterialized(Object objectOrProxy)
    {
        if(isNormalOjbProxy(objectOrProxy))
        {
            String msg;

            try
            {
                IndirectionHandler handler = getIndirectionHandler(objectOrProxy);

                return handler.alreadyMaterialized() ? handler.getRealSubject() : null;
            }
            catch(ClassCastException e)
            {
                // shouldn't happen but still ...
                msg = "The InvocationHandler for the provided Proxy was not an instance of " + IndirectionHandler.class.getName();
                log.error(msg);
                throw new PersistenceBrokerException(msg, e);
            }
            catch(IllegalArgumentException e)
            {
                msg = "Could not retrieve real object for given Proxy: " + objectOrProxy;
                log.error(msg);
                throw new PersistenceBrokerException(msg, e);
            }
            catch(PersistenceBrokerException e)
            {
                log.error("Could not retrieve real object for given Proxy: " + objectOrProxy);
                throw e;
            }
        }
        else if(isVirtualOjbProxy(objectOrProxy))
        {
            try
            {
                VirtualProxy proxy = (VirtualProxy) objectOrProxy;

                return proxy.alreadyMaterialized() ? proxy.getRealSubject() : null;
            }
            catch(PersistenceBrokerException e)
            {
                log.error("Could not retrieve real object for VirtualProxy: " + objectOrProxy);
                throw e;
            }
        }
        else
        {
            return objectOrProxy;
        }
    }
688256
private <T> T getProxyObject(
      T originalObject, AdWordsSession session, Class<T> cls, boolean isUtility) {
    // Find the retry strategy of this class type.
    ApiRetryStrategy retryStrategy =
        ApiRetryStrategyManager.getRetryStrategy(cls.getSimpleName(), isUtility);

    // If no corresponding retry strategy, just use the original object instead of a wrapping proxy.
    if (retryStrategy == null) {
      return originalObject;
    }

    InvocationHandler invocationHandler =
        new ApiInvocationHandlerWithRateLimiter(originalObject, session, retryStrategy);
    return Reflection.newProxy(cls, invocationHandler);
  }
881626
def _get_class(self, superclass, namespace=None,
                   local_only=False, include_qualifiers=True,
                   include_classorigin=True):
        
        return self.GetClass(superclass,
                             namespace=namespace,
                             local_only=local_only,
                             include_qualifiers=include_qualifiers,
                             include_classorigin=include_classorigin)
91014
public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException {
	// used reflection to make sure this work with Java 5 and 6
	try {
	    return (T) stat.getClass().getMethod("getObject", new Class[] { int.class, Class.class }).invoke(stat, new Object[] { parameterIndex, type });
	}
	catch (Throwable t) {
	    ExceptionUtil.rethrowIfNecessary(t);
	    if (t instanceof InvocationTargetException && ((InvocationTargetException) t).getTargetException() instanceof SQLException)
		throw (SQLException) ((InvocationTargetException) t).getTargetException();
	    throw new PageRuntimeException(Caster.toPageException(t));
	}
    }