[jboss-cvs] JBossAS SVN: r105101 - in projects/jboss-reflect/trunk/src: main/java/org/jboss/reflect/plugins/introspection and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 21 11:28:35 EDT 2010


Author: kabir.khan at jboss.com
Date: 2010-05-21 11:28:34 -0400 (Fri, 21 May 2010)
New Revision: 105101

Removed:
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoEqualizer.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/LazyJavassistClassInfo.java
Modified:
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationValueFactory.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistClassInfo.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistMethodInfo.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
   projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/SignatureKey.java
   projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/test/AbstractBeanInfoTest.java
Log:
Commits 105097 onwards were in the wrong branch. reverted

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationValueFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationValueFactory.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/AnnotationValueFactory.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -56,7 +56,7 @@
    public static Value createValue(AnnotationHelper annotationHelper, TypeInfo type, Object value)
    {
       Value rtnValue = null;
-      if (type.isArray())
+      if (type instanceof ArrayInfo)
       {
          Object[] objects = getArray((ArrayInfo)type, value);
          Value[] values = new Value[objects.length];
@@ -66,7 +66,7 @@
          }
          rtnValue = new ArrayValueImpl(type, values);
       }
-      else if (type.isPrimitive())
+      else if (type instanceof PrimitiveInfo)
       {
          rtnValue = new PrimitiveValue(value.toString(), (PrimitiveInfo)type); 
       }
@@ -74,11 +74,11 @@
       {
          rtnValue = new StringValueImpl((String)value, type);
       }
-      else if (type.isAnnotation())
+      else if (type instanceof AnnotationInfo)
       {
          rtnValue = annotationHelper.createAnnotationValue((AnnotationInfo)type, value);
       }
-      else if (type.isEnum())
+      else if (type instanceof EnumInfo)
       {
          rtnValue = new EnumValueImpl(type, value.toString());
       }

Deleted: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoEqualizer.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoEqualizer.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/ClassInfoEqualizer.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -1,63 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.reflect.plugins;
-
-import org.jboss.reflect.plugins.introspection.ParameterizedClassInfo;
-import org.jboss.reflect.plugins.javassist.JavassistClassInfo;
-import org.jboss.reflect.plugins.javassist.JavassistParameterizedClassInfo;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.DelegateClassInfo;
-
-/**
- * A hacky attempt at unifying how we compare the different class infos
- * This will become a problem if unknown class infos are added...
- * 
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ClassInfoEqualizer
-{
-   public boolean equals(ClassInfo infoA, ClassInfo infoB)
-   {
-      if (infoA instanceof DelegateClassInfo && infoB instanceof DelegateClassInfo == false)
-      {
-         return infoA.getName().equals(infoB.getName());
-      }
-      if (infoA instanceof DelegateClassInfo == false && infoB instanceof DelegateClassInfo)
-      {
-         return infoA.getName().equals(infoB.getName());
-      }
-      if (infoA instanceof JavassistClassInfo && infoB instanceof JavassistClassInfo)
-      {
-         ((JavassistClassInfo)infoA).getClassSignature()
-      }
-      if (infoA instanceof DelegateClassInfo && infoB instanceof DelegateClassInfo)
-      {
-         if (infoA instanceof ParameterizedClassInfo && infoB instanceof ParameterizedClassInfo)
-         {
-            return ((ParameterizedClassInfo)infoA).getParameterizedType().equals(((ParameterizedClassInfo)infoB).getParameterizedType());
-         }
-      }
-      return false;
-   }
-}

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/introspection/ParameterizedClassInfo.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -153,9 +153,4 @@
    {
       buffer.append(parameterizedType);
    }
-   
-   public ParameterizedType getParameterizedType()
-   {
-      return parameterizedType;
-   }
 }

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistClassInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistClassInfo.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistClassInfo.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -30,7 +30,7 @@
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @version $Revision: 1.1 $
  */
-public interface JavassistClassInfo extends ClassInfo
+interface JavassistClassInfo extends ClassInfo
 {
    ClassSignature getClassSignature();
    

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistMethodInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistMethodInfo.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistMethodInfo.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -34,8 +34,6 @@
 import org.jboss.reflect.spi.MethodInfo;
 import org.jboss.reflect.spi.MutableMethodInfo;
 import org.jboss.reflect.spi.MutableMethodInfoCommand;
-import org.jboss.reflect.spi.NumberInfo;
-import org.jboss.reflect.spi.PrimitiveInfo;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.util.JBossStringBuilder;
 
@@ -86,7 +84,7 @@
       return name;
    }
 
-   public TypeInfo getReturnTypeOld()
+   public TypeInfo getReturnType()
    {
       if (returnType != null)
          return returnType;
@@ -97,76 +95,19 @@
          if (sig != null)
          {
             if (sig.getReturnType() instanceof BaseType == false)
-               returnType = typeInfo.getFactory().getTypeInfo(typeInfo.getClassLoaderInternal(), sig.getReturnType(), JavassistTypeVariableSpy.createForBehavior(((JavassistClassInfo)getDeclaringClass()).getClassSignature(), sig));
+               return typeInfo.getFactory().getTypeInfo(typeInfo.getClassLoaderInternal(), sig.getReturnType(), JavassistTypeVariableSpy.createForBehavior(((JavassistClassInfo)getDeclaringClass()).getClassSignature(), sig));
          }
 
-         if (returnType == null)
-         {
-            CtClass clazz = ctMethod.getReturnType();
-            returnType = typeInfo.getFactory().getTypeInfo(clazz);
-         }
+         CtClass clazz = ctMethod.getReturnType();
+         returnType = typeInfo.getFactory().getTypeInfo(clazz);
       }
       catch (NotFoundException e)
       {
          throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for return type of method " + getName(), e);
       }
-      
       return returnType;
    }
-   
-   public TypeInfo getReturnType()
-   {
-      if (returnType != null)
-         return returnType;
 
-      returnType = getLazyInfo(getSignatureKey(), -1);
-      return returnType;
-   }
-   
-   ClassInfo lazyLoadReturnType()
-   {
-      if (returnType instanceof LazyJavassistClassInfo)
-      {
-         TypeInfo returnType = null;
-         try
-         {
-            CtMethod ctMethod = (CtMethod)ctBehavior;
-            MethodSignature sig = getMethodSignature();
-            if (sig != null)
-            {
-               if (sig.getReturnType() instanceof BaseType == false)
-                  returnType = typeInfo.getFactory().getTypeInfo(typeInfo.getClassLoaderInternal(), sig.getReturnType(), JavassistTypeVariableSpy.createForBehavior(((JavassistClassInfo)getDeclaringClass()).getClassSignature(), sig));
-            }
-
-            if (returnType == null)
-            {
-               CtClass clazz = ctMethod.getReturnType();
-               returnType = typeInfo.getFactory().getTypeInfo(clazz);
-            }
-         }
-         catch (NotFoundException e)
-         {
-            throw JavassistTypeInfoFactoryImpl.raiseClassNotFound("for return type of method " + getName(), e);
-         }
-         this.returnType = returnType;
-      }
-      if (returnType instanceof ClassInfo == false)
-         throw new IllegalArgumentException(returnType + " is not an instance of ClassInfo");
-
-      return (ClassInfo)returnType;         
-   }
-   
-   private TypeInfo getLazyInfo(SignatureKey key, int index)
-   {
-      String param = index > 0 ? key.getParams()[index] : SignatureKey.getReturnType(ctBehavior);
-      
-      TypeInfo info = typeInfo.getFactory().getPrimitiveOrNumberInfo(param);
-      if (info != null)
-         return info;
-
-      return LazyJavassistClassInfo.createJavassistClassInfo(this, param, index);
-   }
-
    public Object invoke(Object target, Object[] args) throws Throwable
    {
       if (method == null)

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/JavassistTypeInfoFactoryImpl.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -454,10 +454,36 @@
       if (cl == null)
          throw new IllegalArgumentException("Null class loader");
       
-      TypeInfo number = getPrimitiveOrNumberInfo(name, cl, clazz);
+      TypeInfo primitive = PrimitiveInfo.valueOf(name);
+      if (primitive != null)
+         return primitive;
+
+      NumberInfo number = NumberInfo.valueOf(name);
       if (number != null)
-         return number;
-         
+      {
+         synchronized (number)
+         {
+            if (number.getPhase() != NumberInfo.Phase.INITIALIZING)
+            {
+               if (number.getPhase() != NumberInfo.Phase.COMPLETE)
+               {
+                  number.initializing();
+                  Class<?> useClass = clazz;
+                  try
+                  {
+                     if (useClass == null)
+                        useClass = cl.loadClass(name);
+                  }
+                  catch (ClassNotFoundException e)
+                  {
+                     throw new RuntimeException(e);
+                  }
+                  number.setDelegate(get(useClass));
+               }
+               return number;
+            }
+         }
+      }
       
       //Handle array names
       if (name.charAt(0) == '[')
@@ -511,48 +537,6 @@
       
       return result;
    }
-
-   TypeInfo getPrimitiveOrNumberInfo(String name)
-   {
-      return getPrimitiveOrNumberInfo(name, null, null);
-   }
-
-   protected TypeInfo getPrimitiveOrNumberInfo(String name, ClassLoader cl, Class<?> clazz)
-   {
-      TypeInfo primitive = PrimitiveInfo.valueOf(name);
-      if (primitive != null)
-         return primitive;
-
-      NumberInfo number = NumberInfo.valueOf(name);
-      if (number != null)
-      {
-         synchronized (number)
-         {
-            if (number.getPhase() != NumberInfo.Phase.INITIALIZING)
-            {
-               if (number.getPhase() != NumberInfo.Phase.COMPLETE)
-               {
-                  number.initializing();
-                  Class<?> useClass = clazz;
-                  try
-                  {
-                     if (cl == null)
-                        cl = SecurityActions.getContextClassLoader();
-                     if (useClass == null)
-                        useClass = cl.loadClass(name);
-                  }
-                  catch (ClassNotFoundException e)
-                  {
-                     throw new RuntimeException(e);
-                  }
-                  number.setDelegate(get(useClass));
-               }
-               return number;
-            }
-         }
-      }
-      return null;
-   }
    
    private ClassLoader getClassLoader(final TypeInfo info)
    {
@@ -587,6 +571,45 @@
     */
    private TypeInfo delegateToIntrospectionImplementation(ClassLoader cl, String name) throws ClassNotFoundException
    {
+//      System.out.println("======> " + name + " " + cl);
+//      
+//      //Extra code just for debugging
+//      ClassPool pool = poolFactory.getPoolForLoader(cl);
+//      try
+//      {
+//         CtClass ct = pool.get(name); 
+//      }
+//      catch(Exception alreadyHandled)
+//      {
+//         System.out.println("---> Not found in " + pool);
+//      }
+//      
+//      Class<?> clazz = cl.loadClass(name);
+//      System.out.println("---> Loaded real class from " + clazz.getClassLoader());
+//      
+//      try
+//      {
+//         CtClass ct = pool.get(name); 
+//      }
+//      catch(Exception alreadyHandled)
+//      {
+//         System.out.println("---> Not found again in " + pool);
+//      }
+//      
+//      pool = poolFactory.getPoolForLoader(clazz.getClassLoader());
+//      try
+//      {
+//         CtClass ct = pool.get(name); 
+//         System.out.println("---> Found in actual pool " + pool);
+//      }
+//      catch(Exception alreadyHandled)
+//      {
+//         System.out.println("---> Not found in actual pool " + pool);
+//      }
+//      
+
+      //Extra code - END
+      
       try
       {
          IntrospectionTypeInfoFactory factory = new IntrospectionTypeInfoFactory();

Deleted: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/LazyJavassistClassInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/LazyJavassistClassInfo.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/LazyJavassistClassInfo.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -1,554 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.reflect.plugins.javassist;
-
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.reflect.spi.AnnotationAttribute;
-import org.jboss.reflect.spi.AnnotationInfo;
-import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.ArrayInfo;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.DelegateClassInfo;
-import org.jboss.reflect.spi.EnumConstantInfo;
-import org.jboss.reflect.spi.EnumInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.InterfaceInfo;
-import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.PackageInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.util.JBossObject;
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * When calling getReturnType() or getParameterTypes() on JavassistConstructorInfo or JavassistMethodInfo
- * we are often only interested in the type so return this class to avoid having to load up everything from
- * the classpools and initializing the CtClass.ClassFile. If people call something more advanced
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public abstract class LazyJavassistClassInfo extends JBossObject implements ClassInfo, ArrayInfo, EnumInfo, InterfaceInfo, AnnotationInfo
-{
-   private static final long serialVersionUID = 1L;
-
-   private final String name;
-   
-   protected volatile ClassInfo delegate;
-   
-   protected LazyJavassistClassInfo(String name)
-   {
-      //super(null, true);
-      this.name = name;
-   }
-
-   public static LazyJavassistClassInfo createJavassistClassInfo(JavassistMethodInfo behavior, String name, int index)
-   {
-      return new LazyJavassistMethodClassInfo(behavior, name, index); 
-   }
-   
-   //Simple methods
-   
-   public String getName()
-   {
-      return name;
-   }
-
-   public String getSimpleName()
-   {
-      int index = name.lastIndexOf('.');
-      if (index < 0)
-          return name;
-      else
-          return name.substring(index + 1);
-   }
-
-   public boolean isPrimitive()
-   {
-      return false;
-   }
-
-   @Override
-   public void toShortString(JBossStringBuilder buffer)
-   {
-      buffer.append(getName());
-   }
-
-   @Override
-   protected void toString(JBossStringBuilder buffer)
-   {
-      buffer.append("name=").append(getName());
-   }
-
-   @Override
-   protected int getHashCode()
-   {
-      return getName().hashCode();
-   }
-
-   @Override
-   public boolean equals(Object obj)
-   {
-      if (obj == this)
-         return true;
-      if (obj == null || obj instanceof TypeInfo == false)
-         return false;
-
-      TypeInfo other = (TypeInfo) obj;
-      return getName().equals(other.getName());
-   }
-
-   public boolean equals(Object obj, Set<String> doneTypeVariables)
-   {
-      if (obj instanceof DelegateClassInfo && obj instanceof LazyJavassistClassInfo == false)
-         return ((DelegateClassInfo)obj).equals(this, doneTypeVariables);
-      return super.equals(obj, doneTypeVariables);
-   }
-
-   //The following methods need to load up the delegate
-   
-   public TypeInfo[] getActualTypeArguments()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getActualTypeArguments();
-   }
-
-   public TypeInfo getComponentType()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getComponentType();
-   }
-
-   public ConstructorInfo getDeclaredConstructor(TypeInfo... parameters)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getDeclaredConstructor(parameters);
-   }
-
-   public ConstructorInfo[] getDeclaredConstructors()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getDeclaredConstructors();
-   }
-   
-   public Object convertValue(Object value, boolean replaceProperties, boolean trim) throws Throwable
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.convertValue(value, replaceProperties, trim);
-   }
-
-   public Object convertValue(Object value, boolean replaceProperties) throws Throwable
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.convertValue(value, replaceProperties);
-   }
-
-   public Object convertValue(Object value) throws Throwable
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.convertValue(value);
-   }
-
-   public AnnotationValue getAnnotation(String name)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getAnnotation(name);
-   }
-
-   public AnnotationValue[] getAnnotations()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getAnnotations();
-   }
-
-   public TypeInfo getArrayType()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getArrayType();
-   }
-
-   public <T> T getAttachment(Class<T> expectedType)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getAttachment(expectedType);
-   }
-
-   public Object getAttachment(String name)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getAttachment(name);
-   }
-
-   public ClassLoader getClassLoader()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getClassLoader();
-   }
-
-   public FieldInfo getDeclaredField(String name)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getDeclaredField(name);
-   }
-
-   public FieldInfo[] getDeclaredFields()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getDeclaredFields();
-   }
-
-   public MethodInfo getDeclaredMethod(String name, TypeInfo... parameters)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getDeclaredMethod(name, parameters);
-   }
-
-   public MethodInfo[] getDeclaredMethods()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getDeclaredMethods();
-   }
-
-   public InterfaceInfo[] getGenericInterfaces()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getGenericInterfaces();
-   }
-
-   public ClassInfo getGenericSuperclass()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getGenericSuperclass();
-   }
-
-   public InterfaceInfo[] getInterfaces()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getInterfaces();
-   }
-
-   public TypeInfo getKeyType()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getKeyType();
-   }
-
-   public int getModifiers()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getModifiers();
-   }
-
-   public TypeInfo getOwnerType()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getOwnerType();
-   }
-
-   public PackageInfo getPackage()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getPackage();
-   }
-
-   public ClassInfo getRawType()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getRawType();
-   }
-
-   public ClassInfo getSuperclass()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getSuperclass();
-   }
-
-   public Class<?> getType()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getType();
-   }
-
-   public TypeInfoFactory getTypeInfoFactory()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getTypeInfoFactory();
-   }
-
-   public String getTypeVariable()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getTypeVariable();
-   }
-
-   public <T extends Annotation> T getUnderlyingAnnotation(Class<T> annotationType)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getUnderlyingAnnotation(annotationType);
-   }
-
-   public Annotation[] getUnderlyingAnnotations()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getUnderlyingAnnotations();
-   }
-
-   public TypeInfo getValueType()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.getValueType();
-   }
-
-   public boolean isAnnotation()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isAnnotation();
-   }
-
-   public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isAnnotationPresent(annotationType);
-   }
-
-   public boolean isAnnotationPresent(String name)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isAnnotationPresent(name);
-   }
-
-   public boolean isArray()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isArray();
-   }
-
-   public boolean isAssignableFrom(TypeInfo info)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isAssignableFrom(info);
-   }
-
-   public boolean isCollection()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isCollection();
-   }
-
-   public boolean isEnum()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isEnum();
-   }
-
-   public boolean isInstance(Object object)
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isInstance(object);
-   }
-
-   public boolean isInterface()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isInterface();
-   }
-
-   public boolean isMap()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isMap();
-   }
-
-   public boolean isPublic()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isPublic();
-   }
-
-   public boolean isStatic()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isStatic();
-   }
-
-   public boolean isVolatile()
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.isVolatile();
-   }
-
-   public Object newArrayInstance(int size) throws Throwable
-   {
-      if (delegate == null)
-         loadDelegate();
-      return delegate.newArrayInstance(size);
-   }
-
-   public void setAttachment(String name, Object attachment)
-   {
-      if (delegate == null)
-         loadDelegate();
-      delegate.setAttachment(name, attachment);
-   }
-   
-   public EnumConstantInfo getEnumConstant(String name)
-   {
-      if (delegate == null)
-         loadDelegate();
-      if (delegate instanceof EnumInfo)
-         return ((EnumInfo)delegate).getEnumConstant(name);
-      throw new IllegalStateException(delegate + " is not an EnumInfo");
-   }
-
-   public EnumConstantInfo[] getEnumConstants()
-   {
-      if (delegate == null)
-         loadDelegate();
-      if (delegate instanceof EnumInfo)
-         return ((EnumInfo)delegate).getEnumConstants();
-      throw new IllegalStateException(delegate + " is not an EnumInfo");
-   }
-
-   public Object getEnumValue(String name)
-   {
-      if (delegate == null)
-         loadDelegate();
-      if (delegate instanceof EnumInfo)
-         return ((EnumInfo)delegate).getEnumValue(name);
-      throw new IllegalStateException(delegate + " is not an EnumInfo");
-   }
-
-
-   public AnnotationAttribute getAttribute(String name)
-   {
-      if (delegate == null)
-         loadDelegate();
-      if (delegate instanceof AnnotationInfo)
-         return ((AnnotationInfo)delegate).getAttribute(name);
-      throw new IllegalStateException(delegate + " is not an AnnotationInfo");
-   }
-
-   public AnnotationAttribute[] getAttributes()
-   {
-      if (delegate == null)
-         loadDelegate();
-      if (delegate instanceof AnnotationInfo)
-         return ((AnnotationInfo)delegate).getAttributes();
-      throw new IllegalStateException(delegate + " is not an AnnotationInfo");
-   }
-   
-   protected abstract void loadDelegate();
-
-   private static class LazyJavassistBehaviorClassInfo extends LazyJavassistClassInfo
-   {
-      private static final long serialVersionUID = 1L;
-
-      protected final JavassistAnnotatedParameterInfo owner;
-      protected final int index;
-      
-      protected LazyJavassistBehaviorClassInfo(JavassistAnnotatedParameterInfo method, String name, int index)
-      {
-         super(name);
-         owner = method;
-         this.index = index;
-      }
-
-      @Override
-      protected void loadDelegate()
-      {
-            
-      }
-   }
-   
-   private static class LazyJavassistMethodClassInfo extends LazyJavassistBehaviorClassInfo
-   {
-      private static final long serialVersionUID = 1L;
-
-      protected LazyJavassistMethodClassInfo(JavassistMethodInfo method, String name, int index)
-      {
-         super(method, name, index);
-      }
-
-      @Override
-      protected void loadDelegate()
-      {
-         if (index >= 0)
-         {
-            super.loadDelegate();
-            return;
-         }
-           
-         delegate = ((JavassistMethodInfo)owner).lazyLoadReturnType();
-      }
-      
-   }
-   
-}

Modified: projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/SignatureKey.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/SignatureKey.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/main/java/org/jboss/reflect/plugins/javassist/SignatureKey.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -22,8 +22,6 @@
 package org.jboss.reflect.plugins.javassist;
 
 import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
 
 import javassist.CtBehavior;
 import javassist.bytecode.Descriptor;
@@ -40,26 +38,12 @@
  */
 public class SignatureKey
 {
-   private static final Set<String> primitives = new HashSet<String>();
-   static
-   {
-      primitives.add("boolean");
-      primitives.add("char");
-      primitives.add("byte");
-      primitives.add("short");
-      primitives.add("int");
-      primitives.add("long");
-      primitives.add("float");
-      primitives.add("double");
-      primitives.add("void");
-   }
-   
    /** The name */
-   final String name;
+   String name;
    
    /** The parameter names */
-   final String[] params;
-   
+   String[] params;
+
    /** The cached hashcode */
    private transient int cachedHashCode = Integer.MIN_VALUE;
    
@@ -188,19 +172,9 @@
          i = getParameterTypeString(desc, i, args, n++);
       }
       while (i > 0 && n < args.length);
-      
-      
       return args;
    }
 
-   public static String getReturnType(CtBehavior behavior)
-   {
-      String desc = behavior.getSignature();
-      String[] rtn = new String[1];
-      getParameterTypeString(desc, desc.indexOf(')') + 1, rtn, 0);
-      return rtn[0];
-   }
-   
    /**
     * Put the next argument into the parameter string array 
     * 
@@ -209,7 +183,7 @@
     * @param args the parameter string array
     * @param n the current index of the arguments array
     */
-   private static int getParameterTypeString(String desc, int i, String[] args, int n)
+   private int getParameterTypeString(String desc, int i, String[] args, int n)
    {
       int i2;
       String name;
@@ -270,7 +244,7 @@
     * @param the character for the primitive
     * @return the primitive real name
     */
-   private static String toPrimitiveClass(char c)
+   private String toPrimitiveClass(char c)
    {
       String type = null;
       switch (c)
@@ -323,9 +297,4 @@
    {
       return params[i].equals("long");
    }
-   
-   public static boolean isPrimitive(String param)
-   {
-      return primitives.contains(param);
-   }
 }

Modified: projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/test/AbstractBeanInfoTest.java
===================================================================
--- projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/test/AbstractBeanInfoTest.java	2010-05-21 15:23:24 UTC (rev 105100)
+++ projects/jboss-reflect/trunk/src/test/java/org/jboss/test/beaninfo/test/AbstractBeanInfoTest.java	2010-05-21 15:28:34 UTC (rev 105101)
@@ -167,26 +167,22 @@
          assertEmpty(actual);
          return;
       }
-      
-      //Extra debug code
-      
-      for (PropertyInfo expectedInfo : expected)
+      getLog().debug(clazz + " expected properties=" + expected + " actual=" + actual);
+      boolean equals = expected.equals(actual);
+      if (equals == false)
       {
-         for (PropertyInfo actualInfo : actual)
-         {
-            if (expectedInfo.getName().equals(actualInfo.getName()))
-            {
-               assertEquals(expectedInfo.hashCode(), actualInfo.hashCode());
-               assertEquals(expectedInfo, actualInfo);
-            }
-         }
+         System.out.println("expected = " + expected);
+         System.out.println("actual = " + actual);
+         
+         PropertyInfo[] expecteds = expected.toArray(new PropertyInfo[2]);
+         PropertyInfo[] actuals = actual.toArray(new PropertyInfo[2]);
+         
+         expected = getExpectedProperties(clazz, mode);
+         actual = beanInfo.getProperties();
       }
+      assertTrue(equals);
+//      assertEquals(expected, actual);
       
-      //Extra - end
-      
-      getLog().debug(clazz + " expected properties=" + expected + " actual=" + actual);
-      assertEquals(expected, actual);
-      
       HashMap<String, PropertyInfo> actualProps = new HashMap<String, PropertyInfo>();
       for (PropertyInfo prop : actual)
          actualProps.put(prop.getName(), prop);




More information about the jboss-cvs-commits mailing list