Reputation: 2477
Is there an easy way (idealy existing helper library) to detect shadowed attributes of a java bean given it has multiple level of hierarchy?
[C] extends [B] extends [A]. Then attribute [A].firstName is defined.
I want to detect beans where [C].firstName is redefined (which is likely a developer error) inside a generic jUnit test so this kind of "hard to find bug" is catched by the build process.
Note: in Eclispe IDE this is equivalent to "Field declaration hides another field or variable" under Java/Compiler/Errors/Name shadowing and conflicts.
Upvotes: 1
Views: 84
Reputation: 386
Typically you wouldn't put this in a unit test, rather you'd put something like Checkstyle in your integration build process which will flag the same issue.
Upvotes: 2