Skip to content

Avoid usage of reflection API in Enum deserialization #840

@andreaTP

Description

@andreaTP

return (T) targetEnum.getMethod("forValue", String.class).invoke(null, rawValue);

This is extremely unsafe and it works only because there is a "hidden" contract with the generator to emit the specific forValue method on the enum class.
My first reaction would be to make it more similar to a normal "class", and extend the API of ValuedEnum to cover the deserialization explicitly.

Please note that this is going to be a breaking API change for abstractions and I hope we can fix it before GA.

Do you have any prior art on the subject?
Any consideration?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done ✔️

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions