External refinements are not applied to packages checked before the spec's package

Ouverte
#416 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
testing-qa

Piste de recherche

Start with RefinementProcessor.processPackage, which the issue identifies as registering external specs, checking package types, and then recursing into sub-packages. Trace how first-pass information is registered across the package tree and how verification consumes external specs. Reproduce the example with VectorRefinements and Client; done means the invalid Vector constructor call reports a refinement error regardless of package order.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug

An @ExternalRefinementsFor spec is ignored when the code that uses the class is in a package that is checked before the spec's own package: its parent package, or a sibling that comes earlier. A call that violates the spec then passes verification silently.

Example

sub/VectorRefinements.java:

package sub;

import liquidjava.specification.ExternalRefinementsFor;
import liquidjava.specification.Refinement;

@ExternalRefinementsFor("java.util.Vector")
public interface VectorRefinements<E> {
    public void Vector(@Refinement("_ >= 0") int initialCapacity);
}

Client.java, in the unnamed package:

import java.util.Vector;

public class Client {
    public static void main(String[] args) {
        Vector<String> v = new Vector<>(-1);
    }
}

Verifying the directory gives Correct! Passed Verification. (checked with 0.0.35 and main).

Spec in Client in Result
sub unnamed package (same directory, or spec in sub/) passes
sub sibling app passes
aspec sibling zclient Refinement Error
sub sub or sub.inner Refinement Error
unnamed package unnamed package or app Refinement Error

Cause

RefinementProcessor.processPackage registers a package's external specs, checks that package's types, and only then recurses into its sub-packages. A spec is therefore unknown while every package checked before its own is verified.

Possible fix

Register the external specs (and the other first-pass information) of the whole package tree before checking any package's types.

Impact

Found while running the Barista benchmark specs (package expert.<class>;) against exercises in the unnamed package: every violation passed until the spec's package line was removed.

Langage dominant
Java
Étoiles
73
Forks
38
Merge moyen
12 h 32 min
PR mergées (30 j)
45

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de liquid-java/liquidjava

Toutes les issues de liquid-java/liquidjava

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.