[JBoss-user] [Javassist user questions] - Re: inserting duplicated members
I've tested javassist 3 (beta), recompiling my sources with the above library, but the behavior of the shown code has not changed. I've substituted the aPool.write() call with a call toBytecode() over the CtClass object, but I'm still able to copy duplicated members as detailed in previous posts. Any idea? Thanks, Luca View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=3836951#3836951 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3836951 --- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149alloc_id=8166op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [Javassist user questions] - Re: inserting duplicated members
Well, I suppose it suffices the field_info is different, since even adding fields of the same type works. I've tried it both with a primitice type (an int) and an object (a string), both with the same name and the same access specifier (even if this should not change things) and it works. Luca View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=3836021#3836021 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3836021 --- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149alloc_id=8166op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [Javassist user questions] - Re: inserting duplicated members
Well, src and dest are different CtClass, I mean they are produced from different classes. When I try to define the class, in my classloader, as: /* create the pools */ ClassPool aPool=ClassPool.getDefault(); this.addClasspathToPoll(aPool); . byte[] code= aPool.write(className); return this.defineClass(className,code,0,code.length); I got the exception, if the code produced by the pool is related to a class manipulate with two method with the same signature. Is the above the code you were looking for? Thanks, Luca View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=3835659#3835659 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3835659 --- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149alloc_id=8166op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [Javassist user questions] - Re: inserting duplicated members
Here is my thought. The JVM throws an exception if a class has two methods with the same name and signature becuase such a class cannot pass the bytecode verification. This is the spec. I guess the reason that the JVM accepts a class that has two fields with the same name is because the JVM wrongly ignore such duplicated fields, i.e. this is a bug of the JVM. I don't know. Anyway, if you use Javassist 3.0, Javassist does not allow you to create such borken classes! Please try it. View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=3835688#3835688 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3835688 --- This SF.Net email is sponsored by: Oracle 10g Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE. http://ads.osdn.com/?ad_id=3149alloc_id=8166op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [Javassist user questions] - Re: inserting duplicated members
Are src and dest different CtClass objects? If yes, the problem is not adding copied methods. I think maybe your way of using a class loader is somewhat wrong. Can you show me the code that throws ClassFormatError? View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=3835505#3835505 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3835505 --- This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months! http://ads.osdn.com/?ad_id=2562alloc_id=6184op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [Javassist user questions] - Re: inserting duplicated members
I have just released 3.0 beta! This version rejects such a duplicated member. In principle, you can add a duplicated member to a class file but the JVM will reject that class file since it does not pass bytecode verification. View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=3835331#3835331 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3835331 --- This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months! http://ads.osdn.com/?ad_id=2562alloc_id=6184op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [Javassist user questions] - Re: inserting duplicated members
Maybe I'm misunderstanding but I've the following code to work on my system: CtField fields[]=src.getDeclaredFields(); CtField addingField=null; for(int i=0;ifields.length;i++) { addingField=new CtField(fields.getType(),fields.getName(),dest); addingField.setModifiers(fields.getModifiers()); dest.addField(addingField); } supposing src and dest are CtClass objects. Now what I cannot understand is why the system is allowing me to copy (and create) objects from the dest class even if the I copy duplicated fields (I mean fields with the same name but different type) from src to dest. Moreover, if I try something similar with methods: CtMethod toAdd[]=src.getDeclaredMethods(); CtMethod copy=null; for(int i=0;itoAdd.length;i++) { copy=CtNewMethod.copy(toAdd,dest,null); dest.addMethod(copy); } and the method has the same signature of another one, which already exists in src, I got an ClassFormatException during creation. Why this does not happen with the fields? Hope someone can explain me this. Luca View the original post : http://www.jboss.org/index.html?module=bbop=viewtopicp=3835345#3835345 Reply to the post : http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3835345 --- This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months! http://ads.osdn.com/?ad_id=2562alloc_id=6184op=click ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user