Apache NetBeans version
Apache NetBeans 31
What happened
Copying or renaming a Java class results in broken syntax in certain cases, see the examples below.
The error appears to be related to the fact that the class name appears multiple times as type argument in the interface list.
Language / Project Type / NetBeans Component
Java, Editor, Refactoring
How to reproduce
Create the following Java interface in a non-default package:
package org.example;
interface Example extends Comparable<Example>, Iterable<Example>, Cloneable { }
Refactor-copy or refactor-rename the interface within the same package. The result is:
interface Example1 extends Comparable<Example1>,Iterable<Example1>, , Cloneable { }
Notice the extra comma (which breaks the syntax) and the missing space before "Iterable".
The analogous example with a class instead of an interface exhibits the same error.
Different variations of the faulty result happen with different spacing. For example, adding an extra space before "Iterable" results in (notice the "null"):
interface Example1 extends Comparable<Example1>,null Iterable<Example1>, , Cloneable { }
Similarly, removing the space before "Iterable" results in:
interface Example1 extends Comparable<Example1>,nullIterable<Example1>, , Cloneable { }
Likewise, if the original uses multiple lines:
interface Example
extends
Comparable<Example>,
Iterable<Example>,
Cloneable
{ }
the result is:
interface Example1
extends
Comparable<Example1>,null
Iterable<Example1>, ,
Cloneable
{ }
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows
JDK
JDK 21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
The issue doesn't appear to happen in the default package.
The issue already occurred in NetBeans 30.
Are you willing to submit a pull request?
No
Apache NetBeans version
Apache NetBeans 31
What happened
Copying or renaming a Java class results in broken syntax in certain cases, see the examples below.
The error appears to be related to the fact that the class name appears multiple times as type argument in the interface list.
Language / Project Type / NetBeans Component
Java, Editor, Refactoring
How to reproduce
Create the following Java interface in a non-default package:
Refactor-copy or refactor-rename the interface within the same package. The result is:
Notice the extra comma (which breaks the syntax) and the missing space before "Iterable".
The analogous example with a class instead of an interface exhibits the same error.
Different variations of the faulty result happen with different spacing. For example, adding an extra space before "Iterable" results in (notice the "null"):
Similarly, removing the space before "Iterable" results in:
Likewise, if the original uses multiple lines:
the result is:
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows
JDK
JDK 21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
The issue doesn't appear to happen in the default package.
The issue already occurred in NetBeans 30.
Are you willing to submit a pull request?
No