[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/DKorablin/ByteCodeReader/master/ByteCodeReader/Jvm.cs [Back]  [Original]

using System;
using System.Runtime.InteropServices;

namespace AlphaOmega.Debug
{
	/// Java Virtual Machine native structures
	/// https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html
	public struct Jvm
	{
		/// 
		/// Each class file contains the definition of a single class or interface.
		/// Although a class or interface need not have an external representation literally contained in a file (for instance, because the class is generated by a class loader), we will colloquially refer to any valid representation of a class or interface as being in the class file format.
		/// 
		[StructLayout(LayoutKind.Sequential, Pack = 1)]
		public struct ClassFile1
		{
			/// The magic item supplies the magic number identifying the class file format; it has the value 0xCAFEBABE
			public UInt32 magic;

			/// Minor class file version
			public UInt16 minor_version;

			/// Major class file version
			public UInt16 major_version;

			/// 
			/// The value of the  item is equal to the number of entries in the  table plus one.
			/// A  index is considered valid if it is greater than zero and less than , with the exception for constants of type long and double noted in 4.4.5.
			/// 
			public UInt16 constant_pool_count;

			/// Class files is valid
			public Boolean IsValid => this.magic == 0xCAFEBABE;

			/// 
			/// The values of the minor_version and major_version items are the minor and major version numbers of this class file.
			/// Together, a major and a minor version number determine the version of the class file format.
			/// If a class file has major version number M and minor version number m, we denote the version of its class file format as M.m.
			/// Thus, class file format versions may be ordered lexicographically, for example, 1.5 < 2.0 < 2.1.
			/// 
			/// 
			/// A Java Virtual Machine implementation can support a class file format of version v if and only if v lies in some contiguous range Mi.0  v  Mj.m.
			/// The release level of the Java SE platform to which a Java Virtual Machine implementation conforms is responsible for determining the range.
			/// 
			public Version Version => new Version(this.major_version, this.minor_version);
		}

		/// Each class file contains the definition of a single class or interface
		/// Although a class or interface need not have an external representation literally contained in a file (for instance, because the class is generated by a class loader), we will colloquially refer to any valid representation of a class or interface as being in the class file format
		[StructLayout(LayoutKind.Sequential, Pack = 1)]
		public struct ClassFile2
		{
			/// The value of the access_flags item is a mask of flags used to denote access permissions to and properties of this class or interface
			[Flags]
			public enum ACC : UInt16
			{
				/// Declared public; may be accessed from outside its package
				PUBLIC = 0x0001,
				/// Declared final; no subclasses allowed
				FINAL = 0x0010,
				/// Treat superclass methods specially when invoked by the invokespecial instruction
				/// 
				/// The  flag indicates which of two alternative semantics is to be expressed by the invokespecial instruction (invokespecial) if it appears in this class.
				/// Compilers to the instruction set of the Java Virtual Machine should set the  flag.
				/// 
				SUPER = 0x0020,
				/// Is an interface, not a class
				/// 
				/// An interface is distinguished by its  flag being set.
				/// If its  flag is not set, this class file defines a class, not an interface.
				/// If the  flag of this class file is set, its  flag must also be set (JLS 9.1.1.1).
				/// Such a class file must not have its ,  or  flags set.
				/// 
				INTERFACE = 0x0200,
				/// Declared abstract; must not be instantiated
				ABSTRACT = 0x0400,
				/// Declared synthetic; not present in the source code
				/// A class may be marked with the  flag to indicate that it was generated by a compiler and does not appear in source code
				SYNTHETIC = 0x1000,
				/// Declared as an annotation type
				/// 
				/// An annotation type must have its  flag set.
				/// If the  flag is set, the  flag must be set as well.
				/// If the  flag of this class file is not set, it may have any of the other flags in Table 4.1 set, except the  flag.
				/// However, such a class file cannot have both its  and  flags set (JLS 8.1.1.2).
				/// 
				ANNOTATION = 0x2000,
				/// Declared as an enum type
				/// The  flag indicates that this class or its superclass is declared as an enumerated type
				ENUM = 0x4000,
			}

			/// The value of the access_flags item is a mask of flags used to denote access permissions to and properties of this class or interface
			public ACC access_flags;

			/// The value of the this_class item must be a valid index into the  table
			/// The  entry at that index must be a  structure (4.4.1) representing the class or interface defined by this class file
			public UInt16 this_class;

			/// 
			/// For a class, the value of the super_class item either must be zero or must be a valid index into the  table.
			/// If the value of the super_class item is nonzero, the  entry at that index must be a  structure (4.4.1) representing the direct superclass of the class defined by this class file.
			/// Neither the direct superclass nor any of its superclasses may have the  flag set in the access_flags item of its ClassFile structure.
			/// 
			/// 
			/// If the value of the super_class item is zero, then this class file must represent the class Object, the only class or interface without a direct superclass.
			/// For an interface, the value of the super_class item must always be a valid index into the  table.
			/// The  entry at that index must be a  structure representing the class Object.
			/// 
			public UInt16 super_class;

			/// The value of the interfaces_count item gives the number of direct superinterfaces of this class or interface type
			public UInt16 interfaces_count;

			//public UInt16[interfaces_count] interfaces;
		}

		/// Each field is described by a field_info structure
		/// No two fields in one class file may have the same name and descriptor (4.3.2)
		[StructLayout(LayoutKind.Sequential, Pack = 1)]
		public struct field_info
		{
			/// The value of the access_flags item is a mask of flags used to denote access permission to and properties of this field
			/// 
			/// Fields of classes may set any of the flags in Table 4.4.
			/// However, a specific field of a class may have at most one of its , , and  flags set (JLS 8.3.1) and must not have both its  and  flags set (JLS 8.3.1.4).
			/// All fields of interfaces must have their , , and  flags set; they may have their  flag set and must not have any of the other flags in Table 4.4 set (JLS 9.3). 
			/// 
			[Flags]
			public enum ACC : UInt16
			{
				/// Declared public; may be accessed from outside its package
				PUBLIC = 0x0001,
				/// Declared private; usable only within the defining class
				PRIVATE = 0x0002,
				/// Declared protected; may be accessed within subclasses
				PROTECTED = 0x0004,
				/// Declared static
				STATIC = 0x0008,
				/// Declared final; never directly assigned to after object construction (JLS 17.5)
				FINAL = 0x0010,
				/// Declared volatile; cannot be cached
				VOLATILE = 0x0040,
				/// Declared transient; not written or read by a persistent object manager
				TRANSIENT = 0x0080,
				/// Declared synthetic; not present in the source code
				/// A field may be marked with the  flag to indicate that it was generated by a compiler and does not appear in source code
				SYNTHETIC = 0x1000,
				/// Declared as an element of an enum
				/// The  flag indicates that this field is used to hold an element of an enumerated type
				ENUM = 0x4000,
			}

			/// The value of the access_flags item is a mask of flags used to denote access permission to and properties of this field
			public ACC access_flags;

			/// 
			/// The value of the name_index item must be a valid index into the constant_pool table.
			/// The constant_pool entry at that index must be a  (4.4.7) structure which must represent a valid unqualified name (4.2.2) denoting a field.
			/// 
			public UInt16 name_index;

			/// The value of the descriptor_index item must be a valid index into the  table
			/// The  entry at that index must be a  (4.4.7) structure that must represent a valid field descriptor (4.3.2)
			public UInt16 descriptor_index;

			/// The value of the attributes_count item indicates the number of additional attributes (4.7) of this field
			public UInt16 attributes_count;

			//public attribute_info[attributes_count] attributes;
		}

		/// Each method, including each instance initialization method (2.9) and the class or interface initialization method (2.9), is described by a method_info structure
		/// No two methods in one class file may have the same name and descriptor (4.3.3)
		[StructLayout(LayoutKind.Sequential, Pack = 1)]
		public struct method_info
		{
			/// 
			/// Methods of classes may have any of the flags in Table 4.6-A set.
			/// However, each method of a class may have at most one of its , , and  flags set (JLS 8.4.3)
			/// 
			/// 
			/// Methods of interfaces may have any of the flags in Table 4.6-A set except , , , and  (JLS 9.4).
			/// In a class file whose version number is less than 52.0, each method of an interface must have its  and  flags set; in a class file whose version number is 52.0 or above, each method of an interface must have exactly one of its  and  flags set.
			/// Each instance initialization method (2.9) may have at most one of its , , and  flags set, and may also have its , , and  flags set, but must not have any of the other flags in Table 4.6-A set.
			/// 
			[Flags]
			public enum ACC : UInt16
			{
				/// Declared public; may be accessed from outside its package
				PUBLIC = 0x0001,
				/// Declared private; accessible only within the defining class
				PRIVATE = 0x0002,
				/// Declared protected; may be accessed within subclasses
				PROTECTED = 0x0004,
				/// Declared static
				STATIC = 0x0008,
				/// Declared final; must not be overridden (5.4.5)
				FINAL = 0x0010,
				/// Declared synchronized; invocation is wrapped by a monitor use
				SYNCHRONIZED = 0x0020,
				/// A bridge method, generated by the compiler
				/// The  flag is used to indicate a bridge method generated by a compiler for the Java programming language
				BRIDGE = 0x0040,
				/// Declared with variable number of arguments
				/// 
				/// The  flag indicates that this method takes a variable number of arguments at the source code level.
				/// A method declared to take a variable number of arguments must be compiled with the  flag set to 1.
				/// All other methods must be compiled with the  flag set to 0
				/// 
				VARARGS = 0x0080,
				/// Declared native; implemented in a language other than Java
				NATIVE = 0x0100,
				/// Declared abstract; no implementation is provided.
				///  If a method of a class or interface has its  flag set, it must not have any of its , , , , , or  flags set.
				ABSTRACT = 0x0400,
				/// Declared strictfp; floating-point mode is FP-strict
				/// 
				/// Class and interface initialization methods are called implicitly by the Java Virtual Machine.
				/// The value of their access_flags item is ignored except for the setting of the  flag
				/// 
				STRICT = 0x0800,
				/// Declared synthetic; not present in the source code
				/// The  flag indicates that this method was generated by a compiler and does not appear in source code, unless it is one of the methods named in 4.7.8
				SYNTHETIC = 0x1000,
			}

			/// The value of the access_flags item is a mask of flags used to denote access permission to and properties of this method
			public ACC access_flags;

			/// The value of the name_index item must be a valid index into the constant_pool table
			/// The constant_pool entry at that index must be a  structure (4.4.7) representing either one of the special method names <init> or <clinit> (2.9), or a valid unqualified name denoting a method (4.2.2)
			public UInt16 name_index;

			/// The value of the descriptor_index item must be a valid index into the constant_pool table
			/// The constant_pool entry at that index must be a  structure representing a valid method descriptor (4.3.3)
			public UInt16 descriptor_index;

			/// The value of the attributes_count item indicates the number of additional attributes of this method
			public UInt16 attributes_count;

			//public UInt16[attributes_count] attributes;
		}

		/// All attributes have the following general format
		[StructLayout(LayoutKind.Sequential, Pack = 1)]
		public struct attribute_info
		{
			/// For all attributes, the attribute_name_index must be a valid unsigned 16-bit index into the constant pool of the class
			/// The  entry at attribute_name_index must be a  structure (4.4.7) representing the name of the attribute
			public UInt16 attribute_name_index;

			/// The value of the attribute_length item indicates the length of the subsequent information in bytes
			/// The length does not include the initial six bytes that contain the attribute_name_index and attribute_length items
			public UInt32 attribute_length;

			//public Byte[] info;
		}

		/// Method Type and Method Handle Resolution
		/// https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-5.html#jvms-5.4.3.5
		public enum REF : Byte
		{
			/// getfield C.f:T
			getField=1,
			/// getstatic C.f:T
			getStatic=2,
			/// putfield C.f:T
			putField=3,
			/// putstatic C.f:T
			putStatic=4,
			/// invokevirtual C.m:(A*)T
			invokeVirtual=5,
			/// invokestatic C.m:(A*)T
			invokeStatic=6,
			/// invokespecial C.m:(A*)T
			invokeSpecial=7,
			/// new C; dup; invokespecial C.<init>:(A*)void
			newInvokeSpecial=8,
			/// invokeinterface C.m:(A*)T
			invokeInterface=9,
		}

		/// Constant pool tags
		public enum CONSTANT : Byte
		{
			/// The  structure is used to represent a class or an interface
			Class = 7,
			/// Fields, methods, and interface methods are represented by similar structures
			Fieldref = 9,
			/// Fields, methods, and interface methods are represented by similar structures
			Methodref = 10,
			/// Fields, methods, and interface methods are represented by similar structures
			InterfaceMethodref = 11,
			/// The  structure is used to represent constant objects of the type String
			String = 8,
			/// The  structures represent 4-byte numeric (int) constant
			Integer = 3,
			/// The  structures represent 4-byte numeric (float) constant
			Float = 4,
			/// The  represent 8-byte numeric (long) constant
			Long = 5,
			/// The  represent 8-byte numeric (double) constant
			Double = 6,
			/// The  structure is used to represent a field or method, without indicating which class or interface type it belongs to
			NameAndType = 12,
			/// The  structure is used to represent constant string values
			Utf8 = 1,
			/// The  structure is used to represent a method handle
			MethodHandle = 15,
			/// The  structure is used to represent a method type
			MethodType = 16,
			/// The  structure is used by an invokedynamic instruction (invokedynamic) to specify a bootstrap method, the dynamic invocation name, the argument and return types of the call, and optionally, a sequence of additional constants called static arguments to the bootstrap method
			InvokeDynamic = 18,
		}

		/// Known attributes
		public enum ATTRIBUTE
		{
			/// Undefined custom attribute
			/// Will be read as Byte[]
			Undefined,
			/// A ConstantValue attribute represents the value of a constant expression (JLS 15.28)
			ConstantValue,
			/// The Code attribute is a variable-length attribute in the attributes table of a method_info structure (4.6)
			/// A Code attribute contains the Java Virtual Machine instructions and auxiliary information for a method, including an instance initialization method or a class or interface initialization method (2.9)
			Code,
			/// The StackMapTable attribute is a variable-length attribute in the attributes table of a Code attribute (4.7.3)
			/// A StackMapTable attribute is used during the process of verification by type checking (4.10.1)
			StackMapTable,
			/// The Exceptions attribute is a variable-length attribute in the attributes table of a method_info structure (4.6)
			/// The Exceptions attribute indicates which checked exceptions a method may throw
			Exceptions,
			/// If the constant pool of a class or interface C contains at least one  entry (4.4.1) which represents a class or interface that is not a member of a package, then there must be exactly one InnerClasses attribute in the attributes table of the ClassFile structure for C
			InnerClasses,
			/// The EnclosingMethod attribute is a fixed-length attribute in the attributes table of a ClassFile structure (4.1)
			/// A class must have an EnclosingMethod attribute if and only if it represents a local class or an anonymous class (JLS 14.3, JLS 15.9.5)
			EnclosingMethod,
			/// The Synthetic attribute is a fixed-length attribute in the attributes table of a ClassFile, field_info, or method_info structure (4.1, 4.5, 4.6)
			/// 
			/// A class member that does not appear in the source code must be marked using a Synthetic attribute, or else it must have its ACC_SYNTHETIC flag set.
			/// The only exceptions to this requirement are compiler-generated methods which are not considered implementation artifacts, namely the instance initialization method representing a default constructor of the Java programming language (2.9), the class initialization method (2.9), and the Enum.values() and Enum.valueOf() methods
			/// 
			Synthetic,
			/// The Signature attribute is a fixed-length attribute in the attributes table of a ClassFile, field_info, or method_info structure (4.1, 4.5, 4.6)
			/// 
			/// A Signature attribute records a signature (4.7.9.1) for a class, interface, constructor, method, or field whose declaration in the Java programming language uses type variables or parameterized types.
			/// See The Java Language Specification, Java SE 8 Edition for details about these types
			/// 
			Signature,
			/// There may be at most one SourceFile attribute in the attributes table of a ClassFile structure
			SourceFile,
			/// There may be at most one SourceDebugExtension attribute in the attributes table of a ClassFile structure
			SourceDebugExtension,
			/// 
			/// The LineNumberTable attribute is an optional variable-length attribute in the attributes table of a Code attribute (4.7.3).
			/// It may be used by debuggers to determine which part of the code array corresponds to a given line number in the original source file.
			/// If multiple LineNumberTable attributes are present in the attributes table of a Code attribute, then they may appear in any order.
			/// There may be more than one LineNumberTable attribute per line of a source file in the attributes table of a Code attribute.
			/// That is, LineNumberTable attributes may together represent a given line of a source file, and need not be one-to-one with source lines.
			/// 
			LineNumberTable,
			/// The LocalVariableTable attribute is an optional variable-length attribute in the attributes table of a Code attribute (4.7.3)
			/// It may be used by debuggers to determine the value of a given local variable during the execution of a method
			LocalVariableTable,
			/// The LocalVariableTypeTable attribute is an optional variable-length attribute in the attributes table of a Code attribute (4.7.3)
			/// It may be used by debuggers to determine the value of a given local variable during the execution of a method
			LocalVariableTypeTable,
			/// The Deprecated attribute is an optional fixed-length attribute in the attributes table of a ClassFile, field_info, or method_info structure (4.1, 4.5, 4.6)
			/// A class, interface, method, or field may be marked using a Deprecated attribute to indicate that the class, interface, method, or field has been superseded
			Deprecated,
			/// The RuntimeVisibleAnnotations attribute is a variable-length attribute in the attributes table of a ClassFile, field_info, or method_info structure (4.1, 4.5, 4.6)
			/// The RuntimeVisibleAnnotations attribute records run-time visible annotations on the declaration of the corresponding class, field, or method. The Java Virtual Machine must make these annotations available so they can be returned by the appropriate reflective APIs
			RuntimeVisibleAnnotations,
			/// The RuntimeInvisibleAnnotations attribute is a variable-length attribute in the attributes table of a ClassFile, field_info, or method_info structure (4.1, 4.5, 4.6)
			/// The RuntimeInvisibleAnnotations attribute records run-time invisible annotations on the declaration of the corresponding class, method, or field
			RuntimeInvisibleAnnotations,
			/// The RuntimeVisibleParameterAnnotations attribute is a variable-length attribute in the attributes table of the method_info structure (4.6)
			/// The RuntimeVisibleParameterAnnotations attribute records run-time visible annotations on the declarations of formal parameters of the corresponding method. The Java Virtual Machine must make these annotations available so they can be returned by the appropriate reflective APIs
			RuntimeVisibleParameterAnnotations,
			/// The RuntimeInvisibleParameterAnnotations attribute is a variable-length attribute in the attributes table of a method_info structure (4.6)
			/// The RuntimeInvisibleParameterAnnotations attribute records run-time invisible annotations on the declarations of formal parameters of the corresponding method
			RuntimeInvisibleParameterAnnotations,
			/// The RuntimeVisibleTypeAnnotations attribute is an variable-length attribute in the attributes table of a ClassFile, field_info, or method_info structure, or Code attribute (4.1, 4.5, 4.6, 4.7.3)
			/// The RuntimeVisibleTypeAnnotations attribute records run-time visible annotations on types used in the declaration of the corresponding class, field, or method, or in an expression in the corresponding method body. The RuntimeVisibleTypeAnnotations attribute also records run-time visible annotations on type parameter declarations of generic classes, interfaces, methods, and constructors. The Java Virtual Machine must make these annotations available so they can be returned by the appropriate reflective APIs
			RuntimeVisibleTypeAnnotations,
			/// The RuntimeInvisibleTypeAnnotations attribute is an variable-length attribute in the attributes table of a ClassFile, field_info, or method_info structure, or Code attribute (4.1, 4.5, 4.6, 4.7.3). The RuntimeInvisibleTypeAnnotations attribute records run-time invisible annotations on types used in the corresponding declaration of a class, field, or method, or in an expression in the corresponding method body
			/// The RuntimeInvisibleTypeAnnotations attribute also records annotations on type parameter declarations of generic classes, interfaces, methods, and constructors
			RuntimeInvisibleTypeAnnotations,
			/// The AnnotationDefault attribute is a variable-length attribute in the attributes table of certain method_info structures (4.6), namely those representing elements of annotation types (JLS 9.6.1)
			/// The AnnotationDefault attribute records the default value (JLS 9.6.2) for the element represented by the method_info structure. The Java Virtual Machine must make this default value available so it can be applied by appropriate reflective APIs
			AnnotationDefault,
			/// The BootstrapMethods attribute is a variable-length attribute in the attributes table of a ClassFile structure (4.1)
			/// The BootstrapMethods attribute records bootstrap method specifiers referenced by invokedynamic instructions (invokedynamic)
			BootstrapMethods,
			/// The MethodParameters attribute is a variable-length attribute in the attributes table of a method_info structure (4.6)
			/// A MethodParameters attribute records information about the formal parameters of a method, such as their names
			MethodParameters,

			/// Circular reference attribute
			ExceptionTableRef,
			/// Circular reference attribute
			InnerClassesRef,
			/// Circular reference attribute
			LineNumberTableRef,
			/// Circular reference attribute
			LocalVariableTableRef,
			/// Circular reference attribute
			LocalVariableTypeTableRef,
			/// Circular reference attribute
			BootstrapMethodsRef,
			/// Circular reference attribute
			MethodParametersRef,
		}

		#region CONSTANT. See: ConstantTables.cs
		/// 
		/// Because arrays are objects, the opcodes anewarray and multianewarray - but not the opcode new - can reference array "classes" via  structures in the constant_pool table.
		/// For such array classes, the name of the class is the descriptor of the array type (4.3.2).
		/// 
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_Class_info
		{
			/// The tag item has the value  (7).
			public CONSTANT tag;

			/// 
			/// The value of the name_index item must be a valid index into the constant_pool table.
			/// The constant_pool entry at that index must be a  structure (4.4.7) representing a valid binary class or interface name encoded in internal form (4.2.1).
			/// 
			public UInt16 name_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.Class;
		}

		/// Fields, methods, and interface methods are represented by similar structures
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_Fieldref_info
		{
			/// The tag item of a  structure has the value  (9)
			public CONSTANT tag;

			/// The class_index item of a  structure may be either a class type or an interface type
			/// 
			/// The value of the class_index item must be a valid index into the constant_pool table.
			/// The constant_pool entry at that index must be a  structure (4.4.1) representing a class or interface type that has the field or method as a member.
			/// 
			public UInt16 class_index;

			/// 
			/// In a , the indicated descriptor must be a field descriptor (4.3.2).
			/// Otherwise, the indicated descriptor must be a method descriptor (4.3.3).
			/// 
			/// 
			/// The value of the name_and_type_index item must be a valid index into the constant_pool table.
			/// The constant_pool entry at that index must be a  structure (4.4.6).
			/// This constant_pool entry indicates the name and descriptor of the field or method
			/// 
			public UInt16 name_and_type_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.Fieldref;
		}

		/// Fields, methods, and interface methods are represented by similar structures
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_Methodref_info
		{
			/// The tag item of a  structure has the value  (10).
			public CONSTANT tag;

			/// The class_index item of a  structure must be a class type, not an interface type
			public UInt16 class_index;

			/// If the name of the method of a  structure begins with a '<' ('\u003c'), then the name must be the special name <init>, representing an instance initialization method (2.9)
			/// The return type of such a method must be void
			public UInt16 name_and_type_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.Methodref;
		}

		/// Fields, methods, and interface methods are represented by similar structures
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_InterfaceMethodref_info
		{
			/// The tag item of a  structure has the value  (11)
			public CONSTANT tag;

			/// The class_index item of a  structure must be an interface type
			public UInt16 class_index;

			/// banana banana banana
			public UInt16 name_and_type_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.InterfaceMethodref;
		}

		/// The  structure is used to represent constant objects of the type String
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_String_info
		{
			/// The tag item of the  structure has the value  (8).
			public CONSTANT tag;

			/// The constant_pool entry at that index must be a  structure (4.4.7) representing the sequence of Unicode code points to which the String object is to be initialized
			/// The value of the string_index item must be a valid index into the constant_pool table
			public UInt16 string_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.String;
		}

		/// The  structures represent 4-byte numeric (int) constants
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_Integer_info
		{
			/// The tag item of the  structure has the value  (3).
			public CONSTANT tag;

			/// 
			/// The bytes item of the  structure represents the value of the int constant.
			/// The bytes of the value are stored in big-endian (high byte first) order.
			/// 
			public UInt32 bytes;

			/// CONSTANT validataion
			public Boolean IsValid => this.tag == CONSTANT.Integer;
		}

		/// The  structures represent 4-byte numeric (float) constants
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_Float_info
		{
			/// The tag item of the  structure has the value  (4).
			public CONSTANT tag;

			/// 
			/// The bytes item of the  structure represents the value of the float constant in IEEE 754 floating-point single format (2.3.2).
			/// The bytes of the single format representation are stored in big-endian (high byte first) order.
			/// 
			/// 
			/// The value represented by the  structure is determined as follows.
			/// The bytes of the value are first converted into an int constant bits.
			/// Then:
			/// If bits is 0x7f800000, the float value will be positive infinity.
			/// If bits is 0xff800000, the float value will be negative infinity.
			/// If bits is in the range 0x7f800001 through 0x7fffffff or in the range 0xff800001 through 0xffffffff, the float value will be NaN.
			/// In all other cases, let s, e, and m be three values that might be computed from bits: 
			/// 
			/// int s = ((bits >> 31) == 0) ? 1 : -1;
			/// int e = ((bits >> 23) & 0xff);
			/// int m = (e == 0) ?
			///     (bits & 0x7fffff) << 1 :
			///     (bits & 0x7fffff) | 0x800000;
			/// 
			/// Then the float value equals the result of the mathematical expression s  m  2e-150.
			/// 
			public UInt32 bytes;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.Float;
		}

		/// The  and represent 8-byte numeric (long) constants
		/// 
		/// All 8-byte constants take up two entries in the constant_pool table of the class file.
		/// If a  or  structure is the item in the constant_pool table at index n, then the next usable item in the pool is located at index n+2.
		/// The constant_pool index n+1 must be valid but is considered unusable.
		/// 
		/// In retrospect, making 8-byte constants take two constant pool entries was a poor choice.
		/// 
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_Long_info
		{
			/// The tag item of the  structure has the value  (5)
			public CONSTANT tag;

			/// The unsigned high_bytes and low_bytes items of the  structure together represent the value of the long constant
			/// 
			/// ((long) high_bytes << 32) + low_bytes
			/// where the bytes of each of high_bytes and low_bytes are stored in big-endian (high byte first) order.
			/// The high_bytes and low_bytes items of the  structure together represent the double value in IEEE 754 floating-point double format (2.3.2).
			/// The bytes of each item are stored in big-endian (high byte first) order.
			/// 
			public UInt32 high_bytes;

			/// The unsigned high_bytes and low_bytes items of the  structure together represent the value of the long constant
			public UInt32 low_bytes;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.Long;
		}

		/// The  represent 8-byte numeric (double) constants
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_Double_info
		{
			/// The tag item of the  structure has the value  (6)
			public CONSTANT tag;

			/// 
			/// The high_bytes and low_bytes items of the  structure together represent the double value in IEEE 754 floating-point double format (2.3.2).
			/// The bytes of each item are stored in big-endian (high byte first) order
			/// 
			/// 
			/// The value represented by the  structure is determined as follows.
			/// The high_bytes and low_bytes items are converted into the long constant bits, which is equal to
			/// ((long) high_bytes << 32) + low_bytes
			/// 
			/// Then:
			/// If bits is 0x7ff0000000000000L, the double value will be positive infinity.
			/// If bits is 0xfff0000000000000L, the double value will be negative infinity.
			/// If bits is in the range 0x7ff0000000000001L through 0x7fffffffffffffffL or in the range 0xfff0000000000001L through 0xffffffffffffffffL, the double value will be NaN.
			/// In all other cases, let s, e, and m be three values that might be computed from bits:
			/// 
			/// int s = ((bits >> 63) == 0) ? 1 : -1;
			/// int e = (int)((bits >> 52) & 0x7ffL);
			/// long m = (e == 0) ?
			///     (bits & 0xfffffffffffffL) << 1 :
			///     (bits & 0xfffffffffffffL) | 0x10000000000000L;
			///     
			/// Then the floating-point value equals the double value of the mathematical expression s  m  2e-1075.
			/// 
			public UInt32 high_bytes;

			/// 
			/// The high_bytes and low_bytes items of the  structure together represent the double value in IEEE 754 floating-point double format (2.3.2).
			/// The bytes of each item are stored in big-endian (high byte first) order
			/// 
			public UInt32 low_bytes;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.Double;
		}

		/// The  structure is used to represent a field or method, without indicating which class or interface type it belongs to
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_NameAndType_info
		{
			/// The tag item of the  structure has the value  (12).
			public CONSTANT tag;

			/// The constant_pool entry at that index must be a  structure (4.4.7) representing either the special method name <init> (2.9) or a valid unqualified name denoting a field or method (4.2.2)
			/// The value of the name_index item must be a valid index into the constant_pool table
			public UInt16 name_index;

			/// The constant_pool entry at that index must be a  structure (4.4.7) representing a valid field descriptor or method descriptor (4.3.2, 4.3.3)
			/// The value of the descriptor_index item must be a valid index into the constant_pool table
			public UInt16 descriptor_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.NameAndType;
		}

		/// The  structure is used to represent constant string values
		/// (Documentation: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.7) 
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_Utf8_info
		{
			///  The tag item of the  structure has the value  (1)
			public CONSTANT tag;

			/// The value of the length item gives the number of bytes in the bytes array (not the length of the resulting string)
			public UInt32 length;

			/*/// The bytes array contains the bytes of the string
			/// 
			/// String content is encoded in modified UTF-8. Modified UTF-8 strings are encoded so that code point sequences that contain only non-null ASCII characters can be represented using only 1 byte per code point, but all code points in the Unicode codespace can be represented. Modified UTF-8 strings are not null-terminated.
			/// 
			public Byte[] bytes;*/

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.Utf8;
		}

		/// The  structure is used to represent a method handle
		/// (Documentation: https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.4.8) 
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_MethodHandle_info
		{
			///  The tag item of the  structure has the value  (15)
			public CONSTANT tag;

			/// The value denotes the kind of this method handle, which characterizes its bytecode behavior (5.4.3.5)
			/// The value of the reference_kind item must be in the range 1 to 9
			public Byte reference_kind;

			///  The value of the reference_index item must be a valid index into the constant_pool table
			public Byte reference_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.MethodHandle;
		}

		/// The  structure is used to represent a method type
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_MethodType_info
		{
			/// The tag item of the  structure has the value  (16).
			public CONSTANT tag;

			/// The constant_pool entry at that index must be a  structure (4.4.7) representing a method descriptor (4.3.3)
			/// The value of the descriptor_index item must be a valid index into the constant_pool table
			public UInt16 descriptor_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.MethodType;
		}

		/// The  structure is used by an invokedynamic instruction (invokedynamic) to specify a bootstrap method, the dynamic invocation name, the argument and return types of the call, and optionally, a sequence of additional constants called static arguments to the bootstrap method
		[StructLayout(LayoutKind.Sequential)]
		internal struct CONSTANT_InvokeDynamic_info
		{
			/// The tag item of the  structure has the value  (18).
			public CONSTANT tag;

			/// The value of the bootstrap_method_attr_index item must be a valid index into the bootstrap_methods array of the bootstrap method table (4.7.23) of this class file
			public UInt16 bootstrap_method_attr_index;

			/// The constant_pool entry at that index must be a  structure (4.4.6) representing a method name and method descriptor (4.3.3)
			/// The value of the name_and_type_index item must be a valid index into the constant_pool table
			public UInt16 name_and_type_index;

			/// CONSTANT validation
			public Boolean IsValid => this.tag == CONSTANT.InvokeDynamic;
		}
		#endregion CONSTANT. See: ConstantTables.cs
	}
}

Web Proxy Viewer  |  New URL  |  Original Page