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

[NETBEANS-7981] Handling Diagnostics with position -1 while writing error/warning index. #7983

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

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Nov 23, 2024

When code like:

package javaapplication2;

public class JavaApplication2 {

    public static void main(String[] args) {
        new G() {
            
        };
    }
    
}

class G {
    @Deprecated
    G() {}
}

is indexed with -Xlint:deprecation, writing error/warning index may fail due to an exception like:

java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 605
	at com.sun.tools.javac.util.Position$LineTabMapImpl.getColumnNumber(Position.java:266)
	at com.sun.tools.javac.util.Position$LineMapImpl.getColumnNumber(Position.java:236)
	at com.sun.tools.javac.util.Position$LineTabMapImpl.getColumnNumber(Position.java:253)
	at org.netbeans.modules.java.source.indexing.JavaCustomIndexer$ErrorConvertorImpl.getRange(JavaCustomIndexer.java:1329)

This is because the Diagnostics has end position -1. This patch simply proposes to treat this case as a missing end position.

Separately, it should be investigated if javac should produce errors or warnings like this.

@lahodaj lahodaj added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) LSP [ci] enable Language Server Protocol tests VSCode Extension [ci] enable VSCode Extension tests labels Nov 23, 2024
@lahodaj lahodaj requested review from dbalek and mbien November 23, 2024 16:49
@mbien mbien added this to the NB24 milestone Nov 23, 2024
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) LSP [ci] enable Language Server Protocol tests VSCode Extension [ci] enable VSCode Extension tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArrayIndexOutOfBoundsException in JavaCustomIndexer$ErrorConvertorImpl
2 participants