Thu, 07 Jun 2012 20:30:57 -0700
7170079: Adjustments to build-infra makefiles
Reviewed-by: ohair, ohrstrom, ihse, jonas
Contributed-by: jonas <jonas.oreland@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
duke@1 | 1 | #!/bin/sh |
duke@1 | 2 | |
duke@1 | 3 | # |
jjg@874 | 4 | # Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 5 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 6 | # |
duke@1 | 7 | # This code is free software; you can redistribute it and/or modify it |
duke@1 | 8 | # under the terms of the GNU General Public License version 2 only, as |
duke@1 | 9 | # published by the Free Software Foundation. |
duke@1 | 10 | # |
duke@1 | 11 | # This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | # version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | # accompanied this code). |
duke@1 | 16 | # |
duke@1 | 17 | # You should have received a copy of the GNU General Public License version |
duke@1 | 18 | # 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | # |
ohair@554 | 21 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | # or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | # questions. |
duke@1 | 24 | # |
duke@1 | 25 | |
duke@1 | 26 | # |
duke@1 | 27 | # @test |
duke@1 | 28 | # @bug 4884487 6295519 6236704 6429613 |
duke@1 | 29 | # @summary Test for proper diagnostics during path manipulation operations |
duke@1 | 30 | # @author Martin Buchholz |
duke@1 | 31 | # |
duke@1 | 32 | # @run shell/timeout=180 Diagnostics.sh |
duke@1 | 33 | |
duke@1 | 34 | # To run this test manually, simply do ./Diagnostics.sh |
duke@1 | 35 | |
duke@1 | 36 | . ${TESTSRC-.}/Util.sh |
duke@1 | 37 | |
duke@1 | 38 | set -u |
duke@1 | 39 | |
duke@1 | 40 | BCP=`DefaultBootClassPath` |
duke@1 | 41 | |
duke@1 | 42 | DiagnosticsInEnglishPlease |
duke@1 | 43 | |
duke@1 | 44 | No() { NO="no"; "$@"; NO=""; } # No means NO! |
duke@1 | 45 | |
duke@1 | 46 | Warning() { |
duke@1 | 47 | HorizontalRule |
duke@1 | 48 | echo "$@" |
duke@1 | 49 | output=`"$@" 2>&1`; rc="$?" |
duke@1 | 50 | test -n "$output" && echo "$output" |
duke@1 | 51 | test $rc -eq 0 || Fail "Command \"$*\" failed with exitValue $rc"; |
duke@1 | 52 | case "$output" in *warning:*) gotwarning="yes";; *) gotwarning="no";; esac |
duke@1 | 53 | |
duke@1 | 54 | if test "$gotwarning" = "yes" -a "$NO" = "no"; then |
duke@1 | 55 | Fail "Command \"$*\" printed an unexpected warning" |
duke@1 | 56 | elif test "$gotwarning" = "no" -a "$NO" != "no"; then |
duke@1 | 57 | Fail "Command \"$*\" did not generate the expected warning" |
duke@1 | 58 | fi |
duke@1 | 59 | } |
duke@1 | 60 | |
duke@1 | 61 | Error() { |
duke@1 | 62 | HorizontalRule |
duke@1 | 63 | echo "$@" |
duke@1 | 64 | output=`"$@" 2>&1`; rc="$?" |
duke@1 | 65 | test -n "$output" && echo "$output" |
duke@1 | 66 | case "$output" in *error:*) goterror="yes";; *) goterror="no";; esac |
duke@1 | 67 | |
duke@1 | 68 | if test "$NO" = "no"; then |
duke@1 | 69 | test "$rc" -ne 0 && \ |
duke@1 | 70 | Fail "Command \"$*\" failed with return code $rc" |
duke@1 | 71 | test "$goterror" = "yes" && \ |
duke@1 | 72 | Fail "Command \"$*\" did not generate any error message" |
duke@1 | 73 | else |
duke@1 | 74 | test "$rc" -eq 0 && \ |
duke@1 | 75 | Fail "Command \"$*\" was supposed to Die with fatal error"; |
duke@1 | 76 | test "$goterror" = "no" && \ |
duke@1 | 77 | Fail "Command \"$*\" printed an unexpected error message" |
duke@1 | 78 | fi |
duke@1 | 79 | } |
duke@1 | 80 | |
duke@1 | 81 | Cleanup() { |
duke@1 | 82 | Sys rm -rf Main.java Main.class |
duke@1 | 83 | Sys rm -rf classes classes.foo classes.jar classes.war classes.zip |
duke@1 | 84 | Sys rm -rf MANIFEST.MF classesRef.jar classesRefRef.jar jars |
duke@1 | 85 | } |
duke@1 | 86 | |
duke@1 | 87 | Cleanup |
duke@1 | 88 | echo "public class Main{public static void main(String[]a){}}" > Main.java |
duke@1 | 89 | |
duke@1 | 90 | #---------------------------------------------------------------- |
duke@1 | 91 | # No warnings unless -Xlint:path is used |
duke@1 | 92 | #---------------------------------------------------------------- |
duke@1 | 93 | No Warning "$javac" ${TESTTOOLVMOPTS} Main.java |
duke@1 | 94 | No Warning "$javac" ${TESTTOOLVMOPTS} -cp ".${PS}classes" Main.java |
duke@1 | 95 | |
duke@1 | 96 | #---------------------------------------------------------------- |
duke@1 | 97 | # Warn for missing elts in user-specified paths |
duke@1 | 98 | #---------------------------------------------------------------- |
duke@1 | 99 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes" Main.java |
duke@1 | 100 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath/p:classes" Main.java |
duke@1 | 101 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint "-Xbootclasspath/a:classes" Main.java |
duke@1 | 102 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-endorseddirs" "classes" Main.java |
duke@1 | 103 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint "-extdirs" "classes" Main.java |
duke@1 | 104 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath:classes${PS}${BCP}" Main.java |
duke@1 | 105 | |
duke@1 | 106 | #---------------------------------------------------------------- |
duke@1 | 107 | # No warning for missing elts in "system" paths |
duke@1 | 108 | #---------------------------------------------------------------- |
duke@1 | 109 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Djava.endorsed.dirs=classes" Main.java |
duke@1 | 110 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Djava.ext.dirs=classes" Main.java |
duke@1 | 111 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath/p:classes" Main.java |
duke@1 | 112 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath/a:classes" Main.java |
duke@1 | 113 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath:classes${PS}${BCP}" Main.java |
duke@1 | 114 | |
duke@1 | 115 | #---------------------------------------------------------------- |
duke@1 | 116 | # No warning if class path element exists |
duke@1 | 117 | #---------------------------------------------------------------- |
duke@1 | 118 | Sys mkdir classes |
duke@1 | 119 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes" Main.java |
duke@1 | 120 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-endorseddirs" "classes" Main.java |
duke@1 | 121 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-extdirs" "classes" Main.java |
duke@1 | 122 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath/p:classes" Main.java |
duke@1 | 123 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath/a:classes" Main.java |
duke@1 | 124 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath:classes${PS}${BCP}" Main.java |
duke@1 | 125 | |
duke@1 | 126 | Sys "$jar" cf classes.jar Main.class |
duke@1 | 127 | Sys cp classes.jar classes.war |
duke@1 | 128 | Sys cp classes.war classes.zip |
duke@1 | 129 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes.jar" Main.java |
duke@1 | 130 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes.war" Main.java |
duke@1 | 131 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes.zip" Main.java |
duke@1 | 132 | |
duke@1 | 133 | #---------------------------------------------------------------- |
duke@1 | 134 | # Warn if -Xlint is used and if class path element refers to |
duke@1 | 135 | # regular file which doesn't look like a zip file, but is |
duke@1 | 136 | #---------------------------------------------------------------- |
duke@1 | 137 | Sys cp classes.war classes.foo |
duke@1 | 138 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes.foo" Main.java |
duke@1 | 139 | |
duke@1 | 140 | |
duke@1 | 141 | #---------------------------------------------------------------- |
duke@1 | 142 | # No error if class path element refers to regular file which is |
duke@1 | 143 | # not a zip file |
duke@1 | 144 | #---------------------------------------------------------------- |
duke@1 | 145 | No Error "$javac" ${TESTTOOLVMOPTS} -cp Main.java Main.java # Main.java is NOT a jar file |
duke@1 | 146 | No Error "$javac" ${TESTTOOLVMOPTS} Main.java |
duke@1 | 147 | |
duke@1 | 148 | #---------------------------------------------------------------- |
duke@1 | 149 | # Warn if -Xlint is used and if class path element refers to |
duke@1 | 150 | # regular file which is not a zip file |
duke@1 | 151 | #---------------------------------------------------------------- |
duke@1 | 152 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -cp Main.java Main.java # Main.java is NOT a jar file |
duke@1 | 153 | |
duke@1 | 154 | #---------------------------------------------------------------- |
duke@1 | 155 | # Test jar file class path reference recursion |
duke@1 | 156 | #---------------------------------------------------------------- |
duke@1 | 157 | MkManifestWithClassPath classesRef.jar |
duke@1 | 158 | Sys "$jar" cmf MANIFEST.MF classesRefRef.jar Main.class |
duke@1 | 159 | |
duke@1 | 160 | #---------------------------------------------------------------- |
duke@1 | 161 | # Non-existent recursive Class-Path reference gives warning |
duke@1 | 162 | #---------------------------------------------------------------- |
duke@1 | 163 | No Warning "$javac" ${TESTTOOLVMOPTS} -classpath classesRefRef.jar Main.java |
duke@1 | 164 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -classpath classesRefRef.jar Main.java |
duke@1 | 165 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -Xbootclasspath/p:classesRefRef.jar Main.java |
duke@1 | 166 | |
duke@1 | 167 | BadJarFile classesRef.jar |
duke@1 | 168 | |
duke@1 | 169 | #---------------------------------------------------------------- |
duke@1 | 170 | # Non-jar file recursive Class-Path reference gives error |
duke@1 | 171 | #---------------------------------------------------------------- |
duke@1 | 172 | Error "$javac" ${TESTTOOLVMOPTS} -classpath classesRefRef.jar Main.java |
duke@1 | 173 | No Error "$javac" ${TESTTOOLVMOPTS} -Xbootclasspath/a:classesRefRef.jar Main.java |
duke@1 | 174 | |
duke@1 | 175 | MkManifestWithClassPath classes |
duke@1 | 176 | Sys "$jar" cmf MANIFEST.MF classesRef.jar Main.class |
duke@1 | 177 | |
duke@1 | 178 | #---------------------------------------------------------------- |
duke@1 | 179 | # Jar file recursive Class-Path reference is OK |
duke@1 | 180 | #---------------------------------------------------------------- |
duke@1 | 181 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -classpath classesRefRef.jar Main.java |
duke@1 | 182 | No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -Xbootclasspath/p:classesRefRef.jar Main.java |
duke@1 | 183 | |
duke@1 | 184 | #---------------------------------------------------------------- |
jjg@874 | 185 | # Class-Path attribute followed in extdirs or endorseddirs |
duke@1 | 186 | #---------------------------------------------------------------- |
duke@1 | 187 | Sys mkdir jars |
duke@1 | 188 | Sys cp -p classesRefRef.jar jars/. |
jjg@874 | 189 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -extdirs jars Main.java |
jjg@874 | 190 | Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -endorseddirs jars Main.java |
duke@1 | 191 | |
duke@1 | 192 | #---------------------------------------------------------------- |
duke@1 | 193 | # Bad Jar file in extdirs and endorseddirs should not be ignored |
duke@1 | 194 | #---------------------------------------------------------------- |
duke@1 | 195 | BadJarFile jars/classesRef.jar |
duke@1 | 196 | Error "$javac" ${TESTTOOLVMOPTS} -Xlint -extdirs jars Main.java |
duke@1 | 197 | Error "$javac" ${TESTTOOLVMOPTS} -Xlint -endorseddirs jars Main.java |
duke@1 | 198 | |
duke@1 | 199 | Cleanup |
duke@1 | 200 | |
duke@1 | 201 | Bottom Line |