0N/A/*
553N/A * Copyright (c) 2003, 2004, 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 4921543 5009601
0N/A * @summary boxing/unboxing versus foreach crashes javac
0N/A * @author gafter
0N/A *
288N/A * @compile BoxedForeach.java
0N/A * @run main BoxedForeach
0N/A */
0N/A
0N/Aimport java.util.*;
0N/A
0N/Apublic class BoxedForeach {
0N/A static void f(Integer[] a) {
0N/A for ( int i : a ) {
0N/A System.out.println(i);
0N/A }
0N/A }
0N/A static void f(Iterable<Integer> b) {
0N/A g(b);
0N/A h(b);
0N/A for ( int i : b ) {
0N/A System.out.println(i);
0N/A }
0N/A for ( float i : b ) {
0N/A System.out.println(i);
0N/A }
0N/A for ( Iterator<Integer> it = b.iterator(); it.hasNext(); ) {
0N/A float i = it.next();
0N/A }
0N/A }
0N/A static <T extends Integer> void g(Iterable<T> b) {
0N/A for ( int i : b ) {
0N/A System.out.println(i);
0N/A }
0N/A }
0N/A static void h(Iterable<? extends Integer> b) {
0N/A for ( int i : b ) {
0N/A System.out.println(i);
0N/A }
0N/A }
0N/A static void f(int[] c) {
0N/A for ( Integer i : c ) {
0N/A System.out.println(i);
0N/A }
0N/A }
0N/A static <E extends Enum<E>> void f(E[] values) {
0N/A for ( E e : values ) {
0N/A System.out.println(e);
0N/A }
0N/A }
0N/A static int f() {
0N/A for ( Foo f : foolist() ) {
0N/A return f.x;
0N/A }
0N/A return 0;
0N/A }
0N/A static List<Foo> foolist() {
0N/A List<Foo> l = new ArrayList<Foo>();
0N/A l.add(new Foo());
0N/A return l;
0N/A }
0N/A enum color { red, green, blue };
0N/A public static void main(String[] args) {
0N/A Integer[] a1 = { Integer.valueOf(1), Integer.valueOf(2) };
0N/A f(a1);
0N/A f(Arrays.asList(a1));
0N/A int[] a2 = { 1, 2, 3 };
0N/A f(a2);
0N/A f(color.values());
0N/A f();
0N/A }
0N/A}
0N/A
0N/Aclass Foo {
0N/A static int n = 0;
0N/A final int x;
0N/A Foo() {
0N/A x = n++;
0N/A }
0N/A}
0N/A
0N/Aclass A {
0N/A class B {
0N/A }
0N/A java.util.List<String> l;
0N/A String[] args;
0N/A {
0N/A for (String s1 : l) {
0N/A for (String s2 : l) {
0N/A B b = new B();
0N/A }
0N/A }
0N/A for (String s1 : args) {
0N/A for (String s2 : args) {
0N/A B b = new B();
0N/A }
0N/A }
0N/A }
0N/A}