2

I scanned my Java code base with jqassistant into a neo4j library, and I'd like to get all calls (also transitive) to a certain method methodname. I guess it something like this:

MATCH
  (c:Class)-[:DECLARES]-(m:Method)-[:INVOKES*0..]-
  (v:Method {signature: 'javax.path methodname(argument)'})
RETURN DISTINCT c.fqn, m.name, m.signature

Currently, it doesn't seem like the answer is really complete. I only get methods from the same class as methodname, where it is direct calls to the method.

What is the correct syntax?

Gabor Szarnyas
  • 4,410
  • 3
  • 18
  • 42
user857990
  • 1,140
  • 3
  • 14
  • 29
  • 1
    The syntax looks correct to me but the relations should be directed. If you don't see all expected callers there might be issues regarding to either 1. Inheritance: If a caller invokes an abstract method in a super class the scanned graph will not contain relations to implementations of this method. 2. Artifact boundaries: During scan invocations are only resolved between classes within the same artifact. For both cases there are concepts (i.e. pre-defined queries) available that try to resolve relations. Are you scanning the CLI or Maven plugin? – Dirk Mahler Jan 15 '18 at 14:32
  • Yep, tried it too and works like expected - at least after I made the lines to arrows, e.g. (c:Class)-[:DECLARES]->(m:Method) – Jens Nerche Jan 17 '18 at 13:18
  • @DirkMahler I have simplified the Syntax to `MATCH (m:Method)-[:INVOKES*0..]->(v:Method {signature: 'sig'}) RETURN [(m)-->(v)]` and that corrects indeed that one little mistake, but I assume the issue is more on the inheritence or artifact boundaries level. `./bin/jqassistant.sh scan -f ~/external/software/software-core/target/ ./bin/jqassistant.sh scan -f ~/external/software/software-core/target/lib/` How would I have to invoke it correctly? – user857990 Jan 22 '18 at 09:18
  • Ok, you're using the CLI. Can you try to run "jqassistant.sh analyze -concepts classpath:Resolve", try your query again and see if the result has changed? – Dirk Mahler Jan 23 '18 at 15:24
  • Nothing changed, but the command failed. So no surprise. The errors look all roughly like this: `[ Concept Application Failure ]` `2018-01-24 09:20:09.260 [main] WARN AbstractAnalyzeTask - Concept: classpath:ResolveImplements` – user857990 Jan 24 '18 at 08:26
  • Hm, difficult... Did the command really fail (showing an execption) or were just warnings that concepts could not be applied? What do the scanned folders contain: Java classes or JAR/WAR files? – Dirk Mahler Jan 24 '18 at 16:11
  • It was only warnings as shown above. The folders contained the jar files. I tried again with a clean setup, and instead of compiling the jars myself got myself the already built jars. It still never found more connections. Is INVOKE the right connection between two methods? – user857990 Feb 07 '18 at 11:12
  • My bad, if I return the value from the question, I now get more. *ooff*, but not with `[(m)-->(v)]`. Also I am still surprised, how short the list is (since it is open ended, I would have expected to find the source at some point. What I do have is the sink function. – user857990 Feb 07 '18 at 11:20
  • Those newly found methods, are more steps away, but are all from the same class. I hasn't found any method from another class calling those methods, calling `v`. – user857990 Feb 07 '18 at 12:40

0 Answers0