8163229: several regression tests have a main method that is never executed

Reviewed-by: vromero
This commit is contained in:
Archie L. Cobbs 2023-01-17 04:43:40 +00:00 committed by Julian Waters
parent 06f9374e0c
commit 382fe51b6d
129 changed files with 119 additions and 191 deletions

View File

@ -11,7 +11,7 @@ import static p2.A2.f;
public class Test {
public static void main(String argv[]) {
public static void meth() {
f = 1;
}
}

View File

@ -12,7 +12,7 @@ import p2.A2.f;
public class Test {
public static void main(String argv[]) {
public static void meth() {
new f();
}
}

View File

@ -7,7 +7,7 @@
*/
public class T6491592 {
public static void main(String... args) {
public static void meth() {
Object o = null;
o += null;
}

View File

@ -12,7 +12,7 @@ class Foo {
};
class Test {
public static void main() {
public static void meth() {
Foo f = new Foo("Hello!",nosuchfunction()) {};
}
}

View File

@ -7,7 +7,7 @@
*/
public class UnresolvableClassNPEInAttrTest {
public static void main(String[] args) {
public static void meth() {
new Undefined() {
void test() {
new Object() {};

View File

@ -6,7 +6,7 @@
*/
class T8161985 {
public static void main(String [] arg) {
public static void meth() {
T8161985 t = new T8161985();
t.getClass();

View File

@ -6,7 +6,7 @@
*/
class T8238735 {
public static void main(String[] args) {
public static void meth() {
boolean first = true;
first = first ? false : (boolean)(() -> false) ;
}

View File

@ -24,8 +24,4 @@ public class AnonymousInSuperCallNegTest {
}
}); }
}
public static void main(String[] args) {
new JavacBug();
}
}

View File

@ -8,7 +8,7 @@
*/
class BreakAcrossClass {
public static void main(String argv[]) {
public static void meth() {
final int i = 6;
M: {
class A {

View File

@ -37,14 +37,4 @@ public class CaptureInSubtype {
Flaw<?> m(){return fn;}
}
public static void main(String[] args) {
SuperOfShowFlaw sosf = new ShowFlaw();
SuperOfFlaw<List<?>> sof = sosf.m();
List<String> ls = new ArrayList<String>();
ls.add("Smalltalk rules!");
sof.put(ls);
Number n = ShowFlaw.fn.get().get(0);
}
}

View File

@ -8,7 +8,7 @@
*/
public class DASwitch {
public static void main(final String[] args) {
public static void meth() {
int t = 1;
{
final int x;

View File

@ -8,7 +8,7 @@
*/
public class DUParam1 {
public static void main(final String[] args) {
public static void meth(final String[] args) {
// 8.4.1 makes it illegal to assign to a final parameter.
if (false) args = null;
}

View File

@ -11,7 +11,7 @@ class E1 extends Exception {}
class E2 extends Exception {}
public class DefAssignAfterTry1 {
public static void main(String argv[]) {
public static void meth() {
boolean t = true;
E1 se1 = new E1();
E2 se2 = new E2();

View File

@ -11,7 +11,7 @@ class E1 extends Exception {}
class E2 extends Exception {}
public class DefAssignAfterTry2 {
public static void main(String argv[]) {
public static void meth() {
boolean t = true;
E1 se1 = new E1();
E2 se2 = new E2();

View File

@ -11,7 +11,7 @@ class E1 extends Exception {}
class E2 extends Exception {}
public class DefAssignAfterTry3 {
public static void main(String argv[]) {
public static void meth() {
boolean t = true;
E1 se1 = new E1();
E2 se2 = new E2();

View File

@ -8,7 +8,7 @@
*/
class T4717164 {
public static void main(String[] args) {
public static void meth() {
try {
try {
throw new ClassNotFoundException();

View File

@ -12,7 +12,7 @@ class T4718142 {
static void thr() throws E {
throw new E();
}
public static void main(String[] args) {
public static void meth() {
int count = 0;
final int i;
while (true) {

View File

@ -8,7 +8,7 @@
*/
class T4718142a {
public static void main(String[] args) {
public static void meth() {
final int i;
for (int n=0; n<10; n++) {
b: {

View File

@ -21,8 +21,4 @@ class B extends A implements I {
}
public class UncaughtException {
public static void main (String[] args) {
I b = new B();
b.throwCheckedException();
}
}

View File

@ -18,7 +18,7 @@ interface I {
x.getClass();
}
}
public static void main(String[] args) {
public static void meth() {
f(null);
}
}

View File

@ -9,7 +9,7 @@
*/
public class ParseConditional {
public static void main(String[] args) {
public static void meth() {
boolean condition = true;
int a = 1;
int b = 2;

View File

@ -8,7 +8,7 @@
*/
public class SwitchScope {
public static void main(String[] args) {
public static void meth(String[] args) {
switch (args.length) {
case 0:
final int k;

View File

@ -10,7 +10,7 @@
import java.io.PrintStream;
class SynthName2 {
public static void main(String args[]) {
public static void meth(String args[]) {
run(args, System.out);
}
public static void run(String args[],PrintStream out) {

View File

@ -22,7 +22,7 @@ class Outer {
}
class Access {
public static void main(String[] args) {
public static void meth() {
Outer outer = new Outer();
outer.create();
System.out.println("Value of k: " + outer.inner.k);

View File

@ -7,7 +7,7 @@
*/
public class T6306967 {
public static void main(String[] args) {
public static void meth() {
final int x;
while(true) {
if (true) {

View File

@ -42,7 +42,7 @@ class TestC<T>{
}
}
public class T6326754{
public static void main(String... arg){
public static void meth() {
TestC tC =new TestC();
tC.setT();
TestConstructor tc = new TestConstructor("saaa");

View File

@ -8,7 +8,7 @@
import java.security.*;
public class T6379327 {
public static void main(String[] args) {
public static void meth(String[] args) {
final String name = args[0];
try {
new PrivilegedExceptionAction() {

View File

@ -9,7 +9,4 @@
class T6407257a extends T6407257a {}
public class T6407257 extends T6407257a {
public static void main(String... args) {
main(args);
}
}

View File

@ -7,7 +7,7 @@
*/
public class BadTwr implements AutoCloseable {
public static void main(String... args) {
public static void meth(String... args) {
// illegal repeated name
try(BadTwr r1 = new BadTwr(); BadTwr r1 = new BadTwr()) {
System.out.println(r1.toString());

View File

@ -1,5 +1,5 @@
BadTwr.java:12:46: compiler.err.already.defined: kindname.variable, r1, kindname.method, main(java.lang.String...)
BadTwr.java:17:20: compiler.err.already.defined: kindname.variable, args, kindname.method, main(java.lang.String...)
BadTwr.java:12:46: compiler.err.already.defined: kindname.variable, r1, kindname.method, meth(java.lang.String...)
BadTwr.java:17:20: compiler.err.already.defined: kindname.variable, args, kindname.method, meth(java.lang.String...)
BadTwr.java:20:13: compiler.err.cant.assign.val.to.final.var: thatsIt
BadTwr.java:25:24: compiler.err.already.defined: kindname.variable, name, kindname.method, main(java.lang.String...)
BadTwr.java:25:24: compiler.err.already.defined: kindname.variable, name, kindname.method, meth(java.lang.String...)
4 errors

View File

@ -8,7 +8,7 @@
import java.io.IOException;
public class BadTwrSyntax implements AutoCloseable {
public static void main(String... args) throws Exception {
public static void meth() {
// illegal double semicolon ending resources
try(BadTwr twrflow = new BadTwr();;) {
System.out.println(twrflow.toString());

View File

@ -8,7 +8,7 @@
class DuplicateResourceDecl {
public static void main(String[] args) {
public static void meth() {
try(MyResource c = new MyResource();MyResource c = new MyResource()) {
//do something
} catch (Exception e) { }

View File

@ -1,2 +1,2 @@
DuplicateResourceDecl.java:12:56: compiler.err.already.defined: kindname.variable, c, kindname.method, main(java.lang.String[])
DuplicateResourceDecl.java:12:56: compiler.err.already.defined: kindname.variable, c, kindname.method, meth()
1 error

View File

@ -9,7 +9,7 @@
import java.io.IOException;
class ImplicitFinal implements AutoCloseable {
public static void main(String... args) {
public static void meth() {
try(ImplicitFinal r = new ImplicitFinal()) {
r = null; //disallowed
} catch (IOException ioe) { // Not reachable

View File

@ -6,7 +6,7 @@
* @compile/fail/ref=PlainTry.out -XDrawDiagnostics PlainTry.java
*/
public class PlainTry {
public static void main(String... args) {
public static void meth() {
try {
;
}

View File

@ -8,7 +8,7 @@
import java.io.*;
class T7022711 {
public static void main (String args[]) throws Exception {
public static void meth() {
// declared resource
try (DataInputStream is = new DataInputStream(new FileInputStream("x"))) {
while (true) {

View File

@ -7,7 +7,7 @@
public class TwrAndLambda {
public static void main(String... args) {
public static void meth() {
// Lambda expression
AutoCloseable v1 = () -> {};

View File

@ -8,7 +8,7 @@
import java.io.IOException;
public class TwrFlow implements AutoCloseable {
public static void main(String... args) {
public static void meth() {
try(TwrFlow twrFlow = new TwrFlow()) {
System.out.println(twrFlow.toString());
} catch (IOException ioe) { // Not reachable

View File

@ -5,7 +5,7 @@
* @compile/fail/ref=TwrForVariable2.out -XDrawDiagnostics -Xlint:-options TwrForVariable2.java
*/
public class TwrForVariable2 implements AutoCloseable {
public static void main(String... args) {
public static void meth() {
TwrForVariable2 v = new TwrForVariable2();
TwrForVariable3[] v2 = new TwrForVariable3[1];
TwrForVariable3[][] v3 = new TwrForVariable3[1][1];

View File

@ -4,7 +4,7 @@
* @compile/fail/ref=TwrForVariable3.out -XDrawDiagnostics -Xlint:-options TwrForVariable3.java
*/
public class TwrForVariable3 implements AutoCloseable {
public static void main(String... args) {
public static void meth() {
TwrForVariable3 v1 = new TwrForVariable3();
Object v2 = new Object();
Object v3 = new Object() {

View File

@ -5,7 +5,7 @@
* @compile/fail/ref=TwrForVariable4.out -XDrawDiagnostics -Xlint:-options TwrForVariable4.java
*/
public class TwrForVariable4 implements AutoCloseable {
public static void main(String... args) {
public static void meth() {
TwrForVariable4 uninitialized;
try (uninitialized) {

View File

@ -7,7 +7,7 @@
*/
class TwrOnNonResource {
public static void main(String... args) {
public static void meth() {
try(TwrOnNonResource aonr = new TwrOnNonResource()) {
System.out.println(aonr.toString());
}

View File

@ -12,7 +12,7 @@ public class TwrVarKinds implements AutoCloseable {
static TwrVarKinds r3 = new TwrVarKinds();
TwrVarKinds r4 = new TwrVarKinds();
public static void main(String... args) {
public static void meth() {
TwrVarKinds r5 = new TwrVarKinds();

View File

@ -7,7 +7,7 @@
public class TwrVarRedeclaration implements AutoCloseable {
public static void main(String... args) {
public static void meth() {
TwrVarRedeclaration r = new TwrVarRedeclaration();
try (r) {

View File

@ -1,4 +1,4 @@
TwrVarRedeclaration.java:14:33: compiler.err.already.defined: kindname.variable, r, kindname.method, main(java.lang.String...)
TwrVarRedeclaration.java:18:20: compiler.err.already.defined: kindname.variable, r, kindname.method, main(java.lang.String...)
TwrVarRedeclaration.java:23:23: compiler.err.already.defined: kindname.variable, r, kindname.method, main(java.lang.String...)
TwrVarRedeclaration.java:14:33: compiler.err.already.defined: kindname.variable, r, kindname.method, meth()
TwrVarRedeclaration.java:18:20: compiler.err.already.defined: kindname.variable, r, kindname.method, meth()
TwrVarRedeclaration.java:23:23: compiler.err.already.defined: kindname.variable, r, kindname.method, meth()
3 errors

View File

@ -10,7 +10,7 @@ import static java.lang.System.out;
class UseEnum {
enum Animal {cat, dog, bird, fish};
public static void main(String args[]) {
public static void meth() {
Animal pet;
pet = Animal.cat;

View File

@ -19,8 +19,4 @@ import static java.lang.annotation.RetentionPolicy.*;
@A
class Main {
public static void main(String[] args) {
A a = Main.class.getAnnotation(A.class);
System.out.println(a);
}
}

View File

@ -18,7 +18,7 @@ class C {
// static method
static int f() { return @A C.f; }
// main
public static void main(String... args) {
public static void meth() {
int a = @A C.f;
}
}

View File

@ -30,7 +30,7 @@ class T0x1E {
}
class ClassLiterals {
public static void main(String[] args) {
public static void meth() {
if (String.class != @A String.class) throw new Error();
if (@A int.class != int.class) throw new Error();
if (@A int.class != Integer.TYPE) throw new Error();

View File

@ -9,7 +9,7 @@
import java.util.List;
public class Martin {
public static void main(String[] args) throws Throwable {
public static void meth() {
List<?> x1 = null;
List<?> x2 = null;
x1.addAll(x2);

View File

@ -17,14 +17,14 @@ public class Private06 {
void foo(NAFI nafi);
}
public static void main(String [] args) {
public static void meth() {
Private06.NAFI nafi = () -> {};
Private06.FI fi = Private06.NAFI::foo; // OK.
}
}
class Private06_01 {
public static void main(String [] args) {
public static void meth() {
Private06.FI fi = Private06.NAFI::foo; // NOT OK.
}
}

View File

@ -11,7 +11,7 @@ class Static02 {
public static void test() { }
}
public static void main(String[] args) {
public static void meth() {
I.test(); //ok
I i = new I() {};
i.test(); //no!

View File

@ -23,7 +23,7 @@
public class DeprecatedDocComment {
public static void main(String argv[]) {
public static void meth() {
DeprecatedDocComment2.deprecatedTest1();
DeprecatedDocComment2.deprecatedTest2();
DeprecatedDocComment2.deprecatedTest3();

View File

@ -6,7 +6,7 @@
*/
public class T6245699b {
public static void main(String[] args) {
public static void meth() {
IBar b = new Bar();
String x = b.doIt();
}

View File

@ -6,7 +6,7 @@
*/
public class T6413682 {
public static void main(String... args) {
public static void meth() {
Object[] text = new
<Wow,thanks.Mr<List>,and.thanks.Mr<Javac>.Vince>Object[5];
}

View File

@ -7,7 +7,7 @@
*/
public class T6495506 {
public static void main(String... args) {
public static void meth() {
a.A myA = new a.A();
myA.p = myA.vec.get(0);
}

View File

@ -23,7 +23,7 @@ public class T6723444 {
<X1 extends Throwable, X2 extends Throwable> T6723444(Foo<X1> foo, int i)
throws X1, X2 {}
public static void main(String[] args) throws Exception {
public static void meth() throws Exception {
// the following 8 statements should compile without error

View File

@ -8,7 +8,7 @@
*/
public class GetClass {
public static void main(String[] args) {
public static void meth() {
Class<? extends Class<GetClass>> x = GetClass.class.getClass();
}
}

View File

@ -21,7 +21,7 @@ public class Nonlinear {
// when executed, even though there are no explicit casts in
// the program.
public static void main (String [] args) {
public static void meth() {
Integer x = Integer.valueOf(5);
String y = castit (x);
System.out.println (y);

View File

@ -12,7 +12,7 @@ import java.util.Collection;
public class UnsoundInference {
public static void main(String[] args) {
public static void meth() {
Object[] objArray = {new Object()};
ArrayList<String> strList = new ArrayList<String>();
transferBug(objArray, strList);

View File

@ -9,7 +9,7 @@
*/
class Neg08 {
public static void main(String[] args) {
public static void meth() {
String s = new String<>("foo");
}
}

View File

@ -15,7 +15,7 @@ class Neg13 {
static void foo(A<String> as) {}
public static void main(String[] args) {
public static void meth() {
// Method invocation context - good <>(){}
foo(new A<>() {

View File

@ -15,7 +15,7 @@ class Neg14 {
static void foo(A<String> as) {}
public static void main(String[] args) {
public static void meth() {
// Method invocation context - good <>(){}
foo(new A<>() {

View File

@ -23,7 +23,7 @@ class Neg15 {
throw new Error("Blew it");
}
public static void main(String[] args) {
public static void meth() {
someMethod(new Predicate<Integer>() {
public boolean test(Integer n) {

View File

@ -11,7 +11,7 @@ abstract class Neg17<T> {
abstract void m();
public static void main(String[] args) {
void meth() {
Collections.singletonList(new Neg17<>() { void m() {} }).get(0).m(); // good.
Collections.singletonList(new Neg17<>() {
void m() {}

View File

@ -10,7 +10,7 @@ import pkg.Neg18_01;
class Neg18 {
public static void main(String[] args) {
public static void meth() {
new Neg18_01<>() {};
}
}

View File

@ -8,7 +8,7 @@
class Neg19 {
public static void main(String[] args) {
public static void meth() {
new Neg19_01<Neg19>().foo(new Neg19_01<>()); // OK.
new Neg19_01<Neg19>().foo(new Neg19_01<>() {}); // ERROR.
}

View File

@ -22,9 +22,4 @@ public class T4972073 {
}
static class B<E extends MyClass & MyInterface<E> & MyInterface<E>> extends D {}
public static void main(String[] args) {
B b = new B<Sun1>();
}
}

View File

@ -8,7 +8,7 @@
public class Neg {
static void m() {}
public static void main(String... args) {
public static void meth() {
Neg.<Can,I,write,a,little,story,here>m();
}
}

View File

@ -15,7 +15,7 @@ class BadTest {
static <A> Cell<A> makeCell(A x) { return new Cell<A>(x); }
static <A> A id(A x) { return x; }
public static void main(String[] args) {
public static void meth() {
List<Cell<String>> as = nil().prepend(makeCell(null));
List<Cell<String>> bs = cons(makeCell(null), nil());
List<String> xs = id(nil());

View File

@ -27,7 +27,7 @@ class BadTest3 {
static <A> Cell<A> makeCell(A x) { return new Cell<A>(x); }
static <A> A id(A x) { return x; }
public static void main(String[] args) {
public static void meth() {
List<String> xs = nil();
f(null);
f(nil());

View File

@ -32,10 +32,4 @@ class T<X> {
<K> void f(K k) {
this.<Integer>f("");
}
public static void main(String[] args) {
T<Integer> x = new <Object>T<Integer>();
T<Integer>.U<Float> y = x.new <Object>U<Float>();
x.<Object>f("");
}
}

View File

@ -33,7 +33,7 @@ class T<X> {
this.<Object>f("");
}
public static void main(String[] args) {
public static void meth() {
T<Integer> x = new <Object>T<Integer>();
T<Integer>.U<Float> y = x.new <Object>U<Float>();
x.<Integer>f("");

View File

@ -14,7 +14,7 @@ class T<X> {
<K> T(K x) {
}
public static void main(String[] args) {
public static void meth() {
new <Integer>T<Float>("");
}
}

View File

@ -15,7 +15,7 @@ class T {
<B> U(B b) {}
}
public static void main(String[] args) {
public static void meth() {
new T().new <Integer>U<Integer>("");
}
}

View File

@ -32,10 +32,4 @@ class T<X> {
<K> void f() {
this.<Object>f();
}
public static void main(String[] args) {
T<Integer> x = new <Object>T<Integer>("");
T<Integer>.U<Float> y = x.new <Object>U<Float>();
x.<Object>f();
}
}

View File

@ -32,10 +32,4 @@ class T<X> {
<K> void f() {
this.<Object>f();
}
public static void main(String[] args) {
T<Integer> x = new <Object>T<Integer>();
T<Integer>.U<Float> y = x.new <Object>U<Float>("");
x.<Object>f();
}
}

View File

@ -32,10 +32,4 @@ class T<X> {
<K> void f() {
this.<Object>f();
}
public static void main(String[] args) {
T<Integer> x = new <Object>T<Integer>();
T<Integer>.U<Float> y = x.new <Object>U<Float>("");
x.<Object>f();
}
}

View File

@ -10,7 +10,7 @@
*/
public class T6437894 {
public static void main(String... args) {
public static void meth() {
b.B m;
a.A.X x = null;
Long.parseLong(x.toString());

View File

@ -7,7 +7,7 @@
public class AssignmentDifferentTypes {
public static void main(String[] args) {
public static void meth() {
Ref<Der> derexact = null;
Ref<Base> baseexact = null;
Ref<? extends Der> derext = null;

View File

@ -7,7 +7,7 @@
public class AssignmentSameType {
public static void main(String[] args) {
public static void meth() {
Ref<B> exact = null;
Ref<? extends B> ebound = null;
Ref<? super B> sbound = null;

View File

@ -14,7 +14,7 @@ public class T6450290 {
static class A extends Box<A,A> {}
static class B extends Box<B,B> {}
public static void main(String[] args) {
public static void meth() {
Box<?,?> b = new Box<Box<A,A>,Box<A,A>>();
b.value.same = new Box<B,B>(); //javac misses this bad assignment
}

View File

@ -24,9 +24,4 @@ public class NewBeforeOuterConstructed2 {
System.out.println("ok");
}
}
public static void main(String[] args) {
NewBeforeOuterConstructed2 c = new NewBeforeOuterConstructed2(new Object());
Middle m = c.new Middle();
m.f();
}
}

View File

@ -41,7 +41,7 @@ class T8071432 {
}
}
public static void main(String[] args) {
public static void meth() {
Collection<Point> c = Arrays.asList(new Point(1.0, 0.1));
System.out.println("------- 1 ---------------");
System.out.println(c.stream().reduce(0.0,

View File

@ -11,7 +11,7 @@ class LambdaConv10 {
interface Method1<R, A1> { public R call( A1 a1 ); }
public static void main( final String... notUsed ) {
public static void meth() {
Method1<Integer,Integer> m1 = (int i) -> 2 * i;
}
}

View File

@ -17,7 +17,7 @@ class MethodReference20<X> {
static void test(SAM<Integer> s) { }
public static void main(String[] args) {
public static void meth() {
SAM<Integer> s = MethodReference20<String>::new;
test(MethodReference20<String>::new);
}

View File

@ -21,7 +21,7 @@ class MethodReference25 {
static void call(int i, SAM1 s) { s.m(i); }
static void call(int i, SAM2 s) { s.m(i); }
public static void main(String[] args) {
public static void meth() {
call(1, MethodReference25::m); //ambiguous
}
}

View File

@ -34,7 +34,7 @@ public class MethodReference41 {
static void m4(SAM2 s) { }
static void m4(SAM3 s) { }
public static void main(String[] args) {
public static void meth() {
m1(Foo::new);
m2(Foo::new);
m3(Foo::new);

View File

@ -34,7 +34,7 @@ public class MethodReference42 {
static void m4(SAM2 s) { }
static void m4(SAM3 s) { }
public static void main(String[] args) {
public static void meth() {
m1(Foo::new);
m2(Foo::new);
m3(Foo::new);

View File

@ -41,7 +41,7 @@ public class MethodReference43 {
static void m5(SAM3 s) { }
static void m5(SAM4 s) { }
public static void main(String[] args) {
public static void meth() {
m1(Foo::new);
m2(Foo::new);
m3(Foo::new);

View File

@ -36,7 +36,7 @@ public class MethodReference44 {
static void g4(SAM2 s) { }
static void g4(SAM3 s) { }
public static void main(String[] args) {
public static void meth() {
g1(MethodReference44::m);
g2(MethodReference44::m);
g3(MethodReference44::m);

View File

@ -36,7 +36,7 @@ public class MethodReference46 {
static void g4(SAM2 s) { }
static void g4(SAM3 s) { }
public static void main(String[] args) {
public static void meth() {
g1(MethodReference46::m);
g2(MethodReference46::m);
g3(MethodReference46::m);

View File

@ -25,7 +25,7 @@ public class MethodReference47 {
static void g2(SAM1 s) { }
static void g2(SAM2 s) { }
public static void main(String[] args) {
public static void meth() {
g1(MethodReference47::m);
g2(MethodReference47::m);
}

View File

@ -34,7 +34,7 @@ public class MethodReference48 {
static void g4(SAM2 s) { } //ok
static void g4(SAM3 s) { } //ok
public static void main(String[] args) {
public static void meth() {
g1(Foo::m);
g2(Foo::m);
g3(Foo::m);

View File

@ -22,7 +22,7 @@ public class MethodReference60 {
X make(String s);
}
public static void main(String[] args) {
public static void meth() {
BadArrayFactory1<int[]> factory1 = int[]::new; //param mismatch
BadArrayFactory2<int[]> factory2 = int[]::new; //param mismatch
BadArrayFactory3<int[]> factory3 = int[]::new; //param mismatch

View File

@ -20,7 +20,7 @@ public class MostSpecific04 {
void map(LongMapper<? super E> m) { }
}
public static void main(String[] args) {
public static void meth() {
MyList<String> ls = new MyList<String>();
ls.map(e->e.length()); //ambiguous - implicit
ls.map((String e)->e.length()); //ok

View File

@ -20,7 +20,7 @@ public class MostSpecific05 {
void map(NumberConverter<? extends B> m) { }
}
public static void main(String[] args) {
public static void meth() {
MyMapper<Number, Double> mm = new MyMapper<Number, Double>();
mm.map(e->1.0); //ambiguous - implicit
mm.map((Object e)->1.0); //ok

View File

@ -9,7 +9,7 @@
public class LambdaTest2_neg1 {
public static void main(String[] args) {
public static void meth() {
LambdaTest2_neg1 test = new LambdaTest2_neg1();
//not convertible - QooRoo is not a SAM
test.methodQooRoo((Integer i) -> { });

View File

@ -13,7 +13,7 @@ public class MethodRefIntColonColonNewTest {
static <T> SAM<T> infmethod(SAM<T> t) { return t; }
public static void main(String argv[]) {
public static void meth() {
SAM<Object> s = infmethod(int::new);
s.m();
}

View File

@ -17,7 +17,7 @@ class MethodRefToInnerBase {
}
}
public class MethodRefToInnerWithoutOuter extends MethodRefToInnerBase {
public static void main(String[] args) {
public static void meth() {
List<String> list = new ArrayList<>();
list.stream().forEach(TestString::new);
}

Some files were not shown because too many files have changed in this diff Show More