Search in sources :

Example 1 with MalformedParameterizedTypeException

use of java.lang.reflect.MalformedParameterizedTypeException in project j2objc by google.

the class MalformedParameterizedTypeExceptionTest method testMalformedParameterizedTypeException.

/**
     * java.lang.reflect.MalformedParameterizedTypeException#
     * MalformedParameterizedTypeException()
     */
public void testMalformedParameterizedTypeException() {
    MalformedParameterizedTypeException e = new MalformedParameterizedTypeException();
    assertNotNull(e);
    assertNull(e.getMessage());
}
Also used : MalformedParameterizedTypeException(java.lang.reflect.MalformedParameterizedTypeException)

Example 2 with MalformedParameterizedTypeException

use of java.lang.reflect.MalformedParameterizedTypeException in project groovy by apache.

the class Java5 method configureClassNode.

public void configureClassNode(CompileUnit compileUnit, ClassNode classNode) {
    try {
        Class clazz = classNode.getTypeClass();
        Field[] fields = clazz.getDeclaredFields();
        for (Field f : fields) {
            ClassNode ret = makeClassNode(compileUnit, f.getGenericType(), f.getType());
            FieldNode fn = new FieldNode(f.getName(), f.getModifiers(), ret, classNode, null);
            setAnnotationMetaData(f.getAnnotations(), fn);
            classNode.addField(fn);
        }
        Method[] methods = clazz.getDeclaredMethods();
        for (Method m : methods) {
            ClassNode ret = makeClassNode(compileUnit, m.getGenericReturnType(), m.getReturnType());
            Parameter[] params = makeParameters(compileUnit, m.getGenericParameterTypes(), m.getParameterTypes(), m.getParameterAnnotations());
            ClassNode[] exceptions = makeClassNodes(compileUnit, m.getGenericExceptionTypes(), m.getExceptionTypes());
            MethodNode mn = new MethodNode(m.getName(), m.getModifiers(), ret, params, exceptions, null);
            mn.setSynthetic(m.isSynthetic());
            setMethodDefaultValue(mn, m);
            setAnnotationMetaData(m.getAnnotations(), mn);
            mn.setGenericsTypes(configureTypeVariable(m.getTypeParameters()));
            classNode.addMethod(mn);
        }
        Constructor[] constructors = clazz.getDeclaredConstructors();
        for (Constructor ctor : constructors) {
            Parameter[] params = makeParameters(compileUnit, ctor.getGenericParameterTypes(), ctor.getParameterTypes(), ctor.getParameterAnnotations());
            ClassNode[] exceptions = makeClassNodes(compileUnit, ctor.getGenericExceptionTypes(), ctor.getExceptionTypes());
            classNode.addConstructor(ctor.getModifiers(), params, exceptions, null);
        }
        Class sc = clazz.getSuperclass();
        if (sc != null)
            classNode.setUnresolvedSuperClass(makeClassNode(compileUnit, clazz.getGenericSuperclass(), sc));
        makeInterfaceTypes(compileUnit, classNode, clazz);
        setAnnotationMetaData(classNode.getTypeClass().getAnnotations(), classNode);
        PackageNode packageNode = classNode.getPackage();
        if (packageNode != null) {
            setAnnotationMetaData(classNode.getTypeClass().getPackage().getAnnotations(), packageNode);
        }
    } catch (NoClassDefFoundError e) {
        throw new NoClassDefFoundError("Unable to load class " + classNode.toString(false) + " due to missing dependency " + e.getMessage());
    } catch (MalformedParameterizedTypeException e) {
        throw new RuntimeException("Unable to configure class node for class " + classNode.toString(false) + " due to malformed parameterized types", e);
    }
}
Also used : ClassNode(org.codehaus.groovy.ast.ClassNode) MalformedParameterizedTypeException(java.lang.reflect.MalformedParameterizedTypeException) FieldNode(org.codehaus.groovy.ast.FieldNode) Constructor(java.lang.reflect.Constructor) Method(java.lang.reflect.Method) Field(java.lang.reflect.Field) MethodNode(org.codehaus.groovy.ast.MethodNode) Parameter(org.codehaus.groovy.ast.Parameter) PackageNode(org.codehaus.groovy.ast.PackageNode)

Aggregations

MalformedParameterizedTypeException (java.lang.reflect.MalformedParameterizedTypeException)2 Constructor (java.lang.reflect.Constructor)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 ClassNode (org.codehaus.groovy.ast.ClassNode)1 FieldNode (org.codehaus.groovy.ast.FieldNode)1 MethodNode (org.codehaus.groovy.ast.MethodNode)1 PackageNode (org.codehaus.groovy.ast.PackageNode)1 Parameter (org.codehaus.groovy.ast.Parameter)1