-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix illegal reflective access operations (Java 9) #110
Comments
Just wondering how this is going to be fixable without either lobbying for the JDK to provide a supported SelChImpl or moving away from sun.nio.ch entirely... any thoughts out there? |
Hey, this project is an example for Java 8->9 migration and that this code here will break after Java 9 by default: https://docs.oracle.com/javase/9/migrate/toc.htm#JSMIG-GUID-7BB28E4D-99B3-4078-BDC4-FC24180CE82B |
Could you bring this use-case to OpenJDK either by mailing [email protected] and/or logging an issue here https://bugreport.java.com/bugreport/ (which will eventually end up at https://bugs.openjdk.java.net/secure/Dashboard.jspa). Note that JNR will continue to still work on Java 11. Illegal access operations will be denied in a future release to be determined. |
@PaulSandoz Are you aware of a discussion on nio-dev or of a bug report we could follow? |
This doesn't fix the root cause of the problem, but if you want to suppress the warnings, adding |
I running into the same problem with the following code: int i = JavaLibCHelper.getfdFromDescriptor(new FileDescriptor()); One possible solution can be hacking with JNI, because there isn't any check when native code wants to access private field. Test.java import java.io.FileDescriptor;
public class Test {
public static native int getFD(FileDescriptor oth);
public static void main(String[] args) {
System.load(new File("Test").getAbsolutePath()); // load compiled shared lib
int fd = getFD(new FileDescriptor());
}
} ~Test.h /*
* Class: Test
* Method: getFD
* Signature: (Ljava/io/FileDescriptor;)I
*/
JNIEXPORT jint JNICALL Java_Test_getFD
(JNIEnv *, jclass, jobject); ~Test.cpp jint Java_Test_getFD(JNIEnv * env, jclass, jobject o) {
jclass clazz = env->GetObjectClass(o);
jfieldID fd = env->GetFieldID(clazz,"fd","I");
jint res = (jint)env->GetIntField(o, fd);
env->DeleteLocalRef(clazz);
return res;
} It can be write the same logic for SelChImpl class too. |
For |
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by jnr.posix.JavaLibCHelper to method sun.nio.ch.SelChImpl.getFD()
WARNING: Please consider reporting this to the maintainers of jnr.posix.JavaLibCHelper
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
The text was updated successfully, but these errors were encountered: