Clojure interop:解决模糊方法

时间:2011-12-21 21:04:15

标签: tfs clojure interop

在Clojure中针对TFS SDK(对于java)进行编程,我想调用一个方法pendEdit,它有几个实现(从类com.microsoft.tfs.core.clients.versioncontrol.soapextensions.Workspace的javadoc复制):

int pendEdit(ItemSpec[] specs, LockLevel[] lockLevel, FileEncoding[] fileEncoding, GetOptions getOptions, PendChangesOptions pendOptions) 

int pendEdit(ItemSpec[] specs, LockLevel lockLevel, FileEncoding fileEncoding, GetOptions getOptions, PendChangesOptions pendOptions) 

int pendEdit(java.lang.String[] paths, RecursionType recursion, LockLevel[] lockLevel, FileEncoding[] fileEncoding, GetOptions getOptions, PendChangesOptions pendOptions) 

int pendEdit(java.lang.String[] paths, RecursionType recursion, LockLevel lockLevel, FileEncoding fileEncoding, GetOptions getOptions, PendChangesOptions pendOptions)

在我的解压中,我提出了以下代码 - 在我看来最像是类型提示:

(defn checkout-file [^Workspace workspace file]
  (let [spec ^ItemSpec (item-spec-file file)]
    (.pendEdit workspace
               ^"[Lcom.microsoft.tfs.core.clients.versioncontrol.specs.ItemSpec;" (into-array [spec])
               ^LockLevel LockLevel/NONE
               ^FileEncoding FileEncoding/AUTOMATICALLY_DETECT
               ^GetOptions GetOptions/NONE
               ^PendChangesOptions PendChangesOptions/NONE)))

即使这似乎也没有解决歧义 - 导致以下异常:

Exception in thread "main" java.lang.NullPointerException (ts_files.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:5440)
        at clojure.lang.Compiler.load(Compiler.java:5857)
        at clojure.lang.RT.loadResourceScript(RT.java:340)
        at clojure.lang.RT.loadResourceScript(RT.java:331)
        at clojure.lang.RT.load(RT.java:409)
        at clojure.lang.RT.load(RT.java:381)
        at clojure.core$load$fn__4519.invoke(core.clj:4915)
        at clojure.core$load.doInvoke(core.clj:4914)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invoke(core.clj:4729)
        at clojure.core$load_lib.doInvoke(core.clj:4766)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invoke(core.clj:542)
        at clojure.core$load_libs.doInvoke(core.clj:4800)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invoke(core.clj:542)
        at clojure.core$require.doInvoke(core.clj:4881)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at user$eval1.invoke(NO_SOURCE_FILE:1)
        at clojure.lang.Compiler.eval(Compiler.java:5424)
        at clojure.lang.Compiler.eval(Compiler.java:5414)
        at clojure.lang.Compiler.eval(Compiler.java:5391)
        at clojure.core$eval.invoke(core.clj:2382)
        at clojure.main$eval_opt.invoke(main.clj:235)
        at clojure.main$initialize.invoke(main.clj:254)
        at clojure.main$null_opt.invoke(main.clj:279)
        at clojure.main$main.doInvoke(main.clj:354)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:369)
        at clojure.lang.AFn.applyToHelper(AFn.java:163)
        at clojure.lang.Var.applyTo(Var.java:482)
        at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
        at gf.source.teamsystem.api.ts_files$checkout_file.invoke(ts_files.clj:31)
        at gf.source.teamsystem.api.ts_files$eval297.invoke(ts_files.clj:48)
        at clojure.lang.Compiler.eval(Compiler.java:5424)
        ... 31 more

调用pendEdit的第二个实现有什么作用?

0 个答案:

没有答案