Skip to content

static const string in Java with javaconst(1) #1907

@gavol

Description

@gavol

When javaconst(1) is used, static const string are nor properly mapped and the generated code is not valid.

Example test module:

%module jTest

%include <typemaps.i>
%include <stl.i>
%javaconst(1);

struct Test {
    static const std::string aString = "something";
};

In Java the static const string is mapped to:

public final static String aString = something;

Note the missing quotes.

If javaconst(1) is removed, then valid Java code is generated:

public final static String aString = jTestJNI.Test_aString_get();

Using SWIG 4.0.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions