src/sample/nashorn/bad_patterns.js
author mbaesken
Fri, 13 Sep 2019 11:04:46 +0200
changeset 58173 6a30ad1cfeec
parent 47457 217860329f71
permissions -rw-r--r--
8230901: missing ReleaseStringUTFChars in serviceability native code Reviewed-by: stuefe, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47457
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     1
/*
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     3
 *
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     6
 * are met:
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     7
 *
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    10
 *
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    14
 *
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    15
 *   - Neither the name of Oracle nor the names of its
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    18
 *
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    30
 */
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    31
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    32
/**
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    33
 * This is a test script file for staticchecker.js.
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    34
 *
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    35
 * Usage:
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    36
 *    jjs --language=es6 staticcheker.js -- bad_patterns.js
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    37
 */
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    38
var obj = {}
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    39
obj.__proto__ = null;
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    40
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    41
with(obj) {}
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    42
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    43
delete obj;
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    44
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    45
eval("print('hello')")
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    46
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    47
Object = null
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    48
JavaImporter = undefined
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    49
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    50
function func() {}
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    51
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    52
func.prototype.x = 44;
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    53
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    54
Object.prototype.foo = "hello";
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    55
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    56
String.prototype.bar = function() {}
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    57
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    58
try {
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    59
   eval("***");
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    60
} catch(e) {}
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    61
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    62
try {
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    63
   eval("***");
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    64
} catch(e) { ; }
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    65
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    66
try {
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    67
   eval("***");
217860329f71 8190217: Add a JS "static checker" sample for nashorn parser API
sundar
parents:
diff changeset
    68
} catch(e) { print(e) }