harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r538967 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/ test/java/tests/api/java/util/ test/java/tests/api/java/util/support/ test/resources/tests/api/java/util/ test/resources/tests/api/java/util/support/
Date Thu, 17 May 2007 15:30:56 GMT
Author: ayza
Date: Thu May 17 08:30:55 2007
New Revision: 538967

URL: http://svn.apache.org/viewvc?view=rev&rev=538967
Log:
Applying slightly modified version of the patch from HARMONY-3823 ([classlib][luni] Wrong
implementation of strategy for instantiating resource bundles in java.util.ResourceBundle)

Added:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/A.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/B.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/I.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/P.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/tests/api/java/util/
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/tests/api/java/util/support/
    harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/tests/api/java/util/support/B.properties
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java?view=diff&rev=538967&r1=538966&r2=538967
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/ResourceBundle.java
Thu May 17 08:30:55 2007
@@ -267,13 +267,17 @@
 
         try {
             Class<?> bundleClass = Class.forName(bundleName, true, loader);
-            bundle = (ResourceBundle) bundleClass.newInstance();
-            bundle.setLocale(locale);
+
+            if (ResourceBundle.class.isAssignableFrom(bundleClass)) {
+                bundle = (ResourceBundle) bundleClass.newInstance();
+            }
         } catch (LinkageError e) {
         } catch (Exception e) {
         }
 
-        if (bundle == null) {
+        if (bundle != null) {
+            bundle.setLocale(locale);
+        } else {
             final String fileName = bundleName.replace('.', '/');
             InputStream stream = AccessController
                     .doPrivileged(new PrivilegedAction<InputStream>() {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java?view=diff&rev=538967&r1=538966&r2=538967
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/ResourceBundleTest.java
Thu May 17 08:30:55 2007
@@ -28,6 +28,7 @@
 import java.util.Vector;
 
 import tests.support.resource.Support_Resources;
+import tests.api.java.util.support.B;
 
 public class ResourceBundleTest extends junit.framework.TestCase {
 
@@ -126,6 +127,12 @@
 		bundle = ResourceBundle.getBundle(name, Locale.getDefault(), loader);
 		assertEquals("Wrong cached value", 
 				"resource", bundle.getString("property"));
+
+		// Regression test for Harmony-3823
+		B bb = new B();
+		String s = bb.find("nonexistent");
+		s = bb.find("name");
+		assertEquals("Wrong property got", "Name", s);
 	}
 
 	/**

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/A.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/A.java?view=auto&rev=538967
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/A.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/A.java
Thu May 17 08:30:55 2007
@@ -0,0 +1,13 @@
+package tests.api.java.util.support;
+
+public class A implements I {
+    private static P pp = new P();
+
+    public A() {
+        pp.setClazz(getClass());
+    }
+
+    public String find(String key) {
+        return pp.findProp(key);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/A.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/B.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/B.java?view=auto&rev=538967
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/B.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/B.java
Thu May 17 08:30:55 2007
@@ -0,0 +1,4 @@
+package tests.api.java.util.support;
+
+public class B extends A {
+}

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/B.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/I.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/I.java?view=auto&rev=538967
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/I.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/I.java
Thu May 17 08:30:55 2007
@@ -0,0 +1,5 @@
+package tests.api.java.util.support;
+
+public interface I {
+    String find(String key);
+}

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/I.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/P.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/P.java?view=auto&rev=538967
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/P.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/P.java
Thu May 17 08:30:55 2007
@@ -0,0 +1,28 @@
+package tests.api.java.util.support;
+
+import java.util.ResourceBundle;
+
+public class P {
+    private Class c;
+
+    public void setClazz(Class c) {
+        this.c = c;
+    }
+
+    public String findProp(String key) {
+        return findProp(this.c, key);
+    }
+
+    private String findProp(Class cls, String key) {
+        String ret = null;
+        try {
+            ResourceBundle b = ResourceBundle.getBundle(cls.getName());
+            ret = (String)b.getObject(key);
+        } catch (Exception e) {
+        }
+        if (ret == null && !cls.equals(Object.class) && !cls.isPrimitive())
{
+            ret = findProp(cls.getSuperclass(), key);
+        }
+        return ret;
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/support/P.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/tests/api/java/util/support/B.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/tests/api/java/util/support/B.properties?view=auto&rev=538967
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/tests/api/java/util/support/B.properties
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/tests/api/java/util/support/B.properties
Thu May 17 08:30:55 2007
@@ -0,0 +1 @@
+name=Name
\ No newline at end of file

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/resources/tests/api/java/util/support/B.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message