You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by "Svetlana Samoilenko (JIRA)" <ji...@apache.org> on 2006/02/07 09:13:56 UTC

[jira] Created: (HARMONY-79) java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException

java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException
----------------------------------------------------------------------------------------

         Key: HARMONY-79
         URL: http://issues.apache.org/jira/browse/HARMONY-79
     Project: Harmony
        Type: Bug
  Components: Classlib  
    Reporter: Svetlana Samoilenko


According to the j2se 1.4 and 1.5 specification method java.util.jar.Attributes.put throws ClassCastException - if the name is not a Attributes.Name or the value is not a String.

Harmony doesn't throw ClassCastException 
1)       if the name is not a Attributes.Name
2)       if the value is not a String

Code to reproduce: 
import java.util.jar.Attributes; 
public class test2 {          

    public static void main(String[] args) { 
        Attributes att=new Attributes(); 
        try {
            att.put(new Object(), new String("") );
        } catch ( ClassCastException e) {
            System.out.println("ClassCastException if the name is not a Attributes.Name "); 
        };
        try {
            att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
        } catch ( ClassCastException e) {
            System.out.println("ClassCastException if the value is not a String");
            return;
       };
       System.out.println("Wrong. Must be ClassCastException");
    } 
}

Steps to Reproduce: 
1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
2. Compile test2.java using BEA 1.4 javac 
> javac -d . test2.java 
3. Run java using compatible VM (J9) 
> java -showversion test2

Output: 
C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
java version "1.4.2_04" 
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 
BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) 
ClassCastException if the name is not a Attributes.Name

ClassCastException if the value is not a String

C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
(c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
Wrong. Must be ClassCastException

 Siggested fix: 
       to change the line 232 in archive/src/main/java/java/util/jar/Attributes.java as follows: 
232                  return map.put((Name) key, (String) value);

Suggested junit test case:
------------------------ AttributesTest.java ------------------------------------------------- 
import java.util.jar.*;
import junit.framework.*; 

public class AttributesTest extends TestCase { 
    public static void main(String[] args) { 
        junit.textui.TestRunner.run(AttributesTest.class); 
    } 
    public void test_put () { 
        Attributes att=new Attributes(); 
        // ClassCastException if the name is not a Attributes.Name
        try {
            att.put(new Object(), new String("") );
        } catch ( ClassCastException e) {
            // expected
        };
        //ClassCastException if the value is not a String
        try {
            att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
        } catch ( ClassCastException e) {
            // expected
        };
   } 
}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (HARMONY-79) java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-79?page=all ]

Tim Ellison reassigned HARMONY-79:
----------------------------------

    Assign To: Tim Ellison

> java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException
> ----------------------------------------------------------------------------------------
>
>          Key: HARMONY-79
>          URL: http://issues.apache.org/jira/browse/HARMONY-79
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison
>  Attachments: AttributesTest.java, Attributes_patch.txt
>
> According to the j2se 1.4 and 1.5 specification method java.util.jar.Attributes.put throws ClassCastException - if the name is not a Attributes.Name or the value is not a String.
> Harmony doesn't throw ClassCastException 
> 1)       if the name is not a Attributes.Name
> 2)       if the value is not a String
> Code to reproduce: 
> import java.util.jar.Attributes; 
> public class test2 {          
>     public static void main(String[] args) { 
>         Attributes att=new Attributes(); 
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the name is not a Attributes.Name "); 
>         };
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the value is not a String");
>             return;
>        };
>        System.out.println("Wrong. Must be ClassCastException");
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> java version "1.4.2_04" 
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) 
> ClassCastException if the name is not a Attributes.Name
> ClassCastException if the value is not a String
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
> Wrong. Must be ClassCastException
>  Siggested fix: 
>        to change the line 232 in archive/src/main/java/java/util/jar/Attributes.java as follows: 
> 232                  return map.put((Name) key, (String) value);
> Suggested junit test case:
> ------------------------ AttributesTest.java ------------------------------------------------- 
> import java.util.jar.*;
> import junit.framework.*; 
> public class AttributesTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(AttributesTest.class); 
>     } 
>     public void test_put () { 
>         Attributes att=new Attributes(); 
>         // ClassCastException if the name is not a Attributes.Name
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             // expected
>         };
>         //ClassCastException if the value is not a String
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             // expected
>         };
>    } 
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (HARMONY-79) java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-79?page=all ]
     
Tim Ellison closed HARMONY-79:
------------------------------


Verified by Svetlana


> java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException
> ----------------------------------------------------------------------------------------
>
>          Key: HARMONY-79
>          URL: http://issues.apache.org/jira/browse/HARMONY-79
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison
>  Attachments: AttributesTest.java, Attributes_patch.txt
>
> According to the j2se 1.4 and 1.5 specification method java.util.jar.Attributes.put throws ClassCastException - if the name is not a Attributes.Name or the value is not a String.
> Harmony doesn't throw ClassCastException 
> 1)       if the name is not a Attributes.Name
> 2)       if the value is not a String
> Code to reproduce: 
> import java.util.jar.Attributes; 
> public class test2 {          
>     public static void main(String[] args) { 
>         Attributes att=new Attributes(); 
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the name is not a Attributes.Name "); 
>         };
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the value is not a String");
>             return;
>        };
>        System.out.println("Wrong. Must be ClassCastException");
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> java version "1.4.2_04" 
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) 
> ClassCastException if the name is not a Attributes.Name
> ClassCastException if the value is not a String
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
> Wrong. Must be ClassCastException
>  Siggested fix: 
>        to change the line 232 in archive/src/main/java/java/util/jar/Attributes.java as follows: 
> 232                  return map.put((Name) key, (String) value);
> Suggested junit test case:
> ------------------------ AttributesTest.java ------------------------------------------------- 
> import java.util.jar.*;
> import junit.framework.*; 
> public class AttributesTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(AttributesTest.class); 
>     } 
>     public void test_put () { 
>         Attributes att=new Attributes(); 
>         // ClassCastException if the name is not a Attributes.Name
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             // expected
>         };
>         //ClassCastException if the value is not a String
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             // expected
>         };
>    } 
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Resolved: (HARMONY-79) java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-79?page=all ]
     
Tim Ellison resolved HARMONY-79:
--------------------------------

    Resolution: Fixed

Svetlana/Nathan,

Fixed in ARCHIVE module java.util.jar.Attributes at repo revision 378067.

Please check that this fully resolves your problem.


> java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException
> ----------------------------------------------------------------------------------------
>
>          Key: HARMONY-79
>          URL: http://issues.apache.org/jira/browse/HARMONY-79
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison
>  Attachments: AttributesTest.java, Attributes_patch.txt
>
> According to the j2se 1.4 and 1.5 specification method java.util.jar.Attributes.put throws ClassCastException - if the name is not a Attributes.Name or the value is not a String.
> Harmony doesn't throw ClassCastException 
> 1)       if the name is not a Attributes.Name
> 2)       if the value is not a String
> Code to reproduce: 
> import java.util.jar.Attributes; 
> public class test2 {          
>     public static void main(String[] args) { 
>         Attributes att=new Attributes(); 
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the name is not a Attributes.Name "); 
>         };
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the value is not a String");
>             return;
>        };
>        System.out.println("Wrong. Must be ClassCastException");
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> java version "1.4.2_04" 
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) 
> ClassCastException if the name is not a Attributes.Name
> ClassCastException if the value is not a String
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
> Wrong. Must be ClassCastException
>  Siggested fix: 
>        to change the line 232 in archive/src/main/java/java/util/jar/Attributes.java as follows: 
> 232                  return map.put((Name) key, (String) value);
> Suggested junit test case:
> ------------------------ AttributesTest.java ------------------------------------------------- 
> import java.util.jar.*;
> import junit.framework.*; 
> public class AttributesTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(AttributesTest.class); 
>     } 
>     public void test_put () { 
>         Attributes att=new Attributes(); 
>         // ClassCastException if the name is not a Attributes.Name
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             // expected
>         };
>         //ClassCastException if the value is not a String
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             // expected
>         };
>    } 
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (HARMONY-79) java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException

Posted by "Svetlana Samoilenko (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-79?page=comments#action_12366745 ] 

Svetlana Samoilenko commented on HARMONY-79:
--------------------------------------------

Tim, thank you, I can't reproduce the bug with latest sources.

> java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException
> ----------------------------------------------------------------------------------------
>
>          Key: HARMONY-79
>          URL: http://issues.apache.org/jira/browse/HARMONY-79
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>     Assignee: Tim Ellison
>  Attachments: AttributesTest.java, Attributes_patch.txt
>
> According to the j2se 1.4 and 1.5 specification method java.util.jar.Attributes.put throws ClassCastException - if the name is not a Attributes.Name or the value is not a String.
> Harmony doesn't throw ClassCastException 
> 1)       if the name is not a Attributes.Name
> 2)       if the value is not a String
> Code to reproduce: 
> import java.util.jar.Attributes; 
> public class test2 {          
>     public static void main(String[] args) { 
>         Attributes att=new Attributes(); 
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the name is not a Attributes.Name "); 
>         };
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the value is not a String");
>             return;
>        };
>        System.out.println("Wrong. Must be ClassCastException");
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> java version "1.4.2_04" 
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) 
> ClassCastException if the name is not a Attributes.Name
> ClassCastException if the value is not a String
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
> Wrong. Must be ClassCastException
>  Siggested fix: 
>        to change the line 232 in archive/src/main/java/java/util/jar/Attributes.java as follows: 
> 232                  return map.put((Name) key, (String) value);
> Suggested junit test case:
> ------------------------ AttributesTest.java ------------------------------------------------- 
> import java.util.jar.*;
> import junit.framework.*; 
> public class AttributesTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(AttributesTest.class); 
>     } 
>     public void test_put () { 
>         Attributes att=new Attributes(); 
>         // ClassCastException if the name is not a Attributes.Name
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             // expected
>         };
>         //ClassCastException if the value is not a String
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             // expected
>         };
>    } 
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (HARMONY-79) java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException

Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-79?page=all ]

Nathan Beyer updated HARMONY-79:
--------------------------------

    Attachment: Attributes_patch.txt
                AttributesTest.java

Wrote a patch for this bug, as well as what would be a similar bug in the "putAll" method. Also, I attached a test case, which tests these two methods.

For reference, I ran this same test against the following JREs and the test executed the same: Sun 1.4.2_10, Sun 5.0_5 and BEA 5.0_4_R26.0.

> java.util.jar.Attributes.put(Object name, Object value) doesn't throw ClassCastException
> ----------------------------------------------------------------------------------------
>
>          Key: HARMONY-79
>          URL: http://issues.apache.org/jira/browse/HARMONY-79
>      Project: Harmony
>         Type: Bug
>   Components: Classlib
>     Reporter: Svetlana Samoilenko
>  Attachments: AttributesTest.java, Attributes_patch.txt
>
> According to the j2se 1.4 and 1.5 specification method java.util.jar.Attributes.put throws ClassCastException - if the name is not a Attributes.Name or the value is not a String.
> Harmony doesn't throw ClassCastException 
> 1)       if the name is not a Attributes.Name
> 2)       if the value is not a String
> Code to reproduce: 
> import java.util.jar.Attributes; 
> public class test2 {          
>     public static void main(String[] args) { 
>         Attributes att=new Attributes(); 
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the name is not a Attributes.Name "); 
>         };
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             System.out.println("ClassCastException if the value is not a String");
>             return;
>        };
>        System.out.println("Wrong. Must be ClassCastException");
>     } 
> }
> Steps to Reproduce: 
> 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in README.txt. 
> 2. Compile test2.java using BEA 1.4 javac 
> > javac -d . test2.java 
> 3. Run java using compatible VM (J9) 
> > java -showversion test2
> Output: 
> C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2 
> java version "1.4.2_04" 
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05) 
> BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel) 
> ClassCastException if the name is not a Attributes.Name
> ClassCastException if the value is not a String
> C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2 
> (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable. 
> Wrong. Must be ClassCastException
>  Siggested fix: 
>        to change the line 232 in archive/src/main/java/java/util/jar/Attributes.java as follows: 
> 232                  return map.put((Name) key, (String) value);
> Suggested junit test case:
> ------------------------ AttributesTest.java ------------------------------------------------- 
> import java.util.jar.*;
> import junit.framework.*; 
> public class AttributesTest extends TestCase { 
>     public static void main(String[] args) { 
>         junit.textui.TestRunner.run(AttributesTest.class); 
>     } 
>     public void test_put () { 
>         Attributes att=new Attributes(); 
>         // ClassCastException if the name is not a Attributes.Name
>         try {
>             att.put(new Object(), new String("") );
>         } catch ( ClassCastException e) {
>             // expected
>         };
>         //ClassCastException if the value is not a String
>         try {
>             att.put(new Attributes.Name("IMPLEMENTATION_VENDOR"), new Object()); 
>         } catch ( ClassCastException e) {
>             // expected
>         };
>    } 
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira