abcl icon indicating copy to clipboard operation
abcl copied to clipboard

jnew-runtime-class doesn't work right after starting a repl

Open Uthar opened this issue 2 years ago • 5 comments

Example:

Doesn't work:

$ abcl
CL-USER(1): (jnew-runtime-class "org.example.Foo")
#<THREAD "interpreter" {1A5BE58F}>: Debugger invoked on condition of type JAVA-EXCEPTION
  Java exception: #<java.lang.NoSuchMethodException java.lang.NoSuchMethodException:.... {5EC57AD0}>.

Can be worked around by first calling something in the java package:

$ abcl
CL-USER(1): (print-object (jclass "java.lang.Object") t)
#<java.lang.Class class java.lang.Object {5DE63519}>
"#<java.lang.Class class java.lang.Object {5DE63519}>"
CL-USER(2): (jnew-runtime-class "org.example.Foo")
#<java.lang.Class class org.example.Foo {5144A428}>

Expected behavior:

The initialization done by the workaround could be done automatically, so that jnew-runtime-class would work right after starting ABCL.

Uthar avatar Apr 01 '22 15:04 Uthar

@easye I still have this after that merge - it's a separate problem from the print-object stuff. I think this problem has something to do with initialization of the Lisp runtime, maybe the Java interop code is lazily loaded somehow.

Uthar avatar Apr 07 '22 20:04 Uthar

Alright. Re-opening.

easye avatar Apr 07 '22 21:04 easye

Alright. Re-opening.

Thank you

Uthar avatar Apr 08 '22 07:04 Uthar

Alright. Re-opening.

Thank you

Uthar avatar Apr 08 '22 07:04 Uthar

Working with abcl-1.9.2:

CL-USER(8): (jnew-runtime-class "org.example.Foo")
#<java class org.example.Foo>
CL-USER(9): (describe *)
#<java.lang.Class class org.example.Foo {59FA3435}> is an object of type JAVA-OBJECT.
The wrapped Java object is an instance of java.lang.Class:
  "class org.example.Foo"
CL-USER(10): (lisp-implementation-version)
"${abcl.version}-git-c3feba71"
"OpenJDK_64-Bit_Server_VM-MacPorts-17.0.8+7"
"aarch64-Mac_OS_X-13.5.1"
CL-USER(11): 

easye avatar Aug 18 '23 17:08 easye