Java Class.isMemberClass Examples

Java Class.isMemberClass - 19 examples found. These are the top rated real world Java examples of Class.isMemberClass extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 private Object newInstance(Class type) {
   try {
     return type.newInstance();
   } catch (Exception ex) {
     try {
       // Try a private constructor.
       Constructor constructor = type.getDeclaredConstructor();
       constructor.setAccessible(true);
       return constructor.newInstance();
     } catch (SecurityException ignored) {
     } catch (NoSuchMethodException ignored) {
       if (type.isArray())
         throw new SerializationException(
             "Encountered JSON object when expected array of type: " + type.getName(), ex);
       else if (type.isMemberClass() && !Modifier.isStatic(type.getModifiers()))
         throw new SerializationException(
             "Class cannot be created (non-static member class): " + type.getName(), ex);
       else
         throw new SerializationException(
             "Class cannot be created (missing no-arg constructor): " + type.getName(), ex);
     } catch (Exception privateConstructorException) {
       ex = privateConstructorException;
     }
     throw new SerializationException(
         "Error constructing instance of class: " + type.getName(), ex);
   }
 }
  /**
   * Default constructor associates this handler with the queue for the current thread.
   *
   * <p>If there isn't one, this handler won't be able to receive messages.
   */
  public Handler() {
    if (FIND_POTENTIAL_LEAKS) {
      final Class<? extends Handler> klass = getClass();
      if ((klass.isAnonymousClass() || klass.isMemberClass() || klass.isLocalClass())
          && (klass.getModifiers() & Modifier.STATIC) == 0) {
        Log.w(
            TAG,
            "The following Handler class should be static or leaks might occur: "
                + klass.getCanonicalName());
      }
    }
    // @wujl commented

    mLooper = Looper.myLooper();
    if (mLooper == null) {
      throw new RuntimeException(
          "Can't create handler inside thread that has not called Looper.prepare()");
    }
    mQueue = mLooper.mQueue;

    // #wujl
    // @wujl added
    // mLooper = null;
    // mQueue = null;
    // #wujl
    mCallback = null;
  }
Example #3
0
 public static int getNesting(Class<?> clazz) {
   if (clazz.isMemberClass() && !isStatic(clazz)) {
     return 1 + getNesting(clazz.getDeclaringClass());
   } else {
     return 0;
   }
 }
Example #4
0
 public static boolean isCacheable(Annotation[] annotations) {
   for (Annotation qualifier : annotations) {
     Class<?> clazz = qualifier.getClass();
     if (clazz.isAnonymousClass() || (clazz.isMemberClass() && isStatic(clazz))) {
       return false;
     }
   }
   return true;
 }
    private boolean isEnclosingClassParameter() {

      if (enclosingClassCache == null) {
        Class<T> owningType = entity.getType();
        this.enclosingClassCache =
            owningType.isMemberClass() && type.getType().equals(owningType.getEnclosingClass());
      }

      return enclosingClassCache;
    }
  protected List<JavaMethod> initMethods() {
    List<JavaMethod> methodMap = new ArrayList<JavaMethod>();

    // Get all methods for interfaces: normally, even if it is possible in Java
    // to override a method into a inherited interface, there is no meaning
    // to do so (we just ignore potential compilation issues with generated AS3
    // classes for this case since it is always possible to remove the method
    // re-declaration in the child interface).
    Method[] methods = null;
    ParameterizedType[] declaringTypes = GenericTypeUtil.getDeclaringTypes(type);

    if (type.isInterface()) methods = type.getMethods();
    else methods = type.getDeclaredMethods();

    for (Method method : methods) {
      if (shouldGenerateMethod(method)) {
        JavaMethod javaMethod =
            new JavaMethod(method, MethodType.OTHER, this.provider, declaringTypes);

        for (Class<?> clazz : javaMethod.getParameterTypes()) {
          if (clazz.isMemberClass() && !clazz.isEnum()) {
            throw new UnsupportedOperationException(
                "Inner classes are not supported (except enums): " + clazz);
          }
        }
        for (ClientType paramType : javaMethod.getClientParameterTypes())
          addToImports(provider.getJavaImports(paramType, false));

        Class<?> clazz = javaMethod.getReturnType();
        if (clazz.isMemberClass() && !clazz.isEnum()) {
          throw new UnsupportedOperationException(
              "Inner classes are not supported (except enums): " + clazz);
        }
        if (!clazz.equals(Void.class) && !clazz.equals(void.class))
          addToImports(provider.getJavaImports(javaMethod.getClientReturnType(), false));

        methodMap.add(javaMethod);
      }
    }

    return methodMap;
  }