From 2f74334b6da4e2dd2e8a6deaaf452680650b4fc3 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 17 Jul 2009 23:59:01 +0200 Subject: Added a useful note pointing at website/publish script. --- build.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/build.xml b/build.xml index 3464b8f5..0291a29b 100644 --- a/build.xml +++ b/build.xml @@ -79,6 +79,7 @@ + If you want to publish the website to the web, run the website/publish script. -- cgit From 97974b9104430d4c31ef003da3643a7905af46c6 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 18 Jul 2009 00:06:42 +0200 Subject: Refactored the name of the cleanup method arg to 'value'. --- src/lombok/Cleanup.java | 2 +- src/lombok/eclipse/handlers/HandleCleanup.java | 4 ++-- src/lombok/javac/handlers/HandleCleanup.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lombok/Cleanup.java b/src/lombok/Cleanup.java index 7d0fcc3c..ce9e0aa9 100644 --- a/src/lombok/Cleanup.java +++ b/src/lombok/Cleanup.java @@ -78,5 +78,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.SOURCE) public @interface Cleanup { /** The name of the method that cleans up the resource. By default, 'close'. The method must not have any parameters. */ - String cleanupMethod() default "close"; + String value() default "close"; } diff --git a/src/lombok/eclipse/handlers/HandleCleanup.java b/src/lombok/eclipse/handlers/HandleCleanup.java index 29f1ec7c..a256b8e3 100644 --- a/src/lombok/eclipse/handlers/HandleCleanup.java +++ b/src/lombok/eclipse/handlers/HandleCleanup.java @@ -51,7 +51,7 @@ import org.mangosdk.spi.ProviderFor; @ProviderFor(EclipseAnnotationHandler.class) public class HandleCleanup implements EclipseAnnotationHandler { public boolean handle(AnnotationValues annotation, Annotation ast, Node annotationNode) { - String cleanupName = annotation.getInstance().cleanupMethod(); + String cleanupName = annotation.getInstance().value(); if ( cleanupName.length() == 0 ) { annotationNode.addError("cleanupName cannot be the empty string."); return true; @@ -146,7 +146,7 @@ public class HandleCleanup implements EclipseAnnotationHandler { unsafeClose.receiver = receiver; long nameSourcePosition = (long)ast.sourceStart << 32 | ast.sourceEnd; if ( ast.memberValuePairs() != null ) for ( MemberValuePair pair : ast.memberValuePairs() ) { - if ( pair.name != null && new String(pair.name).equals("cleanupMethod") ) { + if ( pair.name != null && new String(pair.name).equals("value") ) { nameSourcePosition = (long)pair.value.sourceStart << 32 | pair.value.sourceEnd; break; } diff --git a/src/lombok/javac/handlers/HandleCleanup.java b/src/lombok/javac/handlers/HandleCleanup.java index 04ed2ed6..7a2f232d 100644 --- a/src/lombok/javac/handlers/HandleCleanup.java +++ b/src/lombok/javac/handlers/HandleCleanup.java @@ -53,7 +53,7 @@ import com.sun.tools.javac.util.Name; @ProviderFor(JavacAnnotationHandler.class) public class HandleCleanup implements JavacAnnotationHandler { @Override public boolean handle(AnnotationValues annotation, JCAnnotation ast, Node annotationNode) { - String cleanupName = annotation.getInstance().cleanupMethod(); + String cleanupName = annotation.getInstance().value(); if ( cleanupName.length() == 0 ) { annotationNode.addError("cleanupName cannot be the empty string."); return true; -- cgit 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. --- build.xml | 3 ++ usage_examples/CleanupExample_post.jpage | 22 ++++++++++++ usage_examples/CleanupExample_pre.jpage | 15 ++++++++ website/features/Cleanup.html | 62 ++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 usage_examples/CleanupExample_post.jpage create mode 100644 usage_examples/CleanupExample_pre.jpage create mode 100644 website/features/Cleanup.html diff --git a/build.xml b/build.xml index 0291a29b..c2933032 100644 --- a/build.xml +++ b/build.xml @@ -74,6 +74,9 @@ + + + diff --git a/usage_examples/CleanupExample_post.jpage b/usage_examples/CleanupExample_post.jpage new file mode 100644 index 00000000..91458459 --- /dev/null +++ b/usage_examples/CleanupExample_post.jpage @@ -0,0 +1,22 @@ +import java.io.*; + +public class CleanupExample { + public static void main(String[] args) throws IOException { + InputStream in = new FileInputStream(args[0]); + try { + OutputStream out = new FileOutputStream(args[1]); + try { + byte[] b = new byte[10000]; + while (true) { + int r = in.read(b); + if (r == -1) break; + out.write(b, 0, r); + } + } finally { + out.close(); + } + } finally { + in.close(); + } + } +} diff --git a/usage_examples/CleanupExample_pre.jpage b/usage_examples/CleanupExample_pre.jpage new file mode 100644 index 00000000..9f639171 --- /dev/null +++ b/usage_examples/CleanupExample_pre.jpage @@ -0,0 +1,15 @@ +import lombok.Cleanup; +import java.io.*; + +public class CleanupExample { + public static void main(String[] args) throws IOException { + @Cleanup InputStream in = new FileInputStream(args[0]); + @Cleanup OutputStream out = new FileOutputStream(args[1]); + byte[] b = new byte[10000]; + while (true) { + int r = in.read(b); + if (r == -1) break; + out.write(b, 0, r); + } + } +} 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 ++- website/features/Data.html | 2 ++ website/features/GetterSetter.html | 1 + website/features/features.css | 7 +++++++ 4 files changed, 12 insertions(+), 1 deletion(-) 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.

diff --git a/website/features/Data.html b/website/features/Data.html index 23f9cea8..cb15ed9b 100644 --- a/website/features/Data.html +++ b/website/features/Data.html @@ -12,6 +12,8 @@

@Data

+

Overview

diff --git a/website/features/GetterSetter.html b/website/features/GetterSetter.html index e865cfff..c71d08c7 100644 --- a/website/features/GetterSetter.html +++ b/website/features/GetterSetter.html @@ -12,6 +12,7 @@

@Getter and @Setter

+

Overview

diff --git a/website/features/features.css b/website/features/features.css index f2eff7fc..de669c7b 100644 --- a/website/features/features.css +++ b/website/features/features.css @@ -33,6 +33,13 @@ h1 { text-align: center; } +.byline { + width: 100%; + text-align: center; + font-style: italic; + font-size: 1.3em; +} + .index { font-size: 1.2em; margin: 64px 0px 32px 64px; -- 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/clear.gif | Bin 0 -> 43 bytes website/features/Cleanup.html | 6 +++--- website/features/Data.html | 6 +++--- website/features/GetterSetter.html | 6 +++--- website/features/clear.gif | Bin 0 -> 43 bytes website/features/features.css | 22 ++++++++++++++++------ website/features/index.html | 8 ++++---- website/index.css | 5 +++-- website/index.html | 4 ++-- website/logi/iepngfix.htc | 2 +- 10 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 website/clear.gif create mode 100644 website/features/clear.gif diff --git a/website/clear.gif b/website/clear.gif new file mode 100644 index 00000000..35d42e80 Binary files /dev/null and b/website/clear.gif differ 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 @@

- +
diff --git a/website/features/Data.html b/website/features/Data.html index cb15ed9b..0a6246bb 100644 --- a/website/features/Data.html +++ b/website/features/Data.html @@ -8,8 +8,8 @@ @Data
+
-

@Data

- +
diff --git a/website/features/GetterSetter.html b/website/features/GetterSetter.html index c71d08c7..70b60f38 100644 --- a/website/features/GetterSetter.html +++ b/website/features/GetterSetter.html @@ -8,8 +8,8 @@ @Getter and @Setter
+
-

@Getter and @Setter

@@ -52,10 +52,10 @@

- +
diff --git a/website/features/clear.gif b/website/features/clear.gif new file mode 100644 index 00000000..35d42e80 Binary files /dev/null and b/website/features/clear.gif differ diff --git a/website/features/features.css b/website/features/features.css index de669c7b..7edaf769 100644 --- a/website/features/features.css +++ b/website/features/features.css @@ -12,6 +12,10 @@ body { background-position: 50px 20px; } +* html #pepper { + background: none; +} + .meat { padding: 0px 48px; } @@ -22,13 +26,19 @@ body { left: 30px; } -.meat .minimumHeight { +.minimumHeight { height: 700px; - width: 5px; + width: 1px; float: right; } +* html .minimumHeight { + height: 0px; +} + h1 { + padding: 8px 0 10px 0; + font-size: 20px; width: 100%; text-align: center; } @@ -42,7 +52,7 @@ h1 { .index { font-size: 1.2em; - margin: 64px 0px 32px 64px; + margin: 48px 0px 32px 64px; } .index dt { @@ -108,7 +118,7 @@ h1 { display: none; } -footer { +.footer { clear: left; margin: 0 auto 0 auto; padding: 16px 0 16px 0; @@ -116,11 +126,11 @@ footer { text-align: center; } -footer .disabled { +.footer .disabled { color: #aaa; } -footer .copyright { +.footer .copyright { color: #555; font-size: 11px; font-style: italic; diff --git a/website/features/index.html b/website/features/index.html index c270f4e3..f7851972 100644 --- a/website/features/index.html +++ b/website/features/index.html @@ -6,10 +6,10 @@ Lombok feature overview - +
+
-

Lombok features

@@ -27,9 +27,9 @@
To boldly throw checked exceptions where no one has thrown them before!
-
+
+
diff --git a/website/index.css b/website/index.css index 884a13dc..e0a1e428 100644 --- a/website/index.css +++ b/website/index.css @@ -8,7 +8,8 @@ body { } h1 { - margin: 8px 0 16px 0; + padding: 8px 0 10px 0; + font-size: 20px; width: 100%; text-align: center; } @@ -120,7 +121,7 @@ code { background-color: #888; } -footer { +.footer { margin-top: 8px; display: block; color: #555; diff --git a/website/index.html b/website/index.html index a1f98be9..dec0c7b5 100644 --- a/website/index.html +++ b/website/index.html @@ -48,8 +48,8 @@ - + diff --git a/website/logi/iepngfix.htc b/website/logi/iepngfix.htc index 7ca4dbe9..bbfb23c5 100755 --- a/website/logi/iepngfix.htc +++ b/website/logi/iepngfix.htc @@ -13,7 +13,7 @@ IEPNGFix.data = IEPNGFix.data || {}; // This must be a path to a blank image, relative to the HTML document(s). // In production use I suggest '/images/blankImg' or similar. That's all! -IEPNGFix.blankImg = 'logi-img/clear.gif'; +IEPNGFix.blankImg = 'clear.gif'; IEPNGFix.fix = function(elm, src, t) { -- cgit