News for hackers. Stuff that matters.
Re:JDK-4513622: keeping a substring of a field prevents GC f... by jeffdavis on Sunday March 08, 2015 @02:46PM (#9166634)
This is why I find rust intriguing. It tracks the lifetimes using the type system, so it would be obvious to the programmer that the large strings would need to live as long as the list holding the small substrings.

I'm not a rust expert, but I believe that it's basically impossible to write something like the code in the bug report without getting a compile time error in rust. You'd either need to use a version of substring that makes a copy, or explicitly keep the large strings around.

Re:JDK-4513622: keeping a substring of a field prevents GC f... by pcwalton on Sunday March 08, 2015 @03:25PM (#9166822)
Yeah, in Rust you'd have to go out of your way to use Rc to reference count the large strings.