Path: blob/master/test/hotspot/jtreg/compiler/c2/Test6357214.java
41149 views
/*1* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/**24* @test25* @bug 635721426* @summary Hotspot server compiler gets integer comparison wrong27*28* @run main/othervm/timeout=60 -DshowAll=ffo -DeventID=444 compiler.c2.Test635721429*/3031package compiler.c2;3233// The test hangs after few iterations before the fix. So it fails if timeout.34public class Test6357214 {35static class MyResult {36public boolean next() {37return true;38}3940public String getString(String in) {41if (in.equals("id"))42return "idFoo";43if (in.equals("contentKey"))44return "ckFoo";45return "Foo";46}4748public int getInt(String in) {49if (in.equals("processingComplete"))50return 0;51return 1;52}5354public byte[] getBytes(String in) {55byte[] arr = null;56if (in.equals("content")) {57arr = new byte[65536];58byte j = 32;59for (int i=0; i<65536; i++) {60arr[i] = j;61if (++j == 127)62j=32;63}64}65return arr;66}67}6869public static volatile boolean bollocks = true;70public String create(String context) throws Exception {7172//73// Extract HTTP parameters74//7576boolean showAll = System.getProperty("showAll") != null;77String eventID = System.getProperty("eventID");78String eventContentKey = System.getProperty("cKey");79//80// Build ContentStaging query based on eventID or eventContentKey81//8283String sql = "select id, processingComplete, contentKey, content "84+ "from ContentStaging cs, ContentStagingKey csk "85+ "where cs.eventContentKey = csk.eventContentKey ";8687if (eventID != null) {88sql += "and id = " + eventID;89}90else if (eventContentKey != null) {91sql += "and cs.eventContentKey = '"92+ eventContentKey93+ "' having id = max(id)";94}95else {96throw new Exception("Need eventID or eventContentKey");97}9899//100// This factory builds a static panel, there is no JSP101//102103StringBuffer html = new StringBuffer();104105try {106107MyResult result = new MyResult();108if (result.next()) {109110eventID = result.getString("id");111int processingComplete = result.getInt("processingComplete");112String contentKey = result.getString("contentKey");113byte[] bytes = result.getBytes("content");114115//116// Print content status and associated controls117//118119html.append("<br/><font class=\"small\">");120html.append("Status: ");121switch (processingComplete) {122case 0 :123case 1 : html.append("PENDING"); break;124case 2 : html.append(contentKey); break;125case 3 : html.append(eventID); break;126default : html.append("UNKNONW");127}128html.append("</font><br/>");129130//131// Print at most 20Kb of content unless "showAll" is set132//133134int limit = showAll ? Integer.MAX_VALUE : 1024 * 20;135System.out.println(limit);136html.append("<pre>");137for (int i = 0; bytes != null && i < bytes.length; i++) {138char c = (char) bytes[i];139switch (c) {140case '<' : html.append("<"); break;141case '>' : html.append(">"); break;142case '&' : html.append("&"); break;143default : html.append(c);144}145146if (i > limit) {147while (bollocks);148// System.out.println("i is " + i);149// System.out.println("limit is " + limit);150html.append("...\n</pre>");151html.append(eventID);152html.append("<pre>");153break;154}155}156html.append("</pre>");157}158}159catch (Exception exception) {160throw exception;161}162finally {163html.append("Oof!!");164}165String ret = html.toString();166System.out.println("Returning string length = "+ ret.length());167return ret;168}169170public static void main(String[] args) throws Exception {171int length=0;172173for (int i = 0; i < 100; i++) {174length = new Test6357214().create("boo").length();175System.out.println(length);176}177}178}179180181182