Skip to content

Conversation

@yonghanlin
Copy link
Contributor

What does this PR do?

This PR fixes a nondeterministic test failure in JavaReflectionTreeBuilderTest.testShadowModelEqualsNormalModel() within . module when running with NonDex.

Problem

The test compares CtType models built from source and from reflection (shadow models). However, both models internally use unordered collections, so the order of elements such as type members, enum values, and annotations vary between runs.

Reproduce Test

To reproduce the failure, run NonDex on . module using the following commands:

mvn -pl . edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=spoon.support.visitor.java.JavaReflectionTreeBuilderTest#testShadowModelEqualsNormalModel

The Fix

  • Sorts and matches type members by signature (memberSignature).
  • Compares enum constants by name instead of position.
  • Sorts annotations by annotation type (qualified name).

@yonghanlin yonghanlin changed the title fix: Nondeterministic test failures in testShadowModelEqualsNormalModel() test: Fixed nondeterministic test failures in testShadowModelEqualsNormalModel() Oct 29, 2025
@yonghanlin yonghanlin changed the title test: Fixed nondeterministic test failures in testShadowModelEqualsNormalModel() review: test: Fixed nondeterministic test failures in testShadowModelEqualsNormalModel() Oct 29, 2025
@monperrus
Copy link
Collaborator

This PR seems too long and too complex given the severity of the problem. Is there a shorter fix as in #6500 and #6501?

@yonghanlin yonghanlin changed the title review: test: Fixed nondeterministic test failures in testShadowModelEqualsNormalModel() test: Fixed nondeterministic test failures in testShadowModelEqualsNormalModel() Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants