4

I have just installed java and kotlin.

I installed Java from oracle, and kotlin by brew.

After writing simple hello-world code in kotlin, I keep getting warnings.

I have tried installing an IDE intellij hoping it might fix, but it did not help.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.openapi.util.JDOMUtil$2 to constructor com.sun.xml.internal.stream.XMLInputFactoryImpl()
WARNING: Please consider reporting this to the maintainers of com.intellij.openapi.util.JDOMUtil$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

I have searched online but none of it actually helped.

My java version and kotlin version

java version "12.0.1" 2019-04-16
Java(TM) SE Runtime Environment (build 12.0.1+12)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
Kotlin version 1.3.31-release-197 (JRE 12.0.1+12)
Kyoo Sik Lee
  • 363
  • 4
  • 19
  • The solution to this is: Just ignore it, you can't really change the library you're using. This warning occurs when a class tries via reflection to access some "forbidden" field / class. You can deny all these accesses via the jvm argument `--illegal-access=deny`, which will throw an error AFAIK – Lino Jun 06 '19 at 07:49
  • 1
    Well I think it was the problem of not using java version 8 Kotlin uses java 8 – Kyoo Sik Lee Jul 27 '19 at 02:08
  • 1
    Could you unduplicate this? – Kyoo Sik Lee Jul 27 '19 at 02:19
  • As far as I can tell: this error only occurs with Java 9 and above, so it can't be a problem with Java 8. So the duplicate should be valid. If you can provide some evidence that the problem is really because of Kotlin, I can remove the duplicate – Lino Jul 27 '19 at 07:41
  • Yes I am also aware that this error occurs with Java 9 and above. And Kotlin only supports Java 8 https://kotlinlang.org/docs/reference/faq.html#does-kotlin-only-target-java-6 So my problem was that I used java 12 which Kotlin does not support. And for those who had same mistake I did might encounter same error. – Kyoo Sik Lee Jul 28 '19 at 08:56

0 Answers0