test/compiler/5091921/Test6357214.java

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2011, 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 6357214
aoqi@0 28 * @summary Hotspot server compiler gets integer comparison wrong
aoqi@0 29 *
aoqi@0 30 * @run main/othervm/timeout=60 -DshowAll=ffo -DeventID=444 Test6357214
aoqi@0 31 */
aoqi@0 32
aoqi@0 33 // The test hangs after few iterations before the fix. So it fails if timeout.
aoqi@0 34 class MyResult {
aoqi@0 35 public boolean next() {
aoqi@0 36 return true;
aoqi@0 37 }
aoqi@0 38
aoqi@0 39 public String getString(String in) {
aoqi@0 40 if (in.equals("id"))
aoqi@0 41 return "idFoo";
aoqi@0 42 if (in.equals("contentKey"))
aoqi@0 43 return "ckFoo";
aoqi@0 44 return "Foo";
aoqi@0 45 }
aoqi@0 46
aoqi@0 47 public int getInt(String in) {
aoqi@0 48 if (in.equals("processingComplete"))
aoqi@0 49 return 0;
aoqi@0 50 return 1;
aoqi@0 51 }
aoqi@0 52
aoqi@0 53 public byte[] getBytes(String in) {
aoqi@0 54 byte[] arr = null;
aoqi@0 55 if (in.equals("content")) {
aoqi@0 56 arr = new byte[65536];
aoqi@0 57 byte j = 32;
aoqi@0 58 for (int i=0; i<65536; i++) {
aoqi@0 59 arr[i] = j;
aoqi@0 60 if (++j == 127)
aoqi@0 61 j=32;
aoqi@0 62 }
aoqi@0 63 }
aoqi@0 64 return arr;
aoqi@0 65 }
aoqi@0 66 }
aoqi@0 67
aoqi@0 68 public class Test6357214 {
aoqi@0 69 public static volatile boolean bollocks = true;
aoqi@0 70 public String create(String context) throws Exception {
aoqi@0 71
aoqi@0 72 //
aoqi@0 73 // Extract HTTP parameters
aoqi@0 74 //
aoqi@0 75
aoqi@0 76 boolean showAll = System.getProperty("showAll") != null;
aoqi@0 77 String eventID = System.getProperty("eventID");
aoqi@0 78 String eventContentKey = System.getProperty("cKey");
aoqi@0 79 //
aoqi@0 80 // Build ContentStaging query based on eventID or eventContentKey
aoqi@0 81 //
aoqi@0 82
aoqi@0 83 String sql = "select id, processingComplete, contentKey, content "
aoqi@0 84 + "from ContentStaging cs, ContentStagingKey csk "
aoqi@0 85 + "where cs.eventContentKey = csk.eventContentKey ";
aoqi@0 86
aoqi@0 87 if (eventID != null) {
aoqi@0 88 sql += "and id = " + eventID;
aoqi@0 89 }
aoqi@0 90 else if (eventContentKey != null) {
aoqi@0 91 sql += "and cs.eventContentKey = '"
aoqi@0 92 + eventContentKey
aoqi@0 93 + "' having id = max(id)";
aoqi@0 94 }
aoqi@0 95 else {
aoqi@0 96 throw new Exception("Need eventID or eventContentKey");
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 //
aoqi@0 100 // This factory builds a static panel, there is no JSP
aoqi@0 101 //
aoqi@0 102
aoqi@0 103 StringBuffer html = new StringBuffer();
aoqi@0 104
aoqi@0 105 try {
aoqi@0 106
aoqi@0 107 MyResult result = new MyResult();
aoqi@0 108 if (result.next()) {
aoqi@0 109
aoqi@0 110 eventID = result.getString("id");
aoqi@0 111 int processingComplete = result.getInt("processingComplete");
aoqi@0 112 String contentKey = result.getString("contentKey");
aoqi@0 113 byte[] bytes = result.getBytes("content");
aoqi@0 114
aoqi@0 115 //
aoqi@0 116 // Print content status and associated controls
aoqi@0 117 //
aoqi@0 118
aoqi@0 119 html.append("<br/><font class=\"small\">");
aoqi@0 120 html.append("Status: ");
aoqi@0 121 switch (processingComplete) {
aoqi@0 122 case 0 :
aoqi@0 123 case 1 : html.append("PENDING"); break;
aoqi@0 124 case 2 : html.append(contentKey); break;
aoqi@0 125 case 3 : html.append(eventID); break;
aoqi@0 126 default : html.append("UNKNONW");
aoqi@0 127 }
aoqi@0 128 html.append("</font><br/>");
aoqi@0 129
aoqi@0 130 //
aoqi@0 131 // Print at most 20Kb of content unless "showAll" is set
aoqi@0 132 //
aoqi@0 133
aoqi@0 134 int limit = showAll ? Integer.MAX_VALUE : 1024 * 20;
aoqi@0 135 System.out.println(limit);
aoqi@0 136 html.append("<pre>");
aoqi@0 137 for (int i = 0; bytes != null && i < bytes.length; i++) {
aoqi@0 138 char c = (char) bytes[i];
aoqi@0 139 switch (c) {
aoqi@0 140 case '<' : html.append("&lt;"); break;
aoqi@0 141 case '>' : html.append("&gt;"); break;
aoqi@0 142 case '&' : html.append("&amp;"); break;
aoqi@0 143 default : html.append(c);
aoqi@0 144 }
aoqi@0 145
aoqi@0 146 if (i > limit) {
aoqi@0 147 while (bollocks);
aoqi@0 148 // System.out.println("i is " + i);
aoqi@0 149 // System.out.println("limit is " + limit);
aoqi@0 150 html.append("...\n</pre>");
aoqi@0 151 html.append(eventID);
aoqi@0 152 html.append("<pre>");
aoqi@0 153 break;
aoqi@0 154 }
aoqi@0 155 }
aoqi@0 156 html.append("</pre>");
aoqi@0 157 }
aoqi@0 158 }
aoqi@0 159 catch (Exception exception) {
aoqi@0 160 throw exception;
aoqi@0 161 }
aoqi@0 162 finally {
aoqi@0 163 html.append("Oof!!");
aoqi@0 164 }
aoqi@0 165 String ret = html.toString();
aoqi@0 166 System.out.println("Returning string length = "+ ret.length());
aoqi@0 167 return ret;
aoqi@0 168 }
aoqi@0 169
aoqi@0 170 public static void main(String[] args) throws Exception {
aoqi@0 171 int length=0;
aoqi@0 172
aoqi@0 173 for (int i = 0; i < 100; i++) {
aoqi@0 174 length = new Test6357214().create("boo").length();
aoqi@0 175 System.out.println(length);
aoqi@0 176 }
aoqi@0 177 }
aoqi@0 178 }
aoqi@0 179

mercurial