Skip to content

Fix issue 97, 95, 93, 84, 39 #96

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

Merged
merged 11 commits into from
Jan 24, 2025
Merged

Fix issue 97, 95, 93, 84, 39 #96

merged 11 commits into from
Jan 24, 2025

Conversation

rahlk
Copy link
Collaborator

@rahlk rahlk commented Jan 22, 2025

The Problem: The error seems to come from a unique situation wherein, mvnw is corrupt and therefore the dependencies are not downloaded. Then, when we use analysis level 2, WALA is unable to resolve any super classes of the two servlet classes.

The fix: First, we ensure that if ./mvnw is corrupt, then ensure we use mvn (which we weren't correctly doing); next, use makeWithRoot(...) to create WALA analysis scope which will assume all classes inherit from java.lang.Object.

This PR also creates a number of integration tests that uses TestContainers to emulate various usage scenarios of maven, gradle, etc. As requested in issue #84.

This PR also fixes issue #97 where we look recursively for jmods folder given JAVA_HOME:

  private static Path getJmodsPath() {
    try {
      try (Stream<Path> paths = Files.walk(Path.of(System.getenv("JAVA_HOME")), Integer.MAX_VALUE, FileVisitOption.FOLLOW_LINKS)) {
        return paths
                .filter(path -> path.getFileName().toString().equals("jmods"))
                .findFirst()
                .orElseThrow(() -> new RuntimeException("jmods directory not found in " + System.getenv("JAVA_HOME")));
      }
    } catch (IOException e) {
      throw new RuntimeException("Error searching for jmods directory", e);
    }
  }

rahlk added 5 commits January 21, 2025 20:16
…> makeWithRoot to build even when dependencies are missing.

Add test containers to test build and add integration tests.

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
…> makeWithRoot to build even when dependencies are missing. Add Integration Tests.

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
…> makeWithRoot to build even when dependencies are missing. Add Integration Tests.

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
@rahlk rahlk marked this pull request as draft January 22, 2025 11:20
@rahlk rahlk requested a review from sinha108 January 22, 2025 11:21
rahlk added 2 commits January 22, 2025 13:45
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
@rahlk rahlk marked this pull request as ready for review January 22, 2025 15:43
rahlk added 2 commits January 23, 2025 10:40
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
@rahlk rahlk requested a review from rofrano January 23, 2025 16:16
@scottkurz
Copy link
Collaborator

The Problem: The error seems to come from a unique situation wherein, mvnw is corrupt and therefore the dependencies are not downloaded. Then, when we use analysis level 2, WALA is unable to resolve any super classes of the two servlet classes.

In reading #95, I noticed it says the problem occurs only when using mvn and goes away when mvnw is used.

rahlk added 2 commits January 24, 2025 12:49
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
…arch seeded at the JAVA_HOME directory to look for a folder.

Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
@rahlk
Copy link
Collaborator Author

rahlk commented Jan 24, 2025

The Problem: The error seems to come from a unique situation wherein, mvnw is corrupt and therefore the dependencies are not downloaded. Then, when we use analysis level 2, WALA is unable to resolve any super classes of the two servlet classes.

In reading #95, I noticed it says the problem occurs only when using mvn and goes away when mvnw is used.

Yeah, either way if the dependencies are ignored WALA is looking for a javax.*.Servlet superclass which can't be found. So, using makeWithRoot will assume that if no superclass dependencies are found then assume (correctly so) that java.lang.Object is the superclass instead of failing.

@rahlk rahlk requested a review from scottkurz January 24, 2025 19:03
Copy link
Collaborator

@rofrano rofrano left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@rofrano rofrano merged commit 2abc7d8 into 1.X.X Jan 24, 2025
1 check passed
@rofrano rofrano deleted the fix-issue-95 branch January 24, 2025 19:13
@rahlk rahlk changed the title Fix issue 95 Fix issue 97, 95, 93, 84, 39 Jan 24, 2025
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