[CLJ-1130] Invoking a static method with the wrong number of arguments results in a NoSuchFieldException, rather than a proper message that the arguments could not be matched to the method Created: 17/Dec/12 Updated: 06/Jan/13 |
|
| Status: | Open |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | Release 1.4 |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Minor |
| Reporter: | Howard Lewis Ship | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | feedback | ||
| Description |
|
My code inadventently invoked a method that expected a single parameter, but passed no parameters. The exception: Exception in thread "main" java.lang.NoSuchFieldException: getService, compiling:(com/annadaletech/nexus/services/registry.clj:168) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6462) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6443) at clojure.lang.Compiler.analyze(Compiler.java:6262) at clojure.lang.Compiler.access$100(Compiler.java:37) at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:5883) .... Caused by: java.lang.NoSuchFieldException: getService at java.lang.Class.getField(Class.java:1520) at clojure.lang.Compiler$StaticFieldExpr.<init>(Compiler.java:1180) at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:923) at clojure.lang.Compiler.analyzeSeq(Compiler.java:6455) ... 78 more That threw me for a bit; really, it looks like the compiler is attempting to access a field and invoke it as an IFn. However, a proper message would be "getService() requires 1 parameter, not 0" (or something to that effect). Even "invalid number of parameters for SmashRuntime/getService()" would be better. |
| Comments |
| Comment by Michael Drogalis [ 06/Jan/13 6:44 PM ] |
|
It looks like it's first trying to resolve a field by name, since field access with / is legal. For example: user=> (Integer/parseInt) user=> (Integer/MAX_VALUE) Would trying to resolve a method before a field fix this? |