Strictly speaking it is not clear from JDK spec if it is required for any Java implementation
to make DNS host name resolution to determine result value of SocketPermission.equals/implies methods.
Let's consider following example:
-------------------------------------
import java.net.SocketPermission;
public class SP01 {
public static void main (String[] args) {
SocketPermission sp1 = new SocketPermission(args[0], "connect");
SocketPermission sp2 = new SocketPermission(args[1], "connect");
System.out.println("equals-1: " + sp1.equals(sp2));
System.out.println("equals-2: " + sp2.equals(sp1));
System.out.println("implies-1: " + sp1.implies(sp2));
System.out.println("implies-2: " + sp2.implies(sp1));
}
}
------------------------------------
If it is executed on JDK-6 with 2 different DNS names representing the same IP address in command line it shows that true is returned always which means coresponding IP adresses are considered inside equals/implies implementation instead of DNS host names.
I agree it is reasonable but it is not specified explicitly.
If such behavior is required from any Java implementation (personally me would prefer this option) then it should be specified explcitly.
It it is up to implementation to either exploit DNS capabilities or resort to literal comparison then such flexibility should be claimed explicitly too.
to make DNS host name resolution to determine result value of SocketPermission.equals/implies methods.
Let's consider following example:
-------------------------------------
import java.net.SocketPermission;
public class SP01 {
public static void main (String[] args) {
SocketPermission sp1 = new SocketPermission(args[0], "connect");
SocketPermission sp2 = new SocketPermission(args[1], "connect");
System.out.println("equals-1: " + sp1.equals(sp2));
System.out.println("equals-2: " + sp2.equals(sp1));
System.out.println("implies-1: " + sp1.implies(sp2));
System.out.println("implies-2: " + sp2.implies(sp1));
}
}
------------------------------------
If it is executed on JDK-6 with 2 different DNS names representing the same IP address in command line it shows that true is returned always which means coresponding IP adresses are considered inside equals/implies implementation instead of DNS host names.
I agree it is reasonable but it is not specified explicitly.
If such behavior is required from any Java implementation (personally me would prefer this option) then it should be specified explcitly.
It it is up to implementation to either exploit DNS capabilities or resort to literal comparison then such flexibility should be claimed explicitly too.
- duplicates
-
JDK-6590234 Unspecified comparison by resolved IP address in SocketPermission.equals(Object obj) method
-
- Closed
-
- relates to
-
JDK-6592623 General contract for hashCode() method is broken in java.net.SocketPermission
-
- Open
-