Skip to content

Clone java objects with hopefully fast MethodHandle-generated code

License

Notifications You must be signed in to change notification settings

bkgood/methodhandlescloner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

methodhandlescloner

abstract

Attempt to quickly clone objects using MethodHandles.

why

Java 9+ gives us a MethodHandles class that allows us to tie together MethodHandles such that the runtime can apply many of the same optimizations in compiled code that we get from normal Java code. Generic routines that manipulate object fields have required in the past to either use reflection and be slow or use more esoteric methods like runtime code generation or sun.misc.Unsafe.

I'd like to do something like protostuff-runtime from protostuff/protostuff with MethodHandles, so that we could infer Protocol Buffers schemas from normal Java code (with annotations) and enjoy performance roughly in line with the typical generated code encoders and decoders. I started this as a way to start playing around with MethodHandles in a simpler space.

todo

  • maybe do recursive cloning, currently references are copied and not traversed.
  • Benchmark this vs a classic reflection-based approach and a generated code approach.

About

Clone java objects with hopefully fast MethodHandle-generated code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages