Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting error calling Class.forName. #169

Closed
matthewfl opened this issue Apr 28, 2023 · 3 comments
Closed

Getting error calling Class.forName. #169

matthewfl opened this issue Apr 28, 2023 · 3 comments

Comments

@matthewfl
Copy link

I am trying to load an application that has some of its parts written in Clojure. Trying to load the Clojure runtime, I get the following error. It seems that that Clojure is internally using Class.forName to load some stuff and that is resulting in the following exception when it internally attempts to use Unsafe.

I would have assumed that because this is running entirely compiled to webassembly, it should be possible for it to use unsafe internally.

java.lang.SecurityException: Unsafejava.lang.SecurityException: Unsafe
	at sun.misc.Unsafe.getUnsafe(Unknown Source)
	at java.net.InetAddress(Unknown Source)
	at internal.internal(Unknown Source)
	at internal.internal(Unknown Source)
	at java.lang.Class.forName0(Unknown Source)
	at clojure.lang.RT.classForName(Unknown Source)
	at clojure.core.server$loading__6789__auto____8961.invoke(Unknown Source)
	at clojure.core.server__init.load(Unknown Source)
	at clojure.core.server__init(Unknown Source)
	at internal.internal(Unknown Source)
	at internal.internal(Unknown Source)
	at java.lang.Class.forName0(Unknown Source)
	at clojure.lang.RT.classForName(Unknown Source)
	at clojure.lang.RT.loadClassForName(Unknown Source)
	at clojure.lang.RT.load(Unknown Source)
	at clojure.core$load$fn__6908.invoke(Unknown Source)
	at clojure.core$load.invokeStatic(Unknown Source)
	at clojure.core$load.doInvoke(Unknown Source)
	at clojure.core$load_one.invokeStatic(Unknown Source)
	at clojure.core$load_lib$fn__6850.invoke(Unknown Source)
	at clojure.core$load_lib.invokeStatic(Unknown Source)
	at clojure.core$load_lib.doInvoke(Unknown Source)
	at clojure.core$load_libs.invokeStatic(Unknown Source)
	at clojure.core$load_libs.doInvoke(Unknown Source)
	at clojure.lang.RT.doInit(Unknown Source)
@alexp-sssup
Copy link
Member

This is likely to be caused by the incomplete support for class loaders in CheerpJ 2.x. This whole class of problems will be solved with the new CheerpJ 3.x architecture that is currently under development.

Please provide a self-contained JAR that demonstrate the problem, so that we can use it as a test case.

@matthewfl
Copy link
Author

matthewfl commented Apr 28, 2023

@alexp-sssup I have created a simple self-contained jar that launches clojure and causes this issue.
I also included a demo page that generates the stack trace.

https://www.dropbox.com/s/pok26fyiw9v860g/cheerpj-clojure.zip?dl=1

@alexp-sssup
Copy link
Member

This problem is fixed with the new CheerpJ 3.0 architecture. Please try this build: https://cjrtnc.leaningtech.com/3_20240122_347/cj3loader.js

Since cjCall has been replaced with the new "library mode", you'll need update your code. See here for more information: https://labs.leaningtech.com/cheerpj3/guides/library-mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants