MethodMatcher not finding methods from all Types

java

(Benjamin Kohler) #1

I am extending AbstractMethodDetection and in getMethodInvocationMatchers() I have:

return Arrays.asList(MethodMatcher.create()
  .typeDefinition(TypeCriteria.anyType())
  .name("equals")
  .withAnyParameters());

I wrote this for testing purposes because it wasn’t finding my methods.

I have found that this line hits on something like java.lang.String calls to equals(Object), but not on for example, org.apache.hadoop.io.Text calls to equals(Object).

Any idea what is going on here?


(Michael Gumowski) #2

Hello,

Are you providing the bytecode of the org.apache.hadoop.io.Text class to your test? If the bytecode of all your dependencies used in your test file is not provided, the semantic engine won’t be able to resolve the method. Consequently, the MethodMatcher won’t trigger.

Cheers,
Michael


(Benjamin Kohler) #3

I think I am providing the bytecode.
I am passing a List of jar Files to the verifier that are all located in the target/dependency directory.

I do get a warning when I run the unit test that some classes were not found during the analysis (even though containing jar files are in the target/dependency directory), however, Text is not one of the listed missing classes.


(Michael Gumowski) #4

Hello @bkohler13,

Sorry for the very late ping. Did you solve the issue with the MethodMatchers?
If it’s the case I would be curious to know how (if you remember).

Regards,
Michael


(Benjamin Kohler) #5

Hey @Michael,

I did get this working. I don’t remember exactly where I was at with this when I asked the question, but it was definitely related to providing the bytecode of the libraries properly.

One I had everything passed to the maven-dependency-plugin properly using artifactItems in the pom, it all worked out.

Thanks for checking in!
Ben