Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openjdk/test/langtools/tools/javac/lambda/   (Sun/Oracle ©)  Datei vom 13.11.2022 mit Größe 1 kB image not shown  

Quelle  LambdaExpr19.java   Sprache: JAVA

 
/*
 * @test /nodynamiccopyright/
 * @bug 8003280
 * @summary Add lambda tests
 *  check that inner scopes are left after a lambda check exception has been thrown
 * @compile/fail/ref=LambdaExpr19.out -XDrawDiagnostics LambdaExpr19.java
 */

class LambdaExpr19 {

    interface SAM {
        String m();
    }

    void m(SAM s) { }

    void testTry() {
        m(() -> {
                try { return 1; }
                catch (Exception e) { }
            });
    }

    void testTryWithResources() {
        m(() -> {
                try (AutoCloseable c = null) { return 1; }
                catch (Exception e) { }
            });
    }

    void testSwitch() {
        m(() -> {
                switch (1) {
                    defaultreturn 1;
                }
            });
    }

    void testFor() {
        m(() -> {
                for (;;) {
                    return 1;
                }
            });
    }

    void testForeach() {
        m(() -> {
                for (Object o : new Object[] { null , null }) {
                    return 1;
                }
            });
    }
}

84%


¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.