8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
Reviewed-by: jjg
This commit is contained in:
parent
94991de3c3
commit
9e35962ebf
@ -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,26 +44,24 @@ 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(Path input, Attribute.Factory attributeFactory)
|
||||||
|
throws IOException, ConstantPoolException {
|
||||||
|
try (InputStream in = Files.newInputStream(input)) {
|
||||||
|
return new ClassFile(in, attributeFactory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClassFile read(File file, Attribute.Factory attributeFactory)
|
public static ClassFile read(File file, Attribute.Factory attributeFactory)
|
||||||
throws IOException, ConstantPoolException {
|
throws IOException, ConstantPoolException {
|
||||||
FileInputStream in = new FileInputStream(file);
|
return read(file.toPath(), attributeFactory);
|
||||||
try {
|
|
||||||
return new ClassFile(in, attributeFactory);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
in.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClassFile read(InputStream in)
|
public static ClassFile read(InputStream in)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user