Skip to content

Commit f650053

Browse files
committed
removal of unicode characters from jmol/4.2 version Hashtable, HashSet,
HashMap, LinkedHashMap. MessagePackReader fix.
1 parent 9aff277 commit f650053

File tree

12 files changed

+164
-154
lines changed

12 files changed

+164
-154
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20240114215407
1+
20240204101011
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20240114215407
1+
20240204101011
Binary file not shown.

sources/net.sf.j2s.java.core/site-resources/test-raf.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

sources/net.sf.j2s.java.core/src/java/util/Hashtable.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,10 @@ public T nextElement() {
18931893

18941894
@Override
18951895
public V setValue(V value) {
1896-
return Hashtable.this.put(getKey(), value);
1896+
int m = modCount;
1897+
V v = put(getKey(), value);
1898+
modCount = m;
1899+
return v;
18971900
}
18981901
};
18991902
}

sources/net.sf.j2s.java.core/src/javajs/util/MessagePackReader.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ public Object getNext(Object array, int pt) throws Exception {
181181
if (array == null) {
182182
switch (b) {
183183
case FLOAT32:
184-
return Float.valueOf(doc.readFloat());
184+
return Double.valueOf(doc.readFloat());
185185
case FLOAT64:
186-
return Float.valueOf((float) doc.readDouble());
186+
return Double.valueOf(doc.readDouble());
187187
case UINT8:
188188
return Integer.valueOf(doc.readUInt8());
189189
case UINT16:
@@ -203,17 +203,17 @@ public Object getNext(Object array, int pt) throws Exception {
203203
case STR8:
204204
return doc.readString(doc.readUInt8());
205205
case STR16:
206-
return doc.readString(doc.readShort());
206+
return doc.readString(doc.readUnsignedShort());
207207
case STR32:
208208
return doc.readString(doc.readInt());
209209
}
210210
} else {
211211
switch (b) {
212212
case FLOAT32:
213-
((float[]) array)[pt] = doc.readFloat();
213+
((double[]) array)[pt] = doc.readFloat();
214214
break;
215215
case FLOAT64:
216-
((float[]) array)[pt] = (float) doc.readDouble();
216+
((double[]) array)[pt] = doc.readDouble();
217217
break;
218218
case UINT8:
219219
((int[]) array)[pt] = doc.readUInt8();
@@ -243,10 +243,10 @@ public Object getNext(Object array, int pt) throws Exception {
243243
((String[]) array)[pt] = doc.readString(doc.readUInt8());
244244
break;
245245
case STR16:
246-
((String[]) array)[pt] = doc.readString(doc.readShort());
246+
((String[]) array)[pt] = doc.readString(doc.readUnsignedShort());
247247
break;
248248
case STR32:
249-
((String[]) array)[pt] = doc.readString(doc.readInt());
249+
((String[]) array)[pt] = doc.readString(doc.readInt()); // technically shoild be unsigned int
250250
break;
251251
}
252252
}
@@ -267,9 +267,9 @@ private Object getArray(int n) throws Exception {
267267
int[] a = new int[n];
268268
a[0] = ((Integer) v).intValue();
269269
v = a;
270-
} else if (v instanceof Float) {
271-
float[] a = new float[n];
272-
a[0] = ((Float) v).floatValue();
270+
} else if (v instanceof Number) {
271+
double[] a = new double[n];
272+
a[0] = ((Number) v).doubleValue();
273273
v = a;
274274
} else if (v instanceof String) {
275275
String[] a = new String[n];
@@ -296,8 +296,6 @@ private Object getMap(int n) throws Exception {
296296
Map<String, Object> map = new Hashtable<String, Object>();
297297
for (int i = 0; i < n; i++) {
298298
String key = getNext(null, 0).toString();
299-
//Logger.info(key);
300-
301299
Object value = getNext(null, 0);
302300
if (value == null) {
303301
//Logger.info("null value for " + key);
@@ -366,10 +364,10 @@ public static Object decode(byte[] b) {
366364
* @param divisor
367365
* @return array of floats
368366
*/
369-
public static float[] getFloats(byte[] b, int n, float divisor) {
367+
public static double[] getFloats(byte[] b, int n, float divisor) {
370368
if (b == null)
371369
return null;
372-
float[] a = new float[n];
370+
double[] a = new double[n];
373371
try {
374372
switch ((b.length - 12) / n) {
375373
case 2:
@@ -522,10 +520,10 @@ public static int[] rldecode32Delta(byte[] b, int n) {
522520
* @param divisor
523521
* @return array of floats
524522
*/
525-
public static float[] rldecodef(byte[] b, int n, float divisor) {
523+
public static double[] rldecodef(byte[] b, int n, float divisor) {
526524
if (b == null)
527525
return null;
528-
float[] ret = new float[n];
526+
double[] ret = new double[n];
529527
for (int i = 0, pt = 3; i < n;) {
530528
int val = BC.bytesToInt(b, (pt++) << 2, true);
531529
for (int j = BC.bytesToInt(b, (pt++) << 2, true); --j >= 0;)
@@ -545,10 +543,10 @@ public static float[] rldecodef(byte[] b, int n, float divisor) {
545543
* @param divisor
546544
* @return array of floats
547545
*/
548-
public static float[] unpack16Deltaf(byte[] b, int n, float divisor) {
546+
public static double[] unpack16Deltaf(byte[] b, int n, float divisor) {
549547
if (b == null)
550548
return null;
551-
float[] ret = new float[n];
549+
double[] ret = new double[n];
552550
for (int i = 0, pt = 6, val = 0, buf = 0; i < n;) {
553551
int diff = BC.bytesToShort(b, (pt++) << 1, true);
554552
if (diff == Short.MAX_VALUE || diff == Short.MIN_VALUE) {
@@ -575,10 +573,10 @@ public static float[] unpack16Deltaf(byte[] b, int n, float divisor) {
575573
* @param divisor
576574
* @return array of floats
577575
*/
578-
public static float[] unpackf(byte[] b, int nBytes, int n, float divisor) {
576+
public static double[] unpackf(byte[] b, int nBytes, int n, float divisor) {
579577
if (b == null)
580578
return null;
581-
float[] ret = new float[n];
579+
double[] ret = new double[n];
582580
switch (nBytes) {
583581
case 1:
584582
for (int i = 0, pt = 12, offset = 0; i < n;) {

sources/net.sf.j2s.java.core/src/test/Test_String.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.UnsupportedEncodingException;
44
import java.nio.CharBuffer;
5+
import java.util.HashMap;
56

67
import javajs.util.Rdr;
78
import javajs.util.SB;
@@ -12,6 +13,10 @@ public static void main(String[] args) {
1213
String s, sb;
1314
byte[] b;
1415

16+
HashMap<String, String> map = new HashMap<String, String>();
17+
map.put("test", "value");
18+
System.out.println("test=" + map.get("test"));
19+
1520
sb = new String(new byte[] { 97, 98, 99 });
1621
System.out.println(sb);
1722
assert (sb.equals("abc"));

0 commit comments

Comments
 (0)