File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ ; ;;; taken from clojure.contrib.reflect 1.2.0
2
+
3
+ ; ;; Copyright (c) 2010 Stuart Halloway & Contributors. All rights
4
+ ; ;; reserved. The use and distribution terms for this software are
5
+ ; ;; covered by the Eclipse Public License 1.0
6
+ ; ;; (http://opensource.org/licenses/eclipse-1.0.php) which can be
7
+ ; ;; found in the file epl-v10.html at the root of this distribution.
8
+ ; ;; By using this software in any fashion, you are agreeing to be
9
+ ; ;; bound by the terms of this license. You must not remove this
10
+ ; ;; notice, or any other, from this software.
11
+
12
+ (ns clj-ssh.reflect )
13
+
14
+ (defn call-method
15
+ " Calls a private or protected method.
16
+
17
+ params is a vector of classes which correspond to the arguments to
18
+ the method e
19
+
20
+ obj is nil for static methods, the instance object otherwise.
21
+
22
+ The method-name is given a symbol or a keyword (something Named)."
23
+ [klass method-name params obj & args]
24
+ (-> klass (.getDeclaredMethod (name method-name)
25
+ (into-array Class params))
26
+ (doto (.setAccessible true ))
27
+ (.invoke obj (into-array Object args))))
28
+
29
+ (defn get-field
30
+ " Access to private or protected field. field-name is a symbol or
31
+ keyword."
32
+ [klass field-name obj]
33
+ (->
34
+ klass
35
+ (.getDeclaredField (name field-name))
36
+ (doto (.setAccessible true ))
37
+ (.get obj)))
You can’t perform that action at this time.
0 commit comments