GUVNOR-2140: Recursion in ClassFactBuilder leads to StackOverflow when loading in assets into project model cache.

(cherry picked from commit b3d55cba88a363dbc2f1b7c3dd5464a63e18a798 and fe0d9e6e7648db814190387da6d7c89860306e89)
(commits squashed and tests fixed)