-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JClass is not properly supported #11
Comments
More generally, I'd say it's a question of supporting generic classes, since There are 2 ways to implement it, though. On one hand, we can automatically convert known types back and forward using information about
User would have to convert data between Julia and Java types himself, but general interface would be much simpler (imagine automatic conversion for something like Personally I tend to the second option because of JVM's type erasure: for runtime there's only primitive types and |
Yes, this is currently not supported, but is an interesting problem.. I think the best way to design this would be to look at actual use cases. Therefore, I would be interested in how you intend on using, eg, |
One use case I have in mind is automatic data conversion and serialization. In Julia-Spark connector, for example, it would be nice to have Generic type should not be necessarily expressed as Julia's type parameter, though. In fact, I'm currently experimenting with an approach where Java's class is not a part of |
The advantage of keeping the Java type as part of the julia type is that you can dispatch based on the Java type, without having to create a julia wrapper type for each java type. That is a huge benefit for wrapping api's, and I would be loath to give that away. I do want to support your use case, but don't understand the details of your usecase yet. So my confusion is as follows. If you have a parameterised java method that returns, say, JJavaRDD{T} , then, when you call that method at runtime, there is no information on what that T can be. You will have to do a runtime check and cast based on external information. So the question is, at what point do you know that T=java.lang.String , and where can you store the information. |
Sure, I'm not talking about inferring type parameters from JVM, but instead about attaching it to
Do you mean dispatching in user's code? Something like this:
? |
Ok, after long-long research I see that this issue is nothing more than naming confusion.
Does it make sense to rename |
BTW, don't you mind if I split code into several files and adjust indents according to CONTRIBUTING.md? If it's not a part of your style, such transformation should make code more easily readable and maintainable. |
Exactly. After I wrote the last comment, and went to bed, that is what i was thinking: "For method return values of
Probably. As you know,
I personally find it simpler to keep it all in my head if its in one file. Its not a very large file right now. But I can understand it if it makes it easier for others to understand the codebase. I would be open to that change, but could you sketch out how you see the files being split, in a separate issue, before you open a PR? I ask since such a PR would get stale very quickly, so I don't want to keep it open for too long for discussion. |
Finally, Andrei, since you are using JavaCall heavily for Sparta.jl, I would be happy to talk over hangouts or skype if you wanted to clarify any design or implementation issue. My email is on my github account. Let me know if you find that useful. |
Agree, it would be helpful, though currently I fill much more confident about the code and don't have a "global" questions right now :) Dicussing more local issues is better to do on GitHub so that others could also see and participate in it.
Just to complement the picture for myself and possibly others, there are 4 things in JVM that JavaCall supports:
So, the reason I had an error is that I tried to use static data where type should have been needed.
Well, for me keeping code in several (named) files just makes it easier to group related functions. E.g. when I first looked at the code, it wasn't obvious how |
As I said above, I'd be open to a PR splitting this up as well, since now I am not the only person reading this code. However, if you can briefly talk about a proposed split before submitting a PR, that will help reduce merge conflicts from this. |
I imagine following files then:
Though I'm not sure if it's possible to efficiently seperate types and |
All the |
Agree, especially given new conversions for date types. So I will prepare PR for splitting files after #15 is merged. I'm closing this issue since it's no longer concerns |
Although in Java
Class
is, well, a class itself, in JavaCall it is not an instance ofJavaObject
. This leads to errors in some cases. Here's an example.First, let's call
.toString()
method of some object to make sure we do everything right:And now let's do the same thing with
.getClass
which returnsJClass
:The error comes from
signature()
method which is supposed to return single-character descriptor of a type, but, when givenJClass
, returns nothing:Most probably, for this specific case it's possible to simply overload
signature()
method, but I'm not sure there will be no other issues with distinction betweenJClass
/JavaObject
, so I leave this design question to you.The text was updated successfully, but these errors were encountered: