digital-preservation / droid

DROID (Digital Record and Object Identification)
BSD 3-Clause "New" or "Revised" License
286 stars 75 forks source link

Errors in the GUI treeview org.openide.util #576

Open nishihatapalmer opened 3 years ago

nishihatapalmer commented 3 years ago

DROID reports illegal reflective access by this netbeans GUI library:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.openide.util.RequestProcessor$TopLevelThreadGroup (file:/home/matt/.m2/repository/org/netbeans/api/org-openide-util/RELEASE110/org-openide-util-RELEASE110.jar) to method sun.awt.AppContext.getAppContext()
WARNING: Please consider reporting this to the maintainers of org.openide.util.RequestProcessor$TopLevelThreadGroup
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

We've had numerous problems with the netbeans GUI libraries in the past years. Sorting is still broken in sub-levels. The code performs illegal reflective operations. We've had to patch some of the worst bugs by overriding their own classes. I spent a long time working with netbeans to get them to accept the bug and showed them several ways to fix it... but nothing has happened in terms of fixes or stable code here.

This is a long winded way of saying it may be time to ditch the netbeans tree-view component. There are other options now that simply didn't exist when DROID was first written.

  1. Create our own hybrid Tree Table component by mixing JTable and JTreeView cell renderers. Lots of tutorials online on how to do this, but probably quite a bit of work. note: technically we could have always done this, but there weren't quite so many tutorials showing how available.
  2. Use a JavaFX TreeTable component. This would mix in the new GUI framework for Java, but it's built on Swing and projects can use both quite happily.
  3. Probably some others, possibly commercial offerings.
nishihatapalmer commented 3 years ago

Note: technically the error reporting in this issue isn't in the treeview outline component directly, but in a library it depends on. Much the same difference really though. The outline has its own share of bugs, and we only need this library because we use it.

nishihatapalmer commented 3 years ago

I've been working on a fix for the illegal errors thrown in netbeans components, and the broken treeview component.

The main cause of the illegal reflective operation is the use of the NbBundle package for internationalization in string bundles. Apache Netbeans itself doesn't really use this anymore. It's possible to get rid of these errors by turning internationlization off, and then on. Recent Netbeans (I used v12) then generates the resource bundle code using standard Java resource bundles and not the nbbundle. The dependency on netbeans openide should also be removed from the pom.

(Note: these is still one place Netbeans stubbornly uses the NbBundle when generating the title of the main form - this still needs manual correction after making form changes in Netbeans back to using the java resource bundle - can't figure out why this happens so far).

For the treeview, I've been building a simple treeview component myself. It just implements standard swing table and tree interfaces, and supports sorting and filtering the rows. It plugs into existing DROID code easily, and just replaces the netbeans tree view.

nishihatapalmer commented 3 years ago

A further possible change at that point would be to convert the forms to the format used by the IntelliJ Swing GUI designer. That would remove all dependency on the netbeans platform, and would mean forms would be editable in a modern and well supported IDE.

I won't do that in replacing the treeview and nbbundle work, a future possibility.