You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spec predicates cannot mention null: "Variable 'null' could not be found" #466
A spec predicate cannot mention null: bindaddr == null ? ... : ... gives Not Found Error: Variable 'null' could not be found. So a spec cannot say what the JDK does when a parameter is null, even where that is the documented way to choose a state.
importjava.net.DatagramSocket;
importjava.net.InetSocketAddress;
publicclassClient {
publicstaticvoidmain(String[] args) throwsException {
DatagramSockets = newDatagramSocket(null); // Variable 'null' could not be founds.setReuseAddress(true);
s.bind(newInetSocketAddress(0));
s.close();
}
}
Expected: Correct! Passed Verification. On the JVM this runs: DatagramSocket(SocketAddress) says "if the address is null, creates an unbound socket", so that options such as setReuseAddress can be set before binding.
Without null in predicates the spec has to pick one state for the constructor. Choosing bound (what every other constructor does) rejects the documented idiom above, which real UDP code uses. Two of five mined GitHub methods using DatagramSocket do exactly this: create with null, then bind(new InetSocketAddress(IP, port)) (e.g. Padawan-Transport-Protocol-PTP Sender.createSocket). Choosing unbound instead lets bind on an already-bound socket through, which throws SocketException on the JVM.
Found while checking mined client code against JDK specs (liquid-java/co-specification, verifier probe V34).
Activity