-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Use method references instead of reflection in TypeUtil #9115
Use method references instead of reflection in TypeUtil #9115
Conversation
TypeUtil currently uses reflection to convert Strings to primitive/boxed basic types. This may not only be a performance problem, but it also prevents environments like GraalVM native-image to detect required methods without the help of an agent. Use method references (Boolean::valueOf, etc.) instead. Signed-off-by: Christian Kohlschütter <[email protected]>
|
||
@FunctionalInterface | ||
private interface ValueOfString<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be Function<String, T>
? It's all internal anyway, no need for another type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea; see commit below
... and use Function<String,Object> instead.
Somehow this PR has an enforcer rule violation ????
I'll dig into this in the morning. |
@kohlschuetter can you merge from |
…peUtil-class2Value
Looking good, merging. |
@gregw should we backport this to Jetty 10.0.x? |
TypeUtil currently uses reflection to convert Strings to primitive/boxed basic types.
This may not only be a performance problem, but it also prevents environments like GraalVM native-image to detect required methods without the help of an agent.
Use method references (Boolean::valueOf, etc.) instead.