-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b16
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
I'm using JDK 22
A DESCRIPTION OF THE PROBLEM :
There is no "java.lang.foreign" subcomponent on the bug report site, FYI, but that's where this belongs.
MemorySegment provides some very helpful get/setString methods to write strings to memory. However, they write null-terminated strings and rely on the terminator to find the length when reading. I am writing and reading strings I know the length of, and thus would like to avoid the overhead of searching for the terminator. Even with the heuristics in StringSupport it's still a mostly linear operation, which for long strings can be painful.
It's quite trivial to implement using StringSupport's copyBytes method, however StringSupport is internal (i.e. requires --add-exports) so it would be nice to have a public way of doing this.
I'm using JDK 22
A DESCRIPTION OF THE PROBLEM :
There is no "java.lang.foreign" subcomponent on the bug report site, FYI, but that's where this belongs.
MemorySegment provides some very helpful get/setString methods to write strings to memory. However, they write null-terminated strings and rely on the terminator to find the length when reading. I am writing and reading strings I know the length of, and thus would like to avoid the overhead of searching for the terminator. Even with the heuristics in StringSupport it's still a mostly linear operation, which for long strings can be painful.
It's quite trivial to implement using StringSupport's copyBytes method, however StringSupport is internal (i.e. requires --add-exports) so it would be nice to have a public way of doing this.
- links to
-
Commit(master) openjdk/jdk/3e0da58e
-
Review(master) openjdk/jdk/20725