forked from checkstyle/checkstyle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#6125: Ignore variable reference as resource statement
- Loading branch information
Showing
3 changed files
with
85 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...heckstyle/checks/coding/onestatementperline/InputOneStatementPerLineTryWithResources.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//non-compiled with javac: Compilable with Java9 | ||
package com.puppycrawl.tools.checkstyle.checks.coding.onestatementperline; | ||
|
||
import java.io.IOException; | ||
import java.io.PipedOutputStream; | ||
import java.io.OutputStream; | ||
|
||
public class InputOneStatementPerLineTryWithResources { | ||
|
||
void method() throws IOException { | ||
OutputStream s1 = new PipedOutputStream(); | ||
OutputStream s2 = new PipedOutputStream(); | ||
try (s1; s2; OutputStream s3 = new PipedOutputStream();) { | ||
} | ||
try (s1; OutputStream s4 = new PipedOutputStream(); s2;) { | ||
} | ||
try (s1; s2; OutputStream s5 = new PipedOutputStream()) { | ||
} | ||
try (s1; OutputStream s6 = new PipedOutputStream(); s2) { | ||
} | ||
try ( | ||
OutputStream s7 = new PipedOutputStream();OutputStream s8 = new PipedOutputStream(); | ||
s2; | ||
) { | ||
} | ||
try (s1; OutputStream s9 = new PipedOutputStream(); | ||
s2;) { | ||
} | ||
try (OutputStream s10 = new PipedOutputStream(); | ||
OutputStream s11 = new PipedOutputStream(); s2;) { | ||
} | ||
} | ||
} |