Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2017-07-06 11:43:33 +0000
committerJay Arthanareeswaran2017-09-18 13:12:45 +0000
commitc798229d351d6daa2232cff6c15750336659223e (patch)
tree24fcc71a360db7f1b71ee743ab823ab51c1d891d /org.eclipse.jdt.compiler.tool.tests
parent062ac5d7a6bf9c9d3013dabfd6e3cb8633f7baec (diff)
downloadeclipse.jdt.core-c798229d351d6daa2232cff6c15750336659223e.tar.gz
eclipse.jdt.core-c798229d351d6daa2232cff6c15750336659223e.tar.xz
eclipse.jdt.core-c798229d351d6daa2232cff6c15750336659223e.zip
Bug 477291: [1.9] Support JRE 9 in JSR199 implementation
Change-Id: Idfbcd6c2e40fbbc1a325dbe43950284404642fc8 Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.compiler.tool.tests')
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/.classpath1
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/.gitignore1
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/build.properties2
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/lib/java9api.jarbin0 -> 25089 bytes
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/pom.xml23
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java22
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java374
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/ForwardingStandardJavaFileManager.java36
9 files changed, 455 insertions, 6 deletions
diff --git a/org.eclipse.jdt.compiler.tool.tests/.classpath b/org.eclipse.jdt.compiler.tool.tests/.classpath
index 01836c4842..2ae2e50653 100644
--- a/org.eclipse.jdt.compiler.tool.tests/.classpath
+++ b/org.eclipse.jdt.compiler.tool.tests/.classpath
@@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="lib" path="lib/java9api.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jdt.compiler.tool.tests/.gitignore b/org.eclipse.jdt.compiler.tool.tests/.gitignore
new file mode 100644
index 0000000000..eb8e3c750d
--- /dev/null
+++ b/org.eclipse.jdt.compiler.tool.tests/.gitignore
@@ -0,0 +1 @@
+/Y.class
diff --git a/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF b/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
index 5a9ed3fa41..19864cdec4 100644
--- a/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.compiler.tool.tests/META-INF/MANIFEST.MF
@@ -8,6 +8,8 @@ Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.jdt.core;bundle-version="3.2.2",
org.junit,
+ org.eclipse.core.resources,
+ org.eclipse.core.runtime,
org.eclipse.test.performance,
org.eclipse.jdt.core.tests.compiler
Export-Package: org.eclipse.jdt.compiler.tool.tests
diff --git a/org.eclipse.jdt.compiler.tool.tests/build.properties b/org.eclipse.jdt.compiler.tool.tests/build.properties
index 9fc5c55fd2..2de2e64f6c 100644
--- a/org.eclipse.jdt.compiler.tool.tests/build.properties
+++ b/org.eclipse.jdt.compiler.tool.tests/build.properties
@@ -13,7 +13,9 @@ bin.includes = META-INF/,\
about.html,\
plugin.properties,\
test.xml,\
+ lib/java9api.jar
.
src.includes = about.html
source.. = src/
output.. = bin/
+jars.extra.classpath = lib/java9api.jar
diff --git a/org.eclipse.jdt.compiler.tool.tests/lib/java9api.jar b/org.eclipse.jdt.compiler.tool.tests/lib/java9api.jar
new file mode 100644
index 0000000000..fd56ad100e
--- /dev/null
+++ b/org.eclipse.jdt.compiler.tool.tests/lib/java9api.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.tool.tests/pom.xml b/org.eclipse.jdt.compiler.tool.tests/pom.xml
index 693f0ad650..f00ca99ac3 100644
--- a/org.eclipse.jdt.compiler.tool.tests/pom.xml
+++ b/org.eclipse.jdt.compiler.tool.tests/pom.xml
@@ -26,4 +26,27 @@
<testSuite>${project.artifactId}</testSuite>
<testClass>org.eclipse.jdt.compiler.tool.tests.AllTests</testClass>
</properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-compiler-plugin</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <configuration>
+ <compilerArgs>
+ <args>-endorseddirs</args>
+ <args>${basedir}/lib</args>
+ </compilerArgs>
+ <!-- Use this form for Tycho 23 or greater -->
+ <log>xml</log>
+ <logDirectory>${project.build.directory}/compilelogs</logDirectory>
+ <showWarnings>true</showWarnings>
+ <excludeResources>
+ <exclude>**/package.html</exclude>
+ </excludeResources>
+ <useProjectSettings>false</useProjectSettings>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java
index a2f7590a53..bdf11f7c1b 100644
--- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java
@@ -32,21 +32,22 @@ import java.util.Properties;
import java.util.Set;
import java.util.logging.LogRecord;
+import javax.lang.model.SourceVersion;
import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileObject;
+import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
+import javax.tools.JavaFileObject.Kind;
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
-import javax.tools.JavaCompiler.CompilationTask;
-import javax.tools.JavaFileObject.Kind;
-
-import junit.framework.Test;
import org.eclipse.jdt.internal.compiler.batch.Main;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
+import junit.framework.Test;
+
public class CompilerInvocationTests extends AbstractCompilerToolTest {
static {
// TESTS_NAMES = new String[] { "test019_sourcepath_without_destination" };
@@ -62,7 +63,14 @@ public static Test suite() {
public static Class<CompilerInvocationTests> testClass() {
return CompilerInvocationTests.class;
}
-
+private boolean isOnJRE9() {
+ try {
+ SourceVersion.valueOf("RELEASE_9");
+ } catch(IllegalArgumentException iae) {
+ return false;
+ }
+ return true;
+}
protected void checkClassFiles(String[] fileNames) {
for (int i = 0, l = fileNames.length; i < l; i++) {
ClassFileReader reader = null;
@@ -204,6 +212,7 @@ class GetJavaFileForInputDetector extends GetJavaFileDetector {
return super.openReader(ignoreEncodingErrors);
}
}
+ @Override
JavaFileObject detector(JavaFileObject original) {
if (original != null && original.getKind() == this.discriminatingKind
&& (this.discriminatingSuffix == null || original.getName().endsWith(this.discriminatingSuffix))) {
@@ -250,6 +259,7 @@ class GetJavaFileForOutputDetector extends GetJavaFileDetector {
return super.openWriter();
}
}
+ @Override
JavaFileObject detector(JavaFileObject original) {
if (original != null && original.getKind() == Kind.CLASS
&& (this.discriminatingSuffix == null || original.getName().endsWith(this.discriminatingSuffix))) {
@@ -553,6 +563,8 @@ public void test009_options_consumption() throws IOException {
StandardJavaFileManager ecjStandardJavaFileManager =
COMPILER.getStandardFileManager(null /* diagnosticListener */, null /* locale */, null /* charset */);
for (String option: CompilerToolTests.ONE_ARG_OPTIONS) {
+ if (isOnJRE9() && (option.equals("-extdirs") || option.equals("-endorseddirs")))
+ continue;
if (ecjStandardJavaFileManager.isSupportedOption(option) != -1) { // some options that the compiler support could well not be supported by the file manager
Iterator<String> remaining = remainingAsList.iterator();
assertTrue("does not support " + option + " option", ecjStandardJavaFileManager.handleOption(option, remaining));
diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java
new file mode 100644
index 0000000000..64ca57c69e
--- /dev/null
+++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java
@@ -0,0 +1,374 @@
+/*******************************************************************************
+ * Copyright (c) 2017 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.compiler.tool.tests;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.ServiceLoader;
+
+import javax.lang.model.SourceVersion;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileManager.Location;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.internal.compiler.tool.EclipseCompiler;
+
+import junit.framework.TestCase;
+
+public class CompilerToolJava9Tests extends TestCase {
+ private static final String RESOURCES_DIR = "resources";
+ private JavaCompiler[] compilers;
+ private String[] compilerNames;
+ private boolean isJREBelow9;
+ private static String _tmpFolder;
+ private static String _tmpSrcFolderName;
+ private static File _tmpSrcDir;
+ private static String _tmpBinFolderName;
+ private static File _tmpBinDir;
+ public static String _tmpGenFolderName;
+ private static File _tmpGenDir;
+
+ private static String modules_directory;
+ public CompilerToolJava9Tests(String name) {
+ super(name);
+ }
+ @Override
+ protected void setUp() throws Exception {
+ this.isJREBelow9 = SourceVersion.latest().compareTo(SourceVersion.RELEASE_8) <= 0;
+ this.compilers = new JavaCompiler[2];
+ this.compilerNames = new String[2];
+ ServiceLoader<JavaCompiler> javaCompilerLoader = ServiceLoader.load(JavaCompiler.class);
+ int compilerCounter = 0;
+ for (JavaCompiler compiler : javaCompilerLoader) {
+ compilerCounter++;
+ if (compiler instanceof EclipseCompiler) {
+ this.compilers[1] = compiler;
+ this.compilerNames[1] = "Eclipse Compiler";
+ }
+ }
+ this.compilerNames[0] = "System compiler";
+ this.compilers[0] = ToolProvider.getSystemJavaCompiler();
+ assertEquals("Only one compiler available", 2, compilerCounter);
+ assertNotNull("System compiler unavailable", this.compilers[0]);
+ assertNotNull("Eclipse compiler unavailable", this.compilers[1]);
+ initializeLocations();
+ }
+ protected void initializeLocations() {
+ _tmpFolder = System.getProperty("java.io.tmpdir");
+ if (_tmpFolder.endsWith(File.separator)) {
+ _tmpFolder += "eclipse-temp";
+ } else {
+ _tmpFolder += (File.separator + "eclipse-temp");
+ }
+ _tmpBinFolderName = _tmpFolder + File.separator + "bin";
+ _tmpBinDir = new File(_tmpBinFolderName);
+ deleteTree(_tmpBinDir); // remove existing contents
+ _tmpBinDir.mkdirs();
+ assert _tmpBinDir.exists() : "couldn't mkdirs " + _tmpBinFolderName;
+
+ _tmpGenFolderName = _tmpFolder + File.separator + "gen-src";
+ _tmpGenDir = new File(_tmpGenFolderName);
+ deleteTree(_tmpGenDir); // remove existing contents
+ _tmpGenDir.mkdirs();
+ assert _tmpGenDir.exists() : "couldn't mkdirs " + _tmpGenFolderName;
+
+ _tmpSrcFolderName = _tmpFolder + File.separator + "src";
+ _tmpSrcDir = new File(_tmpSrcFolderName);
+ deleteTree(_tmpSrcDir); // remove existing contents
+ _tmpSrcDir.mkdirs();
+ assert _tmpSrcDir.exists() : "couldn't mkdirs " + _tmpSrcFolderName;
+
+ modules_directory = getPluginDirectoryPath() + File.separator + "resources" + File.separator + "module_locations";
+ }
+ public void testGetLocationForModule1() {
+ if (this.isJREBelow9) return;
+ for(int i = 0; i < 2; i++) {
+ String cName = this.compilerNames[i];
+ JavaCompiler compiler = this.compilers[i];
+ StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
+ try {
+ Location location = manager.getLocationForModule(StandardLocation.SYSTEM_MODULES, "java.base");
+ assertNotNull(cName + ": Location should not be null", location);
+ } catch (UnsupportedOperationException ex) {
+ fail(cName + ": Should support getLocationForModule()");
+ }
+ catch (IOException e) {
+ fail(cName + ": Should support getLocationForModule()");
+ }
+ }
+
+ }
+
+ public void testGetLocationForModule2() throws IOException {
+ if (this.isJREBelow9) return;
+ for(int i = 0; i < 2; i++) {
+ String cName = this.compilerNames[i];
+ JavaCompiler compiler = this.compilers[i];
+ StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
+ Path path = Paths.get(modules_directory + File.separator + "SimpleModules");
+ manager.setLocationFromPaths(StandardLocation.MODULE_PATH, Arrays.asList(path));
+ try {
+ JavaFileManager.Location location = manager.getLocationForModule(StandardLocation.MODULE_PATH, "module.two");
+ assertNotNull(cName + ":module path location should not be null", location);
+ } catch (UnsupportedOperationException ex) {
+ fail(cName + ":Should support getLocationForModule()");
+ }
+ }
+ }
+ public void testGetLocationForModule3() throws IOException {
+ if (this.isJREBelow9) return;
+ for(int i = 0; i < 2; i++) {
+ String cName = this.compilerNames[i];
+ JavaCompiler compiler = this.compilers[i];
+ StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
+ Path path = Paths.get(modules_directory + File.separator + "SimpleModules" + File.separator + "module.one");
+ manager.setLocationFromPaths(StandardLocation.MODULE_PATH, Arrays.asList(path));
+ try {
+ JavaFileManager.Location location = manager.getLocationForModule(StandardLocation.MODULE_PATH, "module.one");
+ assertNotNull(cName + ":module path location should not be null", location);
+ } catch (UnsupportedOperationException ex) {
+ fail(cName + ":Should support getLocationForModule()");
+ }
+ }
+ }
+ public void testGetJavaFileObjects() {
+ if (this.isJREBelow9) return;
+ }
+ public void testGetJavaFileObjects2() {
+ if (this.isJREBelow9) return;
+ }
+ public void testSetLocationAsPaths() {
+ if (this.isJREBelow9) return;
+ }
+ public void testContains() {
+ if (this.isJREBelow9) return;
+ }
+ public void testGetServiceLoader() {
+ if (this.isJREBelow9) return;
+ }
+ public void testInferModuleName() {
+ if (this.isJREBelow9) return;
+ }
+ public void testListLocationsForModules() {
+ if (this.isJREBelow9) return;
+ }
+ public void testAsPath() {
+ if (this.isJREBelow9) return;
+ }
+ /**
+ * Recursively delete the contents of a directory, including any subdirectories.
+ * This is not optimized to handle very large or deep directory trees efficiently.
+ * @param f is either a normal file (which will be deleted) or a directory
+ * (which will be emptied and then deleted).
+ */
+ public static void deleteTree(File f)
+ {
+ if (null == f) {
+ return;
+ }
+ File[] children = f.listFiles();
+ if (null != children) {
+ // if f has any children, (recursively) delete them
+ for (File child : children) {
+ deleteTree(child);
+ }
+ }
+ // At this point f is either a normal file or an empty directory
+ f.delete();
+ }
+ /**
+ * Copy a file from one location to another, unless the destination file already exists and has
+ * the same timestamp and file size. Create the destination location if necessary. Convert line
+ * delimiters according to {@link #shouldConvertToIndependentLineDelimiter(File)}.
+ *
+ * @param src
+ * the full path to the resource location.
+ * @param destFolder
+ * the full path to the destination location.
+ * @throws IOException
+ */
+ public static void copyResource(File src, File dest) throws IOException {
+ if (dest.exists() &&
+ src.lastModified() < dest.lastModified() &&
+ src.length() == dest.length())
+ {
+ return;
+ }
+
+ // read source bytes
+ byte[] srcBytes = null;
+ srcBytes = read(src);
+
+ if (shouldConvertToIndependentLineDelimiter(src)) {
+ String contents = new String(srcBytes);
+ contents = convertToIndependentLineDelimiter(contents);
+ srcBytes = contents.getBytes();
+ }
+ writeFile(dest, srcBytes);
+ }
+
+ public static void writeFile(File dest, byte[] srcBytes) throws IOException {
+
+ File destFolder = dest.getParentFile();
+ if (!destFolder.exists()) {
+ if (!destFolder.mkdirs()) {
+ throw new IOException("Unable to create directory " + destFolder);
+ }
+ }
+ // write bytes to dest
+ FileOutputStream out = null;
+ try {
+ out = new FileOutputStream(dest);
+ out.write(srcBytes);
+ out.flush();
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ /**
+ * Copy a resource that is located under the <code>resources</code> folder of the plugin to a
+ * corresponding location under the specified target folder. Convert line delimiters according
+ * to {@link #shouldConvertToIndependentLineDelimiter(File)}.
+ *
+ * @param resourcePath
+ * the relative path under <code>[plugin-root]/resources</code> of the resource to
+ * be copied
+ * @param targetFolder
+ * the absolute path of the folder under which the resource will be copied. Folder
+ * and subfolders will be created if necessary.
+ * @return a file representing the copied resource
+ * @throws IOException
+ */
+ public static File copyResource(String resourcePath, File targetFolder) throws IOException {
+ File resDir = new File(getPluginDirectoryPath(), RESOURCES_DIR);
+ File resourceFile = new File(resDir, resourcePath);
+ File targetFile = new File(targetFolder, resourcePath);
+ copyResource(resourceFile, targetFile);
+ return targetFile;
+ }
+
+ /**
+ * Copy all the files under the directory specified by src to the directory
+ * specified by dest. The src and dest directories must exist; child directories
+ * under dest will be created as required. Existing files in dest will be
+ * overwritten. Newlines will be converted according to
+ * {@link #shouldConvertToIndependentLineDelimiter(File)}. Directories
+ * named "CVS" will be ignored.
+ * @param resourceFolderName the name of the source folder, relative to
+ * <code>[plugin-root]/resources</code>
+ * @param the absolute path of the destination folder
+ * @throws IOException
+ */
+ public static void copyResources(String resourceFolderName, File destFolder) throws IOException {
+ File resDir = new File(getPluginDirectoryPath(), RESOURCES_DIR);
+ File resourceFolder = new File(resDir, resourceFolderName);
+ copyResources(resourceFolder, destFolder);
+ }
+
+ private static void copyResources(File resourceFolder, File destFolder) throws IOException {
+ if (resourceFolder == null) {
+ return;
+ }
+ // Copy all resources in this folder
+ String[] children = resourceFolder.list();
+ if (null == children) {
+ return;
+ }
+ // if there are any children, (recursively) copy them
+ for (String child : children) {
+ if ("CVS".equals(child)) {
+ continue;
+ }
+ File childRes = new File(resourceFolder, child);
+ File childDest = new File(destFolder, child);
+ if (childRes.isDirectory()) {
+ copyResources(childRes, childDest);
+ }
+ else {
+ copyResource(childRes, childDest);
+ }
+ }
+ }
+ protected static String getPluginDirectoryPath() {
+ try {
+ if (Platform.isRunning()) {
+ URL platformURL = Platform.getBundle("org.eclipse.jdt.compiler.tool.tests").getEntry("/");
+ return new File(FileLocator.toFileURL(platformURL).getFile()).getAbsolutePath();
+ }
+ return new File(System.getProperty("user.dir")).getAbsolutePath();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+ /**
+ * @return true if this file's end-of-line delimiters should be replaced with
+ * a platform-independent value, e.g. for compilation.
+ */
+ public static boolean shouldConvertToIndependentLineDelimiter(File file) {
+ return file.getName().endsWith(".java");
+ }
+ public static byte[] read(java.io.File file) throws java.io.IOException {
+ int fileLength;
+ byte[] fileBytes = new byte[fileLength = (int) file.length()];
+ java.io.FileInputStream stream = null;
+ try {
+ stream = new java.io.FileInputStream(file);
+ int bytesRead = 0;
+ int lastReadSize = 0;
+ while ((lastReadSize != -1) && (bytesRead != fileLength)) {
+ lastReadSize = stream.read(fileBytes, bytesRead, fileLength - bytesRead);
+ bytesRead += lastReadSize;
+ }
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ }
+ return fileBytes;
+ }
+
+ public static String convertToIndependentLineDelimiter(String source) {
+ if (source.indexOf('\n') == -1 && source.indexOf('\r') == -1) return source;
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0, length = source.length(); i < length; i++) {
+ char car = source.charAt(i);
+ if (car == '\r') {
+ buffer.append('\n');
+ if (i < length-1 && source.charAt(i+1) == '\n') {
+ i++; // skip \n after \r
+ }
+ } else {
+ buffer.append(car);
+ }
+ }
+ return buffer.toString();
+ }
+}
diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/ForwardingStandardJavaFileManager.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/ForwardingStandardJavaFileManager.java
index 7705be966b..cb5f676c7b 100644
--- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/ForwardingStandardJavaFileManager.java
+++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/ForwardingStandardJavaFileManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
+ * Copyright (c) 2008, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,10 @@ package org.eclipse.jdt.compiler.tool.tests;
import java.io.File;
import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Collection;
+
+import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
@@ -54,4 +58,34 @@ class ForwardingStandardJavaFileManager<T extends StandardJavaFileManager> exten
throws IOException {
this.fileManager.setLocation(location, path);
}
+
+ @Override
+ public Path asPath(FileObject arg0) {
+ return this.fileManager.asPath(arg0);
+ }
+
+ @Override
+ public Iterable<? extends JavaFileObject> getJavaFileObjects(Path... arg0) {
+ return this.fileManager.getJavaFileObjects(arg0);
+ }
+
+ @Override
+ public Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(Iterable<? extends Path> arg0) {
+ return this.fileManager.getJavaFileObjectsFromPaths(arg0);
+ }
+
+ @Override
+ public Iterable<? extends Path> getLocationAsPaths(Location arg0) {
+ return this.fileManager.getLocationAsPaths(arg0);
+ }
+
+ @Override
+ public void setLocationForModule(Location arg0, String arg1, Collection<? extends Path> arg2) throws IOException {
+ this.fileManager.setLocationForModule(arg0, arg1, arg2);
+ }
+
+ @Override
+ public void setLocationFromPaths(Location arg0, Collection<? extends Path> arg1) throws IOException {
+ this.fileManager.setLocationFromPaths(arg0, arg1);
+ }
}

Back to the top