File: force_use_nio.patch

package info (click to toggle)
libsis-base-java 18.09~pre1%2Bgit20180928.45fbd31%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,292 kB
  • sloc: java: 9,037; ansic: 813; xml: 160; sh: 139; makefile: 37
file content (175 lines) | stat: -rw-r--r-- 6,308 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
--- a/source/java/ch/systemsx/cisd/base/convert/NativeData.java
+++ b/source/java/ch/systemsx/cisd/base/convert/NativeData.java
@@ -15,8 +15,6 @@
 
 import java.nio.ByteBuffer;
 
-import ch.systemsx.cisd.base.utilities.NativeLibraryUtilities;
-
 /**
  * This class encapsulates native methods to deal with arrays of numbers, converting from numbers to
  * bytes and bytes to numbers.
@@ -28,27 +26,10 @@
  * primitive numbers (int, short, ...)
  * <p>
  * Variant interfaces convert only a sub-array.
- * <p>
- * The class has optimized methods using jni-libraries for some common platforms and a pure-java
- * implementation (called <i>javamode</i> if the jni-libraries are not available). If you want to
- * enforce <i>javamode</i>, you need to pass the property <code>nativedata.javamode=true</code> to
- * the JRE.
  */
 public class NativeData
 {
-    private static final boolean useNativeLib;
-
-    static
-    {
-        if (Boolean.getBoolean("nativedata.javamode"))
-        {
-            useNativeLib = false;
-        } else
-        {
-	    System.loadLibrary("cisd_nativedata");
-	    useNativeLib = true;
-        }
-    }
+    private static final boolean useNativeLib = false;
 
     /** Size of a <code>short</code> value in <code>byte</code>s. */
     public final static int SHORT_SIZE = 2;
--- a/sourceTest/java/ch/systemsx/cisd/base/convert/NativeDataTests.java
+++ b/sourceTest/java/ch/systemsx/cisd/base/convert/NativeDataTests.java
@@ -162,7 +162,6 @@
     @Test(dataProvider = "getOfs")
     public void testLongToByteToLong(int sourceOfs, int targetOfs)
     {
-        assertTrue(NativeData.isUseNativeLib());
         final int sizeOfTarget = 8;
         final long[] orignalArr = new long[]
             { -1, 17, 100000, -1000000 };
@@ -180,7 +179,6 @@
     @Test(dataProvider = "getOfs")
     public void testShortToByteToShort(int sourceOfs, int targetOfs)
     {
-        assertTrue(NativeData.isUseNativeLib());
         final int sizeOfTarget = 2;
         final short[] orignalArr = new short[]
             { -1, 17, 20000, (short) -50000 };
@@ -198,7 +196,6 @@
     @Test(dataProvider = "getOfs")
     public void testCharToByteToChar(int sourceOfs, int targetOfs)
     {
-        assertTrue(NativeData.isUseNativeLib());
         final int sizeOfTarget = 2;
         final char[] orignalArr = new char[]
             { 'c', ';', '\u0222', '\u1000' };
@@ -216,7 +213,6 @@
     @Test(dataProvider = "getOfs")
     public void testFloatToByteToFloat(int sourceOfs, int targetOfs)
     {
-        assertTrue(NativeData.isUseNativeLib());
         final int sizeOfTarget = 4;
         final float[] orignalArr = new float[]
             { -1, 17, 3.14159f, -1e6f };
@@ -234,7 +230,6 @@
     @Test(dataProvider = "getOfs")
     public void testDoubleToByteToDouble(int sourceOfs, int targetOfs)
     {
-        assertTrue(NativeData.isUseNativeLib());
         final int sizeOfTarget = 8;
         final double[] orignalArr = new double[]
             { -1, 17, 3.14159, -1e42 };
@@ -252,7 +247,6 @@
     @Test
     public void testShortEndianConversion()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final short[] values = new short[]
             { 1, 2, 4, 8, 16, 256, 512 };
         final short[] convertedValuesExpected = new short[]
@@ -266,7 +260,6 @@
     @Test
     public void testIntEndianConversion()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final int[] values = new int[]
             { 1, 2, 4, 8, 16, 256, 1 << 16 };
         final int[] convertedValuesExpected = new int[]
@@ -280,7 +273,6 @@
     @Test
     public void testLongEndianConversion()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final long[] values = new long[]
             { 1, 2, 4, 8, 16, 256, 1L << 16, 1L << 24 };
         final long[] convertedValuesExpected = new long[]
@@ -294,7 +286,6 @@
     @Test
     public void testFloatLittleEndianRoundtrip()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final float[] values = new float[]
             { 1.1f, 2.2f, 3.3f, 1e-25f, 1e25f };
         final float[] convertedValuesFound =
@@ -306,7 +297,6 @@
     @Test
     public void testFloatBigEndianRoundtrip()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final float[] values = new float[]
             { 1.1f, 2.2f, 3.3f, 1e-25f, 1e25f };
         final float[] convertedValuesFound =
@@ -318,7 +308,6 @@
     @Test
     public void testDoubleLittleEndianRoundtrip()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final double[] values = new double[]
             { 1.1f, 2.2f, 3.3f, 1e-25f, 1e25f };
         final double[] convertedValuesFound =
@@ -330,7 +319,6 @@
     @Test
     public void testDoubleBigEndianRoundtrip()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final double[] values = new double[]
             { 1.1, 2.2, 3.3, 1e-25, 1e25 };
         final double[] convertedValuesFound =
@@ -342,28 +330,24 @@
     @Test(expectedExceptions = NullPointerException.class)
     public void testNPE()
     {
-        assertTrue(NativeData.isUseNativeLib());
         NativeData.copyByteToLong(null, 0, null, 0, 0, ByteOrder.NATIVE);
     }
 
     @Test(expectedExceptions = IndexOutOfBoundsException.class)
     public void testIOOB()
     {
-        assertTrue(NativeData.isUseNativeLib());
         NativeData.copyByteToLong(new byte[] {}, -1, new long[] {}, 0, 0, ByteOrder.NATIVE);
     }
 
     @Test(expectedExceptions = IndexOutOfBoundsException.class)
     public void testIOOB2()
     {
-        assertTrue(NativeData.isUseNativeLib());
         NativeData.copyByteToLong(new byte[] {}, 0, new long[] {}, 10, 0, ByteOrder.NATIVE);
     }
 
     @Test
     public void testPlatformEndiness()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final double[] values = new double[]
             { 1.1, 2.2, 3.3, 1e-200, 1e200 };
         final double[] valuesLE =
@@ -387,7 +371,6 @@
     @Test
     public void testFloatToByteNonNativeByteOrderPartialOutputArray()
     {
-        assertTrue(NativeData.isUseNativeLib());
         final int sizeOfTarget = 4;
         final ByteOrder nonNativeByteOrder =
                 (NativeData.getNativeByteOrder() == ByteOrder.LITTLE_ENDIAN) ? ByteOrder.BIG_ENDIAN