Re: Java interop question
That works, thanks a lot! Em terça-feira, 5 de fevereiro de 2019 11:55:32 UTC-3, jvshahid escreveu: > > > Thiago Araújo > writes: > > > Hi, > > > > I'm a newcomer to java interop. I'm trying to run the following code > > without success: > > > > (javafx.scene.layout.HBox. (javafx.scene.control.Label. "Foo")) > > > > I get: > > > > IllegalArgumentException No matching ctor found for class > > javafx.scene.layout.HBox clojure.lang.Reflector.invokeConstructor > > (Reflector.java:183) > > The HBox constructor you are trying to use is a variadic method, i.e. it > accepts an array of Node objects. You just need to use something like: > > (into-array javafx.scene.control.Label (javafx.scene.control.Label > "Foo")) > > Cheers, > > JS > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Java interop question
Thiago Araújo writes: > Hi, > > I'm a newcomer to java interop. I'm trying to run the following code > without success: > > (javafx.scene.layout.HBox. (javafx.scene.control.Label. "Foo")) > > I get: > > IllegalArgumentException No matching ctor found for class > javafx.scene.layout.HBox clojure.lang.Reflector.invokeConstructor > (Reflector.java:183) The HBox constructor you are trying to use is a variadic method, i.e. it accepts an array of Node objects. You just need to use something like: (into-array javafx.scene.control.Label (javafx.scene.control.Label "Foo")) Cheers, JS -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Java interop question
Hi, I'm a newcomer to java interop. I'm trying to run the following code without success: (javafx.scene.layout.HBox. (javafx.scene.control.Label. "Foo")) I get: IllegalArgumentException No matching ctor found for class javafx.scene.layout.HBox clojure.lang.Reflector.invokeConstructor (Reflector.java:183) One of the constructors for HBox says we can pass instances of Node (Node is an ancestor of Label), so I wonder why that's not working? I already got through the following gotcha: (javafx.scene.layout.HBox. 5) ;; does not work (javafx.scene.layout.HBox. 5.0) ;; works So it must be some detail I'm missing out. I'm using Java 9.0.4 and Clojure 1.9.0. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
java interop question: how to access Class object statically
Hi all -- Trying to basically do something like Integer.class -- but ... user= (Integer/class) user= java.lang.NoSuchFieldException: class (NO_SOURCE_FILE:2) user= (Integer/getClass) java.lang.NoSuchFieldException: getClass (NO_SOURCE_FILE:4) Some (not so pretty) workarounds are (.getClass (Integer. 0)) (class 0) but there must be a better more idiomatic way to do this? Thanks -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop question: how to access Class object statically
How about just Integer? :) Clojure Integer java.lang.Integer Clojure (class Integer) java.lang.Class Dave On Thu, Sep 15, 2011 at 1:31 PM, Andrew Xue and...@lumoslabs.com wrote: Hi all -- Trying to basically do something like Integer.class -- but ... user= (Integer/class) user= java.lang.NoSuchFieldException: class (NO_SOURCE_FILE:2) user= (Integer/getClass) java.lang.NoSuchFieldException: getClass (NO_SOURCE_FILE:4) Some (not so pretty) workarounds are (.getClass (Integer. 0)) (class 0) but there must be a better more idiomatic way to do this? Thanks -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop question
Yes, Ken's original suggestion was correct -- the clojure code had to look like a real java bean. It works perfectly now, so thanks! On Feb 3, 3:55 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: I don't know what select * from StockTick(symbol=... is doing, but it looks like the error is coming from the library handling that query, not Clojure. -Stuart Sierra clojure.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop question
Thanks for the tip on how to express a java bean -- that appears to only be part of the problem; I still have the error I posted above. But I'm going to keep flailing at it. On Feb 2, 10:11 am, Ken Wesson kwess...@gmail.com wrote: On Wed, Feb 2, 2011 at 11:15 AM, clwham...@gmail.com clwham...@gmail.com wrote: I am doing some prototyping with the event processing framework Esper (http://esper.codehaus.org/) and I'm running up against my ignorance of clojure/java interop. I would like to create a java bean in clojure that is visible to the Esper runtime; I found some sample Java code that I clojurized as follows: (ns cepdemo.core (:import [com.espertech.esper.client Configuration UpdateListener EPServiceProviderManager EPRuntime])) (defrecord Tick [symbol price timestamp]) ... The error I get is: Property named 'symbol' is not valid in any stream [select * from StockTick(symbol='AAPL').win:length(2) having avg(price) 6.0] from which I conclude that defrecord may not be the way to create a java bean. Do I need to use gen-class? I'd try first to make Tick bean-ish with (definterface ITick (getSymbol [this]) (setSymbol [this y]) (getPrice [this]) (setPrice [this y]) (getTimeStamp [this]) (setTimeStamp [this y])) (defrecord Tick [symbol price timestamp] ITick (getSymbol [this] symbol) (setSymbol [this] (throw (UnsupportedOperationException.))) (getPrice [this] price) (setPrice [this] (throw (UnsupportedOperationException.))) (getTimeStamp [this] timestamp) (setTimeStamp [this] (throw (UnsupportedOperationException.))) Tell the external tool that the bean properties are Symbol, Price, and TimeStamp (rather than symbol, price, and timestamp) and unless it tries to mutate your Ticks it ought to work. Of course, you might also consider making a defbean macro that wraps defrecord and automates the above. :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: java interop question
I don't know what select * from StockTick(symbol=... is doing, but it looks like the error is coming from the library handling that query, not Clojure. -Stuart Sierra clojure.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
java interop question
I am doing some prototyping with the event processing framework Esper (http://esper.codehaus.org/) and I'm running up against my ignorance of clojure/java interop. I would like to create a java bean in clojure that is visible to the Esper runtime; I found some sample Java code that I clojurized as follows: (ns cepdemo.core (:import [com.espertech.esper.client Configuration UpdateListener EPServiceProviderManager EPRuntime])) (defrecord Tick [symbol price timestamp]) (defn generate-random-tick [runtime] (let [price (rand-int 10) timestamp (java.util.Date.) symbol AAPL tick (Tick. symbol price timestamp)] (print Sending tick: tick) (.sendEvent runtime tick))) (defn cep-listener [] (proxy [UpdateListener] [] (update [new-data old-data] (print event received: new-data (defn config [] (let [cep-config (Configuration.)] (.addEventType cep-config StockTick (.getName Tick)) (let [cep-sp (EPServiceProviderManager/getProvider myCEPEngine cep-config) cep-rt (.getEPRuntime cep-sp) cep-admin (.getEPAdministrator cep-sp) cep-statement (.createEPL cep-admin select * from StockTick(symbol='AAPL').win:length(2) having avg(price) 6.0)] (.addListener cep-statement cep-listener) (doseq [i (range 10)] (generate-random-tick cep-rt) The error I get is: Property named 'symbol' is not valid in any stream [select * from StockTick(symbol='AAPL').win:length(2) having avg(price) 6.0] from which I conclude that defrecord may not be the way to create a java bean. Do I need to use gen-class? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Newbie : Java Interop question
P = Property. Guess it could have been lower case p. On Oct 15, 11:19 pm, Michael Ossareh ossa...@gmail.com wrote: On Fri, Oct 15, 2010 at 09:32, oak ismail.oka...@gmail.com wrote: Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION Out of interest what is this format? Are my guesses at the letters accurate? I == Interface C == Class M == Method P == ? s == static f == final c = class -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Newbie : Java Interop question
Thanks just what needed to know On Oct 15, 11:13 pm, Randy Hudson randy_hud...@mac.com wrote: Nested classes require the syntax AClass$NestedClass -- this being the real name of the class in the JVM. Static members of classes are referenced as AClass/member -- essentially treating the class as a namespace of its static members. So this should do it: (IEssbase$Home/create IEssbase/JAPI_VERSION) On Oct 15, 12:32 pm, oak ismail.oka...@gmail.com wrote: Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION I can import like this in Clojure =(import `(com.essbase.api.session IEssbase))` I can also call the property like this with success. =(IEssbase/JAPI_VERSION) 11.1.1 = In java the code to get this API instance looks like this. IEssbase ess = null; ess = IEssbase.Home.create(IEssbase.JAPI_VERSION); when in Clojure i try the following = (.. IEssbase Home create IEssbase.JAPI_VERSION) I get the message no such Field exists. Do i have to use a proxy since IEssbase is an Interface if so how do i make call to create to get instance of API back. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Newbie : Java Interop question
Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION I can import like this in Clojure =(import `(com.essbase.api.session IEssbase))` I can also call the property like this with success. =(IEssbase/JAPI_VERSION) 11.1.1 = In java the code to get this API instance looks like this. IEssbase ess = null; ess = IEssbase.Home.create(IEssbase.JAPI_VERSION); when in Clojure i try the following = (.. IEssbase Home create IEssbase.JAPI_VERSION) I get the message no such Field exists. Do i have to use a proxy since IEssbase is an Interface if so how do i make call to create to get instance of API back. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Newbie : Java Interop question
Try using IEssbase/JAPI_VERSION instead (replace dot with slash). On Oct 15, 11:32 am, oak ismail.oka...@gmail.com wrote: Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION I can import like this in Clojure =(import `(com.essbase.api.session IEssbase))` I can also call the property like this with success. =(IEssbase/JAPI_VERSION) 11.1.1 = In java the code to get this API instance looks like this. IEssbase ess = null; ess = IEssbase.Home.create(IEssbase.JAPI_VERSION); when in Clojure i try the following = (.. IEssbase Home create IEssbase.JAPI_VERSION) I get the message no such Field exists. Do i have to use a proxy since IEssbase is an Interface if so how do i make call to create to get instance of API back. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Newbie : Java Interop question
Nested classes require the syntax AClass$NestedClass -- this being the real name of the class in the JVM. Static members of classes are referenced as AClass/member -- essentially treating the class as a namespace of its static members. So this should do it: (IEssbase$Home/create IEssbase/JAPI_VERSION) On Oct 15, 12:32 pm, oak ismail.oka...@gmail.com wrote: Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION I can import like this in Clojure =(import `(com.essbase.api.session IEssbase))` I can also call the property like this with success. =(IEssbase/JAPI_VERSION) 11.1.1 = In java the code to get this API instance looks like this. IEssbase ess = null; ess = IEssbase.Home.create(IEssbase.JAPI_VERSION); when in Clojure i try the following = (.. IEssbase Home create IEssbase.JAPI_VERSION) I get the message no such Field exists. Do i have to use a proxy since IEssbase is an Interface if so how do i make call to create to get instance of API back. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Newbie : Java Interop question
On Fri, Oct 15, 2010 at 09:32, oak ismail.oka...@gmail.com wrote: Hi All, This is how i see the package in package explorer. IEssbase.class (I) IEssbase (C, s f) Home (M, s) create(String) IEssbase (M, c) Home() (P, s f) JAPI_VERSION Out of interest what is this format? Are my guesses at the letters accurate? I == Interface C == Class M == Method P == ? s == static f == final c = class -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
RE: Java interop question: proxy or gen-class?
Many thanks to Meikel Brandmeyer, whose code (after a one-character typo correction) worked the first time. As soon as I saw it, I understood every line of it; the problem was, it wouldn't have occurred to me to put all those elements (which, individually, I understood) together in just that way. Meikel, thanks again for contributing to a frustrated newcomer's education. By the way, I recommend comparing the original Java source code to the final version (at http://gist.github.com/369239) to any newcomer who wants to learn how to write Java code within a Clojure program--you don't even have to be interested in Piccolo2D to learn from this. (May you have) Good coding! Nice, thanks for posting your efforts with this. Piccolo's zoomable UI is pretty interesting, and I've been wanting to play with it for quite a while. Too many other projects; I hadn't taken the time to go into it. Putting it together with Clojure, and having a nice little sample of it to try out, brings it closer to the front of the line for me. Much appreciated! Kevin Kelley -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Java interop question: proxy or gen-class?
Many thanks to Meikel Brandmeyer, whose code (after a one-character typo correction) worked the first time. As soon as I saw it, I understood every line of it; the problem was, it wouldn't have occurred to me to put all those elements (which, individually, I understood) together in just that way. Meikel, thanks again for contributing to a frustrated newcomer's education. By the way, I recommend comparing the original Java source code to the final version (at http://gist.github.com/369239) to any newcomer who wants to learn how to write Java code within a Clojure program--you don't even have to be interested in Piccolo2D to learn from this. (May you have) Good coding! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Java interop question: proxy or gen-class?
Hi, My try. Not tested, though... (defn create-toggle-shape Creates an ellipse that changes shape when it is clicked. [] (let [fIsPressed? (atom false) shape (proxy [PPath] [] (paint [#^PPaintContext paintContext] (if @fIsPressed? (doto (.getGraphics paintContext) (.setPaint (.getPaint this)) (.fill (.getBoundReference this))) (proxy-super paint paintContext] (doto shape (.setPathToEllipse 0 0 100 80) (.addInputEventListener (proxy [PBasicInputEventHandler] [] (mousePressed [evt] (proxy-super mousePressed evt) (reset! fIsPressed? true) (.repaint shape)) (mouseReleased [evt] (proxy-super mouseReleased evt) (reset! fIsPressed? false) (.repaint shape))) Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe, reply using remove me as the subject.
Re: Java interop question: proxy or gen-class?
Since my last post, I've implemented and successfully run everything in this sample program except the ToggleShape class, and I absolutely cannot figure out how to use proxy correctly. Here's the Java code that I'm trying to re-create in Clojure: class ToggleShape extends PPath { private static final long serialVersionUID = 1L; private boolean fIsPressed = false; public ToggleShape() { ; location (1) setPathToEllipse(0, 0, 100, 80); addInputEventListener(new PBasicInputEventHandler() { public void mousePressed(final PInputEvent event) { super.mousePressed(event); fIsPressed = true; repaint(); } public void mouseReleased(final PInputEvent event) { super.mouseReleased(event); fIsPressed = false; repaint(); } }); } protected void paint(final PPaintContext paintContext) { if (fIsPressed) { final Graphics2D g2 = paintContext.getGraphics(); g2.setPaint(getPaint()); g2.fill(getBoundsReference()); } else { super.paint(paintContext); } } } Note that this subclass, ToggleShape, redefines its constructor (see the line marked location (1), above). The question is, what name do I put to the function that executes the Clojure equivalent of setPathToEllipse(0, 0, 100, 80)? Since proxy creates an anonymous subclass, the only function named that I could think to use is that of its superclass, PPath--but I can't get it to work (and the code below is just one of several variations I've tried). To eliminate other possible sources of error, I've taken out the event listeners in the Clojure code below, and all I'm trying to do is have the program display the %...@#! ellipse (I can get it to display a square just fine). I've also put a println statement in the code that creates an instance of ToggleShape (which does execute), and another println statement in the code that implements ToggleShape (which DOES NOT execute). I've searched the web for articles and source code that might give me some idea of how to proceed, and I've also consulted Java reference books, but I haven't found anything that explains what I need to do. Anyway, here's one version of the corresponding Clojure code: (defn create-toggle-shape Creates an ellipse that changes shape when it is clicked. [] (let [fIsPressed? (ref false) serialVersionUID (long 1)] (proxy [PPath] [] ; ToggleShape is an extension of PPath ; I'm trying to create the constructor for ToggleShape--proxy ; requires that what follows is a sequence of superclass method- names- ; arguments-and-bodies. What do I call it here? Since the superclass is ; PPath, the name of its constructor is PPath, so that's what I'm ; trying here--but it doesn't seem to work: the println is ; never executed. (PPath [] ; ; super's constructor should execute automatically (println Reached ToggleShape) (.setPathToEllipse 0 0 100 80) ;add input listeners here ) (paint [paintContext] (if (fIsPressed?) (let [g2 (.getGraphics paintContext)] (do (.. g2 setPaint getPaint) (.fill g2 (.getBoundsReference this (proxy-super paint paintContext)) I can post the entire program if anyone wants to see it. As always, thanks for taking the time to help. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en To unsubscribe, reply using remove me as the subject.
Java interop question: proxy or gen-class?
Hi--I'm continuing on my path to learning how to use Clojure with the graphics library Piccolo2D (http:// www.piccolo2d.org) by re-implementing some of Piccolo2D's sample programs. This time, I'm working on the Building the Interface program described at http://www.piccolo2d.org/learn/interface.html. I've used proxy successfully several times so far, but I'm not sure I can use it here. The code that I'm trying to translate is as follows: --- class ToggleShape extends PPath { private boolean fIsPressed = false; public ToggleShape() { setPathToEllipse(0, 0, 100, 80); addInputEventListener(new PBasicInputEventHandler() { public void mousePressed(PInputEvent event) { super.mousePressed(event); fIsPressed = true; repaint(); } public void mouseReleased(PInputEvent event) { super.mouseReleased(event); fIsPressed = false; repaint(); } }); } protected void paint(PPaintContext paintContext) { if (fIsPressed) { Graphics2D g2 = paintContext.getGraphics(); g2.setPaint(getPaint()); g2.fill(getBoundsReference()); } else { super.paint(paintContext); } } } --- Some questions: 1) Because this new class, ToggleShape, has the added state of fIsPressed, is it possible to use proxy at all, or do I have to use gen-class? If it's the latter, how do I declare the namespace that surrounds the gen-class so that this new class is visible to the code that uses it? 2) If I can use proxy, do I create a constructor for this nameless new class by redefining PPath (which is, after all, the name of the constructor for the superclass)? As always, thanks for your help. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Java interop question
Is it possible to access a constant inside a public static class which is defined inside a public interface? For example: package com.rabbitmq.client; import java.io.IOException; [...skipped...] public interface AMQP { public static class PROTOCOL { public static final int MAJOR = 8; public static final int MINOR = 0; public static final int PORT = 5672; } public static final int FRAME_METHOD = 1; public static final int FRAME_HEADER = 2; public static final int FRAME_BODY = 3; [...skipped...] } I did a lot of experimentartion in the REPL, but no success yet - I can't figure out how to access com.rabbimq.client.AMQP.PROTOCOL.PORT constant in Clojure. It is possible to (import 'com.rabbitmq.client.AMQP), but (import 'com.rabbitmq.client.AMQP.PROTOCOL) gives ClassNotFoundException. (. com.rabbimq.AMQP FRAME_METHOD) returns 1, but neither (. com.rabbitmq.client.AMQP.PROTOCOL PORT), nor (com.rabbitmq.client.AMQP.PROTOCOL/PORT) works. What I'm doing wrong? Best regards, Vladimir --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Java interop question
On Sun, Jan 11, 2009 at 3:30 PM, wal valebe...@gmail.com wrote: Is it possible to access a constant inside a public static class which is defined inside a public interface? For example: package com.rabbitmq.client; import java.io.IOException; [...skipped...] public interface AMQP { public static class PROTOCOL { public static final int MAJOR = 8; public static final int MINOR = 0; public static final int PORT = 5672; } public static final int FRAME_METHOD = 1; public static final int FRAME_HEADER = 2; public static final int FRAME_BODY = 3; [...skipped...] } Probably com.rabbitmq.client.AMQP$PROTOCOL/PORT without parens since it's a field not a method. Documented at http://clojure.org/java_interop -- search for NestedClass --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Java interop question
On 12 янв, 01:01, Chouser chou...@gmail.com wrote: On Sun, Jan 11, 2009 at 3:30 PM, wal valebe...@gmail.com wrote: Is it possible to access a constant inside a public static class which is defined inside a public interface? For example: package com.rabbitmq.client; import java.io.IOException; [...skipped...] public interface AMQP { public static class PROTOCOL { public static final int MAJOR = 8; public static final int MINOR = 0; public static final int PORT = 5672; } public static final int FRAME_METHOD = 1; public static final int FRAME_HEADER = 2; public static final int FRAME_BODY = 3; [...skipped...] } Probably com.rabbitmq.client.AMQP$PROTOCOL/PORT without parens since it's a field not a method. Documented athttp://clojure.org/java_interop-- search for NestedClass --Chouser Yes, it worked! Thanks a lot! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Java interop question
work (.getName (.getClass 0)) java.lang.Integer work (.getName java.lang.Integer) ; Evaluation aborted. Why does the second expression fail? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Java interop question
--- On Sun, 12/14/08, David wrote: work (.getName java.lang.Integer) ; Evaluation aborted. Why does the second expression fail? Would that work in Java? Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Java interop question
On Dec 14, 2:26 pm, David dsieg...@yahoo.com wrote: work (.getName (.getClass 0)) java.lang.Integer work (.getName java.lang.Integer) ; Evaluation aborted. Why does the second expression fail? There used to be a long answer as to why: http://groups.google.com/group/clojure/msg/8fc6f0e9a5800e4b Now there is a short one - it does work! (.getName java.lang.Integer) - java.lang.Integer As of Revision #1158 Committed by rhickey at 12/12/08 9:37:12 PM force instance member interpretation of (.method ClassName), e.g. (.getMethods String) works Rich --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Java interop question
Sneaky, but I bet I'll get confused by the extra functionality at some point. --- On Sun, 12/14/08, Rich Hickey richhic...@gmail.com wrote: There used to be a long answer as to why: http://groups.google.com/group/clojure/msg/8fc6f0e9a5800e4b Now there is a short one - it does work! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Java interop question
I understand how Clojure lets you consume Java objects, and pass Clojure objects to Java programs. However, it is not uncommon for Java libraries to be designed in such a way that you need to create a subclass of something in the library in order to make use of the library. I don't understand whether this is possible in Clojure. As a case in point, I'd like to know how to make use of Gecode/J in Clojure. If you look at the introduction, http://www.gecode.org/gecodej/doc/PageComp.html, you'll see that the first step is to subclass org.gecode.Space, adding special logic to your constructor and creating a custom copy constructor. How would one do something like that from Clojure? Thanks, Mark --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Java interop question
This article has a good example using the proxy function. http://gnuvince.wordpress.com/2008/11/18/fetching-web-comics-with-clojure-part-2/ On Thu, Dec 11, 2008 at 1:22 PM, Randall R Schulz rsch...@sonic.net wrote: On Thursday 11 December 2008 11:31, Mark Engelberg wrote: I understand how Clojure lets you consume Java objects, and pass Clojure objects to Java programs. However, it is not uncommon for Java libraries to be designed in such a way that you need to create a subclass of something in the library in order to make use of the library. I don't understand whether this is possible in Clojure. It's not only possible, but quite straightforward. The basic thing you're looking for is (proxy ...). In some cases, you may need (gen-class). Check them out. They'll get you everything you need for working with white-box frameworks. (I'll check out Geocode/J as soon as I get Firefox back up. It just crashed and I keep 9 windows and over 80 tabs open, so starting it up is pretty slow...) ... Thanks, Mark Randall Schulz --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: java interop question
notallama wrote: this may be more of a java question than a clojure question. i dunno. how do i use a java class from clojure? it's easy enough if it's one of the default java libraries, but so far all i have managed with classes i wrote is unable to resolve to classname i tried running the repl from the directory with the classes i want to use, but no luck. You need to set up your classpath correctly. How you do that depends heavily on how you're launching clojure in the first place. I suspect it's a batch file or shell script, in which case you just need to append the path to your class hierarchy (or the jar file containing it) to the -cp parameter to the java command. On UNIX-like systems, classpath entries are separated by a colon (:), on Windows, I think it's a semicolon (;). So if your class Foo, in package bar is at /tmp/bar/Foo.class, you want to change the part of the java line from java -cp path/clojure.jar:otherstuff to java -cp path/clojure.jar:otherstuff:/tmp/ Hope that helps ~phil --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---