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

Avoiding crash during indexing when a record has a component with a wrong name. #6649

Merged
merged 1 commit into from
Nov 23, 2023

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Nov 1, 2023

Considering code like:

record R(int wait) {}

This produces an error, as wait is not a valid record component name. And it will leave a Symbol.RecordComponent.accessor empty. Which probably is OK in the front-end, but the back end expects this to be filled. As a consequence, the indexing crashes with an exception:
oracle/javavscode#52

Generally, in VanillaCompileWorker.dropMethodsAndErrors we try to fix erroneous ASTs, so that classfiles/sig files can be generated for them. In this case, my proposal is to fill the accessor field with a dummy value - Lower will see is as a user-provided accessor, and do nothing. The test shows how the resulting classfile will look like (including making it unloadable).

@lahodaj lahodaj added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Nov 1, 2023
@lahodaj lahodaj added this to the NB21 milestone Nov 1, 2023
@lahodaj lahodaj requested a review from dbalek November 1, 2023 15:37
@mbien mbien changed the title [JAVAVSCODE-52] Avoiding crash during indexing when a record has a component with a wrong name. Avoiding crash during indexing when a record has a component with a wrong name. Nov 16, 2023
Copy link
Contributor

@dbalek dbalek left a comment

Choose a reason for hiding this comment

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

Thanks.

@lahodaj lahodaj merged commit 60eb7a1 into apache:master Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants