I normally don't answer a question with "Don't do this", but I'll make an exception in this case.
This is a REALLY BAD IDEATM.
As has been pointed out, you are at the mercy of the RUNTIME classpath, over which you have little absolute control, especially if a different group of people is responsible for configuring and provisioning your production environment.
The time to address and resolve this issue is YESTERDAY. This should have never been allowed to happen, and continuing with this will just lead to continual headaches and unexplained, hard-to-debug failures in the future.
Get the architect(s) involved and either
- Rename both of the
User
classes, for example AccountingUser
& SalesUser
. Do not allow one to remain User
if there are legitimately two kinds of users; or
- Reconcile the two definitions, then pull it out to its own library (along with any common supporting code) and make both projects depend on it.