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

Preserve annotations #72

Merged
merged 13 commits into from
Jan 22, 2024
Merged

Conversation

LoiNguyenCS
Copy link
Collaborator

This PR is falling right now because javac requires the class files of annotations in order for the input program to compile successfully.

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.

As we discussed in our meeting this morning, this PR needs to be modified. I think we should adopt the following strategy for annotations:

  • as input, we should take a jar file containing annotation definitions that Specimin should preserve. We should test this using the CF's checker-qual.jar file (that is, the jar file that we expect users will put on their classpath so that they can preserve annotations in the bytecode)
  • for any annotation that we encounter, we should preserve it if and only if it is either 1) solvable with the input source files/classpath, or 2) solvable using the jar file(s) provided in the previous step

We should also consider the case of Lombok and other tools that generate new code based on annotations, which makes this much trickier. We probably want to delombok code before passing it to Specimin in the general case. I don't think this PR needs to solve the Lombok problem, but I wanted to bring it up now @LoiNguyenCS since eventually we probably will encounter code that uses Lombok.

@LoiNguyenCS
Copy link
Collaborator Author

Professor, I have updated the codes.

In this current version of Specimin, the jar files used by annotations will be included in the final output.

Please take a look.

@LoiNguyenCS LoiNguyenCS requested a review from kelloggm December 28, 2023 01:43
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.

@LoiNguyenCS I made a number of changes to try to simplify this PR. I think it is ready to merge, but you should re-review it before we do (this can wait until you are back from your vacation).

"removeunsolvedannotations",
new String[] {"com/example/Simple.java"},
new String[] {"com.example.Simple#baz()"},
new String[] {"src/test/resources/removeunsolvedannotations/input/checker-qual-3.42.0.jar"});
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should only need one copy of this jar file in the repo (if we need it at all - we could ask Gradle to fetch it for us from Maven, instead). Each test should not require its own copy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This file should not be copied into the output.

@@ -14,7 +14,7 @@ for testcase in * ; do
cd "${testcase}/expected/" || exit 1
# javac relies on word splitting
# shellcheck disable=SC2046
javac -proc:only -nowarn $(find . -name "*.java") \
javac -proc:only -nowarn -classpath *.jar $(find . -name "*.java") \
Copy link
Collaborator

Choose a reason for hiding this comment

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

If there is only one copy of checker-qual.jar, then this doesn't need a *

@LoiNguyenCS
Copy link
Collaborator Author

LGTM.

@LoiNguyenCS LoiNguyenCS merged commit c7bb1ec into njit-jerse:main Jan 22, 2024
1 check passed
@LoiNguyenCS LoiNguyenCS deleted the add-annotations branch January 22, 2024 13:28
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.

2 participants