Skip to content

getString() results are ambiguous #2522

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

Closed
pointhi opened this issue Aug 27, 2019 · 3 comments
Closed

getString() results are ambiguous #2522

pointhi opened this issue Aug 27, 2019 · 3 comments

Comments

@pointhi
Copy link

pointhi commented Aug 27, 2019

Simple a copy of a comment, to have a distinct bug report: #2286 (comment)

It seems String constants are not properly defined. This means, I'm able to create constants with different values, but reading them again causes one of the strings to alter in such a way to look like the other one. For example: \n and \\n will always read \\n.

    @Test
    public void shouldNotWorkTest() {
        Context ctx = new Context();

        Assert.assertEquals("\\n", ctx.mkString("\n").getString());
        Assert.assertEquals("\\n", ctx.mkString("\\n").getString());

        ctx.close();
    }

Unless, I use the API in a wrong way, this means Strings are not properly defined using the java interface. Actually, z3 should never try to escape strings, and simply return the internal representation. Otherwise every user needs to write a parser for escaped string constants.

@NikolajBjorner
Copy link
Contributor

The java interface uses an underlying Z3_get_string function that produces an escaped string.
There is another API function Z3_get_lstring, which is for the non-escaped strings, but it may need a different prototype in order not to produce a java string, but a byte sequence that can be marshaled into a proper java string.

NikolajBjorner added a commit that referenced this issue Oct 8, 2019
Signed-off-by: Nikolaj Bjorner <[email protected]>
@NikolajBjorner
Copy link
Contributor

Would be useful to get a hand on operating JNI conventions to finish this feature for Java.

@NikolajBjorner
Copy link
Contributor

Seems there is no interest in fixing the Java bindings.
The python bindings now use Z3_get_lstring correctly.

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

No branches or pull requests

2 participants