View Javadoc
1   package com.puppycrawl.tools.checkstyle.grammars;
2   
3   /**
4    * Input for Java 7 try-with-resources.
5    */
6   public class InputJava7TryWithResources
7   {
8       public static class MyResource implements AutoCloseable {
9           @Override
10          public void close() throws Exception { }
11      }
12  
13      public static void main(String[] args) throws Exception {
14          try (MyResource resource = new MyResource()) { }
15  
16          try (MyResource resource = new MyResource()) { }
17          finally { }
18  
19          try (MyResource resource = new MyResource();) { }
20          catch (Exception e) { }
21  
22          try (MyResource resource = new MyResource();) { }
23          catch (Exception e) { }
24          catch (Throwable t) { }
25          finally { }
26         
27          try (MyResource resource = new MyResource(); MyResource resource2 = new MyResource()) { }
28          catch (Exception e) { }
29          catch (Throwable t) { }
30          finally { }
31         
32          try (MyResource resource = new MyResource(); MyResource resource2 = new MyResource();) { }
33          catch (Exception e) { }
34          catch (Throwable t) { }
35          finally { }
36  
37          try (@SuppressWarnings("all") final MyResource resource = new MyResource()) { }
38      }
39  }