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

Attachments

2

Activity

Show:

Alex Miller January 22, 2016 at 9:03 PM

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

Nicola Mometto October 2, 2014 at 5:48 PM

Updated the patch so that it compiles fine on JDK8

Andy Fingerhut October 2, 2014 at 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 April 14, 2014 at 8:10 PM

Added result of (pst *e) in the description

Alex Miller April 14, 2014 at 8:07 PM

Can you include the (pst *e) ?

Completed

Details

Assignee

Reporter

Labels

Approval

Ok

Patch

Code and Test

Priority

Fix versions

Created April 14, 2014 at 7:57 PM
Updated September 14, 2018 at 10:21 PM
Resolved September 14, 2018 at 10:21 PM