Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/launcher/ClassPathWildCard.sh
41144 views
1
#!/bin/sh
2
# @test
3
# @bug 6510337
4
# @run shell ClassPathWildCard.sh
5
# @summary A very basic/rudimentary test for classpath wildcards
6
# @author Kumar Srinivasan
7
8
#
9
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
10
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11
#
12
# This code is free software; you can redistribute it and/or modify it
13
# under the terms of the GNU General Public License version 2 only, as
14
# published by the Free Software Foundation.
15
#
16
# This code is distributed in the hope that it will be useful, but WITHOUT
17
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
# version 2 for more details (a copy is included in the LICENSE file that
20
# accompanied this code).
21
#
22
# You should have received a copy of the GNU General Public License version
23
# 2 along with this work; if not, write to the Free Software Foundation,
24
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25
#
26
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
27
# or visit www.oracle.com if you need additional information or have any
28
# questions.
29
#
30
31
# An elaborate wildcard testing is done by test/tools/javac/Paths/wcMineField.sh,
32
# this test is a small subset, primarily to ensure that java and javaw launcher
33
# behave consistently, while we are it , doesn't hurt to test other platforms
34
# as well.
35
36
# For debugging
37
# set -x
38
# _JAVA_LAUNCHER_DEBUG=true ; export _JAVA_LAUNCHER_DEBUG
39
40
# Verify directory context variables are set
41
if [ "${TESTJAVA}" = "" ]; then
42
echo "TESTJAVA not set. Test cannot execute. Failed."
43
exit 1
44
fi
45
46
if [ "${COMPILEJAVA}" = "" ]; then
47
COMPILEJAVA="${TESTJAVA}"
48
fi
49
50
if [ "${TESTSRC}" = "" ]; then
51
echo "TESTSRC not set. Test cannot execute. Failed."
52
exit 1
53
fi
54
55
if [ "${TESTCLASSES}" = "" ]; then
56
echo "TESTCLASSES not set. Test cannot execute. Failed."
57
exit 1
58
fi
59
60
JAVA=$TESTJAVA/bin/java
61
JAVAC=$COMPILEJAVA/bin/javac
62
JAR=$COMPILEJAVA/bin/jar
63
64
OUTEXT=".out"
65
66
# We write out a test file, as javaw does not have any notion about
67
# stdout or stderr.
68
69
EmitJavaFile() {
70
fullName=$1
71
fileName=`basename $fullName .java`
72
73
(
74
printf "import java.io.*;\n"
75
printf "public class %s {\n" $fileName
76
printf " public static void main(String[] args) {"
77
printf " String m = \"%s:\";\n" $fileName
78
printf " m = m.concat(\"java.class.path=\");\n"
79
printf " m = m.concat(System.getProperty(\"java.class.path\",\"NONE\"));\n"
80
printf " System.out.println(m);\n"
81
printf " try {\n"
82
printf " PrintStream ps = new PrintStream(\"%s\");\n" $fileName$OUTEXT
83
printf " ps.println(m);\n"
84
printf " ps.flush(); ps.close();\n"
85
printf " } catch (Exception e) {\n"
86
printf " System.out.println(e.getMessage());\n"
87
printf " System.exit(1);\n"
88
printf " }\n"
89
printf " }\n"
90
printf "}\n"
91
) > $fullName
92
}
93
94
CreateClassFiles() {
95
Exp=$1
96
[ -d Test${Exp} ] || mkdir Test${Exp}
97
EmitJavaFile Test${Exp}/Test${Exp}.java
98
$JAVAC ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d Test${Exp} Test${Exp}/Test${Exp}.java || exit 1
99
}
100
101
CreateJarFiles() {
102
Exp=$1
103
[ -d JarDir ] || mkdir JarDir
104
CreateClassFiles $Exp
105
$JAR ${TESTTOOLVMOPTS} -cvf JarDir/Test${Exp}.jar -C Test${Exp} . || exit 1
106
}
107
108
CheckFail() {
109
if [ ! -f ${1}${OUTEXT} ]; then
110
printf "Error: %s fails\n" "$1"
111
exit 1
112
fi
113
}
114
115
# Note: see CR:6328875 this is why we use the NOOP variable
116
# below on Windows
117
118
ExecJava() {
119
variant=$1
120
NOOP=$2
121
122
# Test JAR files first
123
rm -f TestA${OUTEXT}
124
$JAVA${variant} -classpath JarDir/"*"$NOOP TestA || exit 1
125
CheckFail TestA
126
127
rm -f TestB${OUTEXT}
128
$JAVA${variant} -cp JarDir/"*"$NOOP TestB || exit 1
129
CheckFail TestB
130
131
132
# Throw some class files into the mix
133
cp TestC/*.class JarDir
134
cp TestD/*.class JarDir
135
136
rm -f TestC${OUTEXT}
137
$JAVA${variant} --class-path JarDir${PATHSEP}JarDir/"*"$NOOP TestC || exit 1
138
CheckFail TestC
139
140
rm -f TestD${OUTEXT}
141
$JAVA${variant} --class-path=JarDir${PATHSEP}JarDir/"*"$NOOP TestD || exit 1
142
CheckFail TestD
143
}
144
145
CreateJarFiles A
146
CreateJarFiles B
147
CreateClassFiles C
148
CreateClassFiles D
149
150
OS=`uname -s`
151
case $OS in
152
Windows*|CYGWIN*)
153
PATHSEP=";"
154
ExecJava "" "${PATHSEP}NOOPDIR"
155
ExecJava "w" "${PATHSEP}NOOPDIR"
156
break
157
;;
158
159
*)
160
PATHSEP=":"
161
ExecJava "" ""
162
break
163
;;
164
esac
165
166
exit 0
167
168