On Sun, Jan 30, 2011 at 1:35 PM, Jonas Enlund <jonas.enl...@gmail.com> wrote:
> On Sun, Jan 30, 2011 at 7:01 PM, Ken Wesson <kwess...@gmail.com> wrote:
>> On Sun, Jan 30, 2011 at 9:26 AM, Jonas Enlund <jonas.enl...@gmail.com> wrote:
>>> Hi.
>>> I'm trying to create a java.io.Writer proxy (which writes to a
>>> JTextArea) but I can't get it to work.
>>> Here is my clojure code so far:
>>>
>>> (def text-area (javax.swing.JTextArea.))
>>>
>>> (def frame
>>>      (let [f (javax.swing.JFrame.)]
>>>        (.. f getContentPane (add text-area))
>>>        (.setMinimumSize f (java.awt.Dimension. 200 200))
>>>        (.setVisible f true)
>>>        f))
>>>
>>> (def text-area-writer
>>>      (proxy [java.io.Writer] []
>>>        (close [])
>>>        (flush [])
>>>        (write [^chars chrs ^int offs ^int len]
>>>          (.append text-area (String. chrs offs len)))))
>>>
>>> When I load the code above I get an "IllegalArgumentException: Unable
>>> to resolve classname: int" so I think I'm not type hinting correctly.
>>
>> Indeed. You can't (in 1.2 at least) type hint "int" though you can
>> "ints" (array of int). Note that int is a primitive type while array
>> of int is a reference type.
>>
>> Type hinting as Integer shouldn't throw exceptions, but you can
>> probably omit all but the chars hint and have the correct String
>> constructor overload selected.
>
> I tried with 1.3.0-alpha5. With type hints I get "CompilerException
> java.lang.IllegalArgumentException: Only long and double primitives
> are supported". If I only keep the ^chars hint I get an ArityException
> when I do (.write text-area-writer "hello").

Does it work with 1.2? Where exactly is the ArityException being
thrown -- for what function or method?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to