Skip to content
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

Hide jpy from Python users #1138

Open
jjbrosnan opened this issue Aug 26, 2021 · 2 comments
Open

Hide jpy from Python users #1138

jjbrosnan opened this issue Aug 26, 2021 · 2 comments
Assignees
Labels
feature request New feature or request java python
Milestone

Comments

@jjbrosnan
Copy link
Contributor

jjbrosnan commented Aug 26, 2021

In our documentation, we have some instances of Python code that uses jpy to call Java from Python. We've begun to add some functionalities to the deephaven module that allow a user to call java without using jpy. One area that isn't covered, though, is importing Java packages in Python.

Currently, it's extremely diffieult (if not impossible) to implement the analogue of the following code in Python:

ClassLoader.getSystemClassLoader().addURL(new URL(URL_to_jar))

The closest you can get in Python is:

import jpy
URL = jpy.get_type("java.net.URL")
URLClassLoader = jpy.get_type("java.net.URLClassLoader")
jar_url = URL(URL_to_jar)
URL_array = jpy.array(URL, [jar_url])
cryptocompare_classloader = URLClassLoader(URL_array)

This, however, creates a URLClassLoader, but does not get the System ClassLoader. Attempting to call getSystemClassLoader() returns a java.lang.ClassLoader, which does not have an addURL() method.

If a user wants to use an external Java package in a Python console for some reason, they can't. It would be pretty nice to have a little java method that can be called from Python to make this easy for a Python user.

@jjbrosnan jjbrosnan added feature request New feature or request python java labels Aug 26, 2021
@jjbrosnan jjbrosnan added this to the Oct 2021 milestone Aug 26, 2021
@pete-petey pete-petey modified the milestones: Oct 2021, Jan 2022 Dec 29, 2021
@pete-petey pete-petey modified the milestones: Jan 2022, May 2022 Apr 15, 2022
@jmao-denver
Copy link
Contributor

jmao-denver commented May 20, 2022

@chipkent I am puzzled that this is slated for May delivery. I talked to @jjbrosnan to learn more about it and he suggested that I reach out to you to see if there is a concrete use case that could demo this is something we absolutely need to provide. Your thoughts?

@chipkent
Copy link
Member

  1. I don't think this is a May deliverable.
  2. I think this stuff gets fixed by Make Python import Java types using import #1525.
  3. I think the example above can be made to work using jpy.get_type('java.lang.ClassLoader'), so that the python is just like the Java. @jjbrosnan

@jmao-denver jmao-denver modified the milestones: May 2022, Backlog May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request java python
Projects
None yet
Development

No branches or pull requests

4 participants