-
Bug
-
Resolution: Fixed
-
P2
-
5.0
-
b59
-
generic
-
solaris_8
There is a conflict in the API generification.
java.util.Properties has been generified as Map<Object,Object> because some existing clients use non-strings in properties. This is unfortunate, but we really don't want to break existing clients.
javax.naming.InitialContext and javax.naming.directory.InitialDirContext work with properties objects explicitly. However, they describe properties using the type Hashtable<String,?> (in the constructors) and Hashtable<String,Object> (in InitialContext.myProps) rather than Properties.
The enclosed application demonstrates that any client that currently uses a
Properties object to initialize a javax.naming.InitialContext will be broken by the current generification.
import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
public class LdapTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
DirContext rootCtx, jndiCtx, jndiObject;
Properties jndiProperties;
String dsServiceName;
if(args.length != 3) {
System.out.println("Usage: LdapTest Server Account Password");
System.exit(0);
}
jndiProperties = new java.util.Properties();
jndiProperties.put("java.naming.security.authentication", "simple");
jndiProperties.put("java.naming.provider.url", "ldap://" + args[0] + "/");
jndiProperties.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFac\tory");
jndiProperties.put("java.naming.security.principal", args[1]);
jndiProperties.put("java.naming.security.credentials", args[2]);
rootCtx = new InitialDirContext(jndiProperties);
dsServiceName = (String)rootCtx.getAttributes("").get("dsServiceName").get();
System.out.println(dsServiceName);
}
}
java.util.Properties has been generified as Map<Object,Object> because some existing clients use non-strings in properties. This is unfortunate, but we really don't want to break existing clients.
javax.naming.InitialContext and javax.naming.directory.InitialDirContext work with properties objects explicitly. However, they describe properties using the type Hashtable<String,?> (in the constructors) and Hashtable<String,Object> (in InitialContext.myProps) rather than Properties.
The enclosed application demonstrates that any client that currently uses a
Properties object to initialize a javax.naming.InitialContext will be broken by the current generification.
import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
public class LdapTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception {
DirContext rootCtx, jndiCtx, jndiObject;
Properties jndiProperties;
String dsServiceName;
if(args.length != 3) {
System.out.println("Usage: LdapTest Server Account Password");
System.exit(0);
}
jndiProperties = new java.util.Properties();
jndiProperties.put("java.naming.security.authentication", "simple");
jndiProperties.put("java.naming.provider.url", "ldap://" + args[0] + "/");
jndiProperties.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFac\tory");
jndiProperties.put("java.naming.security.principal", args[1]);
jndiProperties.put("java.naming.security.credentials", args[2]);
rootCtx = new InitialDirContext(jndiProperties);
dsServiceName = (String)rootCtx.getAttributes("").get("dsServiceName").get();
System.out.println(dsServiceName);
}
}
- relates to
-
JDK-5064052 unnecessary bridge methods interfere with some generics retrofitting
- Resolved