1113N/A# @bug 4811102 4953711 4955505 4956301 4991229 4998210 5018605 6387069 6733959 0N/A# @build PrintVersion 0N/A# @build UglyPrintVersion 0N/A# @summary Verify Multiple JRE version support 0N/A# @author Joseph E. Kowalski 2362N/A# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A# This code is free software; you can redistribute it and/or modify it 0N/A# under the terms of the GNU General Public License version 2 only, as 0N/A# published by the Free Software Foundation. 0N/A# This code is distributed in the hope that it will be useful, but WITHOUT 0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A# version 2 for more details (a copy is included in the LICENSE file that 0N/A# accompanied this code). 0N/A# You should have received a copy of the GNU General Public License version 0N/A# 2 along with this work; if not, write to the Free Software Foundation, 0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A# Verify directory context variables are set 0N/Aif [
"${TESTJAVA}" =
"" ]
0N/A echo "TESTJAVA not set. Test cannot execute. Failed." 0N/Aif [
"${TESTSRC}" =
"" ]
0N/A echo "TESTSRC not set. Test cannot execute. Failed." 0N/Aif [
"${TESTCLASSES}" =
"" ]
0N/A echo "TESTCLASSES not set. Test cannot execute. Failed." 1113N/A# Tests whether we are on windows (true) or not. 0N/A# Shell routine to test for the proper rejection of syntactically incorrect 0N/A# version specifications. 0N/A echo "Invalid version syntax $1 accepted" 0N/A echo "Unexpected error message for invalid syntax $1" 0N/A# Just as the name says. We sprinkle these in the appropriate location 0N/A# in the test file system and they just say who they are pretending to be. 0N/A# Constructs the jar file needed by these tests. 0N/A if [ "$1" != "" ]; then 0N/A# Constructs a jar file using zip. 0N/A if [ "$1" != "" ]; then 0N/A# Constructs a jar file with a Main-Class attribute of greater than 0N/A# 80 characters to validate the continuation line processing. 0N/A# Make this just long enough to require two continuation lines. Longer 0N/A# paths take too much away from the restricted Windows maximum path length. 0N/A# Note: see the variable UGLYCLASS and its check for path length. 0N/A# Make sure that 5018605 remains fixed by including additional sections 0N/A# in the Manifest which contain the same names as those allowed in the 0N/A if [ "$1" != "" ]; then 0N/A# Constructs a jar file with a fair number of "zip directory" entries and 0N/A# the MANIFEST.MF entry at or near the end of that directory to validate 0N/A# the ability to transverse that directory. 0N/A if [ "$1" != "" ]; then 0N/A for i in 0 1 2 3 4 5 6 7 8 9 ; do 0N/A for j in 0 1 2 3 4 5 6 7 8 9 ; do 0N/A# Creates a jar file with the attributes which caused the failure 0N/A# described in 4991229. 0N/A# Generate a bunch of CENTAB entries, each of which is 64 bytes long 0N/A# which practically guarentees we will hit the appropriate power of 0N/A# two buffer (initially 1K). Note that due to the perversity of 0N/A# zip/jar files, the first entry gets extra stuff so it needs a 0N/A# shorter name to compensate. 0N/A if [ "$1" != "" ]; then 0N/A for i in 0 1 2 3 4 5 6 7 8 9 ; do 0N/A for j in 0 1 2 3 4 5 6 7 8 9 ; do 0N/A# Adds comments to a jar/zip file. This serves two purposes: 0N/A# 1) Make sure zip file comments (both per file and per archive) are 0N/A# properly processed and ignored. 0N/A# 2) A long file comment creates a mondo "Central Directory" entry in 0N/A# the zip file. Such a "mondo" entry could also be due to a very 0N/A# long file name (path) or a long "Ext" entry, but adding the long 0N/A# comment is the easiest way. 0N/A tail="is designed to take up space - lots and lots of space." 0N/A if [ "$line" = "(comment above this line)" ]; then 0N/A for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do 0N/A for j in 0 1 2 3 4 5 6 7 8 9 a b c d e f; do 0N/A if [ "$line" = "(zip file comment below this line)" ]; then 0N/A echo "Zip File Comment Line number 1" >> zipin 0N/A echo "Zip File Comment Line number 2" >> zipin 0N/A# Attempt to launch a vm using a version specifier and make sure the 0N/A# resultant launch (probably a "mock vm") is appropriate. 0N/A if [ "$1" != "" ]; then 0N/A echo "Unexpected error in attempting to locate $1" 0N/A if [ $? != 0 ]; then 1113N/A# Tests very long Main-Class attribute in the jar 0N/A# Main test sequence starts here 0N/A# Make sure that the generic jar/manifest reading code works. Test both 0N/A# compressed and "stored" jar files. 0N/A# The "Ugly" jar (long manifest line) tests are only run if the combination 0N/A# of the file name length restrictions and the length of the cwd allow it. 0N/A# 4998210 shows that some very strange behaviors are semi-supported. 0N/A# In this case, it's the ability to prepend any kind of stuff to the 0N/A# jar file and require that the jar file still work. Note that this 0N/A# "interface" isn't publically supported and we may choose to break 0N/A# it in the future, but this test guarantees that we won't break it 0N/A# without informed consent. We take advantage the fact that the 0N/A# "FullJar" we just tested is probably the best jar to begin with 0N/Aecho "This is just meaningless bytes to prepend to the jar" >
meaningless 0N/A# Officially, one must use "the jar command to create a jar file. However, 0N/A# all the comments about jar commands **imply** that jar files and zip files 0N/A# are equivalent. (Note: this isn't true due to the "0xcafe" insertion.) 0N/A# On systems which have a command line zip, test the ability to use zip 0N/A# to construct a jar and then use it (6387069). 0N/A# jar files shouldn't have comments, but it is possible that somebody added 0N/A# one by using zip -c, zip -z, zipnote or a similar utility. On systems 0N/A# that have "zipnote", verify this functionality. 0N/A# This serves a dual purpose of creating a very large "central directory 0N/A# entry" which validates to code to read such entries. 0N/A# Throw some syntactically challenged (illegal) version specifiers at 0N/A# the interface. Failure (of the launcher) is success for the test. 1113N/A# On windows we see if there is another jre installed, usually 1113N/A# there is, then we test using that, otherwise links are created 1113N/A# to get through to SelectVersion. 1113N/A printf "Warning: TestLongMainClass skipped as there is no" 0N/A# Because scribbling in the registry can be rather destructive, only a 0N/A# subset of the tests are run on Windows. 0N/A# Additional version specifiers containing spaces. (Sigh, unable to 0N/A# figure out the glomming on Windows) 0N/A# Create a mock installation of a number of shell scripts named as though 0N/A# they were installed JREs. Then test to see if the launcher can cause 0N/A# the right shell scripts to be invoked. 0N/A# Note, that as a side effect, this test verifies that JAVA_VERSION_PATH 0N/A# Test extracting the version information from the jar file: 0N/A# Test obtaining the version information from the command line (and that 0N/A# it overrides the manifest). 0N/ALaunchVM "1.13.3_03+&1.13.3*" "1.13.3_03_lastweek" # Strange but true