CSR :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
There are many places in the JNDI implementation that use reflection to access core classes and methods. These seem to date back to a time when JNDI was a separate bundle, and when some of these classes/methods were recently added to the platform. This is no longer the case, and the code can be simplified greatly by removing these usages of reflection, and replacing them with static references. Just two examples are included here to give some context: com/sun/jndi/ldap/ClientId.java ClientId(int version, String hostname, int port, String protocol, Control[] bindCtls, OutputStream trace, String socketFactory) { .... Class<?> objClass = Class.forName("java.lang.Object"); .... This can of course be replaced with java.lang.Object.class! --- com/sun/jndi/ldap/Connection.java private Object createInetSocketAddress(String host, int port) throws NoSuchMethodException { try { Class<?> inetSocketAddressClass = Class.forName("java.net.InetSocketAddress"); Constructor<?> inetSocketAddressCons = inetSocketAddressClass.getConstructor(new Class<?>[]{ String.class, int.class}); return inetSocketAddressCons.newInstance(new Object[]{ host, new Integer(port)}); } catch (ClassNotFoundException | InstantiationException | InvocationTargetException | IllegalAccessException e) { throw new NoSuchMethodException(); } } java.net.SocketAddress is a core class.
|