6714364: refactor javac File handling code into new javac.file package

Reviewed-by: mcimadamore
This commit is contained in:
Jonathan Gibbons 2008-06-16 13:28:00 -07:00
parent 94e7336593
commit c8fdd80cc2
30 changed files with 106 additions and 98 deletions

View File

@ -26,20 +26,14 @@
package com.sun.tools.apt.main;
import java.io.*;
import java.nio.CharBuffer;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.parser.*;
import com.sun.tools.javac.comp.*;
import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.code.Symbol.*;

View File

@ -44,7 +44,7 @@ import java.net.URL;
import java.io.File;
import java.net.MalformedURLException;
import com.sun.tools.javac.util.Paths;
import com.sun.tools.javac.file.Paths;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Type;

View File

@ -36,12 +36,12 @@ import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
import javax.tools.*;
import com.sun.source.tree.Tree;
import com.sun.source.tree.*;
import com.sun.source.util.*;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.comp.*;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.*;
import com.sun.tools.javac.model.*;
import com.sun.tools.javac.parser.Parser;

View File

@ -31,7 +31,6 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Iterator;
@ -42,13 +41,13 @@ import javax.lang.model.SourceVersion;
import javax.tools.*;
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.JavacOption.OptionKind;
import com.sun.tools.javac.main.JavacOption;
import com.sun.tools.javac.main.Main;
import com.sun.tools.javac.main.RecognizedOptions.GrumpyHelper;
import com.sun.tools.javac.main.RecognizedOptions;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.JavacFileManager;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Options;
import com.sun.tools.javac.util.Pair;

View File

@ -23,7 +23,7 @@
* have any questions.
*/
package com.sun.tools.javac.util;
package com.sun.tools.javac.file;
import java.io.IOException;
import java.io.InputStreamReader;

View File

@ -23,11 +23,9 @@
* have any questions.
*/
package com.sun.tools.javac.util;
package com.sun.tools.javac.file;
import com.sun.tools.javac.main.JavacOption;
import com.sun.tools.javac.main.OptionName;
import com.sun.tools.javac.main.RecognizedOptions;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
@ -63,6 +61,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@ -70,14 +69,18 @@ import javax.lang.model.SourceVersion;
import javax.tools.FileObject;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
import java.util.concurrent.ConcurrentHashMap;
import javax.tools.StandardJavaFileManager;
import com.sun.tools.javac.zip.*;
import java.io.ByteArrayInputStream;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.main.JavacOption;
import com.sun.tools.javac.main.OptionName;
import com.sun.tools.javac.main.RecognizedOptions;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Options;
import static com.sun.tools.javac.main.OptionName.*;
import static javax.tools.StandardLocation.*;
@ -1225,7 +1228,7 @@ public class JavacFileManager implements StandardJavaFileManager {
}
@SuppressWarnings("deprecation") // bug 6410637
protected static String getJavacFileName(FileObject file) {
public static String getJavacFileName(FileObject file) {
if (file instanceof BaseFileObject)
return ((BaseFileObject)file).getPath();
URI uri = file.toUri();
@ -1237,7 +1240,7 @@ public class JavacFileManager implements StandardJavaFileManager {
}
@SuppressWarnings("deprecation") // bug 6410637
protected static String getJavacBaseFileName(FileObject file) {
public static String getJavacBaseFileName(FileObject file) {
if (file instanceof BaseFileObject)
return ((BaseFileObject)file).getName();
URI uri = file.toUri();

View File

@ -23,15 +23,9 @@
* have any questions.
*/
package com.sun.tools.javac.util;
package com.sun.tools.javac.file;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.tools.*;
import static javax.tools.StandardLocation.SOURCE_PATH;
import javax.tools.FileObject;
/**
* Provides an easy migration to JSR 199 v3.3. The class is

View File

@ -23,7 +23,8 @@
* have any questions.
*/
package com.sun.tools.javac.util;
package com.sun.tools.javac.file;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
@ -39,15 +40,19 @@ import java.util.LinkedHashSet;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.zip.ZipFile;
import com.sun.tools.javac.code.Lint;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.tools.JavaFileManager.Location;
import static com.sun.tools.javac.main.OptionName.*;
import com.sun.tools.javac.code.Lint;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Options;
import static javax.tools.StandardLocation.*;
import static com.sun.tools.javac.main.OptionName.*;
/** This class converts command line arguments, environment variables
* and system properties (in File.pathSeparator-separated String form)

View File

@ -23,14 +23,26 @@
* have any questions.
*/
package com.sun.tools.javac.zip;
package com.sun.tools.javac.file;
import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.text.MessageFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
import java.util.zip.*;
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;
import java.util.zip.ZipException;
/** This class implements building of index of a zip archive and access to it's context.
* It also uses prebuild index if available. It supports invocations where it will

View File

@ -23,7 +23,7 @@
* have any questions.
*/
package com.sun.tools.javac.zip;
package com.sun.tools.javac.file;
import java.io.File;

View File

@ -42,6 +42,7 @@ import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.file.BaseFileObject;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.util.List;

View File

@ -40,6 +40,7 @@ import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.DiagnosticListener;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;

View File

@ -25,13 +25,13 @@
package com.sun.tools.javac.main;
import com.sun.tools.javac.util.Options;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.MissingResourceException;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.main.JavacOption.Option;
import com.sun.tools.javac.main.RecognizedOptions.OptionHelper;

View File

@ -25,16 +25,12 @@
package com.sun.tools.javac.parser;
import java.io.*;
import java.nio.*;
import java.nio.ByteBuffer;
import java.nio.charset.*;
import java.nio.channels.*;
import java.util.regex.*;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.*;
import static com.sun.tools.javac.parser.Token.*;
import static com.sun.tools.javac.util.LayoutCharacters.*;

View File

@ -25,22 +25,17 @@
package com.sun.tools.javac.processing;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.comp.*;
import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.parser.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.model.JavacElements;
import com.sun.tools.javac.model.JavacTypes;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.main.JavaCompiler;
import java.lang.reflect.*;
import java.util.*;
import java.util.regex.*;
import java.net.URL;
import java.io.Closeable;
import java.io.File;
import java.io.PrintWriter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.io.StringWriter;
import javax.annotation.processing.*;
@ -50,25 +45,35 @@ import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.PackageElement;
import javax.lang.model.util.*;
import javax.tools.JavaFileManager;
import javax.tools.StandardJavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.DiagnosticListener;
import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.file.Paths;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.jvm.*;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.model.JavacElements;
import com.sun.tools.javac.model.JavacTypes;
import com.sun.tools.javac.parser.*;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.util.Abort;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.Name;
import com.sun.tools.javac.util.Options;
import static javax.tools.StandardLocation.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.regex.*;
import java.net.URLClassLoader;
import java.net.URL;
import java.io.Closeable;
import java.io.File;
import java.io.PrintWriter;
import java.io.IOException;
import java.net.MalformedURLException;
/**
* Objects of this class hold and manage the state needed to support
* annotation processing.

View File

@ -27,6 +27,7 @@ package com.sun.tools.javac.util;
import javax.tools.JavaFileObject;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticSource;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;

View File

@ -25,17 +25,13 @@
package com.sun.tools.javac.util;
import java.net.URI;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.tools.Diagnostic;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.tree.JCTree;
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;

View File

@ -33,11 +33,14 @@ import java.util.Map;
import java.util.Set;
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
import com.sun.tools.javac.util.JCDiagnostic.SimpleDiagnosticPosition;
import static com.sun.tools.javac.util.LayoutCharacters.*;
/** A class for error logs. Reports errors and warnings, and

View File

@ -26,10 +26,10 @@
package com.sun.tools.javadoc;
import com.sun.tools.javac.code.Symbol.PackageSymbol;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.file.Old199;
import com.sun.tools.javac.jvm.ClassReader;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.JavacFileManager;
import com.sun.tools.javac.util.Old199;
import java.io.File;
import java.util.EnumSet;

View File

@ -29,19 +29,14 @@ import java.io.*;
import java.util.Collection;
import com.sun.tools.javac.code.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.comp.*;
import com.sun.tools.javac.jvm.ClassReader;
import com.sun.tools.javac.jvm.ClassWriter;
import com.sun.tools.javac.file.Paths;
import com.sun.tools.javac.parser.DocCommentScanner;
import com.sun.tools.javac.util.Paths;
import com.sun.tools.javac.tree.*;
import com.sun.tools.javac.tree.JCTree.*;
import com.sun.tools.javac.util.*;
import com.sun.javadoc.LanguageVersion;
import static com.sun.javadoc.LanguageVersion.*;
/**
* This class could be the main entry point for Javadoc when Javadoc is used as a
@ -147,7 +142,7 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler {
} else if (isValidPackageName(name)) {
names = names.append(name);
} else if (name.endsWith(".java")) {
docenv.error(null, "main.file_not_found", name);;
docenv.error(null, "main.file_not_found", name);
} else {
docenv.error(null, "main.illegal_package_name", name);
}

View File

@ -32,9 +32,9 @@ import javax.tools.Diagnostic;
import javax.tools.DiagnosticListener;
import javax.tools.JavaFileObject;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.JCDiagnostic;
import com.sun.tools.javac.util.JavacFileManager;
/**
* javap's implementation of JavaFileManager.

View File

@ -32,12 +32,12 @@ import java.io.OutputStream;
import java.net.URI;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.parser.Parser;
import com.sun.tools.javac.parser.Scanner;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeScanner;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.JavacFileManager;
import com.sun.tools.javac.util.Log;
import com.sun.tools.javac.util.JCDiagnostic;
import com.sun.tools.javac.util.Options;

View File

@ -4,8 +4,8 @@
* @summary 6589361:Failing building ct.sym file as part of the control build
*/
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.JavacFileManager;
import java.io.File;
import javax.tools.FileObject;
import javax.tools.JavaFileObject;

View File

@ -35,6 +35,7 @@ import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.source.util.*;
import com.sun.tools.javac.api.*;
import com.sun.tools.javac.file.*;
import com.sun.tools.javac.main.*;
import com.sun.tools.javac.util.*;

View File

@ -32,6 +32,7 @@ import java.util.*;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.tools.javac.file.*;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.main.*;
import com.sun.tools.javac.util.*;

View File

@ -33,6 +33,7 @@ import java.util.*;
import javax.annotation.processing.*;
import javax.lang.model.element.*;
import javax.tools.*;
import com.sun.tools.javac.file.*;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.main.*;
import com.sun.tools.javac.util.*;

View File

@ -30,7 +30,7 @@
import java.io.*;
import java.util.*;
import javax.tools.*;
import com.sun.tools.javac.util.*;
import com.sun.tools.javac.file.*;
public class T6705935 {
public static void main(String... args) throws Exception {

View File

@ -30,7 +30,7 @@
*/
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.util.JavacFileManager;
import com.sun.tools.javac.file.JavacFileManager;
import java.util.Arrays;
import javax.lang.model.util.Elements;

View File

@ -30,8 +30,8 @@
*/
import com.sun.tools.javac.api.JavacTaskImpl;
import com.sun.tools.javac.file.JavacFileManager;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.util.JavacFileManager;
import java.io.File;
import java.io.IOException;
import javax.lang.model.element.TypeElement;

View File

@ -29,7 +29,7 @@
* @author Peter von der Ah\u00e9
*/
import com.sun.tools.javac.util.JavacFileManager;
import com.sun.tools.javac.file.JavacFileManager;
public class TestName {
public static void main(String... args) {