1 /* 2 * Copyright (c) 2007, 2012, 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 package org.graalvm.compiler.jtt.optimize; 24 25 import org.junit.Test; 26 27 import org.graalvm.compiler.jtt.JTTTest; 28 29 /* 30 */ 31 @SuppressWarnings("unused") 32 public class List_reorder_bug extends JTTTest { 33 34 private static class TestClass { 35 String s; 36 37 private void print(String s2) { 38 this.s = s2; 39 } 40 41 private void match(Object a, int src, int id, int seq) { 42 print("match: " + src + ", " + id); 43 List item = list; 44 List itemPrev = null; 45 while (item != null) { 46 if (item.id == id) { 47 if (item.bool) { 48 outcall(item.id); 49 } 50 if (itemPrev != null) { 51 itemPrev.next = item.next; 52 } else { 53 list = item.next; 54 } 55 56 item.next = null; 57 return; 58 } 59 60 itemPrev = item; 61 item = item.next; 62 } 63 } 64 } 65 66 static class List { 67 68 List(int id) { 69 this.id = id; 70 } 71 72 List next; 73 int id; 74 boolean bool = true; 75 } 76 77 private static List list; 78 79 public static boolean test(int i) { 80 list = new List(5); 81 list.next = new List(6); 82 new TestClass().match(new Object(), 27, 6, 0); 83 return list.next == null; 84 } 85 86 static int globalId; 87 88 private static void outcall(int id) { 89 globalId = id; 90 } 91 92 @Test 93 public void run0() throws Throwable { 94 runTest("test", 0); 95 } 96 97 }