I think I'm leaning towards the breaking test depending on a few implementation details that we don't necessarily want to guarantee.
1) It expects that loading the Class results in loading the namespace (which isn't promised by gen-class, it's just the default)
2) It expects that importing the Class results in loading the class
3) It expects that loading the Class results in adding some default vars to the namespace (-toString for instance)
I've attached a patch that makes the proposed fix, and corrects the tests for the change.
Should we make a JIRA issue for this?
If this is added, I'd suggest the following for release notes:
"import" no longer causes the imported class to be initialized. This change better matches Java's import behavior and allows the importing of classes that do significant work at initialization time which may fail.
This semantics change is not expected to effect most code, but certain code may have depended on behavior that is no longer true.
1) importing a Class defined via gen-class no longer causes its defining namespace to be loaded, loading is now deferred until first reference. If immediate loading of the namespace is needed, "require" it directly.
2) Some code may have depended on import to initialize the class before it was used. It may now be necessary to manually call (Class/forName "org.example.Class") when initialization is needed. In most cases, this should not be necessary because the Class will be initialized automatically before first use.