3 Replies Latest reply on Oct 18, 2004 12:22 PM by bill.burke

    Primitive types transparency

    jlukiano

      Hi,

      I'm pleased to join you here.

      I have a problem with the annotation Java 1.4 together with a Class[] parameter. My annotation is related to a refactoring initiative to avoid repeating all the lookup/narrow stuff when using EJB. The annotation tag is:

      @@annot.ejblookup (invocarConstrutorParmsArray={br.com.ilheus.hotels.HotelManagerHome,java.lang.String,float,
      net.sourceforge.junitejb.EJBTestCase,br.com.ilheus.hotels.ReservationLocalHome,int})
      
      Thus the annotation class is:
      
      package annot;
      public interface ejblookup {
       Class[] invocarConstrutorParmsArray();
      }
      

      The problem is:

      20:01:23,686 INFO [HomeLookupTest] Starting: testLookup
      20:01:23,702 INFO [STDOUT] java.lang.RuntimeException: java.lang.RuntimeExcepti
      on: java.lang.ClassNotFoundException: No ClassLoaders found for: float
      20:01:23,702 INFO [STDOUT] at org.jboss.aop.annotation.AnnotationElement.ge
      tVisibleAnnotation(AnnotationElement.java:92)
      20:01:23,702 INFO [STDOUT] at org.jboss.aop.annotation.AnnotationElement.ge
      tAnyAnnotation(AnnotationElement.java:107)
      20:01:23,702 INFO [STDOUT] at br.com.ilheus.hotels.aspects.EjbHomeLookupInt
      erceptor.invoke(EjbHomeLookupInterceptor.java:41)

      The AnnotationElement class don't deal correctly with primitive classes. The Class[] has the constructor parameters that should be invoked instead of the constructor annotated. The parameters should also be delegated and I don't want to refactor the primitive types to their wrapper classes. Moreover, the EJB dependencies would be provided in a IoC fashion.

      Maybe, it is a conceptual issue related to the reflection and the javassist API. Any clarification?

        • 1. Re: Primitive types transparency
          bill.burke

          Ok, that's a bug. I need to parse for float, int, etc...

          apologies.

          • 2. Re: Primitive types transparency
            jlukiano

            workaround: I used a comma-separated list as String

            String [] parms = annotejb.invocarConstrutorParms().split(",");
            Class [] parmsClassArray = new Class[parms.length];
            for (int i = 0; i < parms.length; i++) {
             if (parms.equals("char")) parmsClassArray = Character.TYPE;
             else if (parms.equals("byte")) parmsClassArray= Byte.TYPE;
             else if (parms.equals("short")) parmsClassArray = Short.TYPE;
             else if (parms.equals("int")) parmsClassArray = Integer.TYPE;
             else if (parms.equals("long")) parmsClassArray = Long.TYPE;
             else if (parms.equals("float")) parmsClassArray = Float.TYPE;
             else if (parms.equals("double")) parmsClassArray = Double.TYPE;
             else parmsClassArray = Class.forName(parms);
            }
            


            • 3. Re: Primitive types transparency
              bill.burke

              Finally got around to fixing this. Its in CVS now, will be in 1.0 Final release this week.

              Bill