2513N/A/*
2513N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2513N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2513N/A *
2513N/A * This code is free software; you can redistribute it and/or modify it
2513N/A * under the terms of the GNU General Public License version 2 only, as
2513N/A * published by the Free Software Foundation.
2513N/A *
2513N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2513N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2513N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2513N/A * version 2 for more details (a copy is included in the LICENSE file that
2513N/A * accompanied this code).
2513N/A *
2513N/A * You should have received a copy of the GNU General Public License version
2513N/A * 2 along with this work; if not, write to the Free Software Foundation,
2513N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2513N/A *
2513N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2513N/A * or visit www.oracle.com if you need additional information or have any
2513N/A * questions.
2513N/A *
2513N/A */
2513N/A
2513N/A/**
2513N/A * @test
2513N/A * @bug 6956668
2513N/A * @summary misbehavior of XOR operator (^) with int
2513N/A *
2513N/A * @run main/othervm -Xbatch Test6956668
2513N/A */
2513N/A
2513N/A
2513N/Apublic class Test6956668 {
2513N/A
2513N/A public static int bitTest() {
2513N/A int result = 0;
2513N/A
2513N/A int testValue = 73;
2513N/A int bitCount = Integer.bitCount(testValue);
2513N/A
2513N/A if (testValue != 0) {
2513N/A int gap = Long.numberOfTrailingZeros(testValue);
2513N/A testValue >>>= gap;
2513N/A
2513N/A while (testValue != 0) {
2513N/A result++;
2513N/A
2513N/A if ((testValue ^= 0x1) != 0) {
2513N/A gap = Long.numberOfTrailingZeros(testValue);
2513N/A testValue >>>= gap;
2513N/A }
2513N/A }
2513N/A }
2513N/A
2513N/A if (bitCount != result) {
2513N/A System.out.println("ERROR: " + bitCount + " != " + result);
2513N/A System.exit(97);
2513N/A }
2513N/A
2513N/A return (result);
2513N/A }
2513N/A
2513N/A public static void main(String[] args) {
2513N/A for (int i = 0; i < 100000; i++) {
2513N/A int ct = bitTest();
2513N/A }
2513N/A }
2513N/A}