How can I define a clojure type that implements the servlet interface? -


I use java to implement Java class to deftype (using bleeding edge closure branch 1.2) The service interface I am looking forward to would compile the code below (though this is not very useful)

  (ns foo [: import [javax.servlet servlet servletreequest servletResponse]]) . (Deftype servlet [] javax. Servlet service (service [this # javax.servlet.ServletRequest request # ^ javax.servlet.ServletResponse response]))  

but it does not compile is. The compiler produces the message:

  Unmatched type of return: Service, expected: zero, was: java.lang.Object [Third class java.lang.IllegalArgumentException]  

That which I do not understand, because I am returning to zero. Therefore the fact is that the return type of method should not be zero without a problem. For example, for the java.util.Set interface:

  (deftype bar [# ^ number n] java.util.Set (clear [this] zero))  < / Ex> 

compile without problem.

So am I doing wrong in the Servlet interface?

To be clear: I know that the typical case is to use abstract squares instead of directly implementing this interface, but it is still possible to do this.

Stack trace:

(The stack trace for DFTPP servlet ... is:

  Mismatched Returns Type: Service, Expectation: Zero, was: java.lang.Object [Throwing class java.lang.IllegalArgumentException] Restart: 0: [abortion] Return to the top level of mud-traceback: 0: clojure.lang.Compiler $ Neinstansemethodakpars (Kmpailrkjawa:646l) 1: Clojrklangkkmpailr $ Neinstanseksprkbild (Kmpailrkjawa:6ll9) 2: Clojrklangkkmpailr $ Neinstansekspr $ Defteepeprserkpars (Kmpailrkjawa:6003) 3: Clojrklang. Kmpailrkanlyrzesek (Kmpailrkjawa:5289) 4: Clojrklangkkmpailr.analaij (Kmpailrkjawa:5ll0) 5: Clojrklangkkmpailr.analaij (Kmpailrkjawa:507l) 6: Closure. Lang.compiler Eval (Compiler.java) 34347): clojure.lang.Compiler.eval (Compiler.java:5334) 8: clojure.lang.Compiler.eval (Compiler.java:5311) 9: clojure.core $ eval__4350.invoke ( Core.clj: 2364) 10: swank.commands.basic $ eval_region__673.in Kawok (originally .clj: 40) 11: swank.commands.basic $ eval_region__6 73.invoke (basic.clj: 31) 12: swank.commands. Basic $ Avl__686 $ Listner_avl__687kinvoke (Besikkclj: 54) 13: Clojrklangkwarkinvoke (Warkjawa:365) 14: Fu $ Avl__2285kinvoke (No_sors_fail) 15: Clojrklangkkmpailr.avl ( Compiler.java TS343) 16: clojure.lang.Compiler.eval (Compiler.java:5311) 17: clojure.core $ eval__4350.invoke (core. Cluj: 2364) 18: Swankkkor $ Avl_in_maks_packej__320kinvoke (Korkclj: 59) 19: Swankkkor $ Avl_for_maks__383kinvoke (Korkclj: 128) 20: Clojrklangkwarkinvoke (Warkjawa: 373) 21: clojure.lang.AFn.applyToHelper (AFn.java:169) 22: clojure.lang.Var.applyTo (Var.java:482) 23: clojure.core $ apply__3776.invoke (core.clj: 535) 24: Swankkkor $ Avl_from_kantrol__322kinvoke (Korkclj: 66) 25: Swankkkor $ Avl_lup__324kinvoke (Korkclj: 71) 26: Swankkkor $ Span_repl_thred__434 $ Fn__464 $ Fn__465kinvoke (Korkclj: 183) 27: clojure.lang.AFn.applyToHelper (AFn.java:159) 28: clojure.lang.AFn.applyTo (AFn.java.11) 29: clojure.core $ apply__3776.invoke (core.clj: 535) 30: Swankkkor $ SPV N_repl_thred__434 $ Fn__464kdoinvoke (Korkclj: 180) 31: Clojrklangkrestfnkinvoke (Restfnkjawa:398) 32: Clojrklangkafnkrn (Afnkjawa:24 ) 33: java.lang Thread.Run (Thread.Java: 637)  

Try any signals without Do:

  (deftype servlet [] javax.servlet.Servlet (service [this request response] ... body ...))  

  • If you skip all the signals: will try to match the same name / erit method in the interface

    • If you supply all the signs at all, then no estimates have been made. Therefore, all hints (the default of the object) must be correct, both logic and return type

and (doc deftype ) From :

If they have not been supplied, they will be estimated, therefore the type signal should be reserved for non-suspension.


Comments