arsd icon indicating copy to clipboard operation
arsd copied to clipboard

jni.jarToD now rt.jar has gone away

Open John-Colvin opened this issue 1 year ago • 7 comments

rt.jar went away in java 9, so what's the way to get a D interface to those java standard library things?

John-Colvin avatar Mar 02 '23 14:03 John-Colvin

To find java home: java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'

Then extract all the class files (and a bunch of other junk) for fn in /usr/lib/jvm/java-17-openjdk-amd64/jmods/*.jmod; do jmod extract --dir java_extracted $fn; done

Make a jar jar cvf rt.jar java/classes

all looks good, but then when building:

java/java/lang/Module_d_interface.d(10,28): Error: identifier expected following `package`

which is actually wrong because the line in question doesn't contain the word package, it's import import1 = java.lang.module.ModuleDescriptor_d_interface;, but I see what it's getting at.

John-Colvin avatar Mar 02 '23 14:03 John-Colvin

ok, so that last error is fixed by https://github.com/adamdruppe/arsd/pull/371

John-Colvin avatar Mar 02 '23 14:03 John-Colvin

I am supposed to resting so I'm gonna stop here, but I will just say that the instructions for using jni.d weren't super clear, it's a really cool thing that a decent "Here's how to take a massive Java library and call it from D" example project or something that really makes it clear would make much more likely to be used.

John-Colvin avatar Mar 02 '23 14:03 John-Colvin

I haven't touched the java thing for ages now, I did this just as a helper lib for the android thing that went nowhere anyway so aside from the little toy examples I've never actually used it! But yeah the jar to d was an internal helper to translate those classes over. It compiles extremely slowly tho for anything big...

adamdruppe avatar Mar 02 '23 14:03 adamdruppe

fast enough... takes about a minute on my machine to do the whole java standard library, but it doesn't need doing v. often.

John-Colvin avatar Mar 02 '23 15:03 John-Colvin

I mean importing the things to use it in the application, that's what compiles slowly, so you are better off doing it kinda selectively..

adamdruppe avatar Mar 02 '23 15:03 adamdruppe