1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/compiler/5091921/Test6357214.java Wed May 04 13:12:42 2011 -0700 1.3 @@ -0,0 +1,179 @@ 1.4 +/* 1.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +/** 1.29 + * @test 1.30 + * @bug 6357214 1.31 + * @summary Hotspot server compiler gets integer comparison wrong 1.32 + * 1.33 + * @run main/othervm/timeout=60 -DshowAll=ffo -DeventID=444 Test6357214 1.34 + */ 1.35 + 1.36 +// The test hangs after few iterations before the fix. So it fails if timeout. 1.37 +class MyResult { 1.38 + public boolean next() { 1.39 + return true; 1.40 + } 1.41 + 1.42 + public String getString(String in) { 1.43 + if (in.equals("id")) 1.44 + return "idFoo"; 1.45 + if (in.equals("contentKey")) 1.46 + return "ckFoo"; 1.47 + return "Foo"; 1.48 + } 1.49 + 1.50 + public int getInt(String in) { 1.51 + if (in.equals("processingComplete")) 1.52 + return 0; 1.53 + return 1; 1.54 + } 1.55 + 1.56 + public byte[] getBytes(String in) { 1.57 + byte[] arr = null; 1.58 + if (in.equals("content")) { 1.59 + arr = new byte[65536]; 1.60 + byte j = 32; 1.61 + for (int i=0; i<65536; i++) { 1.62 + arr[i] = j; 1.63 + if (++j == 127) 1.64 + j=32; 1.65 + } 1.66 + } 1.67 + return arr; 1.68 + } 1.69 +} 1.70 + 1.71 +public class Test6357214 { 1.72 + public static volatile boolean bollocks = true; 1.73 + public String create(String context) throws Exception { 1.74 + 1.75 + // 1.76 + // Extract HTTP parameters 1.77 + // 1.78 + 1.79 + boolean showAll = System.getProperty("showAll") != null; 1.80 + String eventID = System.getProperty("eventID"); 1.81 + String eventContentKey = System.getProperty("cKey"); 1.82 + // 1.83 + // Build ContentStaging query based on eventID or eventContentKey 1.84 + // 1.85 + 1.86 + String sql = "select id, processingComplete, contentKey, content " 1.87 + + "from ContentStaging cs, ContentStagingKey csk " 1.88 + + "where cs.eventContentKey = csk.eventContentKey "; 1.89 + 1.90 + if (eventID != null) { 1.91 + sql += "and id = " + eventID; 1.92 + } 1.93 + else if (eventContentKey != null) { 1.94 + sql += "and cs.eventContentKey = '" 1.95 + + eventContentKey 1.96 + + "' having id = max(id)"; 1.97 + } 1.98 + else { 1.99 + throw new Exception("Need eventID or eventContentKey"); 1.100 + } 1.101 + 1.102 + // 1.103 + // This factory builds a static panel, there is no JSP 1.104 + // 1.105 + 1.106 + StringBuffer html = new StringBuffer(); 1.107 + 1.108 + try { 1.109 + 1.110 + MyResult result = new MyResult(); 1.111 + if (result.next()) { 1.112 + 1.113 + eventID = result.getString("id"); 1.114 + int processingComplete = result.getInt("processingComplete"); 1.115 + String contentKey = result.getString("contentKey"); 1.116 + byte[] bytes = result.getBytes("content"); 1.117 + 1.118 + // 1.119 + // Print content status and associated controls 1.120 + // 1.121 + 1.122 + html.append("<br/><font class=\"small\">"); 1.123 + html.append("Status: "); 1.124 + switch (processingComplete) { 1.125 + case 0 : 1.126 + case 1 : html.append("PENDING"); break; 1.127 + case 2 : html.append(contentKey); break; 1.128 + case 3 : html.append(eventID); break; 1.129 + default : html.append("UNKNONW"); 1.130 + } 1.131 + html.append("</font><br/>"); 1.132 + 1.133 + // 1.134 + // Print at most 20Kb of content unless "showAll" is set 1.135 + // 1.136 + 1.137 + int limit = showAll ? Integer.MAX_VALUE : 1024 * 20; 1.138 + System.out.println(limit); 1.139 + html.append("<pre>"); 1.140 + for (int i = 0; bytes != null && i < bytes.length; i++) { 1.141 + char c = (char) bytes[i]; 1.142 + switch (c) { 1.143 + case '<' : html.append("<"); break; 1.144 + case '>' : html.append(">"); break; 1.145 + case '&' : html.append("&"); break; 1.146 + default : html.append(c); 1.147 + } 1.148 + 1.149 + if (i > limit) { 1.150 + while (bollocks); 1.151 + // System.out.println("i is " + i); 1.152 + // System.out.println("limit is " + limit); 1.153 + html.append("...\n</pre>"); 1.154 + html.append(eventID); 1.155 + html.append("<pre>"); 1.156 + break; 1.157 + } 1.158 + } 1.159 + html.append("</pre>"); 1.160 + } 1.161 + } 1.162 + catch (Exception exception) { 1.163 + throw exception; 1.164 + } 1.165 + finally { 1.166 + html.append("Oof!!"); 1.167 + } 1.168 + String ret = html.toString(); 1.169 + System.out.println("Returning string length = "+ ret.length()); 1.170 + return ret; 1.171 + } 1.172 + 1.173 + public static void main(String[] args) throws Exception { 1.174 + int length=0; 1.175 + 1.176 + for (int i = 0; i < 100; i++) { 1.177 + length = new Test6357214().create("boo").length(); 1.178 + System.out.println(length); 1.179 + } 1.180 + } 1.181 +} 1.182 +