ADDITIONAL SYSTEM INFORMATION :
Reproducible with standard open jdk 12 on OS X
A DESCRIPTION OF THE PROBLEM :
Compiling the following code in issue reproduction section that uses Sun's internal API (ExtendedOpenOption.DIRECT), with different JDK version passed to --release flag than the javac version, may generate an un-suppressible (?) Sun internal API warning; but when compiling with the same JDK version passed to --release flag no warning will be emitted.
We would like to understand the following:
1. Is this an expected / specified behavior of --release flag to emit warnings when different versions are used? (we can't seems to find relevant information in https://openjdk.java.net/jeps/247)
2. In this specific case, can the internal proprietary API warning be suppressed given it's not produced from -Xlint option?
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Code to be compiled
```
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());
}
}
```
Compilation with different jdk versions passed into --release flag would generate warning message
```
% export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-12.jdk/Contents/Home
% javac --version
javac 12.0.2
% javac src/com/company/Main.java --release 11
src/com/company/Main.java:19: warning: ExtendedOpenOption is internal proprietary API and may be removed in a future release
StandardOpenOption.READ, com.sun.nio.file.ExtendedOpenOption.DIRECT);
^
1 warning
```
Compilation with same jdk versions passed into --release flag does NOT generate warning message
```
% export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
% javac --version
javac 11.0.9
% javac src/com/company/Main.java --release 11
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation with different jdk versions passed into --release flag should not generate warning message, since --release flag is not expected to perform lint checking?
ACTUAL -
Compilation with different jdk versions passed into --release flag would generate warning message
---------- BEGIN SOURCE ----------
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());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The workaround to "suppress" the warning message is to use reflection for the internal API.
Reproducible with standard open jdk 12 on OS X
A DESCRIPTION OF THE PROBLEM :
Compiling the following code in issue reproduction section that uses Sun's internal API (ExtendedOpenOption.DIRECT), with different JDK version passed to --release flag than the javac version, may generate an un-suppressible (?) Sun internal API warning; but when compiling with the same JDK version passed to --release flag no warning will be emitted.
We would like to understand the following:
1. Is this an expected / specified behavior of --release flag to emit warnings when different versions are used? (we can't seems to find relevant information in https://openjdk.java.net/jeps/247)
2. In this specific case, can the internal proprietary API warning be suppressed given it's not produced from -Xlint option?
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Code to be compiled
```
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());
}
}
```
Compilation with different jdk versions passed into --release flag would generate warning message
```
% export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-12.jdk/Contents/Home
% javac --version
javac 12.0.2
% javac src/com/company/Main.java --release 11
src/com/company/Main.java:19: warning: ExtendedOpenOption is internal proprietary API and may be removed in a future release
StandardOpenOption.READ, com.sun.nio.file.ExtendedOpenOption.DIRECT);
^
1 warning
```
Compilation with same jdk versions passed into --release flag does NOT generate warning message
```
% export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
% javac --version
javac 11.0.9
% javac src/com/company/Main.java --release 11
```
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compilation with different jdk versions passed into --release flag should not generate warning message, since --release flag is not expected to perform lint checking?
ACTUAL -
Compilation with different jdk versions passed into --release flag would generate warning message
---------- BEGIN SOURCE ----------
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());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The workaround to "suppress" the warning message is to use reflection for the internal API.