8000 Make JarTypeSolver and ReflectionTypeSolver a bit more versatile. by johanneskloos · Pull Request #4716 · javaparser/javaparser · GitHub
[go: up one dir, main page]

Skip to content

Conversation

johanneskloos
Copy link
Contributor

Two improvements to TypeSolver:

  • JarTypeSolver can now also resolves types that live in .class files hierarchies (think the output from javac), without packaging them in a jar file first.
  • ReflectionTypeSolver gets more flexible filtering; in particular, a pre-made filter is added for the entire Java Class Library.

…iles

Java class paths support loading .class files either from .jar files, or
from file hierarchies containing .class files. There's no reason why
JarTypeSolver shouldn't be able to do that as well!
In particular, allow selecting the entire Java Class Library,
and not just the absolute core JRE classes.
@johanneskloos johanneskloos force-pushed the johanneskloos/typesolvers branch from a8b7734 to cbf34bd Compare April 8, 2025 16:32
}

/**
* Given a apth to class file inside a class file hierarchy, extract the package name from the path.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given a path...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
codecov bot commented Apr 8, 2025

Codecov Report

Attention: Patch coverage is 96.07843% with 2 lines in your changes missing coverage. Please review.

Project coverage is 58.235%. Comparing base (7a24d4a) to head (c40cd37).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...olsolver/resolution/typesolvers/JarTypeSolver.java 95.238% 0 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##              master     #4716   +/-   ##
===========================================
  Coverage     58.235%   58.235%           
  Complexity      2511      2511           
===========================================
  Files            671       671           
  Lines          38767     38767           
  Branches        7034      7034           
===========================================
  Hits           22576     22576           
  Misses         13295     13295           
  Partials        2896      2896           
Flag Coverage Δ
AlsoSlowTests 58.235% <96.078%> (ø)
javaparser-core 58.235% <96.078%> (ø)
javaparser-symbol-solver 58.235% <96.078%> (ø)
jdk-10 57.786% <96.078%> (ø)
jdk-11 57.785% <96.000%> (ø)
jdk-12 57.785% <96.000%> (ø)
jdk-13 57.785% <96.000%> (ø)
jdk-14 58.032% <96.000%> (ø)
jdk-15 58.032% <96.000%> (ø)
jdk-16 58.007% <96.000%> (ø)
jdk-17 58.161% <96.000%> (ø)
jdk-18 58.161% <96.000%> (ø)
jdk-8 57.787% <96.078%> (ø)
jdk-9 57.783% <96.078%> (ø)
macos-latest 58.227% <96.078%> (ø)
ubuntu-latest 58.222% <96.078%> (ø)
windows-latest 58.217% <96.078%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...r/resolution/typesolvers/ReflectionTypeSolver.java 100.000% <100.000%> (ø)
...olsolver/resolution/typesolvers/JarTypeSolver.java 90.625% <95.238%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e0eff1...c40cd37. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Path pathToJar = adaptPath("src/test/resources/javaparser-core-2.1.0.jar");

// Unpack the jar file into a class hierarchy
Path tempDir = Files.createTempDirectory("jp");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this directory be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to using @TempDir.

@jlerbsc
Copy link
Collaborator
jlerbsc commented Apr 8, 2025

Thanks for this interesting PR.

@johanneskloos
Copy link
Contributor Author

@jlerbsc I have addresed your review comments; would you like me to rebase?

@johanneskloos johanneskloos requested a review from jlerbsc April 9, 2025 15:02
@jlerbsc jlerbsc merged commit 6ef01d8 into javaparser:master Apr 9, 2025
35 checks passed
@jlerbsc jlerbsc added this to the next release milestone Apr 9, 2025
@johanneskloos johanneskloos deleted the johanneskloos/typesolvers branch April 11, 2025 16:35
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
0