External specs do not reach user subclasses: a typestate call on a subclass receiver crashes with a sort mismatch
Mantenedores costumam responder em até 1 dia
Um pull request relacionado já foi integrado.
- #354 de @CatarinaGamboa — integrado
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Java
- Estrelas
- 67
- Forks
- 36
- Merge médio
- 2d 4h
- PRs com merge (30d)
- 28
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de liquid-java/liquidjava
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
liquid-java/liquidjava#373 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
liquid-java/liquidjava#321 ·
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
liquid-java/liquidjava#381 ·
Mantenedores costumam responder em até 1 dia
-
enhancement future latte
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
liquid-java/liquidjava#380 ·
Mantenedores costumam responder em até 1 dia
-
An external spec cannot refine methods its class inheritsTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertabug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
liquid-java/liquidjava#379 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de liquid-java/liquidjava
Issues semelhantes
-
Fix Math.ceilDiv wrong result for exact positive divisionsTalvez já em andamento @pamod-madubashana assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
scala-native/scala-native#5094 ·
Mantenedores costumam responder em até 1 dia
-
[Bug] AI unread message badge counts a batch of new bubbles as one messageTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
apache/rocketmq-dashboard#5784 ·
Mantenedores costumam responder em até 3 dias
-
[i18n] 安装实例完成后的成功提示未正确本地化Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
PCL-Community/PCL-CE#3658 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
apache/skywalking#14127 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia