Garbage collection with Automatic Resource Management in Java 7
javawithswaranga.blogspot.com
Garbage collection with Automatic Resource Management in Java 7
1–10 of 21 posts
Re: Garbage collection with Automatic Resource Management in Java 7
#2Re: Garbage collection with Automatic Resource Management in Java 7
#3Re: Garbage collection with Automatic Resource Management in Java 7
#4It's a much needed cleanup of something that's always resulted in clutter in my code. C# has had this feature for over a decade. Nice to see Java adding this since I have a lot of Java code to maintain. Like a lot of Java devs we're switching over to Scala for new projects and using vanilla Java for legacy code. Automatic resource management can be implemented trivially in Scala without the need for a new language fe…
Re: Garbage collection with Automatic Resource Management in Java 7
#5Re: Garbage collection with Automatic Resource Management in Java 7
#6It's a much needed cleanup of something that's always resulted in clutter in my code. C# has had this feature for over a decade. Nice to see Java adding this since I have a lot of Java code to maintain. Like a lot of Java devs we're switching over to Scala for new projects and using vanilla Java for legacy code. Automatic resource management can be implemented trivially in Scala without the need for a new language fe…
How does structural subtyping help you implement automatic resource management?
Re: Garbage collection with Automatic Resource Management in Java 7
#7Re: Garbage collection with Automatic Resource Management in Java 7
#8Re: Garbage collection with Automatic Resource Management in Java 7
#9Earlier quoted context omitted.
How does structural subtyping help you implement automatic resource management?
I can define a resource management method which accepts any object which belongs to a class that provides a close method irrespective of whether that class implements close as part of an an interface or not.
//define it like this: def using[T S) = { val result = operation(obj) obj.close() result }
//use it like this: val writer = new FunkyWriter using(writer) { writer.write("outputting some data") }
ARM was therefore possible in Scala before the Closable interface was even added to the Java libs.