adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
531 stars 125 forks source link

jni.jarToD now rt.jar has gone away #370

Open John-Colvin opened 1 year ago

John-Colvin commented 1 year ago

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 commented 1 year ago

A bunch of explanation about jmod files

John-Colvin commented 1 year ago

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 commented 1 year ago

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

John-Colvin commented 1 year ago

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.

adamdruppe commented 1 year ago

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...

John-Colvin commented 1 year ago

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

adamdruppe commented 1 year ago

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..