netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Bug in code completion for effectively final variables

Open nmatt opened this issue 1 month ago • 0 comments

Apache NetBeans version

Apache NetBeans 28

What happened

Effectively final variables are not code-completed after a prefix within a local class.

Language / Project Type / NetBeans Component

Java, editor, code completion

How to reproduce

In the example class below, invoke code completion after the a. => alsoCallable is not proposed. (The same for any longer prefix of alsoCallable.)

What does work:

  • When declaring alsoCallable as final, code completion after a does propose it.
  • Code completion after c does propose callable (although it is not final just like alsoCallable).
  • Code completion without a prefix (e.g. within an empty{}) does propose alsoCallable.

Example class:

import java.util.concurrent.Callable;

class Example
{
    void run(Callable<?> callable)
    {
        Callable<?> alsoCallable = callable;
        
        new Thread()
        {
            @Override
            public void run()
            {
                a  // <- want code completion for alsoCallable.call() here
            }
        };
    }
}

Did this work correctly in an earlier version?

No / Don't know

Operating System

Windows

JDK

21

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

No

nmatt avatar Nov 13 '25 13:11 nmatt