Skip to content

Commit eae23da

Browse files
authored
Document how I diagnose code cleanliness failures (#1161)
These are the steps I used to diagnose #1159 (comment)
1 parent 0f47c66 commit eae23da

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

BUILDING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,38 @@ The CI build automatically run code cleanliness checks. To run them on your comp
2828
docker run --rm -it -v $(git rev-parse --show-toplevel):/work -w /work/$(git rev-parse --show-prefix) --cap-add=SYS_PTRACE --security-opt seccomp=unconfined quay.io/eclipse-cdt/cdt-infra:latest releng/scripts/check_code_cleanliness.sh
2929
```
3030

31+
#### Diagnosing code cleanliness failures
32+
33+
##### `baseline and build artifacts have same version but different contents`
34+
35+
An error like this:
36+
37+
```
38+
Error: Failed to execute goal org.eclipse.tycho:tycho-p2-plugin:4.0.12:p2-metadata (baselinereplace-p2-metadata) on project org.eclipse.cdt.ui: baseline and build artifacts have same version but different contents
39+
Error: no-classifier: different
40+
Error: org/eclipse/cdt/internal/ui/ImageCombo.class: different
41+
```
42+
43+
may be caused because a dependency has changed API in a way that the same CDT source compiles to different binary.
44+
To diagnose such a problem you can compare the disassembled class files to see what changed:
45+
46+
1. Run the check_code_cleanliness locally using docker (see above for command line)
47+
2. extract the class from the baseline jar (e.g. `core/org.eclipse.cdt.ui/target/baseline/org.eclipse.cdt.ui-9.0.0.202502172234.jar`)
48+
3. Using javap, disassemble the baseline and compiled class file. e.g:
49+
* `javap -c baseline/osgi.bundle/org/eclipse/cdt/internal/ui/ImageCombo.class > baseline.asm`
50+
* `javap -c classes/org/eclipse/cdt/internal/ui/ImageCombo.class > after.asm`
51+
4. Compare the the asm files. e.g:
52+
* `diff baseline.asm after.asm` will output something like:
53+
54+
```java
55+
270c270
56+
< 17: invokespecial #132 // Method org/eclipse/swt/widgets/TypedListener."<init>":(Lorg/eclipse/swt/internal/SWTEventListener;)V
57+
---
58+
> 17: invokespecial #132 // Method org/eclipse/swt/widgets/TypedListener."<init>":(Ljava/util/EventListener;)V
59+
```
60+
61+
5. With the above information you can track down what may have changed. e.g. See https://github.com/eclipse-cdt/cdt/pull/1159#issuecomment-2858751463 for the results of this worked example.
62+
3163
### Profiles
3264

3365
There are a number of profiles (-P to mvn) to control the behaviour of the build.

0 commit comments

Comments
 (0)