comparison test/tools/javac/Paths/Diagnostics.sh @ 3294:9adfb22ff08f

8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: jjg, jlahoda, vromero, mcimadamore, bpatel, ksrini, darcy, anazarov, dfuchs Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, jan.lahoda@oracle.com, vicente.romero@oracle.com, andreas.lundblad@oracle.com, andrey.x.nazarov@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, kumar.x.srinivasan@oracle.com, sundararajan.athijegannathan@oracle.com
author alanb
date Thu, 17 Mar 2016 19:04:28 +0000
parents a28b7f42dae9
children
comparison
equal deleted inserted replaced
4:8658344dfa86 5:a4dcf222c833
1 #!/bin/sh 1 #!/bin/sh
2 2
3 # 3 #
4 # Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. 4 # Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 # 6 #
7 # This code is free software; you can redistribute it and/or modify it 7 # This code is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License version 2 only, as 8 # under the terms of the GNU General Public License version 2 only, as
9 # published by the Free Software Foundation. 9 # published by the Free Software Foundation.
45 45
46 Warning() { 46 Warning() {
47 HorizontalRule 47 HorizontalRule
48 echo "$@" 48 echo "$@"
49 output=`"$@" 2>&1`; rc="$?" 49 output=`"$@" 2>&1`; rc="$?"
50 test -n "$output" && echo "$output" 50 output2=`echo "$output" | grep -v "bootstrap class path not set in conjunction with -source"`
51 test -n "$output2" && echo "$output"
51 test $rc -eq 0 || Fail "Command \"$*\" failed with exitValue $rc"; 52 test $rc -eq 0 || Fail "Command \"$*\" failed with exitValue $rc";
52 case "$output" in *warning:*) gotwarning="yes";; *) gotwarning="no";; esac 53 case "$output2" in *warning:*) gotwarning="yes";; *) gotwarning="no";; esac
53 54
54 if test "$gotwarning" = "yes" -a "$NO" = "no"; then 55 if test "$gotwarning" = "yes" -a "$NO" = "no"; then
55 Fail "Command \"$*\" printed an unexpected warning" 56 Fail "Command \"$*\" printed an unexpected warning"
56 elif test "$gotwarning" = "no" -a "$NO" != "no"; then 57 elif test "$gotwarning" = "no" -a "$NO" != "no"; then
57 Fail "Command \"$*\" did not generate the expected warning" 58 Fail "Command \"$*\" did not generate the expected warning"
85 } 86 }
86 87
87 Cleanup 88 Cleanup
88 echo "public class Main{public static void main(String[]a){}}" > Main.java 89 echo "public class Main{public static void main(String[]a){}}" > Main.java
89 90
91 # We need to set -source 8 -target 8 for those cases where the option is
92 # not legal in 9 and later. However, that triggers an additional warning
93 # about not setting bootclasspath, which is filtered out in Warning.
94 # The alternative would be to extract a minimal rt.jar from JDK and
95 # specify that with -bootclasspath.
96 SRCTRG8="-source 8 -target 8"
97
90 #---------------------------------------------------------------- 98 #----------------------------------------------------------------
91 # No warnings unless -Xlint:path is used 99 # No warnings unless -Xlint:path is used
92 #---------------------------------------------------------------- 100 #----------------------------------------------------------------
93 No Warning "$javac" ${TESTTOOLVMOPTS} Main.java 101 No Warning "$javac" ${TESTTOOLVMOPTS} Main.java
94 No Warning "$javac" ${TESTTOOLVMOPTS} -cp ".${PS}classes" Main.java 102 No Warning "$javac" ${TESTTOOLVMOPTS} -cp ".${PS}classes" Main.java
95 103
96 #---------------------------------------------------------------- 104 #----------------------------------------------------------------
97 # Warn for missing elts in user-specified paths 105 # Warn for missing elts in user-specified paths
98 #---------------------------------------------------------------- 106 #----------------------------------------------------------------
99 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes" Main.java 107 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes" Main.java
100 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath/p:classes" Main.java 108 Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint:path "-Xbootclasspath/p:classes" Main.java
101 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint "-Xbootclasspath/a:classes" Main.java 109 Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint "-Xbootclasspath/a:classes" Main.java
102 110
103 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-endorseddirs" "classes" Main.java 111 Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint:path "-endorseddirs" "classes" Main.java
104 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint "-extdirs" "classes" Main.java 112 Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint "-extdirs" "classes" Main.java
105 # Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath:classes${PS}${BCP}" Main.java 113 #Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint:path "-Xbootclasspath:classes${PS}${BCP}" Main.java
106 114
107 #---------------------------------------------------------------- 115 #----------------------------------------------------------------
108 # No warning for missing elts in "system" paths 116 # No warning for missing elts in "system" paths
109 #---------------------------------------------------------------- 117 #----------------------------------------------------------------
110 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Djava.endorsed.dirs=classes" Main.java 118 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Djava.endorsed.dirs=classes" Main.java
111 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Djava.ext.dirs=classes" Main.java 119 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Djava.ext.dirs=classes" Main.java
112 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath/p:classes" Main.java 120 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath/p:classes" Main.java
113 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath/a:classes" Main.java 121 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath/a:classes" Main.java
114 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath:classes${PS}${BCP}" Main.java 122 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-J-Xbootclasspath:classes${PS}${BCP}" Main.java
115 123
116 #---------------------------------------------------------------- 124 #----------------------------------------------------------------
117 # No warning if class path element exists 125 # No warning if class path element exists
118 #---------------------------------------------------------------- 126 #----------------------------------------------------------------
119 Sys mkdir classes 127 Sys mkdir classes
120 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes" Main.java 128 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes" Main.java
121 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-endorseddirs" "classes" Main.java 129 No Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint:path "-endorseddirs" "classes" Main.java
122 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-extdirs" "classes" Main.java 130 No Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint:path "-extdirs" "classes" Main.java
123 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath/p:classes" Main.java 131 No Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint:path "-Xbootclasspath/p:classes" Main.java
124 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath/a:classes" Main.java 132 No Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint:path "-Xbootclasspath/a:classes" Main.java
125 # No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path "-Xbootclasspath:classes${PS}${BCP}" Main.java 133 #No Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint:path "-Xbootclasspath:classes${PS}${BCP}" Main.java
126 134
127 Sys "$jar" cf classes.jar Main.class 135 Sys "$jar" cf classes.jar Main.class
128 Sys cp classes.jar classes.war 136 Sys cp classes.jar classes.war
129 Sys cp classes.war classes.zip 137 Sys cp classes.war classes.zip
130 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes.jar" Main.java 138 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint:path -cp ".${PS}classes.jar" Main.java
159 Sys "$jar" cmf MANIFEST.MF classesRefRef.jar Main.class 167 Sys "$jar" cmf MANIFEST.MF classesRefRef.jar Main.class
160 168
161 #---------------------------------------------------------------- 169 #----------------------------------------------------------------
162 # Non-existent recursive Class-Path reference gives warning 170 # Non-existent recursive Class-Path reference gives warning
163 #---------------------------------------------------------------- 171 #----------------------------------------------------------------
164 No Warning "$javac" ${TESTTOOLVMOPTS} -classpath classesRefRef.jar Main.java 172 No Warning "$javac" ${TESTTOOLVMOPTS} -classpath classesRefRef.jar Main.java
165 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -classpath classesRefRef.jar Main.java 173 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -classpath classesRefRef.jar Main.java
166 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -Xbootclasspath/p:classesRefRef.jar Main.java 174 No Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint -Xbootclasspath/p:classesRefRef.jar Main.java
167 175
168 BadJarFile classesRef.jar 176 BadJarFile classesRef.jar
169 177
170 #---------------------------------------------------------------- 178 #----------------------------------------------------------------
171 # Non-jar file recursive Class-Path reference gives error 179 # Non-jar file recursive Class-Path reference gives error
172 #---------------------------------------------------------------- 180 #----------------------------------------------------------------
173 Error "$javac" ${TESTTOOLVMOPTS} -classpath classesRefRef.jar Main.java 181 Error "$javac" ${TESTTOOLVMOPTS} -classpath classesRefRef.jar Main.java
174 No Error "$javac" ${TESTTOOLVMOPTS} -Xbootclasspath/a:classesRefRef.jar Main.java 182 No Error "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xbootclasspath/a:classesRefRef.jar Main.java
175 183
176 MkManifestWithClassPath classes 184 MkManifestWithClassPath classes
177 Sys "$jar" cmf MANIFEST.MF classesRef.jar Main.class 185 Sys "$jar" cmf MANIFEST.MF classesRef.jar Main.class
178 186
179 #---------------------------------------------------------------- 187 #----------------------------------------------------------------
180 # Jar file recursive Class-Path reference is OK 188 # Jar file recursive Class-Path reference is OK
181 #---------------------------------------------------------------- 189 #----------------------------------------------------------------
182 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -classpath classesRefRef.jar Main.java 190 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -classpath classesRefRef.jar Main.java
183 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -Xbootclasspath/p:classesRefRef.jar Main.java 191 No Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint -Xbootclasspath/p:classesRefRef.jar Main.java
184 192
185 #---------------------------------------------------------------- 193 #----------------------------------------------------------------
186 # Class-Path attribute followed in extdirs or endorseddirs 194 # Class-Path attribute followed in extdirs or endorseddirs
187 #---------------------------------------------------------------- 195 #----------------------------------------------------------------
188 Sys mkdir jars 196 Sys mkdir jars
189 Sys cp classesRefRef.jar jars/. 197 Sys cp classesRefRef.jar jars/.
190 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -extdirs jars Main.java 198 Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint -extdirs jars Main.java
191 Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -endorseddirs jars Main.java 199 Warning "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint -endorseddirs jars Main.java
192 200
193 #---------------------------------------------------------------- 201 #----------------------------------------------------------------
194 # Bad Jar file in extdirs and endorseddirs should not be ignored 202 # Bad Jar file in extdirs and endorseddirs should not be ignored
195 #---------------------------------------------------------------- 203 #----------------------------------------------------------------
196 BadJarFile jars/classesRef.jar 204 BadJarFile jars/classesRef.jar
197 Error "$javac" ${TESTTOOLVMOPTS} -Xlint -extdirs jars Main.java 205 Error "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint -extdirs jars Main.java
198 Error "$javac" ${TESTTOOLVMOPTS} -Xlint -endorseddirs jars Main.java 206 Error "$javac" ${TESTTOOLVMOPTS} ${SRCTRG8} -Xlint -endorseddirs jars Main.java
199 207
200 Cleanup 208 Cleanup
201 209
202 Bottom Line 210 Bottom Line