An external spec cannot use its superclass spec's states unless the superclass spec is read first

Offen
#461 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
64/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java
Bereich
compilers

Rechercherichtung

Start by reproducing the failure with the three-file example, then read ExternalRefinementTypeChecker.visitCtInterface and compare its behavior with RefinementProcessor.processPackage. Check how processing sub-packages affects registration order too. Done means external specs' state sets are registered before methods are read, independent of file and package order, with the reproducer no longer reporting a missing ghost state.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug

Impact: a subclass's external spec can use the states of a @StateSet declared in its superclass's spec only if the verifier reads the superclass's spec first. Spec files are read in package order (file names here), so splitting a JDK hierarchy into one file per class breaks depending on the names. FrameRefinements.java sorts before WindowRefinements.java, so this fails.

Minimal reproducer (three files in one directory)

// FrameRefinements.java
@ExternalRefinementsFor("java.awt.Frame")
public interface FrameRefinements {
    @StateRefinement(to = "notDisplayable(this)")
    void Frame(String title);

    @StateRefinement(from = "notDisplayable(this)")
    void setUndecorated(boolean undecorated);
}

// WindowRefinements.java
@StateSet({"displayable", "notDisplayable"})
@ExternalRefinementsFor("java.awt.Window")
public interface WindowRefinements {
    @StateRefinement(to = "notDisplayable(this)")
    void dispose();

    @StateRefinement(to = "displayable(this)")
    void pack();
}

// Use.java
public class Use {
    static void borderless() {
        Frame host = new Frame("Playfield");
        host.pack();
        host.setUndecorated(true);
    }
}

Actual (main @ 19991d36):

Not Found Error: Ghost 'java.awt.Frame.notDisplayable' could not be found
6 |     @StateRefinement(to = "notDisplayable(this)")
  |                            ^^^^^^^^^^^^^^^^^^^^
FrameRefinements.java:6

If the two interfaces are in one file with Window first, or if WindowRefinements.java is renamed so that it sorts first (e.g. AWindowRefinements.java), the program verifies up to the expected State Refinement Error on host.setUndecorated(true).

Expected: the result does not depend on file order. The state sets of every external spec should be registered before any spec's methods are read. RefinementProcessor.processPackage already does this for the methods of user classes, but ExternalRefinementTypeChecker.visitCtInterface reads an interface's @StateSets and its methods together, one interface at a time. Sub-packages are processed after their parent, so the same problem appears when the two specs are in different packages.

Found while working on #456.

Vorherrschende Sprache
Java
Sterne
73
Forks
38
Ø Merge
12 Std. 32 Min.
Gemergte PRs (30 T.)
45

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus liquid-java/liquidjava

Alle Issues in liquid-java/liquidjava

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.