Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4199913

java.util.jar.Attributes.put() doesn't throw ClassCastException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
      jar
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      Name: ksC84122 Date: 12/25/98


      According to the javadoc, java.util.jar.Attributes.put(Object name,
      Object value) should throw ClassCastException if the name is not an
      Attributes.Name or the value is not a String . JDK 1.2-fcs,
      however, doesn't implement this feature.

      A test example which demonstrates this problem.
      ===== Test18.java ========
      import java.util.jar.Attributes;

      public class Test18 {

          public static void main (String argv[]) {
              Attributes attr = new Attributes();
              String s = "SomeValue";
          
              try {
                  attr.put("SomeName", s);
                  System.out.println("Failed: ClassCastException excpected");
                  return;
              } catch (ClassCastException cce) { //OKAY
              }
              try {
                  attr.put( new Attributes.Name("SomeName"), s.getBytes()) ;
                  System.out.println("Failed: ClassCastException excpected");
                  return;
              } catch (ClassCastException cce) { //OKAY
              }
              System.out.println("Passed: OK");
              return;
          }
      }

      ========= Sample run (JDK-1.2-V) ==========
      #>java Test18
      Failed: ClassCastException excpected

      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              zlisunw Zhenghua Li (Inactive)
              Reporter:
              ksoshals Kirill Soshalskiy (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: