@@ -58,47 +58,51 @@ static int Main(string[] args)
5858 int successCount = 0 ;
5959 int errorCount = 0 ;
6060
61- foreach ( var filePath in files )
61+ // Use a single TRAP file for all extractions to ensure globally unique IDs
62+ // This prevents ID collisions when CodeQL imports multiple TRAP files
63+ var outputPath = Path . Combine ( trapDir , "jvm-extraction.trap" ) ;
64+
65+ using ( var trapWriter = new TrapWriter ( outputPath ) )
6266 {
63- if ( ! File . Exists ( filePath ) )
64- {
65- Console . WriteLine ( $ "Warning: File does not exist: { filePath } ") ;
66- errorCount ++ ;
67- continue ;
68- }
69-
70- var extension = Path . GetExtension ( filePath ) ;
71- if ( ! AllowedExtensions . Contains ( extension ) )
67+ var extractor = new JvmExtractor ( trapWriter ) ;
68+
69+ foreach ( var filePath in files )
7270 {
73- Console . WriteLine ( $ "Skipping unsupported file type: { filePath } ") ;
74- continue ;
75- }
76-
77- var baseName = Path . GetFileNameWithoutExtension ( filePath ) ;
78- var outputPath = Path . Combine ( trapDir , baseName + ".trap" ) ;
79-
80- Console . WriteLine ( $ "Extracting: { filePath } ") ;
81-
82- try
83- {
84- using var trapWriter = new TrapWriter ( outputPath ) ;
85- var extractor = new JvmExtractor ( trapWriter ) ;
86- extractor . Extract ( filePath ) ;
87-
88- // Copy to source archive
89- ArchiveFile ( filePath , sourceArchiveDir ) ;
90-
91- successCount ++ ;
92- Console . WriteLine ( $ " -> { outputPath } ") ;
93- }
94- catch ( Exception ex )
95- {
96- Console . Error . WriteLine ( $ "Error extracting { filePath } : { ex . Message } ") ;
97- Console . Error . WriteLine ( ex . StackTrace ) ;
98- errorCount ++ ;
71+ if ( ! File . Exists ( filePath ) )
72+ {
73+ Console . WriteLine ( $ "Warning: File does not exist: { filePath } ") ;
74+ errorCount ++ ;
75+ continue ;
76+ }
77+
78+ var extension = Path . GetExtension ( filePath ) ;
79+ if ( ! AllowedExtensions . Contains ( extension ) )
80+ {
81+ Console . WriteLine ( $ "Skipping unsupported file type: { filePath } ") ;
82+ continue ;
83+ }
84+
85+ Console . WriteLine ( $ "Extracting: { filePath } ") ;
86+
87+ try
88+ {
89+ extractor . Extract ( filePath ) ;
90+
91+ // Copy to source archive
92+ ArchiveFile ( filePath , sourceArchiveDir ) ;
93+
94+ successCount ++ ;
95+ }
96+ catch ( Exception ex )
97+ {
98+ Console . Error . WriteLine ( $ "Error extracting { filePath } : { ex . Message } ") ;
99+ Console . Error . WriteLine ( ex . StackTrace ) ;
100+ errorCount ++ ;
101+ }
99102 }
100103 }
101-
104+
105+ Console . WriteLine ( $ " -> { outputPath } ") ;
102106 Console . WriteLine ( $ "\n Extraction complete: { successCount } succeeded, { errorCount } failed") ;
103107 return errorCount > 0 ? 1 : 0 ;
104108 }
0 commit comments