java-topology/test/langtools/tools/javac/flow/tests/TestCaseIfElse.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

78 lines
1.8 KiB
Java

/* /nodynamiccopyright/ */
public class TestCaseIfElse {
@AliveRange(varName="o", bytecodeStart=9, bytecodeLength=8)
@AliveRange(varName="o", bytecodeStart=20, bytecodeLength=9)
void m0(String[] args) {
Object o;
if (args[0] != null) {
o = "then";
o.hashCode();
} else {
o = "else";
o.hashCode();
}
o = "finish";
}
@AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8)
@AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9)
void m1() {
Object o;
int i = 5;
if (i == 5) {
o = "then";
o.hashCode();
} else {
o = "else";
o.hashCode();
}
o = "finish";
}
@AliveRange(varName="o", bytecodeStart=10, bytecodeLength=8)
@AliveRange(varName="o", bytecodeStart=21, bytecodeLength=9)
void m2() {
Object o;
int i = 5;
if (i != 5) {
o = "then";
o.hashCode();
} else {
o = "else";
o.hashCode();
}
o = "finish";
}
@AliveRange(varName="o", bytecodeStart=11, bytecodeLength=3)
@AliveRange(varName="o", bytecodeStart=17, bytecodeLength=2)
Object m3(boolean cond1, boolean cond2) {
Object o;
if (cond1) {
if (cond2) {
o = "then";
} else {
o = "else";
return null;
}
}
return null;
}
@AliveRange(varName="i", bytecodeStart=6, bytecodeLength=2)
int m4(boolean flag) {
int i;
label:
{
if (flag) {
i = 1;
} else {
break label;
}
return i;
}
return -1;
}
}