src/sample/nashorn/consoleuse.js
author herrick
Tue, 12 Feb 2019 11:54:56 -0500
branchJDK-8200758-branch
changeset 57180 1d6f8a7c6d5a
parent 47216 71c04702a3d5
permissions -rw-r--r--
8217687: jpackage --help improvements Reviewed-by: almatvee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30702
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     1
/*
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     3
 *
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     6
 * are met:
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     7
 *
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    10
 *
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    14
 *
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    18
 *
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    30
 */
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    31
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    32
load(__DIR__ + "console.js");
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    33
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    34
console.log("consoleuse.js started!");
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    35
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    36
function func() {
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    37
    console.count("func");
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    38
}
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    39
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    40
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    41
func();
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    42
func();
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    43
func();
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    44
func();
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    45
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    46
// java.io.Console method
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    47
console.readPassword("passworld please: ");
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    48
console.error("Big error: %s!", "you revealed your password!");
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    49
console.warn("You've done this %d times", 345);
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    50
console.assert(arguments.length != 0, "no arguments!");
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    51
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    52
// java.io.Console methods
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    53
var str = console.readLine("enter something: ");
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    54
console.printf("you entered: %s\n", str);
ce6a8edae925 8080848: delete of bound Java method property results in crash
sundar
parents:
diff changeset
    55