zacharymorn commented on pull request #2052:
URL: https://github.com/apache/lucene-solr/pull/2052#issuecomment-747890887
> > Alas, `gradlew precommit` from the command-line on Linux box is still
angry for me:
> > ```
> > > Task :lucene:misc:compileJava
> >
/l/trunk/lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java:163:
warning: ExtendedOpenOption is internal proprietary API and may be removed in
a future release
> >
com.sun.nio.file.ExtendedOpenOption.DIRECT);
> > ^
> >
/l/trunk/lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java:282:
warning: ExtendedOpenOption is internal proprietary API and may be removed in
a future release
> > channel = FileChannel.open(path, StandardOpenOption.READ,
com.sun.nio.file.ExtendedOpenOption.DIRECT);
> >
^
> > error: warnings found and -Werror specified
> > ```
> >
> >
> > Oh I see -- you are using `@SuppressForbidden` (which is indeed
necessary, since we are using an API that we otherwise forbid!), but you must
also add `@SuppressWarnings("sunapi")` to suppress `javac` warnings. Lots of
suppression happening here!! Hmm, but when I tried adding those two lines
locally, `gradlew precommit` still fails, hrmph.
> > This might be a JDK difference -- I'm using JDK 15.
> > Hmm, a little more research uncovers
[JDK-6476630](https://bugs.openjdk.java.net/browse/JDK-6476630), which makes it
sound like it is not possible to suppress this particular warning. Now I'm not
sure what to do! Need @uschindler help again!
>
> Oh wow this is interesting! Yes when I initially started to use
`ExtendedOpenOption.DIRECT` I got build failure from `forbiddenApisMain`. But
after I put in `@SuppressForbidden` the failure went away, so I didn't think
twice about it.
>
> I did deal with this type of error before from another project a long time
ago, and believed back then using ` @SuppressWarnings("sunapi")` with some
flags like `-XDignore.symbol.file` or `-XDenableSunApiLintControl` worked
(couldn't remember which one exactly now). However this seems to be something
no longer supported in the latest JDK now as I'm also having difficulty getting
them to work.
>
> For the few JDK versions I tried, the one that works on my mac without
`@SuppressWarnings("sunapi")` is JDK 11
>
> ```
> openjdk 11.0.9 2020-10-20
> OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
> OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)
> ```
>
> But as soon as I moved to JDK 12 below, that error also started to show up
>
> ```
> openjdk 12.0.2 2019-07-16
> OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.2+10)
> OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.2+10, mixed mode)
> ```
>
> One interesting thing I noticed after playing with a few experiments, is
that the following plain vanilla java program that exercises
`ExtendedOpenOption.DIRECT` doesn't actually output any warning for sun api use
with the JDK 12 above, but does output other "regular" warnings such as
`unchecked`, when compiled with `javac src/com/company/Main.java -Xlint:all`.
>
> ```java
> package com.company;
>
> import java.io.IOException;
> import java.nio.channels.Channel;
> import java.nio.channels.FileChannel;
> import java.nio.file.Path;
> import java.nio.file.StandardOpenOption;
> import java.util.ArrayList;
> import java.util.List;
>
> public class Main {
>
> @SuppressWarnings({"rawtypes", "unchecked"})
> public static void main(String[] args) throws IOException {
> List words = new ArrayList();
> words.add("hello");
>
> Channel channel = FileChannel.open(Path.of("blablabla"),
StandardOpenOption.CREATE, StandardOpenOption.WRITE,
> StandardOpenOption.READ,
com.sun.nio.file.ExtendedOpenOption.DIRECT);
> System.out.println(channel.isOpen());
> }
> }
> ```
>
> So I'm a bit confused at this point and need to do more research on this.
Okay. After spending the last few nights looking into what's causing the
above warning message difference between Lucene and the plain vanilla java
program, I finally found out that running different javac version with the one
passed into `--release` complier flag (defined in
https://github.com/apache/lucene-solr/blob/6af9cbba29ec87b53abd17382862262adaa85144/gradle/defaults-java.gradle#L27)
would cause this internal proprietary API warning message to be emitted for
`ExtendedOpenOption.DIRECT` (and difficult to suppress). However, when the
versions of the two matched, this warning message wouldn't be emitted
(confirmed with JDK 12 & 13)
This behavior seems to make sense as the compiler is trying to warn about
the potentially unportable use of internal API. However, I can't find any
specification of such warning behavior in https://openjdk.java.net/jeps/247 for
this flag, and if this warning is suppressible at all when emitted this way.
But I'll research more into this next.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]