harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r394857 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/Beans.java test/java/org/apache/harmony/tests/java/beans/BeansTest.java
Date Tue, 18 Apr 2006 06:27:36 GMT
Author: mloenko
Date: Mon Apr 17 23:27:33 2006
New Revision: 394857

URL: http://svn.apache.org/viewcvs?rev=394857&view=rev
Log:
fix for HARMONY-358:
java.beans.Beans.instantiate(ClassLoader cls, String name) throws ClassNotFoundException if
cls == null
and regression test

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java?rev=394857&r1=394856&r2=394857&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Beans.java
Mon Apr 17 23:27:33 2006
@@ -108,40 +108,41 @@
             }
         }
         
-        if(result == null) {
-            try {
-                Class c = Class.forName(beanName, true, cls);
-                
-                try {
-                    result = c.newInstance();
-                    
-                    if(result instanceof Applet) {
-                        Applet applet = (Applet) result;
-                        applet.init();
-                    }
-                } catch (IllegalAccessException iae) {
-                    throw new ClassNotFoundException(iae.getClass() + ": "
-                            + iae.getMessage());
-                }
-            } catch (InstantiationException ie) {
-                throw new ClassNotFoundException(ie.getClass() + ": "
-                        + ie.getMessage());
-            }
-        }
+        if (result == null) {
+			try {
+				Class c = Class.forName(beanName, true,
+						cls == null ? ClassLoader.getSystemClassLoader() : cls);
+
+				try {
+					result = c.newInstance();
+
+					if (result instanceof Applet) {
+						Applet applet = (Applet) result;
+						applet.init();
+					}
+				} catch (IllegalAccessException iae) {
+					throw new ClassNotFoundException(iae.getClass() + ": "
+							+ iae.getMessage());
+				}
+			} catch (InstantiationException ie) {
+				throw new ClassNotFoundException(ie.getClass() + ": "
+						+ ie.getMessage());
+			}
+		}
         
         return result;
     }
 
     /**
-     * @com.intel.drl.spec_ref
-     */
+	 * @com.intel.drl.spec_ref
+	 */
     public static Object getInstanceOf(Object bean, Class targetType) {
         return bean;            
     }
 
     /**
-     * @com.intel.drl.spec_ref
-     */
+	 * @com.intel.drl.spec_ref
+	 */
     public static boolean isInstanceOf(Object bean, Class targetType) {
         return bean.getClass().isAssignableFrom(targetType);            
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java?rev=394857&r1=394856&r2=394857&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/tests/java/beans/BeansTest.java
Mon Apr 17 23:27:33 2006
@@ -96,6 +96,16 @@
         }
     }
 
+    //regression test for HARMONY-358
+    public void testInstantiate() throws Exception {
+        try {
+            Class.forName(this.getClass().getName(), true, null);
+            fail("This test is designed to run from classpath rather then from bootclasspath");
+        } catch (ClassNotFoundException ok) {
+        }
+        assertNotNull(Beans.instantiate(null, this.getClass().getName()));
+    } 
+    
     /**
      * 
      */



Mime
View raw message