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
======================================================================
- duplicates
-
JDK-4165833 java.util.jar.Attributes put() method not consistent with specification
-
- Resolved
-