Search code examples
javagradleguicetelegram

An illegal reflective access operation has occurred, Java telegram bot


I've been using this library to try and run a Telegram bot using Java. I setup the project using Gradle in order to use the dependencies.

My project hierarchy is as follows:

.gradle
build
gradle
src
 -main
  -java
   -Main.java
   -MyAmazingBot.java
build.gradle
gradlew
gradlew.bat

This is the guide I used to setup up Gradle. I used the Gradle Wrapper to get my build running.

However, I get the following warning:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/C:/Users/addis/.gradle/caches/modules-2/files-2.1/com.google.inject/guice/4.1.0/eeb69005da379a10071aa4948c48d89250febb07/guice-4.1.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
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

Yet the bot runs fine (it echoes my messages back).

1) Should this message be a cause for concern?

2) Is it possible to run the jar file using java -jar? I get a message no main manifest attribute, in .\build\libs\fsc2.jar

3) Is it possible to run ./gradlew run without using Gradle's wrapper?


Solution

  • This is apparently due to an incompatibility between Guice and Java 9. See issue link below.

    There is no fix just yet. However

    • this is just a warning, and
    • there is a workaround in the issue comments to turn off all of these illegal access warnings.

    Issue link:

    I don't think Gradle is actually at fault here. It seems that the problem is in Telegram / Guice / Cglib.