Hi, > This avoids a possible NPE when the byteorder system property is not > set.
Some people argued (on IRC IIRC) that we should rather let this fail if the property is not setup correcly. I think I agree and revert that like attached. 2007-04-03 Roman Kennke <[EMAIL PROTECTED]> * java/nio/ByteOrder.java (nativeByteOrder): Let this fail when the corresponding property is not set properly. /Roman -- http://kennke.org/blog/
Index: java/nio/ByteOrder.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/nio/ByteOrder.java,v retrieving revision 1.12 diff -u -1 -5 -r1.12 ByteOrder.java --- java/nio/ByteOrder.java 15 Feb 2007 10:38:30 -0000 1.12 +++ java/nio/ByteOrder.java 3 Apr 2007 20:56:25 -0000 @@ -49,31 +49,33 @@ */ public static final ByteOrder BIG_ENDIAN = new ByteOrder(); /** * Constant indicating little endian byte order. */ public static final ByteOrder LITTLE_ENDIAN = new ByteOrder(); /** * Returns the native byte order of the platform currently running. * * @return the native byte order */ public static ByteOrder nativeOrder() { - return ("big".equals(System.getProperty("gnu.cpu.endian")) + // Let this fail with an NPE when the property is not set correctly. + // Otherwise we risk that NIO is silently working wrong. + return (System.getProperty("gnu.cpu.endian").equals("big") ? BIG_ENDIAN : LITTLE_ENDIAN); } /** * Returns a string representation of the byte order. * * @return the string */ public String toString() { return this == BIG_ENDIAN ? "BIG_ENDIAN" : "LITTLE_ENDIAN"; } // This class can only be instantiated here. private ByteOrder()