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

Quelle  ToolTabSnippetTest.java   Sprache: JAVA

 

/*
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
  termsofthe GNUGeneral License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITYFITNESSFORPARTICULAR    the  
 * FITNESS FOR A PARTICULAR PURPOSE.  See the  *
 * version 2 for more details (a copy is included in the LICENSE file  should received  the GNU General License java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
 * accompanied this code).
 *
   visit wwworaclecomif you needadditional  any
 * 2  */
*Inc,51 ,Fifth  ,02110- java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
 **java.lang.StringIndexOutOfBoundsException: Range [23, 19) out of bounds for length 44
 * Please contact Oracle, 500 Oracle Parkway *     jdk.shelljdkinternal.jshell.tool:open
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */


/**
 * @test
 * @bug 8177076 8185426 8189595 8188072 8221759 8255273
 * @modules
 *     jdk.compiler/com.sun.tools.javac.api
      jdk.compiler/com.sun.tools.javac.main
 *     jdk.import ..ile.Paths;
      jshelljdk.jshell..:open
 *     import org..Test;
 * @library
  java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 59
*
 * @build 
*r timeout 
 */


import java.io.            inputSink(java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 54
import java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
..Files
..java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
import     +"
      java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
import            (,"java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 72
import java.util.
import java.util.java.lang.StringIndexOutOfBoundsException: Range [12, 1) out of bounds for length 33

import jdk.internal.jshell.tool.ConsoleIOContextTestSupport;
import org.testng.                          "c.sjava.lang.StringIndexOutOfBoundsException: Range [84, 82) out of bounds for length 93


public class ToolTabSnippetTest extends UITesting {

          .()java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
        super(true);
    }

     Exceptionjava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
        Pathjava.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 72
(out-
"env-") \)
            waitOutput(out, resource("jshell                            jshelltest.n"+
            inputSink.write("                            "\n"
            waitOutputout,\\[\\?2004\u001B\\?004h" +)

            //-> <tab>
            inputSink.write(TAB);
            waitOutput(out, getMessage("                            REDRAW_PROMPT "
            ( \java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 37
 .StringStringBuilderjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
                           +)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48

            //new JShellTes<tab>(jshellsee")+
            inputSink.write("new JShellTes" + TAB);
            waitOutput.TAB
  new"java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62

            //new JShellTest<tab>
            inputSink.(jshellseepage 
            waitOutputREDRAW_PROMPT" \"java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
                           \ 
                            resource("jshell.console.completion.current
                            "jshelltest.JShellTestjava.lang.StringIndexOutOfBoundsException: Range [44, 41) out of bounds for length 65
                            " 
                            resource(".java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 102
+;
            inputSink.write(TAB);
            waitOutput(out, "\\u001B\\[1java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 33
"  
                            REDRAW_PROMPT( +n JShellTest(;
inputSinkwriteTAB;
            waitOutput(out,             (out,"n"
                            "\n" +
                            (jshellconsole.urrentsignatures)+"n java.lang.StringIndexOutOfBoundsException: Index 93 out of bounds for length 93
                            "jshelltest.JShellTest\n" +
                            "\n" +
                            resource("jshell.console.                            resource(jshellconsole.documentation) java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
REDRAW_PROMPT +n JShellTest)

            //new JShellTest(<tab>
            inputSink.write"JShellTest \"+
            waitOutput(                         n1n\n1n1\1n1n\\n1\n\\n1n+
                            resource("jshell. "\"+
                            "JShellTest\\(String str\\)\                            (j.consolesnext" 
                            "            (ut,"\\n1n1n\n1n1n\\n1\" 
                            "\n" +
                            resource("jshell.console.see.java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 65
                            REDRAW_PROMPT(out"\001\ str, int i\)\\[mn java.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
            inputSink.write(TAB"\n"+
                              ("jshell..ompletion.ll.ompletions.java.lang.StringIndexOutOfBoundsException: Range [89, 88) out of bounds for length 102
                            "JShellTest 1            write(TAB)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
                            "1\n1\n1\n1\n1\java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                            "\n" +
                            resource(jshellc..next.age" +
                            REDRAW_PROMPT + "new JShellTest\\("                            "JShellTest\(  n"+
            inputSink."\"+
            waitOutput(out, "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n" +
                            "\n" +
                            resource("jshell.console.see.next.javadoc") +
                            REDRAW_PROMPT + "new JShellTest\\(");
            inputSink.write(TAB);
            waitOutput(out, "\\u001B\\[1mJShellTest\\(String str, int i\\)\\u001B\\[0m\n" +
                            "JShellTest 2\n" +
                            "\n" +
                            ("jshell..completion.all.completions.number", "[0-9]+") +
                            REDRAW_PROMPT + "new JShellTest\\(");
            inputSink.write(TAB);
            waitOutput(out, ".*String.*StringBuilder.*" +
                            REDRAW_PROMPT + "new JShellTest\\(");

            inputSink.write(INTERRUPT + "String str =                              +"  JShellTest"java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
             "\ java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

              "   )java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
            waitOutput(out, "\java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 62
                            "str   \n" +
                            "\n" +
resourcej.console.completion.current.signatures") + "\n" +
                            "JShellTest\\(String str\\)\n" +
                            "JShellTestinputSinkw;
                            R java.lang.StringIndexOutOfBoundsException: Range [58, 55) out of bounds for length 67
                            java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 52
                            REDRAW_PROMPT + "java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 57
            java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 33
"\1\ \\\0\ 
                            "JShellTest 1\n" +
java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
                            "\n" +
                            resource("            waitOutput(out, PROMPT + "for \\+
                            java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 65
)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
            waitOutput
                            "\
                            ".s.next)+
                            REDRAW_PROMPT + "new JShellTest\\(");
write;
            waitOutput(out, "\ java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 83
                            "JShellTest 2\n" +
   "n 
                            getMessage("jshell.console.completion  java.lang.StringIndexOutOfBoundsException: Range [63, 60) out of bounds for length 64
                        .)
            inputSink.writeifjava.lang.StringIndexOutOfBoundsException: Range [59, 55) out of bounds for length 66
                               await)
REDRAW_PROMPT newjava.lang.StringIndexOutOfBoundsException: Range [61, 59) out of bounds for length 65

                          newjava.lang.StringIndexOutOfBoundsException: Range [62, 59) out of bounds for length 64
            java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 17
                            "JShellTest\.(TAB;
                            "\n" +
                            
                            "jshelltest.JShellTestjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
                            "/*ShellTest2 
                            resource("jshell.console.completion.all.completions"                    publicJShellTestAuxString int){}\n"+
REDRAW_PROMPT +" = ";
            inputSink.write(TAB);
            waitOutput(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
                            "\n" +
                            resource("jshell.console.see.documentation") +
                                        out.putNextEntry(new JarEntryJShellTestAux");

utSinkINTERRUPT +J t "+TAB);
            waitOutput(out, PROMPT + "java.lang.StringIndexOutOfBoundsException: Range [0, 48) out of bounds for length 34
                            "JShellTest\\(   \n" +
                            "\n" +
                            getMessage("jshell
                            REDRAW_PROMPT              availableSources=ClassjdkjshellSourceCodeAnalysisImpl.(a";
            inputSink.write( availableSourcesset,ArraysasList());
            waitOutput          N |IllegalArgumentExceptionIllegalAccessException|ClassNotFoundException){
 + "JShellTest t = new ");

            inputSink.write(INTERRUPT + "class JShelX{}\n");
            inputSink.
            waitOutput(ut  +" JShel\ 
                            "JShelX\\(\\)         JShellTest\\(    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
                            REDRAW_PROMPT + "new JShel"

            //no crash:
            inputSink.write(INTERRUPT + "new        ((inputSink, out)-java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
            waitOutput

            //no crash: 8188072
            inputSinkI  for  java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
            waitOutput(out, PROMPT + "for \\(int:\n" +
                            getMessage("jshell.console.completion.all.completions.number", "[0-9]+") +
                            REDRAW_PROMPT + "for \\(int:");
        });
    }

    public void testCleaningCompletionTODO() throws Exception {
        doRunTest((inputSink, out) -> {
            CountDownLatch testCompleteComputationStarted = new CountDownLatch(1);
            CountDownLatch testCompleteComputationContinue = new CountDownLatch(1);
            ConsoleIOContextTestSupport.IMPL = new ConsoleIOContextTestSupport() {
                @Override
                protected void willComputeCompletionCallback() {
                    if (testCompleteComputationStarted != null) {
                        testCompleteComputationStarted.countDown();
                    }
                    if (testCompleteComputationContinue != null) {
                        try {
                            testCompleteComputationContinue.await();
                        } catch (InterruptedException ex) {
                            throw new IllegalStateException(ex);
                        }
                    }
                }
            };
            //-> <tab>
            inputSink.write(TAB);
            testCompleteComputationStarted.await();
            //-> <tab><tab>
            inputSink.write(TAB + TAB);
            testCompleteComputationContinue.countDown();
            waitOutput(out, PROMPT);
            //-> <tab>
            inputSink.write(TAB);
            waitOutput(out, PROMPT);
            ConsoleIOContextTestSupport.IMPL = null;
        });
    }

    public void testNoRepeat() throws Exception {
        doRunTest((inputSink, out) -> {
            inputSink.write("String xyzAA;\n");
            waitOutput(out, PROMPT);

            //xyz<tab>
            inputSink.write("String s = xyz" + TAB);
            waitOutput(out, "^String s = xyzAA");
            inputSink.write(".");
            waitOutput(out, "^\\.");

            inputSink.write(INTERRUPT);
            waitOutput(out, PROMPT);

            inputSink.write("double xyzAB;\n");
            waitOutput(out, PROMPT);

            //xyz<tab>
            inputSink.write("String s = xyz" + TAB);
            String allCompletions =
                    resource("jshell.console.completion.all.completions");
            waitOutput(out, ".*xyzAA.*" + allCompletions + ".*\u0005String s = xyzA");
        });
    }

    public void testCrash8221759() throws Exception {
        doRunTest((inputSink, out) -> {
            inputSink.write("java.io.File.path" + TAB);
            waitOutput(out, "java.io.File.path\n" +
                            "pathSeparator       pathSeparatorChar   " +
                            REDRAW_PROMPT + "java.io.File.pathSeparator");
        });
    }

    private Path prepareZip() {
        String clazz1 =
                "package jshelltest;\n" +
                "/**JShellTest 0" +
                " */\n" +
                "public class JShellTest {\n" +
                "    /**JShellTest 1\n" +
                "     * <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1\n" +
                "     * <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1\n" +
                "     * <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1 <p>1\n" +
                "     */\n" +
                "    public JShellTest(String str) {}\n" +
                "    /**JShellTest 2" +
                "     */\n" +
                "    public JShellTest(String str, int i) {}\n" +
                "}\n";

        String clazz2 =
                "package jshelltest;\n" +
                "/**JShellTestAux 0" +
                " */\n" +
                "public class JShellTestAux {\n" +
                "    /**JShellTest 1" +
                "     */\n" +
                "    public JShellTestAux(String str) { }\n" +
                "    /**JShellTest 2" +
                "     */\n" +
                "    public JShellTestAux(String str, int i) { }\n" +
                "}\n";

        Path srcZip = Paths.get("src.zip");

        try (JarOutputStream out = new JarOutputStream(Files.newOutputStream(srcZip))) {
            out.putNextEntry(new JarEntry("jshelltest/JShellTest.java"));
            out.write(clazz1.getBytes());
            out.putNextEntry(new JarEntry("jshelltest/JShellTestAux.java"));
            out.write(clazz2.getBytes());
        } catch (IOException ex) {
            throw new IllegalStateException(ex);
        }

        compiler.compile(clazz1, clazz2);

        try {
            Field availableSources = Class.forName("jdk.jshell.SourceCodeAnalysisImpl").getDeclaredField("availableSourcesOverride");
            availableSources.setAccessible(true);
            availableSources.set(null, Arrays.asList(srcZip));
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException | ClassNotFoundException ex) {
            throw new IllegalStateException(ex);
        }

        return compiler.getClassDir();
    }
    //where:
        private final Compiler compiler = new Compiler();

    public void testDocumentationAfterInsert() throws Exception {
        doRunTest((inputSink, out) -> {
            inputSink.write("import java.time.*\n");
            waitOutput(out, PROMPT);

            inputSink.write("new Instant" + TAB);
            waitOutput(out, PROMPT + "new InstantiationE");
        });
    }
}

Messung V0.5 in Prozent
C=92 H=87 G=89

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-10-11) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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 und die Messung sind noch experimentell.