Kalle Richter [https://community.jboss.org/people/krichter] created the discussion
"mapping of parameter and generic parameter types" To view the discussion, visit: https://community.jboss.org/message/749365#749365 -------------------------------------------------------------- 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]; cloneConstructor1.addParameter(pool.get(List.class.getName())); cloneConstructor1.addParameter(pool.get(Set.class.getName())); Class clazz1 = clone1.toClass(); System.out.println(clazz1.getConstructors()[0].getParameterTypes().length); System.out.println(clazz1.getConstructors()[0].getGenericParameterTypes().length); } 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()) { ctClass.defrost(); } ctClass.getClassFile().write(classFileStream); byte[] classFileBytes = classFileByteStream.toByteArray(); InputStream classFileCloneStream = new ByteArrayInputStream(classFileBytes); CtClass retValue = pool.makeClass(classFileCloneStream); retValue.setName(ctClass.getName()+"V"+classNameSuffix++); 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 -------------------------------------------------------------- Reply to this message by going to Community [https://community.jboss.org/message/749365#749365] Start a new discussion in Javassist at Community [https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2062]
_______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user