Example usage for java.lang Class isInterface

List of usage examples for java.lang Class isInterface

Introduction

In this page you can find the example usage for java.lang Class isInterface.

Prototype

@HotSpotIntrinsicCandidate
public native boolean isInterface();

Source Link

Document

Determines if the specified Class object represents an interface type.

Usage

From source file:org.powertac.logtool.common.DomainObjectReader.java

private Object resolveArg(Type type, String arg) throws MissingDomainObject {
    // type can be null in a few cases - nothing to be done about it?
    if (null == type) {
        return null;
    }/*w  w w  .  j a v a2  s .co  m*/

    // check for non-parameterized types
    if (type instanceof Class) {
        Class<?> clazz = (Class<?>) type;
        if (clazz.isEnum()) {
            return Enum.valueOf((Class<Enum>) type, arg);
        } else {
            return resolveSimpleArg(clazz, arg);
        }
    }

    // check for collection, denoted by leading (
    if (type instanceof ParameterizedType) {
        ParameterizedType ptype = (ParameterizedType) type;
        Class<?> clazz = (Class<?>) ptype.getRawType();
        boolean isCollection = false;
        if (clazz.equals(Collection.class))
            isCollection = true;
        else {
            Class<?>[] ifs = clazz.getInterfaces();
            for (Class<?> ifc : ifs) {
                if (ifc.equals(Collection.class)) {
                    isCollection = true;
                    break;
                }
            }
        }
        if (isCollection) {
            // expect arg to start with "("
            log.debug("processing collection " + clazz.getName());
            if (arg.charAt(0) != '(') {
                log.error("Collection arg " + arg + " does not start with paren");
                return null;
            }
            // extract element type and resolve recursively
            Type[] tas = ptype.getActualTypeArguments();
            if (1 == tas.length) {
                Class<?> argClazz = (Class<?>) tas[0];
                // create an instance of the collection
                Collection<Object> coll;
                // resolve interfaces into actual classes
                if (clazz.isInterface())
                    clazz = ifImplementors.get(clazz);
                try {
                    coll = (Collection<Object>) clazz.newInstance();
                } catch (Exception e) {
                    log.error("Exception creating collection: " + e.toString());
                    return null;
                }
                // at this point, we can split the string and resolve recursively
                String body = arg.substring(1, arg.indexOf(')'));
                String[] items = body.split(",");
                for (String item : items) {
                    coll.add(resolveSimpleArg(argClazz, item));
                }
                return coll;
            }
        }
    }

    // if we get here, no resolution
    log.error("unresolved arg: type = " + type + ", arg = " + arg);
    return null;
}

From source file:com.gatf.generator.core.GatfTestGeneratorMojo.java

/**
 * @param claz//from  w w w .  j a va  2s .  c  o  m
 * @param parameters
 * @param naming
 * @param formpnm
 * @param isheaderParam
 * @param heirarchy
 * @throws Exception Add new ViewFeild objects that represnt the form elements on the test page of the give rest
 *             full service
 */
@SuppressWarnings("rawtypes")
private ViewField getViewField(Type claz) throws Exception {
    ViewField viewField = null;
    try {
        ParameterizedType type = null;
        Class clas = null;
        if (claz instanceof ParameterizedType) {
            type = (ParameterizedType) claz;
            clas = (Class) type.getRawType();
        } else {
            clas = (Class) claz;
        }

        List<Type> heirarchies = new ArrayList<Type>();
        if (isPrimitive(clas)) {
            viewField = new ViewField();
            viewField.setClaz(clas);
            viewField.setValue(getPrimitiveValue(claz));
        } else if (isMap(clas)) {
            viewField = new ViewField();
            viewField.setClaz(clas);
            viewField.setValue(getMapValue(clas, type.getActualTypeArguments(), heirarchies));
        } else if (isCollection(clas)) {
            viewField = new ViewField();
            viewField.setClaz(clas);
            viewField.setValue(getListSetValue(clas, type.getActualTypeArguments(), heirarchies));
        } else if (!clas.isInterface()) {
            viewField = new ViewField();
            viewField.setClaz(clas);
            viewField.setValue(getObject(clas, heirarchies));
        }
    } catch (Exception e) {
        getLog().error(e);
        getLog().info(
                "Invalid class, cannot be represented as a form/object in a test case - class name = " + claz);
    }
    return viewField;
}

From source file:io.sinistral.proteus.server.tools.swagger.Reader.java

@SuppressWarnings("deprecation")
private Operation parseMethod(Class<?> cls, Method method, AnnotatedMethod annotatedMethod,
        List<Parameter> globalParameters, List<ApiResponse> classApiResponses, List<String> pathParamNames) {
    Operation operation = new Operation();
    if (annotatedMethod != null) {
        method = annotatedMethod.getAnnotated();
    }/*from w ww.j a  va  2 s  . com*/
    ApiOperation apiOperation = ReflectionUtils.getAnnotation(method, ApiOperation.class);
    ApiResponses responseAnnotation = ReflectionUtils.getAnnotation(method, ApiResponses.class);

    String operationId;
    // check if it's an inherited or implemented method.
    boolean methodInSuperType = false;
    if (!cls.isInterface()) {
        methodInSuperType = ReflectionUtils.findMethod(method, cls.getSuperclass()) != null;
    }
    if (!methodInSuperType) {
        for (Class<?> implementedInterface : cls.getInterfaces()) {
            methodInSuperType = ReflectionUtils.findMethod(method, implementedInterface) != null;
            if (methodInSuperType) {
                break;
            }
        }
    }
    if (!methodInSuperType) {
        operationId = method.getName();
    } else {
        operationId = this.getOperationId(method.getName());
    }

    String responseContainer = null;

    Type responseType = null;
    Map<String, Property> defaultResponseHeaders = new LinkedHashMap<String, Property>();

    if (apiOperation != null) {
        if (apiOperation.hidden()) {
            return null;
        }
        if (operationId == null) {
            operationId = apiOperation.nickname();
        }

        defaultResponseHeaders = parseResponseHeaders(apiOperation.responseHeaders());

        operation.summary(apiOperation.value()).description(apiOperation.notes());

        if (!isVoid(apiOperation.response())) {
            responseType = apiOperation.response();
        }
        if (!apiOperation.responseContainer().isEmpty()) {
            responseContainer = apiOperation.responseContainer();
        }
        List<SecurityRequirement> securities = new ArrayList<SecurityRequirement>();
        for (Authorization auth : apiOperation.authorizations()) {
            if (!auth.value().isEmpty()) {
                SecurityRequirement security = new SecurityRequirement();
                security.setName(auth.value());
                for (AuthorizationScope scope : auth.scopes()) {
                    if (!scope.scope().isEmpty()) {
                        security.addScope(scope.scope());
                    }
                }
                securities.add(security);
            }
        }
        for (SecurityRequirement sec : securities) {
            operation.security(sec);
        }
        if (!apiOperation.consumes().isEmpty()) {
            String[] consumesAr = ReaderUtils.splitContentValues(new String[] { apiOperation.consumes() });
            for (String consume : consumesAr) {
                operation.consumes(consume);
            }
        }
        if (!apiOperation.produces().isEmpty()) {
            String[] producesAr = ReaderUtils.splitContentValues(new String[] { apiOperation.produces() });
            for (String produce : producesAr) {
                operation.produces(produce);
            }
        }
    }

    /*
     * @TODO
     * Use apiOperation response class instead of unwrapping ServerResponse's inner type
     */

    if (apiOperation != null && StringUtils.isNotEmpty(apiOperation.responseReference())) {
        Response response = new Response().description(SUCCESSFUL_OPERATION);
        response.schema(new RefProperty(apiOperation.responseReference()));
        operation.addResponse(String.valueOf(apiOperation.code()), response);
    } else if (responseType == null) {
        // pick out response from method declaration
        LOGGER.debug("picking up response class from method {}", method);
        responseType = method.getGenericReturnType();
    }

    if (responseType != null) {
        final JavaType javaType = TypeFactory.defaultInstance().constructType(responseType);
        if (!isVoid(javaType)) {

            final Class<?> responseCls = javaType.getRawClass();

            if (responseCls != null) {
                if (responseCls.isAssignableFrom(ServerResponse.class)) {
                    responseType = javaType.containedType(0);
                } else if (responseCls.isAssignableFrom(CompletableFuture.class)) {
                    Class<?> futureCls = javaType.containedType(0).getRawClass();

                    if (futureCls.isAssignableFrom(ServerResponse.class)) {
                        final JavaType futureType = TypeFactory.defaultInstance()
                                .constructType(javaType.containedType(0));
                        responseType = futureType.containedType(0);
                    } else {
                        responseType = javaType.containedType(0);
                    }
                }
            }
        }
    }

    if (isValidResponse(responseType)) {
        final Property property = ModelConverters.getInstance().readAsProperty(responseType);
        if (property != null) {
            final Property responseProperty = ContainerWrapper.wrapContainer(responseContainer, property);
            final int responseCode = (apiOperation == null) ? 200 : apiOperation.code();
            operation.response(responseCode, new Response().description(SUCCESSFUL_OPERATION)
                    .schema(responseProperty).headers(defaultResponseHeaders));
            appendModels(responseType);
        }
    }

    operation.operationId(operationId);

    if (operation.getConsumes() == null || operation.getConsumes().isEmpty()) {
        final Consumes consumes = ReflectionUtils.getAnnotation(method, Consumes.class);
        if (consumes != null) {
            for (String mediaType : ReaderUtils.splitContentValues(consumes.value())) {
                operation.consumes(mediaType);
            }
        }
    }

    if (operation.getProduces() == null || operation.getProduces().isEmpty()) {
        final Produces produces = ReflectionUtils.getAnnotation(method, Produces.class);
        if (produces != null) {
            for (String mediaType : ReaderUtils.splitContentValues(produces.value())) {
                operation.produces(mediaType);
            }
        }
    }

    List<ApiResponse> apiResponses = new ArrayList<>();
    if (responseAnnotation != null) {
        apiResponses.addAll(Arrays.asList(responseAnnotation.value()));
    }

    Class<?>[] exceptionTypes = method.getExceptionTypes();
    for (Class<?> exceptionType : exceptionTypes) {
        ApiResponses exceptionResponses = ReflectionUtils.getAnnotation(exceptionType, ApiResponses.class);
        if (exceptionResponses != null) {
            apiResponses.addAll(Arrays.asList(exceptionResponses.value()));
        }
    }

    for (ApiResponse apiResponse : apiResponses) {
        addResponse(operation, apiResponse);
    }
    // merge class level @ApiResponse
    for (ApiResponse apiResponse : classApiResponses) {
        String key = (apiResponse.code() == 0) ? "default" : String.valueOf(apiResponse.code());
        if (operation.getResponses() != null && operation.getResponses().containsKey(key)) {
            continue;
        }
        addResponse(operation, apiResponse);
    }

    if (ReflectionUtils.getAnnotation(method, Deprecated.class) != null) {
        operation.setDeprecated(true);
    }

    // process parameters
    for (Parameter globalParameter : globalParameters) {

        LOGGER.debug("globalParameters TYPE: " + globalParameter);

        operation.parameter(globalParameter);
    }

    Annotation[][] paramAnnotations = ReflectionUtils.getParameterAnnotations(method);
    java.lang.reflect.Parameter[] methodParameters = method.getParameters();

    if (annotatedMethod == null) {
        Type[] genericParameterTypes = method.getGenericParameterTypes();

        for (int i = 0; i < genericParameterTypes.length; i++) {

            Type type = TypeFactory.defaultInstance().constructType(genericParameterTypes[i], cls);

            if (type.getTypeName().contains("Optional")
                    || type.getTypeName().contains("io.sinistral.proteus.server.ServerResponse")) {
                if (type instanceof com.fasterxml.jackson.databind.type.SimpleType) {
                    com.fasterxml.jackson.databind.type.SimpleType simpleType = (com.fasterxml.jackson.databind.type.SimpleType) type;

                    type = simpleType.containedType(0);
                }

            }

            if (type.equals(ServerRequest.class) || type.equals(HttpServerExchange.class)
                    || type.equals(HttpHandler.class)
                    || type.getTypeName().contains("io.sinistral.proteus.server.ServerResponse")) {
                continue;
            }

            List<Parameter> parameters = getParameters(type, Arrays.asList(paramAnnotations[i]),
                    methodParameters[i], pathParamNames);

            for (Parameter parameter : parameters) {
                operation.parameter(parameter);
            }
        }
    } else {
        for (int i = 0; i < annotatedMethod.getParameterCount(); i++) {
            AnnotatedParameter param = annotatedMethod.getParameter(i);

            if (param.getParameterType().equals(ServerRequest.class)
                    || param.getParameterType().equals(HttpServerExchange.class)
                    || param.getParameterType().equals(HttpHandler.class)
                    || param.getParameterType().getTypeName().contains("ServerResponse")) {
                continue;
            }

            Type type = TypeFactory.defaultInstance().constructType(param.getParameterType(), cls);

            List<Parameter> parameters = getParameters(type, Arrays.asList(paramAnnotations[i]),
                    methodParameters[i], pathParamNames);

            for (Parameter parameter : parameters) {

                operation.parameter(parameter);
            }
        }
    }

    if (operation.getResponses() == null) {
        Response response = new Response().description(SUCCESSFUL_OPERATION);

        operation.response(200, response);
    }

    processOperationDecorator(operation, method);

    return operation;
}

From source file:com.opensymphony.xwork2.util.DefaultLocalizedTextProvider.java

/**
 * Traverse up class hierarchy looking for message.  Looks at class, then implemented interface,
 * before going up hierarchy./*from  w w w  . j  av  a  2 s  . c  o m*/
 *
 * @return the message
 */
private String findMessage(Class clazz, String key, String indexedKey, Locale locale, Object[] args,
        Set<String> checked, ValueStack valueStack) {
    if (checked == null) {
        checked = new TreeSet<String>();
    } else if (checked.contains(clazz.getName())) {
        return null;
    }

    // look in properties of this class
    String msg = getMessage(clazz.getName(), locale, key, valueStack, args);

    if (msg != null) {
        return msg;
    }

    if (indexedKey != null) {
        msg = getMessage(clazz.getName(), locale, indexedKey, valueStack, args);

        if (msg != null) {
            return msg;
        }
    }

    // look in properties of implemented interfaces
    Class[] interfaces = clazz.getInterfaces();

    for (Class anInterface : interfaces) {
        msg = getMessage(anInterface.getName(), locale, key, valueStack, args);

        if (msg != null) {
            return msg;
        }

        if (indexedKey != null) {
            msg = getMessage(anInterface.getName(), locale, indexedKey, valueStack, args);

            if (msg != null) {
                return msg;
            }
        }
    }

    // traverse up hierarchy
    if (clazz.isInterface()) {
        interfaces = clazz.getInterfaces();

        for (Class anInterface : interfaces) {
            msg = findMessage(anInterface, key, indexedKey, locale, args, checked, valueStack);

            if (msg != null) {
                return msg;
            }
        }
    } else {
        if (!clazz.equals(Object.class) && !clazz.isPrimitive()) {
            return findMessage(clazz.getSuperclass(), key, indexedKey, locale, args, checked, valueStack);
        }
    }

    return null;
}

From source file:jp.co.acroquest.jsonic.JSON.java

protected <T> T create(Context context, Class<? extends T> c) throws Exception {
    Object instance = null;/*from  w  ww  .  j a  v a  2 s. co m*/

    JSONHint hint = context.getHint();
    if (hint != null && hint.type() != Object.class)
        c = hint.type().asSubclass(c);

    if (c.isInterface()) {
        if (SortedMap.class.equals(c)) {
            instance = new TreeMap<Object, Object>();
        } else if (Map.class.equals(c)) {
            instance = new LinkedHashMap<Object, Object>();
        } else if (SortedSet.class.equals(c)) {
            instance = new TreeSet<Object>();
        } else if (Set.class.equals(c)) {
            instance = new LinkedHashSet<Object>();
        } else if (List.class.equals(c)) {
            instance = new ArrayList<Object>();
        } else if (Collection.class.equals(c)) {
            instance = new ArrayList<Object>();
        } else if (Appendable.class.equals(c)) {
            instance = new StringBuilder();
        }
    } else if (Modifier.isAbstract(c.getModifiers())) {
        if (Calendar.class.equals(c)) {
            instance = Calendar.getInstance();
        }
    } else if ((c.isMemberClass() || c.isAnonymousClass()) && !Modifier.isStatic(c.getModifiers())) {
        Class<?> eClass = c.getEnclosingClass();
        Constructor<?> con = c.getDeclaredConstructor(eClass);
        con.setAccessible(true);
        if (context.contextObject != null && eClass.isAssignableFrom(context.contextObject.getClass())) {
            instance = con.newInstance(context.contextObject);
        } else {
            instance = con.newInstance((Object) null);
        }
    } else {
        if (Date.class.isAssignableFrom(c)) {
            try {
                Constructor<?> con = c.getDeclaredConstructor(long.class);
                con.setAccessible(true);
                instance = con.newInstance(0l);
            } catch (NoSuchMethodException e) {
                // no handle
            }
        }

        if (instance == null) {
            Constructor<?> con = c.getDeclaredConstructor();
            con.setAccessible(true);
            instance = con.newInstance();
        }
    }

    return c.cast(instance);
}

From source file:org.apache.openjpa.meta.MetaDataRepository.java

/**
 * Add the given non-mapped interface to the repository.
 * //from ww  w .j  a  v  a 2 s  .co  m
 * @param iface
 *            the non-mapped interface
 */
public NonPersistentMetaData addNonMappedInterface(Class<?> iface) {
    if (iface == null)
        return null;
    if (!iface.isInterface())
        throw new MetaDataException(_loc.get("not-non-mapped", iface));
    if (_locking) {
        synchronized (this) {
            return addNonMappedInterfaceInternal(iface);
        }
    } else {
        return addNonMappedInterfaceInternal(iface);
    }
}

From source file:org.apache.openjpa.meta.ClassMetaData.java

/**
 * Explicitly declare the given interface among the ones this
 * class implements.//from ww w.j  a v  a2 s.c o m
 */
public void addDeclaredInterface(Class<?> iface) {
    if (iface == null || !iface.isInterface())
        throw new MetaDataException(_loc.get("declare-non-interface", this, iface));
    if (_interfaces == null)
        _interfaces = new ArrayList<Class<?>>();
    _interfaces.add(iface);
}

From source file:adalid.core.EntityAtlas.java

@SuppressWarnings("deprecation")
void initialiseFields(Class<?> clazz) {
    track("initialiseFields", _declaringArtifact, clazz.getSimpleName());
    Class<?> c;/*from   ww w .j a  v  a  2s.  c o  m*/
    int d, r;
    String name;
    String key;
    String pattern = "there are several fields for operation {0}";
    String message;
    Class<?> type;
    Class<?> decl;
    Class<?> operationClass;
    Field operationField;
    int modifiers;
    boolean restricted;
    Object o;
    int depth = _declaringArtifact.depth();
    int round = _declaringArtifact.round();
    Class<?>[] classes = new Class<?>[] { Property.class, Key.class, Tab.class, View.class, Instance.class,
            NamedValue.class, Expression.class, Transition.class, Operation.class, Trigger.class };
    Class<?> dac = _declaringArtifact.getClass();
    Class<?> top = Entity.class;
    int i = ArrayUtils.indexOf(classes, clazz);
    if (i != ArrayUtils.INDEX_NOT_FOUND) {
        c = classes[i];
        for (Field field : XS1.getFields(dac, top)) {
            field.setAccessible(true);
            logger.trace(field);
            name = field.getName();
            type = field.getType();
            decl = field.getDeclaringClass();
            if (!c.isAssignableFrom(type)) {
                continue;
            }
            if (c.equals(Expression.class) && Property.class.isAssignableFrom(type)) {
                continue;
            }
            // TODO: extension handling
            if (field.isAnnotationPresent(Extension.class) && Entity.class.isAssignableFrom(type)) {
                //                  if (!dac.equals(decl) || !dac.isAssignableFrom(type)) {
                //                      continue;
                //                  }
                continue;
            }
            modifiers = type.getModifiers();
            if (NamedValue.class.isAssignableFrom(type) || Expression.class.isAssignableFrom(type)) {
                restricted = false;
            } else {
                restricted = type.isInterface() || Modifier.isAbstract(modifiers);
            }
            restricted = restricted || !Modifier.isPublic(modifiers);
            if (restricted) {
                continue;
            }
            modifiers = field.getModifiers();
            restricted = Modifier.isPrivate(modifiers);
            if (restricted) {
                continue;
            }
            restricted = Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers);
            if (restricted) {
                continue;
            }
            if (Operation.class.isAssignableFrom(type)) {
                key = type.getSimpleName();
                operationClass = _operationClasses.get(key);
                if (operationClass != null) {
                    operationField = _operationFields.get(key);
                    if (operationField == null) {
                        _operationFields.put(key, field);
                    } else {
                        message = MessageFormat.format(pattern, operationClass.getName());
                        logger.warn(message);
                        TLC.getProject().getParser().increaseWarningCount();
                    }
                }
            }
            String errmsg = "failed to create a new instance of field \"" + field + "\" at "
                    + _declaringArtifact;
            try {
                o = field.get(_declaringArtifact);
                if (o == null) {
                    logger.debug(message(type, name, o, depth, round));
                    o = XS1.initialiseField(_declaringArtifact, field);
                    if (o == null) {
                        logger.debug(message(type, name, o, depth, round));
                        //                          throw new RuntimeException(message(type, name, o, depth, round));
                    } else {
                        logger.debug(message(type, name, o, depth, round));
                        field.set(_declaringArtifact, o);
                    }
                }
            } catch (IllegalArgumentException | IllegalAccessException ex) {
                throw new InstantiationRuntimeException(errmsg, ex);
            }
        }
    }
}

From source file:com.alibaba.fastjson.parser.ParserConfig.java

public ObjectDeserializer createJavaBeanDeserializer(Class<?> clazz, Type type) {
    boolean asmEnable = this.asmEnable & !this.fieldBased;
    if (asmEnable) {
        JSONType jsonType = TypeUtils.getAnnotation(clazz, JSONType.class);

        if (jsonType != null) {
            Class<?> deserializerClass = jsonType.deserializer();
            if (deserializerClass != Void.class) {
                try {
                    Object deseralizer = deserializerClass.newInstance();
                    if (deseralizer instanceof ObjectDeserializer) {
                        return (ObjectDeserializer) deseralizer;
                    }//w w w .  j  av  a  2s.co m
                } catch (Throwable e) {
                    // skip
                }
            }

            asmEnable = jsonType.asm();
        }

        if (asmEnable) {
            Class<?> superClass = JavaBeanInfo.getBuilderClass(clazz, jsonType);
            if (superClass == null) {
                superClass = clazz;
            }

            for (;;) {
                if (!Modifier.isPublic(superClass.getModifiers())) {
                    asmEnable = false;
                    break;
                }

                superClass = superClass.getSuperclass();
                if (superClass == Object.class || superClass == null) {
                    break;
                }
            }
        }
    }

    if (clazz.getTypeParameters().length != 0) {
        asmEnable = false;
    }

    if (asmEnable && asmFactory != null && asmFactory.classLoader.isExternalClass(clazz)) {
        asmEnable = false;
    }

    if (asmEnable) {
        asmEnable = ASMUtils.checkName(clazz.getSimpleName());
    }

    if (asmEnable) {
        if (clazz.isInterface()) {
            asmEnable = false;
        }
        JavaBeanInfo beanInfo = JavaBeanInfo.build(clazz, type, propertyNamingStrategy);

        if (asmEnable && beanInfo.fields.length > 200) {
            asmEnable = false;
        }

        Constructor<?> defaultConstructor = beanInfo.defaultConstructor;
        if (asmEnable && defaultConstructor == null && !clazz.isInterface()) {
            asmEnable = false;
        }

        for (FieldInfo fieldInfo : beanInfo.fields) {
            if (fieldInfo.getOnly) {
                asmEnable = false;
                break;
            }

            Class<?> fieldClass = fieldInfo.fieldClass;
            if (!Modifier.isPublic(fieldClass.getModifiers())) {
                asmEnable = false;
                break;
            }

            if (fieldClass.isMemberClass() && !Modifier.isStatic(fieldClass.getModifiers())) {
                asmEnable = false;
                break;
            }

            if (fieldInfo.getMember() != null //
                    && !ASMUtils.checkName(fieldInfo.getMember().getName())) {
                asmEnable = false;
                break;
            }

            JSONField annotation = fieldInfo.getAnnotation();
            if (annotation != null //
                    && ((!ASMUtils.checkName(annotation.name())) //
                            || annotation.format().length() != 0 //
                            || annotation.deserializeUsing() != Void.class //
                            || annotation.unwrapped())
                    || (fieldInfo.method != null && fieldInfo.method.getParameterTypes().length > 1)) {
                asmEnable = false;
                break;
            }

            if (fieldClass.isEnum()) { // EnumDeserializer
                ObjectDeserializer fieldDeser = this.getDeserializer(fieldClass);
                if (!(fieldDeser instanceof EnumDeserializer)) {
                    asmEnable = false;
                    break;
                }
            }
        }
    }

    if (asmEnable) {
        if (clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers())) {
            asmEnable = false;
        }
    }

    if (!asmEnable) {
        return new JavaBeanDeserializer(this, clazz, type);
    }

    JavaBeanInfo beanInfo = JavaBeanInfo.build(clazz, type, propertyNamingStrategy);
    try {
        return asmFactory.createJavaBeanDeserializer(this, beanInfo);
        // } catch (VerifyError e) {
        // e.printStackTrace();
        // return new JavaBeanDeserializer(this, clazz, type);
    } catch (NoSuchMethodException ex) {
        return new JavaBeanDeserializer(this, clazz, type);
    } catch (JSONException asmError) {
        return new JavaBeanDeserializer(this, beanInfo);
    } catch (Exception e) {
        throw new JSONException("create asm deserializer error, " + clazz.getName(), e);
    }
}