Skip to content

Commit 7bac7a5

Browse files
committed
Use the native encoding for reading the file written by a native process (forked compiler).
#327
1 parent 1271c85 commit 7bac7a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/org/apache/maven/plugin/compiler/ForkedTool.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ final boolean run(
164164
builder.redirectOutput(dest);
165165
return start(builder, out) == 0;
166166
} finally {
167-
out.append(Files.readString(output.toPath()));
167+
/*
168+
* Need to use the native encoding because it is the encoding used by the native process.
169+
* This is not necessarily the default encoding of the JVM, which is "file.encoding".
170+
* This property is available since Java 17.
171+
*/
172+
String cs = System.getProperty("native.encoding");
173+
out.append(Files.readString(output.toPath(), Charset.forName(cs)));
168174
output.delete();
169175
}
170176
}

0 commit comments

Comments
 (0)