Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
High-level interface #66
Comments
So when I had thought about this earlier, my idea was to use reflection (and some heuristics) to infer the argument types (and thus the exact method), but then cache the results of the reflection. In my experience, most java code that use reflection heavily always cache the results, given how slow it is. So that could be one option. I believe that is how the python-java interface works. I'll have a think about the syntax. My criteria are somewhat contradictory, to reduce the cognitive overhead for both the java and the julia developer. |
Caching results from reflection API sounds promising! I also have some progress on a generated functions approach in |
Could the dot syntax / auto-completion be handled by the |
Yes, that's the idea. It's just that we've not had the time to implement this. |
I wanted to propose a roadmap for this since there are multiple proposals on the table. My vision for the JavaCall package is to provide a solid foundation that takes care of most of the low level interface of the JNI and provides a Julian method of calling Java. We should be able to do a few things like inferring or automatically importing the return type. For some of the examples above, I would like to point out that the below is not really Java. You could not compile that with
It would be closer to something like Groovy. My proposal to support that would be a GroovyCall.jl package which would depend on JavaCall.jl. In that case, we let Groovy handle the syntax parsing. What to expect:
|
Not that I expect this issue to be resolved anytime soon, but I thought it would be nice to write down ideas to have something to start with.
In a perfect world I'd like to use JavaCall something like this:
Or even like this:
A bit closer target may be to implement something like this (i.e. call only one method of one object):
The problem with such syntax is that it lacks several bits of required information:
One way to fix issue with return type is to add them explicitly, similar to Java syntax:
Looks quite weird, but may work. However, it's still unclear how to pass argument types. Note, that
jcall
requires argument types from the method signature which may be parent types of actual arguments, e.g.:The best syntax that comes to mind is:
Or a bit simpler:
Another option is to use reflection to infer unknown parameters. Here we have 2 options:
jcall
.Second option looks attractive, but I have a little experience with generated functions and I'm not sure this will work.