define-simple-class + Java enum as annotation value = invalid Java class created
Vladimir Tsichevski
tsichevski@gmail.com
Mon Nov 5 18:29:00 GMT 2012
Hi Per,
thank you for quick response!
I've just compiled the same Test class from Java source, and compared
the result classes. I've noticed in the class produced with Kawa direct
class name used:
javax/xml/bind/annotation/XmlAccessType
where in Java-originated class goes class spec:
Ljavax/xml/bind/annotation/XmlAccessType;
As to all the module-related stuff. In this particular case I'm not
interested in classes other than produced by define-simple-class.
Anyway, I've followed your advise. Unfortunately, renaming the .scm file
did not help :-(
Regards,
Vladimir
PS: you've done an excellent work, and I'm glad to have a chance to
return back to Kawa again after 8 years :-)
On 05.11.2012 20:47, Per Bothner wrote:
> On 11/05/2012 06:22 AM, Vladimir Tsichevski wrote:
>> Hi all,
>>
>> I'm trying to generate an annotated Java class:
>>
>> (define-alias XmlAccessType javax.xml.bind.annotation.XmlAccessType)
>> (define-alias XmlAccessorType javax.xml.bind.annotation.XmlAccessorType)
>>
>> (define-simple-class <Test> ()
>> (@XmlAccessorType value: XmlAccessType:FIELD)
>> )
>> ;; (compile-file "scratch.scm" "out.zip")
>>
>> where XmlAccessType is enum:
>>
>> public enum XmlAccessType {
>> PROPERTY,
>> FIELD,
>> PUBLIC_MEMBER,
>> NONE
>> }
>>
>> This results in a broken Java class "Test".
>
> Broken how?
>
> The class Test is not a stand-alone class - it is not a
> "module class" The module class (by default) is a class
> that matches the name of the source file scratch.scm
> - i.e. scratch.class. Things might work better if you
> rename scratch.scm to Test.scm so they match.
>
> You might want to (re-)read:
> http://www.gnu.org/software/kawa/Module-classes.html
>
> This is a source of confusion and a semi-frequently asked question.
> It might be worthwhile for the Kawa compiler to emit some extra
> code in Test.class's static initializer so it forces initialization
> of tyhe module class scratch.class first.
More information about the Kawa
mailing list