Thu, 10 Oct 2013 14:58:04 +0200
8001931: The new build system whitespace cleanup
Reviewed-by: tbell, simonis, erikj
vromero@1557 | 1 | /* |
vromero@1557 | 2 | * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. |
vromero@1557 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
vromero@1557 | 4 | * |
vromero@1557 | 5 | * This code is free software; you can redistribute it and/or modify it |
vromero@1557 | 6 | * under the terms of the GNU General Public License version 2 only, as |
vromero@1557 | 7 | * published by the Free Software Foundation. |
vromero@1557 | 8 | * |
vromero@1557 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
vromero@1557 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
vromero@1557 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
vromero@1557 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
vromero@1557 | 13 | * accompanied this code). |
vromero@1557 | 14 | * |
vromero@1557 | 15 | * You should have received a copy of the GNU General Public License version |
vromero@1557 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
vromero@1557 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
vromero@1557 | 18 | * |
vromero@1557 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
vromero@1557 | 20 | * or visit www.oracle.com if you need additional information or have any |
vromero@1557 | 21 | * questions. |
vromero@1557 | 22 | */ |
vromero@1557 | 23 | |
vromero@1557 | 24 | /* |
vromero@1557 | 25 | * @test |
vromero@1557 | 26 | * @bug 7167125 |
vromero@1557 | 27 | * @summary Two variables after the same operation in a inner class return |
vromero@1557 | 28 | * different results |
vromero@1557 | 29 | * @run main DiffResultAfterSameOperationInnerClasses |
vromero@1557 | 30 | */ |
vromero@1557 | 31 | |
vromero@1557 | 32 | public class DiffResultAfterSameOperationInnerClasses { |
vromero@1557 | 33 | public int i = 1; |
vromero@1557 | 34 | private int j = 1; |
vromero@1557 | 35 | public String s1 = "Hi, "; |
vromero@1557 | 36 | private String s2 = "Hi, "; |
vromero@1621 | 37 | public int arr1[] = new int[]{1}; |
vromero@1621 | 38 | public int arr2[] = new int[]{1}; |
vromero@1557 | 39 | |
vromero@1557 | 40 | public static void main(String[] args) { |
vromero@1621 | 41 | DiffResultAfterSameOperationInnerClasses theTest = |
vromero@1621 | 42 | new DiffResultAfterSameOperationInnerClasses(); |
vromero@1621 | 43 | InnerClass inner = theTest.new InnerClass(); |
vromero@1621 | 44 | if (!inner.test1()) { |
vromero@1621 | 45 | throw new AssertionError("Different results after same calculation"); |
vromero@1621 | 46 | } |
vromero@1621 | 47 | |
vromero@1621 | 48 | theTest.resetVars(); |
vromero@1621 | 49 | if (!inner.test2()) { |
vromero@1557 | 50 | throw new AssertionError("Different results after same calculation"); |
vromero@1557 | 51 | } |
vromero@1557 | 52 | } |
vromero@1557 | 53 | |
vromero@1621 | 54 | void resetVars() { |
vromero@1621 | 55 | i = 1; |
vromero@1621 | 56 | j = 1; |
vromero@1621 | 57 | s1 = "Hi, "; |
vromero@1621 | 58 | s2 = "Hi, "; |
vromero@1621 | 59 | arr1[0] = 1; |
vromero@1621 | 60 | arr2[0] = 1; |
vromero@1621 | 61 | } |
vromero@1621 | 62 | |
vromero@1557 | 63 | class InnerClass { |
vromero@1621 | 64 | public boolean test1() { |
vromero@1557 | 65 | i += i += 1; |
vromero@1557 | 66 | j += j += 1; |
vromero@1557 | 67 | |
vromero@1621 | 68 | arr1[0] += arr1[0] += 1; |
vromero@1621 | 69 | arr2[0] += arr2[0] += 1; |
vromero@1621 | 70 | |
vromero@1557 | 71 | s1 += s1 += "dude"; |
vromero@1557 | 72 | s2 += s2 += "dude"; |
vromero@1557 | 73 | |
vromero@1621 | 74 | return (i == j && i == 3 && |
vromero@1621 | 75 | arr1[0] == arr2[0] && arr2[0] == 3 && |
vromero@1621 | 76 | s1.equals(s2) && s1.endsWith("Hi, Hi, dude")); |
vromero@1621 | 77 | } |
vromero@1621 | 78 | |
vromero@1621 | 79 | public boolean test2() { |
vromero@1621 | 80 | (i) += (i) += 1; |
vromero@1621 | 81 | (j) += (j) += 1; |
vromero@1621 | 82 | |
vromero@1621 | 83 | (arr1[0])+= (arr1[0]) += 1; |
vromero@1621 | 84 | (arr2[0])+= (arr2[0]) += 1; |
vromero@1621 | 85 | |
vromero@1621 | 86 | (s1) += (s1) += "dude"; |
vromero@1621 | 87 | (s2) += (s2) += "dude"; |
vromero@1557 | 88 | |
vromero@1557 | 89 | return (i == j && i == 3 && |
vromero@1621 | 90 | arr1[0] == arr2[0] && arr2[0] == 3 && |
vromero@1557 | 91 | s1.equals(s2) && s1.endsWith("Hi, Hi, dude")); |
vromero@1557 | 92 | } |
vromero@1557 | 93 | } |
vromero@1557 | 94 | } |