Skip to content

Java: model top JDK APIs#11779

Merged
jcogs33 merged 41 commits into
github:mainfrom
jcogs33:jcogs33/model-more-top-jdk-apis
Jan 17, 2023
Merged

Java: model top JDK APIs#11779
jcogs33 merged 41 commits into
github:mainfrom
jcogs33:jcogs33/model-more-top-jdk-apis

Conversation

@jcogs33
Copy link
Copy Markdown
Contributor

@jcogs33 jcogs33 commented Dec 21, 2022

Description:

This PR adds missing MaD models for the next 100 top JDK APIs. (The first 100 were reviewed and modeled in #11572).

Consideration:

Please review the added models in detail, especially the following:

  • Why does java.lang.String#endsWith have an existing summary model instead of a neutral model? It returns a boolean, so I thought it should have a neutral model. Should I leave this one as a summary model or switch it to a neutral model?
  • Does the model for java.lang.System#getProperty(String) look correct? I couldn't seem to get a working test case for this one.
  • Should any of the following be summary models instead of neutrals?
    • java.lang.Class#getClassLoader()
    • java.text.DateFormat#format(Date)
    • java.text.SimpleDateFormat#SimpleDateFormat(String)
    • java.time.LocalDate#of(int,int,int)
    • java.util.function.Consumer#accept(Object)
    • java.util.Date#Date(long)
    • java.util.stream.Collectors#joining(CharSequence)
    • java.util.stream.Collectors#toMap(Function,Function)

@github-actions github-actions Bot added the Java label Dec 21, 2022
@jcogs33 jcogs33 marked this pull request as ready for review January 3, 2023 22:23
@jcogs33 jcogs33 requested a review from a team as a code owner January 3, 2023 22:23
Comment thread java/ql/lib/ext/java.lang.model.yml Outdated
Copy link
Copy Markdown
Contributor

@egregius313 egregius313 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I can approve once we get an answer about the endsWith row.

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
+    Java Standard Library,``java.*``,3,615,130,28,,,7,,,10
-    Totals,,217,8449,1563,129,6,10,107,33,1,86
+    Totals,,217,8462,1563,129,6,10,107,33,1,86
  • Changes to framework-coverage-java.csv:
- java.io,37,,40,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,40,
+ java.io,37,,42,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,41,1
- java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.lang,13,,80,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,53,27
- java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,
+ java.sql,11,,2,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,1
- java.util,44,,461,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,36,425
+ java.util,44,,467,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,39,428

@jcogs33
Copy link
Copy Markdown
Contributor Author

jcogs33 commented Jan 12, 2023

Thanks all! I've switched the numeric flow models to neutrals in 6bb865a. Let me know if you want any changes to how I stored/commented them.

We'll then probably need to do the same for numeric flow models added in the previous PR, for consistency.

I updated all of the numeric flow models from the previous PR as well (java.lang.Integer#parseInt(String), java.lang.String#valueOf(int), java.math.BigDecimal#BigDecimal(String)).

java.util.function.Consumer#accept(Object)
This is related to specialized lambda flow, so I don't think it should be handled by MaD.

@atorralba Should java.util.function.Function#apply(Object) not be handled by MaD either? I had added a model for it but am now questioning whether it should be added since it is also related to lambda flow.

@atorralba
Copy link
Copy Markdown
Contributor

@atorralba Should java.util.function.Function#apply(Object) not be handled by MaD either? I had added a model for it but am now questioning whether it should be added since it is also related to lambda flow.

Yes, without knowledge of what the function does, assuming that flow is propagated from arg0 to return value is too "greedy" and prone to FP, I think. Doing that with precision requires analyzing the code of the function itself, and building the dataflow graph accordingly (which, if I'm not mistaken, the existing lambda flow support already does, at least in some cases).

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
+    Java Standard Library,``java.*``,3,614,130,28,,,7,,,10
-    Totals,,217,8449,1563,129,6,10,107,33,1,86
+    Totals,,217,8461,1563,129,6,10,107,33,1,86
  • Changes to framework-coverage-java.csv:
- java.io,37,,40,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,40,
+ java.io,37,,42,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,41,1
- java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.lang,13,,80,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,53,27
- java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,
+ java.sql,11,,2,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,1
- java.util,44,,461,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,36,425
+ java.util,44,,466,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,38,428

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
+    Java Standard Library,``java.*``,3,613,130,28,,,7,,,10
-    Totals,,217,8449,1563,129,6,10,107,33,1,86
+    Totals,,217,8460,1563,129,6,10,107,33,1,86
  • Changes to framework-coverage-java.csv:
- java.io,37,,40,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,40,
+ java.io,37,,42,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,41,1
- java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.lang,13,,80,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,53,27
- java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,
+ java.sql,11,,2,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,1
- java.util,44,,461,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,36,425
+ java.util,44,,465,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,38,427

Comment thread java/ql/lib/ext/java.util.model.yml Outdated
Comment thread java/ql/lib/ext/java.util.model.yml Outdated
michaelnebel
michaelnebel previously approved these changes Jan 13, 2023
Copy link
Copy Markdown
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!
Minor: Added a comment about List.clear and Map.clear.

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
+    Java Standard Library,``java.*``,3,613,130,28,,,7,,,10
-    Totals,,217,8449,1563,129,6,10,107,33,1,86
+    Totals,,217,8460,1563,129,6,10,107,33,1,86
  • Changes to framework-coverage-java.csv:
- java.io,37,,40,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,40,
+ java.io,37,,42,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,41,1
- java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.lang,13,,80,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,53,27
- java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,
+ java.sql,11,,2,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,1
- java.util,44,,461,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,36,425
+ java.util,44,,465,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,38,427

michaelnebel
michaelnebel previously approved these changes Jan 16, 2023
Copy link
Copy Markdown
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread java/ql/lib/ext/java.lang.model.yml Outdated
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ The head of this PR and the base branch were compared for differences in the framework coverage reports. The generated reports are available in the artifacts of this workflow run. The differences will be picked up by the nightly job after the PR gets merged.

Click to show differences in coverage

java

Generated file changes for java

  • Changes to framework-coverage-java.rst:
-    Java Standard Library,``java.*``,3,602,130,28,,,7,,,10
+    Java Standard Library,``java.*``,3,609,130,28,,,7,,,10
-    Totals,,217,8449,1563,129,6,10,107,33,1,86
+    Totals,,217,8456,1563,129,6,10,107,33,1,86
  • Changes to framework-coverage-java.csv:
- java.io,37,,40,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,40,
+ java.io,37,,42,,15,,,,,,,,,,,,,,,,,,,,,,,,,,,22,,,,,,,,41,1
- java.lang,13,,75,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,56,19
+ java.lang,13,,76,,,,,,,,,,,,8,,,,,,4,,,1,,,,,,,,,,,,,,,,53,23
- java.math,,,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1,
- java.sql,11,,1,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,
+ java.sql,11,,2,,,,,,,,4,,,,,,,,,,,,,,,,,7,,,,,,,,,,,,1,1
- java.util,44,,461,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,36,425
+ java.util,44,,465,,,,,,,,,,,,34,,,,,,,5,2,,1,2,,,,,,,,,,,,,,38,427

Copy link
Copy Markdown
Contributor

@atorralba atorralba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the effort! 🙏

@jcogs33 jcogs33 merged commit babdee3 into github:main Jan 17, 2023
@jcogs33 jcogs33 deleted the jcogs33/model-more-top-jdk-apis branch January 17, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants