OOP-778/bindings — reverse-engineered prompt

Reverse engineered prompt

Build me a small Java 17 library for managing object lifecycles and cleanup. I want simple bindable objects that can be linked together so when a parent closes, its children close too, and I can control whether some things close last. It should be easy to create a bindable from a callback, implement the bindable behavior in my own classes, and have a typed fluent option for chaining binds.

Please also include leak debugging, so I can dump all still open bindables to a file and inspect a readable tree with counts, edges, timestamps, and creation stack traces to find what never closed. If it fits, add a helper that automatically binds methods that return bindables, a one time bindable that needs to be marked alive before it can be bound, and event hooks for node creation and close so custom metrics can be attached. Make it safe in concurrent use, keep memory overhead low, and include a simple demo test that creates a dump file so I can see it working. Look up current docs online if you need to.

Want more depth? Deep Reverse