Historically NetBeans project relies on nb-javac for Java editing features, i.e., parsing and lexing, for features such as syntax coloring, code completion, refactorings, and the like.
Approved
nb-javac generated binaryRelying on Javac has some positive aspects, but also some downsides.
Pros:
Cons:
On demand download (of newest javac on old JDKs) is problematic
user needs internet connection
e.g. sometimes download fails
java.source & related modules if full of reflectionTesting matrix is complicated
each supported JDK needs to be tested twice - with nb-javac and without nb-javac
every JDKs javac is a bit different
Every bug/problem one needs to know whether nb-javac was or wasn't in use
Recent version nb-javac-15 isn't really stable
Old nb-javac is a fork of JDK's javac
nobody likes forks
ironically Arvind's team is part of JDK organization - e.g. it maintains own fork of JDK's javac
Clearly there are numerous drawbacks and Apache NetBeans needs a way out. Let's get rid of nb-javac as we know it. Let's replace it with JDK's own javac ! However there are some problems...
javac in JDK15 isn't good enoughBefore NetBeans can really get rid of nb-javac , the `javac` in JDK is needs to be good enough.
Let's now assume JDK17 offers good enough javac , now NetBeans project can suggest/require people to use JDK17 to run Apache NetBeans IDE
Requiring the latest JDK to execute the IDE is serious disadvantage compared to competitors IDEs, but possibly the story may end here and it might even be a good enough story for Apache NetBeans IDE. However...
However, I don't find the restriction of latest JDK satisfying. It is not good enough story yet. There are parties that want to run on the IDE on some Java LTS version and still support the latest Java features. To address their needs let's take JDK17's javac and let run it on JDK8! Of course, there are issues:
javac is written in the language syntax of modern Javajavac is using APIs not available on JDK8The great revelation is that both these problems can be solved with existing Apache NetBeans tools! Rather than maintaining manual patches like nb-javac does, let's write advanced refactoring rules and apply them automatically. For example Optional.isEmpty() method has been added in JDK11. Let's add following rule:
$1.isEmpty() :: $1 instanceof java.util.Optional => !$1.isPresent() ;; |
That automatically rewrites all occurrences of optional.isEmpty() to !optional.isPresent() and that is going to compile on JDK8. Few more (~30) rules like this and the javac is almost ready to run on JDK8! Run few tests to verify the behavior remains the same after the automatic transformation and that's all. People can use Apache NetBeans IDE with javac from the latest JDK or they can use the automatic port of the same code running on JDK8. Ideally the behavior shall be identical. No more questions: Are you using nb-javac or not? No more duplicated testing matrix.