Skip to content

Conversation

@gayanW
Copy link
Collaborator

@gayanW gayanW commented Jul 22, 2018

This refactors String model class based on JDK 10.0.1 source.

  • Add support for JEP 254: Compact Strings, which fixes NoSuchFieldError: String.COMPACT_STRINGS #118

      [junit] java.lang.NoSuchFieldError: java.lang.String.COMPACT_STRINGS
    
  • Refactor String#contentEquals(java.lang.CharSequence) as the current implementation only handles UTF16

@cyrille-artho
Copy link
Member

Is there a way to test this code?

gayanW added 3 commits July 23, 2018 18:00
The value for java.lang.String#COMPACT_STRINGS is injected by JVM.
If it is set to false, bytes in value are always encoded in UTF16.

This also fixes javapathfinder#118:
  [junit] java.lang.NoSuchFieldError: java.lang.String.COMPACT_STRINGS
Currently String#contentEquals(java.lang.CharSequence) implementation
only handles if the bytes in the String value are UTF16 encoded. If not
it throws an assertion error like the following:

    [junit] java.lang.AssertionError: Currently only UTF16 is supported for String comparision with an instance of type AbstractStringBuilder
    [junit]     at java.lang.String.contentEquals(String.java:275)
    [junit]     at gov.nasa.jpf.test.java.lang.StringTest.testContentEquals(StringTest.java:301)
    [junit]     at java.lang.reflect.Method.invoke(gov.nasa.jpf.vm.JPF_java_lang_reflect_Method)
    [junit]     at gov.nasa.jpf.util.test.TestJPF.runTestMethod(TestJPF.java:648)

This updates String#contentEquals(java.lang.CharSequence) method, so it
handles both LATIN1 and UTF16 encoded Strings.
java.lang.String#hash should only need assign when using the
constructor String#String(java.lang.String)
@gayanW
Copy link
Collaborator Author

gayanW commented Jul 23, 2018

You may test it with the JUnit test class StringTest. First two commits 9fad766 and ed880f4 each addresses specific errors which you may find if you run the StringTest with showoutput parameter set to on.

I separate this to smaller commits, so it becomes easier to review.

@gayanW gayanW reopened this Jul 23, 2018
@cyrille-artho cyrille-artho merged commit 7ab53c3 into javapathfinder:java-10 Jul 23, 2018
@cyrille-artho
Copy link
Member

cyrille-artho commented Jul 23, 2018 via email

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants