1 /* 2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import java.awt.*; 25 import java.awt.MultipleGradientPaint.*; 26 import java.awt.image.*; 27 import java.io.*; 28 29 import javax.imageio.*; 30 import javax.swing.*; 31 32 /** 33 * @test 34 * @key headful 35 * @bug 8028722 36 * @summary tests wether drawString with 254 characters causes the xrender 37 * pipeline to hang. 38 * @author ceisserer 39 */ 40 public class XRenderElt254TextTest extends Frame implements Runnable { 41 public volatile boolean success = false; 42 43 public void run() { 44 Image dstImg = getGraphicsConfiguration().createCompatibleVolatileImage(400, 400); 45 Graphics2D g = (Graphics2D) dstImg.getGraphics(); 46 47 StringBuilder strBuilder = new StringBuilder(254); 48 for (int c = 0; c < 254; c++) { 49 strBuilder.append('a'); 50 } 51 52 for (int i = 0; i < 100; i++) { 53 g.drawString(strBuilder.toString(), 20, 20); 54 Toolkit.getDefaultToolkit().sync(); 55 } 56 success = true; 57 } 58 59 public static void main(String[] args) throws Exception { 60 XRenderElt254TextTest test = new XRenderElt254TextTest(); 61 new Thread(test).start(); 62 63 for (int i = 0; i < 30; i++) { 64 Thread.sleep(1000); 65 66 if (test.success) { 67 return; // Test finished successful 68 } 69 } 70 71 throw new RuntimeException("Test Failed"); 72 } 73 }