GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Spec predicates cannot mention null: "Variable 'null' could not be found" · Issue #466 · liquid-java/liquidjava

Spec predicates cannot mention null: "Variable 'null' could not be found" #466

New issue
Copy link
New issue
Copy link
Open
Open
Spec predicates cannot mention null: "Variable 'null' could not be found"#466
Copy link

Description

@CatarinaGamboa
CatarinaGamboa
opened on Nov 2, 2026
Issue body actions

Summary

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.

Minimal reproducer

DatagramSocketRefinements.java:

import java.net.SocketAddress;
import liquidjava.specification.*;

@ExternalRefinementsFor("java.net.DatagramSocket")
@StateSet({"unbound", "bound"})
public interface DatagramSocketRefinements {
    @StateRefinement(to = "bindaddr == null ? unbound(this) : bound(this)")
    void DatagramSocket(SocketAddress bindaddr);

    @StateRefinement(from = "unbound(this)", to = "bound(this)")
    void bind(SocketAddress addr);
}

Client.java:

import java.net.DatagramSocket;
import java.net.InetSocketAddress;

public class Client {
    public static void main(String[] args) throws Exception {
        DatagramSocket s = new DatagramSocket(null);   // Variable 'null' could not be found
        s.setReuseAddress(true);
        s.bind(new InetSocketAddress(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.

Seen on 1a506fe, f7f366c and main at 19991d3.

Why it matters: real code

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.