This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-07
Channels
- # announcements (5)
- # asami (17)
- # aws (11)
- # babashka (67)
- # beginners (90)
- # calva (13)
- # cider (17)
- # circleci (6)
- # clj-kondo (3)
- # clojure (53)
- # clojure-europe (12)
- # clojure-france (8)
- # clojure-germany (3)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-spec (15)
- # clojure-uk (8)
- # clojurescript (41)
- # cursive (7)
- # data-science (6)
- # datomic (8)
- # emacs (10)
- # exercism (1)
- # figwheel-main (2)
- # fulcro (5)
- # graalvm-mobile (97)
- # graphql (1)
- # hyperfiddle (7)
- # inf-clojure (6)
- # interop (4)
- # introduce-yourself (5)
- # jobs (3)
- # kaocha (3)
- # malli (8)
- # meander (8)
- # music (3)
- # nrepl (7)
- # observability (1)
- # off-topic (45)
- # overtone (2)
- # polylith (63)
- # portal (2)
- # re-frame (26)
- # reveal (8)
- # ring (3)
- # shadow-cljs (56)
- # tools-build (5)
- # vim (11)
- # xtdb (8)
Trying to instantiate https://github.com/openjdk/client/blob/master/src/java.desktop/share/classes/sun/awt/EmbeddedFrame.java using reflection
(def ef (new EmbeddedFrame (long 92285152)));; "It's private. Go away."
(def efc (Class/forName "sun.awt.EmbeddedFrame"))
(.getConstructors efc);; #object["[Ljava.lang.reflect.Constructor;" 0x263cb983 "[Ljava.lang.reflect.Constructor;@263cb983"]
(def efcons (.getDeclaredConstructor sun.awt.EmbeddedFrame (into-array Class [java.lang.Long/TYPE])) )
(.setAccessible efcons true)
(identity efcons);; #object[java.lang.reflect.Constructor 0x7b7e14d5 "protected sun.awt.EmbeddedFrame(long)"]
;;all lined up to call it
(.newInstance efcons (into-array Object [(long 92285152)]));; Clojure: class java.lang.InstantiationException
(clojure.lang.Reflector/invokeConstructor (resolve (symbol "sun.awt.EmbeddedFrame")) (into-array [92285152]));; Clojure: class java.lang.IllegalArgumentException
Wow. Got so close.
(def xef (clojure.lang.Reflector/invokeConstructor
(resolve (symbol "sun.awt.X11.XEmbeddedFrame"))
(into-array Object [92285152 ])) )
(.synthesizeWindowActivation xef true)
The number is a window ID. When I run that, it actually causes focus to jump to the correct window!
(def g (.getGraphics xef) )
(.setColor g Color/RED)
(.fillRect g 0,0,1000,1000)
Sadly that does nothing. The rectangle doesn't show up.