View | Details | Raw Unified | Return to bug 363293 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/AbstractCompilerToolTest.java (-10 / +19 lines)
Lines 12-17 Link Here
12
package org.eclipse.jdt.compiler.tool.tests;
12
package org.eclipse.jdt.compiler.tool.tests;
13
13
14
import java.io.File;
14
import java.io.File;
15
import java.io.IOException;
15
import java.io.PrintWriter;
16
import java.io.PrintWriter;
16
import java.util.ArrayList;
17
import java.util.ArrayList;
17
import java.util.List;
18
import java.util.List;
Lines 98-113 Link Here
98
		if (manager == null) {
99
		if (manager == null) {
99
			manager = COMPILER.getStandardFileManager(null, null, null); // will pick defaults up
100
			manager = COMPILER.getStandardFileManager(null, null, null); // will pick defaults up
100
		}
101
		}
101
		List<File> files = new ArrayList<File>();
102
		try {
102
		String[] fileNames = arguments.fileNames;
103
			List<File> files = new ArrayList<File>();
103
		for (int i = 0, l = fileNames.length; i < l; i++) {
104
			String[] fileNames = arguments.fileNames;
104
			if (fileNames[i].startsWith(OUTPUT_DIR)) {
105
			for (int i = 0, l = fileNames.length; i < l; i++) {
105
				files.add(new File(fileNames[i]));
106
				if (fileNames[i].startsWith(OUTPUT_DIR)) {
106
			} else {
107
					files.add(new File(fileNames[i]));
107
				files.add(new File(OUTPUT_DIR + File.separator + fileNames[i]));
108
				} else {
109
					files.add(new File(OUTPUT_DIR + File.separator + fileNames[i]));
110
				}
108
			}
111
			}
109
		}
112
			CompilationTask task = COMPILER.getTask(out, arguments.standardJavaFileManager /* carry the null over */, new CompilerInvocationDiagnosticListener(err), arguments.options, null, manager.getJavaFileObjectsFromFiles(files));
110
		CompilationTask task = COMPILER.getTask(out, arguments.standardJavaFileManager /* carry the null over */, new CompilerInvocationDiagnosticListener(err), arguments.options, null, manager.getJavaFileObjectsFromFiles(files));
113
			return task.call();
111
		return task.call();
114
		} finally {
115
			try {
116
				manager.close();
117
			} catch (IOException e) {
118
				// nop
119
			}
120
		}		
112
	}
121
	}
113
}
122
}
(-)a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java (+4 lines)
Lines 502-508 Link Here
502
		remaining = remainingAsList.iterator();
502
		remaining = remainingAsList.iterator();
503
		assertTrue("does not support -d option", javacStandardJavaFileManager.handleOption("-d", remaining));
503
		assertTrue("does not support -d option", javacStandardJavaFileManager.handleOption("-d", remaining));
504
		assertEquals("unexpected consumption rate", "remainder", remaining.next());
504
		assertEquals("unexpected consumption rate", "remainder", remaining.next());
505
		javacStandardJavaFileManager.close();
505
	}
506
	}
507
	ecjStandardJavaFileManager.close();
506
}
508
}
507
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=226918
509
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=226918
508
// options consumption - check consumption rate on supported zero-args options
510
// options consumption - check consumption rate on supported zero-args options
Lines 525-530 Link Here
525
			assertEquals("unexpected consumption rate", REMAINDER, remaining.next());
527
			assertEquals("unexpected consumption rate", REMAINDER, remaining.next());
526
		}
528
		}
527
	}
529
	}
530
	ecjStandardJavaFileManager.close();
528
}
531
}
529
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=226918
532
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=226918
530
// options consumption - check consumption rate on supported one-arg options
533
// options consumption - check consumption rate on supported one-arg options
Lines 540-545 Link Here
540
			assertEquals("unexpected consumption rate", REMAINDER, remaining.next());
543
			assertEquals("unexpected consumption rate", REMAINDER, remaining.next());
541
		}
544
		}
542
	}
545
	}
546
	ecjStandardJavaFileManager.close();
543
}
547
}
544
// tests #10-11 show that ecj throws a RuntimeException when encountering a wrong
548
// tests #10-11 show that ecj throws a RuntimeException when encountering a wrong
545
// encoding in its parameters, while the default compiler swallows it silently
549
// encoding in its parameters, while the default compiler swallows it silently
(-)a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java (-1 / +4 lines)
Lines 604-610 Link Here
604
		assertTrue("delete failed", inputFile.delete());
604
		assertTrue("delete failed", inputFile.delete());
605
	}
605
	}
606
606
607
	public void testCompilerOneClassWithEclipseCompiler4() {
607
	public void testCompilerOneClassWithEclipseCompiler4() throws IOException {
608
		JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
608
		JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
609
		if (systemCompiler == null) {
609
		if (systemCompiler == null) {
610
			System.out.println("No system java compiler available");
610
			System.out.println("No system java compiler available");
Lines 653-658 Link Here
653
		}
653
		}
654
		// check that the .class file exist for X
654
		// check that the .class file exist for X
655
		assertTrue("delete failed", inputFile.delete());
655
		assertTrue("delete failed", inputFile.delete());
656
		manager.close();
656
	}
657
	}
657
658
658
	public void testCompilerOneClassWithEclipseCompiler5() {
659
	public void testCompilerOneClassWithEclipseCompiler5() {
Lines 869-874 Link Here
869
				builder.append(name.substring(lastIndexOf + 1));
870
				builder.append(name.substring(lastIndexOf + 1));
870
			}
871
			}
871
			assertEquals("Wrong contents", "X.java", String.valueOf(builder));
872
			assertEquals("Wrong contents", "X.java", String.valueOf(builder));
873
			fileManager.close();
872
		} catch (IOException e) {
874
		} catch (IOException e) {
873
			e.printStackTrace();
875
			e.printStackTrace();
874
		}
876
		}
Lines 943-948 Link Here
943
				builder.append(name.substring(lastIndexOf + 1));
945
				builder.append(name.substring(lastIndexOf + 1));
944
			}
946
			}
945
			assertEquals("Wrong contents", "X2.javaX.java", String.valueOf(builder));
947
			assertEquals("Wrong contents", "X2.javaX.java", String.valueOf(builder));
948
			fileManager.close();
946
		} catch (IOException e) {
949
		} catch (IOException e) {
947
			e.printStackTrace();
950
			e.printStackTrace();
948
		}
951
		}

Return to bug 363293