From efe46f68a9d0363fd58222048ddfa9efaf1bc9cd Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 18 Jul 2009 00:25:09 +0200 Subject: Added Cleanup features text. --- website/features/Cleanup.html | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 website/features/Cleanup.html (limited to 'website/features/Cleanup.html') diff --git a/website/features/Cleanup.html b/website/features/Cleanup.html new file mode 100644 index 00000000..53c94701 --- /dev/null +++ b/website/features/Cleanup.html @@ -0,0 +1,62 @@ + + + + + + + + @Cleanup + +
+
+
+ +

@Cleanup

+
+

Overview

+

+ You can use @Cleanup to ensure a given resource is automatically cleaned up before the code execution path exits your + current scope. You do this by annotating any local variable declaration with the @Cleanup annotation like so:
+ @Cleanup InputStream in = new FileInputStream("some/file");
+ As a result, at the end of the scope you're in, in.close() is called. This call is guaranteed to run by way of a + try/finally construct. Look at the example below to see how this works. +

+ If the type of object you'd like to cleanup does not have a close() method, but some other no-argument method, you can + specify the name of this method like so:
+ @Cleanup("dispose") org.eclipse.swt.widgets.CoolBar bar = new CoolBar(parent, 0);
+ By default, the cleanup method is presumed to be close(). A cleanup method that takes argument cannot be called via + @Cleanup. +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Small print

+

+ If your code throws an exception, and the cleanup method call that is then triggered also throws an exception, then the original exception + is hidden by the exception thrown by the cleanup call. You should not rely on this 'feature'. Preferably, lombok would like to generate + code so that, if the main body has thrown an exception, any exception thrown by the close call is silently swallowed (but if the main body + exited in any other way, exceptions by the close call will not be swallowed). The authors of lombok do not currently know of a feasible way + to implement this scheme, but if java updates allow it, or we find a way, we'll fix it. +

+ You do still need to handle any exception that the cleanup method can generate! +

+
+
+ +
+
+
-- cgit From 316ce2584a3d7b860dd3fbe96057df2086808364 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 18 Jul 2009 00:29:07 +0200 Subject: Added a byline to all current feature pages, as well as fixing 1 typo in Cleanup.html. --- website/features/Cleanup.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'website/features/Cleanup.html') diff --git a/website/features/Cleanup.html b/website/features/Cleanup.html index 53c94701..ae74c474 100644 --- a/website/features/Cleanup.html +++ b/website/features/Cleanup.html @@ -12,12 +12,13 @@

@Cleanup

+

Overview

You can use @Cleanup to ensure a given resource is automatically cleaned up before the code execution path exits your current scope. You do this by annotating any local variable declaration with the @Cleanup annotation like so:
- @Cleanup InputStream in = new FileInputStream("some/file");
+ @Cleanup InputStream in = new FileInputStream("some/file");
As a result, at the end of the scope you're in, in.close() is called. This call is guaranteed to run by way of a try/finally construct. Look at the example below to see how this works.

-- cgit From a61efb8db4904a848ba69f3e87747db5883693c1 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 18 Jul 2009 01:44:22 +0200 Subject: Site now looks passable in IE6 and IE7 too. --- website/features/Cleanup.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'website/features/Cleanup.html') diff --git a/website/features/Cleanup.html b/website/features/Cleanup.html index ae74c474..582412cd 100644 --- a/website/features/Cleanup.html +++ b/website/features/Cleanup.html @@ -8,8 +8,8 @@ @Cleanup

+
-

@Cleanup

@@ -54,10 +54,10 @@

- +
-- cgit