Hi,

Since, the use of strings and Attributes.Name is distributed over APIs, I have 
come up with a generic documentation. However any suggestions are welcome.

--- a/src/java.base/share/classes/java/util/jar/Attributes.java Thu Mar 26 
15:26:51 2020 +0000
+++ b/src/java.base/share/classes/java/util/jar/Attributes.java Tue Aug 04 
14:55:46 2020 +0530
@@ -49,7 +49,11 @@
  * Attribute values can contain any characters and
  * will be UTF8-encoded when written to the output stream.  See the
  * <a href="{@docRoot}/../specs/jar/jar.html">JAR File Specification</a>
- * for more information about valid attribute names and values.
+ * for more information about valid attribute names and values. While
+ * insertion, the attribute name (key) can be specified as a string or any
+ * objects of type Attribute.Name or its subclass. But during retrieval,
+ * attribute name (key) specified as a string is discouraged to avoid
+ * unpredictable results.
  *
  * <p>This map and its views have a predictable iteration order, namely the
  * order that keys were inserted into the map, as with {@link LinkedHashMap}.
@@ -96,12 +100,32 @@


Thanks & Regards                                                                
  Vipin MV                                                              
                                                                                
                                                
                                                

-----Vipin Mv1/India/IBM wrote: -----
To: Lance Andersen <lance.ander...@oracle.com>
From: Vipin Mv1/India/IBM
Date: 07/13/2020 07:13PM
Cc: core-libs-dev@openjdk.java.net
Subject: Re: [EXTERNAL] Re: RFR 6470126 java.util.jar.Attributes#containsKey 
fails with Strings

Hi Lance

Thanks for the detailed review. I will go ahead and look into the required 
documentation changes.
                
Thanks & Regards                                                        
Vipin MV                                                                
                                                                                
                                                                                
                                                

-----Lance Andersen <lance.ander...@oracle.com> wrote: -----
To: Vipin Mv1 <vipin...@in.ibm.com>
From: Lance Andersen <lance.ander...@oracle.com>
Date: 07/10/2020 02:27AM
Cc: core-libs-dev@openjdk.java.net
Subject: [EXTERNAL] Re: RFR 6470126 java.util.jar.Attributes#containsKey fails 
with Strings

Hi Vipin,

Apologies for the delay.


After looking at the bug, which is over 14 years old, the SCCS history of 
Attributes.java, I am reluctant to suggest we move forward with your proposed 
change. 

 The  key for an Attributes map entry should be an Attributes.Name object (see 
Attributes::put). Unfortunately your proposed fix introduces a behavioral 
change and could possibly break existing applications.  


A  behavioral change to existing  public methods would require approval via a 
CSR and would require more compressive testing.   I took a quick scan of the 
JCK tests and of the JTReg tests and I believe your change would cause some of 
the existing tests to fail.

>From my perspective, it would be better to clarify the Attributes javadoc to 
>make it clearer that an Attributes.Name object is required   (which I believe 
>has not changed since the Attributes class was added to Java SE).



Best
Lance



On Jul 1, 2020, at 12:42 AM, Vipin Mv1 <vipin...@in.ibm.com> wrote:
Hi,

A gentle reminder to please review this patch.

Thanks & Regards
 Vipin MV                                                                 
                                                                                
                          
                                                 
                                                 

-----Vipin Mv1/India/IBM wrote: -----
To: core-libs-dev@openjdk.java.net
From: Vipin Mv1/India/IBM
Date: 06/15/2020 11:52AM
Subject: Re: RFR 6470126 java.util.jar.Attributes#containsKey fails with Strings

Hi,

I have addressed the review comments and the patch has been uploaded here:

http://cr.openjdk.java.net/~vtewari/6470126/webrev/index.html

Please let me know your suggestions.

Thanks & Regards                                                                
 
Vipin MV                                                                 
                                                                                
                          

-----Vipin Mv1/India/IBM wrote: -----
To: core-libs-dev@openjdk.java.net
From: Vipin Mv1/India/IBM
Date: 05/11/2020 05:00PM
Subject: RFR 6470126 java.util.jar.Attributes#containsKey fails with Strings

Hi,

Please review the fix for the following issue.

https://bugs.openjdk.java.net/browse/JDK-6470126


diff -r 53568400fec3 src/java.base/share/classes/java/util/jar/Attributes.java
--- a/src/java.base/share/classes/java/util/jar/Attributes.java Thu Mar 26 
15:26:51 2020 +0000
+++ b/src/java.base/share/classes/java/util/jar/Attributes.java Mon May 11 
15:00:01 2020 +0530
@@ -205,7 +205,10 @@
      * @return true if this Map contains the specified attribute name
      */
     public boolean containsKey(Object name) {
-        return map.containsKey(name);
+        if(String.class.isInstance(name))
+            return map.containsKey(Name.of((String)name));
+        else
+            return map.containsKey(name);
     }

     /**

Thanks & Regards
Vipin Menon


 

Lance Andersen| Principal Member of Technical Staff | +1.781.442.2037
Oracle Java Engineering 
1 Network Drive 
Burlington, MA 01803
lance.ander...@oracle.com


  
 

Reply via email to