|
1 |
| -file_formats_java_class |
2 |
| -======================= |
3 |
| - |
4 |
| -`file_formats_java_class` provides the facilities for reading CLASS files defined |
5 |
| -in the [Java Virtual Machine Specification](https://docs.oracle.com/javase/specs/), |
6 |
| -[Java SE 7, CLASS major file version 51](https://docs.oracle.com/javase/specs/jvms/se7/html/index.html), |
7 |
| -[chapter 4](https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html). |
8 |
| - |
9 |
| -This library is not constrained by any compiler, but does depend on the *2022 |
10 |
| -specification of Ada*. |
11 |
| - |
12 |
| -Supported Elements (Java SE 7) |
13 |
| ------------------------------- |
14 |
| - |
15 |
| -- Class Access Flags (Table 4.1) |
16 |
| - - `ACC_PUBLIC` |
17 |
| - - `ACC_FINAL` |
18 |
| - - `ACC_SUPER` |
19 |
| - - `ACC_INTERFACE` |
20 |
| - - `ACC_ABSTRACT` |
21 |
| - - `ACC_SYNTHETIC` |
22 |
| - - `ACC_ANNOTATION` |
23 |
| - - `ACC_ENUM` |
24 |
| -- Constant Pool (Table 4.3) |
25 |
| - - `CONSTANT_Class_info` |
26 |
| - - `CONSTANT_Fieldref_info` |
27 |
| - - `CONSTANT_Methodref_info` |
28 |
| - - `CONSTANT_InterfaceMethodref_info` |
29 |
| - - `CONSTANT_String_info` |
30 |
| - - `CONSTANT_Integer_info` |
31 |
| - - `CONSTANT_Float_info` |
32 |
| - - `CONSTANT_Long_info` |
33 |
| - - `CONSTANT_Double_info` |
34 |
| - - `CONSTANT_NameAndType_info` |
35 |
| - - `CONSTANT_Utf8_info` |
36 |
| - - `CONSTANT_MethodHandle_info` |
37 |
| - - `CONSTANT_MethodType_info` |
38 |
| - - `CONSTANT_InvokeDynamic_info` |
39 |
| -- Field Access Flags (Table 4.4) |
40 |
| - - `ACC_PUBLIC` |
41 |
| - - `ACC_PRIVATE` |
42 |
| - - `ACC_PROTECTED` |
43 |
| - - `ACC_STATIC` |
44 |
| - - `ACC_FINAL` |
45 |
| - - `ACC_VOLATILE` |
46 |
| - - `ACC_TRANSIENT` |
47 |
| - - `ACC_SYNTHETIC` |
48 |
| - - `ACC_ENUM` |
49 |
| -- Method Access Flags (Table 4.5) |
50 |
| - - `ACC_PUBLIC` |
51 |
| - - `ACC_PRIVATE` |
52 |
| - - `ACC_PROTECTED` |
53 |
| - - `ACC_STATIC` |
54 |
| - - `ACC_FINAL` |
55 |
| - - `ACC_SYNCHRONIZED` |
56 |
| - - `ACC_BRIDGE` |
57 |
| - - `ACC_VARARGS` |
58 |
| - - `ACC_NATIVE` |
59 |
| - - `ACC_ABSTRACT` |
60 |
| - - `ACC_STRICT` |
61 |
| - - `ACC_SYNTHETIC` |
62 |
| -- Attributes (Table 4.6) |
63 |
| - - `ConstantValue` |
64 |
| - - `Code` |
65 |
| - - `StackMapTable` |
66 |
| - - `Exceptions` |
67 |
| - - `InnerClasses` |
68 |
| - - `EnclosingMethod` |
69 |
| - - `Synthetic` |
70 |
| - - `Signature` |
71 |
| - - `SourceFile` |
72 |
| - - `SourceDebugExtension` |
73 |
| - - `LineNumberTable` |
74 |
| - - `LocalVariableTable` |
75 |
| - - `LocalVariableTypeTable` |
76 |
| - - `Deprecated` |
77 |
| - - `RuntimeVisibleAnnotations` |
78 |
| - - `RuntimeInvisibleAnnotations` |
79 |
| - - `RuntimeVisibleParameterAnnotations` |
80 |
| - - `RuntimeInvisibleParameterAnnotations` |
81 |
| - - `AnnotationDefault` |
82 |
| - - `BootstrapMethods` |
83 |
| - - `Other` - Used for unrecognized/private attributes |
84 |
| - - **NOTE:** All restrictions put in place of each attribute for determining the validity of a CLASS file may not be fully implemented at the current time. |
85 |
| - |
86 |
| -Example Use |
87 |
| ------------ |
88 |
| - |
89 |
| -All pertinent types and subprograms are available within the package |
90 |
| -`File_Formats_Java_Class`. Reading `Class_File` is done primarily through the `Input` aspect, |
91 |
| -as shown below. |
92 |
| - |
93 |
| -```ada |
94 |
| -with Ada.Text_IO; |
95 |
| -
|
96 |
| -with File_Formats_Java_Class; |
97 |
| -use File_Formats_Java_Class; |
98 |
| -
|
99 |
| -procedure Read_Class_File is |
100 |
| - F : File_Type; |
101 |
| - S : Stream_Access; |
102 |
| -begin |
103 |
| - Open (F, In_File, "Example.class"); |
104 |
| - S := Stream (F); |
105 |
| - Ada.Text_IO.Put_Line (Class_File'Input (S)); |
106 |
| - Close (F); |
107 |
| -end Read_Class_File; |
108 |
| -``` |
109 |
| - |
110 |
| -Development Status |
111 |
| ------------------- |
112 |
| - |
113 |
| -This crate does not yet define operations for writing to CLASS files, but this is a priority. |
114 |
| -After writing is complete, this crate will be updated to support CLASS files of Java SE 8+. |
115 |
| -You are free to report issues and contribue to this repository. |
| 1 | +file_formats_java_class |
| 2 | +======================= |
| 3 | + |
| 4 | +`file_formats_java_class` provides the facilities for reading CLASS files defined |
| 5 | +in the [Java Virtual Machine Specification](https://docs.oracle.com/javase/specs/), |
| 6 | +[Java SE 7, CLASS major file version 51](https://docs.oracle.com/javase/specs/jvms/se7/html/index.html), |
| 7 | +[chapter 4](https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html). |
| 8 | + |
| 9 | +This library is not constrained by any compiler, but does depend on the *2022 |
| 10 | +specification of Ada*. |
| 11 | + |
| 12 | +Supported Elements (Java SE 7) |
| 13 | +------------------------------ |
| 14 | + |
| 15 | +- Class Access Flags (Table 4.1) |
| 16 | + - `ACC_PUBLIC` |
| 17 | + - `ACC_FINAL` |
| 18 | + - `ACC_SUPER` |
| 19 | + - `ACC_INTERFACE` |
| 20 | + - `ACC_ABSTRACT` |
| 21 | + - `ACC_SYNTHETIC` |
| 22 | + - `ACC_ANNOTATION` |
| 23 | + - `ACC_ENUM` |
| 24 | +- Constant Pool (Table 4.3) |
| 25 | + - `CONSTANT_Class_info` |
| 26 | + - `CONSTANT_Fieldref_info` |
| 27 | + - `CONSTANT_Methodref_info` |
| 28 | + - `CONSTANT_InterfaceMethodref_info` |
| 29 | + - `CONSTANT_String_info` |
| 30 | + - `CONSTANT_Integer_info` |
| 31 | + - `CONSTANT_Float_info` |
| 32 | + - `CONSTANT_Long_info` |
| 33 | + - `CONSTANT_Double_info` |
| 34 | + - `CONSTANT_NameAndType_info` |
| 35 | + - `CONSTANT_Utf8_info` |
| 36 | + - `CONSTANT_MethodHandle_info` |
| 37 | + - `CONSTANT_MethodType_info` |
| 38 | + - `CONSTANT_InvokeDynamic_info` |
| 39 | +- Field Access Flags (Table 4.4) |
| 40 | + - `ACC_PUBLIC` |
| 41 | + - `ACC_PRIVATE` |
| 42 | + - `ACC_PROTECTED` |
| 43 | + - `ACC_STATIC` |
| 44 | + - `ACC_FINAL` |
| 45 | + - `ACC_VOLATILE` |
| 46 | + - `ACC_TRANSIENT` |
| 47 | + - `ACC_SYNTHETIC` |
| 48 | + - `ACC_ENUM` |
| 49 | +- Method Access Flags (Table 4.5) |
| 50 | + - `ACC_PUBLIC` |
| 51 | + - `ACC_PRIVATE` |
| 52 | + - `ACC_PROTECTED` |
| 53 | + - `ACC_STATIC` |
| 54 | + - `ACC_FINAL` |
| 55 | + - `ACC_SYNCHRONIZED` |
| 56 | + - `ACC_BRIDGE` |
| 57 | + - `ACC_VARARGS` |
| 58 | + - `ACC_NATIVE` |
| 59 | + - `ACC_ABSTRACT` |
| 60 | + - `ACC_STRICT` |
| 61 | + - `ACC_SYNTHETIC` |
| 62 | +- Attributes (Table 4.6) |
| 63 | + - `ConstantValue` |
| 64 | + - `Code` |
| 65 | + - `StackMapTable` |
| 66 | + - `Exceptions` |
| 67 | + - `InnerClasses` |
| 68 | + - `EnclosingMethod` |
| 69 | + - `Synthetic` |
| 70 | + - `Signature` |
| 71 | + - `SourceFile` |
| 72 | + - `SourceDebugExtension` |
| 73 | + - `LineNumberTable` |
| 74 | + - `LocalVariableTable` |
| 75 | + - `LocalVariableTypeTable` |
| 76 | + - `Deprecated` |
| 77 | + - `RuntimeVisibleAnnotations` |
| 78 | + - `RuntimeInvisibleAnnotations` |
| 79 | + - `RuntimeVisibleParameterAnnotations` |
| 80 | + - `RuntimeInvisibleParameterAnnotations` |
| 81 | + - `AnnotationDefault` |
| 82 | + - `BootstrapMethods` |
| 83 | + - `Other` - Used for unrecognized/private attributes |
| 84 | + - **NOTE:** All restrictions put in place of each attribute for determining the validity of a CLASS file may not be fully implemented at the current time. |
| 85 | + |
| 86 | +Example Use |
| 87 | +----------- |
| 88 | + |
| 89 | +All pertinent types and subprograms are available within the package |
| 90 | +`File_Formats_Java_Class`. Reading `Class_File` is done primarily through the `Input` aspect, |
| 91 | +as shown below. |
| 92 | + |
| 93 | +```ada |
| 94 | +with Ada.Text_IO; |
| 95 | +
|
| 96 | +with File_Formats_Java_Class; |
| 97 | +use File_Formats_Java_Class; |
| 98 | +
|
| 99 | +procedure Read_Class_File is |
| 100 | + F : File_Type; |
| 101 | + S : Stream_Access; |
| 102 | +begin |
| 103 | + Open (F, In_File, "Example.class"); |
| 104 | + S := Stream (F); |
| 105 | + Ada.Text_IO.Put_Line (Class_File'Input (S)); |
| 106 | + Close (F); |
| 107 | +end Read_Class_File; |
| 108 | +``` |
| 109 | + |
| 110 | +Development Status |
| 111 | +------------------ |
| 112 | + |
| 113 | +This crate does not yet define operations for writing to CLASS files, but this is a priority. |
| 114 | +After writing is complete, this crate will be updated to support CLASS files of Java SE 8+. |
| 115 | +You are free to report issues and contribue to this repository. |
0 commit comments