Wed, 28 Aug 2013 19:25:18 -0400
8023900: [TESTBUG] Initial compact profile test groups need adjusting
Reviewed-by: dcubed, mchung, hseigel
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | /** |
aoqi@0 | 26 | * @test |
aoqi@0 | 27 | * @bug 6732154 |
aoqi@0 | 28 | * @summary REG: Printing an Image using image/gif doc flavor crashes the VM, Solsparc |
aoqi@0 | 29 | * |
aoqi@0 | 30 | * @run main/othervm -Xcomp -XX:CompileOnly="Test6732154::ascii85Encode" Test6732154 |
aoqi@0 | 31 | */ |
aoqi@0 | 32 | public class Test6732154 { |
aoqi@0 | 33 | |
aoqi@0 | 34 | // Exact copy of sun.print.PSPrinterJob.ascii85Encode([b)[b |
aoqi@0 | 35 | private byte[] ascii85Encode(byte[] inArr) { |
aoqi@0 | 36 | byte[] outArr = new byte[((inArr.length+4) * 5 / 4) + 2]; |
aoqi@0 | 37 | long p1 = 85; |
aoqi@0 | 38 | long p2 = p1*p1; |
aoqi@0 | 39 | long p3 = p1*p2; |
aoqi@0 | 40 | long p4 = p1*p3; |
aoqi@0 | 41 | byte pling = '!'; |
aoqi@0 | 42 | |
aoqi@0 | 43 | int i = 0; |
aoqi@0 | 44 | int olen = 0; |
aoqi@0 | 45 | long val, rem; |
aoqi@0 | 46 | |
aoqi@0 | 47 | while (i+3 < inArr.length) { |
aoqi@0 | 48 | val = ((long)((inArr[i++]&0xff))<<24) + |
aoqi@0 | 49 | ((long)((inArr[i++]&0xff))<<16) + |
aoqi@0 | 50 | ((long)((inArr[i++]&0xff))<< 8) + |
aoqi@0 | 51 | ((long)(inArr[i++]&0xff)); |
aoqi@0 | 52 | if (val == 0) { |
aoqi@0 | 53 | outArr[olen++] = 'z'; |
aoqi@0 | 54 | } else { |
aoqi@0 | 55 | rem = val; |
aoqi@0 | 56 | outArr[olen++] = (byte)(rem / p4 + pling); rem = rem % p4; |
aoqi@0 | 57 | outArr[olen++] = (byte)(rem / p3 + pling); rem = rem % p3; |
aoqi@0 | 58 | outArr[olen++] = (byte)(rem / p2 + pling); rem = rem % p2; |
aoqi@0 | 59 | outArr[olen++] = (byte)(rem / p1 + pling); rem = rem % p1; |
aoqi@0 | 60 | outArr[olen++] = (byte)(rem + pling); |
aoqi@0 | 61 | } |
aoqi@0 | 62 | } |
aoqi@0 | 63 | // input not a multiple of 4 bytes, write partial output. |
aoqi@0 | 64 | if (i < inArr.length) { |
aoqi@0 | 65 | int n = inArr.length - i; // n bytes remain to be written |
aoqi@0 | 66 | |
aoqi@0 | 67 | val = 0; |
aoqi@0 | 68 | while (i < inArr.length) { |
aoqi@0 | 69 | val = (val << 8) + (inArr[i++]&0xff); |
aoqi@0 | 70 | } |
aoqi@0 | 71 | |
aoqi@0 | 72 | int append = 4 - n; |
aoqi@0 | 73 | while (append-- > 0) { |
aoqi@0 | 74 | val = val << 8; |
aoqi@0 | 75 | } |
aoqi@0 | 76 | byte []c = new byte[5]; |
aoqi@0 | 77 | rem = val; |
aoqi@0 | 78 | c[0] = (byte)(rem / p4 + pling); rem = rem % p4; |
aoqi@0 | 79 | c[1] = (byte)(rem / p3 + pling); rem = rem % p3; |
aoqi@0 | 80 | c[2] = (byte)(rem / p2 + pling); rem = rem % p2; |
aoqi@0 | 81 | c[3] = (byte)(rem / p1 + pling); rem = rem % p1; |
aoqi@0 | 82 | c[4] = (byte)(rem + pling); |
aoqi@0 | 83 | |
aoqi@0 | 84 | for (int b = 0; b < n+1 ; b++) { |
aoqi@0 | 85 | outArr[olen++] = c[b]; |
aoqi@0 | 86 | } |
aoqi@0 | 87 | } |
aoqi@0 | 88 | |
aoqi@0 | 89 | // write EOD marker. |
aoqi@0 | 90 | outArr[olen++]='~'; outArr[olen++]='>'; |
aoqi@0 | 91 | |
aoqi@0 | 92 | /* The original intention was to insert a newline after every 78 bytes. |
aoqi@0 | 93 | * This was mainly intended for legibility but I decided against this |
aoqi@0 | 94 | * partially because of the (small) amount of extra space, and |
aoqi@0 | 95 | * partially because for line breaks either would have to hardwire |
aoqi@0 | 96 | * ascii 10 (newline) or calculate space in bytes to allocate for |
aoqi@0 | 97 | * the platform's newline byte sequence. Also need to be careful |
aoqi@0 | 98 | * about where its inserted: |
aoqi@0 | 99 | * Ascii 85 decoder ignores white space except for one special case: |
aoqi@0 | 100 | * you must ensure you do not split the EOD marker across lines. |
aoqi@0 | 101 | */ |
aoqi@0 | 102 | byte[] retArr = new byte[olen]; |
aoqi@0 | 103 | System.arraycopy(outArr, 0, retArr, 0, olen); |
aoqi@0 | 104 | return retArr; |
aoqi@0 | 105 | } |
aoqi@0 | 106 | |
aoqi@0 | 107 | public static void main(String[] args) { |
aoqi@0 | 108 | new Test6732154().ascii85Encode(new byte[0]); |
aoqi@0 | 109 | System.out.println("Test passed."); |
aoqi@0 | 110 | } |
aoqi@0 | 111 | } |