com.fasterxml.jackson.databind.introspect.AnnotatedClass Java Examples

The following examples show how to use com.fasterxml.jackson.databind.introspect.AnnotatedClass. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RegistrationExtensionClientInputDeserializer.java    From webauthn4j with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public RegistrationExtensionClientInput<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

    String name = p.getParsingContext().getCurrentName();
    if (name == null) {
        name = p.getParsingContext().getParent().getCurrentName();
    }

    DeserializationConfig config = ctxt.getConfig();
    AnnotatedClass annotatedClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, RegistrationExtensionClientInput.class);
    Collection<NamedType> namedTypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, annotatedClass);

    for (NamedType namedType : namedTypes) {
        if (Objects.equals(namedType.getName(), name)) {
            return (RegistrationExtensionClientInput<?>) ctxt.readValue(p, namedType.getType());
        }
    }

    logger.warn("Unknown extension '{}' is contained.", name);
    return ctxt.readValue(p, UnknownExtensionClientInput.class);
}
 
Example #2
Source File: RootNameLookup.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public PropertyName findRootName(Class<?> rootType, MapperConfig<?> config)
{
    ClassKey key = new ClassKey(rootType);
    PropertyName name = _rootNames.get(key); 
    if (name != null) {
        return name;
    }
    BeanDescription beanDesc = config.introspectClassAnnotations(rootType);
    AnnotationIntrospector intr = config.getAnnotationIntrospector();
    AnnotatedClass ac = beanDesc.getClassInfo();
    name = intr.findRootName(ac);
    // No answer so far? Let's just default to using simple class name
    if (name == null || !name.hasSimpleName()) {
        // Should we strip out enclosing class tho? For now, nope:
        name = PropertyName.construct(rootType.getSimpleName());
    }
    _rootNames.put(key, name);
    return name;
}
 
Example #3
Source File: ResourceFieldNameTransformer.java    From katharsis-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Extract name to be used by Katharsis from getter's name. It uses
 * {@link ResourceFieldNameTransformer#getMethodName(Method)}, {@link JsonProperty} annotation and
 * {@link PropertyNamingStrategy}.
 *
 * @param method method to extract name
 * @return method name
 */
public String getName(Method method) {
    String name = getMethodName(method);

    if (method.isAnnotationPresent(JsonProperty.class) &&
        !"".equals(method.getAnnotation(JsonProperty.class).value())) {
        name = method.getAnnotation(JsonProperty.class).value();
    } else if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
        Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
        AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);

        int paramsLength = method.getParameterAnnotations().length;
        AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
        for (int i = 0; i < paramsLength; i++) {
            AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
            paramAnnotations[i] = parameterAnnotationMap;
        }

        AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
        AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
        name = serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name);
    }
    return name;
}
 
Example #4
Source File: JacksonResourceFieldInformationProvider.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
protected Optional<String> getName(Method method) {
	ObjectMapper objectMapper = context.getObjectMapper();
	SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
	if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
		String name = ClassUtils.getGetterFieldName(method);
		Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
		AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);

		int paramsLength = method.getParameterAnnotations().length;
		AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
		for (int i = 0; i < paramsLength; i++) {
			AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
			paramAnnotations[i] = parameterAnnotationMap;
		}

		AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
		AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
		return Optional.of(serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name));
	}
	return Optional.empty();
}
 
Example #5
Source File: JavaTimeModule.java    From jackson-modules-java8 with Apache License 2.0 6 votes vote down vote up
protected AnnotatedMethod _findFactory(AnnotatedClass cls, String name, Class<?>... argTypes)
{
    final int argCount = argTypes.length;
    for (AnnotatedMethod method : cls.getFactoryMethods()) {
        if (!name.equals(method.getName())
                || (method.getParameterCount() != argCount)) {
            continue;
        }
        for (int i = 0; i < argCount; ++i) {
            Class<?> argType = method.getParameter(i).getRawType();
            if (!argType.isAssignableFrom(argTypes[i])) {
                continue;
            }
        }
        return method;
    }
    return null;
}
 
Example #6
Source File: TestJaxbAnnotationIntrospector.java    From jackson-modules-base with Apache License 2.0 6 votes vote down vote up
/**
 * Additional simple tests to ensure we will retain basic namespace information
 * now that it can be included
 */
public void testNamespaces() throws Exception
{
    final TypeFactory tf = MAPPER.getTypeFactory();
    JaxbAnnotationIntrospector ai = new JaxbAnnotationIntrospector();
    AnnotatedClass ac = AnnotatedClassResolver.resolve(MAPPER.serializationConfig(),
            tf.constructType(NamespaceBean.class), null);
    AnnotatedField af = _findField(ac, "string");
    assertNotNull(af);
    PropertyName pn = ai.findNameForDeserialization(MAPPER.serializationConfig(), af);
    assertNotNull(pn);

    // JAXB seems to assert field name instead of giving "use default"...
    assertEquals("", pn.getSimpleName());
    assertEquals("urn:method", pn.getNamespace());
}
 
Example #7
Source File: BQTimeModule.java    From bootique with Apache License 2.0 6 votes vote down vote up
protected AnnotatedMethod _findFactory(AnnotatedClass cls, String name, Class<?>... argTypes) {
    final int argCount = argTypes.length;
    for (AnnotatedMethod method : cls.getFactoryMethods()) {
        if (!name.equals(method.getName())
                || (method.getParameterCount() != argCount)) {
            continue;
        }
        for (int i = 0; i < argCount; ++i) {
            Class<?> argType = method.getParameter(i).getRawType();
            if (!argType.isAssignableFrom(argTypes[i])) {
                continue;
            }
        }
        return method;
    }
    return null;
}
 
Example #8
Source File: ExtensionClientOutputDeserializer.java    From webauthn4j with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ExtensionClientOutput<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

    String name = p.getParsingContext().getCurrentName();
    if (name == null) {
        name = p.getParsingContext().getParent().getCurrentName();
    }

    DeserializationConfig config = ctxt.getConfig();
    AnnotatedClass annotatedClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, ExtensionClientOutput.class);
    Collection<NamedType> namedTypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, annotatedClass);

    for (NamedType namedType : namedTypes) {
        if (Objects.equals(namedType.getName(), name)) {
            return (ExtensionClientOutput<?>) ctxt.readValue(p, namedType.getType());
        }
    }

    logger.warn("Unknown extension '{}' is contained.", name);
    return ctxt.readValue(p, UnknownExtensionClientOutput.class);
}
 
Example #9
Source File: AuthenticationExtensionClientInputDeserializer.java    From webauthn4j with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AuthenticationExtensionClientInput<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

    String name = p.getParsingContext().getCurrentName();
    if (name == null) {
        name = p.getParsingContext().getParent().getCurrentName();
    }

    DeserializationConfig config = ctxt.getConfig();
    AnnotatedClass annotatedClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, AuthenticationExtensionClientInput.class);
    Collection<NamedType> namedTypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, annotatedClass);

    for (NamedType namedType : namedTypes) {
        if (Objects.equals(namedType.getName(), name)) {
            return (AuthenticationExtensionClientInput<?>) ctxt.readValue(p, namedType.getType());
        }
    }

    logger.warn("Unknown extension '{}' is contained.", name);
    return ctxt.readValue(p, UnknownExtensionClientInput.class);
}
 
Example #10
Source File: ExtensionClientInputDeserializer.java    From webauthn4j with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ExtensionClientInput<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

    String name = p.getParsingContext().getCurrentName();
    if (name == null) {
        name = p.getParsingContext().getParent().getCurrentName();
    }

    DeserializationConfig config = ctxt.getConfig();
    AnnotatedClass annotatedClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, ExtensionClientInput.class);
    Collection<NamedType> namedTypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, annotatedClass);

    for (NamedType namedType : namedTypes) {
        if (Objects.equals(namedType.getName(), name)) {
            return (ExtensionClientInput<?>) ctxt.readValue(p, namedType.getType());
        }
    }

    logger.warn("Unknown extension '{}' is contained.", name);
    return ctxt.readValue(p, UnknownExtensionClientInput.class);
}
 
Example #11
Source File: ExtensionAuthenticatorOutputDeserializer.java    From webauthn4j with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ExtensionAuthenticatorOutput<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

    String name = p.getParsingContext().getCurrentName();
    if (name == null) {
        name = p.getParsingContext().getParent().getCurrentName();
    }

    DeserializationConfig config = ctxt.getConfig();
    AnnotatedClass annotatedClass = AnnotatedClassResolver.resolveWithoutSuperTypes(config, ExtensionAuthenticatorOutput.class);
    Collection<NamedType> namedTypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, annotatedClass);

    for (NamedType namedType : namedTypes) {
        if (Objects.equals(namedType.getName(), name)) {
            return (ExtensionAuthenticatorOutput<?>) ctxt.readValue(p, namedType.getType());
        }
    }

    logger.warn("Unknown extension '{}' is contained.", name);
    return ctxt.readValue(p, UnknownExtensionAuthenticatorOutput.class);
}
 
Example #12
Source File: AnnotatedClassBuilder.java    From crnk-framework with Apache License 2.0 6 votes vote down vote up
public static AnnotatedClass build(final Class<?> declaringClass, final SerializationConfig serializationConfig) {

		for (final Method method : AnnotatedClass.class.getMethods()) {
			if (CONSTRUCT_METHOD_NAME.equals(method.getName()) &&
					method.getParameterTypes().length == 3) {

				return ExceptionUtil.wrapCatchedExceptions(new Callable<AnnotatedClass>() {
					@Override
					public AnnotatedClass call() throws Exception {
						return buildAnnotatedClass(method, declaringClass, serializationConfig);
					}
				}, "Exception while building AnnotatedClass");
			}
		}
		throw new IllegalStateException(CANNOT_FIND_PROPER_METHOD);
	}
 
Example #13
Source File: AnnotatedFieldBuilder.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
private static AnnotatedField buildAnnotatedField(AnnotatedClass annotatedClass, Field field,
                                                  AnnotationMap annotationMap, Constructor<?> constructor)
        throws IllegalAccessException, InstantiationException, InvocationTargetException {
    Class<?> firstParameterType = constructor.getParameterTypes()[0];
    if (firstParameterType == AnnotatedClass.class ||
            "TypeResolutionContext".equals(firstParameterType.getSimpleName())) {
        return (AnnotatedField) constructor.newInstance(annotatedClass, field, annotationMap);
    } else {
        throw new InternalException(CANNOT_FIND_PROPER_CONSTRUCTOR);
    }
}
 
Example #14
Source File: VirtualPropertiesWriterTest.java    From log4j2-elasticsearch with Apache License 2.0 5 votes vote down vote up
@Test
public void writerCreatedWithDeprecatedConstructorWritesGivenProperties() throws Exception {

    // given
    ObjectMapper objectMapper = new ObjectMapper();
    SerializationConfig config = objectMapper.getSerializationConfig();

    JavaType javaType = config.constructType(LogEvent.class);
    AnnotatedClass annotatedClass = createTestAnnotatedClass(config, javaType);

    SimpleBeanPropertyDefinition simpleBeanPropertyDefinition =
            getTestBeanPropertyDefinition(config, javaType, annotatedClass);

    String expectedName = UUID.randomUUID().toString();
    String expectedValue = UUID.randomUUID().toString();
    VirtualProperty virtualProperty = spy(createNonDynamicVirtualProperty(expectedName, expectedValue));

    ValueResolver valueResolver = createTestValueResolver(virtualProperty, expectedValue);

    VirtualPropertiesWriter writer = new VirtualPropertiesWriter(
            simpleBeanPropertyDefinition,
            new AnnotationCollector.OneAnnotation(
                    annotatedClass.getRawType(),
                    annotatedClass.getAnnotations().get(JsonAppend.class)
            ),
            javaType,
            new VirtualProperty[] { virtualProperty },
            valueResolver
    );

    JsonGenerator jsonGenerator = mock(JsonGenerator.class);

    // when
    writer.serializeAsField(new Object(), jsonGenerator, mock(SerializerProvider.class));

    // then
    verify(jsonGenerator).writeFieldName(eq(expectedName));
    verify(jsonGenerator).writeString(eq(expectedValue));

}
 
Example #15
Source File: JacksonResourceFieldInformationProvider.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
protected Optional<String> getName(Field field) {
	ObjectMapper objectMapper = context.getObjectMapper();
	SerializationConfig serializationConfig = objectMapper.getSerializationConfig();

	if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
		AnnotationMap annotationMap = buildAnnotationMap(field.getDeclaredAnnotations());

		AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(field.getDeclaringClass(), serializationConfig);
		AnnotatedField annotatedField = AnnotatedFieldBuilder.build(annotatedClass, field, annotationMap);
		return Optional.of(serializationConfig.getPropertyNamingStrategy().nameForField(serializationConfig, annotatedField, field.getName()));
	}
	return Optional.empty();
}
 
Example #16
Source File: VirtualPropertiesWriterTest.java    From log4j2-elasticsearch with Apache License 2.0 5 votes vote down vote up
private SimpleBeanPropertyDefinition getTestBeanPropertyDefinition(SerializationConfig config, JavaType javaType, AnnotatedClass annotatedClass) {
    return SimpleBeanPropertyDefinition.construct(
            config,
            new VirtualAnnotatedMember(
                    annotatedClass,
                    LogEvent.class,
                    "virtualProperties",
                    javaType
            )
    );
}
 
Example #17
Source File: VirtualPropertiesWriterTest.java    From log4j2-elasticsearch with Apache License 2.0 5 votes vote down vote up
private AnnotatedClass createTestAnnotatedClass(SerializationConfig config, JavaType javaType) {
    return AnnotatedClassResolver.resolve(
            config,
            javaType,
            null
    );
}
 
Example #18
Source File: EnhancedSwaggerAnnotationIntrospector.java    From swagger-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public PropertyName findRootName(AnnotatedClass ac) {
    ApiModel model = ac.getAnnotation(ApiModel.class);
    if (model != null) {
        return new PropertyName(model.value());
    } else {
        return super.findRootName(ac);
    }
}
 
Example #19
Source File: ResourceFieldNameTransformer.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
public String getName(Field field) {

        String name = field.getName();
        if (field.isAnnotationPresent(JsonProperty.class) &&
            !"".equals(field.getAnnotation(JsonProperty.class).value())) {
            name = field.getAnnotation(JsonProperty.class).value();
        } else if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
            AnnotationMap annotationMap = buildAnnotationMap(field.getDeclaredAnnotations());

            AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(field.getDeclaringClass(), serializationConfig);
            AnnotatedField annotatedField = AnnotatedFieldBuilder.build(annotatedClass, field, annotationMap);
            name = serializationConfig.getPropertyNamingStrategy().nameForField(serializationConfig, annotatedField, name);
        }
        return name;
    }
 
Example #20
Source File: AnnotatedClassBuilder.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
public static AnnotatedClass build(Class<?> declaringClass, SerializationConfig serializationConfig) {

        for (Method method : AnnotatedClass.class.getMethods()) {
            if (CONSTRUCT_METHOD_NAME.equals(method.getName()) &&
                method.getParameterTypes().length == 3) {
                try {
                    return buildAnnotatedClass(method, declaringClass, serializationConfig);
                } catch (InvocationTargetException | IllegalAccessException e) {
                    throw new InternalException("Exception while building " + AnnotatedClass.class.getCanonicalName(), e);
                }
            }
        }

        throw new InternalException(CANNOT_FIND_PROPER_METHOD);
    }
 
Example #21
Source File: AnnotatedClassBuilder.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
private static AnnotatedClass buildAnnotatedClass(Method method, Class<?> declaringClass,
                                                  SerializationConfig serializationConfig)
    throws InvocationTargetException, IllegalAccessException {
    if (method.getParameterTypes()[0] == Class.class) {
        return buildOldAnnotatedClass(method, declaringClass, serializationConfig);
    } else if (method.getParameterTypes()[0] == JavaType.class) {
        return buildNewAnnotatedClass(method, declaringClass, serializationConfig);
    } else {
        throw new InternalException(CANNOT_FIND_PROPER_METHOD);
    }
}
 
Example #22
Source File: AnnotatedClassBuilder.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
private static AnnotatedClass buildOldAnnotatedClass(Method method, Class<?> declaringClass,
                                                     SerializationConfig serializationConfig)
    throws InvocationTargetException, IllegalAccessException {
    boolean useAnnotations = serializationConfig.isAnnotationProcessingEnabled();
    AnnotationIntrospector aintr = useAnnotations ? serializationConfig.getAnnotationIntrospector() : null;
    return AnnotatedClass.class.cast(method.invoke(null, declaringClass, aintr, serializationConfig));
}
 
Example #23
Source File: AnnotatedFieldBuilder.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
public static AnnotatedField build(AnnotatedClass annotatedClass, Field field, AnnotationMap annotationMap) {
    for(Constructor<?> constructor : AnnotatedField.class.getConstructors()) {
        try {
            return buildAnnotatedField(annotatedClass, field, annotationMap, constructor);
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
            throw new InternalException("Exception while building " + AnnotatedField.class.getCanonicalName(), e);
        }
    }
    throw new InternalException(CANNOT_FIND_PROPER_CONSTRUCTOR);
}
 
Example #24
Source File: AnnotatedMethodBuilder.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
public static AnnotatedMethod build(AnnotatedClass annotatedClass, Method method, AnnotationMap annotationMap,
                                    AnnotationMap[] paramAnnotations) {
    for(Constructor<?> constructor : AnnotatedMethod.class.getConstructors()) {
        try {
            return buildAnnotatedField(annotatedClass, method, annotationMap, paramAnnotations, constructor);
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
            throw new InternalException("Exception while building " + AnnotatedMethod.class.getCanonicalName(), e);
        }
    }
    throw new InternalException(CANNOT_FIND_PROPER_CONSTRUCTOR);
}
 
Example #25
Source File: AnnotatedMethodBuilder.java    From katharsis-framework with Apache License 2.0 5 votes vote down vote up
private static AnnotatedMethod buildAnnotatedField(AnnotatedClass annotatedClass, Method method,
                                                   AnnotationMap annotationMap, AnnotationMap[] paramAnnotations,
                                                   Constructor<?> constructor)
        throws IllegalAccessException, InstantiationException, InvocationTargetException {
    Class<?> firstParameterType = constructor.getParameterTypes()[0];
    if (firstParameterType == AnnotatedClass.class ||
            "TypeResolutionContext".equals(firstParameterType.getSimpleName())) {
        return (AnnotatedMethod) constructor.newInstance(annotatedClass, method, annotationMap, paramAnnotations);
    } else {
        throw new InternalException(CANNOT_FIND_PROPER_CONSTRUCTOR);
    }
}
 
Example #26
Source File: ApiAnnotationIntrospector.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
@Nullable
private Transformer<?, ?> findSerializerInstance(Annotated a) {
  if (a instanceof AnnotatedClass) {
    AnnotatedClass clazz = (AnnotatedClass) a;
    List<Class<? extends Transformer<?, ?>>> serializerClasses =
        Serializers.getSerializerClasses(clazz.getRawType(), config);
    if (!serializerClasses.isEmpty()) {
      return Serializers.instantiate(serializerClasses.get(0), TypeToken.of(a.getRawType()));
    }
  }
  return null;
}
 
Example #27
Source File: TestVirtualProperties.java    From jackson-modules-base with Apache License 2.0 5 votes vote down vote up
@Override
public VirtualBeanPropertyWriter withConfig(MapperConfig<?> config,
        AnnotatedClass declaringClass, BeanPropertyDefinition propDef,
        JavaType type)
{
    return new CustomVProperty(propDef, declaringClass.getAnnotations(), type);
}
 
Example #28
Source File: TestJaxbAnnotationIntrospector.java    From jackson-modules-base with Apache License 2.0 5 votes vote down vote up
private AnnotatedField _findField(AnnotatedClass ac, String name)
{
    for (AnnotatedField af : ac.fields()) {
        if (name.equals(af.getName())) {
            return af;
        }
    }
    return null;
}
 
Example #29
Source File: AbstractTypeMaterializer.java    From jackson-modules-base with Apache License 2.0 5 votes vote down vote up
public Class<?> materializeGenericType(MapperConfig<?> config, JavaType type)
{
    Class<?> cls = type.getRawClass();
    // Two-phase processing here; first construct concrete intermediate type:
    String abstractName = _defaultPackage+"abstract." +cls.getName()+"_TYPE_RESOLVE";
    byte[] code = buildAbstractBase(type, abstractName);
    Class<?> raw = _classLoader.loadAndResolve(abstractName, code, cls);
    // and only with that intermediate non-generic type, do actual materialization
    AnnotatedClass ac = AnnotatedClassResolver.resolve(config,
            config.getTypeFactory().constructType(raw), config);
    return materializeRawType(config, ac);
}
 
Example #30
Source File: AbstractTypeMaterializer.java    From jackson-modules-base with Apache License 2.0 5 votes vote down vote up
/**
 * NOTE: should not be called for generic types.
 */
public Class<?> materializeRawType(MapperConfig<?> config, AnnotatedClass typeDef)
{
    final JavaType type = typeDef.getType();

    Class<?> rawType = type.getRawClass();
    String newName = _defaultPackage+rawType.getName();
    BeanBuilder builder = BeanBuilder.construct(config, type, typeDef);
    byte[] bytecode = builder.implement(isEnabled(Feature.FAIL_ON_UNMATERIALIZED_METHOD)).build(newName);
    return _classLoader.loadAndResolve(newName, bytecode, rawType);
}