undefect. CWE-407 — 63 sites patched across 27 ecosystems
Authors: russell@unturf.com · brackishbert@gmail.com · foxhop.net · TimeHexOn.com Patches, unit tests, benchmarks, whitepaper, and outreach briefs. Public domain — no copyright claimed. Use freely.
This commit is contained in:
commit
0a580b313d
70422 changed files with 17213626 additions and 0 deletions
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 6356530
|
||||
* @summary -Xlint:serial does not flag abstract classes with concrete methods/members
|
||||
* @compile/fail/ref=FinalVariableAssignedToInCatchBlockTest.out -XDrawDiagnostics FinalVariableAssignedToInCatchBlockTest.java
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class FinalVariableAssignedToInCatchBlockTest {
|
||||
public void m1(int o)
|
||||
{
|
||||
final int i;
|
||||
try {
|
||||
if (o == 1) {
|
||||
throw new IOException();
|
||||
} else if (o == 2) {
|
||||
throw new InterruptedException();
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
i = 1;
|
||||
} catch (InterruptedException ie) {
|
||||
i = 2;
|
||||
} catch (Exception e) {
|
||||
i = 3;
|
||||
} finally {
|
||||
i = 4;
|
||||
}
|
||||
}
|
||||
|
||||
public void m2(int o)
|
||||
{
|
||||
final int i;
|
||||
try {
|
||||
if (o == 1) {
|
||||
throw new IOException();
|
||||
} else if (o == 2) {
|
||||
throw new InterruptedException();
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
i = 1;
|
||||
} catch (InterruptedException ie) {
|
||||
i = 2;
|
||||
} catch (Exception e) {
|
||||
i = 3;
|
||||
}
|
||||
}
|
||||
|
||||
public void m3(int o) throws Exception
|
||||
{
|
||||
final int i;
|
||||
try {
|
||||
if (o == 1) {
|
||||
throw new IOException();
|
||||
} else if (o == 2) {
|
||||
throw new InterruptedException();
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
i = 1;
|
||||
} catch (InterruptedException ie) {
|
||||
i = 2;
|
||||
}
|
||||
i = 3;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue