External specs do not reach user subclasses: a typestate call on a subclass receiver crashes with a sort mismatch
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #354 de @CatarinaGamboa — fusionado
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Start from RefinedVariable (how it records superclass/interface relations) and RefinementProcessor (its first pass processes types one by one), the two components named in the Causes section. Reproduce with the Repro/AppException example on main to see the sort mismatch, then trace where the state function argument sort is chosen for a subclass receiver. Done looks like the subclass case reporting State Refinement Error: found withThrowable(e) but expected noThrowable(e) instead of crashing — but note open PR #354 is already addressing this, so coordinate before starting.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
An external spec written for a class (@ExternalRefinementsFor("java.lang.Throwable")) does not reach user subclasses. A typestate call on a subclass receiver makes the verifier crash instead of reporting the violation.
Example
Spec (abridged from the Barista Throwable spec):
@ExternalRefinementsFor("java.lang.Throwable")
@StateSet({"noThrowable", "withThrowable"})
public interface ThrowableRefinements {
@StateRefinement(to = "noThrowable(this)") void Throwable(String message);
@StateRefinement(to = "withThrowable(this)") void Throwable(String message, Throwable cause);
@StateRefinement(from = "noThrowable(this)", to = "withThrowable(this)") Throwable initCause(Throwable cause);
}
Client code (a real bug shape: initCause on an exception whose cause was already set throws IllegalStateException: Can't overwrite cause):
public class Repro {
static class AppException extends RuntimeException {
AppException(String message, Throwable cause) { super(message, cause); }
}
static AppException wrap(Exception underlying, Exception detail) {
AppException e = new AppException("operation failed", underlying);
e.initCause(detail); // throws at runtime
return e;
}
}
On main (be47cb68):
Error: Sort mismatch at argument #1 for function (declare-fun java.lang.Throwable.state1 (java.lang.Throwable) Int) supplied sort is Repro$AppException
The same code with Throwable e = new Throwable("operation failed", underlying); is reported as intended:
State Refinement Error: found withThrowable(e) but expected noThrowable(e)
Causes
RefinedVariablerecords only the direct superclass and the direct interfaces, soAppExceptionis never related toThrowable(two levels up), and the state function's argument sort does not match.- A user constructor that delegates to
super(...)gets the default state rather than the state the super constructor's spec gives. RefinementProcessorruns the first pass type by type, so a user class can be processed before the external spec it depends on is registered.
Found while building exercises from real Java bugs (e.g. the "Can't overwrite cause" bugs in Apache projects), where a custom exception subclass is the usual shape.
- Lenguaje dominante
- Java
- Estrellas
- 67
- Forks
- 36
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 28
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de liquid-java/liquidjava
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
liquid-java/liquidjava#373 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
liquid-java/liquidjava#321 ·
Los mantenedores suelen responder en 1 día
-
Synthesize hints for resolutionAbiertoenhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
liquid-java/liquidjava#381 ·
Los mantenedores suelen responder en 1 día
-
enhancement future latte
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
liquid-java/liquidjava#380 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
liquid-java/liquidjava#379 ·
Los mantenedores suelen responder en 1 día
Todos los issues de liquid-java/liquidjava
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
team:Lumberjack
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
OpenLiberty/open-liberty#35998 ·
Los mantenedores suelen responder en 1 día
-
[BUG] SQS SendMessageBatch accepts more than 10 entries instead of TooManyEntriesInBatchRequestAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
floci-io/floci#5319 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Bug QWP
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100