Skip to content

Commit b2e8167

Browse files
authored
Merge pull request github#13587 from github/koesie10/update-java-external-api-name
Java: Fix external API name for nested types
2 parents 1f4af5f + 6806b87 commit b2e8167

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

java/ql/src/Telemetry/ExternalApi.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ class ExternalApi extends Callable {
2727
*/
2828
string getApiName() {
2929
result =
30-
this.getDeclaringType().getPackage() + "." + this.getDeclaringType().getSourceDeclaration() +
31-
"#" + this.getName() + paramsString(this)
30+
this.getDeclaringType().getPackage() + "." +
31+
this.getDeclaringType().getSourceDeclaration().nestedName() + "#" + this.getName() +
32+
paramsString(this)
3233
}
3334

3435
private string getJarName() {

java/ql/test/query-tests/Telemetry/SupportedExternalApis/SupportedExternalApis.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@
77
| java.net.URL#openStream() | 1 |
88
| java.net.URLConnection#getInputStream() | 1 |
99
| java.time.Duration#ofMillis(long) | 1 |
10+
| java.util.Iterator#next() | 1 |
11+
| java.util.Map#entrySet() | 1 |
1012
| java.util.Map#put(Object,Object) | 1 |
13+
| java.util.Map$Entry#getKey() | 1 |
14+
| java.util.Set#iterator() | 1 |
1115
| org.apache.commons.io.FileUtils#deleteDirectory(File) | 1 |

java/ql/test/query-tests/Telemetry/SupportedExternalApis/SupportedExternalApis.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static void main(String[] args) throws Exception {
1515

1616
Map<String, Object> map = new HashMap<>(); // uninteresting (parameterless constructor)
1717
map.put("foo", new Object()); // supported summary
18+
map.entrySet().iterator().next().getKey(); // nested class (Map.Entry), supported summaries (entrySet, iterator, next, getKey)
1819

1920
Duration d = java.time.Duration.ofMillis(1000); // supported neutral
2021

0 commit comments

Comments
 (0)