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

Fix EISOP issue #321 #325

Merged
merged 13 commits into from
Sep 2, 2022
Merged

Fix EISOP issue #321 #325

merged 13 commits into from
Sep 2, 2022

Conversation

zcai1
Copy link
Collaborator

@zcai1 zcai1 commented Aug 18, 2022

This PR fixes #321 by preventing the parsing of multiple stub files for the same JDK class in the same round.

@zcai1 zcai1 changed the title Fix eisop issue 321 Fix eisop issue #321 Aug 18, 2022
Copy link
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

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

Thanks! I only have a few small comments.
We can ignore the daikon failure, it will go away when I update with the next typetools release.

*/
void preProcessTopLevelType(String typeName) {
boolean success = processingClasses.add(typeName);
assert success;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert success;
assert success : "type " + typeName + " is already being processed!";

Copy link
Member

Choose a reason for hiding this comment

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

Does the failure string make it clearer what is going wrong? Can you improve on it?
Instead of success, would changed be clearer?

Copy link
Member

Choose a reason for hiding this comment

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

I'm also wondering whether to throw a BugInCF instead of an assert - if you're worried that this could arise in a client configuration, the assert is likely not enabled and a BugInCF would ensure we raise an error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think added is more straightforward. I'm also using BugInCF now to ensure we always raise the error.

@@ -3119,16 +3149,27 @@ private void stubDebug(String warning) {
private class AjavaAnnotationCollectorVisitor extends DefaultJointVisitor {
@Override
public Void visitClass(ClassTree javacTree, Node javaParserNode) {
TypeDeclaration<?> typeDecl = (TypeDeclaration<?>) javaParserNode;
Copy link
Member

Choose a reason for hiding this comment

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

The old code guarded this cast by an instanceof. No test fails with a ClassCastException, but do you see any reason why the previous code used an instanceof?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, from its super implementation, it seems javaParserNode can have type of LocalClassDeclarationStmt or LocalRecordDeclarationStmt. These two types are not TypeDeclaration but wrappers for ClassOrInterfaceDeclaration and RecordDeclaration, which will be unwrapped by the call super.visitClass(...). So, I need to add the instanceof check back.

@wmdietl wmdietl assigned zcai1 and unassigned wmdietl Sep 1, 2022
Copy link
Member

@wmdietl wmdietl left a comment

Choose a reason for hiding this comment

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

Thanks, looks great!

@wmdietl wmdietl merged commit 918c374 into eisop:master Sep 2, 2022
@wmdietl wmdietl changed the title Fix eisop issue #321 Fix EISOP issue #321 Sep 2, 2022
@wmdietl
Copy link
Member

wmdietl commented Sep 2, 2022

@zcai1 Can you maybe make a PR to expand the changelog entry: e817511
Sorry, should have thought of that before merging...

@zcai1 zcai1 deleted the fix-eisop-issue-321 branch September 6, 2022 00:34
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.

Stub files can no longer undo the class @NonNull annotation on, e.g., Optional
2 participants