8139474: -release 7 -verbose causes Javac exception
authorvromero
Mon, 07 Mar 2016 13:45:38 -0500
changeset 36492 12abe038f3d9
parent 36280 c870cb782aca
child 36493 1e87cd35c980
8139474: -release 7 -verbose causes Javac exception Reviewed-by: jjg
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Wed Jul 05 21:25:35 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java	Mon Mar 07 13:45:38 2016 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
 package com.sun.tools.javac.code;
 
 import java.io.IOException;
-import java.io.File;
+import java.nio.file.Path;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
@@ -45,7 +45,6 @@
 import com.sun.tools.javac.code.Symbol.PackageSymbol;
 import com.sun.tools.javac.code.Symbol.TypeSymbol;
 import com.sun.tools.javac.comp.Annotate;
-import com.sun.tools.javac.comp.Enter;
 import com.sun.tools.javac.file.JRTIndex;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.ClassReader;
@@ -535,25 +534,25 @@
             if (fileManager instanceof StandardJavaFileManager) {
                 StandardJavaFileManager fm = (StandardJavaFileManager)fileManager;
                 if (haveSourcePath && wantSourceFiles) {
-                    List<File> path = List.nil();
-                    for (File file : fm.getLocation(SOURCE_PATH)) {
-                        path = path.prepend(file);
+                    List<Path> path = List.nil();
+                    for (Path sourcePath : fm.getLocationAsPaths(SOURCE_PATH)) {
+                        path = path.prepend(sourcePath);
                     }
                     log.printVerbose("sourcepath", path.reverse().toString());
                 } else if (wantSourceFiles) {
-                    List<File> path = List.nil();
-                    for (File file : fm.getLocation(CLASS_PATH)) {
-                        path = path.prepend(file);
+                    List<Path> path = List.nil();
+                    for (Path classPath : fm.getLocationAsPaths(CLASS_PATH)) {
+                        path = path.prepend(classPath);
                     }
                     log.printVerbose("sourcepath", path.reverse().toString());
                 }
                 if (wantClassFiles) {
-                    List<File> path = List.nil();
-                    for (File file : fm.getLocation(PLATFORM_CLASS_PATH)) {
-                        path = path.prepend(file);
+                    List<Path> path = List.nil();
+                    for (Path platformPath : fm.getLocationAsPaths(PLATFORM_CLASS_PATH)) {
+                        path = path.prepend(platformPath);
                     }
-                    for (File file : fm.getLocation(CLASS_PATH)) {
-                        path = path.prepend(file);
+                    for (Path classPath : fm.getLocationAsPaths(CLASS_PATH)) {
+                        path = path.prepend(classPath);
                     }
                     log.printVerbose("classpath",  path.reverse().toString());
                 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java	Wed Jul 05 21:25:35 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java	Mon Mar 07 13:45:38 2016 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 
 package com.sun.tools.javac.file;
 
-import java.io.File;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
 import java.nio.file.InvalidPathException;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jul 05 21:25:35 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Mon Mar 07 13:45:38 2016 -0500
@@ -31,6 +31,7 @@
 import java.io.StringWriter;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.file.Path;
 import java.util.*;
 import java.util.regex.*;
 import java.util.stream.Collectors;
@@ -42,6 +43,7 @@
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.StandardJavaFileManager;
+
 import static javax.tools.StandardLocation.*;
 
 import com.sun.source.util.TaskEvent;
@@ -79,6 +81,7 @@
 import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Options;
 import com.sun.tools.javac.util.ServiceLoader;
+
 import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
 import static com.sun.tools.javac.main.Option.*;
@@ -317,9 +320,9 @@
 
         if (fileManager instanceof JavacFileManager) {
             StandardJavaFileManager standardFileManager = (JavacFileManager) fileManager;
-            Iterable<? extends File> workingPath = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
-                ? standardFileManager.getLocation(ANNOTATION_PROCESSOR_PATH)
-                : standardFileManager.getLocation(CLASS_PATH);
+            Iterable<? extends Path> workingPath = fileManager.hasLocation(ANNOTATION_PROCESSOR_PATH)
+                ? standardFileManager.getLocationAsPaths(ANNOTATION_PROCESSOR_PATH)
+                : standardFileManager.getLocationAsPaths(CLASS_PATH);
 
             if (needClassLoader(options.get(PROCESSOR), workingPath) )
                 handleException(key, e);
@@ -1298,14 +1301,14 @@
      * Called retroactively to determine if a class loader was required,
      * after we have failed to create one.
      */
-    private boolean needClassLoader(String procNames, Iterable<? extends File> workingpath) {
+    private boolean needClassLoader(String procNames, Iterable<? extends Path> workingpath) {
         if (procNames != null)
             return true;
 
         URL[] urls = new URL[1];
-        for(File pathElement : workingpath) {
+        for(Path pathElement : workingpath) {
             try {
-                urls[0] = pathElement.toURI().toURL();
+                urls[0] = pathElement.toUri().toURL();
                 if (ServiceProxy.hasService(Processor.class, urls))
                     return true;
             } catch (MalformedURLException ex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8139474/DashRelease7DashVerboseTest.java	Mon Mar 07 13:45:38 2016 -0500
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * bug 8139474
+ * @summary -release 7 -verbose causes Javac exception
+ * @compile -release 7 -verbose DashRelease7DashVerboseTest.java
+*/
+
+public class DashRelease7DashVerboseTest {}