Skip to content

Commit

Permalink
Use constants for system properties
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwiddis committed Nov 20, 2023
1 parent 44e732a commit 59471c8
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/com/sun/jna/Native.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static boolean isCompatibleVersion(String expectedVersion, String nativeVersion)
loadNativeDispatchLibrary();

if (! isCompatibleVersion(VERSION_NATIVE, getNativeVersion())) {
String LS = System.getProperty("line.separator");
String LS = System.lineSeparator();
throw new Error(LS + LS
+ "There is an incompatible JNA native library installed on this system" + LS
+ "Expected: " + VERSION_NATIVE + LS
Expand Down
2 changes: 1 addition & 1 deletion src/com/sun/jna/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ private String format(Class<?> type) {

private String toString(int indent, boolean showContents, boolean dumpMemory) {
ensureAllocated();
String LS = System.getProperty("line.separator");
String LS = System.lineSeparator();
String name = format(getClass()) + "(" + getPointer() + ")";
if (!(getPointer() instanceof Memory)) {
name += " (" + size() + " bytes)";
Expand Down
5 changes: 3 additions & 2 deletions test/com/sun/jna/DirectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -203,7 +204,7 @@ public void testGetOptionsForDirectMappingWithMemberInitializer() {
};
final TypeMapper mapper = new DefaultTypeMapper();
final int alignment = Structure.ALIGN_NONE;
final String encoding = System.getProperty("file.encoding");
final String encoding = Charset.defaultCharset().displayName();
Map<String, Object> options = new HashMap<>();
options.put(Library.OPTION_TYPE_MAPPER, mapper);
options.put(Library.OPTION_STRUCTURE_ALIGNMENT, alignment);
Expand All @@ -224,7 +225,7 @@ public void testGetOptionsForDirectMappingWithMemberInitializer() {
public static class DirectMappingStatic {
final static TypeMapper TEST_MAPPER = new DefaultTypeMapper();
final static int TEST_ALIGNMENT = Structure.ALIGN_DEFAULT;
final static String TEST_ENCODING = System.getProperty("file.encoding");
final static String TEST_ENCODING = Charset.defaultCharset().displayName();
final static Map<String, Object> TEST_OPTIONS = new HashMap<>() {
private static final long serialVersionUID = 1L; // we're not serializing it

Expand Down
2 changes: 1 addition & 1 deletion test/com/sun/jna/MemoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public void testDump() {
m.setByte(i, (byte) i);
}

String ls = System.getProperty("line.separator");
String ls = System.lineSeparator();

assertEquals("memory dump" + ls +
"[00010203]" + ls +
Expand Down
4 changes: 2 additions & 2 deletions test/com/sun/jna/NativeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testLongStringGeneration() {
}

public void testCustomStringEncoding() throws Exception {
final String ENCODING = System.getProperty("file.encoding");
final String ENCODING = Charset.defaultCharset().displayName();
// Keep stuff within the extended ASCII range so we work with more
// limited native encodings
String UNICODE = "Un \u00e9l\u00e9ment gr\u00e2ce \u00e0 l'index";
Expand Down Expand Up @@ -477,7 +477,7 @@ public void testGetBytesWithCharset() throws Exception {
public void testGetBytesBadEncoding() throws Exception {
byte[] buf = Native.getBytes(getName(), "unsupported");
assertEquals("Incorrect fallback bytes with bad encoding",
getName(), new String(buf, System.getProperty("file.encoding")));
getName(), new String(buf, Charset.defaultCharset().displayName()));
}

public void testFindDirectMappedClassFailure() {
Expand Down
2 changes: 1 addition & 1 deletion test/com/sun/jna/StructureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1429,7 +1429,7 @@ protected List<String> getFieldOrder() {
}
}
TestStructure s = new TestStructure();
final String LS = System.getProperty("line.separator");
final String LS = System.lineSeparator();
System.setProperty("jna.dump_memory", "true");
final String EXPECTED = "(?m).*" + s.size() + " bytes.*\\{" + LS
+ " int intField@0x0=0x0000" + LS
Expand Down

0 comments on commit 59471c8

Please sign in to comment.