Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/What is "warning: an illegal reflective access operation has occurred"?
Next
Answered
Zoé Brossard
  • 14
Zoé Brossard
Asked: May 17, 20222022-05-17T13:14:30+00:00 2022-05-17T13:14:30+00:00In: java

What is “warning: an illegal reflective access operation has occurred”?

  • 14

. Advertisement .

..3..

. Advertisement .

..4..

What is “warning: an illegal reflective access operation has occurred” ? I am learning about it. Can someone share with me your knowledge and experience?

an illegal reflective access operation has occurred
  • 2 2 Answers
  • 111 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    lyytutoria Expert
    2022-06-04T16:50:02+00:00Added an answer on June 4, 2022 at 4:50 pm

    The cause: 

    The crux of this problem lies in the Module System#Relaxed-strong-encapsulation.

    To support the migration to Java-9, the encapsulation of modules can be loosened. This loosening of encapsulation is controlled at runtime by a new launcher option --illegal-access. And the warning is caused in the first reflective-access operation to any such package, but after that point, their is no warnings. This only warning describes the way opening the other warnings and it cannot be avoided.

    Solution:

    To solve this problem, please do the following suggestions:

    Run it with –illegal-access=deny and don’t open module packages from one to another without  declaration such as a directive(opens) or obvious using of –add-opens VM arg. You could identify static references from compiled code to JDK-internal APIs by using the jdeps tool with the –jdk-internals option.

    The warning message issued when an illegal reflective-access operation is detected has the following form:

    WARNING: Illegal reflective access by $PERPETRATOR to $VICTIM
    

    where: $PERPETRATORis the fully-qualified name of the type containing the code that invoked the reflective operation in question plus the code source (i.e., JAR-file path), if available, and $VICTIMis a string that describes the member being accessed, including the fully-qualified name of the enclosing type

    Remember: You have to ensure your modules don’t make those illegal reflective accesses in order not to face such warnings.    

    • 22
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Raphaël Guillard
    2022-05-26T03:56:07+00:00Added an answer on May 26, 2022 at 3:56 am

    An Oracle article that I found about Java 9 module system is available.

    By default, a type in a module is not accessible to other modules unless it’s a public type and you export its package. You expose only the packages you want to expose. With Java 9, this also applies to reflection.

    As pointed out in https://ittutoria.net/a/50251958/134894, the differences between the AccessibleObject#setAccessible for JDK8 and JDK9 are instructive. JDK9 was specifically added

    This method may be used by a caller in class C to enable access to a member of declaring class D if any of the following hold:

    • C and D are in the same module.
    • The member is public and D is public in a package that the module containing D exports to at least the module containing C.
    • The member is protected static, D is public in a package that the module containing D exports to at least the module containing C, and C is a subclass of D.
    • D is in a package that the module containing D opens to at least the module containing C. All packages in unnamed and open modules are open to all modules and so this method always succeeds when D is in an unnamed or open module.

    This highlights the importance of modules and their exports in Java 9

    • 9
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.