Ok, I found the problem. It is not specific to enumerations: Javassist doesn't
properly handle array classes.
For example, this code poses problems:
String[] theStrings = {"A", "B"};
theStrings = theStrings.clone();
The problem is that in the class file, the method call is represented like that:
16: invokevirtual #5; //Method
"[Ljava/lang/String;".clone:()Ljava/lang/Object;
So this is a call to method "clone" in class "[Ljava/lang/String;". And when
trying to retrieve the target class, MethodCall.getCtClass passes this
classname to ClassPool.get. But ClassPool.get doesn't understand this syntax:
it expects something like java.lang.String[]
So I see two ways to fix it:
- Either change MethodCall.getClassName so that it transforms
[Ljava.lang.String; to java.lang.String[]
- Change ClassPool.get() so that it accepts [Ljava.lang.String;
PS:
The reason why my original code worked with eclipse is that the eclipse
compiler doesn't produce the same bytecode for enums in the values() method:
Javac clones an array while eclipse instanciates a new array and does an
arraycopy.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3875208#3875208
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3875208
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user