eclipse-paho / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.15k stars 893 forks source link

FileLock may stop working in future versions of Java #507

Open jpwsutton opened 6 years ago

jpwsutton commented 6 years ago

Please fill out the form below before submitting, thank you!

When compiling and testing against a Java 9 JVM, the following warning is logged:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.paho.client.mqttv3.internal.FileLock (file:/Users/jsutton/ibm/paho/git/paho.mqtt.java/org.eclipse.paho.client.mqttv3/target/classes/) to method sun.nio.ch.FileLockImpl.release()
WARNING: Please consider reporting this to the maintainers of org.eclipse.paho.client.mqttv3.internal.FileLock
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

This is refering to the fact that FileLock.java uses reflection to check if the java.nio.channels.FileLock API is available, before then calling it.

The reason that this was written this way was to maintain support with JME MIDP which did not have the FileLock API available at the time. It would be worth doing some investigation to see whether this API is available in the latest versions of Java ME 8. If it is, then we can clean this class up considerably!

BrunoVernay commented 6 years ago

Is JME MIDP or Java ME still a requirement?? Or maybe you could create a "legacy" branch ?

Khalil-Bouzekri commented 5 years ago

+1, just migrated to Java 11 and I get the warnings

evnix commented 5 years ago

+1 Same warning here, Java 11 on MacOS

fruwolt commented 4 years ago

+1 same here Java 11 on ubuntu 18.04

panilov7 commented 4 years ago

+1 same here as well Java 11 on ubuntu 18.04

rdasgupt commented 4 years ago

@fruwolt @panilov7 I will look into this after next service release 1.2.3 (target release date 4/10/2020).

solidpulse commented 4 years ago

@rdasgupt is this targeted for 1.2.5?

rdasgupt commented 4 years ago

@avierr We plan to add this in 1.2.5. The target release date is not worked out yet. We are planning to have a release with MQTTv5 support (which is pending for more than a year) before start planning for 1.2.5 (MQTTv3 service release).

ocervinka commented 4 years ago

I'm afraid this hasn't been fixed in 1.2.5. Just tried with bumped up version of Maven dependency and the issue persists: WARNING: Illegal reflective access by org.eclipse.paho.client.mqttv3.internal.FileLock (.../1.2.5/1546cfc794449c39ad569853843a930104fdc297/org.eclipse.paho.client.mqttv3-1.2.5.jar) to method sun.nio.ch.FileLockImpl.release()

rz259 commented 3 years ago

I had the same problem and thus finally investigated the matter. The problem arises from the module system in Java 9 and higher where such access is discouraged (however still permitted). Until this problem is fixed in paho.mqtt.java you can explicitely allow such accesses by using a cmd line argument when running the java program. You just have to add the following option:

--add-opens=java.base/sun.nio.ch=ALL-UNNAMED

This does not only cause the message go away but it also allows explitly the desired access. (See also https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-7BB28E4D-99B3-4078-BDC4-FC24180CE82B)

KeithLaiKB commented 3 years ago

same here, on MQTT V5 Jdk 13.01 on win10 pro x64

jeff-bonevich commented 3 years ago

Still happening with org.eclipse.paho.client.mqttv3 v 1.2.5 and JDK 9: java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

yilmaznaslan commented 2 years ago

Still same problem. Is there any update on this issue ?