jextract error when string contains newline character
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Sun Sep 20 16:15:33 UTC 2020
Hi Michael,
Well spotted - jextract shoud definitively quote the string, or use a
text block.
Filed:
https://bugs.openjdk.java.net/browse/JDK-8253390
Thanks
Maurizio
On 19/09/2020 01:07, Michael Ennen wrote:
> I am running jextract on Windows.h header file thusly:
>
> jextract --source -d . -t com.dx12 -I "$I\um" -I "$I\shared" -C
> "-DWIN32_LEAN_AND_MEAN" -- "$I\um\Windows.h"
>
> In one of the generated constants files (specifically
> Windows_h$constants$39.java) it generates the following:
>
> static final MemorySegment IMAGE_ARCHIVE_START$SEGMENT_CONSTANT_ =
> CLinker.toCString("!<arch>
> ");
> public static jdk.incubator.foreign.MemorySegment IMAGE_ARCHIVE_START()
> { return IMAGE_ARCHIVE_START$SEGMENT_CONSTANT_; }
>
> static final MemorySegment IMAGE_ARCHIVE_END$SEGMENT_CONSTANT_ =
> CLinker.toCString("`
> ");
> public static jdk.incubator.foreign.MemorySegment IMAGE_ARCHIVE_END() {
> return IMAGE_ARCHIVE_END$SEGMENT_CONSTANT_; }
>
> static final MemorySegment IMAGE_ARCHIVE_PAD$SEGMENT_CONSTANT_ =
> CLinker.toCString("
> ");
>
> It may be hard to see but if you take, for instance, the
> IMAGE_ARCHIVE_START segment, it is defined as the following string literal
> (from looking at various windows header files)
>
> "!<arch>\n"
>
> When jextract encounters the newline character it seems it is putting it in
> literally:
>
> CLinker.toCString("!<arch>
> ");
>
> and since it is not a valid multi-line string, java compilation fails.I
> believe it should be put in either as "\n" or as a valid multi-line string
> or as a string literal with plus symbols.
More information about the panama-dev
mailing list