Skip to content
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

WARNING: An illegal reflective access operation has occurred #2266

Closed
rubberduck203 opened this issue Apr 22, 2021 · 5 comments
Closed

WARNING: An illegal reflective access operation has occurred #2266

rubberduck203 opened this issue Apr 22, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@rubberduck203
Copy link

Describe the bug

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.ibm.fhir.model.util.XMLSupport (file:/Users/rubberduck/.gradle/caches/modules-2/files-2.1/com.ibm.fhir/fhir-model/4.7.0/706afb6278d6bf5e56dec035ea17a0f326f41bba/fhir-model-4.7.0.jar) to constructor com.sun.xml.internal.stream.XMLInputFactoryImpl()

Environment
Which version of IBM FHIR Server?

4.7.0

To Reproduce
Steps to reproduce the behavior:

I'm not entirely sure.
Would be happy to help reproduce it given some guidance.

I'm running OpenJDK 11 and it seems that this behavior was introduced in JDK 9.
If you're using an older JDK, you might not see this.

Expected behavior
A clear and concise description of what you expected to happen.

No warnings.

Additional context
Add any other context about the problem here.

This StackOverflow Q&A may help someone who understands the problem better than I.
https://stackoverflow.com/questions/50251798/what-is-an-illegal-reflective-access

@rubberduck203 rubberduck203 added the bug Something isn't working label Apr 22, 2021
@prb112
Copy link
Contributor

prb112 commented Apr 22, 2021

Thanks @rubberduck203 we're aware of the warning. It's related to the XML library which we is dependent upon uses Reflection to access the xml model in memory.

@rubberduck203
Copy link
Author

Cool. Thanks @prb112.
I didn't see an issue anywhere, so wanted to make sure you were aware.

@JohnTimm
Copy link
Collaborator

We are currently using the JVM default implementations of XMLInputFactory, XMLOutputFactory, and TransformerFactory: com.sun.xml.internal.stream.XMLInputFactoryImpl, com.sun.xml.internal.stream.XMLOutputFactoryImpl, and com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl respectively. We found that other, 3rd party implementations cause problems with how we parse / generate XML. I recently retested using Woodstox, Xalan-J, and Saxon without issues. For this particular issue, I think we should upgrade to Java 9 first and then see where things stand. If it turns out that we need to move to a different implementation to avoid the reflective access warning, then we can decide to do so at that time.

@rubberduck203
Copy link
Author

Just FYI, as of Java 17, this won't even compile anymore.
The 17 LTS is scheduled for release Sept 2021.

lmsurpre added a commit that referenced this issue Sep 2, 2021
The javadocs say that these system properties are the first things consulted.
I think we shied away from relying on system properties for proper functionality in the past,
but will Java 17 around the corner it would be nice to remove the reflection here before it breaks.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre added a commit that referenced this issue Sep 2, 2021
In cases where fhir-model is used outside the server, many programs will
need to set the javax.xml.stream properties to get the right behavior.

This commit makes it so that, if these properties are NOT set, then
we'll temporarilly set them to get the right factory for our model.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
lmsurpre added a commit that referenced this issue Sep 16, 2021
* issue #2266 - avoid reflection while instantiating XML factories

The javadocs say that these system properties are the first things consulted.
I think we shied away from relying on system properties for proper functionality in the past,
but will Java 17 around the corner it would be nice to remove the reflection here before it breaks.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>

* issue #2266 - use system properties to create the right factories

In cases where fhir-model is used outside the server, many programs will
need to set the javax.xml.stream properties to get the right behavior.

This commit makes it so that, if these properties are NOT set, then
we'll temporarilly set them to get the right factory for our model.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
@lmsurpre lmsurpre self-assigned this Sep 16, 2021
@lmsurpre lmsurpre added this to the Sprint 2021-13 milestone Sep 16, 2021
@prb112
Copy link
Contributor

prb112 commented Sep 21, 2021

Confirmed with JDK 11 it no longer is reported.

Test 1: Ran build with 4.9.1 and main

mvn clean install -f fhir-parent -pl ../fhir-model --am

Confirmed the message exists on the tag, and not in the main.

Test 2: Ran with Liberty on AdoptOpenJDK 11 with 4.9.1 and main

Confirmed the message exists on tag and not in the main branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants