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
50
test/langtools/tools/javac/lambda/LambdaConv09.java
Normal file
50
test/langtools/tools/javac/lambda/LambdaConv09.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8003280
|
||||
* @summary Add lambda tests
|
||||
* check that SAM conversion handles Object members correctly
|
||||
* @author Alex Buckley
|
||||
* @author Maurizio Cimadamore
|
||||
* @compile/fail/ref=LambdaConv09.out -XDrawDiagnostics LambdaConv09.java
|
||||
*/
|
||||
|
||||
class LambdaConv09 {
|
||||
|
||||
// Not a SAM type; not enough abstract methods
|
||||
interface Foo1 {}
|
||||
|
||||
// SAM type; Foo has no abstract methods
|
||||
interface Foo2 { boolean equals(Object object); }
|
||||
|
||||
|
||||
// Not a SAM type; Foo still has no abstract methods
|
||||
interface Foo3 extends Foo2 { public abstract String toString(); }
|
||||
|
||||
// SAM type; Bar has one abstract non-Object method
|
||||
interface Foo4<T> extends Foo2 { int compare(T o1, T o2); }
|
||||
|
||||
// Not a SAM type; still no valid abstract methods
|
||||
interface Foo5 {
|
||||
boolean equals(Object object);
|
||||
String toString();
|
||||
}
|
||||
|
||||
// SAM type; Foo6 has one abstract non-Object method
|
||||
interface Foo6<T> {
|
||||
boolean equals(Object obj);
|
||||
int compare(T o1, T o2);
|
||||
}
|
||||
|
||||
// SAM type; Foo6 has one abstract non-Object method
|
||||
interface Foo7<T> extends Foo2, Foo6<T> { }
|
||||
|
||||
void test() {
|
||||
Foo1 f1 = ()-> { };
|
||||
Foo2 f2 = ()-> { };
|
||||
Foo3 f3 = x -> true;
|
||||
Foo4 f4 = (x, y) -> 1;
|
||||
Foo5 f5 = x -> true;
|
||||
Foo6 f6 = (x, y) -> 1;
|
||||
Foo7 f7 = (x, y) -> 1;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue