Program working in repl but nowhere else?2019 Community Moderator ElectionHow to display Clojure version in REPL?Is there a software-engineering methodology for functional programming?How to reload a clojure file in REPLClojure: [Soft] Working from the ReplClojure Leining REPL OutOfMemoryError Java heap spaceHow to explore Java methods through REPLWhy is this Clojure micro benchmark so slow?How to run a clojure program in replClojure REPL, interop, Unable to resolve symbolREPL broke out of nowhere
Motivation for Zeta Function of an Algebraic Variety
Do I really need to have a scientific explanation for my premise?
Marriage green card at end of current visa with 2 Year residency requirement waiver in-process, question
Why would one plane in this picture not have gear down yet?
If I receive an SOS signal, what is the proper response?
How to detect if C code (which needs 'extern C') is compiled in C++
Does "Until when" sound natural for native speakers?
What are some noteworthy "mic-drop" moments in math?
Good for you! in Russian
PTIJ: wiping amalek’s memory?
Should I tell my boss the work he did was worthless
Why is computing ridge regression with a Cholesky decomposition much quicker than using SVD?
Child Theme Path Being Ignored With wp_enqueue_scripts
Doesn't allowing a user mode program to access kernel space memory and execute the IN and OUT instructions defeat the purpose of having CPU modes?
finite abelian groups tensor product.
They call me Inspector Morse
How to draw cubes in a 3 dimensional plane
Signed and unsigned numbers
Vocabulary for giving just numbers, not a full answer
How did Alan Turing break the enigma code using the hint given by the lady in the bar?
Reverse string, can I make it faster?
Are there historical instances of the capital of a colonising country being temporarily or permanently shifted to one of its colonies?
An alternative proof of an application of Hahn-Banach
What problems would a superhuman have whose skin is constantly hot?
Program working in repl but nowhere else?
2019 Community Moderator ElectionHow to display Clojure version in REPL?Is there a software-engineering methodology for functional programming?How to reload a clojure file in REPLClojure: [Soft] Working from the ReplClojure Leining REPL OutOfMemoryError Java heap spaceHow to explore Java methods through REPLWhy is this Clojure micro benchmark so slow?How to run a clojure program in replClojure REPL, interop, Unable to resolve symbolREPL broke out of nowhere
I suspect this may be somewhat related to java-interop since I call a lot of java functionality in my code.
When I run the following in my REPL (via emacs) it works exactly as it should
(def height 100)
(def image (BufferedImage. width height BufferedImage/TYPE_INT_ARGB))
(def graphics (.createGraphics image))
(.setColor graphics Color/black)
(for [x (range 0 width 10)]
(.drawLine graphics x 0 x height ))
(for [y (range 0 height 10)]
(.drawLine graphics 0 y width y))
(ImageIO/write image "png" (io/file "output.png"))
An image of a grid is properly generated.
However if I do C-c C-k, it generates a blank image.
Now, when I stick it in a function and I run it via lein run
I get a warning I don't understand:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by clojure.lang.InjectedInvoker/1832669781 (file:/home/n/.m2/repository/org/clojure/clojure/1.10.0/clojure-1.10.0.jar) to method sun.java2d.SunGraphics2D.setColor(java.awt.Color)
WARNING: Please consider reporting this to the maintainers of clojure.lang.InjectedInvoker/1832669781
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
I know very little about clojure and even less about java, but I am running openjdk 10.
I believe my code is written correctly (albeit poorly), is this an issue with my code or is it clojure?
clojure clojure-java-interop
add a comment |
I suspect this may be somewhat related to java-interop since I call a lot of java functionality in my code.
When I run the following in my REPL (via emacs) it works exactly as it should
(def height 100)
(def image (BufferedImage. width height BufferedImage/TYPE_INT_ARGB))
(def graphics (.createGraphics image))
(.setColor graphics Color/black)
(for [x (range 0 width 10)]
(.drawLine graphics x 0 x height ))
(for [y (range 0 height 10)]
(.drawLine graphics 0 y width y))
(ImageIO/write image "png" (io/file "output.png"))
An image of a grid is properly generated.
However if I do C-c C-k, it generates a blank image.
Now, when I stick it in a function and I run it via lein run
I get a warning I don't understand:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by clojure.lang.InjectedInvoker/1832669781 (file:/home/n/.m2/repository/org/clojure/clojure/1.10.0/clojure-1.10.0.jar) to method sun.java2d.SunGraphics2D.setColor(java.awt.Color)
WARNING: Please consider reporting this to the maintainers of clojure.lang.InjectedInvoker/1832669781
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
I know very little about clojure and even less about java, but I am running openjdk 10.
I believe my code is written correctly (albeit poorly), is this an issue with my code or is it clojure?
clojure clojure-java-interop
add a comment |
I suspect this may be somewhat related to java-interop since I call a lot of java functionality in my code.
When I run the following in my REPL (via emacs) it works exactly as it should
(def height 100)
(def image (BufferedImage. width height BufferedImage/TYPE_INT_ARGB))
(def graphics (.createGraphics image))
(.setColor graphics Color/black)
(for [x (range 0 width 10)]
(.drawLine graphics x 0 x height ))
(for [y (range 0 height 10)]
(.drawLine graphics 0 y width y))
(ImageIO/write image "png" (io/file "output.png"))
An image of a grid is properly generated.
However if I do C-c C-k, it generates a blank image.
Now, when I stick it in a function and I run it via lein run
I get a warning I don't understand:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by clojure.lang.InjectedInvoker/1832669781 (file:/home/n/.m2/repository/org/clojure/clojure/1.10.0/clojure-1.10.0.jar) to method sun.java2d.SunGraphics2D.setColor(java.awt.Color)
WARNING: Please consider reporting this to the maintainers of clojure.lang.InjectedInvoker/1832669781
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
I know very little about clojure and even less about java, but I am running openjdk 10.
I believe my code is written correctly (albeit poorly), is this an issue with my code or is it clojure?
clojure clojure-java-interop
I suspect this may be somewhat related to java-interop since I call a lot of java functionality in my code.
When I run the following in my REPL (via emacs) it works exactly as it should
(def height 100)
(def image (BufferedImage. width height BufferedImage/TYPE_INT_ARGB))
(def graphics (.createGraphics image))
(.setColor graphics Color/black)
(for [x (range 0 width 10)]
(.drawLine graphics x 0 x height ))
(for [y (range 0 height 10)]
(.drawLine graphics 0 y width y))
(ImageIO/write image "png" (io/file "output.png"))
An image of a grid is properly generated.
However if I do C-c C-k, it generates a blank image.
Now, when I stick it in a function and I run it via lein run
I get a warning I don't understand:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by clojure.lang.InjectedInvoker/1832669781 (file:/home/n/.m2/repository/org/clojure/clojure/1.10.0/clojure-1.10.0.jar) to method sun.java2d.SunGraphics2D.setColor(java.awt.Color)
WARNING: Please consider reporting this to the maintainers of clojure.lang.InjectedInvoker/1832669781
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
I know very little about clojure and even less about java, but I am running openjdk 10.
I believe my code is written correctly (albeit poorly), is this an issue with my code or is it clojure?
clojure clojure-java-interop
clojure clojure-java-interop
asked Mar 7 at 6:28
namgonamgo
62
62
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I suspect the problem you have is that “for” does not do what you think it does. It generates a lazy sequence. At the REPL the printer will generally evaluate these, but standalone code will not.
Try replacing the for with doseq. This will eagerly execute your side effects and should improve matters.
The illegal access warnings are a red herring. Since the Java module system came in there are certain patterns of interop which generate them. Details of how to resolve the warnings are given in the Clojure FAQ at https://clojure.org/guides/faq#illegal_access
1
Doseq fixed the issue.
– namgo
Mar 7 at 8:03
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037376%2fprogram-working-in-repl-but-nowhere-else%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I suspect the problem you have is that “for” does not do what you think it does. It generates a lazy sequence. At the REPL the printer will generally evaluate these, but standalone code will not.
Try replacing the for with doseq. This will eagerly execute your side effects and should improve matters.
The illegal access warnings are a red herring. Since the Java module system came in there are certain patterns of interop which generate them. Details of how to resolve the warnings are given in the Clojure FAQ at https://clojure.org/guides/faq#illegal_access
1
Doseq fixed the issue.
– namgo
Mar 7 at 8:03
add a comment |
I suspect the problem you have is that “for” does not do what you think it does. It generates a lazy sequence. At the REPL the printer will generally evaluate these, but standalone code will not.
Try replacing the for with doseq. This will eagerly execute your side effects and should improve matters.
The illegal access warnings are a red herring. Since the Java module system came in there are certain patterns of interop which generate them. Details of how to resolve the warnings are given in the Clojure FAQ at https://clojure.org/guides/faq#illegal_access
1
Doseq fixed the issue.
– namgo
Mar 7 at 8:03
add a comment |
I suspect the problem you have is that “for” does not do what you think it does. It generates a lazy sequence. At the REPL the printer will generally evaluate these, but standalone code will not.
Try replacing the for with doseq. This will eagerly execute your side effects and should improve matters.
The illegal access warnings are a red herring. Since the Java module system came in there are certain patterns of interop which generate them. Details of how to resolve the warnings are given in the Clojure FAQ at https://clojure.org/guides/faq#illegal_access
I suspect the problem you have is that “for” does not do what you think it does. It generates a lazy sequence. At the REPL the printer will generally evaluate these, but standalone code will not.
Try replacing the for with doseq. This will eagerly execute your side effects and should improve matters.
The illegal access warnings are a red herring. Since the Java module system came in there are certain patterns of interop which generate them. Details of how to resolve the warnings are given in the Clojure FAQ at https://clojure.org/guides/faq#illegal_access
answered Mar 7 at 7:47
pete23pete23
1,2621320
1,2621320
1
Doseq fixed the issue.
– namgo
Mar 7 at 8:03
add a comment |
1
Doseq fixed the issue.
– namgo
Mar 7 at 8:03
1
1
Doseq fixed the issue.
– namgo
Mar 7 at 8:03
Doseq fixed the issue.
– namgo
Mar 7 at 8:03
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037376%2fprogram-working-in-repl-but-nowhere-else%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown