-
Notifications
You must be signed in to change notification settings - Fork 348
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
Add whole-program inference mode using stub files instead of jaif files #2871
Conversation
I think I fixed this. Can you double check the diffs? |
Yes, that works now. Thanks, I appreciate it. It looks like some of the all-systems tests are failing; I'll look into that and then re-assign you when tests are passing for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked at all the code yet. Could you please add a comment for every method, even private ones?
import scenelib.annotations.util.Strings; | ||
|
||
/** | ||
* SceneToStubWriter provides two static methods named <code>write</code> that write a given {@link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use {@code }
instead of the html tag.
...ework/src/main/java/org/checkerframework/common/wholeprograminference/SceneToStubWriter.java
Outdated
Show resolved
Hide resolved
// do so is here. | ||
wholeProgramInference.saveResults(); | ||
WholeProgramInference.OutputKind outputKind = | ||
checker.hasOption("outputStubs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change -AoutputStubs
to -Ainfer=stubs
. Then this would be checker.getOption("infer").equals("stubs")
. That makes documenting this option easier.
AnnotatedTypeMirror stubType = stubTypes.getAnnotatedTypeMirror(elt); | ||
// This is a bit of a hack - need to decide if the annotated type mirror | ||
// contains ANY annotations - i.e. on deep types, method params, etc. | ||
boolean stubTypeHasAnAnnotation = stubType != null && stubType.toString().contains("@"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with a TypeScanner:
new SimpleAnnotatedTypeScanner<Boolean, Void>() {
@Override
protected Boolean defaultAction(AnnotatedTypeMirror type, Void aVoid) {
return type.getAnnotations().isEmpty();
}
@Override
protected Boolean reduce(Boolean r1, Boolean r2) {
r1 = r1 == null ? false : r1;
r2 = r2 == null ? false : r2;
return r1 || r2;
}
};
I've added javadoc to all the methods and fields, even the private ones, and made the changes @smillst suggested (with one exception: I was able to avoid the need to scan for the presence of annotations in general, so I could remove the ugly string hack entirely without replacing it with a |
...k/src/main/java/org/checkerframework/common/wholeprograminference/WholeProgramInference.java
Outdated
Show resolved
Hide resolved
...ework/src/main/java/org/checkerframework/common/wholeprograminference/SceneToStubWriter.java
Outdated
Show resolved
Hide resolved
...main/java/org/checkerframework/common/wholeprograminference/WholeProgramInferenceScenes.java
Outdated
Show resolved
Hide resolved
...ava/org/checkerframework/common/wholeprograminference/WholeProgramInferenceScenesHelper.java
Outdated
Show resolved
Hide resolved
...ava/org/checkerframework/common/wholeprograminference/WholeProgramInferenceScenesHelper.java
Outdated
Show resolved
Hide resolved
...ava/org/checkerframework/common/wholeprograminference/WholeProgramInferenceScenesHelper.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/framework/source/SourceChecker.java
Outdated
Show resolved
Hide resolved
@kelloggm Please update the pull request description to match the implementation. |
...ework/src/main/java/org/checkerframework/common/wholeprograminference/SceneToStubWriter.java
Outdated
Show resolved
Hide resolved
...ework/src/main/java/org/checkerframework/common/wholeprograminference/SceneToStubWriter.java
Outdated
Show resolved
Hide resolved
…move-ascenewrapper-remove-vivifyAnd into scene-to-stub-writer-remove-ascenewrapper-remove-vivifyAnd-2
…move-ascenewrapper-remove-vivifyAnd-2
…into scene-to-stub-writer-remove-aclasswrapper
…move-aclasswrapper into scene-to-stub-writer-remove-ascenewrapper
…move-ascenewrapper into scene-to-stub-writer-remove-ascenewrapper-remove-vivifyAnd
…move-ascenewrapper-remove-vivifyAnd into scene-to-stub-writer-remove-ascenewrapper-remove-vivifyAnd-2
…move-ascenewrapper into scene-to-stub-writer-remove-ascenewrapper-remove-vivifyAnd
…move-ascenewrapper-remove-vivifyAnd into scene-to-stub-writer-remove-ascenewrapper-remove-vivifyAnd-2
…into scene-to-stub-writer-remove-ascenewrapper
This PR adds a command-line options to support using .astub files as the output of whole-program inference instead of .jaif files, and permits
-Ainfer
to take an argument:-AmergeStubsWithSource
causes stub types to be used, even when source files are available; the stronger type from the two is used.For now, there is scant documentation on
-Ainfer=stubs
, because there is no practical way for a user to make use of it (for now). This is because the manual only describes how to run whole-program inference via theinfer-and-annotate.sh
script, which is not practical for large programs. Providing a version ofinfer-and-annotate.sh
that uses stubs (or something more scalable) is explicitly future work for this PR.The stub mode of WPI is tested with the same tests that the
.jaif
version of whole-program inference uses. Those tests also implicitly test-AmergeStubsWithSource
, because it's not possible to overwrite (a lack of) annotations in source files otherwise.Merge together with typetools/annotation-tools#279