oracle / graalpython

A Python 3 implementation built on GraalVM
Other
1.2k stars 104 forks source link

Exporting a method with a different name than its declaration #408

Open RevolvingMadness opened 2 months ago

RevolvingMadness commented 2 months ago

Let's say I have a Java class:

class Foo {
    public void bar() {
        System.out.println("bar");
    }
}

I want to access that bar method in python but with a different name. I swear a while ago I could do:

@HostAccess.Export(name = "barMethod")
public void bar() {
    System.out.println("bar");
}

But now the name field doesn't exist?

So then in Python it would be called with barMethod instead of bar.

chumer commented 2 months ago

That is currently not possible. Can you elaborate a bit on why you would want to do that instead of declaring a method with the new name?

RevolvingMadness commented 1 month ago

I have a typing library in python that allows IntelliSense to function and I want to use snake_case because that is what you are supposed to use with methods. In Java you're supposed to use camelCase for method names. So the declaration in Java would be barMethod the method in Python would be bar_method. I can just declare the methods in java as bar_method or the methods in Python as barMethod but I was just wondering if this was possible.