3 Replies Latest reply on Oct 18, 2004 12:22 PM by Bill Burke

    Primitive types transparency

    jlukiano Newbie


      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,
      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
      20:01:23,702 INFO [STDOUT] at org.jboss.aop.annotation.AnnotationElement.ge
      20:01:23,702 INFO [STDOUT] at br.com.ilheus.hotels.aspects.EjbHomeLookupInt

      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 Master

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


          • 2. Re: Primitive types transparency
            jlukiano Newbie

            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 Master

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