Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/5091921/Test6357214.java
32285 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*22*/2324/**25* @test26* @bug 635721427* @summary Hotspot server compiler gets integer comparison wrong28*29* @run main/othervm/timeout=60 -DshowAll=ffo -DeventID=444 Test635721430*/3132// The test hangs after few iterations before the fix. So it fails if timeout.33class MyResult {34public boolean next() {35return true;36}3738public String getString(String in) {39if (in.equals("id"))40return "idFoo";41if (in.equals("contentKey"))42return "ckFoo";43return "Foo";44}4546public int getInt(String in) {47if (in.equals("processingComplete"))48return 0;49return 1;50}5152public byte[] getBytes(String in) {53byte[] arr = null;54if (in.equals("content")) {55arr = new byte[65536];56byte j = 32;57for (int i=0; i<65536; i++) {58arr[i] = j;59if (++j == 127)60j=32;61}62}63return arr;64}65}6667public class Test6357214 {68public static volatile boolean bollocks = true;69public String create(String context) throws Exception {7071//72// Extract HTTP parameters73//7475boolean showAll = System.getProperty("showAll") != null;76String eventID = System.getProperty("eventID");77String eventContentKey = System.getProperty("cKey");78//79// Build ContentStaging query based on eventID or eventContentKey80//8182String sql = "select id, processingComplete, contentKey, content "83+ "from ContentStaging cs, ContentStagingKey csk "84+ "where cs.eventContentKey = csk.eventContentKey ";8586if (eventID != null) {87sql += "and id = " + eventID;88}89else if (eventContentKey != null) {90sql += "and cs.eventContentKey = '"91+ eventContentKey92+ "' having id = max(id)";93}94else {95throw new Exception("Need eventID or eventContentKey");96}9798//99// This factory builds a static panel, there is no JSP100//101102StringBuffer html = new StringBuffer();103104try {105106MyResult result = new MyResult();107if (result.next()) {108109eventID = result.getString("id");110int processingComplete = result.getInt("processingComplete");111String contentKey = result.getString("contentKey");112byte[] bytes = result.getBytes("content");113114//115// Print content status and associated controls116//117118html.append("<br/><font class=\"small\">");119html.append("Status: ");120switch (processingComplete) {121case 0 :122case 1 : html.append("PENDING"); break;123case 2 : html.append(contentKey); break;124case 3 : html.append(eventID); break;125default : html.append("UNKNONW");126}127html.append("</font><br/>");128129//130// Print at most 20Kb of content unless "showAll" is set131//132133int limit = showAll ? Integer.MAX_VALUE : 1024 * 20;134System.out.println(limit);135html.append("<pre>");136for (int i = 0; bytes != null && i < bytes.length; i++) {137char c = (char) bytes[i];138switch (c) {139case '<' : html.append("<"); break;140case '>' : html.append(">"); break;141case '&' : html.append("&"); break;142default : html.append(c);143}144145if (i > limit) {146while (bollocks);147// System.out.println("i is " + i);148// System.out.println("limit is " + limit);149html.append("...\n</pre>");150html.append(eventID);151html.append("<pre>");152break;153}154}155html.append("</pre>");156}157}158catch (Exception exception) {159throw exception;160}161finally {162html.append("Oof!!");163}164String ret = html.toString();165System.out.println("Returning string length = "+ ret.length());166return ret;167}168169public static void main(String[] args) throws Exception {170int length=0;171172for (int i = 0; i < 100; i++) {173length = new Test6357214().create("boo").length();174System.out.println(length);175}176}177}178179180181