• 0 Posts
  • 1 Comment
Joined 11 months ago
cake
Cake day: October 20th, 2023

help-circle
  • When I started Clojure 3 years ago I had zero Java and Clojure knowledge but was experienced in C, Python, Shell etc. WhileI had no issues learning Clojure I did struggle with Java in Clojure, where Java by itself wasnt an issue.

    I use VSCode with Calva aswel.

    Clojure.reflect helps a lot and so does bean.

    I made this snippet in a dev ns to require and use to get methods: (ns myapp.dev (:require [clojure.pprint :refer [print-table]] [clojure.reflect :refer [reflect]]))

    (defn get-members [in] (print-table [:name :flags :parameter-types :return-type] (sort-by :name (:members (reflect in)))))

    And I got this helper from a gist: (comment “call private methods from https://gist.github.com/egamble/7781127”)

    (defn call-method [obj method-name & args] (let [m (first (filter (fn [x] (… x getName (equals method-name))) (… obj getClass getDeclaredMethods)))] (. m (setAccessible true)) (. m (invoke obj (into-array Object args)))))