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

ConstraintManager source tree fix #137

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

ConstraintManager source tree fix #137

wants to merge 3 commits into from

Conversation

topnessman
Copy link
Member

visitorState.getPath().getLeaf() throw NullPointerException sometimes, and doesn't always return correct source tree location. Change to ClassTree as a temporary fix. There is an issue related to this: typetools#31

@@ -167,6 +165,17 @@ private AnnotationLocation getCurrentLocation() {
}
}

// visitorState.getPath().getLeaf() caused NullPointerException on some real project
// and doesn't always return correct source tree. Using class tree at least shows which
Copy link
Member

@CharlesZ-Chen CharlesZ-Chen Jan 23, 2018

Choose a reason for hiding this comment

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

  1. "Using class tree at least shows " is ambiguous -- i.e. the code in this function actually only use class tree when visitorState.getPath() is null.
    Maybe only add a code comment on the else branch to document using class tree is a workaround for when visitorState.getPath() is null?

  2. " and doesn't always return correct source tree": do you have minimum code example for that? Should this be an issue instead of a code comment?

Copy link
Member Author

@topnessman topnessman left a comment

Choose a reason for hiding this comment

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

pull in master

// visitorState.getPath().getLeaf() caused NullPointerException on some real project
// and doesn't always return correct source tree. Using class tree at least shows which
// Java source class there is such unsatisfiable error and also doesn't throw exception
private Tree getCurrentTreeLocation() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Add Javadoc

}

private AnnotationLocation getCurrentLocation() {
private AnnotationLocation getCurrentAnnotationLocation() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Javadoc

if (visitorState.getPath() != null) {
return visitorState.getPath().getLeaf();
} else {
return visitorState.getClassTree();
Copy link
Member Author

Choose a reason for hiding this comment

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

Add TODOs for both methods - why hitting this case(else branch)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Issue: find a minimum test case
Throw NPE in else branch, and find the project that causes exception.

@topnessman
Copy link
Member Author

Find which projects failed.

# Conflicts:
#	src/checkers/inference/model/ConstraintManager.java
@topnessman
Copy link
Member Author

Sorry I can't recall how I triggered the NPE at that time, but it should be the time when source code is pre-annotated, and the constraints cannot be satisfied before solver (AlwaysFalseConstraint). Maybe you can close this issue for now, and revisit the problem later in an ad-hoc way. I noticed in the latest master branch that source tree location will be passed from InferenceVIsitor instead of leveraging VisitorState, so might be not worthy to continue on this PR. The link is:

// TODO: forward error msg keys and nodes from InferenceVisitor to create a more

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

Successfully merging this pull request may close these issues.

4 participants