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

assume unfound classes to be in the same package as the current class #57

Merged
merged 6 commits into from
Nov 29, 2023

Conversation

LoiNguyenCS
Copy link
Collaborator

No description provided.

@LoiNguyenCS
Copy link
Collaborator Author

Professor,

This is the PR to fix #49 and #48.

For classes that could not be found among import statements, instead of throwing an exception, Specimin will now assume those classes to be in the same package as the current class.

@LoiNguyenCS LoiNguyenCS requested a review from kelloggm November 28, 2023 00:41
@tahiat tahiat self-requested a review November 28, 2023 03:12
@tahiat
Copy link
Collaborator

tahiat commented Nov 28, 2023

LGTM

@LoiNguyenCS
Copy link
Collaborator Author

Professor, I have updated the codes.

@LoiNguyenCS LoiNguyenCS requested a review from kelloggm November 28, 2023 15:58
// package as the current class
String packageName = classAndPackageMap.getOrDefault(type, currentPackage);
UnsolvedClass newClass = new UnsolvedClass(type, packageName);
newClass.addMethod(creationMethod);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This code should also call createUnsolvedClass (and then call addMethod on the result)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as we've added updateMissingClass to the updateUnsolvedClass method, I think we can't call updateUnsolvedClass here because we need to add the method to the UnsolvedClass instance before updating the list of missing classes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we need to add the method to the UnsolvedClass instance before updating the list of missing classes

Why? The pointer is still valid, and I don't think there's any reason to believe that any computation will be done with the list of missing classes before the call to addMethod is executed (assuming a sequential Java semantics, but I'm okay with that assumption here given the way the JVM works).

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, I am wrong: updateMissingClass does more computation than I expected. I was incorrectly thinking that it just updates a data structure; it also does computation over the list of methods.

Can you modify updateUnsolvedClass to take a varargs array of methods and add them all to the class before it calls updateMissingClass?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Professor, I'm afraid that might make updateUnsolvedClass more complicated than it should be. The reason is that it will require an additional array as an argument whenever it is called, even if there is no methods added (such as in line 529 and 674). And even at line 704, while there is a method added, there is only one method added. So modifying updateUnsolvedClass to take an array of methods as an argument seems to be unnecessary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

it will require an additional array as an argument whenever it is called

It will not, if you use the varargs feature as I suggested. It is designed for exactly this situation, and the resulting code should be simpler than what you currently have.

@LoiNguyenCS
Copy link
Collaborator Author

Professor,

I have updated the codes based on your suggestions. Please take a look.

Copy link
Collaborator

@kelloggm kelloggm left a comment

Choose a reason for hiding this comment

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

I implemented my suggestion. I think this is ready to merge, but I'd like @LoiNguyenCS to take one more look. Please do, and then if this looks good to you please merge.

Copy link
Collaborator Author

@LoiNguyenCS LoiNguyenCS left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you

@LoiNguyenCS LoiNguyenCS merged commit 54b1c2d into njit-jerse:main Nov 29, 2023
1 check passed
@LoiNguyenCS LoiNguyenCS deleted the remove-exception branch November 29, 2023 14:37
This was referenced Nov 29, 2023
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.

3 participants