Clojure

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

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4
  • Fix Version/s: None
  • Component/s: None
  • Labels:

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.

Activity

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: