8003280: Add lambda tests

Turn on lambda expression, method reference and default method support

Reviewed-by: jjg
This commit is contained in:
Maurizio Cimadamore 2012-11-17 19:01:03 +00:00
parent c39f1d99b4
commit a494f0ab86
451 changed files with 15433 additions and 488 deletions

View file

@ -25,7 +25,7 @@
* @test
* @summary check that default methods don't cause ClassReader to complete classes recursively
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods pkg/Foo.java
* @compile pkg/Foo.java
* @compile ClassReaderTest.java
*/

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary negative test for ambiguous defaults
* @compile/fail/ref=Neg01.out -XDallowDefaultMethods -XDrawDiagnostics Neg01.java
* @compile/fail/ref=Neg01.out -XDrawDiagnostics Neg01.java
*/
class Neg01 {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that ill-formed MI hierarchies do not compile
* @compile/fail/ref=Neg02.out -XDallowDefaultMethods -XDrawDiagnostics Neg02.java
* @compile/fail/ref=Neg02.out -XDrawDiagnostics Neg02.java
*/
class Neg02 {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that re-abstraction works properly
* @compile/fail/ref=Neg03.out -XDallowDefaultMethods -XDrawDiagnostics Neg03.java
* @compile/fail/ref=Neg03.out -XDrawDiagnostics Neg03.java
*/
class Neg03 {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that default method must have most specific return type
* @compile/fail/ref=Neg04.out -XDallowDefaultMethods -XDrawDiagnostics Neg04.java
* @compile/fail/ref=Neg04.out -XDrawDiagnostics Neg04.java
*/
class Neg04 {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that abstract methods are compatible with inherited defaults
* @compile/fail/ref=Neg05.out -XDallowDefaultMethods -XDrawDiagnostics Neg05.java
* @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java
*/
class Neg05 {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary flow analysis is not run on inlined default bodies
* @compile/fail/ref=Neg06.out -XDallowDefaultMethods -XDrawDiagnostics Neg06.java
* @compile/fail/ref=Neg06.out -XDrawDiagnostics Neg06.java
*/
class Neg06 {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that default overrides are properly type-checked
* @compile/fail/ref=Neg07.out -XDallowDefaultMethods -XDrawDiagnostics Neg07.java
* @compile/fail/ref=Neg07.out -XDrawDiagnostics Neg07.java
*/
class Neg07 {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that default overrides are properly type-checked
* @compile/fail/ref=Neg08.out -XDallowDefaultMethods -XDrawDiagnostics Neg08.java
* @compile/fail/ref=Neg08.out -XDrawDiagnostics Neg08.java
*/
class Neg08 {
interface I {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that default overrides are properly type-checked
* @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg09.java
* @compile/fail/ref=Neg09.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg09.java
*/
import java.util.List;

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that default overrides are properly type-checked
* @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDallowDefaultMethods -XDrawDiagnostics Neg10.java
* @compile/fail/ref=Neg10.out -Werror -Xlint:unchecked -XDrawDiagnostics Neg10.java
*/
class Neg10 {
interface I<X extends Exception> {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that default overrides are properly type-checked
* @compile/fail/ref=Neg11.out -XDallowDefaultMethods -XDrawDiagnostics Neg11.java
* @compile/fail/ref=Neg11.out -XDrawDiagnostics Neg11.java
*/
class Neg11 {
interface I {

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that abstract methods are discarded in overload resolution diags
* @compile/fail/ref=Neg12.out -XDallowDefaultMethods -XDrawDiagnostics Neg12.java
* @compile/fail/ref=Neg12.out -XDrawDiagnostics Neg12.java
*/
class Neg12 {

View file

@ -1,4 +1,4 @@
Neg12.java:21:12: compiler.err.does.not.override.abstract: Neg12.D, m(java.lang.String), Neg12.I2
Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, ,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))}
Neg12.java:24:10: compiler.err.cant.apply.symbols: kindname.method, m, compiler.misc.no.args,{(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch))}
Neg12.java:25:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Integer, compiler.misc.no.args, kindname.class, Neg12.B, (compiler.misc.arg.length.mismatch)
3 errors

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that default method overriding object members are flagged as error
* @compile/fail/ref=Neg13.out -XDallowDefaultMethods -XDrawDiagnostics Neg13.java
* @compile/fail/ref=Neg13.out -XDrawDiagnostics Neg13.java
*/
interface Neg13 {
default protected Object clone() { return null; } //protected not allowed here

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that a class cannot have two sibling interfaces with a default and abstract method
* @compile/fail/ref=Neg14.out -XDallowDefaultMethods -XDrawDiagnostics Neg14.java
* @compile/fail/ref=Neg14.out -XDrawDiagnostics Neg14.java
*/
class Neg14 {
interface IA { int m(); }

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that level skipping in default super calls is correctly rejected
* @compile/fail/ref=Neg15.out -XDallowDefaultMethods -XDrawDiagnostics Neg15.java
* @compile/fail/ref=Neg15.out -XDrawDiagnostics Neg15.java
*/
class Neg15 {
interface I { default void m() { } }

View file

@ -1,7 +1,7 @@
/*
* @test /nodynamiccopyright/
* @summary check that level skipping in default super calls is correctly rejected
* @compile/fail/ref=Neg16.out -XDallowDefaultMethods -XDrawDiagnostics Neg16.java
* @compile/fail/ref=Neg16.out -XDrawDiagnostics Neg16.java
*/
class Neg16 {
interface I { default void m() { } }

View file

@ -24,14 +24,12 @@
/*
* @test
* @summary basic test for default methods
* @ignore awaits lambda support
* @author Maurizio Cimadamore
* @compile -XDallowLambda -XDallowPoly -XDallowDefaultMethods Pos01.java
*/
import java.util.*;
class Pos01 {
public class Pos01 {
interface Mapper<T> {
T map(T in);

View file

@ -25,7 +25,7 @@
* @test
* @summary test for explicit resolution of ambiguous default methods
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods Pos02.java
* @compile Pos02.java
*/
class Pos02 {

View file

@ -25,7 +25,7 @@
* @test
* @summary test for overriding with default method
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods Pos04.java
* @compile Pos04.java
*/
class Pos04 {

View file

@ -25,7 +25,7 @@
* @test
* @summary check that indirectly inherited default methods are discovered during resolution
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods Pos05.java
* @compile Pos05.java
*/
class Pos05 {

View file

@ -25,7 +25,7 @@
* @test
* @summary check that well-formed MI hierarchies behaves well w.r.t. method resolution (i.e. no ambiguities)
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods Pos06.java
* @compile Pos06.java
*/
class Pos06 {

View file

@ -25,7 +25,7 @@
* @test
* @summary check that compilation order does not matter
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods Pos07.java
* @compile Pos07.java
*/
class Pos07 {

View file

@ -25,7 +25,7 @@
* @test
* @summary check that common overrider solves default method conflicts
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods Pos08.java
* @compile Pos08.java
*/
class Pos08 {

View file

@ -25,7 +25,7 @@
* @test
* @summary check that type-variables in generic extension decl can be accessed from default impl
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods Pos10.java
* @compile Pos10.java
*/
class Pos10 {

View file

@ -25,7 +25,7 @@
* @test
* @summary complex test with conflict resolution via overriding
* @author Brian Goetz
* @compile -XDallowDefaultMethods Pos11.java
* @compile Pos11.java
*/
class Pos11 {

View file

@ -24,7 +24,7 @@
/*
* @test
* @summary check that 'this' can be used from within an extension method
* @compile -XDallowDefaultMethods Pos12.java
* @compile Pos12.java
*/
interface Pos12 {

View file

@ -24,7 +24,7 @@
/*
* @test
* @summary qualified 'this' inside default method causes StackOverflowException
* @compile -XDallowDefaultMethods Pos13.java
* @compile Pos13.java
*/
public class Pos13 {

View file

@ -24,7 +24,7 @@
/*
* @test
* @summary check that overload resolution selects most specific signature
* @compile -XDallowDefaultMethods Pos14.java
* @compile Pos14.java
*/
class Pos14 {

View file

@ -24,7 +24,7 @@
/*
* @test
* @summary check that overload resolution selects most specific signature
* @compile -XDallowDefaultMethods Pos15.java
* @compile Pos15.java
*/
class Pos15 {

View file

@ -24,7 +24,7 @@
/*
* @test
* @summary 'class wins' should not short-circuit overload resolution
* @compile -XDallowDefaultMethods Pos16.java
* @compile Pos16.java
*/
class Pos16 {

View file

@ -23,10 +23,7 @@
/*
* @test
* @ignore awaits for VM support
* @summary check that code attributed for default methods is correctly generated
* @compile -XDallowDefaultMethods TestDefaultBody.java
* @run main TestDefaultBody
*/
import com.sun.tools.classfile.AccessFlags;

View file

@ -25,8 +25,6 @@
* @test
* @ignore awaits for VM support
* @summary check that javac does not generate bridge methods for defaults
* @compile -XDallowDefaultMethods TestNoBridgeOnDefaults.java
* @run main TestNoBridgeOnDefaults
*/
import com.sun.tools.classfile.ClassFile;

View file

@ -82,7 +82,7 @@ public class FDTest {
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source));
null, null, Arrays.asList(source));
try {
ct.analyze();
} catch (Throwable ex) {

View file

@ -25,8 +25,8 @@
* @test
* @summary smoke test for separate compilation of default methods
* @author Maurizio Cimadamore
* @compile -XDallowDefaultMethods pkg1/A.java
* @compile -XDallowDefaultMethods Separate.java
* @compile pkg1/A.java
* @compile Separate.java
*/
import pkg1.A;

View file

@ -323,7 +323,7 @@ public class TestDefaultSuperCall {
void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
Arrays.asList("-XDallowDefaultMethods"), null, Arrays.asList(source));
null, null, Arrays.asList(source));
try {
ct.analyze();
} catch (Throwable ex) {

View file

@ -54,7 +54,7 @@ public class TestDefaultMethodsSyntax {
}
List<String> getOptions() {
return Arrays.asList("-XDallowDefaultMethods", "-source", versionString);
return Arrays.asList("-source", versionString);
}
}