jgpc42 / insn

Functional JVM bytecode generation for Clojure.
Eclipse Public License 1.0
198 stars 5 forks source link

Support for setting the SourceFile attribute of the class #9

Closed cnuernber closed 3 years ago

cnuernber commented 3 years ago

I am getting a crash in graalvm's system because the sourcefile attribute isn't set on a generated class.

Is there a way I can set the SourceFile attribute? It appears you have to visit the ClassNode in asm2:

https://javadoc.io/doc/org.ow2.asm/asm/5.2/org/objectweb/asm/tree/ClassNode.html#visitSource-java.lang.String-java.lang.String-

How would you recommend setting the sourcefile attribute?

cnuernber commented 3 years ago

I temporarily hacked around it with this patch:

visit_source.zip

jgpc42 commented 3 years ago

Thanks for this. Shall I apply it, or do you want to send a pull request?

I can release 0.5.2 sometime tomorrow if you need it.

cnuernber commented 3 years ago

If you are comfortable with it, then by all means apply it. The second argument is debug information. Clojure itself sets very specific debug information so at some point someone may want that. This patch, as it stands, solves the issue and I was able to get graal native compiling some generated code into a shared library.

I would love a new version whenever you are ready.

jgpc42 commented 3 years ago

Just pushed 0.5.2 to clojars with support for the :source and :debug options. Thanks again for bringing this to my attention.

cnuernber commented 3 years ago

Awesome, thanks for quick response!

cnuernber commented 3 years ago

With that upgrade I was able to release a version of avclj where you can compile it into a shared library and call that shared library from c++ in order to encode video. Truly an astounding world we live in :-).

https://user-images.githubusercontent.com/40426/111914957-c05cac80-8a39-11eb-9d60-52b5597461aa.mp4

jgpc42 commented 3 years ago

Wow, this is really great stuff! When I get some time, I definitely need to check this out more in depth! :+1: