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 (-4 / +9 lines)
Lines 19-24 Link Here
19
import java.io.StringWriter;
19
import java.io.StringWriter;
20
import java.nio.charset.Charset;
20
import java.nio.charset.Charset;
21
import java.util.ArrayList;
21
import java.util.ArrayList;
22
import java.util.Collections;
22
import java.util.HashSet;
23
import java.util.HashSet;
23
import java.util.Iterator;
24
import java.util.Iterator;
24
import java.util.List;
25
import java.util.List;
Lines 604-610 Link Here
604
		assertTrue("delete failed", inputFile.delete());
605
		assertTrue("delete failed", inputFile.delete());
605
	}
606
	}
606
607
607
	public void testCompilerOneClassWithEclipseCompiler4() {
608
	public void testCompilerOneClassWithEclipseCompiler4() throws IOException {
608
		JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
609
		JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler();
609
		if (systemCompiler == null) {
610
		if (systemCompiler == null) {
610
			System.out.println("No system java compiler available");
611
			System.out.println("No system java compiler available");
Lines 653-658 Link Here
653
		}
654
		}
654
		// check that the .class file exist for X
655
		// check that the .class file exist for X
655
		assertTrue("delete failed", inputFile.delete());
656
		assertTrue("delete failed", inputFile.delete());
657
		manager.close();
656
	}
658
	}
657
659
658
	public void testCompilerOneClassWithEclipseCompiler5() {
660
	public void testCompilerOneClassWithEclipseCompiler5() {
Lines 869-874 Link Here
869
				builder.append(name.substring(lastIndexOf + 1));
871
				builder.append(name.substring(lastIndexOf + 1));
870
			}
872
			}
871
			assertEquals("Wrong contents", "X.java", String.valueOf(builder));
873
			assertEquals("Wrong contents", "X.java", String.valueOf(builder));
874
			fileManager.close();
872
		} catch (IOException e) {
875
		} catch (IOException e) {
873
			e.printStackTrace();
876
			e.printStackTrace();
874
		}
877
		}
Lines 934-948 Link Here
934
			Iterable<? extends JavaFileObject> compilationUnits = fileManager.list(sourceLoc, "", fileTypes, true);
937
			Iterable<? extends JavaFileObject> compilationUnits = fileManager.list(sourceLoc, "", fileTypes, true);
935
	
938
	
936
			Iterator<? extends JavaFileObject> it = compilationUnits.iterator();
939
			Iterator<? extends JavaFileObject> it = compilationUnits.iterator();
937
			StringBuilder builder = new StringBuilder();
940
			List<String> names = new ArrayList<String>();
938
			while (it.hasNext()) {
941
			while (it.hasNext()) {
939
				JavaFileObject next = it.next();
942
				JavaFileObject next = it.next();
940
				String name = next.getName();
943
				String name = next.getName();
941
				name = name.replace('\\', '/');
944
				name = name.replace('\\', '/');
942
				int lastIndexOf = name.lastIndexOf('/');
945
				int lastIndexOf = name.lastIndexOf('/');
943
				builder.append(name.substring(lastIndexOf + 1));
946
				names.add(name.substring(lastIndexOf + 1));
944
			}
947
			}
945
			assertEquals("Wrong contents", "X2.javaX.java", String.valueOf(builder));
948
			Collections.sort(names);
949
			assertEquals("Wrong contents", "[X.java, X2.java]", names.toString());
950
			fileManager.close();
946
		} catch (IOException e) {
951
		} catch (IOException e) {
947
			e.printStackTrace();
952
			e.printStackTrace();
948
		}
953
		}

Return to bug 363293