equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
27 |
27 |
28 import java.io.File; |
28 import java.io.File; |
29 import java.io.FileInputStream; |
29 import java.io.FileInputStream; |
30 import java.io.IOException; |
30 import java.io.IOException; |
31 import java.io.InputStream; |
31 import java.io.InputStream; |
|
32 import java.nio.file.Path; |
32 |
33 |
33 import static com.sun.tools.classfile.AccessFlags.*; |
34 import static com.sun.tools.classfile.AccessFlags.*; |
34 |
35 |
35 /** |
36 /** |
36 * See JVMS, section 4.2. |
37 * See JVMS, section 4.2. |
42 */ |
43 */ |
43 public class ClassFile { |
44 public class ClassFile { |
44 public static ClassFile read(File file) |
45 public static ClassFile read(File file) |
45 throws IOException, ConstantPoolException { |
46 throws IOException, ConstantPoolException { |
46 return read(file, new Attribute.Factory()); |
47 return read(file, new Attribute.Factory()); |
|
48 } |
|
49 |
|
50 public static ClassFile read(Path path) |
|
51 throws IOException, ConstantPoolException { |
|
52 return read(path.toFile(), new Attribute.Factory()); |
47 } |
53 } |
48 |
54 |
49 public static ClassFile read(File file, Attribute.Factory attributeFactory) |
55 public static ClassFile read(File file, Attribute.Factory attributeFactory) |
50 throws IOException, ConstantPoolException { |
56 throws IOException, ConstantPoolException { |
51 FileInputStream in = new FileInputStream(file); |
57 FileInputStream in = new FileInputStream(file); |