Commit 4810100
authored
Fix misleading JDK compatibility error message for TASTy version
mismatches
Fixes #24233
### Description
When the compiler encounters a TASTy version mismatch (e.g., attempting
to read a TASTy file produced by a newer compiler version like 3.7.1
with compiler 3.3.6), it throws an `UnpickleException`. The error
handling code in _`ClassfileParser`_ and `ClassfileTastyUUIDParser `was
catching this as a generic `RuntimeException `and appending a misleading
message suggesting to "check the JDK compatibility of your Scala
version."
### This message was confusing because:
The error is about TASTy format versions (majorVersion: 28), not Java
classfile versions
The JDK version suggestion is irrelevant to TASTy compatibility issues
### Changes Made
- Modified exception handlers in `ClassfileParser.scala` and
`ClassfileTastyUUIDParser.scala`
- Added pattern matching to detect `UnpickleException `specifically
- Suppress JDK compatibility hint for TASTy unpickling errors
- Preserve the hint for actual classfile version issues
### Example
**Before:**
```
class file ... is broken (version 52.0),
please check the JDK compatibility of your Scala version (3.3.6),
reading aborted with class dotty.tools.tasty.UnpickleException:
TASTy signature has wrong version...
```
**After:**
```
class file ... is broken,
reading aborted with class dotty.tools.tasty.UnpickleException:
TASTy signature has wrong version...
```
The UnpickleException message already contains clear information about
the TASTy version mismatch, making the JDK hint unnecessary and
confusing.
Testing
- Manually verified code correctness through inspection
- Changes are minimal and focused on error message formatting
- No functional changes to compilation logic
1 parent 890b442 commit 4810100
File tree
2 files changed
+8
-4
lines changed- compiler/src/dotty/tools/dotc/core/classfile
2 files changed
+8
-4
lines changedLines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
310 | 312 | | |
311 | 313 | | |
312 | 314 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
0 commit comments