harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From qi...@apache.org
Subject svn commit: r728612 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/ test/java/org/apache/harmony/beans/tests/java/beans/ test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/ test/support/java/org/apache...
Date Mon, 22 Dec 2008 05:05:28 GMT
Author: qiuxx
Date: Sun Dec 21 21:05:27 2008
New Revision: 728612

URL: http://svn.apache.org/viewvc?rev=728612&view=rev
Log:
Apply for HARMONY-4602,([classlib][beans] Introspector.getBeanInfo(Class) will get wrong BeanInfo
when there are same classes in different package)

Added:
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java?rev=728612&r1=728611&r2=728612&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Introspector.java
Sun Dec 21 21:05:27 2008
@@ -300,7 +300,14 @@
             beanInfoClassName = searchPath[i] + "." + beanInfoName; //$NON-NLS-1$
             try{
                 theBeanInfo = loadBeanInfo(beanInfoClassName, beanClass);
-                break;
+                
+                // find the beanInfo of the given beanClass, check whether the
+                // beanInfo is consistent with the given beanClass
+                Class<?> beanClassOfBeanInfo = theBeanInfo.getBeanDescriptor()
+                        .getBeanClass();
+                if (beanClassOfBeanInfo.equals(beanClass)) {
+                    break;
+                } 
             }catch(Exception e){
                 //ignore, try next one
             }

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java?rev=728612&r1=728611&r2=728612&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
Sun Dec 21 21:05:27 2008
@@ -1649,6 +1649,46 @@
         }
     }
 
+    /*
+     * @test setBeanInfoSearchPath
+     * 
+     * Change the sequence of the paths in Introspector.searchpaths, check
+     * whether the BeanInfo is consistent with the bean class
+     */
+    public void testSetBeanInfoSearchPath_SameClassesInDifferentPackage()
+            throws IntrospectionException {
+        // set the search path in the correct sequence
+        Introspector
+                .setBeanInfoSearchPath(new String[] {
+                        "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info",
+                        "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info",
});
+
+        BeanInfo beanInfo = Introspector
+                .getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
+        BeanDescriptor beanDesc = beanInfo.getBeanDescriptor();
+
+        assertEquals(beanDesc.getName(), "mocksubject1");
+        assertEquals(
+                beanDesc.getBeanClass(),
+                org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
+
+        // set the search path in the reverse sequence
+        Introspector
+                .setBeanInfoSearchPath(new String[] {
+                        "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info",
+                        "org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info",
});
+
+        beanInfo = Introspector
+                .getBeanInfo(org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
+        beanDesc = beanInfo.getBeanDescriptor();
+
+        assertEquals(beanDesc.getName(), "mocksubject1");
+        assertEquals(
+                beanDesc.getBeanClass(),
+                org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);
+
+    }
+
     static class MockSecurity2 extends SecurityManager {
 
         @Override

Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java?rev=728612&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
Sun Dec 21 21:05:27 2008
@@ -0,0 +1,33 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1;
+
+public class MockHomonymySubject implements java.io.Serializable {
+
+    private static final long serialVersionUID = -5670959173127764297L;
+
+    public MockHomonymySubject() {
+    }
+
+    public int getFoo() {
+        return -1;
+    }
+
+    public void setFoo(int foo) {
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/MockHomonymySubject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java?rev=728612&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
Sun Dec 21 21:05:27 2008
@@ -0,0 +1,36 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.info;
+
+import java.beans.BeanDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class MockHomonymySubjectBeanInfo extends SimpleBeanInfo {
+
+    private BeanDescriptor beanDesc = new BeanDescriptor(
+            org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject1.MockHomonymySubject.class);;
+
+    public MockHomonymySubjectBeanInfo() {
+        beanDesc.setName("mocksubject1");
+    }
+
+    public BeanDescriptor getBeanDescriptor() {
+        return beanDesc;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject1/info/MockHomonymySubjectBeanInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java?rev=728612&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
Sun Dec 21 21:05:27 2008
@@ -0,0 +1,33 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2;
+
+public class MockHomonymySubject implements java.io.Serializable {
+
+    private static final long serialVersionUID = -8789259604314388286L;
+
+    public MockHomonymySubject() {
+    }
+
+    public int getFoo() {
+        return -1;
+    }
+
+    public void setFoo(int foo) {
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/MockHomonymySubject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java?rev=728612&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
Sun Dec 21 21:05:27 2008
@@ -0,0 +1,36 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.info;
+
+import java.beans.BeanDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class MockHomonymySubjectBeanInfo extends SimpleBeanInfo {
+
+    private BeanDescriptor beanDesc = new BeanDescriptor(
+            org.apache.harmony.beans.tests.support.mock.homonymy.mocksubject2.MockHomonymySubject.class);;
+
+    public MockHomonymySubjectBeanInfo() {
+        beanDesc.setName("mocksubject2");
+    }
+
+    public BeanDescriptor getBeanDescriptor() {
+        return beanDesc;
+    }
+
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/homonymy/mocksubject2/info/MockHomonymySubjectBeanInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message