提交 a906d5f6 编写于 作者: V vromero

8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)

Reviewed-by: jjg
上级 70d997f4
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
package com.sun.tools.classfile; package com.sun.tools.classfile;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import static com.sun.tools.classfile.AccessFlags.*; import static com.sun.tools.classfile.AccessFlags.*;
...@@ -44,28 +44,26 @@ import static com.sun.tools.classfile.AccessFlags.*; ...@@ -44,28 +44,26 @@ import static com.sun.tools.classfile.AccessFlags.*;
public class ClassFile { public class ClassFile {
public static ClassFile read(File file) public static ClassFile read(File file)
throws IOException, ConstantPoolException { throws IOException, ConstantPoolException {
return read(file, new Attribute.Factory()); return read(file.toPath(), new Attribute.Factory());
} }
public static ClassFile read(Path path) public static ClassFile read(Path input)
throws IOException, ConstantPoolException { throws IOException, ConstantPoolException {
return read(path.toFile(), new Attribute.Factory()); return read(input, new Attribute.Factory());
} }
public static ClassFile read(File file, Attribute.Factory attributeFactory) public static ClassFile read(Path input, Attribute.Factory attributeFactory)
throws IOException, ConstantPoolException { throws IOException, ConstantPoolException {
FileInputStream in = new FileInputStream(file); try (InputStream in = Files.newInputStream(input)) {
try {
return new ClassFile(in, attributeFactory); return new ClassFile(in, attributeFactory);
} finally {
try {
in.close();
} catch (IOException e) {
// ignore
}
} }
} }
public static ClassFile read(File file, Attribute.Factory attributeFactory)
throws IOException, ConstantPoolException {
return read(file.toPath(), attributeFactory);
}
public static ClassFile read(InputStream in) public static ClassFile read(InputStream in)
throws IOException, ConstantPoolException { throws IOException, ConstantPoolException {
return new ClassFile(in, new Attribute.Factory()); return new ClassFile(in, new Attribute.Factory());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册