Although IntelliJ IDE doesn't give me any warning, this two-line method causes a compilation error Error:(12, 37) java: incompatible types: byte[] cannot be converted to int
:
import java.math.BigInteger;
public class Test {
public static void main(String[] args){
String foo = "123";
new BigInteger(foo.getBytes(), 1, 1);
}
}
In JDK 11 there is a valid constructor with this signature public BigInteger(byte[] val, int off, int len)
(line 306 of java.math.BigInteger) but not in JDK 8. I was able to compile it directly with javac
for JDK 11 but it fails with JDK 8 as expected. I have configured IntelliJ to use JDK 11 but I don't know why it's using an older version... System.out.println(System.getProperty("java.version"))
prints 11.0.1
. Seems like it's compiling with JDK 8 and running it with JDK 11.
I have checked I have JDK 11 selected in the following places:
- Run/Debug Configurations > JRE
- Project Structure > Project > Project SDK
- Project Structure > Project > Project Language Level
- Project Structure > Modules > Language Level
I am using IntelliJ IDEA 2018.2.6 (Community Edition)
. Problem persists after restarting IntelliJ.
Edit:
project uses maven