[jboss-jira] [JBoss JIRA] (JASSIST-167) GenericSignatureFormatError when calling Field.getDeclaredAnnotations() on javassist field/annotation

Jeffrey Selk (JIRA) jira-events at lists.jboss.org
Mon May 14 10:22:18 EDT 2012


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

Jeffrey Selk updated JASSIST-167:
---------------------------------

    Steps to Reproduce: 
{code:title=Example.java|borderStyle=solid}
try {
            ClassPool pool = ClassPool.getDefault();
            CtClass bean = pool.makeClass("com.mytestcase.test.TestClass");
            String fieldCode = "private java.lang.String myString;";
            CtField field = CtField.make(fieldCode, bean);
            bean.addField(field);
            ConstPool constPool = field.getFieldInfo().getConstPool();
            AnnotationsAttribute annoAttr = new AnnotationsAttribute(constPool,
                    AnnotationsAttribute.visibleTag);
            javassist.bytecode.annotation.Annotation annot = new javassist.bytecode.annotation.Annotation(
                    java.lang.annotation.Retention.class.getName(), constPool);
            EnumMemberValue e = new EnumMemberValue(constPool);
            e.setType(java.lang.annotation.RetentionPolicy.class.toString());
            e.setValue("RUNTIME");
            annot.addMemberValue("value", e);
            field.getFieldInfo().addAttribute(annoAttr);
            annoAttr.addAnnotation(annot);

            Class<?> builtClass = bean.toClass();
            builtClass.getDeclaredFields()[0].getDeclaredAnnotations(); // throws Exception
        } catch (CannotCompileException e) {
            e.printStackTrace();
        }
{code}


  was:
try {
            ClassPool pool = ClassPool.getDefault();
            CtClass bean = pool.makeClass("com.mytestcase.test.TestClass");
            String fieldCode = "private java.lang.String myString;";
            CtField field = CtField.make(fieldCode, bean);
            bean.addField(field);
            ConstPool constPool = field.getFieldInfo().getConstPool();
            AnnotationsAttribute annoAttr = new AnnotationsAttribute(constPool,
                    AnnotationsAttribute.visibleTag);
            javassist.bytecode.annotation.Annotation annot = new javassist.bytecode.annotation.Annotation(
                    java.lang.annotation.Retention.class.getName(), constPool);
            EnumMemberValue e = new EnumMemberValue(constPool);
            e.setType(java.lang.annotation.RetentionPolicy.class.toString());
            e.setValue("RUNTIME");
            annot.addMemberValue("value", e);
            field.getFieldInfo().addAttribute(annoAttr);
            annoAttr.addAnnotation(annot);

            Class<?> builtClass = bean.toClass();
            builtClass.getDeclaredFields()[0].getDeclaredAnnotations(); // throws Exception
        } catch (CannotCompileException e) {
            e.printStackTrace();
        }




    
> GenericSignatureFormatError when calling Field.getDeclaredAnnotations() on javassist field/annotation
> -----------------------------------------------------------------------------------------------------
>
>                 Key: JASSIST-167
>                 URL: https://issues.jboss.org/browse/JASSIST-167
>             Project: Javassist
>          Issue Type: Bug
>    Affects Versions: 3.12.0.GA
>         Environment: CentOS release 6.2 x64
> Linux tucker 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux
> java version "1.6.0_31"
> Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
> Java HotSpot(TM) Server VM (build 20.6-b01, mixed mode)
>            Reporter: Jeffrey Selk
>            Assignee: Shigeru Chiba
>
> Using javassist to create a Field with an Annotation on it, and the Annotation contains a member that is an Enumeration, after the class is created a GenericSignatureFormatError is thrown when trying to introspect the Field.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list