Skip to content

Java wrapper classes handling #9

Closed

Description

@iuliux

The Java wrapper classes (Integer, Boolean, Byte, Char, Short, Long, Float, Double [and String]) should be handled consistently.

At the moment Integer, Boolean and String are translated into primitive types in Python and the rest are treated as common objects.

I think that the same rule should apply to all of them.

A big problem here are the (pretty useful) static methods inside them.

Activity

  1. natural commented on Apr 24, 2012

    @natural
    Owner

    I wrote a test for this:

    https://github.com/natural/java2python/blob/master/test/BasicTypes2.java

    And after the bug fix in 940a4ff, it passes. All of the types you mention are translated into Python builtin types.

    | A big problem here are the (pretty useful) static methods inside them.

    Could you explain what this means?

  2. iuliux commented on Apr 24, 2012

    @iuliux
    ContributorAuthor

    Could you explain what this means?

    I was referring to methods like:

    int a = Integer.parseInt(string_numeral);
    

    But never mind. I just tried it out and it looks good.
    Sorry, my bad, speaking before testing.

    But it is still inconsistent, and I mean by this:

    // Integer
    obj = (Integer) o;
    // Float
    obj = (Float) o;
    

    turns into:

    #  Integer
    self.obj = int(o)
    #  Float
    self.obj = o
    

    Maybe just adding some more rules in config/default.py for the rest of the types would be a good solution?

  3. natural commented on Apr 25, 2012

    @natural
    Owner

    Commit 0d1e103 should address your concerns. Please review and advise, and if everything is ok, close the ticket.

    Thanks again for all of your feedback!

  4. iuliux commented on Apr 25, 2012

    @iuliux
    ContributorAuthor

    It's ok, only skipped the Float from there. I fixed it quickly in Pull Req #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions