0 Replies Latest reply on Jul 21, 2012 2:50 AM by Kalle Richter

    mapping of parameter and generic parameter types

    Kalle Richter Newbie

      Hallo together,

      I'm wondering whether the length of the arrays returned by java.lang.reflect.Constructor.getParameterTypes() and getGenericParameterTypes() should be always equal, i.e. whether it's a bug if they're not or whether I'm doing something wrong. You can run the program below and you'll understand my problem immediately


      package org.h9t2.javassistbug;
      import java.io.*;
      import java.util.List;
      import java.util.Set;
      import javassist.*;
      public class App {
          private final static ClassPool pool = ClassPool.getDefault();
          public static void main( String[] args ) throws NotFoundException, IOException, CannotCompileException 
              CtClass ctClass1 = pool.get(Clazz.class.getName());
              CtClass clone1 = createClone(ctClass1);
              CtConstructor cloneConstructor1 = clone1.getConstructors()[0];
              Class clazz1 = clone1.toClass();
          private static int classNameSuffix = 1;
          private static CtClass createClone(CtClass ctClass) throws IOException {
              ByteArrayOutputStream classFileByteStream =new ByteArrayOutputStream();
              DataOutputStream classFileStream = new DataOutputStream(classFileByteStream);
              if(ctClass.isFrozen()) {
              byte[] classFileBytes = classFileByteStream.toByteArray();
              InputStream classFileCloneStream = new ByteArrayInputStream(classFileBytes);
              CtClass retValue = pool.makeClass(classFileCloneStream);
              return retValue;
      class Clazz {
          public Clazz(
              List<Boolean> parameter0,
              int b
          ) {}


      Or is it the fault of my createClone method?


      Any help or hint is appreciated


      Best regards