Initial load
diff --git a/test/java/util/ResourceBundle/Bug4083270Test.java b/test/java/util/ResourceBundle/Bug4083270Test.java
new file mode 100644
index 0000000..e6a7337
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4083270Test.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    @test
+    @summary test Bug 4083270
+    @run main Bug4083270Test
+    @bug 4083270
+*/
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.*;
+
+/*
+ * Bug: ResourceBundle.geBundle does not check for subclass of ResourceBundle.
+ * This test tries to load a properties file that has a class file with the
+ * same name that isn't a subclass of ResourceBundle.  If the properties
+ * file is found, that means that getBundle ignored the class file because
+ * it wasn't a subclass of ResourceBundle.
+ */
+public class Bug4083270Test extends RBTestFmwk {
+    public static void main(String[] args) throws Exception {
+        new Bug4083270Test(true).run(args);
+    }
+
+    public Bug4083270Test(boolean dummy) {
+    }
+
+    public Bug4083270Test() throws Exception {
+        //If we get here, it means getBundle tried to instantiate this
+        //class.  It shouldn't since this class does not subclass
+        //ResourceBundle.
+        errln("ResourceBundle loaded a non-ResourceBundle class");
+    }
+
+    public void testRecursiveResourceLoads() throws Exception {
+        final String className = getClass().getName();
+        try {
+            ResourceBundle bundle = ResourceBundle.getBundle(className, Locale.getDefault());
+            if (bundle == null) {
+                errln("ResourceBundle did not find properties file");
+            } else if (!(bundle instanceof PropertyResourceBundle)) {
+                errln("ResourceBundle loaded a non-ResourceBundle class");
+            }
+        } catch (MissingResourceException e) {
+            errln("ResourceBundle threw a MissingResourceException");
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4083270Test.properties b/test/java/util/ResourceBundle/Bug4083270Test.properties
new file mode 100644
index 0000000..1578c71
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4083270Test.properties
@@ -0,0 +1,23 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+Bug4179221Test=Bug4179221Test
\ No newline at end of file
diff --git a/test/java/util/ResourceBundle/Bug4165815Test.java b/test/java/util/ResourceBundle/Bug4165815Test.java
new file mode 100644
index 0000000..ec21bda
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4165815Test.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    The fix for 4165815 has been backed out because of compatibility issues.
+    Disabled this test temporarily until a better fix is found by removing
+    the at-signs.
+    test
+    summary test Bug 4165815
+    run main Bug4165815Test
+    bug 4165815
+*/
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+
+/**
+ *  This is a regression test for the following bug:
+ *  "If the path specified by the baseName argument to
+ *  ResourceBundle.getBundle() begins with a leading slash, then the bundle
+ *  is not found relative to the classpath.
+ *
+ *  Clearly, the leading slash was inappropriate, however this did work
+ *  previously (pre 1.2) and should continue to work in the same fashion."
+ *
+ *  A Bundle base name should never contain a "/" and thus an
+ *  IllegalArgumentException should be thrown.
+ */
+public class Bug4165815Test extends RBTestFmwk {
+    public static void main(String[] args) throws Exception {
+        new Bug4165815Test().run(args);
+    }
+
+    private static final String bundleName = "/Bug4165815Bundle";
+    public void testIt() throws Exception {
+        try {
+            ResourceBundle bundle = ResourceBundle.getBundle(bundleName, new Locale("en", "US"));
+            errln("ResourceBundle returned a bundle when it should not have.");
+        } catch (IllegalArgumentException e) {
+            //This is what we should get when the base name contains a "/" character.
+        } catch (MissingResourceException e) {
+            errln("ResourceBundle threw a MissingResourceException when it should have thrown an IllegalArgumentException.");
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Class.java b/test/java/util/ResourceBundle/Bug4168625Class.java
new file mode 100644
index 0000000..dcb8996
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Class.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import java.util.Locale;
+
+/**
+ * Class loaded by custom class loader to load resources.
+ * This call is called through the ResourceGetter interface
+ * by the test.  The ResourceGetter interface is loaded
+ * by the system loader to avoid ClassCastsExceptions.
+ */
+public class Bug4168625Class implements Bug4168625Getter {
+        /** return the specified resource or null if not found */
+    public ResourceBundle getResourceBundle(String resource, Locale locale) {
+        try {
+            return ResourceBundle.getBundle(resource, locale);
+        } catch (MissingResourceException e) {
+            return null;
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Getter.java b/test/java/util/ResourceBundle/Bug4168625Getter.java
new file mode 100644
index 0000000..77ddae1
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Getter.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+
+/**
+ * Interface loaded by system class loader allowing
+ * Bug4168625Class instances to be called by
+ * test class.  This class provides a common base class
+ * for classes loaded by different loaders.  Both the system
+ * loader and the custom loader used by the Bug4168625Test
+ * class load this same interface class using the system class
+ * loader.  The custom loader then loads a subclass that is
+ * then passed back to the caller.  The fact that the caller
+ * and loader share a common base class allows the caller
+ * to cast the object without causing a ClassCastException.
+ */
+public interface Bug4168625Getter {
+    /** return the specified resource or null if not found */
+    public ResourceBundle getResourceBundle(String resource, Locale locale);
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Resource.java b/test/java/util/ResourceBundle/Bug4168625Resource.java
new file mode 100644
index 0000000..a035e6c
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Resource.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ListResourceBundle;
+
+public class Bug4168625Resource extends ListResourceBundle {
+    /**
+     * Overrides ListResourceBundle
+     */
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "name", "Bug4168625Resource" },
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Resource2.java b/test/java/util/ResourceBundle/Bug4168625Resource2.java
new file mode 100644
index 0000000..9aac1c4
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Resource2.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ListResourceBundle;
+
+public class Bug4168625Resource2 extends ListResourceBundle {
+    /**
+     * Overrides ListResourceBundle
+     */
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "name", "Bug4168625Resource2" },
+            { "baseName", "Bug4168625Resource2" },
+            { "Bug4168625Resource2", "Bug4168625Resource2" },
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Resource2_en_US.java b/test/java/util/ResourceBundle/Bug4168625Resource2_en_US.java
new file mode 100644
index 0000000..cc0c10d
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Resource2_en_US.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ListResourceBundle;
+
+public class Bug4168625Resource2_en_US extends ListResourceBundle {
+    /**
+     * Overrides ListResourceBundle
+     */
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "name", "Bug4168625Resource2_en_US" },
+            { "Bug4168625Resource2_en_US", "Bug4168625Resource2_en_US" },
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Resource3.java b/test/java/util/ResourceBundle/Bug4168625Resource3.java
new file mode 100644
index 0000000..d98c3cc
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Resource3.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ListResourceBundle;
+
+public class Bug4168625Resource3 extends ListResourceBundle {
+    /**
+     * Overrides ListResourceBundle
+     */
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "name", "Bug4168625Resource3" },
+            { "Bug4168625Resource3", "Bug4168625Resource3" },
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Resource3_en.java b/test/java/util/ResourceBundle/Bug4168625Resource3_en.java
new file mode 100644
index 0000000..d8ea44e
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Resource3_en.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ListResourceBundle;
+
+public class Bug4168625Resource3_en extends ListResourceBundle {
+    /**
+     * Overrides ListResourceBundle
+     */
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "name", "Bug4168625Resource3_en" },
+            { "Bug4168625Resource3_en", "Bug4168625Resource3_en" },
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Resource3_en_CA.java b/test/java/util/ResourceBundle/Bug4168625Resource3_en_CA.java
new file mode 100644
index 0000000..b560f5f
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Resource3_en_CA.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ListResourceBundle;
+
+public class Bug4168625Resource3_en_CA extends ListResourceBundle {
+    /**
+     * Overrides ListResourceBundle
+     */
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "name", "Bug4168625Resource3_en_CA" },
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Resource3_en_IE.java b/test/java/util/ResourceBundle/Bug4168625Resource3_en_IE.java
new file mode 100644
index 0000000..85d744f
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Resource3_en_IE.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ListResourceBundle;
+
+public class Bug4168625Resource3_en_IE extends ListResourceBundle {
+    /**
+     * Overrides ListResourceBundle
+     */
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "name", "Bug4168625Resource3_en_IE" },
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Resource3_en_US.java b/test/java/util/ResourceBundle/Bug4168625Resource3_en_US.java
new file mode 100644
index 0000000..5c264c4
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Resource3_en_US.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.ListResourceBundle;
+
+public class Bug4168625Resource3_en_US extends ListResourceBundle {
+    /**
+     * Overrides ListResourceBundle
+     */
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "name", "Bug4168625Resource3" },
+            { "Bug4168625Resource3_en_US", "Bug4168625Resource3_en_US" },
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4168625Test.java b/test/java/util/ResourceBundle/Bug4168625Test.java
new file mode 100644
index 0000000..b71b429
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4168625Test.java
@@ -0,0 +1,667 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    @test
+    @summary test Resource Bundle for bug 4168625
+    @build Bug4168625Class Bug4168625Getter Bug4168625Resource Bug4168625Resource3 Bug4168625Resource3_en Bug4168625Resource3_en_CA Bug4168625Resource3_en_IE Bug4168625Resource3_en_US Bug4168625Resource2_en_US Bug4168625Resource2
+    @run main/timeout=600 Bug4168625Test
+    @bug 4168625
+*/
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.*;
+import java.io.*;
+
+/**
+ *  This test tries to correct three efficiency problems with the caching
+ *  mechanism of ResourceBundle.  All tests assume that none of the bundles
+ *  have been previously loaded and cached.  It also allows concurrent loads
+ *  of resource bundles to be performed if the bundles are unrelated (ex. a
+ *  load of a local system resource by one thread while another thread is
+ *  doing a slow load over a network).
+ */
+public class Bug4168625Test extends RBTestFmwk {
+    public static void main(String[] args) throws Exception {
+        new Bug4168625Test().run(args);
+    }
+
+    /**
+     * Verify that getBundle will do something reasonable when part of the
+     * resource hierarchy is missing.
+     */
+    public void testMissingParent() throws Exception {
+        final Locale oldDefault = Locale.getDefault();
+        Locale.setDefault(new Locale("en", "US"));
+        try {
+            final Locale loc = new Locale("jf", "jf");
+            ResourceBundle bundle = ResourceBundle.getBundle("Bug4168625Resource2", loc);
+            final String s1 = bundle.getString("name");
+            if (!s1.equals("Bug4168625Resource2_en_US")) {
+                errln("getBundle did not find leaf bundle: "+bundle.getClass().getName());
+            }
+            final String s2 = bundle.getString("baseName");
+            if (!s2.equals("Bug4168625Resource2")) {
+                errln("getBundle did not set up proper inheritance chain");
+            }
+        } finally {
+            Locale.setDefault(oldDefault);
+        }
+    }
+
+    /**
+     *  Previous versions of ResourceBundle have had the following
+     *  caching behavior.  Assume the classes
+     *  Bug4168625Resource_fr_FR, Bug4168625Resource_fr,
+     *  Bug4168625Resource_en_US, and Bug4168625Resource_en don't
+     *  exist.  The class Bug4168625Resource does.  Assume the default
+     *  locale is en_US.
+     *  <P>
+     *  <pre>
+     *  getBundle("Bug4168625Resource", new Locale("fr", "FR"));
+     *      -->try to load Bug4168625Resource_fr_FR
+     *      -->try to load Bug4168625Resource_fr
+     *      -->try to load Bug4168625Resource_en_US
+     *      -->try to load Bug4168625Resource_en
+     *      -->load Bug4168625Resource
+     *      -->cache Bug4168625Resource as Bug4168625Resource
+     *      -->cache Bug4168625Resource as Bug4168625Resource_en
+     *      -->cache Bug4168625Resource as Bug4168625Resource_en_US
+     *      -->return Bug4168625Resource
+     *  getBundle("Bug4168625Resource", new Locale("fr", "FR"));
+     *      -->try to load Bug4168625Resource_fr_FR
+     *      -->try to load Bug4168625Resource_fr
+     *      -->find cached Bug4168625Resource_en_US
+     *      -->return Bug4168625Resource_en_US (which is realy Bug4168625Resource)
+     *  </pre>
+     *  <P>
+     *  The second call causes two loads for Bug4168625Resource_fr_FR and
+     *  Bug4168625Resource_en which have already been tried and failed.  These
+     *  two loads should have been cached as Bug4168625Resource by the first
+     *  call.
+     *
+     *  The following, more efficient behavior is desired:
+     *  <P>
+     *  <pre>
+     *  getBundle("Bug4168625Resource", new Locale("fr", "FR"));
+     *      -->try to load Bug4168625Resource_fr_FR
+     *      -->try to load Bug4168625Resource_fr
+     *      -->try to load Bug4168625Resource_en_US
+     *      -->try to load Bug4168625Resource_en
+     *      -->load Bug4168625Resource
+     *      -->cache Bug4168625Resource as Bug4168625Resource
+     *      -->cache Bug4168625Resource as Bug4168625Resource_en
+     *      -->cache Bug4168625Resource as Bug4168625Resource_en_US
+     *      -->cache Bug4168625Resource as Bug4168625Resource_fr
+     *      -->cache Bug4168625Resource as Bug4168625Resource_fr_FR
+     *      -->return Bug4168625Resource
+     *  getBundle("Bug4168625Resource", new Locale("fr", "FR"));
+     *      -->find cached Bug4168625Resource_fr_FR
+     *      -->return Bug4168625Resource_en_US (which is realy Bug4168625Resource)
+     *  </pre>
+     *  <P>
+     *
+     */
+    public void testCacheFailures() throws Exception {
+        checkResourceLoading("Bug4168625Resource", new Locale("fr", "FR"));
+    }
+
+    /**
+     *  Previous versions of ResourceBundle have had the following
+     *  caching behavior.  Assume the current locale is locale is en_US.
+     *  The classes Bug4168625Resource_en_US, and Bug4168625Resource_en don't
+     *  exist.  The class Bug4168625Resource does.
+     *  <P>
+     *  <pre>
+     *  getBundle("Bug4168625Resource", new Locale("en", "US"));
+     *      -->try to load Bug4168625Resource_en_US
+     *      -->try to load Bug4168625Resource_en
+     *      -->try to load Bug4168625Resource_en_US
+     *      -->try to load Bug4168625Resource_en
+     *      -->load Bug4168625Resource
+     *      -->cache Bug4168625Resource as Bug4168625Resource
+     *      -->cache Bug4168625Resource as Bug4168625Resource_en
+     *      -->cache Bug4168625Resource as Bug4168625Resource_en_US
+     *      -->return Bug4168625Resource
+     *  </pre>
+     *  <P>
+     *  The redundant loads of Bug4168625Resource_en_US and Bug4168625Resource_en
+     *  should not occur.  The desired behavior is as follows:
+     *  <P>
+     *  <pre>
+     *  getBundle("Bug4168625Resource", new Locale("en", "US"));
+     *      -->try to load Bug4168625Resource_en_US
+     *      -->try to load Bug4168625Resource_en
+     *      -->load Bug4168625Resource
+     *      -->cache Bug4168625Resource as Bug4168625Resource
+     *      -->cache Bug4168625Resource as Bug4168625Resource_en
+     *      -->cache Bug4168625Resource as Bug4168625Resource_en_US
+     *      -->return Bug4168625Resource
+     *  </pre>
+     *  <P>
+     */
+    public void testRedundantLoads() throws Exception {
+        checkResourceLoading("Bug4168625Resource", Locale.getDefault());
+    }
+
+    /**
+     * Ensure that resources are only loaded once and are cached correctly
+     */
+    private void checkResourceLoading(String resName, Locale l) throws Exception {
+        final Loader loader = new Loader( new String[] { "Bug4168625Class" }, new String[] { "Bug4168625Resource3_en_US", "Bug4168625Resource3_en_CA" });
+        final Class c = loader.loadClass("Bug4168625Class");
+        Bug4168625Getter test = (Bug4168625Getter)c.newInstance();
+        final String resClassName;
+        if (l.toString().length() > 0) {
+            resClassName = resName+"_"+l;
+        } else {
+            resClassName = resName;
+        }
+
+        Object bundle = test.getResourceBundle(resName, l);
+        loader.logClasses("Initial lookup of "+resClassName+" generated the following loads:");
+
+        final Vector lastLoad = new Vector(loader.loadedClasses.size());
+        boolean dups = false;
+        for (int i = loader.loadedClasses.size() - 1; i >= 0 ; i--) {
+            final Object item = loader.loadedClasses.elementAt(i);
+            loader.loadedClasses.removeElementAt(i);
+            if (loader.loadedClasses.contains(item)) {
+                logln("Resource loaded more than once: "+item);
+                dups = true;
+            } else {
+                lastLoad.addElement(item);
+            }
+        }
+        if (dups) {
+            errln("ResourceBundle loaded some classes multiple times");
+        }
+
+        loader.loadedClasses.removeAllElements();
+        bundle = test.getResourceBundle(resName, l);
+        loader.logClasses("Second lookup of "+resClassName+" generated the following loads:");
+
+        dups = false;
+        for (int i = 0; i < loader.loadedClasses.size(); i++) {
+            Object item = loader.loadedClasses.elementAt(i);
+            if (lastLoad.contains(item)) {
+                logln("ResourceBundle did not cache "+item+" correctly");
+                dups = true;
+            }
+        }
+        if (dups) {
+            errln("Resource bundle not caching some classes properly");
+        }
+    }
+
+    /**
+     *  Previous versions of ResourceBundle exhibited the following caching behavior.
+     *  Assume the class Bug4168625Resource_en exists. Bug4168625Resource_en_US does
+     *  not.  Two threads, ThreadA and ThreadB both try to get the same bundle.
+     *  <P>
+     *  <pre>
+     *  ThreadA.getBundle("Bug4168625Resource", new Locale("en", "US"));
+     *      A-->try to load Bug4168625Resource_en_US
+     *  ThreadB.getBundle("Bug4168625Resource", new Locale("en", "US"));
+     *      B-->try to load Bug4168625Resource_en_US
+     *      B-->load Bug4168625Resource_en (#1)
+     *      A-->load Bug4168625Resource_en (#2)
+     *      A-->cache Bug4168625Resource_en (#2) as Bug4168625Resource_en
+     *      A-->cache Bug4168625Resource_en (#2) as Bug4168625Resource_en_US
+     *      A-->return Bug4168625Resource_en (#2)
+     *      B-->cache Bug4168625Resource_en (#1) as Bug4168625Resource_en
+     *      B-->cache Bug4168625Resource_en (#1) as Bug4168625Resource_en_US
+     *      B-->return Bug4168625Resource_en (#1)
+     *  </pre>
+     *  <P>
+     *  Both threads try and fail to load Bug4168625Resource_en_US.  Both
+     *  threads load Bug4168625Resource_en.  Both threads get their own copy
+     *  of the Bug4168625Resource_en resource.
+     *
+     *  The desired behavior is as follows:
+     *  <P>
+     *  <pre>
+     *  ThreadA.getBundle("Bug4168625Resource", new Locale("en", "US"));
+     *      A-->try to load Bug4168625Resource_en_US
+     *  ThreadB.getBundle("Bug4168625Resource", new Locale("en", "US"));
+     *      B-->try to load Bug4168625Resource_en_US
+     *      B-->load Bug4168625Resource_en
+     *      A-->load Bug4168625Resource_en (block in ResourceBundle.getBundle)
+     *      B-->cache Bug4168625Resource_en as Bug4168625Resource_en
+     *      B-->cache Bug4168625Resource_en as Bug4168625Resource_en_US
+     *      A-->return Bug4168625Resource_en
+     *      B-->return Bug4168625Resource_en
+     *  </pre>
+     *  <P>
+     *  Note that both threads return the same bundle object.
+     */
+    public void testConcurrentLoading1() throws Exception {
+        final Loader loader = new Loader( new String[] { "Bug4168625Class" }, new String[] { "Bug4168625Resource3_en_US", "Bug4168625Resource3_en_CA" });
+        final Class c = loader.loadClass("Bug4168625Class");
+        final Bug4168625Getter test = (Bug4168625Getter)c.newInstance();
+
+            //both threads want the same resource
+        ConcurrentLoadingThread thread1 = new ConcurrentLoadingThread(loader, test, new Locale("en", "US"));
+        ConcurrentLoadingThread thread2 = new ConcurrentLoadingThread(loader, test, new Locale("en", "US"));
+
+        thread1.start();            //start thread 1
+        loader.waitForNotify(1);    //wait for thread1 to do getBundle & block in loader
+        thread2.start();            //start second thread
+        loader.waitForNotify(2, 1000);  //wait until thread2 blocks somewhere in getBundle
+        thread1.ping();             //continue both threads
+        thread2.ping();
+
+        thread1.join();             //wait unitl both threads complete
+        thread2.join();
+
+            //Now, examine the class loads that were done.
+        loader.logClasses("Classes loaded after completion of both threads:");
+
+        boolean dups = false;
+        for (int i = loader.loadedClasses.size() - 1; i >= 0 ; i--) {
+            final Object item = loader.loadedClasses.elementAt(i);
+            loader.loadedClasses.removeElementAt(i);
+            if (loader.loadedClasses.contains(item)) {
+                logln("Resource loaded more than once: "+item);
+                dups = true;
+            }
+        }
+        if (dups) {
+            errln("ResourceBundle loaded some classes multiple times");
+        }
+    }
+
+    private class ConcurrentLoadingThread extends Thread {
+        private Loader loader;
+        public Object bundle;
+        private Bug4168625Getter test;
+        private Locale locale;
+        private String resourceName = "Bug4168625Resource3";
+        public ConcurrentLoadingThread(Loader loader, Bug4168625Getter test, Locale l, String resourceName) {
+            this.loader = loader;
+            this.test = test;
+            this.locale = l;
+            this.resourceName = resourceName;
+        }
+        public ConcurrentLoadingThread(Loader loader, Bug4168625Getter test, Locale l) {
+            this.loader = loader;
+            this.test = test;
+            this.locale = l;
+        }
+        public void run() {
+            try {
+                logln(">>"+threadName()+">run");
+                bundle = test.getResourceBundle(resourceName, locale);
+            } catch (Exception e) {
+                errln("TEST CAUGHT UNEXPECTED EXCEPTION: "+e);
+            } finally {
+                logln("<<"+threadName()+"<run");
+            }
+        }
+        public synchronized void waitUntilPinged() {
+            logln(">>"+threadName()+">waitUntilPinged");
+            loader.notifyEveryone();
+            try {
+                wait(30000);    //wait 30 seconds max.
+            } catch (InterruptedException e) {
+                logln("Test deadlocked.");
+            }
+            logln("<<"+threadName()+"<waitUntilPinged");
+        }
+        public synchronized void ping() {
+            logln(">>"+threadName()+">ping "+threadName(this));
+            notifyAll();
+            logln("<<"+threadName()+"<ping "+threadName(this));
+        }
+    };
+
+    /**
+     * This test ensures that multiple resources can be loading at the same
+     * time as long as they don't depend on each other in some way.
+     */
+    public void testConcurrentLoading2() throws Exception {
+        final Loader loader = new Loader( new String[] { "Bug4168625Class" }, new String[] { "Bug4168625Resource3_en_US", "Bug4168625Resource3_en_CA" });
+        final Class c = loader.loadClass("Bug4168625Class");
+        final Bug4168625Getter test = (Bug4168625Getter)c.newInstance();
+
+        ConcurrentLoadingThread thread1 = new ConcurrentLoadingThread(loader, test, new Locale("en", "CA"));
+        ConcurrentLoadingThread thread2 = new ConcurrentLoadingThread(loader, test, new Locale("en", "IE"));
+
+        thread1.start();            //start thread 1
+        loader.waitForNotify(1);    //wait for thread1 to do getBundle & block in loader
+        thread2.start();            //start second thread
+        thread2.join(1000);         //wait until thread2 blocks somewhere in getBundle
+
+            //Thread1 should be blocked inside getBundle at the class loader
+            //Thread2 should have completed its getBundle call and terminated
+        if (!thread1.isAlive() || thread2.isAlive()) {
+            errln("ResourceBundle.getBundle not allowing legal concurrent loads");
+        }
+
+        thread1.ping();             //continue thread1
+        thread1.join();
+        thread2.join();
+    }
+
+    /**
+     * This test ensures that a resource loads correctly (with all its parents)
+     * when memory is very low (ex. the cache gets purged during a load).
+     */
+    public void testLowMemoryLoad() throws Exception {
+        final String[] classToLoad = { "Bug4168625Class" };
+        final String[] classToWait = { "Bug4168625Resource3_en_US","Bug4168625Resource3_en","Bug4168625Resource3" };
+        final Loader loader = new Loader(classToLoad, classToWait);
+        final Class c = loader.loadClass("Bug4168625Class");
+        final Bug4168625Getter test = (Bug4168625Getter)c.newInstance();
+        causeResourceBundleCacheFlush();
+
+        ConcurrentLoadingThread thread1 = new ConcurrentLoadingThread(loader, test, new Locale("en", "US"));
+        thread1.start();            //start thread 1
+        loader.waitForNotify(1);    //wait for thread1 to do getBundle(en_US) & block in loader
+        causeResourceBundleCacheFlush();    //cause a cache flush
+        thread1.ping();             //kick thread 1
+        loader.waitForNotify(2);    //wait for thread1 to do getBundle(en) & block in loader
+        causeResourceBundleCacheFlush();    //cause a cache flush
+        thread1.ping();             //kick thread 1
+        loader.waitForNotify(3);    //wait for thread1 to do getBundle(en) & block in loader
+        causeResourceBundleCacheFlush();    //cause a cache flush
+        thread1.ping();             //kick thread 1
+        thread1.ping();             //kick thread 1
+        thread1.join(1000);         //wait until thread2 blocks somewhere in getBundle
+
+        ResourceBundle bundle = (ResourceBundle)thread1.bundle;
+        String s1 = bundle.getString("Bug4168625Resource3_en_US");
+        String s2 = bundle.getString("Bug4168625Resource3_en");
+        String s3 = bundle.getString("Bug4168625Resource3");
+        if ((s1 == null) || (s2 == null) || (s3 == null)) {
+            errln("Bundle not constructed correctly.  The parent chain is incorrect.");
+        }
+    }
+
+    /**
+     * A simple class loader that loads classes from the current
+     * working directory.  The loader will block the current thread
+     * of execution before it returns when it tries to load
+     * the class "Bug4168625Resource3_en_US".
+     */
+    private static final String CLASS_PREFIX = "";
+    private static final String CLASS_SUFFIX = ".class";
+
+    private static final class SimpleLoader extends ClassLoader {
+        private boolean network = false;
+
+        public SimpleLoader() {
+            this.network = false;
+        }
+        public SimpleLoader(boolean simulateNetworkLoad) {
+            this.network = simulateNetworkLoad;
+        }
+        public Class loadClass(final String className, final boolean resolveIt)
+                throws ClassNotFoundException {
+            Class result;
+            synchronized (this) {
+                result = findLoadedClass(className);
+                if (result == null) {
+                    if (network) {
+                        try {
+                             Thread.sleep(100);
+                        } catch (java.lang.InterruptedException e) {
+                        }
+                    }
+                    result = super.findSystemClass(className);
+                    if ((result != null) && resolveIt) {
+                        resolveClass(result);
+                    }
+                }
+            }
+            return result;
+        }
+    }
+
+    private final class Loader extends ClassLoader {
+        public final Vector loadedClasses = new Vector();
+        private String[] classesToLoad;
+        private String[] classesToWaitFor;
+
+        public Loader() {
+            classesToLoad = new String[0];
+            classesToWaitFor = new String[0];
+        }
+
+        public Loader(final String[] classesToLoadIn, final String[] classesToWaitForIn) {
+            classesToLoad = classesToLoadIn;
+            classesToWaitFor = classesToWaitForIn;
+        }
+
+        /**
+         * Load a class.  Files we can load take preference over ones the system
+         * can load.
+         */
+        private byte[] getClassData(final String className) {
+            boolean shouldLoad = false;
+            for (int i = classesToLoad.length-1; i >= 0; --i) {
+                if (className.equals(classesToLoad[i])) {
+                    shouldLoad = true;
+                    break;
+                }
+            }
+
+            if (shouldLoad) {
+                final String name = CLASS_PREFIX+className+CLASS_SUFFIX;
+                try {
+                    final InputStream fi = this.getClass().getClassLoader().getResourceAsStream(name);
+                    final byte[] result = new byte[fi.available()];
+                    fi.read(result);
+                    return result;
+                } catch (Exception e) {
+                    logln("Error loading test class: "+name);
+                    logln(e.toString());
+                    return null;
+                }
+            } else {
+                return null;
+            }
+        }
+
+        /**
+         * Load a class.  Files we can load take preference over ones the system
+         * can load.
+         */
+        public Class loadClass(final String className, final boolean resolveIt)
+                throws ClassNotFoundException {
+            Class result;
+            synchronized (this) {
+                logln(">>"+threadName()+">load "+className);
+                loadedClasses.addElement(className);
+
+                result = findLoadedClass(className);
+                if (result == null) {
+                    final byte[] classData = getClassData(className);
+                    if (classData == null) {
+                        //we don't have a local copy of this one
+                        logln("Loading system class: "+className);
+                        result = loadFromSystem(className);
+                    } else {
+                        result = defineClass(classData, 0, classData.length);
+                        if (result == null) {
+                            //there was an error defining the class
+                            result = loadFromSystem(className);
+                        }
+                    }
+                    if ((result != null) && resolveIt) {
+                        resolveClass(result);
+                    }
+                }
+            }
+            for (int i = classesToWaitFor.length-1; i >= 0; --i) {
+                if (className.equals(classesToWaitFor[i])) {
+                    rendezvous();
+                    break;
+                }
+            }
+            logln("<<"+threadName()+"<load "+className);
+            return result;
+        }
+
+        /**
+         * Delegate loading to the system loader
+         */
+        private Class loadFromSystem(String className) throws ClassNotFoundException {
+            return super.findSystemClass(className);
+        }
+
+        public void logClasses(String title) {
+            logln(title);
+            for (int i = 0; i < loadedClasses.size(); i++) {
+                logln("    "+loadedClasses.elementAt(i));
+            }
+            logln("");
+        }
+
+        public int notifyCount = 0;
+        public int waitForNotify(int count) {
+            return waitForNotify(count, 0);
+        }
+        public synchronized int waitForNotify(int count, long time) {
+            logln(">>"+threadName()+">waitForNotify");
+            if (count > notifyCount) {
+                try {
+                    wait(time);
+                } catch (InterruptedException e) {
+                }
+            } else {
+                logln("  count("+count+") > notifyCount("+notifyCount+")");
+            }
+            logln("<<"+threadName()+"<waitForNotify");
+            return notifyCount;
+        }
+        private synchronized void notifyEveryone() {
+            logln(">>"+threadName()+">notifyEveryone");
+            notifyCount++;
+            notifyAll();
+            logln("<<"+threadName()+"<notifyEveryone");
+        }
+        private void rendezvous() {
+            final Thread current = Thread.currentThread();
+            if (current instanceof ConcurrentLoadingThread) {
+                ((ConcurrentLoadingThread)current).waitUntilPinged();
+            }
+        }
+    }
+
+    private static String threadName() {
+        return threadName(Thread.currentThread());
+    }
+
+    private static String threadName(Thread t) {
+        String temp = t.toString();
+        int ndx = temp.indexOf("Thread[");
+        temp = temp.substring(ndx + "Thread[".length());
+        ndx = temp.indexOf(',');
+        temp = temp.substring(0, ndx);
+        return temp;
+    }
+
+    /** Fill memory to force all SoftReferences to be GCed */
+    private void causeResourceBundleCacheFlush() {
+        logln("Filling memory...");
+        int allocationSize = 1024;
+        Vector memoryHog = new Vector();
+        try {
+            while (true) {
+                memoryHog.addElement(new byte[allocationSize]);
+                allocationSize *= 2;
+            }
+        } catch (Throwable e) {
+            logln("Caught "+e+" filling memory");
+        } finally{
+            memoryHog = null;
+            System.gc();
+        }
+        logln("last allocation size: " + allocationSize);
+    }
+
+    /**
+     *  NOTE: this problem is not externally testable and can only be
+     *  verified through code inspection unless special code to force
+     *  a task switch is inserted into ResourceBundle.
+     *  The class Bug4168625Resource_sp exists.  It's parent bundle
+     *  (Bug4168625Resource) contains a resource string with the tag
+     *  "language" but Bug4168625Resource_sp does not.
+     *  Assume two threads are executing, ThreadA and ThreadB and they both
+     *  load a resource Bug4168625Resource with from sp locale.
+     *  ResourceBundle.getBundle adds a bundle to the bundle cache (in
+     *  findBundle) before it sets the bundle's parent (in getBundle after
+     *  returning from findBundle).
+     *  <P>
+     *  <pre>
+     *  ThreadA.getBundle("Bug4168625Resource", new Locale("sp"));
+     *      A-->load Bug4168625Resource_sp
+     *      A-->find cached Bug4168625Resource
+     *      A-->cache Bug4168625Resource_sp as Bug4168625Resource_sp
+     *  ThreadB.getBundle("Bug4168625Resource", new Locale("sp"));
+     *      B-->find cached Bug4168625Resource_sp
+     *      B-->return Bug4168625Resource_sp
+     *  ThreadB.bundle.getString("language");
+     *      B-->try to find "language" in Bug4168625Resource_sp
+     *      B-->Bug4168625Resource_sp does not have a parent, so return null;
+     *  ThreadB.System.out.println("Some unknown country");
+     *      A-->set parent of Bug4168625Resource_sp to Bug4168625Resource
+     *      A-->return Bug4168625Resource_sp (the same bundle ThreadB got)
+     *  ThreadA.bundle.getString("language");
+     *      A-->try to find "language" in Bug4168625Resource_sp
+     *      A-->try to find "language" in Bug4168625Resource (parent of Bug4168625Resource_sp)
+     *      A-->return the string
+     *  ThreadA.System.out.println("Langauge = "+country);
+     *  ThreadB.bundle.getString("language");
+     *      B-->try to find "language" in Bug4168625Resource_sp
+     *      B-->try to find "language" in Bug4168625Resource (parent of Bug4168625Resource_sp)
+     *      B-->return the string
+     *  ThreadB.System.out.println("Langauge = "+country);
+     *  </pre>
+     *  <P>
+     *  Note that the first call to getString() by ThreadB returns null, but the second
+     *  returns a value.  Thus to ThreadB, the bundle appears to change.  ThreadA gets
+     *  the expected results right away.
+     */
+}
diff --git a/test/java/util/ResourceBundle/Bug4177489Test.java b/test/java/util/ResourceBundle/Bug4177489Test.java
new file mode 100644
index 0000000..93c9683
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4177489Test.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    @test
+    @summary test Resource Bundle for bug 4177489
+    @build Bug4177489_Resource Bug4177489_Resource_jf
+    @run main Bug4177489Test
+    @bug 4177489
+*/
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.*;
+import java.io.*;
+
+public class Bug4177489Test extends RBTestFmwk {
+    public static void main(String[] args) throws Exception {
+        new Bug4177489Test().run(args);
+    }
+
+    public void testIt() throws Exception {
+        ResourceBundle rb = ResourceBundle.getBundle( "Bug4177489_Resource" );
+        Locale l = rb.getLocale();
+        if (l.toString().length() > 0) {
+            errln("ResourceBundle didn't handle resource class name with '_' in it.");
+        }
+
+        Locale loc = new Locale("jf", "");
+        ResourceBundle rb2 = ResourceBundle.getBundle( "Bug4177489_Resource", loc );
+        if (!loc.equals(rb2.getLocale())) {
+            errln("ResourceBundle didn't return proper locale name:"+rb2.getLocale());
+        }
+
+        loc = new Locale("jf", "JF");
+        ResourceBundle rb3 = ResourceBundle.getBundle("Bug4177489_Resource", loc);
+        if (!loc.equals(rb3.getLocale())) {
+            errln("ResourceBundle didn't return proper locale name for property bundle:"+rb3.getLocale());
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4177489_Resource.java b/test/java/util/ResourceBundle/Bug4177489_Resource.java
new file mode 100644
index 0000000..bf9833a
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4177489_Resource.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.*;
+
+public class Bug4177489_Resource extends ListResourceBundle {
+    public Object[][] getContents() {
+       return contents;
+    }
+    static final Object[][] contents = {
+       {"key1", "value1"}
+    };
+}
diff --git a/test/java/util/ResourceBundle/Bug4177489_Resource_jf.java b/test/java/util/ResourceBundle/Bug4177489_Resource_jf.java
new file mode 100644
index 0000000..9bfce2b
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4177489_Resource_jf.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1999 - All Rights Reserved
+ *
+ * Portions Copyright 2007 by Sun Microsystems, Inc.,
+ * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
+ * All rights reserved.
+ *
+ * This software is the confidential and proprietary information
+ * of Sun Microsystems, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Sun.
+ *
+ * The original version of this source code and documentation is
+ * copyrighted and owned by IBM. These materials are provided
+ * under terms of a License Agreement between IBM and Sun.
+ * This technology is protected by multiple US and International
+ * patents. This notice and attribution to IBM may not be removed.
+ *
+ */
+
+import java.util.*;
+
+public class Bug4177489_Resource_jf extends ListResourceBundle {
+    public Object[][] getContents() {
+       return contents;
+    }
+    static final Object[][] contents = {
+       {"keyJF", "valueJF"}
+    };
+}
diff --git a/test/java/util/ResourceBundle/Bug4177489_Resource_jf_JF.properties b/test/java/util/ResourceBundle/Bug4177489_Resource_jf_JF.properties
new file mode 100644
index 0000000..d9ffac7
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4177489_Resource_jf_JF.properties
@@ -0,0 +1,23 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+Bug4177489Test=Bug4177489Test
diff --git a/test/java/util/ResourceBundle/Bug4179766Class.java b/test/java/util/ResourceBundle/Bug4179766Class.java
new file mode 100644
index 0000000..8a05c68
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4179766Class.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+
+/**
+ * Class loaded by custom class loader to load resources.
+ * This call is called through the ResourceGetter interface
+ * by the test.  The ResourceGetter interface is loaded
+ * by the system loader to avoid ClassCastsExceptions.
+ */
+public class Bug4179766Class implements Bug4179766Getter {
+        /** return the specified resource or null if not found */
+    public ResourceBundle getResourceBundle(String resource) {
+        try {
+            return ResourceBundle.getBundle(resource);
+        } catch (MissingResourceException e) {
+            return null;
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4179766Getter.java b/test/java/util/ResourceBundle/Bug4179766Getter.java
new file mode 100644
index 0000000..1f083e6
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4179766Getter.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+import java.util.ResourceBundle;
+
+/**
+ * Interface loaded by system class loader allowing
+ * Bug4179766Class instances to be called by
+ * test class.  This class provides a common base class
+ * for classes loaded by different loaders.  Both the system
+ * loader and the custom loader used by the TestBug4179766
+ * class load this same interface class using the system class
+ * loader.  The custom loader then loads a subclass that is
+ * then passed back to the caller.  The fact that the caller
+ * and loader share a common base class allows the caller
+ * to cast the object without causing a ClassCastException.
+ */
+public interface Bug4179766Getter {
+    /** return the specified resource or null if not found */
+    public ResourceBundle getResourceBundle(String resource);
+}
diff --git a/test/java/util/ResourceBundle/Bug4179766Resource.java b/test/java/util/ResourceBundle/Bug4179766Resource.java
new file mode 100644
index 0000000..72d7645
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4179766Resource.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+import java.util.ListResourceBundle;
+
+/**
+ * A dummy resource to be loaded by the custom class loader.
+ * The contents are unimportant.
+ */
+public class Bug4179766Resource extends ListResourceBundle {
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "MonthNames",
+                new String[] {
+                    "January",
+                    "February",
+                    "March",
+                    "April",
+                    "May",
+                    "June",
+                    "July",
+                    "August",
+                    "September",
+                    "October",
+                    "November",
+                    "December",
+                    "",
+                }
+            },
+            { "DayNames",
+                new String[] {
+                    "Sunday",
+                    "Monday",
+                    "Tuesday",
+                    "Wednesday",
+                    "Thursday",
+                    "Friday",
+                    "Saturday",
+                }
+            }
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4195978Test.java b/test/java/util/ResourceBundle/Bug4195978Test.java
new file mode 100644
index 0000000..fdaff27
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4195978Test.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/**
+ * @test
+ * @bug 4195978
+ * @summary Verifies that resource bundle names have case distinction.
+ * @author joconner
+ */
+import java.util.*;
+
+public class Bug4195978Test extends ListResourceBundle {
+
+    public static void main(final String args[]) throws Exception {
+        new Bug4195978Test().test();
+    }
+
+    public void test() throws Exception {
+        try {
+            // load a property resourcebundle
+            final ResourceBundle bundle = ResourceBundle.getBundle("bug4195978Test");
+            // load this file as a ListResourceBundle
+            final ResourceBundle bundle2 = ResourceBundle.getBundle("Bug4195978Test");
+
+            // get the "test" keyid from both bundles
+            String b1 = bundle.getString("test");
+            String b2 = bundle2.getString("test");
+
+            // one should be lowercase, the other is uppercase
+            // each bundle can be used seperately because their names
+            // are distinguished by case.
+            if (b1.equals("test") && b2.equals("TEST")) {
+                System.out.println("Passed");
+            }
+        } catch (Exception e) {
+            System.err.println("Failed");
+            System.err.println(e);
+            throw e;
+        }
+
+
+    }
+
+    public Object[][] getContents() {
+        return contents;
+    }
+
+    Object[][] contents = {
+        {"test", "TEST"},
+    };
+
+
+}
diff --git a/test/java/util/ResourceBundle/Bug4257318.java b/test/java/util/ResourceBundle/Bug4257318.java
new file mode 100644
index 0000000..2af35a8
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4257318.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/**
+ * @test
+ * @bug 4257318
+ * @author John O'Conner
+ * @build Bug4257318Res Bug4257318Res_en
+ * @run main Bug4257318
+ */
+
+import java.util.ResourceBundle;
+
+
+public class Bug4257318 {
+  ResourceBundle res;
+  boolean passed;
+
+  public Bug4257318() {
+    passed = false;
+    res = ResourceBundle.getBundle("Bug4257318Res", new java.util.Locale("","",""));
+  }
+
+  boolean run() {
+    String str = res.getString("Hello");
+    passed = str.equals("Hello from the root bundle!");
+    System.out.println("Root bundle string: " + str);
+    return passed;
+  }
+
+  public static void main(String[] args) throws Exception {
+    boolean passed;
+    Bug4257318 test = new Bug4257318();
+    passed = test.run();
+    if (!passed) {
+      throw new Exception("Bug4257318 Test: FAILED");
+    }
+
+  }
+}
diff --git a/test/java/util/ResourceBundle/Bug4257318Res.java b/test/java/util/ResourceBundle/Bug4257318Res.java
new file mode 100644
index 0000000..0d092d4
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4257318Res.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/**
+
+  @bug 4257318
+  @author John O'Conner
+  */
+
+import java.util.ListResourceBundle;
+
+public class Bug4257318Res extends ListResourceBundle {
+
+  public Object[][] getContents() {
+    return contents;
+  }
+
+  static Object[][] contents = {
+    {"Hello", "Hello from the root bundle!"},
+  };
+}
diff --git a/test/java/util/ResourceBundle/Bug4257318Res_en.java b/test/java/util/ResourceBundle/Bug4257318Res_en.java
new file mode 100644
index 0000000..3e45dea
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4257318Res_en.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/**
+
+  @bug 4257318
+  @author John O'Conner
+  */
+
+import java.util.ListResourceBundle;
+
+public class Bug4257318Res_en extends ListResourceBundle {
+
+  public Object[][] getContents() {
+    return contents;
+  }
+
+  static Object[][] contents = {
+    {"Hello", "Hello from the en bundle!"},
+  };
+}
diff --git a/test/java/util/ResourceBundle/Bug4353454.java b/test/java/util/ResourceBundle/Bug4353454.java
new file mode 100644
index 0000000..c6828d3
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4353454.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4353454
+ * @summary Test if the second getBundle call finds a bundle in the default Locale search path.
+ */
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+
+public class Bug4353454 {
+
+    public static void main(String[] args) {
+        Locale l = Locale.getDefault();
+        try {
+            Locale.setDefault(Locale.US);
+            test();
+            test();
+        } finally {
+            Locale.setDefault(l);
+        }
+    }
+
+    private static void test() {
+        ResourceBundle myResources = ResourceBundle.getBundle("RB4353454", new Locale(""));
+        if (!"Got it!".equals(myResources.getString("text"))) {
+            throw new RuntimeException("returned wrong resource for key 'text': "
+                                       + myResources.getString("text"));
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4396021.java b/test/java/util/ResourceBundle/Bug4396021.java
new file mode 100644
index 0000000..e70750e
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4396021.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4396021
+ * @summary Verify that a resource bundle can override its parent.
+ * @build Bug4396021GeneralMessages Bug4396021SpecialMessages
+ * @run main Bug4396021
+ */
+
+import java.util.ResourceBundle;
+
+public class Bug4396021 {
+
+    private static ResourceBundle bundle;
+
+    public static void main(String[] args) throws Exception {
+        bundle = ResourceBundle.getBundle("Bug4396021SpecialMessages");
+
+        checkValue("special_key", "special_value");
+        checkValue("general_key", "general_value");
+    }
+
+    private static void checkValue(String key, String expected) throws Exception {
+        String result = bundle.getString(key);
+        if (!result.equals(expected)) {
+            throw new RuntimeException("Got wrong value from resource bundle"
+                    + " - key: " + key + ", expected: " + expected
+                    + ", got: " + result);
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4396021GeneralMessages.java b/test/java/util/ResourceBundle/Bug4396021GeneralMessages.java
new file mode 100644
index 0000000..68a83bc
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4396021GeneralMessages.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+import java.util.ListResourceBundle;
+
+public class Bug4396021GeneralMessages extends ListResourceBundle {
+
+    private static final Object[][] contents = {
+        {"general_key", "general_value"},
+    };
+
+    public Bug4396021GeneralMessages() {
+        super();
+    }
+
+    protected Object[][] getContents() {
+        return contents;
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug4396021SpecialMessages.java b/test/java/util/ResourceBundle/Bug4396021SpecialMessages.java
new file mode 100644
index 0000000..420056b
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug4396021SpecialMessages.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+import java.util.ListResourceBundle;
+
+public class Bug4396021SpecialMessages extends ListResourceBundle {
+
+    private static final Object[][] contents = {
+        {"special_key", "special_value"},
+    };
+
+    public Bug4396021SpecialMessages() {
+        setParent(getBundle("Bug4396021GeneralMessages"));
+    }
+
+    protected Object[][] getContents() {
+        return contents;
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug6190861.java b/test/java/util/ResourceBundle/Bug6190861.java
new file mode 100644
index 0000000..0e4eeb4
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6190861.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 6190861
+ * @summary Make sure to always load the default locale's bundle when
+ * there's no bundle for the requested locale.
+ */
+
+import java.util.*;
+
+public class Bug6190861 {
+
+    static public void main(String[] args) {
+        Locale.setDefault(new Locale("en", "US"));
+
+        List localeList = new ArrayList();
+        localeList.add(Locale.ENGLISH);
+        localeList.add(Locale.KOREA);
+        localeList.add(Locale.UK);
+        localeList.add(new Locale("en", "CA"));
+        localeList.add(Locale.ENGLISH);
+
+        Iterator iter = localeList.iterator();
+        while (iter.hasNext()){
+            Locale currentLocale = (Locale) iter.next();
+            System.out.println("\ncurrentLocale = "
+                               + currentLocale.getDisplayName());
+
+            ResourceBundle messages = ResourceBundle.getBundle("Bug6190861Data",currentLocale);
+
+            Locale messagesLocale = messages.getLocale();
+            System.out.println("messagesLocale = "
+                               + messagesLocale.getDisplayName());
+            checkMessages(messages);
+        }
+    }
+
+    static void checkMessages(ResourceBundle messages) {
+        String greetings = messages.getString("greetings");
+        String inquiry = messages.getString("inquiry");
+        String farewell = messages.getString("farewell");
+        System.out.println(greetings);
+        System.out.println(inquiry);
+        System.out.println(farewell);
+        if (!greetings.equals("Hiya.")) {
+            throw new RuntimeException("got wrong resource bundle");
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug6190861Data.properties b/test/java/util/ResourceBundle/Bug6190861Data.properties
new file mode 100644
index 0000000..5deeca3
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6190861Data.properties
@@ -0,0 +1,28 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+greetings = Hello.
+farewell = Goodbye.
+inquiry = How are you?
diff --git a/test/java/util/ResourceBundle/Bug6190861Data_en_US.properties b/test/java/util/ResourceBundle/Bug6190861Data_en_US.properties
new file mode 100644
index 0000000..d16d2eb
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6190861Data_en_US.properties
@@ -0,0 +1,28 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+greetings = Hiya.
+farewell = Seeya.
+inquiry = Howdy?
diff --git a/test/java/util/ResourceBundle/Bug6204853.java b/test/java/util/ResourceBundle/Bug6204853.java
new file mode 100644
index 0000000..e644f36
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6204853.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 6204853
+ * @summary tests PropertyResourceBundle(Reader) constructor.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.PropertyResourceBundle;
+
+public final class Bug6204853 {
+
+    public Bug6204853() {
+        try {
+            String srcDir = System.getProperty("test.src", ".");
+            FileInputStream  fis8859_1 =
+                new FileInputStream(new File(srcDir, "Bug6204853.properties"));
+            FileInputStream fisUtf8 =
+                new FileInputStream(new File(srcDir, "Bug6204853_Utf8.properties"));
+            InputStreamReader isrUtf8 = new InputStreamReader(fisUtf8, "UTF-8");
+
+            PropertyResourceBundle bundleUtf8 = new PropertyResourceBundle(isrUtf8);
+            PropertyResourceBundle bundle = new PropertyResourceBundle(fis8859_1);
+
+            String[] arrayUtf8 = createKeyValueArray(bundleUtf8);
+            String[] array = createKeyValueArray(bundle);
+
+            isrUtf8.close();
+            fisUtf8.close();
+            fis8859_1.close();
+
+            if (!Arrays.equals(arrayUtf8, array)) {
+                throw new RuntimeException("PropertyResourceBundle constructed from a UTF-8 encoded property file is not equal to the one constructed from ISO-8859-1 encoded property file.");
+            }
+        } catch (FileNotFoundException fnfe) {
+            throw new RuntimeException(fnfe);
+        } catch (IOException ioe) {
+            throw new RuntimeException(ioe);
+        }
+    }
+
+    private final String[] createKeyValueArray(PropertyResourceBundle b) {
+        List<String> keyValueList = new ArrayList<String>();
+        StringBuilder sb = new StringBuilder();
+
+        for (String key : b.keySet()) {
+            sb.setLength(0);
+            sb.append(key);
+            sb.append(" = ");
+            sb.append(b.getString(key));
+            keyValueList.add(sb.toString());
+        }
+
+        String[] keyValueArray = keyValueList.toArray(new String[0]);
+        Arrays.sort(keyValueArray);
+        return keyValueArray;
+    }
+
+    public final static void main(String[] args) {
+        new Bug6204853();
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug6204853.properties b/test/java/util/ResourceBundle/Bug6204853.properties
new file mode 100644
index 0000000..5373a01
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6204853.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+
+key1 = \u30b5\u30f3\u30bf\u30af\u30e9\u30e9
+key2 = \u30ab\u30ea\u30d5\u30a9\u30eb\u30cb\u30a2
+key3 = \u30a2\u30e1\u30ea\u30ab\u5408\u8846\u56fd
diff --git a/test/java/util/ResourceBundle/Bug6204853_Utf8.properties b/test/java/util/ResourceBundle/Bug6204853_Utf8.properties
new file mode 100644
index 0000000..76f448b
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6204853_Utf8.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+
+key1 = サンタクララ
+key2 = カリフォルニア
+key3 = アメリカ合衆国
diff --git a/test/java/util/ResourceBundle/Bug6287579.java b/test/java/util/ResourceBundle/Bug6287579.java
new file mode 100644
index 0000000..9012eed
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6287579.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 6287579
+ * @summary Make sure that getContents() of ListResourceBundle subclasses is 'protected'
+ *          and returns a different Object[]][] instance in each invocation.
+ */
+
+import java.lang.reflect.*;
+import java.util.*;
+
+public class Bug6287579 {
+    static final Locale ROOT = new Locale("");
+
+    static final String[] baseNames = {
+        "sun.text.resources.BreakIteratorInfo",
+        "sun.text.resources.FormatData",
+        "sun.text.resources.CollationData",
+        "sun.util.resources.LocaleNames",
+        "sun.util.resources.TimeZoneNames",
+
+        // Make sure the properties-to-class conversion tool generates
+        // the proper getContents().
+        "sun.awt.resources.awt",
+    };
+
+    public static void main(String[] args) throws Exception {
+        int errors = 0;
+
+        List<Locale> locales = new ArrayList<Locale>();
+        locales.addAll(Arrays.asList(Locale.getAvailableLocales()));
+        locales.add(ROOT);
+
+        for (Locale locale : locales) {
+            for (String base : baseNames) {
+                String className = getResourceName(base, locale);
+                errors += checkGetContents(className);
+            }
+        }
+        if (errors > 0) {
+            throw new RuntimeException(errors + " errors found");
+        }
+    }
+
+    static int checkGetContents(String className) throws Exception {
+        int err = 0;
+        try {
+            Class clazz = Class.forName(className);
+            Method getContentsMethod = clazz.getDeclaredMethod("getContents",
+                                                               (Class[]) null);
+            if (!Modifier.isProtected(getContentsMethod.getModifiers())) {
+                System.err.println(className + ": not protected");
+                err++;
+            }
+            getContentsMethod.setAccessible(true);
+            Object bundle = clazz.newInstance();
+            Object o1 = getContentsMethod.invoke(bundle, (Object[]) null);
+            Object o2 = getContentsMethod.invoke(bundle, (Object[]) null);
+            if (o1 == o2) {
+                System.err.println(className + ": same instance returned");
+                err++;
+            }
+        } catch (ClassNotFoundException ce) {
+            // Skip nonexistent classes
+        } catch (NoSuchMethodException me) {
+            System.out.println(className + ": no declared getContents()");
+        }
+        return err;
+    }
+
+    static String getResourceName(String base, Locale locale) {
+        if (locale.equals(ROOT)) {
+            return base;
+        }
+        StringBuilder sb = new StringBuilder(base);
+        sb.append('_').append(locale.getLanguage());
+        if (locale.getCountry().length() > 0
+            || locale.getVariant().length() > 0) {
+            sb.append('_').append(locale.getCountry());
+        }
+        if (locale.getVariant().length() > 0) {
+            sb.append('_').append(locale.getVariant());
+        }
+        return sb.toString();
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug6299235Test.java b/test/java/util/ResourceBundle/Bug6299235Test.java
new file mode 100644
index 0000000..d0032ac
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6299235Test.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+import java.io.File;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import sun.util.CoreResourceBundleControl;
+
+/*
+ * After introducing CoreResourceBundleControl for Awt/Swing resources
+ * loading, non-existent resources won't be actually searched from
+ * bootclasspath and extension directory. But we should still fallback
+ * to the current behavior which allows the third-part to provide their
+ * own version of awt resources, for example even though we never claim
+ * we support it yet.
+ * Look into bug 6299235 for more details.
+ */
+
+public class Bug6299235Test {
+
+    public static void main(String args[]) throws Exception {
+        /* Try to load "sun.awt.resources.awt_ru_RU.properties which
+         * is in awtres.jar.
+         */
+        ResourceBundle russionAwtRes = ResourceBundle.getBundle("sun.awt.resources.awt",
+                                                                new Locale("ru", "RU"),
+                                                                CoreResourceBundleControl.getRBControlInstance());
+
+        /* If this call throws MissingResourceException, the test fails. */
+        if (russionAwtRes != null) {
+            String result = russionAwtRes.getString("foo");
+            if (result.equals("bar")) {
+                System.out.println("Bug6299235Test passed");
+            } else {
+                System.err.println("Bug6299235Test failed");
+                throw new Exception("Resource found, but value of key foo is not correct\n");
+            }
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug6299235Test.sh b/test/java/util/ResourceBundle/Bug6299235Test.sh
new file mode 100644
index 0000000..6da631e
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6299235Test.sh
@@ -0,0 +1,86 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#!/bin/sh
+#
+# @test
+# @bug 6299235
+# @summary test Bug 6299235 to make sure the third-party provided sun resources could be picked up.
+# @build Bug6299235Test
+# @run shell Bug6299235Test.sh
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+  SunOS | Linux )
+    PATHSEP=":"
+    FILESEP="/"
+    ;;
+  Windows* )
+    PATHSEP=";"
+    FILESEP="\\"
+    ;;
+  * )
+    echo "${OS} is unrecognized system!"
+    exit 1;
+    ;;
+esac
+
+if [ -z "${TESTSRC}" ]; then
+  echo "TESTSRC undefined: defaulting to ."
+  TESTSRC=.
+fi
+
+if [ -z "${TESTJAVA}" ]; then
+  echo "TESTJAVA undefined: can't continue."
+  exit 1
+fi
+
+# See if TESTJAVA points to JRE or JDK
+if [ -d "${TESTJAVA}${FILESEP}jre" ]; then
+    JRE_EXT_DIR=${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext
+else
+    JRE_EXT_DIR=${TESTJAVA}${FILESEP}lib${FILESEP}ext
+fi
+
+if [ -d "${JRE_EXT_DIR}" ]; then
+    NEW_EXT_DIR=${JRE_EXT_DIR}${PATHSEP}${TESTSRC}
+else
+    NEW_EXT_DIR=${TESTSRC}
+fi
+
+echo "TESTJAVA=${TESTJAVA}"
+echo "TESTSRC=${TESTSRC}"
+echo "TESTCLASSES=${TESTCLASSES}"
+echo "NEW_EXT_DIR=${NEW_EXT_DIR}"
+
+cd ${TESTSRC}
+
+${TESTJAVA}/bin/java -cp ${TESTCLASSES} -Djava.ext.dirs=${NEW_EXT_DIR} Bug6299235Test
+
+if [ $? -ne 0 ]
+    then
+      echo "Test fails: exception thrown!"
+      exit 1
+fi
+
+exit 0
diff --git a/test/java/util/ResourceBundle/Bug6355009.java b/test/java/util/ResourceBundle/Bug6355009.java
new file mode 100644
index 0000000..4b703ab
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6355009.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 6355009
+ * @summary Make sure not to have too many causes for MissingResourceException
+ */
+
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+
+public final strictfp class Bug6355009 {
+    private final ResourceBundle bundle = ResourceBundle.getBundle(Bug6355009.class.getName());
+
+    public final static void main(String[] args) {
+        try {
+            new Bug6355009();
+        } catch (MissingResourceException e) {
+            Throwable cause = e;
+            int count = 0;
+            while ((cause = cause.getCause()) != null) {
+                if (cause instanceof MissingResourceException) {
+                    count++;
+                }
+            }
+            if (count > 0) {
+                throw new RuntimeException("too many causes: " + count);
+            }
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug6356571.java b/test/java/util/ResourceBundle/Bug6356571.java
new file mode 100644
index 0000000..5331331
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6356571.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 6356571
+ * @summary Make sure that non-ResourceBundle classes are ignored and
+ * properties files are loaded correctly.
+ */
+
+import java.util.ResourceBundle;
+
+public class Bug6356571 {
+    // Bug6356571.class is not a ResourceBundle class, so it will be
+    // ignored and Bug6356571.properties will be loaded.
+    private ResourceBundle bundle = ResourceBundle.getBundle("Bug6356571");
+
+    void check() {
+        String id = bundle.getString("id");
+        if (!"6356571".equals(id)) {
+            throw new RuntimeException("wrong id: " + id);
+        }
+    }
+
+    public final static void main(String[] args) {
+        new Bug6356571().check();
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug6356571.properties b/test/java/util/ResourceBundle/Bug6356571.properties
new file mode 100644
index 0000000..e9d8695
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6356571.properties
@@ -0,0 +1,25 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+
+id=6356571
diff --git a/test/java/util/ResourceBundle/Bug6359330.java b/test/java/util/ResourceBundle/Bug6359330.java
new file mode 100644
index 0000000..3e97987
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6359330.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 6359330
+ * @summary Make sure that getBundle doesn't cause a security error
+ * with a security manager when instantialing RBClassLoader (internal
+ * classloader).
+ */
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.SAXNotRecognizedException;
+
+public class Bug6359330 {
+
+    public static void main(String[] args) throws Throwable {
+        System.setSecurityManager(new SecurityManager());
+        try {
+            SAXParserFactory spf = SAXParserFactory.newInstance();
+            spf.setNamespaceAware(true);
+            spf.setValidating(true);
+            SAXParser sp = spf.newSAXParser();
+            // The following line shouldn't throw a
+            // java.security.AccessControlException.
+            sp.setProperty("foo", "bar");
+        } catch (SAXNotRecognizedException e) {
+            // Ignore this expected exception.
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Bug6572242.java b/test/java/util/ResourceBundle/Bug6572242.java
new file mode 100644
index 0000000..c19ad68
--- /dev/null
+++ b/test/java/util/ResourceBundle/Bug6572242.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @summary Make sure that ResourceBundle.getBundle ignores LinkageError for compatibility.
+ * @bug 6572242
+ */
+
+import java.util.ResourceBundle;
+
+public class Bug6572242 {
+    public static void main(String[] args) {
+        ResourceBundle rb = ResourceBundle.getBundle("bug6572242");
+        String data = rb.getString("data");
+        if (!data.equals("type")) {
+            throw new RuntimeException("got \"" + data + "\", expected \"type\"");
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/AbstractRB.java b/test/java/util/ResourceBundle/Control/AbstractRB.java
new file mode 100644
index 0000000..3c6fe26
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/AbstractRB.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.util.*;
+
+public abstract class AbstractRB extends ListResourceBundle {
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "type", "class (abstract)" }
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/BadControlsTest.java b/test/java/util/ResourceBundle/Control/BadControlsTest.java
new file mode 100644
index 0000000..659802f
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/BadControlsTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 5102289
+ * @summary Test if ResourceBundle.getBundle detects bad Control implementations.
+ */
+
+import java.io.*;
+import java.util.*;
+import static java.util.ResourceBundle.Control.*;
+
+public class BadControlsTest {
+    public static void main(String[] args) {
+        ResourceBundle.Control control;
+
+        control = new ResourceBundle.Control() {
+                public List<String> getFormats(String name) {
+                    return null;
+                }
+            };
+        testControl(control, "getFormats returns null");
+
+        control = new ResourceBundle.Control() {
+                public List<String> getFormats(String name) {
+                    return Arrays.asList("java.class", null, "java.properties");
+                }
+            };
+        testControl(control, "getFormats returns a List containing null");
+
+        control = new ResourceBundle.Control() {
+                public List<Locale> getCandidateLocales(String name, Locale loc) {
+                    return null;
+                }
+            };
+        testControl(control, "getCandidateLocales returns null");
+
+        control = new ResourceBundle.Control() {
+                public List<Locale> getCandidateLocales(String name, Locale loc) {
+                    return Arrays.asList(Locale.US, null, Locale.ENGLISH);
+                }
+            };
+        testControl(control, "getCandidateLocales returns a List containing null");
+
+        long[] badTtls = {
+            TTL_NO_EXPIRATION_CONTROL - 1,
+            -10000,
+            Long.MIN_VALUE
+        };
+        for (final long ttl : badTtls) {
+            control = new ResourceBundle.Control() {
+                    public long getTimeToLive(String name, Locale loc) {
+                        return ttl;
+                    }
+                };
+            testControl(control, "getTimeToLive returns " + ttl);
+        }
+
+        control = new ResourceBundle.Control() {
+                public String toBundleName(String name, Locale loc) {
+                    return null;
+                }
+            };
+        try {
+            ResourceBundle rb = ResourceBundle.getBundle("StressOut", control);
+            throw new RuntimeException("toBundleName returns null");
+        } catch (MissingResourceException e) {
+            if (!(e.getCause() instanceof NullPointerException)) {
+                throw new RuntimeException("toBundleName returns null. The cause isn't NPE.");
+            }
+        }
+
+        // null Control tests
+        control = null;
+        try {
+            ResourceBundle rb = ResourceBundle.getBundle("StressOut", control);
+            throw new RuntimeException("getBundle doesn't throw NPE with null Control");
+        } catch (NullPointerException e) {
+            // OK
+        }
+    }
+
+    private static void testControl(ResourceBundle.Control control, String testTitle) {
+        try {
+            ResourceBundle rb = ResourceBundle.getBundle("StressOut", control);
+            throw new RuntimeException(testTitle);
+        } catch (IllegalArgumentException e) {
+            System.out.println(testTitle + ": PASSED (" + e.getMessage() + ")");
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/BadStaticInitRB.java b/test/java/util/ResourceBundle/Control/BadStaticInitRB.java
new file mode 100644
index 0000000..5ba14de
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/BadStaticInitRB.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.util.*;
+
+public class BadStaticInitRB extends ListResourceBundle {
+    // Must have an error in this static initializer
+    static {
+        int[] x = new int[1];
+        x[100] = 100;
+    }
+
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "type", "class (static initializer error)" }
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/Bug6530694.java b/test/java/util/ResourceBundle/Control/Bug6530694.java
new file mode 100644
index 0000000..7ab7eb2
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/Bug6530694.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * @test
+ * @bug 6530694
+ * @summary Checks that sun.util.CoreResourceBundleControl does not apply
+ *     to the application provided Swing resources.
+ * @run main/othervm Bug6530694
+ */
+
+import java.util.Locale;
+import javax.swing.UIDefaults;
+import javax.swing.UIManager;
+
+public class Bug6530694 {
+    Bug6530694() {
+        Locale.setDefault(Locale.GERMANY);
+        UIDefaults defs = UIManager.getDefaults();
+        defs.addResourceBundle("Bug6530694");
+        String str = defs.getString("testkey");
+        if (!"testvalue".equals(str)) {
+            throw new RuntimeException("Could not load the resource for de_DE locale");
+        }
+    }
+
+    public static void main(String[] args) {
+        new Bug6530694();
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/Bug6530694_de_DE.properties b/test/java/util/ResourceBundle/Control/Bug6530694_de_DE.properties
new file mode 100644
index 0000000..ea0af5d
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/Bug6530694_de_DE.properties
@@ -0,0 +1,23 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+testkey=testvalue
diff --git a/test/java/util/ResourceBundle/Control/Chinese.properties b/test/java/util/ResourceBundle/Control/Chinese.properties
new file mode 100644
index 0000000..d09c7cf
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/Chinese.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+data=root
diff --git a/test/java/util/ResourceBundle/Control/Chinese_zh.properties b/test/java/util/ResourceBundle/Control/Chinese_zh.properties
new file mode 100644
index 0000000..a9e60ce
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/Chinese_zh.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+data=zh
diff --git a/test/java/util/ResourceBundle/Control/Chinese_zh_CN.properties b/test/java/util/ResourceBundle/Control/Chinese_zh_CN.properties
new file mode 100644
index 0000000..c4e4919
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/Chinese_zh_CN.properties
@@ -0,0 +1,28 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+# Empty
+
diff --git a/test/java/util/ResourceBundle/Control/Chinese_zh_TW.properties b/test/java/util/ResourceBundle/Control/Chinese_zh_TW.properties
new file mode 100644
index 0000000..6bf15af
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/Chinese_zh_TW.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+# Empty
diff --git a/test/java/util/ResourceBundle/Control/ControlFactoryTest.java b/test/java/util/ResourceBundle/Control/ControlFactoryTest.java
new file mode 100644
index 0000000..f6fda4c
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/ControlFactoryTest.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 5102289
+ * @summary Test the ResourceBundle.Control factory methods.
+ */
+
+import java.util.*;
+import static java.util.ResourceBundle.Control.*;
+
+public class ControlFactoryTest {
+
+    /**
+     * An interface for calling ResourceBundle.Control.getControl or
+     * ResourceBundle.Control.getNoFallbackControl.
+     */
+    private static interface Factory {
+        public ResourceBundle.Control getControl(List<String> formats);
+        public String name();
+    }
+
+    static int errors;
+
+    public static void main(String[] args) {
+        // Test getControl.
+        testControlFactory(new Factory() {
+                public ResourceBundle.Control getControl(List<String> formats) {
+                    return ResourceBundle.Control.getControl(formats);
+                }
+                public String name() { return "getControl"; }
+            }, Locale.getDefault());
+
+        // Test getNoFallbackControl.
+        testControlFactory(new Factory() {
+                public ResourceBundle.Control getControl(List<String> formats) {
+                    return ResourceBundle.Control.getNoFallbackControl(formats);
+                }
+                public String name() { return "getNoFallbackControl"; }
+            }, null);
+
+        if (errors > 0) {
+            throw new RuntimeException("FAILED: " + errors + " error(s)");
+        }
+    }
+
+    private static void testControlFactory(Factory factory, Locale loc) {
+        testGetControl(factory, loc, FORMAT_DEFAULT, "java.class", "java.properties");
+        testGetControl(factory, loc, FORMAT_CLASS, "java.class");
+        testGetControl(factory, loc, FORMAT_PROPERTIES, "java.properties");
+
+        // test IllegalArgumentException
+        String[][] data = {
+            { "java.class", "java.properties", "java.xml" },
+            { "java.class", "java.props" },
+            { "java.properties", "java.class" },
+            { "java.foo", "java.properties" },
+            { "java.foo" },
+            { null },
+        };
+        for (String[] fmts : data) {
+            try {
+                List<String> fmt = Arrays.asList(fmts);
+                ResourceBundle.Control control = factory.getControl(fmt);
+                error("getControl: %s%n", fmt);
+            } catch (IllegalArgumentException e) {
+            }
+        }
+
+        // test NPE
+        try {
+            ResourceBundle.Control control = factory.getControl(null);
+            error("%s: doesn't throw NPE.%n", factory.name());
+        } catch (NullPointerException npe) {
+        }
+    }
+
+    private static void testGetControl(Factory factory,
+                                       Locale loc,
+                                       final List<String> FORMATS,
+                                       String... fmtStrings) {
+        final ResourceBundle.Control CONTROL = factory.getControl(FORMATS);
+        List<String> fmt = CONTROL.getFormats("any");
+        if (fmt != FORMATS) {
+            error("%s: returns %s, expected %s.%n",
+                  factory.name(), fmt, FORMATS);
+        }
+        ResourceBundle.Control control = null;
+
+        // Check if getControl always returns the expected singleton.
+        for (int i = 0; i < 10; i++) {
+            fmt = Arrays.asList(fmtStrings);
+            control = factory.getControl(fmt);
+            if (control != CONTROL) {
+                error("%s: doesn't return the singleton: got %s, expected %s%n",
+                      factory.name(), control, CONTROL);
+            }
+        }
+
+        // Check if getFallbackLocale performs as expected.
+        Locale defaultLocale = Locale.getDefault();
+        Locale nonDefaultLocale = defaultLocale.equals(Locale.US) ? Locale.JAPAN : Locale.US;
+        if (loc != null) {
+            // Test ResourceBundle.Control.getControl()
+            Locale l = CONTROL.getFallbackLocale("any", nonDefaultLocale);
+            if (!defaultLocale.equals(l)) {
+                error("%s: getFallbackLocale doesn't return default locale. got %s, expected %s%n",
+                      factory.name(), toString(l), toString(defaultLocale));
+            }
+            l = CONTROL.getFallbackLocale("any", defaultLocale);
+            if (l != null) {
+                error("%s: getFallbackLocale doesn't return null. got %s%n",
+                      factory.name(), toString(l));
+            }
+        } else {
+            // Test ResourceBundle.Control.getNoFallbackControl()
+            Locale l = CONTROL.getFallbackLocale("any", nonDefaultLocale);
+            if (l != null) {
+                error("%s: getFallbackLocale doesn't return null. got %s%n",
+                      factory.name(), toString(l));
+            }
+            l = CONTROL.getFallbackLocale("any", defaultLocale);
+            if (l != null) {
+                error("%s: getFallbackLocale doesn't return null. got %s%n",
+                      factory.name(), toString(l));
+            }
+        }
+    }
+
+    private static String toString(Locale loc) {
+        if (loc == null)
+            return "null";
+        return "\"" + loc.getLanguage() + "_" + loc.getCountry() + "_" + loc.getVariant() + "\"";
+    }
+
+    private static void error(String msg) {
+        System.out.println(msg);
+        errors++;
+    }
+
+    private static void error(String fmt, Object... args) {
+        System.out.printf(fmt, args);
+        errors++;
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/DefaultControlTest.java b/test/java/util/ResourceBundle/Control/DefaultControlTest.java
new file mode 100644
index 0000000..7e079f2
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/DefaultControlTest.java
@@ -0,0 +1,443 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 5102289 6278334
+ * @summary Test the default Control implementation. The expiration
+ * functionality of newBundle, getTimeToLive, and needsReload is
+ * tested by ExpirationTest.sh. The factory methods are tested
+ * separately.
+ * @build TestResourceRB
+ * @build NonResourceBundle
+ * @run main DefaultControlTest
+ */
+
+import java.util.*;
+import static java.util.ResourceBundle.Control.*;
+
+public class DefaultControlTest {
+    // The ResourceBundle.Control instance
+    static final ResourceBundle.Control CONTROL
+        = ResourceBundle.Control.getControl(FORMAT_DEFAULT);
+
+    static final ResourceBundle BUNDLE = new ResourceBundle() {
+            public Enumeration<String> getKeys() { return null; }
+            protected Object handleGetObject(String key) { return null; }
+        };
+
+    static final String CLAZZ = FORMAT_CLASS.get(0);
+
+    static final String PROPERTIES = FORMAT_PROPERTIES.get(0);
+
+    static final ClassLoader LOADER = DefaultControlTest.class.getClassLoader();
+
+    // Full arguments for NPE testing
+    static final Object[] FULLARGS = { "any",
+                                       Locale.US,
+                                       FORMAT_PROPERTIES.get(0),
+                                       LOADER,
+                                       BUNDLE };
+
+    static int errors;
+
+    public static void main(String[] args) {
+        checkConstants();
+
+        // Test getFormats(String)
+        testGetFormats();
+
+        // Test getCandidateLocales(String, Locale)
+        testGetCandidateLocales();
+
+        // Test getFallbackLocale(String, Locale)
+        testGetFallbackLocale();
+
+        // Test newBundle(String, Locale, String, ClassLoader, boolean)
+        testNewBundle();
+
+        // Test toBundleName(String, Locale)
+        testToBundleName();
+
+        // Test getTimeToLive(String, Locale)
+        testGetTimeToLive();
+
+        // Test needsReload(String, Locale, String, ClassLoader,
+        //                  ResourceBundle, long)
+        testNeedsReload();
+
+        // Test toResourceName(String, String)
+        testToResourceName();
+
+        if (errors > 0) {
+            throw new RuntimeException("FAILED: " + errors + " error(s)");
+        }
+    }
+
+    private static void checkConstants() {
+        // Check FORMAT_*
+        if (!CONTROL.FORMAT_DEFAULT.equals(Arrays.asList("java.class",
+                                                        "java.properties"))) {
+            error("Wrong Control.FORMAT_DEFAULT");
+        }
+        checkImmutableList(CONTROL.FORMAT_DEFAULT);
+        if (!CONTROL.FORMAT_CLASS.equals(Arrays.asList("java.class"))) {
+            error("Wrong Control.FORMAT_CLASS");
+        }
+        checkImmutableList(CONTROL.FORMAT_CLASS);
+        if (!CONTROL.FORMAT_PROPERTIES.equals(Arrays.asList("java.properties"))) {
+            error("Wrong Control.FORMAT_PROPERTIES");
+        }
+        checkImmutableList(CONTROL.FORMAT_PROPERTIES);
+
+        // Check TTL_*
+        if (CONTROL.TTL_DONT_CACHE != -1) {
+            error("Wrong Control.TTL_DONT_CACHE: %d%n", CONTROL.TTL_DONT_CACHE);
+        }
+        if (CONTROL.TTL_NO_EXPIRATION_CONTROL != -2) {
+            error("Wrong Control.TTL_NO_EXPIRATION_CONTROL: %d%n",
+                  CONTROL.TTL_NO_EXPIRATION_CONTROL);
+        }
+    }
+
+    private static void checkImmutableList(List<String> list) {
+        try {
+            list.add("hello");
+            error("%s is mutable%n", list);
+        } catch (UnsupportedOperationException e) {
+        }
+    }
+
+    private static void testGetFormats() {
+        List<String> list = CONTROL.getFormats("foo");
+        if (list != CONTROL.FORMAT_DEFAULT) {
+            error("getFormats returned " + list);
+        }
+        try {
+            list = CONTROL.getFormats(null);
+            error("getFormats doesn't throw NPE.");
+        } catch (NullPointerException e) {
+        }
+    }
+
+    private static void testGetCandidateLocales() {
+        Map<Locale, Locale[]> candidateData = new HashMap<Locale, Locale[]>();
+        candidateData.put(new Locale("ja", "JP", "YOK"), new Locale[] {
+                              new Locale("ja", "JP", "YOK"),
+                              new Locale("ja", "JP"),
+                              new Locale("ja"),
+                              new Locale("") });
+        candidateData.put(new Locale("ja", "JP"), new Locale[] {
+                              new Locale("ja", "JP"),
+                              new Locale("ja"),
+                              new Locale("") });
+        candidateData.put(new Locale("ja"), new Locale[] {
+                              new Locale("ja"),
+                              new Locale("") });
+
+        candidateData.put(new Locale("ja", "", "YOK"), new Locale[] {
+                              new Locale("ja", "", "YOK"),
+                              new Locale("ja"),
+                              new Locale("") });
+        candidateData.put(new Locale("", "JP", "YOK"), new Locale[] {
+                              new Locale("", "JP", "YOK"),
+                              new Locale("", "JP"),
+                              new Locale("") });
+        candidateData.put(new Locale("", "", "YOK"), new Locale[] {
+                              new Locale("", "", "YOK"),
+                              new Locale("") });
+        candidateData.put(new Locale("", "JP"), new Locale[] {
+                              new Locale("", "JP"),
+                              new Locale("") });
+        candidateData.put(new Locale(""), new Locale[] {
+                              new Locale("") });
+
+        for (Locale locale : candidateData.keySet()) {
+            List<Locale> candidates = CONTROL.getCandidateLocales("any", locale);
+            List<Locale> expected = Arrays.asList(candidateData.get(locale));
+            if (!candidates.equals(expected)) {
+                error("Wrong candidates for %s: got %s, expected %s%n",
+                      toString(locale), candidates, expected);
+            }
+        }
+        final int NARGS = 2;
+        for (int mask = 0; mask < (1 << NARGS)-1; mask++) {
+            Object[] data = getNpeArgs(NARGS, mask);
+            try {
+                List<Locale> candidates = CONTROL.getCandidateLocales((String) data[0],
+                                                                      (Locale) data[1]);
+                error("getCandidateLocales(%s, %s) doesn't throw NPE.%n",
+                      data[0], toString((Locale)data[1]));
+            } catch (NullPointerException e) {
+            }
+        }
+    }
+
+    private static void testGetFallbackLocale() {
+        Locale current = Locale.getDefault();
+        Locale.setDefault(Locale.ITALY);
+        try {
+            Locale loc = CONTROL.getFallbackLocale("any", Locale.FRANCE);
+            if (loc != Locale.ITALY) {
+                error("getFallbackLocale: got %s, expected %s%n",
+                      toString(loc), toString(Locale.ITALY));
+            }
+            loc = CONTROL.getFallbackLocale("any", Locale.ITALY);
+            if (loc != null) {
+                error("getFallbackLocale: got %s, expected null%n", toString(loc));
+            }
+        } finally {
+            Locale.setDefault(current);
+        }
+
+        final int NARGS = 2;
+        for (int mask = 0; mask < (1 << NARGS)-1; mask++) {
+            Object[] data = getNpeArgs(NARGS, mask);
+            try {
+                Locale loc = CONTROL.getFallbackLocale((String) data[0], (Locale) data[1]);
+                error("getFallbackLocale(%s, %s) doesn't throw NPE.%n", data[0], data[1]);
+            } catch (NullPointerException e) {
+            }
+        }
+    }
+
+    private static void testNewBundle() {
+        int testNo = 0;
+        ResourceBundle rb = null;
+        try {
+            testNo = 1;
+            rb = CONTROL.newBundle("StressOut", Locale.JAPANESE,
+                                   PROPERTIES, LOADER, false);
+            String s = rb.getString("data");
+            if (!s.equals("Japan")) {
+                error("newBundle: #%d got %s, expected Japan%n", testNo, s);
+            }
+
+            testNo = 2;
+            rb = CONTROL.newBundle("TestResourceRB", new Locale(""),
+                                   CLAZZ, LOADER, false);
+            s = rb.getString("type");
+            if (!s.equals(CLAZZ)) {
+                error("newBundle: #%d got %s, expected %s%n", testNo, s, CLAZZ);
+            }
+        } catch (Throwable e) {
+            error("newBundle: #%d threw %s%n", testNo, e);
+            e.printStackTrace();
+        }
+
+        // Test exceptions
+
+        try {
+            // MalformedDataRB contains an invalid Unicode notation which
+            // causes to throw an IllegalArgumentException.
+            rb = CONTROL.newBundle("MalformedDataRB", Locale.ENGLISH,
+                                   PROPERTIES, LOADER, false);
+            error("newBundle: doesn't throw IllegalArgumentException with malformed data.");
+        } catch (IllegalArgumentException iae) {
+        } catch (Exception e) {
+            error("newBundle: threw %s%n", e);
+        }
+
+        try {
+            rb = CONTROL.newBundle("StressOut", Locale.JAPANESE,
+                                   "foo.bar", LOADER, false);
+            error("newBundle: doesn't throw IllegalArgumentException with invalid format.");
+        } catch (IllegalArgumentException iae) {
+        } catch (Exception e) {
+            error("newBundle: threw %s%n", e);
+        }
+
+        try {
+            rb = CONTROL.newBundle("NonResourceBundle", new Locale(""),
+                                   "java.class", LOADER, false);
+            error("newBundle: doesn't throw ClassCastException with a non-ResourceBundle subclass.");
+        } catch (ClassCastException cce) {
+        } catch (Exception e) {
+            error("newBundle: threw %s%n", e);
+        }
+
+        // NPE test
+        final int NARGS = 4;
+        for (int mask = 0; mask < (1 << NARGS)-1; mask++) {
+            Object[] data = getNpeArgs(NARGS, mask);
+            Locale loc = (Locale) data[1];
+            try {
+                rb = CONTROL.newBundle((String) data[0], loc,
+                                       (String) data[2], (ClassLoader) data[3],
+                                       false);
+                error("newBundle(%s, %s, %s, %s, false) doesn't throw NPE.%n",
+                      data[0], toString(loc), data[2], data[3]);
+            } catch (NullPointerException npe) {
+            } catch (Exception e) {
+                error("newBundle(%s, %s, %s, %s, false) threw %s.%n",
+                      data[0], toString(loc), data[2], data[3], e);
+            }
+        }
+    }
+
+    private static void testGetTimeToLive() {
+        long ttl = CONTROL.getTimeToLive("any", Locale.US);
+        if (ttl != CONTROL.TTL_NO_EXPIRATION_CONTROL) {
+            error("getTimeToLive: got %d, expected %d%n", ttl,
+                  CONTROL.TTL_NO_EXPIRATION_CONTROL);
+        }
+        final int NARGS = 2;
+        for (int mask = 0; mask < (1 << NARGS)-1; mask++) {
+            Object[] data = getNpeArgs(NARGS, mask);
+            try {
+                ttl = CONTROL.getTimeToLive((String) data[0], (Locale) data[1]);
+                error("getTimeToLive(%s, %s) doesn't throw NPE.%n", data[0], data[1]);
+            } catch (NullPointerException e) {
+            }
+        }
+    }
+
+    // The functionality of needsReload is tested by
+    // ExpirationTest.sh. Only parameter checking is tested here.
+    private static void testNeedsReload() {
+        long loadTime = System.currentTimeMillis();
+
+        // NPE test
+        final int NARGS = 5;
+        for (int mask = 0; mask < (1 << NARGS)-1; mask++) {
+            Object[] data = getNpeArgs(NARGS, mask);
+            Locale loc = (Locale) data[1];
+            try {
+                boolean b = CONTROL.needsReload((String) data[0], loc,
+                                                (String) data[2], (ClassLoader) data[3],
+                                                (ResourceBundle) data[4], loadTime);
+                error("needsReload(%s, %s, %s, %s, %s, loadTime) doesn't throw NPE.%n",
+                      data[0], toString(loc), data[2], data[3], data[4]);
+            } catch (NullPointerException e) {
+            }
+        }
+    }
+
+    private static void testToBundleName() {
+        final String name = "J2SE";
+        Map<Locale, String> bundleNames = new HashMap<Locale, String>();
+        bundleNames.put(new Locale("ja", "JP", "YOK"),
+                        name + "_" + "ja" + "_" + "JP" + "_" + "YOK");
+        bundleNames.put(new Locale("ja", "JP"),
+                        name + "_" + "ja" + "_" + "JP");
+        bundleNames.put(new Locale("ja"),
+                        name + "_" + "ja");
+        bundleNames.put(new Locale("ja", "", "YOK"),
+                        name + "_" + "ja" + "_" + "" + "_" + "YOK");
+        bundleNames.put(new Locale("", "JP", "YOK"),
+                        name + "_" + "" + "_" + "JP" + "_" + "YOK");
+        bundleNames.put(new Locale("", "", "YOK"),
+                        name + "_" + "" + "_" + "" + "_" + "YOK");
+        bundleNames.put(new Locale("", "JP"),
+                        name + "_" + "" + "_" + "JP");
+        bundleNames.put(new Locale(""),
+                        name);
+
+        for (Locale locale : bundleNames.keySet()) {
+            String bn = CONTROL.toBundleName(name, locale);
+            String expected = bundleNames.get(locale);
+            if (!bn.equals(expected)) {
+                error("toBundleName: got %s, expected %s%n", bn, expected);
+            }
+        }
+
+        final int NARGS = 2;
+        for (int mask = 0; mask < (1 << NARGS)-1; mask++) {
+            Object[] data = getNpeArgs(NARGS, mask);
+            try {
+                String s = CONTROL.toBundleName((String) data[0], (Locale) data[1]);
+                error("toBundleName(%s, %s) doesn't throw NPE.%n", data[0], data[1]);
+            } catch (NullPointerException e) {
+            }
+        }
+    }
+
+    private static void testToResourceName() {
+        String[][] names = {
+            // bundleName,   suffix, expected result
+            { "com.sun.J2SE", "xml", "com/sun/J2SE.xml" },
+            { ".J2SE", "xml", "/J2SE.xml" },
+            { "J2SE", "xml", "J2SE.xml" },
+            { "com/sun/J2SE", "xml", "com/sun/J2SE.xml" },
+            { "com.sun.J2SE", "", "com/sun/J2SE." },
+            { ".", "", "/." },
+            { "", "", "." },
+
+            // data for NPE tests
+            { null, "any", null },
+            { "any", null, null },
+            { null, null, null },
+            };
+
+        for (String[] data : names) {
+            String result = null;
+            boolean npeThrown = false;
+            try {
+                result = CONTROL.toResourceName(data[0], data[1]);
+            } catch (NullPointerException npe) {
+                npeThrown = true;
+            }
+            String expected = data[2];
+            if (expected != null) {
+                if (!result.equals(expected)) {
+                    error("toResourceName: got %s, expected %s%n", result, data[2]);
+                }
+            } else {
+                if (!npeThrown) {
+                    error("toResourceName(%s, %s) doesn't throw NPE.%n", data[0], data[1]);
+                }
+            }
+        }
+    }
+
+    /**
+     * Produces permutations argument data that contains at least one
+     * null.
+     */
+    private static Object[] getNpeArgs(int length, int mask) {
+        Object[] data = new Object[length];
+        for (int i = 0; i < length; i++) {
+            if ((mask & (1 << i)) == 0) {
+                data[i] = null;
+            } else {
+                data[i] = FULLARGS[i];
+            }
+        }
+        return data;
+    }
+
+    private static String toString(Locale loc) {
+        if (loc == null)
+            return "null";
+        return "\"" + loc.getLanguage() + "_" + loc.getCountry() + "_" + loc.getVariant() + "\"";
+    }
+
+    private static void error(String msg) {
+        System.out.println(msg);
+        errors++;
+    }
+
+    private static void error(String fmt, Object... args) {
+        System.out.printf(fmt, args);
+        errors++;
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/ExpirationTest.java b/test/java/util/ResourceBundle/Control/ExpirationTest.java
new file mode 100644
index 0000000..01390b8
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/ExpirationTest.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+/*
+ * This class is used by ExpirationTest.sh. See the timing information in
+ * the shell script.
+ */
+
+import java.util.*;
+
+public class ExpirationTest {
+    static final Locale AUSTRIA = new Locale("de", "AT");
+    static String format;
+    static String fileType;
+
+    public static void main(String[] args) {
+        // If -latency is specified, try sleeping for 3 seconds 3
+        // times to see its latency. If the latency is too large, then
+        // the program exits with 2. (See sleep())
+        if ("-latency".equals(args[0])) {
+            System.out.print("Checking latency... ");
+            for (int i = 0; i < 3; i++) {
+                sleep(3);
+            }
+            System.out.println("done");
+            System.exit(0);
+        }
+
+        format = args[0];
+        fileType = args[1];
+
+        Locale loc = Locale.getDefault();
+        try {
+            Locale.setDefault(Locale.JAPAN);
+            ResourceBundle.Control control = new TestControl();
+            ResourceBundle rb = ResourceBundle.getBundle("ExpirationData", Locale.GERMAN,
+                                                         control);
+            check(rb.getString("data"), "German");
+
+            rb = ResourceBundle.getBundle("ExpirationData", AUSTRIA, control);
+            check(rb.getString("january"), "Januar");
+
+            // Wait until the instance gets expired in the cache in 7 seconds.
+            sleep(7);
+
+            // At this point, it should be determined that reloading is not needed.
+            rb = ResourceBundle.getBundle("ExpirationData", Locale.GERMAN, control);
+            check(rb.getString("data"), "German");
+
+            rb = ResourceBundle.getBundle("ExpirationData", AUSTRIA, control);
+            check(rb.getString("january"), "Januar");
+
+            // Wait until the instance in the cache gets expired again and
+            // ExpirationData_de gets updated.
+            // 33 = 40 - 7 (See the timing chart in ExpirationTest.sh)
+            sleep(33);
+
+            // At this point, getBundle must reload the updated
+            // ExpirationData_de and ExpirationData_de_AT must be
+            // avaible.
+
+            rb = ResourceBundle.getBundle("ExpirationData", Locale.GERMAN, control);
+            try {
+                check(rb.getString("data"), "Deutsch");
+            } catch (RuntimeException e) {
+                if (format.equals("class")) {
+                    // Class loader doesn't load updated classes.
+                    System.out.println("Known class limitation: " + e.getMessage());
+                }
+            }
+
+            rb = ResourceBundle.getBundle("ExpirationData", AUSTRIA, control);
+            try {
+                check(rb.getString("january"), "J\u00e4nner");
+            } catch (RuntimeException e) {
+                if (fileType.equals("jar")) {
+                    // Jar doesn't load new entries.
+                    System.out.println("Known jar limitation: " + e.getMessage());
+                } else {
+                    throw e;
+                }
+            }
+        } finally {
+            Locale.setDefault(loc);
+        }
+    }
+
+    private static void check(String s, String expected) {
+        String time = getTime();
+        if (!s.equals(expected)) {
+            throw new RuntimeException("got '" + s + "', expected '" + expected + "' at "
+                                       + time);
+        }
+        System.out.println("ExpirationTest: got '" + s + "' at " + time);
+    }
+
+    private static void sleep(int seconds) {
+        long millis = seconds * 1000;
+        long start = System.currentTimeMillis();
+        try {
+            Thread.sleep(millis);
+        } catch (InterruptedException e) {
+        }
+        long end = System.currentTimeMillis();
+        long latency = end - start - millis;
+        // If the latecy is more than 1% of the requested sleep time,
+        // then give up the testing.
+        if (latency > millis/100) {
+            System.err.printf("Latency is too large: slept for %d [ms], "
+                              + "expected %d [ms] latency rate: %+.2f%% (expected not more than 1%%)%n"
+                              + "exiting...%n",
+                              end - start, millis, (double)latency*100.0/millis);
+            System.exit(2);
+        }
+    }
+
+    private static final String getTime() {
+        return new Date().toString().substring(11, 19);
+    }
+
+    private static class TestControl extends ResourceBundle.Control {
+        @Override
+        public long getTimeToLive(String name, Locale loc) {
+            return 5000; // 5 seconds
+        }
+
+        @Override
+        public ResourceBundle newBundle(String name, Locale loc,
+                                        String fmt, ClassLoader cl, boolean reload)
+            throws IllegalAccessException, InstantiationException, java.io.IOException {
+            ResourceBundle bundle = super.newBundle(name, loc, fmt, cl, reload);
+            if (bundle != null) {
+                System.out.println("newBundle: " + (reload ? "**re" : "")
+                                   + "loaded '" + toName(name, loc , fmt) + "' at " + getTime());
+            }
+            return bundle;
+        }
+
+        @Override
+        public boolean needsReload(String name, Locale loc,
+                                   String fmt, ClassLoader cl,
+                                   ResourceBundle rb, long time) {
+            boolean b = super.needsReload(name, loc, fmt, cl, rb, time);
+            System.out.println("needsReload: '" + b + "' for " + toName(name, loc, fmt)
+                               + " at " + getTime());
+            return b;
+        }
+
+        private String toName(String name, Locale loc, String fmt) {
+            return toResourceName(toBundleName(name, loc), fmt.substring(5));
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/ExpirationTest.sh b/test/java/util/ResourceBundle/Control/ExpirationTest.sh
new file mode 100644
index 0000000..449162c
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/ExpirationTest.sh
@@ -0,0 +1,331 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+# @test
+# @bug 4212439 5102289 6272156
+# @summary Tests for expiration control and reloading expired resource bundles.
+# @build ExpirationTest
+# @run shell/timeout=300 ExpirationTest.sh
+
+#
+# Timings of the test sequence
+#
+# 0         5    7      10             20             40  [seconds]
+# +---------+----+------+------//------+------//------+--
+# g         X    g      X              U              g   [event]
+#
+#  0 g - java starts; the first getBundle call gets "German";
+#        sleep for 7 sec
+#  5 X - the bundle expires (every 5 seconds)
+#  7 g - java wakes up; the second getBundle call still gets "German";
+#        sleep for 33 sec
+# 10 X - the bundle expires in the cache
+# 20 U - shell script updates DE and add AT
+# 40 g - java wakes up; third getBundle call; gets "Deutsch"
+#
+# event: g - getBundle, X - eXpire, U - Update
+#
+#
+# ExpirationTest.java uses 3 exit values.
+#  0 - passed
+#  1 - failed
+#  2 - can't proceed due to slow platform
+#
+
+# Check environment variables
+if [ "x$TESTJAVA" = "x" ]; then
+    1>&2 echo "No TESTJAVA defined. exiting..."
+    exit 1
+fi
+
+# Make sure that this test is run in C locale
+LANG=C
+export LANG
+LC_ALL=
+export LC_ALL
+
+: ${TESTCLASSES:=.}
+
+# YES if the platform has %s support in date
+HAS_S=NO
+
+case "`uname`" in
+Windows*)
+    DEL=";"
+    ;;
+SunOS)
+    DEL=":"
+    ;;
+Linux)
+    DEL=":"
+    HAS_S=YES
+    ;;
+esac
+
+# Interval until resources are updated
+INTERVAL=20
+
+DATA=ExpirationData
+
+ROOT=${DATA}.properties
+JA=${DATA}_ja.properties
+DE=${DATA}_de.properties
+AT=${DATA}_de_AT.properties
+
+JARFILE=data.jar
+
+createProperties() {
+    rm -f ${DATA}*.properties
+    echo "data: English" > $ROOT
+    (echo "data: Japanese"; echo "january: 1gatsu") > $JA
+    (echo "data: German"; echo "january: Januar") > $DE
+    echo "Properties files have been created at `date +%T`"
+}
+
+createJar() {
+    if [ "$FORMAT" = "properties" ]; then
+	createProperties
+	F="${DATA}*.properties"
+    else
+	createClasses
+	F="-C classes ${ROOT}.class -C classes ${JA}.class -C classes ${DE}.class"
+    fi
+    ${TESTJAVA}/bin/jar cf $JARFILE $F
+    ${TESTJAVA}/bin/jar tvf $JARFILE
+    rm -f ${DATA}*.properties
+    echo "Jar created at `date +%T`"
+}
+
+createClasses() {
+    rm -f ${DATA}*.java
+    rm -rf classes
+    mkdir classes
+    createJava $ROOT English
+    createJava $JA Japanese
+    createJava $DE German Januar
+    ${TESTJAVA}/bin/javac -d classes ${ROOT}.java ${JA}.java ${DE}.java
+    echo "Created" classes/*.class "at `date +%T`"
+}
+
+createJava() {
+    (echo "
+import java.util.*;
+
+public class $1 extends ListResourceBundle {
+    public Object[][] getContents() {
+	return new Object[][] {
+	    { \"data\", \"$2\" },"
+    if [ "x$3" != "x" ]; then
+	echo "	    { \"january\", \"$3\" },"
+    fi
+echo "	};
+    }
+}") >$1.java
+}
+
+updateDEaddAT() {
+    rm -f $DE
+    (echo "data=Deutsch"; echo "january=Januar") > $DE
+    # add de_AT
+    echo "january=J\u00e4nner" > $AT
+    echo "Updated '"${DE}"' and added '"${AT}"' at `date +%T`"
+}
+
+updateClassDEaddClassAT() {
+    rm -f $DE.java classes/$DE.class
+    createJava $DE Deutsch Januar
+    ${TESTJAVA}/bin/javac -d classes ${DE}.java
+    createJava $AT Deutsch "J\\u00e4nner"
+    ${TESTJAVA}/bin/javac -d classes ${AT}.java
+    echo "Updated '"${DE}"' class and added '"${AT}"' class at `date +%T`"
+}
+
+updateJar() {
+    if [ "$FORMAT" = "properties" ]; then
+	updateDEaddAT
+	F="$DE $AT"
+    else
+	updateClassDEaddClassAT
+	F="-C classes ${DE}.class -C classes ${AT}.class"
+    fi
+    ${TESTJAVA}/bin/jar uf $JARFILE $F
+    rm -f $DE $AT
+    echo "Updated '"${JARFILE}"' at `date +%T`"
+    ${TESTJAVA}/bin/jar tvf $JARFILE
+}
+
+getSeconds() {
+    if [ "$HAS_S" = "YES" ]; then
+	date '+%s'
+    else
+	# Returns an approximation of the offset from the Epoch in
+	# seconds.
+	date -u '+%Y %j %H %M %S' | \
+	awk '{d=($1-1970)*365.2425; print int(((((((d+$2-1)*24)+$3)*60)+$3)*60)+$5);}'
+    fi
+}
+
+#
+# Execute $1 and check how long it takes
+#
+timedExec() {
+    S=`getSeconds`
+    eval $1
+    E=`getSeconds`
+    D=`expr $E - $S`
+    #
+    # If this machine is too slow, give up the further testing.
+    #
+    if [ "$D" -gt $2 ]; then
+	1>&2 echo "This machine took $D seconds to prepare test data," \
+		  "which is too slow to proceed. Exiting..."
+	exit 0
+    fi
+    unset S
+    unset E
+    unset D
+}
+
+checkStatus() {
+    if [ $1 = 0 ]; then
+	echo "$2: PASSED"
+    elif [ $1 != 2 ]; then
+	echo "$2: FAILED"
+	exit 1
+    else
+	# Just we should't proceed to avoid timing issues.
+	exit 0
+    fi
+}
+
+#
+# Before starting tests, check the latency with Thread.sleep().
+#
+${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}." ExpirationTest -latency
+STATUS=$?
+if [ $STATUS = 2 ]; then
+    exit 0
+fi
+
+#
+# Tests for properties
+#
+FORMAT=properties
+
+#
+# Test with plain files (properties)
+#
+echo "Starting test with properties files at `date +%T`"
+
+#
+# Creates properties files
+#
+timedExec createProperties 10
+
+#
+# Execute a child process which will update files in $INTERVAL seconds.
+#
+(sleep $INTERVAL; updateDEaddAT; exit 0) &
+
+${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}." ExpirationTest properties file
+STATUS=$?
+wait
+checkStatus $STATUS "Test with properties files"
+
+#
+# Test with jar file if jar is available (properties)
+#
+if [ -x ${TESTJAVA}/bin/jar ] || [ -x ${TESTJAVA}/bin/jar.exe ]; then
+    HASJAR=YES
+else
+    HASJAR=NO
+fi
+
+if [ $HASJAR = YES  ]; then
+    echo ""
+    echo "Starting test with a jar file (properties) at `date +%T`"
+
+    #
+    # Create a jar files with properties
+    #
+    timedExec createJar 10
+
+    (sleep $INTERVAL; updateJar; exit 0) &
+    ${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}${JARFILE}" ExpirationTest properties jar
+    STATUS=$?
+    wait
+    checkStatus $STATUS "Test with a jar file (properties)"
+fi
+
+#
+# Test for classes
+#
+
+# Note: class-based resource bundles can't be reloaded due to the
+# cache support in class loaders. So the results of the test cases
+# below are not checked. (Test cases always pass.)
+
+# If there's no javac available, then give up the test with
+# class-based properties.
+if [ ! -x ${TESTJAVA}/bin/javac ] && [ ! -x ${TESTJAVA}/bin/javac.exe ]; then
+    exit 0
+fi
+
+rm -f ${DATA}*.properties $JARFILE
+
+FORMAT=class
+ROOT=`basename $ROOT .properties`
+JA=`basename $JA .properties`
+DE=`basename $DE .properties`
+AT=`basename $AT .properties`
+
+echo ""
+echo "Starting test with class files at `date +%T`"
+
+#
+# Create class files
+#
+timedExec createClasses 10
+
+(sleep $INTERVAL; updateClassDEaddClassAT; exit 0) &
+${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}classes" ExpirationTest class file
+STATUS=$?
+wait
+checkStatus $STATUS "Test with class files"
+
+if [ $HASJAR = YES ]; then
+    echo ""
+    echo "Starting test with a jar file (class) at `date +%T`"
+
+    #
+    # Create a jar file with class files
+    #
+    timedExec createJar 10
+
+    (sleep $INTERVAL; updateJar; exit 0) &
+    ${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}${JARFILE}" ExpirationTest class jar
+    STATUS=$?
+    wait
+    checkStatus $STATUS "Test with a jar file (class)"
+fi
+
+exit 0
diff --git a/test/java/util/ResourceBundle/Control/LoadingStrategiesTest.java b/test/java/util/ResourceBundle/Control/LoadingStrategiesTest.java
new file mode 100644
index 0000000..c4a2ee4
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/LoadingStrategiesTest.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4303146 5102289 6272060
+ * @summary Test non-standard loading strategies with ResourceBundle.Control subclasses
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class LoadingStrategiesTest {
+
+    static int errors;
+
+    public static void main(String[] args) {
+        ResourceBundle rb;
+        String s;
+
+        // Test zh_TW -> root, zh_CN -> zh -> root
+        rb = ResourceBundle.getBundle("Chinese", Locale.TAIWAN, new ChineseControl());
+        s = rb.getString("data");
+        check("chinese with Locale.TAIWAN", s, "root");
+
+        rb = ResourceBundle.getBundle("Chinese", Locale.CHINA, new ChineseControl());
+        s = rb.getString("data");
+        check("chinese with Locale.CHINA", s, "zh");
+
+
+        // Test use of per-locale packaging
+        preparePerLocalePackageProperties();
+
+        rb = ResourceBundle.getBundle("test.package.Messages", Locale.US,
+                                      new PerLocalePackageControl());
+        s = rb.getString("data");
+        check("Per-locale package with Locale.US", s, "");
+
+        rb = ResourceBundle.getBundle("test.package.Messages", Locale.GERMAN,
+                                      new PerLocalePackageControl());
+        s = rb.getString("data");
+        check("Per-locale package with Locale.GERMAN", s, "de");
+
+        rb = ResourceBundle.getBundle("test.package.Messages", Locale.JAPAN,
+                                      new PerLocalePackageControl());
+        s = rb.getString("data");
+        check("Per-locale package with Locale.JAPAN", s, "ja_JP");
+
+
+        // Check any errors
+        if (errors > 0) {
+            throw new RuntimeException("FAILED: " + errors + " error(s)");
+        }
+    }
+
+    private static void check(String msg, String got, String expected) {
+        if (!got.equals(expected)) {
+            error("%s: got \"%s\", expected \"%s\"%n", msg, got, expected);
+        }
+    }
+
+    private static class ChineseControl extends ResourceBundle.Control {
+        @Override
+        public List<Locale> getCandidateLocales(String baseName,
+                                                Locale locale) {
+            if (locale.equals(Locale.TAIWAN)) {
+                return Arrays.asList(locale,
+                                     // no Locale("zh")
+                                     new Locale(""));
+            }
+            return super.getCandidateLocales(baseName, locale);
+        }
+    }
+
+    private static class PerLocalePackageControl extends ResourceBundle.Control {
+        @Override
+        public String toBundleName(String baseName, Locale locale) {
+            if (baseName == null || locale == null) {
+                throw new NullPointerException();
+            }
+            String loc = super.toBundleName("", locale);
+            if (loc.length() > 0) {
+                return baseName.replaceFirst("^([\\w\\.]+)\\.(\\w+)$",
+                                             "$1." + loc.substring(1) + ".$2");
+            }
+            return baseName;
+        }
+
+        // Avoid fallback to the default locale (6272060)
+        @Override
+        public Locale getFallbackLocale(String baseName, Locale locale) {
+            if (baseName == null || locale == null) {
+                throw new NullPointerException();
+            }
+            return null;
+        }
+    }
+
+    // Creates:
+    //     test/package/Messages.properties
+    //     test/package/de/Messages.properties
+    //     test/package/ja_JP/Messages.properties
+    private static void preparePerLocalePackageProperties() {
+        final String DEL = File.separator;
+        try {
+            String dir = System.getProperty("test.classes", ".");
+            String[] subdirs = { "", "de", "ja_JP" };
+            for (String subdir : subdirs) {
+                StringBuilder sb = new StringBuilder();
+                sb.append(dir).append(DEL).append("test").append(DEL).append("package");
+                if (subdir.length() > 0) {
+                    sb.append(DEL).append(subdir);
+                }
+                File path = new File(sb.toString());
+                path.mkdirs();
+                File propsfile = new File(path, "Messages.properties");
+                OutputStream os = new FileOutputStream(propsfile);
+                Properties props = new Properties();
+                props.setProperty("data", subdir);
+                props.store(os, null);
+                System.out.println("Created: " + propsfile);
+                os.close();
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("Can't set up per-locale properties", e);
+        }
+    }
+
+    private static void error(String msg) {
+        System.out.println(msg);
+        errors++;
+    }
+
+    private static void error(String fmt, Object... args) {
+        System.out.printf(fmt, args);
+        errors++;
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/MalformedDataRB_en.properties b/test/java/util/ResourceBundle/Control/MalformedDataRB_en.properties
new file mode 100644
index 0000000..254d16c
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/MalformedDataRB_en.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+data=\u001xyz
diff --git a/test/java/util/ResourceBundle/Control/MissingResourceCauseTest.java b/test/java/util/ResourceBundle/Control/MissingResourceCauseTest.java
new file mode 100644
index 0000000..135573a
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/MissingResourceCauseTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class MissingResourceCauseTest {
+    public static void main(String[] args) {
+        callGetBundle("NonResourceBundle", ClassCastException.class);
+        callGetBundle("MalformedDataRB", Locale.ENGLISH, IllegalArgumentException.class);
+        callGetBundle("PrivateConstructorRB", IllegalAccessException.class);
+        callGetBundle("AbstractRB", InstantiationException.class);
+        callGetBundle("BadStaticInitRB", ExceptionInInitializerError.class);
+        callGetBundle("UnreadableRB", IOException.class);
+    }
+
+    private static void callGetBundle(String baseName,
+                                      Class<? extends Throwable> expectedCause) {
+        callGetBundle(baseName, Locale.getDefault(), expectedCause);
+    }
+
+    private static void callGetBundle(String baseName, Locale locale,
+                                      Class<? extends Throwable> expectedCause) {
+        ResourceBundle rb;
+        try {
+            rb = ResourceBundle.getBundle(baseName, locale);
+            throw new RuntimeException("getBundle(\""+baseName+"\") doesn't throw "
+                                      + expectedCause);
+        } catch (MissingResourceException e) {
+            Throwable cause = e.getCause();
+            if (!expectedCause.isInstance(cause)) {
+                throw new RuntimeException("getBundle(\""+baseName+"\") throws "
+                                           + cause + ", expected " + expectedCause);
+            }
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/MissingResourceCauseTest.sh b/test/java/util/ResourceBundle/Control/MissingResourceCauseTest.sh
new file mode 100644
index 0000000..c4f0aa8
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/MissingResourceCauseTest.sh
@@ -0,0 +1,57 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+# @test
+# @bug 4354216
+# @summary Test for the cause support when throwing a
+# MissingResourceBundle. (This test exists under
+# ResourceBundle/Control because bad resource bundle data can be
+# shared with other test cases.)
+# @build MissingResourceCauseTest
+# @build NonResourceBundle PrivateConstructorRB AbstractRB BadStaticInitRB
+# @run shell MissingResourceCauseTest.sh
+
+case "`uname`" in
+Windows*)
+    DEL=";";
+    ;;
+*)
+    DEL=":";
+    ;;
+esac
+
+#
+# Create an unreadble properties file
+#
+UNREADABLE=UnreadableRB.properties
+rm -f $UNREADABLE
+echo "type=unreadable" >$UNREADABLE
+chmod 000 $UNREADABLE
+
+: ${TESTCLASS:=.}
+: ${TESTSRC:=.}
+
+${TESTJAVA}/bin/java -esa -cp ${TESTCLASS}${DEL}${TESTSRC} MissingResourceCauseTest
+STATUS=$?
+chmod 666 $UNREADABLE
+rm -f $UNREADABLE
+exit $?
diff --git a/test/java/util/ResourceBundle/Control/NonResourceBundle.java b/test/java/util/ResourceBundle/Control/NonResourceBundle.java
new file mode 100644
index 0000000..99c48e5
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/NonResourceBundle.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+public class NonResourceBundle {
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "type", "Non-ResourceBundle" }
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/PackagePrivateRB.java b/test/java/util/ResourceBundle/Control/PackagePrivateRB.java
new file mode 100644
index 0000000..5367db8
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/PackagePrivateRB.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.util.*;
+
+// Package private resource bundle
+class PackagePrivateRB extends ListResourceBundle {
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "type", "class (package1.PackagePrivateRB)" }
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/PackagePrivateTest.java b/test/java/util/ResourceBundle/Control/PackagePrivateTest.java
new file mode 100644
index 0000000..86b57c2
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/PackagePrivateTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4175293 5102289
+ * @summary Test if package private ResourceBundles can be loaded.
+ * @build PackagePrivateRB
+ * @run main/timeout=300/othervm -esa PackagePrivateTest
+ */
+
+import java.io.*;
+import java.util.*;
+import static java.util.ResourceBundle.Control.*;
+
+public class PackagePrivateTest {
+    public static void main(String[] args) {
+        ResourceBundle rb;
+
+        // Make sure that the default Control can't load the package
+        // private resource bundles.
+        try {
+            rb = ResourceBundle.getBundle("PackagePrivateRB");
+            throw new RuntimeException(
+                       "doesn't throw MissingResourceException with the default Control");
+        } catch (MissingResourceException e) {
+        }
+
+        // Remove the dummy cache entry
+        ResourceBundle.clearCache();
+
+        rb = ResourceBundle.getBundle("PackagePrivateRB",
+                new ResourceBundle.Control() {
+                    @Override
+                    public List<String> getFormats(String baseName) {
+                        return FORMAT_CLASS;
+                    }
+
+                    @Override
+                    public ResourceBundle newBundle(String baseName,
+                                                    Locale locale,
+                                                    String format,
+                                                    ClassLoader loader,
+                                                    boolean reload)
+                        throws IllegalAccessException,
+                               InstantiationException, IOException {
+                        String bn = toBundleName(baseName, locale);
+                        if ("java.class".equals(format)) {
+                            try {
+                                Class<? extends ResourceBundle> cl =
+                                    (Class<? extends ResourceBundle>) loader.loadClass(bn);
+                                return  cl.newInstance();
+                            } catch (ClassNotFoundException e) {
+                                //System.out.println("ClassNotFoundException: " + e.getMessage());
+                            }
+                            return null;
+                        }
+                        throw new IllegalArgumentException("unknown format: " + format);
+                    }
+                });
+        String s = rb.getString("type");
+        if (!s.equals("class (package1.PackagePrivateRB)")) {
+            throw new RuntimeException("wrong type: got " + s + ", expected '" +
+                                       "class (package1.PackagePrivateRB)'");
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/PrivateConstructorRB.java b/test/java/util/ResourceBundle/Control/PrivateConstructorRB.java
new file mode 100644
index 0000000..604f589
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/PrivateConstructorRB.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.util.*;
+
+public class PrivateConstructorRB extends ListResourceBundle {
+    private PrivateConstructorRB() {
+    }
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "type", "class (private constructor)" }
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/StressOut.properties b/test/java/util/ResourceBundle/Control/StressOut.properties
new file mode 100644
index 0000000..51b7a6e
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/StressOut.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+data: U.S.A.
diff --git a/test/java/util/ResourceBundle/Control/StressOut_en_CA.properties b/test/java/util/ResourceBundle/Control/StressOut_en_CA.properties
new file mode 100644
index 0000000..a41aede
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/StressOut_en_CA.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+# empty
diff --git a/test/java/util/ResourceBundle/Control/StressOut_ja.properties b/test/java/util/ResourceBundle/Control/StressOut_ja.properties
new file mode 100644
index 0000000..6c9d36e
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/StressOut_ja.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+data: Japan
diff --git a/test/java/util/ResourceBundle/Control/StressOut_ja_JP.properties b/test/java/util/ResourceBundle/Control/StressOut_ja_JP.properties
new file mode 100644
index 0000000..a41aede
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/StressOut_ja_JP.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+# empty
diff --git a/test/java/util/ResourceBundle/Control/StressOut_ko.properties b/test/java/util/ResourceBundle/Control/StressOut_ko.properties
new file mode 100644
index 0000000..8971bcb
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/StressOut_ko.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+data: Korea
diff --git a/test/java/util/ResourceBundle/Control/StressOut_zh_CN.properties b/test/java/util/ResourceBundle/Control/StressOut_zh_CN.properties
new file mode 100644
index 0000000..c7e8af4
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/StressOut_zh_CN.properties
@@ -0,0 +1,27 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+
+data: China
diff --git a/test/java/util/ResourceBundle/Control/StressTest.java b/test/java/util/ResourceBundle/Control/StressTest.java
new file mode 100644
index 0000000..742df10
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/StressTest.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 5102289
+ * @summary Stress test for ResourceBundle.getBundle with ResourceBundle.Control.
+ * @run main/timeout=300/othervm -esa StressTest
+ */
+
+import java.util.*;
+import java.util.concurrent.atomic.*;
+
+public class StressTest {
+    static final Locale ROOT_LOCALE = new Locale("");
+    static final Random rand = new Random();
+    static final Locale[] locales = {
+        Locale.US,
+        Locale.CHINA,
+        ROOT_LOCALE,
+        Locale.JAPAN,
+        Locale.CANADA,
+        Locale.KOREA
+    };
+    static final String[] expected = {
+        "U.S.A.",
+        "China",
+        "U.S.A.",
+        "Japan",
+        "U.S.A.", // StressOut_en_CA.properties is empty.
+        "Korea"
+    };
+    final static long startTime = System.currentTimeMillis();
+
+    // increment each element when one getBundle call is done.
+    static AtomicIntegerArray counters;
+    static int[] prevCounters;
+    static int intervalForCounterCheck;
+    static AtomicInteger clearCounter = new AtomicInteger();
+
+    static volatile boolean runrun = true;
+
+    public static void main(String[] args) {
+        int nThreads = 2;
+        if (args.length > 0) {
+            nThreads = Math.max(Integer.parseInt(args[0]), 2);
+        }
+        int nSeconds = 180;
+        if (args.length > 1) {
+            nSeconds = Integer.parseInt(args[1]);
+        }
+        Locale.setDefault(Locale.US);
+        Thread[] tasks = new Thread[locales.length * nThreads];
+        counters = new AtomicIntegerArray(tasks.length);
+
+        for (int i = 0; i < tasks.length; i++) {
+            tasks[i] = new Thread(new Worker(i));
+        }
+        for (int i = 0; i < tasks.length; i++) {
+            tasks[i].start();
+        }
+
+        int nProcessors = Runtime.getRuntime().availableProcessors();
+        intervalForCounterCheck = Math.max(tasks.length / nProcessors, 1);
+        System.out.printf("%d processors, intervalForCounterCheck = %d [sec]%n",
+                          nProcessors, intervalForCounterCheck);
+        try {
+            for (int i = 0; runrun && i < nSeconds; i++) {
+                Thread.sleep(1000); // 1 seconds
+                if ((i % intervalForCounterCheck) == 0) {
+                    checkCounters();
+                }
+            }
+            runrun = false;
+            for (int i = 0; i < tasks.length; i++) {
+                tasks[i].join();
+            }
+        } catch (InterruptedException e) {
+        }
+
+        printCounters();
+    }
+
+    static void checkCounters() {
+        int length = counters.length();
+        int[] snapshot = new int[length];
+        for (int i = 0; i < length; i++) {
+            snapshot[i] = counters.get(i);
+        }
+
+        if (prevCounters == null) {
+            prevCounters = snapshot;
+            return;
+        }
+
+        for (int i = 0; i < length; i++) {
+            if (snapshot[i] > prevCounters[i]) {
+                continue;
+            }
+            System.out.printf(
+                "Warning: Thread #%d hasn't updated its counter for the last %d second(s).%n",
+                i, intervalForCounterCheck);
+        }
+        prevCounters = snapshot;
+    }
+
+    static void printCounters() {
+        long total = 0;
+        int min = Integer.MAX_VALUE;
+        int max = Integer.MIN_VALUE;
+        for (int i = 0; i < counters.length(); i++) {
+            int counter = counters.get(i);
+            total += counter;
+            min = Math.min(min, counter);
+            max = Math.max(max, counter);
+        }
+        System.out.printf("Total: %d calls, min=%d, max=%d, cache cleared %d times%n",
+                          total, min, max, clearCounter.get());
+    }
+
+    static class Worker implements Runnable {
+        final int id;
+        final int index;
+        final Locale locale;
+        final String str;
+        final int max;
+        final boolean cleaner;
+        ResourceBundle.Control control;
+
+        Worker(int i) {
+            id = i;
+            index = i % locales.length;
+            locale = locales[index];
+            cleaner = locale.equals(ROOT_LOCALE);
+            str = expected[index];
+            max = rand.nextInt((index + 1) * 500) + 1000;
+            control = new TestControl(max);
+            System.out.println("Worker" + i + ": locale="+locale+", expected="+str+
+                               ", max="+max);
+        }
+
+        public void run() {
+            while (runrun) {
+                ResourceBundle rb = ResourceBundle.getBundle("StressOut", locale, control);
+                counters.incrementAndGet(id);
+                String s = rb.getString("data");
+                if (!s.equals(str)) {
+                    runrun = false;
+                    throw new RuntimeException(locale + ": rb.locale=" + rb.getLocale() +
+                                               ", got " + s + ", expected " + str);
+                }
+                try {
+                    Thread.sleep(rand.nextInt(max/500));
+                } catch (InterruptedException e) {
+                }
+                if (cleaner && (rand.nextInt(10000) == 0)) {
+                    //System.out.println("Clearing cache!");
+                    ResourceBundle.clearCache();
+                    clearCounter.incrementAndGet();
+                }
+            }
+        }
+
+        static class TestControl extends ResourceBundle.Control {
+            int max;
+
+            public List<Locale> getCandidateLocales(String baseName, Locale locale) {
+                List<Locale> list = super.getCandidateLocales(baseName, locale);
+                //System.out.println("Candidate locales=" + list);
+                return list;
+            }
+            public TestControl(int max) {
+                this.max = max;
+            }
+            public long getTimeToLive(String baseName, Locale locale) {
+                // This will set TTL to a random value for each bundle.
+                long ttl = rand.nextInt(max);
+                //System.out.println("TTL: " + baseName + "_" + locale + " for " + ttl);
+                return ttl;
+            }
+            public boolean needsReload(String baseName, Locale locale,
+                                       String format, ClassLoader loader,
+                                       ResourceBundle bundle, long loadTime) {
+                //System.out.println("Expired: " + baseName + "_" + locale + "." + format +
+                //                 " at " + (loadTime-startTime) + ", bundle=" + bundle);
+                return rand.nextBoolean();
+            }
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/TestResourceRB.java b/test/java/util/ResourceBundle/Control/TestResourceRB.java
new file mode 100644
index 0000000..ac07b0d
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/TestResourceRB.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.util.*;
+
+public class TestResourceRB extends ListResourceBundle {
+    public Object[][] getContents() {
+        return new Object[][] {
+            { "type", "java.class" }
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/XMLResourceBundleTest.java b/test/java/util/ResourceBundle/Control/XMLResourceBundleTest.java
new file mode 100644
index 0000000..b2e4fee
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/XMLResourceBundleTest.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 5102289 4403721
+ * @summary Test XML support as shown in the ResourceBundle.Control description.
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import static java.util.ResourceBundle.Control.*;
+
+public class XMLResourceBundleTest {
+    public static void main(String[] args) {
+        ResourceBundle.Control xmlControl = new ResourceBundle.Control() {
+                   @Override
+                   public List<String> getFormats(String baseName) {
+                       if (baseName == null) {
+                           throw new NullPointerException();
+                       }
+                       return Arrays.asList("xml");
+                   }
+                   @Override
+                   public ResourceBundle newBundle(String baseName, Locale locale,
+                                                   String format,
+                                                   ClassLoader loader,
+                                                   boolean reload)
+                       throws IllegalAccessException,
+                              InstantiationException, IOException {
+                       if (baseName == null || locale == null
+                           || format == null || loader == null) {
+                           throw new NullPointerException();
+                       }
+                       ResourceBundle bundle = null;
+                       if (format.equals("xml")) {
+                           String bundleName = toBundleName(baseName, locale);
+                           String resourceName = toResourceName(bundleName, format);
+                           URL url = loader.getResource(resourceName);
+                           if (url != null) {
+                               URLConnection connection = url.openConnection();
+                               if (connection != null) {
+                                   if (reload) {
+                                       // disable caches if reloading
+                                       connection.setUseCaches(false);
+                                   }
+                                   InputStream stream = connection.getInputStream();
+                                   if (stream != null) {
+                                       BufferedInputStream bis = new BufferedInputStream(stream);
+                                       bundle = new XMLResourceBundle(bis);
+                                       bis.close();
+                                   }
+                               }
+                           }
+                       }
+                       return bundle;
+                   }
+               };
+        ResourceBundle rb = ResourceBundle.getBundle("XmlRB", new Locale(""), xmlControl);
+        String type = rb.getString("type");
+        if (!type.equals("XML")) {
+            throw new RuntimeException("Root Locale: type: got " + type
+                                       + ", expected XML (ASCII)");
+        }
+
+        rb = ResourceBundle.getBundle("XmlRB", Locale.JAPAN, xmlControl);
+        type = rb.getString("type");
+        // Expect fullwidth "XML"
+        if (!type.equals("\uff38\uff2d\uff2c")) {
+            throw new RuntimeException("Locale.JAPAN: type: got " + type
+                                       + ", expected \uff38\uff2d\uff2c (fullwidth XML)");
+        }
+    }
+
+    private static class XMLResourceBundle extends ResourceBundle {
+        private Properties props;
+
+        XMLResourceBundle(InputStream stream) throws IOException {
+            props = new Properties();
+            props.loadFromXML(stream);
+        }
+
+        protected Object handleGetObject(String key) {
+            if (key == null) {
+                throw new NullPointerException();
+            }
+            return props.get(key);
+        }
+
+        public Enumeration<String> getKeys() {
+            // Not implemented
+            return null;
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Control/XmlRB.xml b/test/java/util/ResourceBundle/Control/XmlRB.xml
new file mode 100644
index 0000000..a96efe1
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/XmlRB.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!---->
+
+<!-- DTD for properties -->
+<!DOCTYPE properties [
+<!ELEMENT properties ( comment?, entry* ) >
+<!ATTLIST properties version CDATA #FIXED "1.0">
+<!ELEMENT comment (#PCDATA) >
+<!ELEMENT entry (#PCDATA) >
+<!ATTLIST entry key CDATA #REQUIRED>
+]>
+
+<properties>
+    <comment>Test data for XMLResourceBundleTest.java</comment>
+    <entry key="type">XML</entry>
+</properties>
diff --git a/test/java/util/ResourceBundle/Control/XmlRB_ja.xml b/test/java/util/ResourceBundle/Control/XmlRB_ja.xml
new file mode 100644
index 0000000..2dc7dc5
--- /dev/null
+++ b/test/java/util/ResourceBundle/Control/XmlRB_ja.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!---->
+
+<!-- DTD for properties -->
+<!DOCTYPE properties [
+<!ELEMENT properties ( comment?, entry* ) >
+<!ATTLIST properties version CDATA #FIXED "1.0">
+<!ELEMENT comment (#PCDATA) >
+<!ELEMENT entry (#PCDATA) >
+<!ATTLIST entry key CDATA #REQUIRED>
+]>
+
+<properties>
+    <comment>Test data for XMLResourceBundleTest.java</comment>
+    <entry key="type">XML</entry>
+</properties>
diff --git a/test/java/util/ResourceBundle/FakeTestResource.java b/test/java/util/ResourceBundle/FakeTestResource.java
new file mode 100644
index 0000000..4ba5b1a
--- /dev/null
+++ b/test/java/util/ResourceBundle/FakeTestResource.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+// NOTE:  This class is part of the ResourceBundleTest.
+// The ResourceBundle code should never find this class, even if the caller looks
+// for "FakeTestResource".  If it does, that's an error.
+
+public class FakeTestResource {
+    public FakeTestResource() {
+    }
+}
diff --git a/test/java/util/ResourceBundle/KeySetMessages.java b/test/java/util/ResourceBundle/KeySetMessages.java
new file mode 100644
index 0000000..54aa387
--- /dev/null
+++ b/test/java/util/ResourceBundle/KeySetMessages.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.util.*;
+
+public class KeySetMessages extends ListResourceBundle {
+    protected Object[][] getContents() {
+        return new Object[][] {
+            { "food", "Cheeseburger" },
+            { "drink", "Coke" }};
+    }
+}
diff --git a/test/java/util/ResourceBundle/KeySetMessages_zh_CN.java b/test/java/util/ResourceBundle/KeySetMessages_zh_CN.java
new file mode 100644
index 0000000..21c9c26
--- /dev/null
+++ b/test/java/util/ResourceBundle/KeySetMessages_zh_CN.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.util.*;
+
+public class KeySetMessages_zh_CN extends ListResourceBundle {
+    protected Object[][] getContents() {
+        return new Object[][] {
+            { "food", "Peking Duck" },
+            { "tea", "Oolong" }};
+    }
+}
diff --git a/test/java/util/ResourceBundle/KeySetResources.properties b/test/java/util/ResourceBundle/KeySetResources.properties
new file mode 100644
index 0000000..220cff7
--- /dev/null
+++ b/test/java/util/ResourceBundle/KeySetResources.properties
@@ -0,0 +1,26 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+
+food: Cheeseburger
+drink: Coke
diff --git a/test/java/util/ResourceBundle/KeySetResources_ja_JP.properties b/test/java/util/ResourceBundle/KeySetResources_ja_JP.properties
new file mode 100644
index 0000000..a22ff0f
--- /dev/null
+++ b/test/java/util/ResourceBundle/KeySetResources_ja_JP.properties
@@ -0,0 +1,26 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+
+food: Chicken Teriyaki
+tea: Green Tea
diff --git a/test/java/util/ResourceBundle/KeySetTest.java b/test/java/util/ResourceBundle/KeySetTest.java
new file mode 100644
index 0000000..61c4afd
--- /dev/null
+++ b/test/java/util/ResourceBundle/KeySetTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4095319 4286358
+ * @summary Test cases for the containsKey, keySet, and handleKeySet
+ * methods that are new in Mustang.
+ * @build KeySetMessages KeySetMessages_zh_CN
+ * @run main KeySetTest
+ */
+
+import java.lang.reflect.*;
+import java.util.*;
+
+public class KeySetTest {
+    static final List<String> fullKeys = Arrays.asList("food", "drink", "tea");
+    static final List<String> localKeys = Arrays.asList("food", "tea");
+
+    public static void main(String[] args) {
+        // Test PropertyResourceBundle
+        testKeys("KeySetResources", Locale.JAPAN);
+
+        // Test ListResourceBundle
+        testKeys("KeySetMessages", Locale.CHINA);
+    }
+
+    static void testKeys(String bundleName, Locale locale) {
+        ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale);
+        System.out.println("food = " + rb.getString("food"));
+
+        // Test keySet()
+        Set<String> allKeys = rb.keySet();
+        if (!(allKeys.containsAll(fullKeys) && fullKeys.containsAll(allKeys))) {
+            throw new RuntimeException("got "+allKeys + ", expected " + fullKeys);
+        }
+
+        // Test containsKey()
+        for (String key : fullKeys) {
+            if (!rb.containsKey(key)) {
+                throw new RuntimeException("rb doesn't contain: " + key);
+            }
+        }
+        for (String key : new String[] { "snack", "beer" }) {
+            if (rb.containsKey(key)) {
+                throw new RuntimeException("rb contains: " + key);
+            }
+        }
+
+        // Make sure that the default handleKeySet implementation
+        // returns the subset keys of the given locale.
+        TestBundle tb = new TestBundle(bundleName, locale);
+        Set<String> childKeys = tb.handleKeySet();
+        if (!(childKeys.containsAll(localKeys) || localKeys.containsAll(childKeys))) {
+            throw new RuntimeException("get " + childKeys + ", expected " + localKeys);
+        }
+    }
+
+    static class TestBundle extends ResourceBundle {
+        ResourceBundle bundle;
+        Method m;
+
+        public TestBundle() {}
+
+        public TestBundle(String name, Locale locale) {
+            bundle = ResourceBundle.getBundle(name, locale);
+
+            // Prepare for the handleGetObject call
+            try {
+                Class clazz = bundle.getClass();
+                m = clazz.getMethod("handleGetObject", String.class);
+                m.setAccessible(true);
+            } catch (Exception e) {
+                throw new RuntimeException("method preparation error", e);
+            }
+        }
+
+        public Enumeration<String> getKeys() {
+            return bundle.getKeys();
+        }
+
+        // handleGetObject() doesn't look up its parent bundles.
+        protected Object handleGetObject(String key) {
+            try {
+                return m.invoke(bundle, key);
+            } catch (Exception e) {
+                throw new RuntimeException("handleGetObject error", e);
+            }
+        }
+
+        public Set<String> handleKeySet() {
+            return super.handleKeySet();
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/RB4353454_en.properties b/test/java/util/ResourceBundle/RB4353454_en.properties
new file mode 100644
index 0000000..2444b1e
--- /dev/null
+++ b/test/java/util/ResourceBundle/RB4353454_en.properties
@@ -0,0 +1,26 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+#
+#
+text=Got it!
diff --git a/test/java/util/ResourceBundle/RBTestFmwk.java b/test/java/util/ResourceBundle/RBTestFmwk.java
new file mode 100644
index 0000000..99f3051
--- /dev/null
+++ b/test/java/util/ResourceBundle/RBTestFmwk.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+import java.lang.reflect.*;
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.io.*;
+import java.text.*;
+
+/**
+ * RBTestFmwk is a base class for tests that can be run conveniently from
+ * the command line as well as under the Java test harness.
+ * <p>
+ * Sub-classes implement a set of methods named Test<something>. Each
+ * of these methods performs some test. Test methods should indicate
+ * errors by calling either err or errln.  This will increment the
+ * errorCount field and may optionally print a message to the log.
+ * Debugging information may also be added to the log via the log
+ * and logln methods.  These methods will add their arguments to the
+ * log only if the test is being run in verbose mode.
+ */
+public class RBTestFmwk {
+    //------------------------------------------------------------------------
+    // Everything below here is boilerplate code that makes it possible
+    // to add a new test by simply adding a function to an existing class
+    //------------------------------------------------------------------------
+
+    protected RBTestFmwk() {
+        // Create a hashtable containing all the test methods.
+        testMethods = new Hashtable();
+        Method[] methods = getClass().getDeclaredMethods();
+        for( int i=0; i<methods.length; i++ ) {
+            if( methods[i].getName().startsWith("Test")
+                    || methods[i].getName().startsWith("test") ) {
+                testMethods.put( methods[i].getName(), methods[i] );
+            }
+        }
+    }
+
+    protected void run(String[] args) throws Exception
+    {
+        System.out.println(getClass().getName() + " {");
+        indentLevel++;
+
+        // Set up the log and reference streams.  We use PrintWriters in order to
+        // take advantage of character conversion.  The JavaEsc converter will
+        // convert Unicode outside the ASCII range to Java's \\uxxxx notation.
+        log = new PrintWriter(System.out,true);
+
+        // Parse the test arguments.  They can be either the flag
+        // "-verbose" or names of test methods. Create a list of
+        // tests to be run.
+        Vector testsToRun = new Vector( args.length );
+        for( int i=0; i<args.length; i++ ) {
+            if( args[i].equals("-verbose") ) {
+                verbose = true;
+            }
+            else if( args[i].equals("-prompt") ) {
+                prompt = true;
+            } else if (args[i].equals("-nothrow")) {
+                nothrow = true;
+            } else {
+                Object m = testMethods.get( args[i] );
+                if( m != null ) {
+                    testsToRun.addElement( m );
+                }
+                else {
+                    usage();
+                    return;
+                }
+            }
+        }
+
+        // If no test method names were given explicitly, run them all.
+        if( testsToRun.size() == 0 ) {
+            Enumeration methodNames = testMethods.elements();
+            while( methodNames.hasMoreElements() ) {
+                testsToRun.addElement( methodNames.nextElement() );
+            }
+        }
+
+        // Run the list of tests given in the test arguments
+        for( int i=0; i<testsToRun.size(); i++ ) {
+            int oldCount = errorCount;
+
+            Method testMethod = (Method)testsToRun.elementAt(i);
+            writeTestName(testMethod.getName());
+
+            try {
+                testMethod.invoke(this, new Object[0]);
+            }
+            catch( IllegalAccessException e ) {
+                errln("Can't acces test method " + testMethod.getName());
+            }
+            catch( InvocationTargetException e ) {
+                errorCount++;
+                log.println("\nUncaught throwable thrown in test method "
+                            + testMethod.getName());
+                e.getTargetException().printStackTrace(this.log);
+                if (!nothrow) {
+                    throw new RuntimeException("Exiting...");
+                }
+            }
+            writeTestResult(errorCount - oldCount);
+        }
+        indentLevel--;
+        writeTestResult(errorCount);
+        if (prompt) {
+            System.out.println("Hit RETURN to exit...");
+            try {
+                System.in.read();
+            }
+            catch (IOException e) {
+                System.out.println("Exception: " + e.toString() + e.getMessage());
+            }
+        }
+        if (nothrow) {
+            System.exit(errorCount);
+        }
+    }
+
+    /**
+     * Adds given string to the log if we are in verbose mode.
+     */
+    protected void log( String message ) {
+        if( verbose ) {
+            indent(indentLevel + 1);
+            log.print( message );
+            log.flush();
+        }
+    }
+
+    protected void logln( String message ) {
+        log(message + System.getProperty("line.separator"));
+    }
+
+    /**
+     * Report an error
+     */
+    protected void err( String message ) {
+        errorCount++;
+        indent(indentLevel + 1);
+        log.print( message );
+        log.flush();
+
+        if (!nothrow) {
+            throw new RuntimeException(message);
+        }
+    }
+
+    protected void errln( String message ) {
+        err(message + System.getProperty("line.separator"));
+    }
+
+
+    protected void writeTestName(String testName) {
+        indent(indentLevel);
+        log.print(testName);
+        log.flush();
+        needLineFeed = true;
+    }
+
+    protected void writeTestResult(int count) {
+        if (!needLineFeed) {
+            indent(indentLevel);
+            log.print("}");
+        }
+        needLineFeed = false;
+
+        if (count != 0)
+            log.println(" FAILED");
+        else
+            log.println(" Passed");
+    }
+
+    private final void indent(int distance) {
+        if (needLineFeed) {
+            log.println(" {");
+            needLineFeed = false;
+        }
+        log.print(spaces.substring(0, distance * 2));
+    }
+
+    /**
+     * Print a usage message for this test class.
+     */
+    void usage() {
+        System.out.println(getClass().getName() +
+                            ": [-verbose] [-nothrow] [-prompt] [test names]");
+
+        System.out.println("test names:");
+        Enumeration methodNames = testMethods.keys();
+        while( methodNames.hasMoreElements() ) {
+            System.out.println("\t" + methodNames.nextElement() );
+        }
+    }
+
+    private boolean     prompt = false;
+    private boolean     nothrow = false;
+    protected boolean   verbose = false;
+
+    private PrintWriter log;
+    private int         indentLevel = 0;
+    private boolean     needLineFeed = false;
+    private int         errorCount = 0;
+
+    private Hashtable testMethods;
+    private final String spaces = "                                          ";
+}
diff --git a/test/java/util/ResourceBundle/ReferencesTest.java b/test/java/util/ResourceBundle/ReferencesTest.java
new file mode 100644
index 0000000..57b3aff
--- /dev/null
+++ b/test/java/util/ResourceBundle/ReferencesTest.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4405807
+ * @run main/othervm -Xms10m ReferencesTest
+ * @summary Verify that references from ResourceBundle cache don't prevent
+ * class loader reclamation.
+ */
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * This test relies on the current behavior of the garbage collector and is
+ * therefore no clear indicator of whether the fix for 4405807 works.
+ * If the test fails, it might indicate a regression, or it might just mean
+ * that a less aggressive garbage collector is used.
+ */
+public class ReferencesTest {
+
+    private static final int CLASS_LOADER_COUNT = 20;
+
+    // These two parallel arrays have references to the same class loaders.
+    // The weakLoaders array lets us track whether class loaders are being
+    // reclaimed after the references in the loaders array are nulled out.
+    private static ClassLoader[] loaders = new ClassLoader[CLASS_LOADER_COUNT];
+    private static WeakReference[] weakLoaders = new WeakReference[CLASS_LOADER_COUNT];
+
+    public static void main(String[] args) throws Exception {
+
+        URL testDirectory = new File(System.getProperty("test.classes", ".")).toURL();
+
+        for (int i = 0; i < loaders.length; i++) {
+            URL[] urls = { testDirectory };
+            loaders[i] = new URLClassLoader(urls);
+            weakLoaders[i] = new WeakReference(loaders[i]);
+        }
+
+        // fill the ResourceBundle cache with entries for half the class loaders
+        loadBundles(0, CLASS_LOADER_COUNT / 2);
+
+        report("After loading resource bundles for first half of class loaders: ");
+
+        // release the first half of the class loaders
+        for (int i = 0; i < CLASS_LOADER_COUNT / 2; i++) {
+            loaders[i] = null;
+        }
+
+        System.gc();
+
+        report("After releasing first half of class loaders: ");
+
+        // fill the ResourceBundle cache with entries for second half the class loaders
+        loadBundles(CLASS_LOADER_COUNT / 2, CLASS_LOADER_COUNT);
+
+        report("After loading resource bundles for second half of class loaders: ");
+
+        // release the second half of the class loaders
+        for (int i = CLASS_LOADER_COUNT / 2; i < CLASS_LOADER_COUNT; i++) {
+            loaders[i] = null;
+        }
+
+        System.gc();
+
+        report("After releasing second half of class loaders: ");
+
+        // The garbage collector in Tiger actually has reclaimed all class
+        // loaders at this point, but in order not to become too dependent
+        // on the current behavior, we only require that the first half
+        // has been reclaimed.
+        if (countLoaders(0, CLASS_LOADER_COUNT / 2) > 0) {
+            throw new RuntimeException("Too many class loaders not reclaimed yet.");
+        }
+    }
+
+    private static void report(String when) throws Exception {
+        int first = countLoaders(0, CLASS_LOADER_COUNT / 2);
+        int second = countLoaders(CLASS_LOADER_COUNT / 2, CLASS_LOADER_COUNT);
+
+        Class clazz = ResourceBundle.class;
+        Field cacheList = clazz.getDeclaredField("cacheList");
+        cacheList.setAccessible(true);
+        int cacheSize = ((Map)cacheList.get(clazz)).size();
+
+        System.out.println(when);
+        System.out.println("    " + first + " loaders alive in first half");
+        System.out.println("    " + second + " loaders alive in second half");
+        System.out.println("    " + cacheSize + " entries in resource bundle cache");
+    }
+
+    private static void loadBundles(int start, int end) throws Exception {
+        for (int i = start; i < end; i++) {
+            // There's no resource bundle for NonExistantBundle - this
+            // let's us test the case where a resource bundle is not found,
+            // which in the past created a SoftReference on the value side
+            // of the cache.
+            try {
+                ResourceBundle.getBundle("NonExistantBundle", Locale.US, loaders[i]);
+            } catch (MissingResourceException e) {
+            }
+            // There's a base resource bundle for ReferencesTestBundle - the
+            // normal case.
+            ResourceBundle.getBundle("ReferencesTestBundle", Locale.US, loaders[i]);
+        }
+    }
+
+    private static int countLoaders(int start, int end) {
+        int count = 0;
+        for (int i = start; i < end; i++) {
+            if (weakLoaders[i].get() != null) {
+                count++;
+            }
+        }
+        return count;
+    }
+}
diff --git a/test/java/util/ResourceBundle/ReferencesTestBundle.properties b/test/java/util/ResourceBundle/ReferencesTestBundle.properties
new file mode 100644
index 0000000..ac8db17
--- /dev/null
+++ b/test/java/util/ResourceBundle/ReferencesTestBundle.properties
@@ -0,0 +1,23 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+unused=Hallo, alle miteinander!
diff --git a/test/java/util/ResourceBundle/ResourceBundleTest.java b/test/java/util/ResourceBundle/ResourceBundleTest.java
new file mode 100644
index 0000000..93977fb
--- /dev/null
+++ b/test/java/util/ResourceBundle/ResourceBundleTest.java
@@ -0,0 +1,393 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    @test
+    @bug 4049325 4073127 4083270 4106034 4108126
+    @summary test Resource Bundle
+    @build TestResource TestResource_de TestResource_fr TestResource_fr_CH
+    @build TestResource_it FakeTestResource
+    @run main ResourceBundleTest
+*/
+/*
+ *
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+import java.text.*;
+import java.util.*;
+import java.io.*;
+
+public class ResourceBundleTest extends RBTestFmwk {
+    public static void main(String[] args) throws Exception {
+        new ResourceBundleTest().run(args);
+    }
+
+    public ResourceBundleTest() {
+        makePropertiesFile();
+    }
+
+    public void TestResourceBundle() {
+        Locale  saveDefault = Locale.getDefault();
+        Locale.setDefault(new Locale("fr", "FR"));
+
+        // load up the resource bundle, and make sure we got the right one
+        ResourceBundle  bundle = ResourceBundle.getBundle("TestResource");
+        if (!bundle.getClass().getName().equals("TestResource_fr"))
+            errln("Expected TestResource_fr, got " + bundle.getClass().getName());
+
+        // these resources are defines in ResourceBundle_fr
+        String  test1 = bundle.getString("Time");
+        if (!test1.equals("Time keeps on slipping..."))
+            errln("TestResource_fr returned wrong value for \"Time\":  got " + test1);
+
+        test1 = bundle.getString("For");
+        if (!test1.equals("Four score and seven years ago..."))
+            errln("TestResource_fr returned wrong value for \"For\":  got " + test1);
+
+        String[] test2 = bundle.getStringArray("All");
+        if (test2.length != 4)
+            errln("TestResource_fr returned wrong number of elements for \"All\": got " + test2.length);
+        else if (!test2[0].equals("'Twas brillig, and the slithy toves") ||
+                 !test2[1].equals("Did gyre and gimble in the wabe.") ||
+                 !test2[2].equals("All mimsy were the borogoves,") ||
+                 !test2[3].equals("And the mome raths outgrabe."))
+            errln("TestResource_fr returned the wrong value for one of the elements in \"All\"");
+
+        Object  test3 = bundle.getObject("Good");
+        if (test3 == null || test3.getClass() != Integer.class)
+            errln("TestResource_fr returned an object of the wrong class for \"Good\"");
+        else if (((Integer)test3).intValue() != 3)
+            errln("TestResource_fr returned the wrong value for \"Good\": got " + test3);
+
+        // This resource is defined in TestResource and inherited by TestResource_fr
+        test2 = bundle.getStringArray("Men");
+        if (test2.length != 3)
+            errln("TestResource_fr returned wrong number of elements for \"Men\": got " + test2.length);
+        else if (!test2[0].equals("1") ||
+                 !test2[1].equals("2") ||
+                 !test2[2].equals("C"))
+            errln("TestResource_fr returned the wrong value for one of the elements in \"All\"");
+
+        // This resource is defined in neither TestResource not TestResource_fr
+        try {
+            test3 = bundle.getObject("Is");
+            errln("TestResource_fr returned a value for \"Is\" when it shouldn't: got " + test3);
+        }
+        catch (MissingResourceException e) {
+        }
+
+        String[] keys = { "Now", "Time", "For", "All", "Good", "Men", "Come" };
+        checkKeys(bundle.getKeys(),  keys);
+
+        Locale.setDefault(saveDefault);
+    }
+
+    public void TestListResourceBundle() {
+        // load up the resource and check to make sure we got the right class
+        // (we don't define be_BY or be, so we fall back on the root default)
+        ResourceBundle  bundle = ResourceBundle.getBundle("TestResource",
+                            new Locale("be", "BY"));
+        if (!bundle.getClass().getName().equals("TestResource"))
+            errln("Expected TestResource, got " + bundle.getClass().getName());
+
+        doListResourceBundleTest(bundle);
+    }
+
+    /**
+     * @bug 4073127
+     * Repeat TestListResourceBundle on TestResource_it, which is a ListResourceBundle
+     * with NO contents.  It should gracefully inherit everything from the root
+     * TestResource.
+     */
+    public void TestEmptyListResourceBundle() {
+        ResourceBundle bundle = ResourceBundle.getBundle("TestResource",
+                            new Locale("it", "IT"));
+        doListResourceBundleTest(bundle);
+    }
+
+    private void doListResourceBundleTest(ResourceBundle bundle) {
+        // load up the resource and check to make sure we got the right class
+        // all of these resources are defined in TestResource; it doesn' inherit from anybody
+        String  test1 = bundle.getString("Now");
+        if (!test1.equals("Now is the time for all..."))
+            errln("TestResource returned wrong value for \"Now\":  got " + test1);
+
+        test1 = bundle.getString("Time");
+        if (!test1.equals("Howdy Doody Time!"))
+            errln("TestResource returned wrong value for \"Time\":  got " + test1);
+
+        test1 = bundle.getString("Come");
+        if (!test1.equals("Come into my parlor..."))
+            errln("TestResource returned wrong value for \"Come\":  got " + test1);
+
+        Object  test3 = bundle.getObject("Good");
+        if (test3 == null || test3.getClass() != Integer.class)
+            errln("TestResource returned an object of the wrong class for \"Good\"");
+        else if (((Integer)test3).intValue() != 27)
+            errln("TestResource returned the wrong value for \"Good\": got " + test3);
+
+        String[] test2 = bundle.getStringArray("Men");
+        if (test2.length != 3)
+            errln("TestResource returned wrong number of elements for \"Men\": got " + test2.length);
+        else if (!test2[0].equals("1") ||
+                 !test2[1].equals("2") ||
+                 !test2[2].equals("C"))
+            errln("TestResource returned the wrong value for one of the elements in \"All\"");
+
+        // this item isn't defined in TestResource
+        try {
+            test3 = bundle.getObject("All");
+            errln("TestResource_en returned a value for \"All\" when it shouldn't: got " + test3);
+        }
+        catch (MissingResourceException e) {
+        }
+
+        String[] keys = { "Now", "Time", "Good", "Men", "Come" };
+        checkKeys(bundle.getKeys(), keys);
+    }
+
+    /**
+     * @bug 4049325
+     * @ summary Bug 4049325 says ResourceBundle.findBundle() uses a hard-coded '/' as
+     * the directory separator when searching for properties files.  Interestingly, it
+     * still works on my NT installation.  I can't tell whether this is a required
+     * property of all Java implementations (the magic appears to happen ClassLoader.
+     * getResourceAsStream(), which is a native function) or a lucky property of my
+     * particular implementation.  If this bug regresses, this test may still pass
+     * because a lower-level facility translates the / to the platform-specific separator
+     * for us.
+     */
+    public void TestPropertyResourceBundle() {
+        ResourceBundle  bundle = ResourceBundle.getBundle("TestResource",
+                            new Locale("es", "ES"));
+
+        // these resources are defined in TestResource_es.properties
+        String  test = bundle.getString("Now");
+        if (!test.equals("How now brown cow"))
+            errln("TestResource_es returned wrong value for \"Now\":  got " + test);
+
+        test = bundle.getString("Is");
+        if (!test.equals("Is there a dog?"))
+            errln("TestResource_es returned wrong value for \"Is\":  got " + test);
+
+        test = bundle.getString("The");
+        if (!test.equals("The rain in Spain"))
+            errln("TestResource_es returned wrong value for \"The\":  got " + test);
+
+        test = bundle.getString("Time");
+        if (!test.equals("Time marches on..."))
+            errln("TestResource_es returned wrong value for \"Time\":  got " + test);
+
+        // this resource is defined in TestResource and inherited by TestResource_es
+        String[] test2 = bundle.getStringArray("Men");
+        if (test2.length != 3)
+            errln("TestResource returned wrong number of elements for \"Men\": got " + test2.length);
+        else if (!test2[0].equals("1") ||
+                 !test2[1].equals("2") ||
+                 !test2[2].equals("C"))
+            errln("TestResource returned the wrong value for one of the elements in \"All\"");
+
+        // this resource is defined in neither TestResource nor TestResource_es
+        try {
+            test = bundle.getString("All");
+            errln("TestResource_es returned a value for \"All\" when it shouldn't: got " + test);
+        }
+        catch (MissingResourceException e) {
+        }
+
+        String[] keys = { "Now", "Is", "The", "Time", "Good", "Men", "Come" };
+        checkKeys(bundle.getKeys(), keys);
+    }
+
+    /**
+     * @bug 4108126
+     */
+    public void TestGetLocale() {
+        // try to find TestResource_fr_CH.  Should get fr_CH as its locale
+        ResourceBundle test = ResourceBundle.getBundle("TestResource",
+                        new Locale("fr", "CH", ""));
+        Locale locale = test.getLocale();
+        if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("CH")))
+            errln("Actual locale for TestResource_fr_CH should have been fr_CH, got " + locale);
+
+        // try to find TestResource_fr_BE, which doesn't exist.  Should get fr as its locale
+        test = ResourceBundle.getBundle("TestResource",
+                        new Locale("fr", "BE", ""));
+        locale = test.getLocale();
+        if (!(locale.getLanguage().equals("fr")) || !(locale.getCountry().equals("")))
+            errln("Actual locale for TestResource_fr_BE should have been fr, got " + locale);
+
+        // try to find TestResource_iw_IL, which doesn't exist.  Should get root locale
+        // as its locale
+        test = ResourceBundle.getBundle("TestResource",
+                        new Locale("iw", "IL", ""));
+        locale = test.getLocale();
+        if (!(locale.getLanguage().equals("")) || !(locale.getCountry().equals("")))
+            errln("Actual locale for TestResource_iw_IL should have been the root locale, got "
+                            + locale);
+    }
+
+    /*
+     * @bug 4083270
+     */
+    public void TestNonSubclass() {
+        // ResourceBundle.getBundle should never return an object that isn't an instance
+        // of ResourceBundle or one of its subclasses.  We have a class called FakeTestResource
+        // in this package that isn't a ResourceBundle.  If we get that back, we barf.
+        // (Actually, at the time I fixed this bug, getResource() would throw a
+        // ClassCastException in that case.)
+        // There's also a properties file called FakeTestResource; we should get back a
+        // PropertyResourceBundle pointing to that file.
+        Object test1 = ResourceBundle.getBundle("FakeTestResource",
+                Locale.US);
+
+        if (!(test1 instanceof ResourceBundle))
+            errln("Got back a " + test1.getClass().getName() + " instead of a PropertyResourceBundle when looking for FakeTestResource.");
+
+        ResourceBundle test = (ResourceBundle)test1;
+
+        // there's also a properties file called FakeTestResource.  getBundle() should
+        // find it, and it should have the following contents
+        String message = test.getString("message");
+        if (!message.equals("Hello!"))
+            errln("Supposedly found FakeTestResource.properties, but it had the wrong contents.");
+    }
+
+    /*
+     * @bug 4106034
+     */
+    public void TestErrorMessage() {
+        // Ensure that the message produced by the exception thrown
+        // by ResourceBundle.getObject contains both the class name and
+        // the key name.
+        final String className = "TestResource";
+        final String keyName = "DontGetThis";
+        ResourceBundle bundle = ResourceBundle.getBundle(className,
+                            new Locale("it", "IT"));
+        try {
+            Object o = bundle.getObject(keyName);
+            errln(bundle.getClass().getName()+" returned a value for tag \""+keyName+"\" when it should have thrown an exception.  It returned "+o);
+        } catch (MissingResourceException e) {
+            String message = e.getMessage();
+            boolean found = false;
+            if (message.indexOf(className) < 0) {
+                    errln("MissingResourceException error message did not contain class name.");
+            }
+            if (message.indexOf(keyName) < 0) {
+                    errln("MissingResourceException error message did not contain resource key name.");
+            }
+        }
+    }
+
+
+    private void makePropertiesFile() {
+        try {
+            //
+            // The getProperty call is to ensure that this test will work with
+            // the JTREG test harness.  When running in the harness, the current
+            // directory is often set to someplace that isn't on the CLASSPATH,
+            // so we can't just create the properties files in the current
+            // directory.  But the harness uses the "test.classes" property to
+            // tell us where the classes directory is.
+            //
+            String classesDir = System.getProperty("test.classes", ".");
+            File    file = new File(classesDir, "TestResource_es.properties");
+            if (!file.exists()) {
+                FileOutputStream stream = new FileOutputStream(file);
+                Properties  props = new Properties();
+
+                props.put("Now", "How now brown cow");
+                props.put("Is", "Is there a dog?");
+                props.put("The", "The rain in Spain");
+                props.put("Time", "Time marches on...");
+
+                props.save(stream, "Test property list");
+
+                stream.close();
+            }
+
+            file = new File(classesDir, "FakeTestResource.properties");
+            if (!file.exists()) {
+                FileOutputStream stream = new FileOutputStream(file);
+                Properties props = new Properties();
+
+                props.put("message", "Hello!");
+
+                props.save(stream, "Test property list");
+
+                stream.close();
+            }
+        }
+        catch (java.io.IOException e) {
+            errln("Got exception: " + e);
+        }
+    }
+
+    private void checkKeys(Enumeration testKeys, String[] expectedKeys) {
+        Hashtable   hash = new Hashtable();
+        String      element;
+        int         elementCount = 0;
+
+        for (int i=0; i < expectedKeys.length; i++)
+            hash.put(expectedKeys[i], expectedKeys[i]);
+
+        while (testKeys.hasMoreElements()) {
+            element = (String)testKeys.nextElement();
+            elementCount++;
+            if (!hash.containsKey(element))
+                errln(element + " missing from key list.");
+        }
+
+        if (elementCount != expectedKeys.length)
+            errln("Wrong number of elements in key list: expected " + expectedKeys.length +
+                " got " + elementCount);
+    }
+}
diff --git a/test/java/util/ResourceBundle/RestrictedBundleTest.html b/test/java/util/ResourceBundle/RestrictedBundleTest.html
new file mode 100644
index 0000000..4214467
--- /dev/null
+++ b/test/java/util/ResourceBundle/RestrictedBundleTest.html
@@ -0,0 +1,3 @@
+<!---->
+This is a test.
+<applet code=RestrictedBundleTest.class width=400 height=400></applet>
diff --git a/test/java/util/ResourceBundle/RestrictedBundleTest.java b/test/java/util/ResourceBundle/RestrictedBundleTest.java
new file mode 100644
index 0000000..dc8244f
--- /dev/null
+++ b/test/java/util/ResourceBundle/RestrictedBundleTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/**
+ * @test
+ * @bug 4126805
+ * @run applet RestrictedBundleTest.html
+ * @summary I was able to reproduce this bug with 1.2b2, but not with the current 1.2
+ * build.  It appears that it was fixed by changes to the class-loading mechanism,
+ * which now throws a ClassNotFoundException where before it was propagating through
+ * a bogus ClassFormatError.  Therefore, this is just an additional regression test
+ * for whatever bug that was.
+ */
+
+import java.util.ResourceBundle;
+import java.applet.Applet;
+import java.util.MissingResourceException;
+
+public class RestrictedBundleTest extends Applet {
+    public void init() {
+        super.init();
+        try {
+            ResourceBundle bundle = ResourceBundle.getBundle("unavailable.base.name");
+
+            throw new RuntimeException("Error: MissingResourceException is not thrown");
+        }
+        catch (MissingResourceException e) {
+            // other types of error will propagate back out into the test harness
+            System.out.println("OK");
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Test4300693.java b/test/java/util/ResourceBundle/Test4300693.java
new file mode 100644
index 0000000..886a7bf
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4300693.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    @test
+    @summary test that ResourceBundle.getBundle can be called recursively
+    @build  Test4300693RB
+    @run main Test4300693
+    @bug 4300693
+*/
+
+/*
+ *
+ */
+
+import java.util.ResourceBundle;
+
+public class Test4300693 {
+
+   static private ResourceBundle rb = ResourceBundle.getBundle("Test4300693RB");
+
+   static public void main(String[] args) {
+       System.out.println(rb.getString("test result"));
+   }
+
+}
diff --git a/test/java/util/ResourceBundle/Test4300693RB.java b/test/java/util/ResourceBundle/Test4300693RB.java
new file mode 100644
index 0000000..2943dd0
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4300693RB.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ */
+
+import java.util.ResourceBundle;
+import java.util.ListResourceBundle;
+
+public class Test4300693RB extends ListResourceBundle {
+
+    public static ResourceBundle rb = ResourceBundle.getBundle("Test4300693RB");
+
+    public Object[][] getContents() {
+        return contents;
+    }
+
+    static final Object[][] contents = {
+        {"test result", "Test4300693 succeeded"}
+    };
+
+}
diff --git a/test/java/util/ResourceBundle/Test4314141.java b/test/java/util/ResourceBundle/Test4314141.java
new file mode 100644
index 0000000..890dfc8
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    @test
+    @summary Verify a few assertions of the new specification of ResourceBundle.getBundle
+    @build Test4314141B Test4314141B_fr_CH Test4314141B_es_ES
+    @run main Test4314141
+    @bug 4314141
+*/
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+import java.util.MissingResourceException;
+
+public class Test4314141 {
+
+    public static void main(String[] args) {
+        testCandidateOmission();
+        testExample();
+    }
+
+    /**
+     * Tests that candidate bundle names where the final component is an empty string are omitted.
+     * Previous versions of ResourceBundle might attempt to load bundles with a trailing
+     * underscore (e.g., "Test4314141_") resulting from concatenation with an empty string.
+     * This is no longer permitted.
+     */
+    static void testCandidateOmission() {
+        Locale.setDefault(Locale.US);
+        doTestCandidateOmission("de", "DE", "EURO", new String[] {"_de", ""});
+        doTestCandidateOmission("de", "DE", "", new String[] {"_de", ""});
+        doTestCandidateOmission("de", "", "EURO", new String[] {"_de", ""});
+        doTestCandidateOmission("de", "", "", new String[] {"_de", ""});
+        doTestCandidateOmission("", "DE", "EURO", new String[] {"__DE", ""});
+        doTestCandidateOmission("", "DE", "", new String[] {"__DE", ""});
+        doTestCandidateOmission("", "", "EURO", new String[] {"___EURO", ""});
+        doTestCandidateOmission("", "", "", new String[] {""});
+    }
+
+    static void doTestCandidateOmission(String language, String country, String variant,
+            String[] expectedSuffixes) {
+        doTest("Test4314141A", language, country, variant, expectedSuffixes);
+    }
+
+    /**
+     * Verifies the example from the getBundle specification.
+     */
+    static void testExample() {
+        Locale.setDefault(new Locale("en", "UK"));
+        doTestExample("fr", "CH", new String[] {"_fr_CH.class", "_fr.properties", ".class"});
+        doTestExample("fr", "FR", new String[] {"_fr.properties", ".class"});
+        doTestExample("de", "DE", new String[] {"_en.properties", ".class"});
+        doTestExample("en", "US", new String[] {"_en.properties", ".class"});
+        doTestExample("es", "ES", new String[] {"_es_ES.class", ".class"});
+    }
+
+    static void doTestExample(String language, String country, String[] expectedSuffixes) {
+        doTest("Test4314141B", language, country, "", expectedSuffixes);
+    }
+
+    static void doTest(String baseName, String language, String country, String variant,
+            String[] expectedSuffixes) {
+        System.out.print("Looking for " + baseName + " \"" + language + "\", \"" + country + "\", \"" + variant + "\"");
+        ResourceBundle bundle = ResourceBundle.getBundle(baseName, new Locale(language, country, variant));
+        System.out.print(" => got ");
+        String previousName = null;
+        int nameCount = 0;
+        for (int i = 3; i >= 0; i--) {
+            String name = bundle.getString("name" + i);
+            if (!name.equals(previousName)) {
+                if (previousName != null) {
+                    System.out.print(", ");
+                }
+                System.out.print(name);
+                if (!name.equals(baseName + expectedSuffixes[nameCount++])) {
+                    System.out.println();
+                    throw new RuntimeException("Error: got unexpected resource bundle");
+                }
+                previousName = name;
+            }
+        }
+        System.out.println();
+        if (nameCount != expectedSuffixes.length) {
+            throw new RuntimeException("Error: parent chain too short");
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Test4314141A.properties b/test/java/util/ResourceBundle/Test4314141A.properties
new file mode 100644
index 0000000..cf2b04f
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141A.properties
@@ -0,0 +1,26 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name0=Test4314141A
+name1=Test4314141A
+name2=Test4314141A
+name3=Test4314141A
diff --git a/test/java/util/ResourceBundle/Test4314141A_.properties b/test/java/util/ResourceBundle/Test4314141A_.properties
new file mode 100644
index 0000000..8a23a89
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141A_.properties
@@ -0,0 +1,25 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name1=Test4314141A_
+name2=Test4314141A_
+name3=Test4314141A_
diff --git a/test/java/util/ResourceBundle/Test4314141A__DE.properties b/test/java/util/ResourceBundle/Test4314141A__DE.properties
new file mode 100644
index 0000000..36bbf53
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141A__DE.properties
@@ -0,0 +1,24 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name2=Test4314141A__DE
+name3=Test4314141A__DE
diff --git a/test/java/util/ResourceBundle/Test4314141A___EURO.properties b/test/java/util/ResourceBundle/Test4314141A___EURO.properties
new file mode 100644
index 0000000..203cdb3
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141A___EURO.properties
@@ -0,0 +1,23 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name3=Test4314141A___EURO
diff --git a/test/java/util/ResourceBundle/Test4314141A_de.properties b/test/java/util/ResourceBundle/Test4314141A_de.properties
new file mode 100644
index 0000000..75c315f
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141A_de.properties
@@ -0,0 +1,25 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name1=Test4314141A_de
+name2=Test4314141A_de
+name3=Test4314141A_de
diff --git a/test/java/util/ResourceBundle/Test4314141A_de_.properties b/test/java/util/ResourceBundle/Test4314141A_de_.properties
new file mode 100644
index 0000000..6319928
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141A_de_.properties
@@ -0,0 +1,24 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name2=Test4314141A_de_
+name3=Test4314141A_de_
diff --git a/test/java/util/ResourceBundle/Test4314141B.java b/test/java/util/ResourceBundle/Test4314141B.java
new file mode 100644
index 0000000..1b3c69c
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141B.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+import java.util.ListResourceBundle;
+
+public class Test4314141B extends ListResourceBundle {
+    protected Object[][] getContents() {
+        return new Object[][] {
+            {"name0", "Test4314141B.class"},
+            {"name1", "Test4314141B.class"},
+            {"name2", "Test4314141B.class"},
+            {"name3", "Test4314141B.class"}
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Test4314141B_en.properties b/test/java/util/ResourceBundle/Test4314141B_en.properties
new file mode 100644
index 0000000..fc09361
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141B_en.properties
@@ -0,0 +1,25 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name1=Test4314141B_en.properties
+name2=Test4314141B_en.properties
+name3=Test4314141B_en.properties
diff --git a/test/java/util/ResourceBundle/Test4314141B_es_ES.java b/test/java/util/ResourceBundle/Test4314141B_es_ES.java
new file mode 100644
index 0000000..105d393
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141B_es_ES.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+import java.util.ListResourceBundle;
+
+public class Test4314141B_es_ES extends ListResourceBundle {
+    protected Object[][] getContents() {
+        return new Object[][] {
+            {"name2", "Test4314141B_es_ES.class"},
+            {"name3", "Test4314141B_es_ES.class"}
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Test4314141B_fr.properties b/test/java/util/ResourceBundle/Test4314141B_fr.properties
new file mode 100644
index 0000000..9df5dd3
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141B_fr.properties
@@ -0,0 +1,25 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name1=Test4314141B_fr.properties
+name2=Test4314141B_fr.properties
+name3=Test4314141B_fr.properties
diff --git a/test/java/util/ResourceBundle/Test4314141B_fr_CH.java b/test/java/util/ResourceBundle/Test4314141B_fr_CH.java
new file mode 100644
index 0000000..3af0061
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141B_fr_CH.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+import java.util.ListResourceBundle;
+
+public class Test4314141B_fr_CH extends ListResourceBundle {
+    protected Object[][] getContents() {
+        return new Object[][] {
+            {"name2", "Test4314141B_fr_CH.class"},
+            {"name3", "Test4314141B_fr_CH.class"}
+        };
+    }
+}
diff --git a/test/java/util/ResourceBundle/Test4314141B_fr_CH.properties b/test/java/util/ResourceBundle/Test4314141B_fr_CH.properties
new file mode 100644
index 0000000..7fddbe1
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4314141B_fr_CH.properties
@@ -0,0 +1,24 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name2=Test4314141B_fr_CH.properties
+name3=Test4314141B_fr_CH.properties
diff --git a/test/java/util/ResourceBundle/Test4318520.java b/test/java/util/ResourceBundle/Test4318520.java
new file mode 100644
index 0000000..b89d023
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4318520.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    @test
+    @summary test that getBundle handles change in default locale correctly
+    @bug 4318520
+*/
+
+/*
+ *
+ */
+
+import java.util.ResourceBundle;
+import java.util.Locale;
+
+public class Test4318520 {
+
+    public static void main(String[] args) {
+        test(Locale.GERMAN);
+        test(Locale.ENGLISH);
+    }
+
+    private static void test(Locale locale) {
+        Locale.setDefault(locale);
+        ResourceBundle myResources =
+                ResourceBundle.getBundle("Test4318520RB", Locale.FRENCH);
+        String actualLocale = myResources.getString("name");
+        if (!actualLocale.equals(locale.toString())) {
+            System.out.println("expected: " + locale + ", got: " + actualLocale);
+            throw new RuntimeException();
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/Test4318520RB_de.properties b/test/java/util/ResourceBundle/Test4318520RB_de.properties
new file mode 100644
index 0000000..05b5161
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4318520RB_de.properties
@@ -0,0 +1,23 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name=de
diff --git a/test/java/util/ResourceBundle/Test4318520RB_en.properties b/test/java/util/ResourceBundle/Test4318520RB_en.properties
new file mode 100644
index 0000000..620f814
--- /dev/null
+++ b/test/java/util/ResourceBundle/Test4318520RB_en.properties
@@ -0,0 +1,23 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+name=en
diff --git a/test/java/util/ResourceBundle/TestBug4179766.java b/test/java/util/ResourceBundle/TestBug4179766.java
new file mode 100644
index 0000000..9c7b1ed
--- /dev/null
+++ b/test/java/util/ResourceBundle/TestBug4179766.java
@@ -0,0 +1,311 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+    @test  1.3 99/02/15
+    @summary test Resource Bundle for bug 4179766
+    @build Bug4179766Class Bug4179766Resource Bug4179766Getter
+    @run main TestBug4179766
+    @bug 4179766
+*/
+/*
+ *
+ *
+ * (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+import java.util.Hashtable;
+import java.util.ResourceBundle;
+import java.util.MissingResourceException;
+import java.util.Hashtable;
+import java.io.File;
+import java.io.FileInputStream;
+
+/**
+ * This class tests the behavior of the ResourceBundle cache with
+ * respect to ClassLoaders.  The same resource loaded by different
+ * loaders should be cached as separate objects, one for each loader.
+ * In order to test this behavior, this test constructs a custom
+ * class loader to load its resources.  It does not delegate resource
+ * loading to the system loader to load the class files, but loads
+ * them from the current directory instead.  This is so that the
+ * defining class loader for the resources is different.  If it
+ * delegated to the system loader to load the resources, the
+ * defining ClassLoader would be the same even though the initiating
+ * loader differered, and the resource would only be cached once.
+ */
+public class TestBug4179766 extends RBTestFmwk {
+    //hash code used by class loaders when sameHash is true
+    private static final int SAME_HASH_CODE = 0;
+    //the next unique hash code
+    private static int nextHashCode = SAME_HASH_CODE + 1;
+    //suffix on class files
+    private static final String CLASS_SUFFIX = ".class";
+
+    //generate a unique hashcode for a class loader
+    private static synchronized int getNextHashCode() {
+        return nextHashCode++;
+    }
+
+    public static void main(String[] args) throws Exception {
+        //static links so all needed classes get compiled
+        Object o1 = new Bug4179766Class();
+        Object o2 = new Bug4179766Resource();
+        new TestBug4179766().run(args);
+    }
+
+    /**
+    * Ensure the resource cache is working correctly for a single
+    * resource from a single loader.  If we get the same resource
+    * from the same loader twice, we should get the same resource.
+    */
+    public void testCache() throws Exception {
+        Loader loader = new Loader(false);
+        ResourceBundle b1 = getResourceBundle(loader, "Bug4179766Resource");
+        if (b1 == null) {
+            errln("Resource not found: Bug4179766Resource");
+        }
+        ResourceBundle b2 = getResourceBundle(loader, "Bug4179766Resource");
+        if (b2 == null) {
+            errln("Resource not found: Bug4179766Resource");
+        }
+        printIDInfo("[bundle1]",b1);
+        printIDInfo("[bundle2]",b2);
+        if (b1 != b2) {
+            errln("Different objects returned by same ClassLoader");
+        }
+    }
+
+    /**
+    * Test that loaders with the same hash key still
+    * cache resources seperately
+    */
+    public void testSameHash() throws Exception {
+        doTest(true);
+    }
+
+    /**
+    * Test that loaders with different hash keys
+    * cache resources seperately
+    */
+    public void testDifferentHash() throws Exception {
+        doTest(false);
+    }
+
+    /**
+     * Ensure that cached resources for different ClassLoaders
+     * are cached seperately
+     */
+    private void doTest(boolean sameHash) throws Exception {
+        ResourceBundle b1 = getResourceBundle(new Loader(sameHash), "Bug4179766Resource");
+        if (b1 == null) {
+           errln("Resource not found: Bug4179766Resource");
+        }
+        ResourceBundle b2 = getResourceBundle(new Loader(sameHash), "Bug4179766Resource");
+        if (b2 == null) {
+           errln("Resource not found: Bug4179766Resource");
+        }
+        printIDInfo("[bundle1]",b1);
+        printIDInfo("[bundle2]",b2);
+        if (b1 == b2) {
+           errln("Same object returned by different ClassLoaders");
+        }
+    }
+
+    /**
+     * Get a resource using a specified class loader to load the resource
+     */
+    private ResourceBundle getResourceBundle(Loader loader, String name) throws Exception {
+        try {
+            Class c = loader.loadClass("Bug4179766Class");
+            Bug4179766Getter test = (Bug4179766Getter)c.newInstance();
+            return test.getResourceBundle(name);
+        } catch (ClassNotFoundException e) {
+            errln("Class not found by custom class loader: "+name);
+            throw e;
+        } catch (InstantiationException e) {
+            errln("Error instantiating: "+name);
+            throw e;
+        } catch (IllegalAccessException e) {
+            errln("IllegalAccessException instantiating: "+name);
+            throw e;
+        }
+    }
+
+    /**
+     * Print information about an object
+     * [message][object's identity][object's class][object's loader][loaders hash][loaders identity]
+     */
+    private void printIDInfo(String message, Object o) {
+        if (o == null) {
+            return;
+        }
+        Class c = o.getClass();
+        ClassLoader l = c.getClassLoader();
+        int hash = -1;
+        if (l != null) {
+            hash = l.hashCode();
+        }
+        logln(message + System.identityHashCode(o) + "  Class: " + c
+                + "  ClassLoader: " + l + "  loaderHash: " + hash
+                + "  loaderPrimHash: " + System.identityHashCode(l));
+    }
+
+    /**
+     * A simple class loader that loads classes from the current
+     * working directory.  The hash code of the loader can be
+     * set to be either the loaders identity or 0, allowing several
+     * loaders to have the same hashCode value.
+     */
+    public class Loader extends ClassLoader {
+        private int thisHashCode;
+
+        /**
+         * Create a new loader
+         */
+        public Loader(boolean sameHash) {
+            if (sameHash) {
+                thisHashCode = SAME_HASH_CODE;
+            } else {
+                thisHashCode = getNextHashCode();
+            }
+        }
+
+        /**
+         * Return the hash code for this loader.
+         */
+        public int hashCode() {
+            return thisHashCode;
+        }
+
+        /**
+         * Get the data from the class file for the specified class.  If
+         * the file can't be found, or the class is not one of the
+         * special ones listed below, return null.
+         *    Bug4179766Class
+         *    Bug4179766Resource
+         */
+        private byte[] getClassData(String className) {
+            boolean shouldLoad = className.equals("Bug4179766Class");
+            shouldLoad = shouldLoad || className.equals("Bug4179766Resource");
+
+            if (shouldLoad) {
+                try {
+                    File file = new File(System.getProperty("test.classes", "."), className+CLASS_SUFFIX);
+                    FileInputStream fi = new FileInputStream(file);
+                    byte[] result = new byte[fi.available()];
+                    fi.read(result);
+                    return result;
+                } catch (Exception e) {
+                    return null;
+                }
+            } else {
+                return null;
+            }
+        }
+
+        /**
+         * Load a class.  Files we can load take preference over ones the system
+         * can load.
+         */
+        public synchronized Class loadClass(String className, boolean resolveIt)
+                throws ClassNotFoundException {
+
+            Class result = findLoadedClass(className);
+            if (result != null) {
+                printInfo("        ***Returning cached class: "+className, result);
+                return result;
+            }
+
+            byte[] classData = getClassData(className);
+            if (classData == null) {
+                //we don't have a local copy of this one
+                return loadFromSystem(className);
+            }
+
+            result = defineClass(classData, 0, classData.length);
+            if (result == null) {
+                //there was an error defining the class
+                return loadFromSystem(className);
+            }
+
+            if (resolveIt) {
+                resolveClass(result);
+            }
+
+            printInfo("        ***Loaded local class: "+className, result);
+            return result;
+        }
+
+        /**
+         * Delegate loading to the system loader
+         */
+        private Class loadFromSystem(String className) throws ClassNotFoundException {
+            try {
+                Class result = super.findSystemClass(className);
+                printInfo("        ***Returning system class: "+className, result);
+                return result;
+            } catch (ClassNotFoundException e) {
+                printInfo("        ***Class not found: "+className, null);
+                throw e;
+            }
+        }
+
+        /**
+         * Print information about a class that was loaded
+         * [loader identity][message][class identity]
+         */
+        private void printInfo(String message, Class c) {
+            if (c != null) {
+                logln(""+System.identityHashCode(this)+"  "+message+"  "+System.identityHashCode(c));
+            } else {
+                logln(""+System.identityHashCode(this)+"  "+message);
+            }
+        }
+    }
+}
diff --git a/test/java/util/ResourceBundle/TestResource.java b/test/java/util/ResourceBundle/TestResource.java
new file mode 100644
index 0000000..d9b69e5
--- /dev/null
+++ b/test/java/util/ResourceBundle/TestResource.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+// NOTE:  This class is part of the ResourceBundleTest.
+
+import java.util.*;
+
+public class TestResource extends ListResourceBundle {
+    public Object[][] getContents() {
+        return contents;
+    }
+
+    static final Object[][] contents = {
+        { "Now", "Now is the time for all..." },
+        { "Time", "Howdy Doody Time!" },
+        { "Good", new Integer(27) },
+        { "Men", new String[] { "1", "2", "C" } },
+        { "Come", "Come into my parlor..." }
+    };
+}
diff --git a/test/java/util/ResourceBundle/TestResource_de.java b/test/java/util/ResourceBundle/TestResource_de.java
new file mode 100644
index 0000000..b9754cf
--- /dev/null
+++ b/test/java/util/ResourceBundle/TestResource_de.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+// NOTE:  This class is part of the ResourceBundleTest.
+
+// NOTE:  As of 11/21/97, this class isn't actually being used by the ResourceBundleTest
+// anymore.  I've left it here simply because we don't currently have a way to obsolete
+// a file in RCS.  If you're running it, you've got a problem!
+
+import java.util.*;
+import java.io.*;
+
+public class TestResource_de extends PropertyResourceBundle {
+    public TestResource_de() throws IOException, FileNotFoundException {
+        super(new FileInputStream("TestResource_de"));
+    }
+}
diff --git a/test/java/util/ResourceBundle/TestResource_fr.java b/test/java/util/ResourceBundle/TestResource_fr.java
new file mode 100644
index 0000000..2bd7fee
--- /dev/null
+++ b/test/java/util/ResourceBundle/TestResource_fr.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+// NOTE:  This class is part of the ResourceBundleTest.
+
+import java.util.*;
+
+public class TestResource_fr extends ResourceBundle {
+    public TestResource_fr() {
+    }
+
+    public Object handleGetObject(String key) throws MissingResourceException {
+        if (key.equals("Time"))
+            return "Time keeps on slipping...";
+        else if (key.equals("For"))
+            return "Four score and seven years ago...";
+        else if (key.equals("All")) {
+            String[] values = {
+                "'Twas brillig, and the slithy toves",
+                "Did gyre and gimble in the wabe.",
+                "All mimsy were the borogoves,",
+                "And the mome raths outgrabe."
+            };
+            return values;
+        }
+        else if (key.equals("Good"))
+            return new Integer(3);
+        else
+            return null;
+    }
+
+    public Enumeration getKeys() {
+        Hashtable keys = new Hashtable();
+
+        keys.put("Time", "Time");
+        keys.put("For", "For");
+        keys.put("All", "All");
+        keys.put("Good", "Good");
+
+        Enumeration parentKeys = parent.getKeys();
+        while (parentKeys.hasMoreElements()) {
+            Object  elt = parentKeys.nextElement();
+            keys.put(elt, elt);
+        }
+
+        return keys.elements();
+    }
+}
diff --git a/test/java/util/ResourceBundle/TestResource_fr_CH.java b/test/java/util/ResourceBundle/TestResource_fr_CH.java
new file mode 100644
index 0000000..5cccbfe
--- /dev/null
+++ b/test/java/util/ResourceBundle/TestResource_fr_CH.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+// NOTE:  This class is part of the ResourceBundleTest.
+
+// This class is here so that we can call getLocale() on it and get back fr_CH.
+// It should gracefully inherit everything from TestResource_fr.
+
+import java.util.*;
+
+public class TestResource_fr_CH extends ListResourceBundle {
+    public Object[][] getContents() {
+        return contents;
+    }
+
+    static final Object[][] contents = {
+    };
+}
diff --git a/test/java/util/ResourceBundle/TestResource_it.java b/test/java/util/ResourceBundle/TestResource_it.java
new file mode 100644
index 0000000..da1268d
--- /dev/null
+++ b/test/java/util/ResourceBundle/TestResource_it.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ *
+ *
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * Portions copyright (c) 2007 Sun Microsystems, Inc.
+ * All Rights Reserved.
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for NON-COMMERCIAL purposes and without
+ * fee is hereby granted provided that this copyright notice
+ * appears in all copies. Please refer to the file "copyright.html"
+ * for further important copyright and licensing information.
+ *
+ * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
+ * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+ * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
+ *
+ */
+
+// NOTE:  This class is part of the ResourceBundleTest.
+
+// This class is designed to make sure we don't crash ResourceBundle if we create
+// a ListResourceBundle with nothing in it.  This should gracefully inherit everything
+// from its parent.
+
+import java.util.*;
+
+public class TestResource_it extends ListResourceBundle {
+    public Object[][] getContents() {
+        return contents;
+    }
+
+    static final Object[][] contents = {
+    };
+}
diff --git a/test/java/util/ResourceBundle/awtres.jar b/test/java/util/ResourceBundle/awtres.jar
new file mode 100644
index 0000000..4315634
--- /dev/null
+++ b/test/java/util/ResourceBundle/awtres.jar
Binary files differ
diff --git a/test/java/util/ResourceBundle/bug4195978Test.properties b/test/java/util/ResourceBundle/bug4195978Test.properties
new file mode 100644
index 0000000..8eb5f84
--- /dev/null
+++ b/test/java/util/ResourceBundle/bug4195978Test.properties
@@ -0,0 +1,28 @@
+# 
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+# 
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+# 
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+# 
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+# This file is part of Bug4195978Test.
+# 2/20/2000
+# joconner
+#
+test=test
+
diff --git a/test/java/util/ResourceBundle/bug6572242.properties b/test/java/util/ResourceBundle/bug6572242.properties
new file mode 100644
index 0000000..a26713c
--- /dev/null
+++ b/test/java/util/ResourceBundle/bug6572242.properties
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+data=type