After putting further thought into the semantics for getPath() in ClassPathResource, I realized the following.

  1. Several tests were previously misusing getPath(), and I rectified that in commit 1688becd73ab35eb2768c4af97356655b486ba26.
  2. My updates to the Javadoc for getPath() make it clear that the semantics are very inconsistent. See current Javadoc.
  3. If we switch getPath() to return this.absolutePath, the entire test suite passes except ClassPathResourceTests.preserveLeadingSlashForClassRelativeAccess(). Yet, I would argue that's not a valid use case.

In light of the above, I'm wondering if we should:

  1. Switch getPath() to return the absolute path consistently without a leading slash.
  2. Return the Javadoc for getPath() to its previous state (prior to #29094).
  3. Remove the newly introduced getAbsolutePath() method (i.e., revert #29094).

Comment From: sbrannen

@jhoeller, I've assigned this one to both of us so that we can discuss it once you're back.