Re: Re: annotations
Peter Veentjer <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Hi Niels, although I have no direct answer to your question, I can help to ease the pain of debugging. The ASM jar you are currently using doesn't contain debug information so the stacktrace is quite useless since it doesn't contain line numbers. In the ASM distribution, you can find a ASM jar containing debug information. If you combine this jar with the ASM sources in your IDE, you can browse the ASM code and have a better idea what is causing the problem. Success with your problem. On Thu, Jan 28, 2010 at 5:19 PM, Niels Boldt <[email protected]> wrote: > H, > > Sorry for my previous message, somehow hitted send before it as ready > > I'm using version 1.5.3 > > I'm quite new to asm and are currently wrestling with generation of > annotations on my classes, It goes quite well with annotations like > > @Entity( name="AdGamer" ) > > that pretty much resmembles the example at > http://asm.ow2.org/doc/tutorial-annotations.html, however when I try to > create annotation that contains enums, like > > @ManyToOne( optional = false , cascade=CascadeType.PERSIST ) > > I get an error message like > > java.lang.IllegalArgumentException: value SINGLE_TABLE > at org.objectweb.asm.ClassWriter.newConstItem(Unknown Source) > at org.objectweb.asm.ClassWriter.newConst(Unknown Source) > at org.objectweb.asm.attrs.Annotation.writeValue(Unknown Source) > > ... > > I generate the annotations with the following code that run for each > annotation of the class and then iterate through all methods of the > java.reflect.Annotation > > org.objectweb.asm.attrs.Annotation attr = new > org.objectweb.asm.attrs.Annotation("L" + > annotation.annotationType().getName().replace(".", "/") + ";"); > ........ > //get all the methods > try { > if( !"hashCode".equals( m.getName() ) && > !"equals".equals( m.getName() ) && !"toString".equals( m.getName() ) && > !"annotationType".equals( m.getName() ) ){ > Object o = m.invoke( annotation , null ); > attr.add( m.getName() , o ); > } > } > catch( Exception exc ){ > throw new RuntimeException( exc ); > } > > My error is probably related to the way I use attr.add, but the problem is > that I don't understand this method or the way annotations are structured. > The ASMifierClassVisitor does not help me as it ignores complex attributes, > in other case it has been a great help. > > If anyone could point me in the right direction, or provide a link to an > example etc I would be most thankful > > Best Regards > Niels > -- > BinaryConstructors ApS > Vestergade 10a, 4th > 1456 Kbh K > Denmark > phone: +4528138757 > web: http://www.binaryconstructors.dk > mail: [email protected] > skype: nielsboldt > > > -- > You receive this message as a subscriber of the [email protected] mailing list. > To unsubscribe: mailto:[email protected] > For general help: mailto:[email protected]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > >
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws