Avoid clearing OneShotByteResources on dump input

Bug: b/367066320
Change-Id: Ibc274ca61ce401a13cb35240484b6c9258b123c4
diff --git a/src/main/java/com/android/tools/r8/utils/AndroidApp.java b/src/main/java/com/android/tools/r8/utils/AndroidApp.java
index 9ce000f..fbe0ea6 100644
--- a/src/main/java/com/android/tools/r8/utils/AndroidApp.java
+++ b/src/main/java/com/android/tools/r8/utils/AndroidApp.java
@@ -806,7 +806,13 @@
       ZipOutputStream dexArchiveOutputStream,
       ProgramResource programResource)
       throws ResourceException, IOException {
-    byte[] bytes = StreamUtils.streamToByteArrayClose(programResource.getByteStream());
+    byte[] bytes;
+    if (programResource instanceof OneShotByteResource) {
+      OneShotByteResource oneShotByteResource = (OneShotByteResource) programResource;
+      bytes = oneShotByteResource.getBytesForDumpInput();
+    } else {
+      bytes = StreamUtils.streamToByteArrayClose(programResource.getByteStream());
+    }
     if (programResource.getKind() == Kind.CF) {
       Set<String> classDescriptors = programResource.getClassDescriptors();
       String classDescriptor =
diff --git a/src/main/java/com/android/tools/r8/utils/OneShotByteResource.java b/src/main/java/com/android/tools/r8/utils/OneShotByteResource.java
index 494d500..76be7da 100644
--- a/src/main/java/com/android/tools/r8/utils/OneShotByteResource.java
+++ b/src/main/java/com/android/tools/r8/utils/OneShotByteResource.java
@@ -54,6 +54,11 @@
     return result;
   }
 
+  public byte[] getBytesForDumpInput() {
+    assert bytes != null;
+    return bytes;
+  }
+
   @Override
   public Set<String> getClassDescriptors() {
     return classDescriptors;