java-topology/test/langtools/tools/javac/T6326693/FinalVariableAssignedToInCatchBlockTest.java
russell@unturf.com 0a580b313d 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.
2026-03-26 17:11:57 -04:00

71 lines
1.8 KiB
Java

/*
* @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;
}
}