# HG changeset patch # User sundar # Date 1433248168 -19800 # Node ID 24cb54d0bfa2a3870d3fa0be65ed1c5d2a8c9b73 # Parent d03088193a17a85f450da230724d4e6f5dd1630b# Parent e5b03cc6f26966d2d524bda53a17b287326bb060 Merge diff -r d03088193a17 -r 24cb54d0bfa2 src/jdk/nashorn/internal/runtime/Source.java --- a/src/jdk/nashorn/internal/runtime/Source.java Tue Jun 02 10:40:19 2015 +0200 +++ b/src/jdk/nashorn/internal/runtime/Source.java Tue Jun 02 17:59:28 2015 +0530 @@ -910,14 +910,16 @@ start = 2; cs = StandardCharsets.UTF_16BE; } else if (bytes.length > 1 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE) { - start = 2; - cs = StandardCharsets.UTF_16LE; + if (bytes.length > 3 && bytes[2] == 0 && bytes[3] == 0) { + start = 4; + cs = Charset.forName("UTF-32LE"); + } else { + start = 2; + cs = StandardCharsets.UTF_16LE; + } } else if (bytes.length > 2 && bytes[0] == (byte) 0xEF && bytes[1] == (byte) 0xBB && bytes[2] == (byte) 0xBF) { start = 3; cs = StandardCharsets.UTF_8; - } else if (bytes.length > 3 && bytes[0] == (byte) 0xFF && bytes[1] == (byte) 0xFE && bytes[2] == 0 && bytes[3] == 0) { - start = 4; - cs = Charset.forName("UTF-32LE"); } else if (bytes.length > 3 && bytes[0] == 0 && bytes[1] == 0 && bytes[2] == (byte) 0xFE && bytes[3] == (byte) 0xFF) { start = 4; cs = Charset.forName("UTF-32BE");