eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[Tests] ClassFileBytesDisassembler based tests should not encode constant pool index
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 49
Description
As the evolving PR https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3896 shows, it is very painful when tests encode disassembly output. The said PR results in a different order of methods emission in the class file that results in constant pool indexes that are hard coded in the tests to be invalidated and for many tests to "fail" - It is only the constant pool *index* that differs, the indexed entry is still the same.
It would be good to avoid encoding disassembly into tests unless absolutely needed instead relying on reflection or runtime behavior where possible.
Where we **must** rely on disassembly,
- We need to come up with a new mode for `ClassFileBytesDisassembler` that elides constant pool indexes in the ouput
- Ensure _somehow_ (via deprecation or ...) that no new tests get written that would encode the numerical index.
In a disassembly output like, there is **absolutely nothing to be achieved** by encoding constant pool offsets (shown in \*\*index\*\* form below)
```
// Method descriptor **#34** (Ljava/util/List;)V
// Signature: (Ljava/util/List;)V
// Stack: 2, Locals: 2
Record(java.util.List list);
0 aload_0 [this]
1 invokespecial java.lang.Record() [**36**]
4 aload_0 [this]
5 aload_1 [list]
6 putfield Record.list : java.util.List [**14**]
9 return
Line numbers:
[pc: 0, line: 1]
Method Parameters:
list
RuntimeVisibleTypeAnnotations:
#**10** @Ann(
target type = 0x16 METHOD_FORMAL_PARAMETER
method parameter index = 0
)
#**10** @Ann(
target type = 0x16 METHOD_FORMAL_PARAMETER
method parameter index = 0
location = [TYPE_ARGUMENT(0)]
)
;
```
Contributor guide
Research direction
Start by reviewing ClassFileBytesDisassembler and the test changes discussed in pull request 3896. Trace how disassembly output is generated and how tests compare it, then define a mode that omits constant pool indexes and determine how new tests should be prevented from encoding them. Done means affected tests no longer depend on numeric indexes while preserving meaningful disassembly checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100