Repository navigation
Commit b3a4e4a
Fix crashes on enum methods, varargs calls and calls on a call result (#420)
Three crashes on ordinary Java code, met together in one real class
(JabRef's `EditAction`). One commit each.
## 1. An enum with a method crashes the verifier
```java
enum Action { UNDO, REDO; String getText() { return name(); } }
```
```
NullPointerException: Cannot invoke "String.endsWith(String)" because "qualifiedName" is null
at ExternalRefinementTypeChecker.visitCtMethod
```
`ExternalRefinementTypeChecker` skips classes and records (user code)
but not enums, so it visits the enum's methods with no external target.
**Fix:** a no-op `visitCtEnum`, as for records.
## 2. A varargs call with more arguments than parameters
```java
void debug(String format, Object... args) {}
logger.debug("{} and {}", a, b); // IndexOutOfBoundsException: Index 2 out of bounds for length 2
```
`mapInvocation` and `checkParameters` index the parameters by argument
position. **Fix:** both use only the arguments bound one to one to
parameters; the ones collected into the varargs array are left out (an
array parameter's refinement is not checked per element anyway).
## 3. A call on the result of a call without a return refinement
```java
holder.get().close();
// Argument Mismatch Error: Argument '#holder_14' and its respective parameter of ghost 'Door.state1'
// types are incompatible: expected Door, got Holder
```
When `get()` has no return refinement, its `TARGET` metadata is still
its own receiver (`holder`), and `prepareInvocationTarget` used it as
the receiver of `close()`. **Fix:** a call whose `TARGET` is not its
return value (`RETURN_VAR_NAME`) gives a fresh receiver of the call's
type, in an unknown state, created once per call (`Keys.RECEIVER`, as
for constructor calls). Now: `found true but expected open(#fresh)`.
## Tests
- `CorrectEnumWithMethod`: crashed before.
- `CorrectVarargsCall` (more, fewer and an explicit array) and
`ErrorVarargsCall` (a refined fixed parameter before the varargs is
still checked): crashed before.
- `CorrectCallResultReceiver` (a call with no precondition on a call
result) and `ErrorCallResultReceiver` (reported as a state error, not an
argument mismatch).
- `mvn test`: 463 tests, 0 failures.
Found on a real fixed bug: JabRef's Edit command calling
`undo()`/`redo()` without `canUndo()`/`canRedo()` (PR
JabRef/jabref#9777). We also checked 53 exercises built from real OSS
bugs on main (69895fa) and with these changes: the results are
identical.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent d3e00be commit b3a4e4a
8 files changed
Lines changed: 143 additions & 2 deletions
File tree
- liquidjava-example/src/main/java/testSuite
- liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker
- general_checkers
- object_checkers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
422 | | - | |
| 422 | + | |
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
440 | 450 | | |
441 | 451 | | |
442 | 452 | | |
| |||
451 | 461 | | |
452 | 462 | | |
453 | 463 | | |
454 | | - | |
| 464 | + | |
455 | 465 | | |
456 | 466 | | |
457 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
851 | 866 | | |
852 | 867 | | |
853 | 868 | | |
| |||
857 | 872 | | |
858 | 873 | | |
859 | 874 | | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
860 | 881 | | |
861 | 882 | | |
862 | 883 | | |
| |||
0 commit comments