Java: Update the comments in SupportedExternalApis to include the neutral kind and add a sink neutral example.

This commit is contained in:
Michael Nebel 2023-06-12 11:08:32 +02:00
Родитель 71a36fcf0f
Коммит 6deeb36a97
2 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -17,7 +17,7 @@ class SupportedExternalApis {
map.put("foo", new Object()); // supported summary
map.entrySet().iterator().next().getKey(); // nested class (Map.Entry), supported summaries (entrySet, iterator, next, getKey)
Duration d = java.time.Duration.ofMillis(1000); // supported neutral
Duration d = java.time.Duration.ofMillis(1000); // supported neutral summary
URL github = new URL("https://www.github.com/"); // supported summary
InputStream stream = github.openConnection().getInputStream(); // supported source (getInputStream), supported sink (openConnection)
@ -25,6 +25,9 @@ class SupportedExternalApis {
new FileWriter(new File("foo")); // supported sink (FileWriter), supported summary (File)
new URL("http://foo").openStream(); // supported sink (openStream), supported summary (URL)
FileUtils.deleteDirectory(new File("foo")); // supported neutral (deleteDirectory), supported summary (File)
File file = new File("foo"); // supported summary (File)
FileUtils.deleteDirectory(file); // supported neutral summary (deleteDirectory)
file.compareTo(file); // supported neutral sink (compareTo)
}
}

Просмотреть файл

@ -11,15 +11,15 @@ class ExternalApiUsage {
Map<String, Object> map = new HashMap<>();
map.put("foo", new Object());
Duration d = java.time.Duration.ofMillis(1000); // supported as a neutral model
Duration d = java.time.Duration.ofMillis(1000); // supported as a neutral summary model
long l = "foo".length(); // supported as a neutral model
long l = "foo".length(); // supported as a neutral summary model
AtomicReference<String> ref = new AtomicReference<>(); // uninteresting (parameterless constructor)
ref.set("foo"); // supported as a summary model
ref.toString(); // not supported
String.class.isAssignableFrom(Object.class); // parameter with generic type, supported as a neutral model
String.class.isAssignableFrom(Object.class); // parameter with generic type, supported as a neutral summary model
System.out.println(d);
System.out.println(map);