# HG changeset patch # User Lukas Stadler # Date 1396628635 -7200 # Node ID cd9404a8216b09a5581e4b2176bfbe4ae4617276 # Parent 82399ac30721ab7f8323d6368edc7f4956c1ae9c fix NPE in HexCodeFile diff -r 82399ac30721 -r cd9404a8216b graal/com.oracle.graal.printer/src/com/oracle/graal/printer/HexCodeFile.java --- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/HexCodeFile.java Fri Apr 04 17:06:44 2014 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/HexCodeFile.java Fri Apr 04 18:23:55 2014 +0200 @@ -39,23 +39,23 @@ * *
  *     HexCodeFile ::= Platform Delim HexCode Delim (OptionalSection Delim)*
- * 
+ *
  *     OptionalSection ::= Comment | OperandComment | JumpTable | LookupTable
- * 
+ *
  *     Platform ::= "Platform" ISA WordWidth
- * 
+ *
  *     HexCode ::= "HexCode" StartAddress HexDigits
- * 
+ *
  *     Comment ::= "Comment" Position String
- * 
+ *
  *     OperandComment ::= "OperandComment" Position String
- * 
+ *
  *     JumpTable ::= "JumpTable" Position EntrySize Low High
- * 
+ *
  *     LookupTable ::= "LookupTable" Position NPairs KeySize OffsetSize
- * 
+ *
  *     Position, EntrySize, Low, High, NPairs KeySize OffsetSize ::= int
- * 
+ *
  *     Delim := "<||@"
  * 
* @@ -184,15 +184,19 @@ * Formats a byte array as a string of hex digits. */ public static String hexCodeString(byte[] code) { - StringBuilder sb = new StringBuilder(code.length * 2); - for (int b : code) { - String hex = Integer.toHexString(b & 0xff); - if (hex.length() == 1) { - sb.append('0'); + if (code == null) { + return ""; + } else { + StringBuilder sb = new StringBuilder(code.length * 2); + for (int b : code) { + String hex = Integer.toHexString(b & 0xff); + if (hex.length() == 1) { + sb.append('0'); + } + sb.append(hex); } - sb.append(hex); + return sb.toString(); } - return sb.toString(); } /**