harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r495876 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/RenderingHints.java test/api/java/common/org/apache/harmony/awt/tests/java/awt/RenderingHintsTest.java
Date Sat, 13 Jan 2007 12:01:15 GMT
Author: hindessm
Date: Sat Jan 13 04:01:14 2007
New Revision: 495876

URL: http://svn.apache.org/viewvc?view=rev&rev=495876
Log:
Applied patch from "[#HARMONY-2517] [classlib][awt] Compatibility:
java.awt.RenderingHints(Map<RenderingHints.Key,?> init) constructor
throws NPE on Harmony while it works silently on RI".

Added:
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/RenderingHintsTest.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java?view=diff&rev=495876&r1=495875&r2=495876
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/RenderingHints.java
Sat Jan 13 04:01:14 2007
@@ -124,12 +124,14 @@
         } else {
             Set<?> entries = m.entrySet();
 
-            Iterator<?> it = entries.iterator();
-            while (it.hasNext()) {
-                Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
-                Key key = (Key) entry.getKey();
-                Object val = entry.getValue();
-                put(key, val);
+            if (entries != null){
+                Iterator<?> it = entries.iterator();
+                while (it.hasNext()) {
+                    Map.Entry<?, ?> entry = (Map.Entry<?, ?>) it.next();
+                    Key key = (Key) entry.getKey();
+                    Object val = entry.getValue();
+                    put(key, val);
+                }
             }
         }
     }

Added: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/RenderingHintsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/RenderingHintsTest.java?view=auto&rev=495876
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/RenderingHintsTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/RenderingHintsTest.java
Sat Jan 13 04:01:14 2007
@@ -0,0 +1,95 @@
+/*
+ *  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.awt.tests.java.awt;
+
+import java.awt.RenderingHints;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+public class RenderingHintsTest extends TestCase {
+    
+    public void testConstructor_Null_Map() {
+        // Regression test HARMONY-2517
+        Map<RenderingHints.Key,?> localMap = new dummyMap(); 
+        RenderingHints rh = new RenderingHints(localMap); 
+        assertTrue(rh.isEmpty()); 
+    }
+    
+    private class dummyMap implements Map<RenderingHints.Key, Object> { 
+        public void clear() { 
+            return; 
+        } 
+
+        public boolean containsKey(Object p0) { 
+            return false; 
+        } 
+
+        public boolean containsValue(Object p0) { 
+            return false; 
+        } 
+
+        public Set<Map.Entry<RenderingHints.Key, Object>> entrySet() { 
+            return null; 
+        } 
+
+        public boolean equals(Object p0) { 
+            return false; 
+        } 
+
+        public Object get(Object p0) { 
+            return null; 
+        } 
+
+        public int hashCode() { 
+            return 0; 
+        } 
+
+        public boolean isEmpty() { 
+            return false; 
+        } 
+
+        public Set<RenderingHints.Key> keySet() { 
+            return null; 
+        } 
+
+        public Object put(RenderingHints.Key p0, Object p1) { 
+            return null; 
+        } 
+
+        public void putAll(Map p0) { 
+            return; 
+        } 
+
+        public Object remove(Object p0) { 
+            return null; 
+        } 
+
+        public int size() { 
+            return 0; 
+        } 
+
+        public Collection<Object> values() { 
+            return null; 
+        } 
+    }
+
+} 
+

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/org/apache/harmony/awt/tests/java/awt/RenderingHintsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message