The Wayback Machine - https://web.archive.org/web/20211003213817/https://github.com/github/codeql/pull/6770
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: Add models for java.util.stream. #6770

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

@aschackmull
Copy link
Contributor

@aschackmull aschackmull commented Sep 28, 2021

The (important) method collect(Collector<T,A,R> collector) is unfortunately not supported yet - left as follow-up work.

@github-actions github-actions bot added the Java label Sep 28, 2021
"java.util.stream;Stream;false;sorted;(Comparator);;Element of Argument[-1];Parameter[0..1] of Argument[0];value",
"java.util.stream;Stream;false;takeWhile;(Predicate);;Element of Argument[-1];Parameter[0] of Argument[0];value",
"java.util.stream;Stream;false;takeWhile;(Predicate);;Element of Argument[-1];Element of ReturnValue;value",
"java.util.stream;Stream;false;toArray;;;Element of Argument[-1];ArrayElement of ReturnValue;value"
Copy link
Contributor

@intrigus-lgtm intrigus-lgtm Sep 28, 2021

This is missing Stream#toList?
There are also the new mapMulti methods added in Java 16.

Copy link
Contributor Author

@aschackmull aschackmull Sep 29, 2021

Thanks, yes, I missed those. I'll add them.

"java.util.stream;BaseStream;false;iterator;();;Element of Argument[-1];Element of ReturnValue;value",
"java.util.stream;BaseStream;false;onClose;(Runnable);;Element of Argument[-1];Element of ReturnValue;value",
"java.util.stream;BaseStream;false;parallel;();;Element of Argument[-1];Element of ReturnValue;value",
"java.util.stream;BaseStream;false;sequential;();;Element of Argument[-1];Element of ReturnValue;value",
"java.util.stream;BaseStream;false;spliterator;();;Element of Argument[-1];Element of ReturnValue;value",
"java.util.stream;BaseStream;false;unordered;();;Element of Argument[-1];Element of ReturnValue;value",
Copy link
Contributor

@Marcono1234 Marcono1234 Sep 28, 2021

Shouldn't those consider subtypes? DoubleStream, IntStream and LongStream seem to override some of these methods.

Also, is subtypes=true needed to consider parameterized types of these generic types?

Copy link
Contributor Author

@aschackmull aschackmull Sep 29, 2021

subtypes is actually a bad name for this column - overrides is the better name. The confusion between the two names is due to a change in the interpretation of the column that was actually a bug fix. Parameterized types shouldn't be an issue and doesn't need overrides=true, but you are right that we'll likely want to include overrides here when there indeed are relevant overridden methods to consider. Thanks.

@aschackmull
Copy link
Contributor Author

@aschackmull aschackmull commented Sep 30, 2021

The mapMulti methods are too complex to fully handle with our current method body synthesis. The full model would look something like

        Element of Argument[-1] -> Parameter[0] of Argument[0]
        Argument[0] of Parameter[1] of Argument[0] -> Element of Parameter[1] of Argument[0]
        Element of Parameter[1] of Argument[0] -> Element of ReturnValue

which should then synthesise

        mapMulti(mapper) {
          elm = this.elem
          cons = new Consumer {
            retelem
            apply(x) { this.retelem = x }
          }
          mapper(elm, cons)
          //stream = ...
          stream.elem = cons.retelem
          return stream
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants