[Git][reproducible-builds/diffoscope][master] Ensure that Java class files are named .class on the filesystem before passing them to javap(1).

Chris Lamb (@lamby) gitlab at salsa.debian.org
Fri Aug 1 18:49:01 UTC 2025



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
9ec7aad2 by Chris Lamb at 2025-08-01T11:48:27-07:00
Ensure that Java class files are named .class on the filesystem before passing them to javap(1).

- - - - -


1 changed file:

- diffoscope/comparators/java.py


Changes:

=====================================
diffoscope/comparators/java.py
=====================================
@@ -21,10 +21,12 @@
 import re
 import os.path
 import logging
+import shutil
 
-from diffoscope.tools import tool_required
 from diffoscope.difference import Difference
 from diffoscope.exc import RequiredToolNotFound
+from diffoscope.tempfiles import get_named_temporary_file
+from diffoscope.tools import tool_required
 
 from .utils.file import File
 from .utils.command import Command, strip_ansi_escapes
@@ -49,9 +51,19 @@ class ProcyonDecompiler(Command):
 
 class Javap(Command):
     def __init__(self, path, *args, **kwargs):
-        super().__init__(path, *args, **kwargs)
+        # Ensure that class files are named .class on the filesystem as javap
+        # will not accept files with other extensions.
+        if not path.endswith(".class"):
+            self.tempfile = get_named_temporary_file(suffix=".class")
+            logger.debug(f"Copying {path} to {self.tempfile.name}")
+            shutil.copy(path, self.tempfile.name)
+            path = self.tempfile.name
+
+        # Save the realpath for filter()
         self.real_path = os.path.realpath(path)
 
+        super().__init__(path, *args, **kwargs)
+
     @tool_required("javap")
     def cmdline(self):
         return [



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/9ec7aad21d7a45069a3dddd4bcee476fe1dff1ae

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/commit/9ec7aad21d7a45069a3dddd4bcee476fe1dff1ae
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20250801/30077970/attachment.htm>


More information about the rb-commits mailing list