Unable to find final method in superclass

110 views
Skip to first unread message

Pradeep Gollakota

unread,
May 19, 2014, 6:58:53 PM5/19/14
to clo...@googlegroups.com

Hi All,

I’m trying to work with NIO in Java 7, and I’m not able to access methods that are declared in the super class.

(.getPath (java.nio.file.FileSystems/getDefault) "/")

The above code throws the following Exception:

Exception in thread "main" java.lang.IllegalArgumentException: No matching method found: getPath for class sun.nio.fs.MacOSXFileSystem, compiling:(/private/var/folders/7t/hd4k0hbn4zx6hvdlhhglncwwnr07sd/T/form-init118501231724308669.clj:1:141)
    at clojure.lang.Compiler.load(Compiler.java:7142)
    at clojure.lang.Compiler.loadFile(Compiler.java:7086)
    at clojure.main$load_script.invoke(main.clj:274)
    at clojure.main$init_opt.invoke(main.clj:279)
    at clojure.main$initialize.invoke(main.clj:307)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.doInvoke(main.clj:420)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: No matching method found: getPath for class sun.nio.fs.MacOSXFileSystem
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:53)
    at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
    at filecollector.core$_main.doInvoke(core.clj:33)
    at clojure.lang.RestFn.invoke(RestFn.java:397)
    at clojure.lang.Var.invoke(Var.java:375)
    at user$eval5$fn__7.invoke(form-init118501231724308669.clj:1)
    at user$eval5.invoke(form-init118501231724308669.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6703)
    at clojure.lang.Compiler.eval(Compiler.java:6693)
    at clojure.lang.Compiler.load(Compiler.java:7130)
    ... 11 more

This seems to be related to the following JIRA CLJ-1243

Any thoughts on how to proceed?

Thanks,
Pradeep

Paul Richardson

unread,
May 19, 2014, 9:11:26 PM5/19/14
to clo...@googlegroups.com
Hi Pradeep,

The exception you are seeing happens when clojure can't find the correct method; this is often due to an "arity" mismatch, as is the case here.

.getPath expects two arguments: a String followed by a String array. Java makes the variadic parameter seem optional, but in clojure it must explicitly be there.

passing nil will get you an npe, but
(.getPath (java.nio.file.FileSystems/getDefault) "/" (make-array String 0))
should work. You could make yourself a convenience function if you're going to call it a lot.

Hope that helps you out

Paul

Pradeep Gollakota

unread,
May 19, 2014, 9:18:35 PM5/19/14
to clo...@googlegroups.com
Thank you very much Paul.

Worked like a charm!
Reply all
Reply to author
Forward
0 new messages