elharo opened a new issue, #283:
URL: https://github.com/apache/maven-dependency-analyzer/issues/283

   ## Bug Description
   
   In `DefaultMethodVisitor.java:148`, `visitInvokeDynamicInsn` processes 
`bootstrapMethodArguments` but only filters for `Type` instances:
   
   ```java
   Arrays.stream(bootstrapMethodArguments)
           .filter(Type.class::isInstance)
           .map(Type.class::cast)
           .forEach(t -> resultCollector.addType(usedByClass, t));
   ```
   
   Bootstrap arguments can also be `Handle` instances (common for lambda method 
references). Each `Handle` has a `getOwner()` method returning the internal 
name of the owning class (e.g., `"com/example/CustomClass"`), but this is never 
recorded.
   
   For example, for `list.stream().map(CustomClass::getField)`:
   - The invokedynamic instruction has a `Handle` bootstrap argument pointing 
to `CustomClass.getField()`
   - `Handle.getOwner()` returns `"com/example/CustomClass"`
   - This class reference is never recorded as a dependency
   
   ## Impact
   
   Method references (`::`) to user-defined classes in streams, optionals, or 
any lambda context will miss the dependency on the target class's artifact. 
Since lambdas and method references are pervasive in Java 8+ code, this causes 
frequent false negatives in dependency detection.
   
   ## Suggested Fix
   
   Add `Handle.getOwner()` to the result collector alongside the existing 
`Type` processing:
   
   ```java
   resultCollector.addName(usedByClass, bootstrapMethodHandle.getOwner());
   ```


-- 
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