Bug-Report: No matching method found

42 views
Skip to first unread message

ntu...@googlemail.com

unread,
Aug 13, 2008, 4:34:59 AM8/13/08
to Clojure
user=> (. (new StringBuilder) (length))
java.lang.IllegalArgumentException: No matching method found: length
java.lang.IllegalArgumentException: No matching method found: length
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:44)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at user.eval__2221.invoke(Unknown Source)
at clojure.lang.Compiler.eval(Compiler.java:3847)
at clojure.lang.Repl.main(Repl.java:75)

Cf. http://java.sun.com/javase/6/docs/api/java/lang/StringBuilder.html#length()

Rich Hickey

unread,
Aug 13, 2008, 7:56:28 AM8/13/08
to Clojure


On Aug 13, 4:34 am, "ntu...@googlemail.com" <ntu...@googlemail.com>
wrote:
> user=> (. (new StringBuilder) (length))
> java.lang.IllegalArgumentException: No matching method found: length


Works for me:

user=> (. (new StringBuilder) (length))
0


Rich

Parth Malwankar

unread,
Aug 13, 2008, 8:08:55 AM8/13/08
to Clojure
I am seeing the same error on Debian.:

user=> (. (new StringBuilder) (length))
java.lang.IllegalArgumentException: No matching method found: length
java.lang.IllegalArgumentException: No matching method found: length
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:
44)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:
28)
at user.eval__2149.invoke(Unknown Source)
at clojure.lang.Compiler.eval(Compiler.java:3847)
at clojure.lang.Repl.main(Repl.java:75)
user=>

[parth:~/src/clojure]% svn info
Path: .
URL: https://clojure.svn.sourceforge.net/svnroot/clojure/trunk
Repository Root: https://clojure.svn.sourceforge.net/svnroot/clojure
Repository UUID: b4165764-bd0f-0410-b771-ab16a44d2305
Revision: 998
Node Kind: directory
Schedule: normal
Last Changed Author: rhickey
Last Changed Rev: 998
Last Changed Date: 2008-08-13 01:56:17 +0530 (Wed, 13 Aug 2008)

[parth:~/src/clojure]%

ntu...@googlemail.com

unread,
Aug 13, 2008, 8:33:23 AM8/13/08
to Clojure
On Aug 13, 1:56 pm, Rich Hickey <richhic...@gmail.com> wrote:
> Works for me:
>
> user=> (. (new StringBuilder) (length))
> 0

Apparently the reason why the length method is not considered is
because in static public List getMethods(Class c, int arity, String
name, boolean getStatics); the test !
Modifier.isVolatile(allmethods[i].getModifiers()) returns false.
allmethods[i].getModifiers() returns 4161. Maybe that's different in
your environment? I am running java version "1.6.0_06" on Ubuntu 8.04
i386.

Thanks.

Rich Hickey

unread,
Aug 13, 2008, 10:42:26 AM8/13/08
to Clojure


On Aug 13, 8:33 am, "ntu...@googlemail.com" <ntu...@googlemail.com>
wrote:
Aargh. I can reproduce with JDK 6 on OS X.

This has to do with bridge method handling, which I added specifically
to deal with StringBuilder and similar situations. Unfortunately, JDK
6 has very different modifiers than JDK 5 for StringBuilder.

If you have both JDKs, try this in each and compare the results to see
what I'm up against:

(dorun
(map #(println (Integer/toString (.getModifiers %) 16) \tab (str %))
(sort-by #(vector (.getName %) (str %))
(seq (.getMethods (identity StringBuilder))))))

Working on a work-around now,

Rich

ntu...@googlemail.com

unread,
Aug 13, 2008, 11:01:30 AM8/13/08
to Clojure
On Aug 13, 4:42 pm, Rich Hickey <richhic...@gmail.com> wrote:
> If you have both JDKs, try this in each and compare the results to see
> what I'm up against:
>
> (dorun
>  (map #(println (Integer/toString (.getModifiers %) 16) \tab (str %))
>       (sort-by #(vector (.getName %) (str %))
>                (seq (.getMethods (identity StringBuilder))))))
>

Did just that. Unfortuantely Google Groups does not allow me to attach
files to postings. I instead uploaded the results as jdk5.txt and
jdk6.txt to this groups files section.

> Working on a work-around now,

Many thanks.

Rich Hickey

unread,
Aug 13, 2008, 11:07:33 AM8/13/08
to Clojure


On Aug 13, 11:01 am, "ntu...@googlemail.com" <ntu...@googlemail.com>
wrote:
Fix is up - thanks for the report.

Rich

ntupel

unread,
Aug 13, 2008, 2:54:24 PM8/13/08
to clo...@googlegroups.com
On Wed, 2008-08-13 at 08:07 -0700, Rich Hickey wrote:
> Fix is up - thanks for the report.

Thanks for your quick response.


Reply all
Reply to author
Forward
0 new messages