Skip to content

Commit fab7780

Browse files
committed
fix(bench): anchor buildClassFileMap regex to line start to avoid false Javadoc matches
1 parent a9f5ee1 commit fab7780

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

scripts/compare-javacg.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ function buildClassFileMap(fixtureDir) {
7979
const javaFiles = fs.readdirSync(fixtureDir).filter((f) => f.endsWith('.java'));
8080
for (const filename of javaFiles) {
8181
const src = fs.readFileSync(path.join(fixtureDir, filename), 'utf8');
82-
// Match any combination of access/modifier keywords before the type keyword
82+
// Match any combination of access/modifier keywords before the type keyword.
83+
// Anchored to line start (^…/m) so Javadoc comments containing the word
84+
// "class" before the actual declaration don't produce a false match.
8385
const m = src.match(
84-
/(?:(?:public|protected|private|abstract|final|sealed|non-sealed|strictfp)\s+)*(?:class|interface|enum|record)\s+(\w+)/,
86+
/^(?:(?:public|protected|private|abstract|final|sealed|non-sealed|strictfp)\s+)*(?:class|interface|enum|record)\s+(\w+)/m,
8587
);
8688
if (m) {
8789
map.set(m[1], filename);

0 commit comments

Comments
 (0)