Guys, we need some discussion before I dare to move on... The error in the quoted email below shows that one shouldn't be using `Objects.requireNonNull(obj)` when `javac.target=1.6`. There are two ways to solve it:
- either rewrite to `if (obj == null) throw NPE();` - or by setting `javac.target=1.7` or higher There are tens of inconsistencies of this kind in our sources. Before we start working on a PR, we should know how we want to fix these inconsistencies. As such I wanted to bring this issue to your attention. -jt so 28. 11. 2020 v 10:30 odesĂlatel Jaroslav Tulach < jaroslav.tul...@gmail.com> napsal: > Hi. > The release is successfully over, long live the next release! > > Since the [failure of modern code]( > https://github.com/apache/netbeans/pull/ > 2369) experiment, I can't stop thinking about the enormous possibilities > NetBeans project could get by adopting `--release` flag of `javac`. There > has > been numerous voices calling for "coding against never JDK" and that's > what > the `--release` flag and the nature of [NetBeans Runtime Container](http:// > wiki.apidesign.org/wiki/NetBeans_Runtime_Container) allows us to do. > However, > let's start with the basics: > > Let's enable usage of `--release` in our Ant Javac task and let's make it > the > same as the `javac.target` value: > > ```diff > --- a/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java > +++ b/nbbuild/antsrc/org/netbeans/nbbuild/CustomJavac.java > @@ -66,6 +66,11 @@ > > @Override > public void execute() throws BuildException { > + String tgr = getTarget(); > + if (tgr.matches("\\d+")) { > + tgr = "1." + tgr; > + } > + setRelease(tgr.substring(2)); > String src = getSource(); > if (src.matches("\\d+")) { > src = "1." + src; > ``` > > That immediately shows errors in our code base. Just compile with JDK-11 > and > you'll see errors like: > > ```bash > [nb-javac] Compiling 8 source files to /netbeans/platform/queries/build/ > classes > [nb-javac] Ignoring source, target and bootclasspath as release has been > set > [repeat] warning: [options] source value 6 is obsolete and will be > removed > in a future release > [repeat] warning: [options] target value 1.6 is obsolete and will be > removed in a future release > [repeat] warning: [options] To suppress warnings about obsolete > options, > use -Xlint:-options. > [repeat] /netbeans/platform/queries/src/org/netbeans/api/queries/ > VersioningQuery.java:52: error: cannot find symbol > [repeat] java.util.Objects.requireNonNull(uri); > [repeat] ^ > [repeat] symbol: class Objects > [repeat] location: package java.util > [repeat] 1 error > [repeat] 3 warnings > [nbmerge] Failed to build target: all-queries > ``` > > What's the problem? In spite our code sets the `javac.target=1.6`, it is > using > API which isn't present in JDK6. That's wrong. Let's fix that! > > We need a Travis job using JDK-11 to compile (JDK8 doesn't support the `-- > release` flag and Ant javac task just ignores it) and then we need us to > fix all > the compilation issues found. > > If the change is done properly (and the `--release` flag is used at all > compilations), we can drop the requirement to use JDK8 to compile Apache > NetBeans. Yet the code will still run on JDK8 thanks to using `--release > 8` or > older. How does that sound? > > Jaroslav Tulach > NetBeans Platform Architect > > > >