aboutsummaryrefslogtreecommitdiff
path: root/lux-bootstrapper
diff options
context:
space:
mode:
authorEduardo Julian2022-03-16 16:44:40 -0400
committerEduardo Julian2022-03-16 16:44:40 -0400
commit49387dbbf08a9b06b815a662d117c7aa37120482 (patch)
treef9be901f65271f0a4a8a331f4aadc3ff84099c9f /lux-bootstrapper
parentbf53ee92fc3c33a4885aa227e55d24f7ba3cb2c4 (diff)
JVM interop now allows importing inherited virtual/interface methods.
Diffstat (limited to 'lux-bootstrapper')
-rw-r--r--lux-bootstrapper/src/lux/host.clj30
1 files changed, 14 insertions, 16 deletions
diff --git a/lux-bootstrapper/src/lux/host.clj b/lux-bootstrapper/src/lux/host.clj
index 00763ade3..7b114a772 100644
--- a/lux-bootstrapper/src/lux/host.clj
+++ b/lux-bootstrapper/src/lux/host.clj
@@ -111,10 +111,10 @@
lookup-field false
)
-(do-template [<name> <static?> <method-type>]
+(do-template [<name> <static?> <method-type> <options>]
(defn <name> [class-loader target method-name args]
(|let [target-class (Class/forName target true class-loader)]
- (if-let [[^Method method ^Class declarer] (first (for [^Method =method (.getDeclaredMethods target-class)
+ (if-let [[^Method method ^Class declarer] (first (for [^Method =method (<options> target-class)
:when (and (.equals ^Object method-name (.getName =method))
(.equals ^Object <static?> (Modifier/isStatic (.getModifiers =method)))
(let [param-types (&/->list (seq (.getParameterTypes =method)))]
@@ -125,22 +125,20 @@
(&/|map #(.getName ^Class %) param-types)))))]
[=method
(.getDeclaringClass =method)]))]
- (if (= target-class declarer)
- (|let [parent-gvars (->> target-class .getTypeParameters seq &/->list)
- gvars (->> method .getTypeParameters seq &/->list)
- gargs (->> method .getGenericParameterTypes seq &/->list)
- _ (when (.getAnnotation method java.lang.Deprecated)
- (println (str "[Host Warning] Deprecated method: " target "." method-name " " (->> args &/->seq print-str))))]
- (return (&/T [(.getGenericReturnType method)
- (->> method .getExceptionTypes &/->list (&/|map #(.getName ^Class %)))
- parent-gvars
- gvars
- gargs])))
- (&/fail-with-loc (str "[Host Error] " <method-type> " method " (pr-str method-name) " for " "(" (->> args (&/|interpose ", ") (&/fold str "")) ")" " belongs to parent " (.getName declarer) " instead of " target)))
+ (|let [parent-gvars (->> target-class .getTypeParameters seq &/->list)
+ gvars (->> method .getTypeParameters seq &/->list)
+ gargs (->> method .getGenericParameterTypes seq &/->list)
+ _ (when (.getAnnotation method java.lang.Deprecated)
+ (println (str "[Host Warning] Deprecated method: " target "." method-name " " (->> args &/->seq print-str))))]
+ (return (&/T [(.getGenericReturnType method)
+ (->> method .getExceptionTypes &/->list (&/|map #(.getName ^Class %)))
+ parent-gvars
+ gvars
+ gargs])))
(&/fail-with-loc (str "[Host Error] " <method-type> " method does not exist: " target "." method-name " " "(" (->> args (&/|interpose ", ") (&/fold str "")) ")")))))
- lookup-static-method true "Static"
- lookup-virtual-method false "Virtual"
+ lookup-static-method true "Static" .getDeclaredMethods
+ lookup-virtual-method false "Virtual" .getMethods
)
(defn lookup-constructor [class-loader target args]