Class file with info taken from a byte[] or slice thereof.
| 43 | * Class file with info taken from a {@code byte[]} or slice thereof. |
| 44 | */ |
| 45 | public class DirectClassFile implements ClassFile { |
| 46 | /** the expected value of the ClassFile.magic field */ |
| 47 | private static final int CLASS_FILE_MAGIC = 0xcafebabe; |
| 48 | |
| 49 | /** |
| 50 | * minimum {@code .class} file major version |
| 51 | * |
| 52 | * See http://en.wikipedia.org/wiki/Java_class_file for an up-to-date |
| 53 | * list of version numbers. Currently known (taken from that table) are: |
| 54 | * |
| 55 | * Java SE 9 = 53 (0x35 hex), |
| 56 | * Java SE 8 = 52 (0x34 hex), |
| 57 | * Java SE 7 = 51 (0x33 hex), |
| 58 | * Java SE 6.0 = 50 (0x32 hex), |
| 59 | * Java SE 5.0 = 49 (0x31 hex), |
| 60 | * JDK 1.4 = 48 (0x30 hex), |
| 61 | * JDK 1.3 = 47 (0x2F hex), |
| 62 | * JDK 1.2 = 46 (0x2E hex), |
| 63 | * JDK 1.1 = 45 (0x2D hex). |
| 64 | * |
| 65 | * Valid ranges are typically of the form |
| 66 | * "A.0 through B.C inclusive" where A <= B and C >= 0, |
| 67 | * which is why we don't have a CLASS_FILE_MIN_MINOR_VERSION. |
| 68 | */ |
| 69 | private static final int CLASS_FILE_MIN_MAJOR_VERSION = 45; |
| 70 | |
| 71 | /** |
| 72 | * maximum {@code .class} file major version |
| 73 | * |
| 74 | * Note: if you change this, please change "java.class.version" in System.java. |
| 75 | */ |
| 76 | private static final int CLASS_FILE_MAX_MAJOR_VERSION = 53; |
| 77 | |
| 78 | /** maximum {@code .class} file minor version */ |
| 79 | private static final int CLASS_FILE_MAX_MINOR_VERSION = 0; |
| 80 | |
| 81 | /** |
| 82 | * {@code non-null;} the file path for the class, excluding any base directory |
| 83 | * specification |
| 84 | */ |
| 85 | private final String filePath; |
| 86 | |
| 87 | /** {@code non-null;} the bytes of the file */ |
| 88 | private final ByteArray bytes; |
| 89 | |
| 90 | /** |
| 91 | * whether to be strict about parsing; if |
| 92 | * {@code false}, this avoids doing checks that only exist |
| 93 | * for purposes of verification (such as magic number matching and |
| 94 | * path-package consistency checking) |
| 95 | */ |
| 96 | private final boolean strictParse; |
| 97 | |
| 98 | /** |
| 99 | * {@code null-ok;} the constant pool; only ever {@code null} |
| 100 | * before the constant pool is successfully parsed |
| 101 | */ |
| 102 | private StdConstantPool pool; |
nothing calls this directly
no outgoing calls
no test coverage detected