Mercurial > hg > graal-jvmci-8
comparison agent/src/share/classes/sun/jvm/hotspot/runtime/Bytes.java @ 6881:8eeffbc22f10
8001055: Bytes.swap should follow big endian
Summary: This is a mistake change in 6879063 about Bytes.swap. Java byte code order always follows big endian, but in that change, assume they follow native platform order that is not right.
Reviewed-by: coleenp, sspitsyn, dholmes
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Fri, 19 Oct 2012 08:58:14 -0700 |
parents | b9a9ed0f8eeb |
children |
comparison
equal
deleted
inserted
replaced
6880:c7957b458bf8 | 6881:8eeffbc22f10 |
---|---|
28 import sun.jvm.hotspot.utilities.PlatformInfo; | 28 import sun.jvm.hotspot.utilities.PlatformInfo; |
29 | 29 |
30 /** Encapsulates some byte-swapping operations defined in the VM */ | 30 /** Encapsulates some byte-swapping operations defined in the VM */ |
31 | 31 |
32 public class Bytes { | 32 public class Bytes { |
33 // swap if client platform is different from server's. | |
34 private boolean swap; | 33 private boolean swap; |
35 | 34 |
36 public Bytes(MachineDescription machDesc) { | 35 public Bytes(MachineDescription machDesc) { |
37 String cpu = PlatformInfo.getCPU(); | 36 swap = !machDesc.isBigEndian(); |
38 if (cpu.equals("sparc")) { | |
39 if (machDesc.isBigEndian()) { | |
40 swap = false; | |
41 } else { | |
42 swap = true; | |
43 } | |
44 } else { // intel | |
45 if (machDesc.isBigEndian()) { | |
46 swap = true; | |
47 } else { | |
48 swap = false; | |
49 } | |
50 } | |
51 } | 37 } |
52 | 38 |
53 /** Should only swap if the hardware's underlying byte order is | 39 /** Should only swap if the hardware's underlying byte order is |
54 different from Java's */ | 40 different from Java's */ |
55 public short swapShort(short x) { | 41 public short swapShort(short x) { |