January 02, 2020
On Wednesday, 1 January 2020 at 16:48:40 UTC, Adam D. Ruppe wrote:
> Another big update here in my blog this week:
>
> http://dpldocs.info/this-week-in-d/Blog.Posted_2019_12_30.html
I have to wonder if you sleep. Thank you for your work.
January 02, 2020
On Wednesday, 1 January 2020 at 18:15:32 UTC, Adam D. Ruppe wrote:

i see you updated everything ! wow !! :))

just a note : i had to add a sourceSets instruction
```
android {
    ...
    defaultConfig {
    ...
    }
    sourceSets {
        main {
            // let gradle pack the shared library into apk
            jniLibs.srcDirs = ['./src/main/jniLibs']
        }
    }
    ...
}
```
in the build.gradle file (the one in app directory) of the test application

it didn't pack the library in the apk otherwise, in my setup (which is plain basic, probably not relevant anyway)



January 02, 2020
On Thursday, 2 January 2020 at 20:26:05 UTC, visitor wrote:
> i see you updated everything ! wow !! :))

yea, the setup program should now download the runtime binaries for you and set up ldc2.conf fairly automatically (I haven't tested on Windows yet though and of course it will static assert on Mac but should be easy fix when I get to it).

Getting there. I think I have a plan for making new Java classes from D too that I'll play with when I get more time...

> just a note : i had to add a sourceSets instruction

hmm, ok, I didn't have to do that on mine but I can add a note to the docs for others.

tbh I don't really understand very much about android and the ide. I've never actually made an android app myself and never actually even heard of gradle before I started playing with this....
January 04, 2020
On Thursday, 2 January 2020 at 20:36:46 UTC, Adam D. Ruppe wrote:
>
> Getting there. I think I have a plan for making new Java classes from D too that I'll play with when I get more time...

!!!   You tried very hard to blow up the whole thing !
Sorry, nope ! still running fine :)

i didn't try the new automated setup, though, but your jni.d works fine, both on the test android app and my little experiment with "normal" java (using regular dmd - 2.089.1 - there, btw)
Thanks :)

January 05, 2020
On Saturday, 4 January 2020 at 16:59:13 UTC, visitor wrote:
> On Thursday, 2 January 2020 at 20:36:46 UTC, Adam D. Ruppe wrote:
>>
>> Getting there. I think I have a plan for making new Java classes from D too that I'll play with when I get more time...

Your createJVM() setup works fine on my little experiment !
Not a single line of java! wow ! very Nice :))


January 04, 2020
On Sun, Jan 05, 2020 at 03:56:37AM +0000, visitor via Digitalmars-d-announce wrote:
> On Saturday, 4 January 2020 at 16:59:13 UTC, visitor wrote:
> > On Thursday, 2 January 2020 at 20:36:46 UTC, Adam D. Ruppe wrote:
> > > 
> > > Getting there. I think I have a plan for making new Java classes from D too that I'll play with when I get more time...
> 
> Your createJVM() setup works fine on my little experiment !
> Not a single line of java! wow ! very Nice :))
[...]

I've been saying, Adam's jni.d is epic stuff.  It's a perfect showcase of how D's metaprogramming capabilities are a big enabler of this sort of inter-language interfacing.  If we play it right, D could become a powerful player as a glue language for pulling different languages together in an integrated, hassle-free way.


T

-- 
Real men don't take backups. They put their source on a public FTP-server and let the world mirror it. -- Linus Torvalds
January 06, 2020
On Sunday, 5 January 2020 at 03:56:37 UTC, visitor wrote:
> Not a single line of java!

so i got kinda excited for creating a class 100% in D as well, but.....

https://developer.android.com/training/articles/perf-jni.html

"DefineClass is not implemented. Android does not use Java bytecodes or class files, so passing in binary class data doesn't work."

gah, there goes that idea. So I guess that means the lambda callbacks for ui classes must be implemented in Java too. alas.

but still most things work anyway so still fun.

I need to make one of those NativeActivity ndk programs as a sample though, to show people how to do all that stuff.
January 06, 2020
On Monday, 6 January 2020 at 14:37:54 UTC, Adam D. Ruppe wrote:

> gah, there goes that idea. So I guess that means the lambda callbacks for ui classes must be implemented in Java too. alas.
>
> but still most things work anyway so still fun.

hum ... indeed most of the native samples in android are using java helper classes

do you still plan to add the ability to create java classes in D for non-android projects ?
(ui callbacks, that's where i paused in my non-Android test, also in this project i made "GlobalRef"s to reuse java objects / classes - thanks for warmly warning about the possible wreckage)

(btw, though good to know the trick, in fact i don't need the sourceSets instruction for the jniLibs, i forgot to put the library in the right subfolder ... "x86" or "armeabi-v7a", etc...)



January 06, 2020
On Monday, 6 January 2020 at 17:18:46 UTC, visitor wrote:
> hum ... indeed most of the native samples in android are using java helper classes

Yeah, the NativeActivity is I think the only one that doesn't (and that's just because Google provides a pre-built helper java class).

But I'm personally OK with that; reusing the platform as much as we can is a strength of D, it doesn't have to be all one thing. A little bit of Java gives you hooks into the IDE and stuff and isn't that much work; you can still reuse the majority of a D core.

> do you still plan to add the ability to create java classes in D for non-android projects ?

yes. I might not get around to it for a little while and it will very possibly be opt-in with a -version thing (right now I call it WithClassLoadSupport - creating a class would use the same code to work with the binary format). But I do want to do it.

Another challenge would be syntax. D does lambdas and anonymous inner classes... but they probably won't get the magic on them.

It may end up being a helper template, so you'd be like

JavaLambda!InterfaceName( a => whatever );

or something like that. I still need to think more about it.

> also in this project i made "GlobalRef"s to reuse java objects / classes - thanks for warmly warning about the possible

I plan to address this later too. Probably all return values will conservatively get the global ref unless you declare it as like `Manual!T` instead, which then wraps it for you and uses the type system to determine what needs to be it.

(if you look at the comments of jni.d you can see a lot of my notes to self about problems and possible future directions. Not all of them actually work out, but it gives you some view into what's in my brain.)

> (btw, though good to know the trick, in fact i don't need the sourceSets instruction for the jniLibs, i forgot to put the library in the right subfolder ... "x86" or "armeabi-v7a", etc...)

excellent.
January 06, 2020
On Monday, 6 January 2020 at 14:37:54 UTC, Adam D. Ruppe wrote:
> On Sunday, 5 January 2020 at 03:56:37 UTC, visitor wrote:
>> Not a single line of java!
>
> so i got kinda excited for creating a class 100% in D as well, but.....
>
> https://developer.android.com/training/articles/perf-jni.html
>
> "DefineClass is not implemented. Android does not use Java bytecodes or class files, so passing in binary class data doesn't work."
>

I haven't tried, but:

https://github.com/linkedin/dexmaker