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
23
test/langtools/tools/javac/lvti/SelfRefTest.java
Normal file
23
test/langtools/tools/javac/lvti/SelfRefTest.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8177466
|
||||
* @summary Add compiler support for local variable type-inference
|
||||
* @compile/fail/ref=SelfRefTest.out -XDrawDiagnostics SelfRefTest.java
|
||||
*/
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
class SelfRefTest {
|
||||
|
||||
int q() { return 42; }
|
||||
int m(int t) { return t; }
|
||||
|
||||
void test(boolean cond) {
|
||||
var x = cond ? x : x; //error - self reference
|
||||
var y = (Function<Integer, Integer>)(Integer y) -> y; //error - bad shadowing
|
||||
var z = (Runnable)() -> { int z2 = m(z); }; //error - self reference
|
||||
var w = new Object() { int w = 42; void test() { int w2 = w; } }; //ok
|
||||
int u = u; //ok
|
||||
int q = q(); //ok
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue