duke@1: /* ohair@554: * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as duke@1: * published by the Free Software Foundation. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: /* duke@1: * @test duke@1: * @bug 4869233 4872709 4868735 4921949 4921209 4965701 4934916 4975565 4974939 duke@1: * @summary Boxing/unboxing positive unit and regression tests duke@1: * @author gafter duke@1: */ duke@1: duke@1: public class Boxing1 { duke@1: duke@1: static Boolean _Boolean = true; duke@1: static boolean _boolean = _Boolean; duke@1: duke@1: static Byte _Byte = (byte)3; duke@1: static byte _byte = _Byte; duke@1: duke@1: static Character _Character = 'a'; duke@1: static char _char = _Character; duke@1: duke@1: static Short _Short = (short)4; duke@1: static short _short = _Short; duke@1: duke@1: static Integer _Integer = 5; duke@1: static int _int = _Integer; duke@1: duke@1: static Long _Long = 12L; duke@1: static long _long = _Long; duke@1: duke@1: static Float _Float = 1.2f; duke@1: static float _float = _Float; duke@1: duke@1: static Double _Double = 1.34; duke@1: static double _double = _Double; duke@1: duke@1: public static void main(String[] args) { duke@1: _Double = _Integer + _Integer + 0.0d; duke@1: if (_Double != 10) throw new Error(); duke@1: duke@1: _Integer = 2; duke@1: _float = _Integer; duke@1: if (_float != 2.0f) throw new Error(); duke@1: duke@1: _int = 12; duke@1: _Float = _int + 0.0f; duke@1: if (_Float != 12.0f) throw new Error(); duke@1: duke@1: _Integer = 8; duke@1: _float = (float)_Integer; duke@1: if (_float != 8.0f) throw new Error(); duke@1: duke@1: _int = 9; duke@1: _Float = (Float)(_int + 0.0f); duke@1: if (_Float != 9.0f) throw new Error(); duke@1: duke@1: if (_Boolean) ; else throw new Error(); duke@1: if (!_Boolean) throw new Error(); duke@1: duke@1: if (_Integer >= _Long) throw new Error(); duke@1: duke@1: _Character = 'a'; duke@1: String s1 = ("_" + _Character + "_").intern(); duke@1: if (s1 != "_a_") throw new Error(s1); duke@1: duke@1: /* assignment operators don't work; see 4921209 */ duke@1: if (_Integer++ != 8) throw new Error(); duke@1: if (_Integer++ != 9) throw new Error(); duke@1: if (++_Integer != 11) throw new Error(); duke@1: if ((_Integer += 3) != 14) throw new Error(); duke@1: if ((_Integer -= 3) != 11) throw new Error(); duke@1: duke@1: Integer i = 0; duke@1: i = i + 2; duke@1: i += 2; duke@1: if (i != 4) throw new Error(); duke@1: duke@1: int j = 0; duke@1: j += i; duke@1: if (j != 4) throw new Error(); duke@1: duke@1: Integer a[] = new Integer[1]; duke@1: a[0] = 3; duke@1: a[0] += 3; duke@1: if (a[0] != 6) throw new Error(); duke@1: duke@1: Froobie x = new Froobie(); duke@1: Froobie y = new Froobie(); duke@1: x.next = y; duke@1: x.next.i = 4; duke@1: x.next.i += 4; duke@1: if (--x.next.i != 7) throw new Error(); duke@1: if (x.next.i-- != 7) throw new Error(); duke@1: if (x.next.i != 6) throw new Error(); duke@1: duke@1: boxIndex(); duke@1: boxArray(); duke@1: } duke@1: duke@1: static void boxIndex() { duke@1: String[] a = { "hello", "world" }; duke@1: Integer i = 0; duke@1: System.out.println(a[i]); duke@1: } duke@1: duke@1: static void boxArray() { duke@1: Integer[] a2 = { 0, 1, 2, 3 }; duke@1: for (int i : a2) duke@1: System.out.println(i); duke@1: } duke@1: duke@1: static class Froobie { duke@1: Froobie next = null; duke@1: Integer i = 1; duke@1: } duke@1: duke@1: static class Scott { duke@1: Integer i[]; duke@1: Integer j[]; duke@1: Integer k; duke@1: duke@1: int q = i[j[k]]++; duke@1: } duke@1: duke@1: class T4974939 { duke@1: void f() { duke@1: Byte b = 12; duke@1: Byte c = 'a'; duke@1: duke@1: Short s = 'b'; duke@1: Short t = 12; duke@1: duke@1: Character d = 12; duke@1: } duke@1: } duke@1: }