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

Introduce Java Interface Generator #438

Open
fniephaus opened this issue Oct 24, 2024 · 0 comments
Open

Introduce Java Interface Generator #438

fniephaus opened this issue Oct 24, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@fniephaus
Copy link
Member

TL;DR

We plan to provide a tool for generating Java interfaces for Python packages, providing a more seamless and user-friendly experience for creating Java applications that leverage Python packages.

Goals

The polyglot Value API can be used to interact dynamically with objects and call methods or functions from GraalPy and other Graal Languages. Such a value can also be mapped to a Java type via Value.as(java.lang.Class), which allows Java developers to program against a Java interface to interact with Python objects rather than the dynamic Value API. This, however, requires GraalPy users to provide appropriate Java interfaces for the Python packages they want to use.
The goal of this project is to create a tool that can generate Java interfaces for Python types. This is especially useful to automate the interface creation step, allowing developers to generate and regenerate Java interfaces whenever they change or upgrade the Python packages they would like to embed in Java.

Non-Goals

In the first version, it likely won't be possible to fully automate the generation of Java interfaces. The goal is not to integrate this generator into the Maven and Gradle build cycles just yet but rather to create a standalone tool that can be reused multiple times.
The generator relies on Python type annotations and typeshed files (.pyi) to improve type inference for return values and arguments. However, the goal is not to accurately detect all types, and the generator will often fall back to Value or the Java Object class for ambiguous cases.

@fniephaus fniephaus added the enhancement New feature or request label Oct 24, 2024
@fniephaus fniephaus added this to the Planned for the Future milestone Oct 24, 2024
@fniephaus fniephaus moved this to In Progress in GraalPy Roadmap Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

2 participants