qkhanhpro
qkhanhpro

Reputation: 5220

How to find a module name and package name in Java

Currently i am running into this issue

WARNING: Illegal reflective access by my-example-class to field 
sun.reflect.annotation.AnnotationInvocationHandler.memberValues

What I understand is that I need to add --add-opens module/package=target-module(,target-module)*

Knowing the full path to the field name, where can I search for the package name / module name so that I can pass to the -add-opens flag?

Right now I can only guess --add-opens something/sun.reflect.annotation=ALL-UNNAMED

Upvotes: 2

Views: 1374

Answers (1)

Md. Faisal Habib
Md. Faisal Habib

Reputation: 1116

To get a Module by a Class, you can use the getModule()

Module module = YourClass.getModule();

To get the name ->

String moduleName = module.getName();

Use this.getClass().getCanonicalName() to get the full class name.

Resources:

Way to use getModule

Oracle documentation about getModule

getCanonicalName() Method

How to use getCanonicalName method

Upvotes: 2

Related Questions