question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Illegal reflective access operation warning when using `java.lang.Void` as value type

See original GitHub issue

I’m using Jackson (2.9.7) through Spring’s RestTemplate:

ResponseEntity<Void> response = getRestTemplate().exchange(
		requestUrl,
		HttpMethod.PATCH,
		new HttpEntity<>(dto, authHeaders),
		Void.class
);

When Void is used to indicate that the ResponseEntity has no body, the following warning appears in the console:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.fasterxml.jackson.databind.util.ClassUtil (file:/<snip>repository/com/fasterxml/jackson/core/jackson-databind/2.9.7/jackson-databind-2.9.7.jar) to constructor java.lang.Void()
WARNING: Please consider reporting this to the maintainers of com.fasterxml.jackson.databind.util.ClassUtil
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 problem disappears if String is used as generic type.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
cowtowncodercommented, Dec 6, 2018

It probably also makes sense to add explicit handling for (nominal) type Void. Not much point in introspecting it as POJO. I’ll actually re-open this to have a look.

1reaction
cowtowncodercommented, Dec 7, 2018

Ok: as an orthogonal thing, I added handling for Void as special type to avoid handling of type as POJO; this should prevent warning. There are already handlers for “always read/write asnull”, as it happens, so not much additional work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java 9 Illegal Reflective Access Warning - Baeldung
The readability of modules is a coarse concept and concerns whether one module has a dependency on another module. The accessibility of modules ......
Read more >
How to hide warning "Illegal reflective access" in java 9 ...
1. Simple approach · This approach merges error and output streams. That may not be desirable in some cases. · You cannot redirect...
Read more >
Illegal access in Java 16 A.K.A. 'My program crashes!'
WARNING : An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.przybyl.ddj16.
Read more >
An illegal reflective access operation has occurred when ...
An illegal reflective access operation has occurred when using Java 11 with ForgeRock products. The purpose of this article is to provide ...
Read more >
java - Oracle Help Center
You can use the java command to launch a Java application. ... permit except that a warning message is issued for each illegal...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found