jdk/test/java/lang/SecurityManager/modules/CustomSecurityManager.sh
author mchung
Wed, 10 Aug 2016 15:51:25 -0700
changeset 40261 86a49ba76f52
parent 36511 9d0388c6b336
permissions -rw-r--r--
8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
#
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     2
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     4
#
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     7
# published by the Free Software Foundation.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
#
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
# This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
# version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
# accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
#
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
# You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
# 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
#
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
# or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
# questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
#
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
# @test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
# @summary Basic test of -Djava.security.manager to a class in named module.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    27
set -e
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
if [ -z "$TESTJAVA" ]; then
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    30
  if [ $# -lt 1 ]; then exit 1; fi
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
  TESTJAVA="$1"; shift
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
  COMPILEJAVA="${TESTJAVA}"
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
  TESTSRC=`pwd`
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    34
  TESTCLASSES=`pwd`
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
fi
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
OS=`uname -s`
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
case "$OS" in
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
  Windows*)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
    PS=";"
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    41
    ;;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
  CYGWIN* )
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    43
    PS=";"
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
    ;;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    45
  * )
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
    PS=":"
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    47
    ;;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
esac
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
JAVAC="$COMPILEJAVA/bin/javac"
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
JAVA="$TESTJAVA/bin/java ${TESTVMOPTS}"
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
mkdir -p mods
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 36511
diff changeset
    54
$JAVAC -d mods --module-source-path ${TESTSRC} `find ${TESTSRC}/m -name "*.java"`
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
mkdir -p classes
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
$JAVAC -d classes ${TESTSRC}/Test.java
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 36511
diff changeset
    59
$JAVA -cp classes --module-path mods --add-modules m \
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
    -Djava.security.manager \
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
    -Djava.security.policy=${TESTSRC}/test.policy Test
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 36511
diff changeset
    62
$JAVA -cp classes --module-path mods --add-modules m \
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
    -Djava.security.manager=p.CustomSecurityManager \
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
    -Djava.security.policy=${TESTSRC}/test.policy Test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
exit 0