[jboss-jira] [JBoss JIRA] (JASSIST-226) automatical modification of class and method Annotation

Paolo Paolo (JIRA) issues at jboss.org
Mon Jun 30 06:37:27 EDT 2014


     [ https://issues.jboss.org/browse/JASSIST-226?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paolo Paolo updated JASSIST-226:
--------------------------------

    Description: 
I'm using Javassist to create .class file at runtime. Every method of the created class must have a Java Annotation ("@annotation example") with an URI. The problem is that the Annotation class modifies automatically the URI by substituting slashes with dots.

//the Annotation String that I need
@RDFBean('http://www.semanticweb.org/pi/2014/5/test#Test')
//the resulting String
@RDFBean('http:..www.semanticweb.org.pi.2014.5.test#Test')

Is there a way to prevent this String modification?
I suppose it's related to the different notation between a file path and a Java package.

This is the code:

ClassPool pool = ClassPool.getDefault();
CtClass cc = pool.makeClass(className);
		
ClassFile ccFile = cc.getClassFile();
ConstPool constpool = ccFile.getConstPool();

// create the annotation
AnnotationsAttribute attr = new AnnotationsAttribute(constpool, AnnotationsAttribute.visibleTag);
// classLocalName contains: http://www.semanticweb.org/pi/2014/5/test#Test
Annotation annot = new Annotation("RDFBean('"+classLocalName+"')", constpool);
attr.addAnnotation(annot);
ccFile.addAttribute(attr);



  was:
I'm using Javassist to create .class file at runtime. Every method of the created class must have a Java Annotation ("@annotation example") with an URI. The problem is that the Annotation class modifies automatically the URI by substituting slashes with dots.

//the Annotation String that I need
@RDFBean('http://www.semanticweb.org/pi/2014/5/test#Test')
//the resulting String
@RDFBean('http:..www.semanticweb.org.pi.2014.5.test#Test')

Is there a way to prevent this String modification?
I suppose it's related to the different notation between a file path and a Java package.



> automatical modification of class and method Annotation
> -------------------------------------------------------
>
>                 Key: JASSIST-226
>                 URL: https://issues.jboss.org/browse/JASSIST-226
>             Project: Javassist
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 3.18.0-GA
>         Environment: JavaSE-1.7, Eclipse Kepler
>            Reporter: Paolo Paolo
>            Assignee: Shigeru Chiba
>              Labels: annotations
>
> I'm using Javassist to create .class file at runtime. Every method of the created class must have a Java Annotation ("@annotation example") with an URI. The problem is that the Annotation class modifies automatically the URI by substituting slashes with dots.
> //the Annotation String that I need
> @RDFBean('http://www.semanticweb.org/pi/2014/5/test#Test')
> //the resulting String
> @RDFBean('http:..www.semanticweb.org.pi.2014.5.test#Test')
> Is there a way to prevent this String modification?
> I suppose it's related to the different notation between a file path and a Java package.
> This is the code:
> ClassPool pool = ClassPool.getDefault();
> CtClass cc = pool.makeClass(className);
> 		
> ClassFile ccFile = cc.getClassFile();
> ConstPool constpool = ccFile.getConstPool();
> // create the annotation
> AnnotationsAttribute attr = new AnnotationsAttribute(constpool, AnnotationsAttribute.visibleTag);
> // classLocalName contains: http://www.semanticweb.org/pi/2014/5/test#Test
> Annotation annot = new Annotation("RDFBean('"+classLocalName+"')", constpool);
> attr.addAnnotation(annot);
> ccFile.addAttribute(attr);



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the jboss-jira mailing list