0N/A/*
553N/A * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 4098316 4522720
0N/A * @summary Test chained assignments using access methods.
0N/A * @author William Maddox (maddox)
0N/A *
0N/A * @compile ChainedAssignment.java
0N/A * @run main ChainedAssignment
0N/A */
0N/A
0N/Apublic class ChainedAssignment {
0N/A
0N/A private int a = 0;
0N/A private int b = 0;
0N/A private int c = 0;
0N/A
0N/A static private int sa = 0;
0N/A static private int sb = 0;
0N/A static private int sc = 0;
0N/A
0N/A private class Inner {
0N/A
0N/A void test1() throws Exception {
0N/A (a) = (b) = 1;
0N/A if (a != 1 || b != 1) {
0N/A throw new Exception("FAILED (11)");
0N/A }
0N/A System.out.println(a + " " + b + " " + c);
0N/A a = b = c;
0N/A if (a != 0 || b != 0) {
0N/A throw new Exception("FAILED (12)");
0N/A }
0N/A System.out.println(a + " " + b + " " + c);
0N/A a = (b) += 5;
0N/A if (a != 5 || b != 5) {
0N/A throw new Exception("FAILED (13)");
0N/A }
0N/A System.out.println(a + " " + b + " " + c);
0N/A }
0N/A
0N/A void test2() throws Exception {
0N/A sa = sb = 1;
0N/A if (sa != 1 || sb != 1) {
0N/A throw new Exception("FAILED (21)");
0N/A }
0N/A System.out.println(sa + " " + sb + " " + sc);
0N/A sa = sb = sc;
0N/A if (sa != 0 || sb != 0) {
0N/A throw new Exception("FAILED (22)");
0N/A }
0N/A System.out.println(sa + " " + sb + " " + sc);
0N/A sa = sb += 5;
0N/A if (sa != 5 || sb != 5) {
0N/A throw new Exception("FAILED (23)");
0N/A }
0N/A System.out.println(sa + " " + sb + " " + sc);
0N/A }
0N/A
0N/A }
0N/A
0N/A public static void main(String[] args) throws Exception {
0N/A ChainedAssignment outer = new ChainedAssignment();
0N/A Inner inner = outer.new Inner();
0N/A inner.test1();
0N/A inner.test2();
0N/A }
0N/A
0N/A}