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

ASTParser should detect and report when no suitable system library has been configured #3047 #3063

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

jarthana
Copy link
Member

@jarthana jarthana commented Oct 9, 2024

What it does

Fixes #3047

How to test

Author checklist

been configured

let ASTParser detect missing system library
+ look in classpaths and/or javaproject
+ first look for module java.base else for class java.lang.Object

fix test setups:
+ converterJclMin9 lacked some relevant classes
+ initialization of variable CONVERTER_JCL15_LIB was missing
+ correction of .classpath for some converter test projects:
  + don't use 1.8 lib for projects > 9
  + mark system libraries as modular

modified the new test:
+ copy the original test from DOM test to a new compiler test
  - here we expect missing type errors instead of NPE
+ update test expectation in DOM to the new exception
@stephan-herrmann
Copy link
Contributor

Commit 19be8b3 got a bit more complex than expected for two reasons:

  • Several tests were indeed ill-configured using minimal system libraries that didn't match the project compliance etc. Also one such library was found to be quite incomplete.
    • a bunch of tests configured for "1.8" indeed do not supply any system library at all:
      createJavaProject("P", new String[] { "" }, new String[0], "");
  • based on the decision to look for module java.base, it get's a bit blurry if that module is not found:
    • I added a fallback looking for class java.lang.Object if no module was found at all.
    • the code needs to differentiate if explicit classpaths are provided or if that information should come from an IJavaProject
    • still at 1.8 the code keeps silent (for pragmatic reasons, partly because of the number of lib-less tests)

The current state is a compromise trying to raise the exception in most relevant situations.

We could probably simplify the code and also check at compliance 1.8 if we only look for class java.lang.Object. I didn't make this the one and only criterion because I feared that searching deep into details of all classpath entries might degrade performance, more so than just looking for module-info at the root of each entry.

If, however, we assume when RESOLVE_BINDING is requested, the compiler will need to lookup java.lang.Object anyway, then we could reduce the checks to that class lookup (but would need to "fix" more tests which don't have system libraries configured).

@jarthana wdyt?

@stephan-herrmann
Copy link
Contributor

  • Several tests were indeed ill-configured using minimal system libraries that didn't match the project compliance

Some locations seemed to suffer from the confusion between 1.8 and 18. E.g., project Converter_15_1 uses compliance "15" but as library "CONVERTER_JCL18_LIB" was used, which is for "1.8"!

@jarthana
Copy link
Member Author

Looks good, Stephan. I just looked at what we do in the IDE. There, we seem to somehow turn that into a build path problem. Probably lot of work goes behind that.

@jarthana jarthana merged commit 74d062b into eclipse-jdt:master Oct 15, 2024
10 checks passed
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.

ASTParser should detect and report when no suitable system library has been configured
2 participants