Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 26-37
Link Here
|
26 |
import org.eclipse.jdt.core.JavaCore; |
26 |
import org.eclipse.jdt.core.JavaCore; |
27 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
27 |
import org.eclipse.jdt.core.compiler.InvalidInputException; |
28 |
import org.eclipse.jdt.core.tests.util.Util; |
28 |
import org.eclipse.jdt.core.tests.util.Util; |
|
|
29 |
import org.eclipse.jdt.internal.compiler.batch.ClasspathJar; |
29 |
import org.eclipse.jdt.internal.compiler.batch.ClasspathLocation; |
30 |
import org.eclipse.jdt.internal.compiler.batch.ClasspathLocation; |
30 |
import org.eclipse.jdt.internal.compiler.batch.Main; |
31 |
import org.eclipse.jdt.internal.compiler.batch.Main; |
31 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
32 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
32 |
|
33 |
|
33 |
public class BatchCompilerTest extends AbstractRegressionTest { |
34 |
public class BatchCompilerTest extends AbstractRegressionTest { |
34 |
public static final String OUTPUT_DIR_PLACEHOLDER = "---OUTPUT_DIR_PLACEHOLDER---"; |
35 |
public static final String OUTPUT_DIR_PLACEHOLDER = "---OUTPUT_DIR_PLACEHOLDER---"; |
|
|
36 |
public static final String LIB_DIR_PLACEHOLDER = "---LIB_DIR_PLACEHOLDER---"; |
35 |
static final String JRE_HOME_DIR = Util.getJREDirectory(); |
37 |
static final String JRE_HOME_DIR = Util.getJREDirectory(); |
36 |
private static final Main MAIN = new Main(null, null, false); |
38 |
private static final Main MAIN = new Main(null, null, false); |
37 |
|
39 |
|
Lines 53-58
Link Here
|
53 |
return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_5); |
56 |
return buildUniqueComplianceTestSuite(testClass(), ClassFileConstants.JDK1_5); |
54 |
} |
57 |
} |
55 |
|
58 |
|
|
|
59 |
private static boolean CASCADED_JARS_CREATED; |
60 |
private void createCascadedJars() { |
61 |
if (!CASCADED_JARS_CREATED) { |
62 |
File libDir = new File(LIB_DIR); |
63 |
Util.delete(libDir); // make sure we recycle the libs |
64 |
libDir.mkdirs(); |
65 |
try { |
66 |
Util.createJar( |
67 |
new String[] { |
68 |
"p/A.java", |
69 |
"package p;\n" + |
70 |
"public class A {\n" + |
71 |
"}", |
72 |
}, |
73 |
new String[] { |
74 |
"META-INF/MANIFEST.MF", |
75 |
"Manifest-Version: 1.0\n" + |
76 |
"Created-By: Eclipse JDT Test Harness\n" + |
77 |
"Class-Path: lib2.jar\n", |
78 |
"p/S1.java", |
79 |
"package p;\n" + |
80 |
"public class S1 {\n" + |
81 |
"}", |
82 |
}, |
83 |
LIB_DIR + "/lib1.jar", |
84 |
JavaCore.VERSION_1_4); |
85 |
Util.createJar( |
86 |
new String[] { |
87 |
"p/B.java", |
88 |
"package p;\n" + |
89 |
"public class B {\n" + |
90 |
"}", |
91 |
"p/R.java", |
92 |
"package p;\n" + |
93 |
"public class R {\n" + |
94 |
" public static final int R2 = 2;\n" + |
95 |
"}", |
96 |
}, |
97 |
new String[] { |
98 |
"p/S2.java", |
99 |
"package p;\n" + |
100 |
"public class S2 {\n" + |
101 |
"}", |
102 |
}, |
103 |
LIB_DIR + "/lib2.jar", |
104 |
JavaCore.VERSION_1_4); |
105 |
Util.createJar( |
106 |
new String[] { |
107 |
"p/C.java", |
108 |
"package p;\n" + |
109 |
"public class C {\n" + |
110 |
"}", |
111 |
"p/R.java", |
112 |
"package p;\n" + |
113 |
"public class R {\n" + |
114 |
" public static final int R3 = 3;\n" + |
115 |
"}", |
116 |
}, |
117 |
new String[] { |
118 |
"META-INF/MANIFEST.MF", |
119 |
"Manifest-Version: 1.0\n" + |
120 |
"Created-By: Eclipse JDT Test Harness\n" + |
121 |
"Class-Path: lib4.jar\n", |
122 |
}, |
123 |
LIB_DIR + "/lib3.jar", |
124 |
JavaCore.VERSION_1_4); |
125 |
Util.createJar( |
126 |
new String[] { |
127 |
"p/D.java", |
128 |
"package p;\n" + |
129 |
"public class D {\n" + |
130 |
"}", |
131 |
}, |
132 |
new String[] { |
133 |
"META-INF/MANIFEST.MF", |
134 |
"Manifest-Version: 1.0\n" + |
135 |
"Created-By: Eclipse JDT Test Harness\n" + |
136 |
"Class-Path: lib1.jar lib3.jar\n", |
137 |
}, |
138 |
LIB_DIR + "/lib4.jar", |
139 |
JavaCore.VERSION_1_4); |
140 |
Util.createJar( |
141 |
new String[] { |
142 |
"p/C.java", |
143 |
"package p;\n" + |
144 |
"public class C {\n" + |
145 |
"}", |
146 |
"p/R.java", |
147 |
"package p;\n" + |
148 |
"public class R {\n" + |
149 |
" public static final int R3 = 3;\n" + |
150 |
"}", |
151 |
}, |
152 |
new String[] { |
153 |
"META-INF/MANIFEST.MF", |
154 |
"Manifest-Version: 1.0\n" + |
155 |
"Created-By: Eclipse JDT Test Harness\n" + |
156 |
"Class-Path: s/lib6.jar\n", |
157 |
}, |
158 |
LIB_DIR + "/lib5.jar", |
159 |
JavaCore.VERSION_1_4); |
160 |
new File(LIB_DIR + "/s").mkdir(); |
161 |
Util.createJar( |
162 |
new String[] { |
163 |
"p/D.java", |
164 |
"package p;\n" + |
165 |
"public class D {\n" + |
166 |
"}", |
167 |
}, |
168 |
new String[] { |
169 |
"META-INF/MANIFEST.MF", |
170 |
"Manifest-Version: 1.0\n" + |
171 |
"Created-By: Eclipse JDT Test Harness\n" + |
172 |
"Class-Path: ../lib7.jar\n", |
173 |
}, |
174 |
LIB_DIR + "/s/lib6.jar", |
175 |
JavaCore.VERSION_1_4); |
176 |
Util.createJar( |
177 |
new String[] { |
178 |
"p/A.java", |
179 |
"package p;\n" + |
180 |
"public class A {\n" + |
181 |
"}", |
182 |
}, |
183 |
new String[] { |
184 |
"META-INF/MANIFEST.MF", |
185 |
"Manifest-Version: 1.0\n" + |
186 |
"Created-By: Eclipse JDT Test Harness\n" + |
187 |
"Class-Path: lib2.jar\n", |
188 |
}, |
189 |
LIB_DIR + "/lib7.jar", |
190 |
JavaCore.VERSION_1_4); |
191 |
Util.createJar( |
192 |
new String[] { |
193 |
"p/F.java", |
194 |
"package p;\n" + |
195 |
"public class F {\n" + |
196 |
"}", |
197 |
}, |
198 |
new String[] { |
199 |
"META-INF/MANIFEST.MF", |
200 |
"Manifest-Version: 1.0\n" + |
201 |
"Created-By: Eclipse JDT Test Harness\n" + |
202 |
"Class-Path: " + LIB_DIR + "/lib3.jar lib1.jar\n", |
203 |
}, |
204 |
LIB_DIR + "/lib8.jar", |
205 |
JavaCore.VERSION_1_4); |
206 |
Util.createJar( |
207 |
new String[] { |
208 |
"p/G.java", |
209 |
"package p;\n" + |
210 |
"public class G {\n" + |
211 |
"}", |
212 |
}, |
213 |
new String[] { |
214 |
"META-INF/MANIFEST.MF", |
215 |
"Manifest-Version: 1.0\n" + |
216 |
"Created-By: Eclipse JDT Test Harness\n" + |
217 |
"Class-Path: lib1.jar\n" + |
218 |
"Class-Path: lib3.jar\n", |
219 |
}, |
220 |
LIB_DIR + "/lib9.jar", |
221 |
JavaCore.VERSION_1_4); |
222 |
Util.createJar( |
223 |
new String[] { |
224 |
"p/A.java", |
225 |
"package p;\n" + |
226 |
"public class A {\n" + |
227 |
"}", |
228 |
}, |
229 |
// spoiled jar: MANIFEST.MF is a directory |
230 |
new String[] { |
231 |
"META-INF/MANIFEST.MF/MANIFEST.MF", |
232 |
"Manifest-Version: 1.0\n" + |
233 |
"Created-By: Eclipse JDT Test Harness\n" + |
234 |
"Class-Path: lib2.jar\n", |
235 |
}, |
236 |
LIB_DIR + "/lib10.jar", |
237 |
JavaCore.VERSION_1_4); |
238 |
Util.createJar( |
239 |
new String[] { |
240 |
"p/A.java", |
241 |
"package p;\n" + |
242 |
"public class A {\n" + |
243 |
"}", |
244 |
}, |
245 |
new String[] { |
246 |
"META-INF/MANIFEST.MF", |
247 |
"Manifest-Version: 1.0\n" + |
248 |
"Created-By: Eclipse JDT Test Harness\n" + |
249 |
"Class-Path:\n", |
250 |
}, |
251 |
LIB_DIR + "/lib11.jar", |
252 |
JavaCore.VERSION_1_4); |
253 |
Util.createJar( |
254 |
null, |
255 |
new String[] { |
256 |
"META-INF/MANIFEST.MF", |
257 |
"Manifest-Version: 1.0\n" + |
258 |
"Created-By: Eclipse JDT Test Harness\n" + |
259 |
"Class-Path:lib1.jar\n", // missing space |
260 |
}, |
261 |
LIB_DIR + "/lib12.jar", |
262 |
JavaCore.VERSION_1_4); |
263 |
Util.createJar( |
264 |
null, |
265 |
new String[] { |
266 |
"META-INF/MANIFEST.MF", |
267 |
"Manifest-Version: 1.0\n" + |
268 |
"Created-By: Eclipse JDT Test Harness\n" + |
269 |
"Class-Path:lib1.jar lib1.jar\n", // missing space |
270 |
}, |
271 |
LIB_DIR + "/lib13.jar", |
272 |
JavaCore.VERSION_1_4); |
273 |
Util.createJar( |
274 |
null, |
275 |
new String[] { |
276 |
"META-INF/MANIFEST.MF", |
277 |
"Manifest-Version: 1.0\n" + |
278 |
"Created-By: Eclipse JDT Test Harness\n" + |
279 |
" Class-Path: lib1.jar\n", // extra space at line start |
280 |
}, |
281 |
LIB_DIR + "/lib14.jar", |
282 |
JavaCore.VERSION_1_4); |
283 |
Util.createJar( |
284 |
null, |
285 |
new String[] { |
286 |
"META-INF/MANIFEST.MF", |
287 |
"Manifest-Version: 1.0\n" + |
288 |
"Created-By: Eclipse JDT Test Harness\n" + |
289 |
"Class-Path: lib1.jar", // missing newline at end |
290 |
}, |
291 |
LIB_DIR + "/lib15.jar", |
292 |
JavaCore.VERSION_1_4); |
293 |
Util.createJar( |
294 |
new String[] { |
295 |
"p/A.java", |
296 |
"package p;\n" + |
297 |
"public class A {\n" + |
298 |
"}", |
299 |
}, |
300 |
new String[] { |
301 |
"META-INF/MANIFEST.MF", |
302 |
"Manifest-Version: 1.0\n" + |
303 |
"Created-By: Eclipse JDT Test Harness\n" + |
304 |
"Class-Path: \n" + |
305 |
" lib2.jar\n", |
306 |
"p/S1.java", |
307 |
"package p;\n" + |
308 |
"public class S1 {\n" + |
309 |
"}", |
310 |
}, |
311 |
LIB_DIR + "/lib16.jar", |
312 |
JavaCore.VERSION_1_4); |
313 |
new File(LIB_DIR + "/dir").mkdir(); |
314 |
Util.createJar( |
315 |
new String[] { |
316 |
"p/A.java", |
317 |
"package p;\n" + |
318 |
"public class A {\n" + |
319 |
"}", |
320 |
}, |
321 |
new String[] { |
322 |
"META-INF/MANIFEST.MF", |
323 |
"Manifest-Version: 1.0\n" + |
324 |
"Created-By: Eclipse JDT Test Harness\n" + |
325 |
"Class-Path: ../lib2.jar\n", |
326 |
}, |
327 |
LIB_DIR + "/dir/lib17.jar", |
328 |
JavaCore.VERSION_1_4); |
329 |
CASCADED_JARS_CREATED = true; |
330 |
} catch (IOException e) { |
331 |
// ignore |
332 |
} |
333 |
} |
334 |
} |
335 |
|
56 |
private String getLibraryClassesAsQuotedString() { |
336 |
private String getLibraryClassesAsQuotedString() { |
57 |
String[] paths = Util.getJavaClassLibs(); |
337 |
String[] paths = Util.getJavaClassLibs(); |
58 |
StringBuffer buffer = new StringBuffer(); |
338 |
StringBuffer buffer = new StringBuffer(); |
Lines 157-163
Link Here
|
157 |
* pass true to get the output directory flushed before the test |
437 |
* pass true to get the output directory flushed before the test |
158 |
* runs |
438 |
* runs |
159 |
*/ |
439 |
*/ |
160 |
private void runTest(boolean shouldCompileOK, String[] testFiles, String commandLine, |
440 |
private void runTest( |
|
|
441 |
boolean shouldCompileOK, |
442 |
String[] testFiles, |
443 |
String commandLine, |
161 |
String expectedOutOutputString, |
444 |
String expectedOutOutputString, |
162 |
String expectedErrOutputString, |
445 |
String expectedErrOutputString, |
163 |
boolean shouldFlushOutputDirectory) { |
446 |
boolean shouldFlushOutputDirectory) { |
Lines 279-284
Link Here
|
279 |
errOutputString); |
562 |
errOutputString); |
280 |
} |
563 |
} |
281 |
} |
564 |
} |
|
|
565 |
private void runTest( |
566 |
boolean shouldCompileOK, |
567 |
String[] testFiles, |
568 |
String commandLine, |
569 |
Matcher outOutputStringMatcher, |
570 |
Matcher errOutputStringMatcher, |
571 |
boolean shouldFlushOutputDirectory) { |
572 |
File outputDirectory = new File(OUTPUT_DIR); |
573 |
if (shouldFlushOutputDirectory) |
574 |
Util.flushDirectoryContent(outputDirectory); |
575 |
try { |
576 |
if (!outputDirectory.isDirectory()) { |
577 |
outputDirectory.mkdirs(); |
578 |
} |
579 |
PrintWriter sourceFileWriter; |
580 |
for (int i = 0; i < testFiles.length; i += 2) { |
581 |
String fileName = OUTPUT_DIR + File.separator + testFiles[i]; |
582 |
File file = new File(fileName), innerOutputDirectory = file |
583 |
.getParentFile(); |
584 |
if (!innerOutputDirectory.isDirectory()) { |
585 |
innerOutputDirectory.mkdirs(); |
586 |
} |
587 |
sourceFileWriter = new PrintWriter(new FileOutputStream(file)); |
588 |
sourceFileWriter.write(testFiles[i + 1]); |
589 |
sourceFileWriter.close(); |
590 |
} |
591 |
} catch (FileNotFoundException e) { |
592 |
e.printStackTrace(); |
593 |
throw new RuntimeException(e); |
594 |
} |
595 |
String printerWritersNameRoot = OUTPUT_DIR + File.separator + testName(); |
596 |
String outFileName = printerWritersNameRoot + "out.txt", |
597 |
errFileName = printerWritersNameRoot + "err.txt"; |
598 |
Main batchCompiler; |
599 |
PrintWriter out = null; |
600 |
PrintWriter err = null; |
601 |
boolean compileOK; |
602 |
try { |
603 |
try { |
604 |
out = new PrintWriter(new FileOutputStream(outFileName)); |
605 |
err = new PrintWriter(new FileOutputStream(errFileName)); |
606 |
batchCompiler = new Main(out, err, false); |
607 |
} catch (FileNotFoundException e) { |
608 |
System.out.println(getClass().getName() + '#' + getName()); |
609 |
e.printStackTrace(); |
610 |
throw new RuntimeException(e); |
611 |
} |
612 |
try { |
613 |
final String[] tokenizeCommandLine = Main.tokenize(commandLine); |
614 |
compileOK = batchCompiler.compile(tokenizeCommandLine); |
615 |
} catch (RuntimeException e) { |
616 |
compileOK = false; |
617 |
System.out.println(getClass().getName() + '#' + getName()); |
618 |
e.printStackTrace(); |
619 |
throw e; |
620 |
} |
621 |
} finally { |
622 |
if (out != null) |
623 |
out.close(); |
624 |
if (err != null) |
625 |
err.close(); |
626 |
} |
627 |
String outOutputString = Util.fileContent(outFileName), |
628 |
errOutputString = Util.fileContent(errFileName); |
629 |
boolean compareOK = false, outCompareOK = false, errCompareOK = false; |
630 |
String expectedErrOutputString = null, expectedOutOutputString = null; |
631 |
if (compileOK == shouldCompileOK) { |
632 |
if (outOutputStringMatcher == null) { |
633 |
outCompareOK = true; |
634 |
} else { |
635 |
outCompareOK = outOutputStringMatcher.match(outOutputString); |
636 |
expectedOutOutputString = outOutputStringMatcher.expected(); |
637 |
} |
638 |
if (errOutputStringMatcher == null) { |
639 |
errCompareOK = true; |
640 |
} else { |
641 |
errCompareOK = errOutputStringMatcher.match(errOutputString); |
642 |
expectedErrOutputString = errOutputStringMatcher.expected(); |
643 |
} |
644 |
compareOK = outCompareOK && errCompareOK; |
645 |
} |
646 |
if (compileOK != shouldCompileOK || !compareOK) { |
647 |
System.out.println(getClass().getName() + '#' + getName()); |
648 |
for (int i = 0; i < testFiles.length; i += 2) { |
649 |
System.out.print(testFiles[i]); |
650 |
System.out.println(" ["); |
651 |
System.out.println(testFiles[i + 1]); |
652 |
System.out.println("]"); |
653 |
} |
654 |
} |
655 |
if (compileOK != shouldCompileOK) |
656 |
System.out.println(errOutputString); |
657 |
if (compileOK == shouldCompileOK && !compareOK) { |
658 |
System.out.println( |
659 |
"------------ [START OUT] ------------\n" |
660 |
+ "------------- Expected: -------------\n" |
661 |
+ expectedOutOutputString |
662 |
+ "\n------------- but was: -------------\n" |
663 |
+ outOutputString |
664 |
+ "\n--------- (cut and paste:) ----------\n" |
665 |
+ Util.displayString(outputDirNormalizer |
666 |
.normalized(outOutputString)) |
667 |
+ "\n------------- [END OUT] -------------\n" |
668 |
+ "------------ [START ERR] ------------\n" |
669 |
+ "------------- Expected: -------------\n" |
670 |
+ expectedErrOutputString |
671 |
+ "\n------------- but was: -------------\n" |
672 |
+ errOutputString |
673 |
+ "\n--------- (cut and paste:) ----------\n" |
674 |
+ Util.displayString(outputDirNormalizer |
675 |
.normalized(errOutputString)) |
676 |
+ "\n------------- [END ERR] -------------\n"); |
677 |
} |
678 |
if (shouldCompileOK) |
679 |
assertTrue("Unexpected problems: " + errOutputString, compileOK); |
680 |
else |
681 |
assertTrue("Unexpected success: " + errOutputString, !compileOK); |
682 |
if (!outCompareOK) { |
683 |
// calling assertEquals to benefit from the comparison UI |
684 |
// (need appropriate exception) |
685 |
assertEquals( |
686 |
"Unexpected standard output for invocation with arguments [" |
687 |
+ commandLine + "]", |
688 |
expectedOutOutputString, |
689 |
outOutputString); |
690 |
} |
691 |
if (!errCompareOK) { |
692 |
assertEquals( |
693 |
"Unexpected error output for invocation with arguments [" |
694 |
+ commandLine + "]", |
695 |
expectedErrOutputString, |
696 |
errOutputString); |
697 |
} |
698 |
} |
282 |
private void runClasspathTest(String classpathInput, String[] expectedClasspathEntries, |
699 |
private void runClasspathTest(String classpathInput, String[] expectedClasspathEntries, |
283 |
String expectedError) { |
700 |
String expectedError) { |
284 |
File outputDirectory = new File(OUTPUT_DIR); |
701 |
File outputDirectory = new File(OUTPUT_DIR); |
Lines 356-361
Link Here
|
356 |
} |
773 |
} |
357 |
} |
774 |
} |
358 |
|
775 |
|
|
|
776 |
static abstract class Matcher { |
777 |
abstract boolean match(String effective); |
778 |
abstract String expected(); // for use in JUnit comparison framework |
779 |
} |
780 |
static class StringMatcher extends Matcher { |
781 |
private String expected; |
782 |
private Normalizer normalizer; |
783 |
StringMatcher(String expected, Normalizer normalizer) { |
784 |
this.expected = expected; |
785 |
this.normalizer = normalizer; |
786 |
} |
787 |
boolean match(String effective) { |
788 |
if (this.expected == null) { |
789 |
return effective == null; |
790 |
} |
791 |
if (this.normalizer == null) { |
792 |
return this.expected.equals(effective); |
793 |
} |
794 |
return this.expected.equals(this.normalizer.normalized(effective)); |
795 |
} |
796 |
String expected() { |
797 |
return this.expected; |
798 |
} |
799 |
} |
800 |
static class SubstringMatcher extends Matcher { |
801 |
private String substring; |
802 |
SubstringMatcher(String substring) { |
803 |
this.substring = substring; |
804 |
} |
805 |
boolean match(String effective) { |
806 |
effective = outputDirNormalizer.normalized(effective); |
807 |
return effective.indexOf(this.substring) != -1; |
808 |
} |
809 |
String expected() { |
810 |
return "*" + this.substring + "*"; |
811 |
} |
812 |
} |
813 |
static final Matcher EMPTY_STRING_MATCHER = new Matcher() { |
814 |
String expected() { |
815 |
return org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING; |
816 |
} |
817 |
boolean match(String effective) { |
818 |
return effective != null && effective.length() == 0; |
819 |
} |
820 |
}; |
821 |
static final Matcher ONE_FILE_GENERATED_MATCHER = new SubstringMatcher("[1 .class file generated]"); |
822 |
static final Matcher TWO_FILES_GENERATED_MATCHER = new SubstringMatcher("[2 .class files generated]"); |
359 |
/** |
823 |
/** |
360 |
* Abstract normalizer for output comparison. This class merely embodies a |
824 |
* Abstract normalizer for output comparison. This class merely embodies a |
361 |
* chain of responsibility, plus the signature of the method of interest |
825 |
* chain of responsibility, plus the signature of the method of interest |
Lines 556-572
Link Here
|
556 |
* OUTPUT_DIR_PLACEHOLDER and changes file separator to / if the |
1020 |
* OUTPUT_DIR_PLACEHOLDER and changes file separator to / if the |
557 |
* platform file separator is different from /. |
1021 |
* platform file separator is different from /. |
558 |
*/ |
1022 |
*/ |
559 |
private static Normalizer outputDirNormalizer; |
1023 |
static Normalizer outputDirNormalizer; |
560 |
static { |
1024 |
static { |
561 |
if (File.separatorChar == '/') { |
1025 |
if (File.separatorChar == '/') { |
562 |
outputDirNormalizer = new StringNormalizer( |
1026 |
outputDirNormalizer = |
563 |
null, OUTPUT_DIR, OUTPUT_DIR_PLACEHOLDER); |
1027 |
new StringNormalizer( |
|
|
1028 |
new StringNormalizer( |
1029 |
null, OUTPUT_DIR, OUTPUT_DIR_PLACEHOLDER), |
1030 |
LIB_DIR, LIB_DIR_PLACEHOLDER); |
564 |
} |
1031 |
} |
565 |
else { |
1032 |
else { |
566 |
outputDirNormalizer = new StringNormalizer( |
1033 |
outputDirNormalizer = |
|
|
1034 |
new StringNormalizer( |
567 |
new StringNormalizer( |
1035 |
new StringNormalizer( |
|
|
1036 |
new StringNormalizer( |
568 |
null, File.separator, "/"), |
1037 |
null, File.separator, "/"), |
569 |
OUTPUT_DIR, OUTPUT_DIR_PLACEHOLDER); |
1038 |
OUTPUT_DIR, OUTPUT_DIR_PLACEHOLDER), |
|
|
1039 |
LIB_DIR, LIB_DIR_PLACEHOLDER); |
570 |
} |
1040 |
} |
571 |
} |
1041 |
} |
572 |
|
1042 |
|
Lines 1503-1584
Link Here
|
1503 |
"incorrect classpath: dummmy_dir\n", |
1973 |
"incorrect classpath: dummmy_dir\n", |
1504 |
true); |
1974 |
true); |
1505 |
} |
1975 |
} |
1506 |
// we tolerate inexisting jars on the classpath |
1976 |
// we tolerate inexisting jars on the classpath, and we don't even warn about |
1507 |
// TODO (maxime) check and document |
1977 |
// them (javac does the same as us) |
1508 |
public void _test017b(){ |
1978 |
public void test017b(){ |
1509 |
this.runConformTest( |
1979 |
this.runTest( |
|
|
1980 |
true, |
1510 |
new String[] { |
1981 |
new String[] { |
1511 |
"X.java", |
1982 |
"X.java", |
1512 |
"/** */\n" + |
1983 |
"/** */\n" + |
1513 |
"public class X {\n" + |
1984 |
"public class X {\n" + |
1514 |
" OK1 ok1;\n" + |
1985 |
" OK1 ok1;\n" + |
1515 |
"}", |
1986 |
"}", |
1516 |
"OK1.java", |
1987 |
"OK1.java", |
1517 |
"/** */\n" + |
1988 |
"/** */\n" + |
1518 |
"public class OK1 {\n" + |
1989 |
"public class OK1 {\n" + |
1519 |
" // empty\n" + |
1990 |
" // empty\n" + |
1520 |
"}" |
1991 |
"}" |
1521 |
}, |
1992 |
}, |
1522 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" |
1993 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" |
1523 |
+ " -1.5 -g -preserveAllLocals" |
1994 |
+ " -1.5 -g -preserveAllLocals" |
1524 |
+ " -cp dummy.jar" + File.pathSeparator + File.pathSeparator + "\"" + OUTPUT_DIR + "\"" |
1995 |
+ " -cp dummy.jar" + File.pathSeparator + File.pathSeparator + "\"" + OUTPUT_DIR + "\"" |
1525 |
+ " -verbose -proceedOnError -referenceInfo" |
1996 |
+ " -verbose -proceedOnError -referenceInfo" |
1526 |
+ " -d \"" + OUTPUT_DIR + "\"", |
1997 |
+ " -d \"" + OUTPUT_DIR + "\"", |
1527 |
"[2 .class files generated]\n", |
1998 |
TWO_FILES_GENERATED_MATCHER, |
1528 |
"incorrect classpath: dummmy.jar\n", |
1999 |
EMPTY_STRING_MATCHER, |
1529 |
true); |
2000 |
true); |
1530 |
} |
2001 |
} |
1531 |
// we tolerate empty classpath entries |
2002 |
// we tolerate empty classpath entries, and we don't even warn about |
1532 |
// TODO (maxime) check and document |
2003 |
// them (javac does the same as us) |
1533 |
public void _test017c(){ |
2004 |
public void test017c(){ |
1534 |
this.runConformTest( |
2005 |
this.runTest( |
|
|
2006 |
true, |
1535 |
new String[] { |
2007 |
new String[] { |
1536 |
"X.java", |
2008 |
"X.java", |
1537 |
"/** */\n" + |
2009 |
"/** */\n" + |
1538 |
"public class X {\n" + |
2010 |
"public class X {\n" + |
1539 |
" OK1 ok1;\n" + |
2011 |
" OK1 ok1;\n" + |
1540 |
"}", |
2012 |
"}", |
1541 |
"OK1.java", |
2013 |
"OK1.java", |
1542 |
"/** */\n" + |
2014 |
"/** */\n" + |
1543 |
"public class OK1 {\n" + |
2015 |
"public class OK1 {\n" + |
1544 |
" // empty\n" + |
2016 |
" // empty\n" + |
1545 |
"}" |
2017 |
"}" |
1546 |
}, |
2018 |
}, |
1547 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" |
2019 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" |
1548 |
+ " -1.5 -g -preserveAllLocals" |
2020 |
+ " -1.5 -g -preserveAllLocals" |
1549 |
+ " -cp " + File.pathSeparator + File.pathSeparator + "\"" + OUTPUT_DIR + "\"" |
2021 |
+ " -cp " + File.pathSeparator + File.pathSeparator + "\"" + OUTPUT_DIR + "\"" |
1550 |
+ " -verbose -proceedOnError -referenceInfo" |
2022 |
+ " -verbose -proceedOnError -referenceInfo" |
1551 |
+ " -d \"" + OUTPUT_DIR + "\"", |
2023 |
+ " -d \"" + OUTPUT_DIR + "\"", |
1552 |
"[2 .class files generated]\n", |
2024 |
TWO_FILES_GENERATED_MATCHER, |
1553 |
"incorrect classpath\n", |
2025 |
EMPTY_STRING_MATCHER, |
1554 |
true); |
2026 |
true); |
1555 |
} |
2027 |
} |
1556 |
// command line - unusual classpath (empty, but using current directory, still OK provided |
2028 |
// command line - unusual classpath (empty) |
1557 |
// that we execute from the appropriate directory); since there is no notion |
2029 |
// ok provided we explicit the sourcepath |
1558 |
// of current directory for this tests suite, the test is not executed |
2030 |
public void test018a(){ |
1559 |
// TODO (maxime) enforce working directory |
2031 |
String currentWorkingDirectoryPath = System.getProperty("user.dir"); |
1560 |
public void _test018(){ |
2032 |
if (currentWorkingDirectoryPath == null) { |
1561 |
this.runConformTest( |
2033 |
System.err.println("BatchCompilerTest#18a could not access the current working directory " + currentWorkingDirectoryPath); |
1562 |
new String[] { |
2034 |
} else if (!new File(currentWorkingDirectoryPath).isDirectory()) { |
1563 |
"X.java", |
2035 |
System.err.println("BatchCompilerTest#18a current working directory is not a directory " + currentWorkingDirectoryPath); |
1564 |
"/** */\n" + |
2036 |
} else { |
1565 |
"public class X {\n" + |
2037 |
String xPath = currentWorkingDirectoryPath + File.separator + "X.java"; |
1566 |
" OK1 ok1;\n" + |
2038 |
String ok1Path = currentWorkingDirectoryPath + File.separator + "OK1.java"; |
1567 |
"}", |
2039 |
PrintWriter sourceFileWriter; |
1568 |
"OK1.java", |
2040 |
try { |
1569 |
"/** */\n" + |
2041 |
File file = new File(xPath); |
1570 |
"public class OK1 {\n" + |
2042 |
sourceFileWriter = new PrintWriter(new FileOutputStream(file)); |
1571 |
" // empty\n" + |
2043 |
sourceFileWriter.write( |
1572 |
"}" |
2044 |
"/** */\n" + |
1573 |
}, |
2045 |
"public class X {\n" + |
1574 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" |
2046 |
" OK1 ok1;\n" + |
1575 |
+ " -1.5 -g -preserveAllLocals" |
2047 |
"}"); |
1576 |
+ " -verbose -proceedOnError -referenceInfo" |
2048 |
sourceFileWriter.close(); |
1577 |
+ " -d \"" + OUTPUT_DIR + "\"", |
2049 |
file = new File(ok1Path); |
1578 |
"[2 .class files generated]\n", |
2050 |
sourceFileWriter = new PrintWriter(new FileOutputStream(file)); |
1579 |
"", |
2051 |
sourceFileWriter.write( |
1580 |
true); |
2052 |
"/** */\n" + |
|
|
2053 |
"public class OK1 {\n" + |
2054 |
" // empty\n" + |
2055 |
"}"); |
2056 |
sourceFileWriter.close(); |
2057 |
this.runTest( |
2058 |
true, |
2059 |
new String[] { |
2060 |
"dummy.java", // enforce output directory creation |
2061 |
"" |
2062 |
}, |
2063 |
"X.java" |
2064 |
+ " -1.5 -g -preserveAllLocals" |
2065 |
+ " -verbose -proceedOnError" |
2066 |
+ " -sourcepath ." |
2067 |
+ " -d \"" + OUTPUT_DIR + "\"", |
2068 |
TWO_FILES_GENERATED_MATCHER, |
2069 |
EMPTY_STRING_MATCHER, |
2070 |
false); |
2071 |
} catch (FileNotFoundException e) { |
2072 |
System.err.println("BatchCompilerTest#18a could not write to current working directory " + currentWorkingDirectoryPath); |
2073 |
} finally { |
2074 |
new File(xPath).delete(); |
2075 |
new File(ok1Path).delete(); |
2076 |
} |
2077 |
} |
2078 |
} |
2079 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=214725 |
2080 |
// empty sourcepath works with javac but not with ecj |
2081 |
public void _test018b(){ |
2082 |
String currentWorkingDirectoryPath = System.getProperty("user.dir"); |
2083 |
if (currentWorkingDirectoryPath == null) { |
2084 |
System.err.println("BatchCompilerTest#18b could not access the current working directory " + currentWorkingDirectoryPath); |
2085 |
} else if (!new File(currentWorkingDirectoryPath).isDirectory()) { |
2086 |
System.err.println("BatchCompilerTest#18b current working directory is not a directory " + currentWorkingDirectoryPath); |
2087 |
} else { |
2088 |
String xPath = currentWorkingDirectoryPath + File.separator + "X.java"; |
2089 |
String ok1Path = currentWorkingDirectoryPath + File.separator + "OK1.java"; |
2090 |
PrintWriter sourceFileWriter; |
2091 |
try { |
2092 |
File file = new File(xPath); |
2093 |
sourceFileWriter = new PrintWriter(new FileOutputStream(file)); |
2094 |
sourceFileWriter.write( |
2095 |
"/** */\n" + |
2096 |
"public class X {\n" + |
2097 |
" OK1 ok1;\n" + |
2098 |
"}"); |
2099 |
sourceFileWriter.close(); |
2100 |
file = new File(ok1Path); |
2101 |
sourceFileWriter = new PrintWriter(new FileOutputStream(file)); |
2102 |
sourceFileWriter.write( |
2103 |
"/** */\n" + |
2104 |
"public class OK1 {\n" + |
2105 |
" // empty\n" + |
2106 |
"}"); |
2107 |
sourceFileWriter.close(); |
2108 |
this.runTest( |
2109 |
true, |
2110 |
new String[] { |
2111 |
"dummy.java", // enforce output directory creation |
2112 |
"" |
2113 |
}, |
2114 |
"X.java" |
2115 |
+ " -1.5 -g -preserveAllLocals" |
2116 |
+ " -verbose -proceedOnError" |
2117 |
+ " -d \"" + OUTPUT_DIR + "\"", |
2118 |
TWO_FILES_GENERATED_MATCHER, |
2119 |
EMPTY_STRING_MATCHER, |
2120 |
false); |
2121 |
} catch (FileNotFoundException e) { |
2122 |
System.err.println("BatchCompilerTest#18b could not write to current working directory " + currentWorkingDirectoryPath); |
2123 |
} finally { |
2124 |
new File(xPath).delete(); |
2125 |
new File(ok1Path).delete(); |
2126 |
} |
1581 |
} |
2127 |
} |
|
|
2128 |
} |
1582 |
public void test019(){ |
2129 |
public void test019(){ |
1583 |
this.runNegativeTest( |
2130 |
this.runNegativeTest( |
1584 |
new String[] { |
2131 |
new String[] { |
Lines 7857-7862
Link Here
|
7857 |
"invalid warning option: -warn:null,+unused. Must specify a warning token\n", |
8404 |
"invalid warning option: -warn:null,+unused. Must specify a warning token\n", |
7858 |
true); |
8405 |
true); |
7859 |
} |
8406 |
} |
|
|
8407 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8408 |
// basic link: a jar only referenced in the manifest of the first one is found |
8409 |
public void test216_jar_ref_in_jar(){ |
8410 |
createCascadedJars(); |
8411 |
this.runConformTest( |
8412 |
new String[] { |
8413 |
"src/p/X.java", |
8414 |
"package p;\n" + |
8415 |
"/** */\n" + |
8416 |
"public class X {\n" + |
8417 |
" A a;\n" + |
8418 |
" B b;\n" + |
8419 |
"}", |
8420 |
}, |
8421 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8422 |
+ " -cp \"" + LIB_DIR + File.separator + "lib1.jar\"" |
8423 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8424 |
+ " -1.5 -g -preserveAllLocals" |
8425 |
+ " -proceedOnError -referenceInfo" |
8426 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8427 |
"", |
8428 |
"", |
8429 |
true); |
8430 |
} |
8431 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8432 |
// may want a specific option to mimick javac 1.4 |
8433 |
// caveat: javac 1.5 with -source 1.4 and -target 1.4 still uses the links |
8434 |
public void _test216_jar_ref_in_jar_suppress(){ |
8435 |
createCascadedJars(); |
8436 |
this.runNegativeTest( |
8437 |
new String[] { |
8438 |
"src/p/X.java", |
8439 |
"package p;\n" + |
8440 |
"/** */\n" + |
8441 |
"public class X {\n" + |
8442 |
" A a;\n" + |
8443 |
" B b;\n" + |
8444 |
"}", |
8445 |
}, |
8446 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8447 |
+ " -cp \"" + LIB_DIR + File.separator + "lib1.jar\"" |
8448 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8449 |
+ " -ignoreJarClassPath -g -preserveAllLocals" |
8450 |
+ " -proceedOnError -referenceInfo" |
8451 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8452 |
"", |
8453 |
"----------\n" + |
8454 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
8455 |
" B b;\n" + |
8456 |
" ^\n" + |
8457 |
"B cannot be resolved to a type\n" + |
8458 |
"----------\n" + |
8459 |
"1 problem (1 error)", |
8460 |
true); |
8461 |
} |
8462 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8463 |
// links are followed recursively, eliminating dupes |
8464 |
public void test217_jar_ref_in_jar(){ |
8465 |
createCascadedJars(); |
8466 |
this.runConformTest( |
8467 |
new String[] { |
8468 |
"src/p/X.java", |
8469 |
"package p;\n" + |
8470 |
"/** */\n" + |
8471 |
"public class X {\n" + |
8472 |
" A a;\n" + |
8473 |
" B b;\n" + |
8474 |
" C c;\n" + |
8475 |
" D d;\n" + |
8476 |
"}", |
8477 |
}, |
8478 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8479 |
+ " -cp \"" + LIB_DIR + File.separator + "lib3.jar\"" |
8480 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8481 |
+ " -1.5 -g -preserveAllLocals" |
8482 |
+ " -proceedOnError -referenceInfo" |
8483 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8484 |
"", |
8485 |
"", |
8486 |
true); |
8487 |
} |
8488 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8489 |
// at first level, this is depth first, masking tailing libs |
8490 |
public void test218_jar_ref_in_jar(){ |
8491 |
createCascadedJars(); |
8492 |
this.runNegativeTest( |
8493 |
new String[] { |
8494 |
"src/p/X.java", |
8495 |
"package p;\n" + |
8496 |
"/** */\n" + |
8497 |
"public class X {\n" + |
8498 |
" int i = R.R2;\n" + |
8499 |
" int j = R.R3;\n" + |
8500 |
"}", |
8501 |
}, |
8502 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8503 |
+ " -cp \"" + LIB_DIR + File.separator + "lib1.jar\"" |
8504 |
+ " -cp \"" + LIB_DIR + File.separator + "lib3.jar\"" |
8505 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8506 |
+ " -1.5 -g -preserveAllLocals" |
8507 |
+ " -proceedOnError -referenceInfo" |
8508 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8509 |
"", |
8510 |
"----------\n" + |
8511 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
8512 |
" int j = R.R3;\n" + |
8513 |
" ^^^^\n" + |
8514 |
"R.R3 cannot be resolved\n" + |
8515 |
"----------\n" + |
8516 |
"1 problem (1 error)", |
8517 |
true); |
8518 |
} |
8519 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8520 |
// using only links, we adopt a depth first algorithm |
8521 |
public void test219_jar_ref_in_jar(){ |
8522 |
createCascadedJars(); |
8523 |
this.runNegativeTest( |
8524 |
new String[] { |
8525 |
"src/p/X.java", |
8526 |
"package p;\n" + |
8527 |
"/** */\n" + |
8528 |
"public class X {\n" + |
8529 |
" int i = R.R2;\n" + |
8530 |
" int j = R.R3;\n" + |
8531 |
"}", |
8532 |
}, |
8533 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8534 |
+ " -cp \"" + LIB_DIR + File.separator + "lib4.jar\"" |
8535 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8536 |
+ " -1.5 -g -preserveAllLocals" |
8537 |
+ " -proceedOnError -referenceInfo" |
8538 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8539 |
"", |
8540 |
"----------\n" + |
8541 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
8542 |
" int j = R.R3;\n" + |
8543 |
" ^^^^\n" + |
8544 |
"R.R3 cannot be resolved\n" + |
8545 |
"----------\n" + |
8546 |
"1 problem (1 error)", |
8547 |
true); |
8548 |
} |
8549 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8550 |
// managing subdirectories and .. properly |
8551 |
public void test220_jar_ref_in_jar(){ |
8552 |
createCascadedJars(); |
8553 |
this.runConformTest( |
8554 |
new String[] { |
8555 |
"src/p/X.java", |
8556 |
"package p;\n" + |
8557 |
"/** */\n" + |
8558 |
"public class X {\n" + |
8559 |
" A a;\n" + |
8560 |
" B b;\n" + |
8561 |
" C c;\n" + |
8562 |
" D d;\n" + |
8563 |
"}", |
8564 |
}, |
8565 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8566 |
+ " -cp \"" + LIB_DIR + File.separator + "lib5.jar\"" |
8567 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8568 |
+ " -1.5 -g -preserveAllLocals" |
8569 |
+ " -proceedOnError -referenceInfo" |
8570 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8571 |
"", |
8572 |
"", |
8573 |
true); |
8574 |
} |
8575 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8576 |
// variant: the second jar on a line is found as well |
8577 |
public void test221_jar_ref_in_jar(){ |
8578 |
createCascadedJars(); |
8579 |
this.runConformTest( |
8580 |
new String[] { |
8581 |
"src/p/X.java", |
8582 |
"package p;\n" + |
8583 |
"/** */\n" + |
8584 |
"public class X {\n" + |
8585 |
" C c;\n" + |
8586 |
"}", |
8587 |
}, |
8588 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8589 |
+ " -cp \"" + LIB_DIR + File.separator + "lib4.jar\"" |
8590 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8591 |
+ " -1.5 -g -preserveAllLocals" |
8592 |
+ " -proceedOnError -referenceInfo" |
8593 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8594 |
"", |
8595 |
"", |
8596 |
true); |
8597 |
} |
8598 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8599 |
// we eat up absolute links silently |
8600 |
public void test222_jar_ref_in_jar(){ |
8601 |
createCascadedJars(); |
8602 |
this.runConformTest( |
8603 |
new String[] { |
8604 |
"src/p/X.java", |
8605 |
"package p;\n" + |
8606 |
"/** */\n" + |
8607 |
"public class X {\n" + |
8608 |
" F f;\n" + |
8609 |
"}", |
8610 |
}, |
8611 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8612 |
+ " -cp \"" + LIB_DIR + File.separator + "lib8.jar\"" |
8613 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8614 |
+ " -1.5 -g -preserveAllLocals" |
8615 |
+ " -proceedOnError -referenceInfo" |
8616 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8617 |
"", |
8618 |
"", |
8619 |
true); |
8620 |
} |
8621 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8622 |
// absolute links do not mask following relative links |
8623 |
public void test223_jar_ref_in_jar(){ |
8624 |
createCascadedJars(); |
8625 |
this.runConformTest( |
8626 |
new String[] { |
8627 |
"src/p/X.java", |
8628 |
"package p;\n" + |
8629 |
"/** */\n" + |
8630 |
"public class X {\n" + |
8631 |
" A a;\n" + |
8632 |
" F f;\n" + |
8633 |
"}", |
8634 |
}, |
8635 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8636 |
+ " -cp \"" + LIB_DIR + File.separator + "lib8.jar\"" |
8637 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8638 |
+ " -1.5 -g -preserveAllLocals" |
8639 |
+ " -proceedOnError -referenceInfo" |
8640 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8641 |
"", |
8642 |
"", |
8643 |
true); |
8644 |
} |
8645 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8646 |
// absolute links are not followed |
8647 |
public void test224_jar_ref_in_jar(){ |
8648 |
createCascadedJars(); |
8649 |
this.runNegativeTest( |
8650 |
new String[] { |
8651 |
"src/p/X.java", |
8652 |
"package p;\n" + |
8653 |
"/** */\n" + |
8654 |
"public class X {\n" + |
8655 |
" C c;\n" + |
8656 |
"}", |
8657 |
}, |
8658 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8659 |
+ " -cp \"" + LIB_DIR + File.separator + "lib8.jar\"" |
8660 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8661 |
+ " -1.5 -g -preserveAllLocals" |
8662 |
+ " -proceedOnError -referenceInfo" |
8663 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8664 |
"", |
8665 |
"----------\n" + |
8666 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + |
8667 |
" C c;\n" + |
8668 |
" ^\n" + |
8669 |
"C cannot be resolved to a type\n" + |
8670 |
"----------\n" + |
8671 |
"1 problem (1 error)", |
8672 |
true); |
8673 |
} |
8674 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8675 |
// we accept duplicate classpath lines in manifest and we follow the jars of the |
8676 |
// second and following lines as well as the first line (emit a warning as javac does) |
8677 |
public void test225_jar_ref_in_jar(){ |
8678 |
createCascadedJars(); |
8679 |
this.runConformTest( |
8680 |
new String[] { |
8681 |
"src/p/X.java", |
8682 |
"package p;\n" + |
8683 |
"/** */\n" + |
8684 |
"public class X {\n" + |
8685 |
" A a;\n" + |
8686 |
" G g;\n" + |
8687 |
"}", |
8688 |
}, |
8689 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8690 |
+ " -cp \"" + LIB_DIR + File.separator + "lib9.jar\"" |
8691 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8692 |
+ " -1.5 -g -preserveAllLocals" |
8693 |
+ " -proceedOnError -referenceInfo" |
8694 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8695 |
"", |
8696 |
"multiple Class-Path headers in manifest of jar file: ---LIB_DIR_PLACEHOLDER---/lib9.jar\n", |
8697 |
true); |
8698 |
} |
8699 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8700 |
// we accept duplicate classpath lines in manifest and we follow the jars of the |
8701 |
// second and following lines as well as the first line (emit a warning as javac does) |
8702 |
public void test226_jar_ref_in_jar(){ |
8703 |
createCascadedJars(); |
8704 |
this.runConformTest( |
8705 |
new String[] { |
8706 |
"src/p/X.java", |
8707 |
"package p;\n" + |
8708 |
"/** */\n" + |
8709 |
"public class X {\n" + |
8710 |
" C c;\n" + |
8711 |
" G g;\n" + |
8712 |
"}", |
8713 |
}, |
8714 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8715 |
+ " -cp \"" + LIB_DIR + File.separator + "lib9.jar\"" |
8716 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8717 |
+ " -1.5 -g -preserveAllLocals" |
8718 |
+ " -proceedOnError -referenceInfo" |
8719 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8720 |
"", |
8721 |
"multiple Class-Path headers in manifest of jar file: ---LIB_DIR_PLACEHOLDER---/lib9.jar\n", |
8722 |
true); |
8723 |
} |
8724 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8725 |
// bootclasspath does not get expanded with linked files |
8726 |
public void test227_jar_ref_in_jar(){ |
8727 |
createCascadedJars(); |
8728 |
this.runNegativeTest( |
8729 |
new String[] { |
8730 |
"src/p/X.java", |
8731 |
"package p;\n" + |
8732 |
"/** */\n" + |
8733 |
"public class X {\n" + |
8734 |
" A a;\n" + |
8735 |
" B b;\n" + |
8736 |
"}", |
8737 |
}, |
8738 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8739 |
+ " -bootclasspath " + getLibraryClassesAsQuotedString() |
8740 |
+ File.pathSeparator + "\"" + LIB_DIR + File.separator + "lib1.jar\"" |
8741 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8742 |
+ " -1.5 -g -preserveAllLocals" |
8743 |
+ " -proceedOnError -referenceInfo" |
8744 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8745 |
"", |
8746 |
"----------\n" + |
8747 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
8748 |
" B b;\n" + |
8749 |
" ^\n" + |
8750 |
"B cannot be resolved to a type\n" + |
8751 |
"----------\n" + |
8752 |
"1 problem (1 error)", |
8753 |
true); |
8754 |
} |
8755 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8756 |
// jar files reached indirectly bear the access rules of the entry that |
8757 |
// references them |
8758 |
public void test228_jar_ref_in_jar(){ |
8759 |
createCascadedJars(); |
8760 |
this.runConformTest( |
8761 |
new String[] { |
8762 |
"src/p/X.java", |
8763 |
"package p;\n" + |
8764 |
"/** */\n" + |
8765 |
"public class X {\n" + |
8766 |
" A a;\n" + |
8767 |
"}", |
8768 |
}, |
8769 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8770 |
+ " -cp \"" + LIB_DIR + File.separator + "lib3.jar[~p/A]\"" |
8771 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8772 |
+ " -1.5 -g -preserveAllLocals" |
8773 |
+ " -proceedOnError -referenceInfo" |
8774 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8775 |
"", |
8776 |
"----------\n" + |
8777 |
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + |
8778 |
" A a;\n" + |
8779 |
" ^\n" + |
8780 |
"Discouraged access: The type A is not accessible due to restriction on classpath entry ---LIB_DIR_PLACEHOLDER---/lib3.jar\n" + |
8781 |
"----------\n" + |
8782 |
"1 problem (1 warning)", |
8783 |
true); |
8784 |
} |
8785 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8786 |
// jar files reached indirectly bear the access rules of the entry that |
8787 |
// references them - this hides the access rules of further instances of the |
8788 |
// same jar on the classpath |
8789 |
public void test229_jar_ref_in_jar(){ |
8790 |
createCascadedJars(); |
8791 |
this.runConformTest( |
8792 |
new String[] { |
8793 |
"src/p/X.java", |
8794 |
"package p;\n" + |
8795 |
"/** */\n" + |
8796 |
"public class X {\n" + |
8797 |
" A a;\n" + |
8798 |
"}", |
8799 |
}, |
8800 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8801 |
+ " -cp \"" + LIB_DIR + File.separator + "lib3.jar[~p/A]\"" |
8802 |
+ " -cp \"" + LIB_DIR + File.separator + "lib1.jar[-p/A]\"" |
8803 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8804 |
+ " -1.5 -g -preserveAllLocals" |
8805 |
+ " -proceedOnError -referenceInfo" |
8806 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8807 |
"", |
8808 |
"----------\n" + |
8809 |
"1. WARNING in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + |
8810 |
" A a;\n" + |
8811 |
" ^\n" + |
8812 |
"Discouraged access: The type A is not accessible due to restriction on classpath entry ---LIB_DIR_PLACEHOLDER---/lib3.jar\n" + |
8813 |
"----------\n" + |
8814 |
"1 problem (1 warning)", |
8815 |
true); |
8816 |
} |
8817 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8818 |
// jar files reached indirectly bear the access rules of the entry that |
8819 |
// references them - this hides the access rules of further instances of the |
8820 |
// same jar on the classpath |
8821 |
public void test230_jar_ref_in_jar(){ |
8822 |
createCascadedJars(); |
8823 |
this.runConformTest( |
8824 |
new String[] { |
8825 |
"src/p/X.java", |
8826 |
"package p;\n" + |
8827 |
"/** */\n" + |
8828 |
"public class X {\n" + |
8829 |
" A a;\n" + |
8830 |
"}", |
8831 |
}, |
8832 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8833 |
+ " -cp \"" + LIB_DIR + File.separator + "lib3.jar[-DUMMY]\"" |
8834 |
+ " -cp \"" + LIB_DIR + File.separator + "lib1.jar[-p/A]\"" |
8835 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8836 |
+ " -1.5 -g -preserveAllLocals" |
8837 |
+ " -proceedOnError -referenceInfo" |
8838 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8839 |
"", |
8840 |
"", |
8841 |
true); |
8842 |
} |
8843 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8844 |
// jar files reached indirectly bear the access rules of the entry that |
8845 |
// references them - this hides the access rules of further instances of the |
8846 |
// same jar on the classpath, to the point of absorbing it if none is specified |
8847 |
public void test231_jar_ref_in_jar(){ |
8848 |
createCascadedJars(); |
8849 |
this.runConformTest( |
8850 |
new String[] { |
8851 |
"src/p/X.java", |
8852 |
"package p;\n" + |
8853 |
"/** */\n" + |
8854 |
"public class X {\n" + |
8855 |
" A a;\n" + |
8856 |
"}", |
8857 |
}, |
8858 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8859 |
+ " -cp \"" + LIB_DIR + File.separator + "lib3.jar\"" |
8860 |
+ " -cp \"" + LIB_DIR + File.separator + "lib1.jar[-p/A]\"" |
8861 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8862 |
+ " -1.5 -g -preserveAllLocals" |
8863 |
+ " -proceedOnError -referenceInfo" |
8864 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8865 |
"", |
8866 |
"", |
8867 |
true); |
8868 |
} |
8869 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8870 |
// -sourcepath is OK at first level |
8871 |
public void test232_jar_ref_in_jar(){ |
8872 |
createCascadedJars(); |
8873 |
this.runConformTest( |
8874 |
new String[] { |
8875 |
"src/p/X.java", |
8876 |
"package p;\n" + |
8877 |
"/** */\n" + |
8878 |
"public class X {\n" + |
8879 |
" S1 s;\n" + |
8880 |
"}", |
8881 |
}, |
8882 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8883 |
+ " -sourcepath \"" + LIB_DIR + File.separator + "lib1.jar\"" |
8884 |
+ " -1.5 -g -preserveAllLocals" |
8885 |
+ " -proceedOnError -referenceInfo" |
8886 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8887 |
"", |
8888 |
"", |
8889 |
true); |
8890 |
} |
8891 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8892 |
// -sourcepath is KO at second level (that is, it does not leverage the links |
8893 |
// at all) |
8894 |
public void test233_jar_ref_in_jar(){ |
8895 |
createCascadedJars(); |
8896 |
this.runNegativeTest( |
8897 |
new String[] { |
8898 |
"src/p/X.java", |
8899 |
"package p;\n" + |
8900 |
"/** */\n" + |
8901 |
"public class X {\n" + |
8902 |
" S2 s;\n" + |
8903 |
"}", |
8904 |
}, |
8905 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8906 |
+ " -sourcepath \"" + LIB_DIR + File.separator + "lib1.jar\"" |
8907 |
+ " -1.5 -g -preserveAllLocals" |
8908 |
+ " -proceedOnError -referenceInfo" |
8909 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8910 |
"", |
8911 |
"----------\n" + |
8912 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + |
8913 |
" S2 s;\n" + |
8914 |
" ^^\n" + |
8915 |
"S2 cannot be resolved to a type\n" + |
8916 |
"----------\n" + |
8917 |
"1 problem (1 error)", |
8918 |
true); |
8919 |
} |
8920 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8921 |
// error case: the MANIFEST.MF is a directory; should fail gracefully |
8922 |
public void test234_jar_ref_in_jar(){ |
8923 |
createCascadedJars(); |
8924 |
this.runNegativeTest( |
8925 |
new String[] { |
8926 |
"src/p/X.java", |
8927 |
"package p;\n" + |
8928 |
"/** */\n" + |
8929 |
"public class X {\n" + |
8930 |
" A a;\n" + |
8931 |
" B b;\n" + |
8932 |
"}", |
8933 |
}, |
8934 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8935 |
+ " -cp \"" + LIB_DIR + File.separator + "lib10.jar\"" |
8936 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8937 |
+ " -1.5 -g -preserveAllLocals" |
8938 |
+ " -proceedOnError -referenceInfo" |
8939 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8940 |
"", |
8941 |
"----------\n" + |
8942 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
8943 |
" B b;\n" + |
8944 |
" ^\n" + |
8945 |
"B cannot be resolved to a type\n" + |
8946 |
"----------\n" + |
8947 |
"1 problem (1 error)", |
8948 |
true); |
8949 |
} |
8950 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
8951 |
// using relative paths for libs |
8952 |
public void test235_jar_ref_in_jar(){ |
8953 |
String currentWorkingDirectoryPath = System.getProperty("user.dir"); |
8954 |
if (currentWorkingDirectoryPath == null) { |
8955 |
System.err.println("BatchCompilerTest#235 could not access the current working directory " + currentWorkingDirectoryPath); |
8956 |
} else if (!new File(currentWorkingDirectoryPath).isDirectory()) { |
8957 |
System.err.println("BatchCompilerTest#235 current working directory is not a directory " + currentWorkingDirectoryPath); |
8958 |
} else { |
8959 |
String lib1Path = currentWorkingDirectoryPath + File.separator + "lib1.jar"; |
8960 |
String lib2Path = currentWorkingDirectoryPath + File.separator + "lib2.jar"; |
8961 |
try { |
8962 |
Util.createJar( |
8963 |
null, |
8964 |
new String[] { |
8965 |
"META-INF/MANIFEST.MF", |
8966 |
"Manifest-Version: 1.0\n" + |
8967 |
"Created-By: Eclipse JDT Test Harness\n" + |
8968 |
"Class-Path: lib2.jar\n", |
8969 |
}, |
8970 |
lib1Path, |
8971 |
JavaCore.VERSION_1_4); |
8972 |
Util.createJar( |
8973 |
new String[] { |
8974 |
"p/A.java", |
8975 |
"package p;\n" + |
8976 |
"public class A {\n" + |
8977 |
"}", |
8978 |
}, |
8979 |
null, |
8980 |
lib2Path, |
8981 |
JavaCore.VERSION_1_4); |
8982 |
this.runConformTest( |
8983 |
new String[] { |
8984 |
"src/p/X.java", |
8985 |
"package p;\n" + |
8986 |
"/** */\n" + |
8987 |
"public class X {\n" + |
8988 |
" A a;\n" + |
8989 |
"}", |
8990 |
}, |
8991 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
8992 |
+ " -cp lib1.jar" // relative |
8993 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
8994 |
+ " -1.5 -g -preserveAllLocals" |
8995 |
+ " -proceedOnError -referenceInfo" |
8996 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
8997 |
"", |
8998 |
"", |
8999 |
true); |
9000 |
} catch (IOException e) { |
9001 |
System.err.println("BatchCompilerTest#235 could not write to current working directory " + currentWorkingDirectoryPath); |
9002 |
} finally { |
9003 |
new File(lib1Path).delete(); |
9004 |
new File(lib2Path).delete(); |
9005 |
} |
9006 |
} |
9007 |
} |
9008 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9009 |
// empty Class-Path header |
9010 |
// javac 1.4.2 passes, later versions fail in error |
9011 |
// java accepts the same jar (which makes the compiler responsible for the |
9012 |
// error detection) |
9013 |
// design: will issue a warning |
9014 |
public void test236_jar_ref_in_jar(){ |
9015 |
createCascadedJars(); |
9016 |
this.runTest( |
9017 |
true, |
9018 |
new String[] { |
9019 |
"src/p/X.java", |
9020 |
"package p;\n" + |
9021 |
"/** */\n" + |
9022 |
"public class X {\n" + |
9023 |
" A a;\n" + |
9024 |
"}", |
9025 |
}, |
9026 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
9027 |
+ " -classpath \"" + LIB_DIR + File.separator + "lib11.jar\"" |
9028 |
+ " -1.5 -g -preserveAllLocals" |
9029 |
+ " -verbose -proceedOnError -referenceInfo" |
9030 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
9031 |
ONE_FILE_GENERATED_MATCHER, |
9032 |
new StringMatcher( |
9033 |
"invalid Class-Path header in manifest of jar file: ---LIB_DIR_PLACEHOLDER---/lib11.jar\n", |
9034 |
outputDirNormalizer), |
9035 |
true); |
9036 |
} |
9037 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9038 |
// missing space after ClassPath: |
9039 |
public void test237_jar_ref_in_jar(){ |
9040 |
createCascadedJars(); |
9041 |
this.runTest( |
9042 |
false, |
9043 |
new String[] { |
9044 |
"src/p/X.java", |
9045 |
"package p;\n" + |
9046 |
"/** */\n" + |
9047 |
"public class X {\n" + |
9048 |
" A a;\n" + |
9049 |
"}", |
9050 |
}, |
9051 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
9052 |
+ " -classpath \"" + LIB_DIR + File.separator + "lib12.jar\"" |
9053 |
+ " -1.5 -g -preserveAllLocals" |
9054 |
+ " -referenceInfo" |
9055 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
9056 |
"", |
9057 |
"invalid Class-Path header in manifest of jar file: ---LIB_DIR_PLACEHOLDER---/lib12.jar\n" + |
9058 |
"----------\n" + |
9059 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + |
9060 |
" A a;\n" + |
9061 |
" ^\n" + |
9062 |
"A cannot be resolved to a type\n" + |
9063 |
"----------\n" + |
9064 |
"1 problem (1 error)", |
9065 |
true); |
9066 |
} |
9067 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9068 |
// missing space after ClassPath |
9069 |
// javac reports an error (including an explicit manifest header error since |
9070 |
// version 1.5); moreover, it stops interpreting the said header |
9071 |
// design: we report a warning and eat up the remainding of the line |
9072 |
public void test238_jar_ref_in_jar(){ |
9073 |
createCascadedJars(); |
9074 |
this.runTest( |
9075 |
false, |
9076 |
new String[] { |
9077 |
"src/p/X.java", |
9078 |
"package p;\n" + |
9079 |
"/** */\n" + |
9080 |
"public class X {\n" + |
9081 |
" A a;\n" + |
9082 |
"}", |
9083 |
}, |
9084 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
9085 |
+ " -classpath \"" + LIB_DIR + File.separator + "lib13.jar\"" |
9086 |
+ " -1.5 -g -preserveAllLocals" |
9087 |
+ " -proceedOnError -referenceInfo" |
9088 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
9089 |
"", |
9090 |
"invalid Class-Path header in manifest of jar file: ---LIB_DIR_PLACEHOLDER---/lib13.jar\n" + |
9091 |
"----------\n" + |
9092 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + |
9093 |
" A a;\n" + |
9094 |
" ^\n" + |
9095 |
"A cannot be resolved to a type\n" + |
9096 |
"----------\n" + |
9097 |
"1 problem (1 error)", |
9098 |
true); |
9099 |
} |
9100 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9101 |
// extra space before Class-Path header |
9102 |
// the net result is that the line is part of the value of the previous header |
9103 |
// we then simply don't see the remainding of the line as jars |
9104 |
public void test239_jar_ref_in_jar(){ |
9105 |
createCascadedJars(); |
9106 |
this.runTest( |
9107 |
false, |
9108 |
new String[] { |
9109 |
"src/p/X.java", |
9110 |
"package p;\n" + |
9111 |
"/** */\n" + |
9112 |
"public class X {\n" + |
9113 |
" A a;\n" + |
9114 |
"}", |
9115 |
}, |
9116 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
9117 |
+ " -classpath \"" + LIB_DIR + File.separator + "lib14.jar\"" |
9118 |
+ " -1.5 -g -preserveAllLocals" |
9119 |
+ " -proceedOnError -referenceInfo" |
9120 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
9121 |
"", |
9122 |
"----------\n" + |
9123 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + |
9124 |
" A a;\n" + |
9125 |
" ^\n" + |
9126 |
"A cannot be resolved to a type\n" + |
9127 |
"----------\n" + |
9128 |
"1 problem (1 error)", |
9129 |
true); |
9130 |
} |
9131 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9132 |
// missing newline at the end of the line |
9133 |
// javac eats the line silently, which results into not finding A |
9134 |
// design: we report a warning and eat up the remainding of the line |
9135 |
public void test240_jar_ref_in_jar(){ |
9136 |
createCascadedJars(); |
9137 |
this.runTest( |
9138 |
false, |
9139 |
new String[] { |
9140 |
"src/p/X.java", |
9141 |
"package p;\n" + |
9142 |
"/** */\n" + |
9143 |
"public class X {\n" + |
9144 |
" A a;\n" + |
9145 |
"}", |
9146 |
}, |
9147 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
9148 |
+ " -classpath \"" + LIB_DIR + File.separator + "lib15.jar\"" |
9149 |
+ " -1.5 -g -preserveAllLocals" |
9150 |
+ " -proceedOnError -referenceInfo" |
9151 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
9152 |
"", |
9153 |
"invalid Class-Path header in manifest of jar file: ---LIB_DIR_PLACEHOLDER---/lib15.jar\n" + |
9154 |
"----------\n" + |
9155 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 4)\n" + |
9156 |
" A a;\n" + |
9157 |
" ^\n" + |
9158 |
"A cannot be resolved to a type\n" + |
9159 |
"----------\n" + |
9160 |
"1 problem (1 error)", |
9161 |
true); |
9162 |
} |
9163 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9164 |
// white-box test for duplicate classpath lines variant (empty line between the |
9165 |
// entries) |
9166 |
public void test241_jar_ref_in_jar(){ |
9167 |
try { |
9168 |
assertTrue(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( |
9169 |
new StringReader( |
9170 |
"Manifest-Version: 1.0\n" + |
9171 |
"Created-By: Eclipse JDT Test Harness\n" + |
9172 |
"Class-Path: lib1.jar\n" + |
9173 |
"\n" + |
9174 |
"Class-Path: lib3.jar\n"))); |
9175 |
assertEquals(2, ClasspathJar.MANIFEST_ANALYZER.getClasspathSectionsCount()); |
9176 |
assertEquals(2, ClasspathJar.MANIFEST_ANALYZER.getCalledFileNames().size()); |
9177 |
} catch (IOException e) { |
9178 |
e.printStackTrace(); |
9179 |
fail(); |
9180 |
} |
9181 |
} |
9182 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9183 |
// white-box test for duplicate classpath lines variant (other header between the |
9184 |
// entries - note that since we are not doing a full-fledged manifest analysis, |
9185 |
// a dummy header passes) |
9186 |
public void test242_jar_ref_in_jar(){ |
9187 |
try { |
9188 |
assertTrue(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( |
9189 |
new StringReader( |
9190 |
"Manifest-Version: 1.0\n" + |
9191 |
"Created-By: Eclipse JDT Test Harness\n" + |
9192 |
"Class-Path: lib1.jar\n" + |
9193 |
"Dummy:\n" + |
9194 |
"Class-Path: lib3.jar\n"))); |
9195 |
assertEquals(2, ClasspathJar.MANIFEST_ANALYZER.getClasspathSectionsCount()); |
9196 |
assertEquals(2, ClasspathJar.MANIFEST_ANALYZER.getCalledFileNames().size()); |
9197 |
} catch (IOException e) { |
9198 |
e.printStackTrace(); |
9199 |
fail(); |
9200 |
} |
9201 |
} |
9202 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9203 |
// white-box test: tabs are not seen as URI separator, but as parts of URI instead |
9204 |
// will trigger downstream errors if the jars are really needed |
9205 |
public void test243_jar_ref_in_jar(){ |
9206 |
try { |
9207 |
assertTrue(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( |
9208 |
new StringReader( |
9209 |
"Manifest-Version: 1.0\n" + |
9210 |
"Created-By: Eclipse JDT Test Harness\n" + |
9211 |
"Class-Path: lib1.jar\tlib2.jar\n"))); |
9212 |
assertEquals(1, ClasspathJar.MANIFEST_ANALYZER.getClasspathSectionsCount()); |
9213 |
assertEquals(1, ClasspathJar.MANIFEST_ANALYZER.getCalledFileNames().size()); |
9214 |
} catch (IOException e) { |
9215 |
e.printStackTrace(); |
9216 |
fail(); |
9217 |
} |
9218 |
} |
9219 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9220 |
// managing continuations properly |
9221 |
public void test244_jar_ref_in_jar(){ |
9222 |
createCascadedJars(); |
9223 |
this.runConformTest( |
9224 |
new String[] { |
9225 |
"src/p/X.java", |
9226 |
"package p;\n" + |
9227 |
"/** */\n" + |
9228 |
"public class X {\n" + |
9229 |
" A a;\n" + |
9230 |
" B b;\n" + |
9231 |
"}", |
9232 |
}, |
9233 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
9234 |
+ " -cp \"" + LIB_DIR + File.separator + "lib16.jar\"" |
9235 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
9236 |
+ " -1.5 -g -preserveAllLocals" |
9237 |
+ " -proceedOnError -referenceInfo" |
9238 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
9239 |
"", |
9240 |
"", |
9241 |
true); |
9242 |
} |
9243 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9244 |
// white-box test: variants on continuations |
9245 |
public void test245_jar_ref_in_jar(){ |
9246 |
try { |
9247 |
assertTrue(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( |
9248 |
new StringReader( |
9249 |
"Manifest-Version: 1.0\n" + |
9250 |
"Created-By: Eclipse JDT Test Harness\n" + |
9251 |
"Class-Path: \n" + |
9252 |
" lib1.jar \n" + |
9253 |
"\n"))); |
9254 |
assertEquals(1, ClasspathJar.MANIFEST_ANALYZER.getClasspathSectionsCount()); |
9255 |
assertEquals(1, ClasspathJar.MANIFEST_ANALYZER.getCalledFileNames().size()); |
9256 |
} catch (IOException e) { |
9257 |
e.printStackTrace(); |
9258 |
fail(); |
9259 |
} |
9260 |
} |
9261 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9262 |
// white-box test: variants on continuations |
9263 |
public void test246_jar_ref_in_jar(){ |
9264 |
try { |
9265 |
assertTrue(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( |
9266 |
new StringReader( |
9267 |
"Manifest-Version: 1.0\n" + |
9268 |
"Created-By: Eclipse JDT Test Harness\n" + |
9269 |
"Class-Path: \n" + |
9270 |
" \n" + |
9271 |
" lib1.jar \n" + |
9272 |
" \n" + |
9273 |
" lib1.jar \n" + |
9274 |
"\n"))); |
9275 |
assertEquals(1, ClasspathJar.MANIFEST_ANALYZER.getClasspathSectionsCount()); |
9276 |
assertEquals(2, ClasspathJar.MANIFEST_ANALYZER.getCalledFileNames().size()); |
9277 |
} catch (IOException e) { |
9278 |
e.printStackTrace(); |
9279 |
fail(); |
9280 |
} |
9281 |
} |
9282 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9283 |
// white-box test: variants on continuations |
9284 |
public void test247_jar_ref_in_jar(){ |
9285 |
try { |
9286 |
assertFalse(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( |
9287 |
new StringReader( |
9288 |
"Manifest-Version: 1.0\n" + |
9289 |
"Created-By: Eclipse JDT Test Harness\n" + |
9290 |
"Class-Path: \n" + |
9291 |
" lib1.jar"))); |
9292 |
} catch (IOException e) { |
9293 |
e.printStackTrace(); |
9294 |
fail(); |
9295 |
} |
9296 |
} |
9297 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9298 |
// white-box test: variants on continuations |
9299 |
public void test248_jar_ref_in_jar(){ |
9300 |
try { |
9301 |
assertFalse(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( |
9302 |
new StringReader( |
9303 |
"Manifest-Version: 1.0\n" + |
9304 |
"Created-By: Eclipse JDT Test Harness\n" + |
9305 |
"Class-Path: \n" + |
9306 |
" \n" + |
9307 |
" lib1.jar"))); |
9308 |
} catch (IOException e) { |
9309 |
e.printStackTrace(); |
9310 |
fail(); |
9311 |
} |
9312 |
} |
9313 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9314 |
// white-box test: variants on continuations |
9315 |
public void test249_jar_ref_in_jar(){ |
9316 |
try { |
9317 |
assertFalse(ClasspathJar.MANIFEST_ANALYZER.analyzeManifestContents( |
9318 |
new StringReader( |
9319 |
"Manifest-Version: 1.0\n" + |
9320 |
"Created-By: Eclipse JDT Test Harness\n" + |
9321 |
"Class-Path: \n" + |
9322 |
"lib1.jar"))); |
9323 |
} catch (IOException e) { |
9324 |
e.printStackTrace(); |
9325 |
fail(); |
9326 |
} |
9327 |
} |
9328 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9329 |
// extdirs jars do not follow links |
9330 |
public void test250_jar_ref_in_jar(){ |
9331 |
createCascadedJars(); |
9332 |
this.runNegativeTest( |
9333 |
new String[] { |
9334 |
"src/p/X.java", |
9335 |
"package p;\n" + |
9336 |
"/** */\n" + |
9337 |
"public class X {\n" + |
9338 |
" A a;\n" + |
9339 |
" B b;\n" + |
9340 |
"}", |
9341 |
}, |
9342 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
9343 |
+ " -extdirs \"" + LIB_DIR + File.separator + "dir\"" |
9344 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
9345 |
+ " -1.5 -g -preserveAllLocals" |
9346 |
+ " -proceedOnError -referenceInfo" |
9347 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
9348 |
"", |
9349 |
"----------\n" + |
9350 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
9351 |
" B b;\n" + |
9352 |
" ^\n" + |
9353 |
"B cannot be resolved to a type\n" + |
9354 |
"----------\n" + |
9355 |
"1 problem (1 error)", |
9356 |
true); |
9357 |
} |
9358 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars |
9359 |
// endorseddirs does not get expanded with linked files |
9360 |
public void test251_jar_ref_in_jar(){ |
9361 |
createCascadedJars(); |
9362 |
this.runNegativeTest( |
9363 |
new String[] { |
9364 |
"src/p/X.java", |
9365 |
"package p;\n" + |
9366 |
"/** */\n" + |
9367 |
"public class X {\n" + |
9368 |
" A a;\n" + |
9369 |
" B b;\n" + |
9370 |
"}", |
9371 |
}, |
9372 |
"\"" + OUTPUT_DIR + File.separator + "src/p/X.java\"" |
9373 |
+ " -endorseddirs \"" + LIB_DIR + File.separator + "dir\"" |
9374 |
+ " -sourcepath \"" + OUTPUT_DIR + File.separator + "src\"" |
9375 |
+ " -1.5 -g -preserveAllLocals" |
9376 |
+ " -proceedOnError -referenceInfo" |
9377 |
+ " -d \"" + OUTPUT_DIR + File.separator + "bin\" ", |
9378 |
"", |
9379 |
"----------\n" + |
9380 |
"1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/src/p/X.java (at line 5)\n" + |
9381 |
" B b;\n" + |
9382 |
" ^\n" + |
9383 |
"B cannot be resolved to a type\n" + |
9384 |
"----------\n" + |
9385 |
"1 problem (1 error)", |
9386 |
true); |
9387 |
} |
7860 |
public static Class testClass() { |
9388 |
public static Class testClass() { |
7861 |
return BatchCompilerTest.class; |
9389 |
return BatchCompilerTest.class; |
7862 |
} |
9390 |
} |