Example #1
1
 private void makeInterfaceTypes(CompileUnit cu, ClassNode classNode, Class clazz) {
   Type[] interfaceTypes = clazz.getGenericInterfaces();
   if (interfaceTypes.length == 0) {
     classNode.setInterfaces(ClassNode.EMPTY_ARRAY);
   } else {
     ClassNode[] ret = new ClassNode[interfaceTypes.length];
     for (int i = 0; i < interfaceTypes.length; i++) {
       Type type = interfaceTypes[i];
       while (!(type instanceof Class)) {
         ParameterizedType pt = (ParameterizedType) type;
         Type t2 = pt.getRawType();
         if (t2 == type) {
           throw new GroovyBugError(
               "Cannot transform generic signature of "
                   + clazz
                   + " with generic interface "
                   + interfaceTypes[i]
                   + " to a class.");
         }
         type = t2;
       }
       ret[i] = makeClassNode(cu, interfaceTypes[i], (Class) type);
     }
     classNode.setInterfaces(ret);
   }
 }
Example #2
0
 private void makeInterfaceTypes(CompileUnit cu, ClassNode classNode, Class clazz) {
   Type[] interfaceTypes = clazz.getGenericInterfaces();
   if (interfaceTypes.length == 0) {
     classNode.setInterfaces(ClassNode.EMPTY_ARRAY);
   } else {
     Class[] interfaceClasses = clazz.getInterfaces();
     ClassNode[] ret = new ClassNode[interfaceTypes.length];
     for (int i = 0; i < interfaceTypes.length; i++) {
       ret[i] = makeClassNode(cu, interfaceTypes[i], interfaceClasses[i]);
     }
     classNode.setInterfaces(ret);
   }
 }