ns-resolve might throw ClassNotFoundException but should return nil

Description

The doc of ns-resolve states that in case the symbol cannot be resolved, it should return nil.

However if the symbol contains dots and is not a resolvable Class, a ClassNotFoundException is thrown

Approach: Catch CNFE when attempting to resolve a dotted symbol as a class and return nil instead.

Patch: clj-1403-2.patch

Screened by: Alex Miller
The attached patch makes ns-resolve return nil in that case instead of throwing an exception

Environment

None

Activity

Show:
Alex Miller
April 14, 2014, 8:07 PM

Can you include the (pst *e) ?

Nicola Mometto
April 14, 2014, 8:10 PM

Added result of (pst *e) in the description

Andy Fingerhut
October 2, 2014, 5:36 PM

Nicola, the patch 0001-CLJ-1403-ns-resolve-returns-nil-if-class-is-not-foun.patch dated 31 Aug 2014 applies cleanly to latest Clojure master as of Oct 1 2014, but fails to compile with JDK8. I haven't checked whether it compiles cleanly with other JDK versions yet.

Nicola Mometto
October 2, 2014, 5:48 PM

Updated the patch so that it compiles fine on JDK8

Alex Miller
January 22, 2016, 9:03 PM

Updated patch to apply to master, no other changes, attribution retained.

Completed

Assignee

Unassigned

Reporter

Nicola Mometto

Labels

Approval

Ok

Patch

Code and Test

Fix versions

Priority

Minor
Configure