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

An illegal reflective access operation has occurred on application start #895

Closed
foal opened this issue Apr 27, 2022 · 2 comments
Closed
Labels

Comments

@foal
Copy link

foal commented Apr 27, 2022

Describe the bug
On an application start I see the following

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.esotericsoftware.kryo.serializers.CachedFields (file:/Users/mailo/.m2/repository/com/esotericsoftware/kryo/5.3.0/kryo-5.3.0.jar) to field java.util.concurrent.atomic.AtomicLong.value
WARNING: Please consider reporting this to the maintainers of com.esotericsoftware.kryo.serializers.CachedFields
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

Environment:

  • OS: [e.g. Windows]
  • JDK Version: [e.g. 11]
  • Kryo Version: [e.g. 5.3.0]
@theigl
Copy link
Collaborator

theigl commented Apr 27, 2022

@foal: Kryo is missing safe serializers for a couple JDK types. AtomicLong is one of them. I'm planning to add the missing serializers to Kryo 5, but we unfortunately cannot register them by default, because it would break backwards compatibility. You can either ignore the warning for now, or register a custom serializer like this:

	/** Serializer for {@link AtomicLong} */
	public static class AtomicLongSerializer extends Serializer<AtomicLong> {
		public void write (Kryo kryo, Output output, AtomicLong object) {
			output.writeLong(object.get());
		}

		public AtomicLong read (Kryo kryo, Input input, Class<? extends AtomicLong> type) {
			return new AtomicLong(input.readLong());
		}

		public AtomicLong copy (Kryo kryo, AtomicLong original) {
			return new AtomicLong(original.get());
		}
	}

@theigl
Copy link
Collaborator

theigl commented Apr 27, 2022

Other types missing safe serializers are discussed in #885

@theigl theigl closed this as completed Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants