netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

fixes an ambiguous method reference in SearchTask.

Open mbien opened this issue 3 years ago • 6 comments
trafficstars

The compiler can't decide if this is an ExceptionAction or a Runnable and marks the line as an error in-editor. Interestingly, the module builds fine.

We can help the compiler by casting to Runnable or by using a lambda expression. Cast is more compact.

ambiguous

mbien avatar Oct 26 '22 15:10 mbien

The change looks ok, but it raises the question whether the javac or NetBeans java editing is wrong.

matthiasblaesing avatar Nov 06 '22 17:11 matthiasblaesing

The change looks ok, but it raises the question whether the javac or NetBeans java editing is wrong.

yeah exactly. The module uses a different nb-javac version than the one in the editor. The one in the editor appears to be more strict.

mbien avatar Nov 06 '22 17:11 mbien

@jlahoda @singh-akhilesh could you please have a look at this? Either there is a bug in the OpenJDK javac or in the NetBeans Java Editor integration of javac. Only one of these can be right. At least I hope, that the JLS defines which method resolution is the right one.

matthiasblaesing avatar Nov 09 '22 20:11 matthiasblaesing

moving this to NB18 since its super low prio if at all a problem.

mbien avatar Jan 09 '23 17:01 mbien

I still see the same in-editor error in NB 18 using vanilla javac of JDK 20.0.2 and in NB 19 which currently uses javac based on JDK 21+26. The module builds fine on all tested JDKs without warnings in that class.

@lahodaj @jlahoda @dbalek any idea what could cause this discrepancy?

mbien avatar Aug 06 '23 21:08 mbien

removing milestone

mbien avatar Oct 11 '23 10:10 mbien

revisited this old PR now that we have enough infrastructure to be able to use javac.release=11.. and as soon the release flag is set it does also fail in the build:

/home/mbien/NetBeansProjects/netbeans/platform/api.search/src/org/netbeans/modules/search/SearchTask.java:86: error: reference to writeAccess is ambiguous
            Mutex.EVENT.writeAccess(resultViewPanel::requestFocusInWindow);
  both method <T>writeAccess(ExceptionAction<T>) in Mutex and method writeAccess(Runnable) in Mutex match
  where T is a type-variable:
    T extends Object declared in method <T>writeAccess(ExceptionAction<T>)

this would make the behavior at least consistent between embedded javac use and CLI javac use - which was my main worry tbh. (cc @lahodaj )

Will refresh this PR and bump the module to release 11 which would make this PR essentially a part of https://github.com/apache/netbeans/issues/8813

mbien avatar Sep 26 '25 19:09 mbien

planning to merge this soon since: 1) trivial and 2) mystery of the editor inconsistency is resolved

edit: at least three of the module dependencies use javac.release=11 or 17 already, so the bump should have no side effects here

mbien avatar Sep 30 '25 15:09 mbien