Package org.jboss.reflect.spi

Examples of org.jboss.reflect.spi.TypeInfoFactory


      assertEquals(expected, actual);
   }
  
   protected void assertDeclaredFields(Class<?> clazz, ClassInfo classInfo) throws Throwable
   {
      TypeInfoFactory factory = getTypeInfoFactory();
      Set<FieldInfo> expected = new HashSet<FieldInfo>();
      for (Field field : clazz.getDeclaredFields())
      {
         TypeInfo type = factory.getTypeInfo(field.getGenericType());
         FieldInfo f = new FieldInfoImpl(null, field.getName(), type, field.getModifiers(), classInfo);
         expected.add(f);
      }
     
      FieldInfo[] result = classInfo.getDeclaredFields();
View Full Code Here


  
   protected void assertDeclaredField(Class<?> clazz, Field field, ClassInfo classInfo) throws Throwable
   {
      getLog().debug("Checking field " + field.getName());
     
      TypeInfoFactory factory = getTypeInfoFactory();
     
      FieldInfo fieldInfo = classInfo.getDeclaredField(field.getName());
      assertNotNull(field.getName(), fieldInfo);
      TypeInfo type = factory.getTypeInfo(field.getGenericType());
      assertTypeEquals(field.getName(), type, fieldInfo.getType());
      assertEquals(classInfo, fieldInfo.getDeclaringClass());
      assertEquals(field.getModifiers(), fieldInfo.getModifiers());
      assertFieldAnnotations(field, fieldInfo);
   }
View Full Code Here

      assertFieldAnnotations(field, fieldInfo);
   }
  
   protected void assertDeclaredMethods(Class<?> clazz, ClassInfo classInfo) throws Throwable
   {
      TypeInfoFactory factory = getTypeInfoFactory();
      Set<MethodInfo> expected = new HashSet<MethodInfo>();
      for (Method method : clazz.getDeclaredMethods())
      {
         TypeInfo returnType = factory.getTypeInfo(method.getReturnType());
         Class<?>[] paramClasses = method.getParameterTypes();
         TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
         AnnotationValue[][] paramAnnotations = new AnnotationValue[paramClasses.length][0];
         int i = 0;
         for (Class<?> c : paramClasses)
            paramTypes[i++] = factory.getTypeInfo(c);
         MethodInfo m = new MethodInfoImpl(null, method.getName(), returnType, paramTypes, paramAnnotations, null, method.getModifiers(), classInfo);
         expected.add(m);
      }
     
      MethodInfo[] result = classInfo.getDeclaredMethods();
View Full Code Here

  
   protected void assertDeclaredMethod(Class<?> clazz, Method method, ClassInfo classInfo) throws Throwable
   {
      getLog().debug("Checking method " + method.getName() + Arrays.asList(method.getParameterTypes()));

      TypeInfoFactory factory = getTypeInfoFactory();
     
      Type[] paramClasses = method.getGenericParameterTypes();
      TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
      for (int i = 0; i < paramClasses.length; ++i)
         paramTypes[i] = factory.getTypeInfo(paramClasses[i]);
      MethodInfo methodInfo = classInfo.getDeclaredMethod(method.getName(), paramTypes);
      assertNotNull(method.getName(), methodInfo);
      TypeInfo returnType = factory.getTypeInfo(method.getGenericReturnType());
      TypeInfo[] actualParamTypes = methodInfo.getParameterTypes();
      for (int i = 0; i < paramTypes.length; ++i)
         assertTypeEquals(method.getName() + " param" + i, paramTypes[i], actualParamTypes[i]);
      Class<?>[] exceptionClasses = method.getExceptionTypes();
      TypeInfo[] expectedExceptionTypes = new TypeInfo[exceptionClasses.length];
      for (int i = 0; i < exceptionClasses.length; ++i)
         expectedExceptionTypes[i] = factory.getTypeInfo(exceptionClasses[i]);
      TypeInfo[] actualExceptionTypes = methodInfo.getExceptionTypes();
      for (int i = 0; i < exceptionClasses.length; ++i)
         assertTypeEquals(method.getName() + " exception" + i, expectedExceptionTypes[i], actualExceptionTypes[i]);
      assertTypeEquals(method.getName() + " returnType", returnType, methodInfo.getReturnType());
      assertEquals(classInfo, methodInfo.getDeclaringClass());
View Full Code Here

      assertParameterAnnotations(method, methodInfo);
   }
  
   protected void assertDeclaredConstructors(Class<?> clazz, ClassInfo classInfo) throws Throwable
   {
      TypeInfoFactory factory = getTypeInfoFactory();
      Set<ConstructorInfo> expected = new HashSet<ConstructorInfo>();
      for (Constructor<?> constructor : clazz.getDeclaredConstructors())
      {
         Class<?>[] paramClasses = constructor.getParameterTypes();
         TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
         AnnotationValue[][] paramAnnotations = new AnnotationValue[paramClasses.length][0];
         int i = 0;
         for (Class<?> c : paramClasses)
            paramTypes[i++] = factory.getTypeInfo(c);
         ConstructorInfo c = new ConstructorInfoImpl(null, paramTypes, paramAnnotations, null, constructor.getModifiers(), classInfo);
         expected.add(c);
      }
     
      ConstructorInfo[] result = classInfo.getDeclaredConstructors();
View Full Code Here

  
   protected void assertDeclaredConstructor(Class<?> clazz, Constructor<?> constructor, ClassInfo classInfo) throws Throwable
   {
      getLog().debug("Checking constructor " + Arrays.asList(constructor.getParameterTypes()));

      TypeInfoFactory factory = getTypeInfoFactory();
     
      Type[] paramClasses = constructor.getGenericParameterTypes();
     
      // HACK: This is to workaround a bug in Sun's compiler related to enum constructors
      //       having no generic parameters?
      Type[] parameterTypes = constructor.getParameterTypes();
      if (paramClasses.length != parameterTypes.length)
         paramClasses = parameterTypes;
     
      TypeInfo[] paramTypes = new TypeInfo[paramClasses.length];
      for (int i = 0; i < paramClasses.length; ++i)
         paramTypes[i] = factory.getTypeInfo(paramClasses[i]);
      ConstructorInfo constructorInfo = classInfo.getDeclaredConstructor(paramTypes);
      assertNotNull(constructorInfo);
      TypeInfo[] actualParamTypes = constructorInfo.getParameterTypes();
      for (int i = 0; i < paramTypes.length; ++i)
         assertTypeEquals(clazz + " constructorParameter" + i, paramTypes[i], actualParamTypes[i]);
      Class<?>[] exceptionClasses = constructor.getExceptionTypes();
      TypeInfo[] expectedExceptionTypes = new TypeInfo[exceptionClasses.length];
      for (int i = 0; i < exceptionClasses.length; ++i)
         expectedExceptionTypes[i] = factory.getTypeInfo(exceptionClasses[i]);
      TypeInfo[] actualExceptionTypes = constructorInfo.getExceptionTypes();
      for (int i = 0; i < exceptionClasses.length; ++i)
         assertTypeEquals(clazz + " constructorException" + i, expectedExceptionTypes[i], actualExceptionTypes[i]);
      assertEquals(classInfo, constructorInfo.getDeclaringClass());
      assertEquals(constructor.getModifiers(), constructorInfo.getModifiers());
View Full Code Here

      super(name);
   }

   public void testByteArrayInfo()
   {
      TypeInfoFactory factory = getTypeInfoFactory();
      byte[] x = {};
      TypeInfo xinfo = factory.getTypeInfo(x.getClass());
      getLog().debug(xinfo);
      assertTrue(xinfo instanceof ArrayInfo);
      ArrayInfo ainfo = (ArrayInfo) xinfo;
      TypeInfo compType = ainfo.getComponentType();
      assertEquals(PrimitiveInfo.BYTE, compType);
View Full Code Here

      byte[] x = {};
      Class<?>[] parameterTypes = {x.getClass(), int.class, int.class};
      Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", parameterTypes);
      assertNotNull(defineClass);
      Class<?>[] types = defineClass.getParameterTypes();
      TypeInfoFactory factory = getTypeInfoFactory();
      TypeInfo arg0Info = factory.getTypeInfo(types[0]);
      assertTrue(arg0Info instanceof ArrayInfo);
      getLog().debug(arg0Info);
      ArrayInfo ainfo = (ArrayInfo) arg0Info;
      TypeInfo compType = ainfo.getComponentType();
      assertEquals(PrimitiveInfo.BYTE, compType);
View Full Code Here

      byte[] x = {};
      Class<?>[] parameterTypes = {x.getClass(), int.class, int.class};
      Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", parameterTypes);
      assertNotNull(defineClass);
      Type[] types = defineClass.getGenericParameterTypes();
      TypeInfoFactory factory = getTypeInfoFactory();
      TypeInfo arg0Info = factory.getTypeInfo(types[0]);
      assertTrue(arg0Info instanceof ArrayInfo);
      getLog().debug(arg0Info);
      ArrayInfo ainfo = (ArrayInfo) arg0Info;
      TypeInfo compType = ainfo.getComponentType();
      assertEquals(PrimitiveInfo.BYTE, compType);
View Full Code Here

      assertEquals(PrimitiveInfo.BYTE, compType);
   }

   protected ClassInfo getClassInfo(Class<?> clazz)
   {
      TypeInfoFactory factory = getTypeInfoFactory();
      TypeInfo info = factory.getTypeInfo(clazz);
      assertNotNull(info);
      assertTrue(info instanceof ClassInfo);
      ClassInfo cinfo = (ClassInfo) info;
      getLog().debug(cinfo);
      return cinfo;
View Full Code Here

TOP

Related Classes of org.jboss.reflect.spi.TypeInfoFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.