Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-5779

"Organize Imports" removes import of a referenced record

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 12.4
    • None
    • None

    Description

      When the "On Save" action "Organize Imports" is enabled, references to records from other files are removed when saving the file.

      Simplified example:

      File org/example/MainApp.java:

      package org.example;
      import org.example.model.Foobar;
      public class MainApp {
        private Foobar f;
      }
      

      File org/example/model/Foobar.java:

      package org.example.model;
      public record Foobar(String name) {
      }
      

      After saving MainApp.java, the import line is removed and the file cannot be compiled.

      Attachments

        Activity

          People

            Unassigned Unassigned
            striderapache dennis lucero
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: