gnodet commented on PR #1165:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/1165#issuecomment-7394852343

   _Claude Code on behalf of Guillaume Nodet_
   
   **Missing SourceFile attribute fallback**: `collectClassAnalyses()` relies 
on the SourceFile attribute to match class files to source files. If a class 
file lacks this attribute (can happen with synthetic classes or bytecode 
generated by tools), `sourceFileName()` returns empty string and the class is 
omitted from dependency tracking.
   
   **Scenario**:
   - Annotation processor generates `FooGenerated.class` without SourceFile 
attribute
   - `BytecodeAnalyzer.analyze()` returns `sourceFileName=''`
   - Check `'Model.java'.equals('')` fails
   - Class not added to `classFileCache`
   - Type `FooGenerated` not tracked in incremental state
   - Consumers of `FooGenerated` not recompiled when it changes
   
   **Fix**: Fall back to inferring source file from class name:
   ```java
   String sourceFile = a.sourceFileName();
   if (sourceFile.isEmpty()) {
       // Infer from class name: com.example.Foo → Foo.java
       String simpleName = 
qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
       simpleName = simpleName.split("\\$")[0]; // Strip inner class suffix
       sourceFile = simpleName + ".java";
   }
   if (simpleSourceName.equals(sourceFile)) {
       // ... proceed
   }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to