diff --git a/src/main/java/com/google/devtools/build/lib/actions/PathMapper.java b/src/main/java/com/google/devtools/build/lib/actions/PathMapper.java
index 1d006ed7678737..d0065344a8bbfe 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/PathMapper.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/PathMapper.java
@@ -80,6 +80,16 @@ default boolean isNoop() {
return this == NOOP;
}
+ /**
+ * Returns an opaque object whose equality class encodes the behavior of this mapper for use in
+ * in-memory cache keys.
+ *
+ *
The default implementation returns the {@link Class} of the mapper.
+ */
+ default Object cacheKey() {
+ return this.getClass();
+ }
+
/** A {@link PathMapper} that doesn't change paths. */
PathMapper NOOP = execPath -> execPath;
}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/StrippingPathMapper.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/StrippingPathMapper.java
index cfdd6d54b8e475..47086e5b18dd9d 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/StrippingPathMapper.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/StrippingPathMapper.java
@@ -176,6 +176,11 @@ public ExceptionlessMapFn