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

Restrict system library check to require Java nature #3560

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ptziegler
Copy link
Contributor

The validation of the project classpath introduced with 74d062b always fails, if the project doesn't have a Java nature (and thus usually no .classpath file).

This causes issues when e.g. trying to open a source file with the Java editor or simply when trying to use the AST parser outside of a Java project. With this change, the check becomes more conservative and only fails, if both the Java nature exists and no system library is configured.

Note that one can avoid this exception by disabling the binding resolution. But given that this requires changes in user code, it is more prudent to only fail in cases where this is the desired behavior.

Resolves #3298

Author checklist

The validation of the project classpath introduced with
74d062b always fails, if the project
doesn't have a Java nature (and thus usually no .classpath file).

This causes issues when e.g. trying to open a source file with the Java
editor or simply when trying to use the AST parser outside of a Java
project. With this change, the check becomes more conservative and only
fails, if both the Java nature exists and no system library is
configured.

Note that one can avoid this exception by disabling the binding
resolution. But given that this requires changes in user code, it is
more prudent to only fail in cases where this is the desired behavior.

Resolves eclipse-jdt#3298
@ptziegler
Copy link
Contributor Author

I've added an additional test case that also checks the situation where the AST parser is used without any project.

Note that this currently causes testGH3047() to fail because the source file is parsed without the Java project being set (and also because no requestor is set). This hasn't thrown an exception up until now and therefore, at least from my perspective, shouldn't.

@ptziegler
Copy link
Contributor Author

ptziegler commented Jan 16, 2025

After looking closer testGH3047() and testGH3047_2() are effectively copies of one another, except that the latter is passing the IJavaProject to the ASTParser. The problem is that testGH3047() is effectively the setup we have in our application and what's causing the regression.

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.

"Missing System Library" exception in ASTParser
1 participant