|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
package com.sun.java.util.jar.pack; |
|
|
|
import java.util.Arrays; |
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
*/ |
|
class Constants { |
|
|
|
private Constants(){} |
|
|
|
public final static int JAVA_MAGIC = 0xCAFEBABE; |
|
|
|
/* |
|
Java Class Version numbers history |
|
1.0 to 1.3.X 45,3 |
|
1.4 to 1.4.X 46,0 |
|
1.5 to 1.5.X 49,0 |
|
1.6 to 1.5.x 50,0 |
|
1.7 to 1.6.x 51,0 |
|
1.8 to 1.7.x 52,0 |
|
*/ |
|
|
|
public final static Package.Version JAVA_MIN_CLASS_VERSION = |
|
Package.Version.of(45, 03); |
|
|
|
public final static Package.Version JAVA5_MAX_CLASS_VERSION = |
|
Package.Version.of(49, 00); |
|
|
|
public final static Package.Version JAVA6_MAX_CLASS_VERSION = |
|
Package.Version.of(50, 00); |
|
|
|
public final static Package.Version JAVA7_MAX_CLASS_VERSION = |
|
Package.Version.of(51, 00); |
|
|
|
public final static Package.Version JAVA8_MAX_CLASS_VERSION = |
|
Package.Version.of(52, 00); |
|
|
|
public final static int JAVA_PACKAGE_MAGIC = 0xCAFED00D; |
|
|
|
public final static Package.Version JAVA5_PACKAGE_VERSION = |
|
Package.Version.of(150, 7); |
|
|
|
public final static Package.Version JAVA6_PACKAGE_VERSION = |
|
Package.Version.of(160, 1); |
|
|
|
public final static Package.Version JAVA7_PACKAGE_VERSION = |
|
Package.Version.of(170, 1); |
|
|
|
public final static Package.Version JAVA8_PACKAGE_VERSION = |
|
Package.Version.of(171, 0); |
|
|
|
|
|
public final static Package.Version JAVA_MAX_CLASS_VERSION = |
|
JAVA8_MAX_CLASS_VERSION; |
|
|
|
|
|
public final static Package.Version MAX_PACKAGE_VERSION = |
|
JAVA7_PACKAGE_VERSION; |
|
|
|
public final static int CONSTANT_POOL_INDEX_LIMIT = 0x10000; |
|
public final static int CONSTANT_POOL_NARROW_LIMIT = 0x00100; |
|
|
|
public final static String JAVA_SIGNATURE_CHARS = "BSCIJFDZLV(["; |
|
|
|
public final static byte CONSTANT_Utf8 = 1; |
|
public final static byte CONSTANT_unused2 = 2; |
|
public final static byte CONSTANT_Integer = 3; |
|
public final static byte CONSTANT_Float = 4; |
|
public final static byte CONSTANT_Long = 5; |
|
public final static byte CONSTANT_Double = 6; |
|
public final static byte CONSTANT_Class = 7; |
|
public final static byte CONSTANT_String = 8; |
|
public final static byte CONSTANT_Fieldref = 9; |
|
public final static byte CONSTANT_Methodref = 10; |
|
public final static byte CONSTANT_InterfaceMethodref = 11; |
|
public final static byte CONSTANT_NameandType = 12; |
|
public final static byte CONSTANT_unused13 = 13; |
|
public final static byte CONSTANT_unused14 = 14; |
|
public final static byte CONSTANT_MethodHandle = 15; |
|
public final static byte CONSTANT_MethodType = 16; |
|
public final static byte CONSTANT_unused17 = 17; |
|
public final static byte CONSTANT_InvokeDynamic = 18; |
|
|
|
|
|
public final static byte CONSTANT_None = 0; |
|
public final static byte CONSTANT_Signature = CONSTANT_unused13; |
|
public final static byte CONSTANT_BootstrapMethod = CONSTANT_unused17; |
|
public final static byte CONSTANT_Limit = 19; |
|
|
|
public final static byte CONSTANT_All = 50; |
|
public final static byte CONSTANT_LoadableValue = 51; |
|
public final static byte CONSTANT_AnyMember = 52; |
|
public final static byte CONSTANT_FieldSpecific = 53; |
|
public final static byte CONSTANT_GroupFirst = CONSTANT_All; |
|
public final static byte CONSTANT_GroupLimit = CONSTANT_FieldSpecific+1; |
|
|
|
|
|
public final static byte REF_getField = 1; |
|
public final static byte REF_getStatic = 2; |
|
public final static byte REF_putField = 3; |
|
public final static byte REF_putStatic = 4; |
|
public final static byte REF_invokeVirtual = 5; |
|
public final static byte REF_invokeStatic = 6; |
|
public final static byte REF_invokeSpecial = 7; |
|
public final static byte REF_newInvokeSpecial = 8; |
|
public final static byte REF_invokeInterface = 9; |
|
|
|
// pseudo-access bits |
|
public final static int ACC_IC_LONG_FORM = (1<<16); |
|
|
|
|
|
public static final int ATTR_CONTEXT_CLASS = 0; |
|
public static final int ATTR_CONTEXT_FIELD = 1; |
|
public static final int ATTR_CONTEXT_METHOD = 2; |
|
public static final int ATTR_CONTEXT_CODE = 3; |
|
public static final int ATTR_CONTEXT_LIMIT = 4; |
|
public static final String[] ATTR_CONTEXT_NAME |
|
= { "class", "field", "method", "code" }; |
|
|
|
|
|
public static final int |
|
X_ATTR_OVERFLOW = 16, |
|
CLASS_ATTR_SourceFile = 17, |
|
METHOD_ATTR_Code = 17, |
|
FIELD_ATTR_ConstantValue = 17, |
|
CLASS_ATTR_EnclosingMethod = 18, |
|
METHOD_ATTR_Exceptions = 18, |
|
X_ATTR_Signature = 19, |
|
X_ATTR_Deprecated = 20, |
|
X_ATTR_RuntimeVisibleAnnotations = 21, |
|
X_ATTR_RuntimeInvisibleAnnotations = 22, |
|
METHOD_ATTR_RuntimeVisibleParameterAnnotations = 23, |
|
CLASS_ATTR_InnerClasses = 23, |
|
METHOD_ATTR_RuntimeInvisibleParameterAnnotations = 24, |
|
CLASS_ATTR_ClassFile_version = 24, |
|
METHOD_ATTR_AnnotationDefault = 25, |
|
METHOD_ATTR_MethodParameters = 26, |
|
X_ATTR_RuntimeVisibleTypeAnnotations = 27, |
|
X_ATTR_RuntimeInvisibleTypeAnnotations = 28, |
|
CODE_ATTR_StackMapTable = 0, |
|
CODE_ATTR_LineNumberTable = 1, |
|
CODE_ATTR_LocalVariableTable = 2, |
|
CODE_ATTR_LocalVariableTypeTable = 3; |
|
|
|
|
|
public static final int FO_DEFLATE_HINT = 1<<0; |
|
public static final int FO_IS_CLASS_STUB = 1<<1; |
|
|
|
|
|
public static final int AO_HAVE_SPECIAL_FORMATS = 1<<0; |
|
public static final int AO_HAVE_CP_NUMBERS = 1<<1; |
|
public static final int AO_HAVE_ALL_CODE_FLAGS = 1<<2; |
|
public static final int AO_HAVE_CP_EXTRAS = 1<<3; |
|
public static final int AO_HAVE_FILE_HEADERS = 1<<4; |
|
public static final int AO_DEFLATE_HINT = 1<<5; |
|
public static final int AO_HAVE_FILE_MODTIME = 1<<6; |
|
public static final int AO_HAVE_FILE_OPTIONS = 1<<7; |
|
public static final int AO_HAVE_FILE_SIZE_HI = 1<<8; |
|
public static final int AO_HAVE_CLASS_FLAGS_HI = 1<<9; |
|
public static final int AO_HAVE_FIELD_FLAGS_HI = 1<<10; |
|
public static final int AO_HAVE_METHOD_FLAGS_HI = 1<<11; |
|
public static final int AO_HAVE_CODE_FLAGS_HI = 1<<12; |
|
public static final int AO_UNUSED_MBZ = (-1)<<13; |
|
|
|
public static final int LG_AO_HAVE_XXX_FLAGS_HI = 9; |
|
|
|
|
|
static final int VRM_CLASSIC = 0; |
|
static final int VRM_PACKAGE = 1; |
|
|
|
public static final int NO_MODTIME = 0; |
|
|
|
|
|
public final static int[] noInts = {}; |
|
public final static byte[] noBytes = {}; |
|
public final static Object[] noValues = {}; |
|
public final static String[] noStrings = {}; |
|
public final static List<Object> emptyList = Arrays.asList(noValues); |
|
|
|
|
|
public final static int |
|
_meta_default = 0, |
|
_meta_canon_min = 1, |
|
_meta_canon_max = 115, |
|
_meta_arb = 116, |
|
_meta_run = 117, |
|
_meta_pop = 141, |
|
_meta_limit = 189; |
|
|
|
|
|
public final static int |
|
_nop = 0, |
|
_aconst_null = 1, |
|
_iconst_m1 = 2, |
|
_iconst_0 = 3, |
|
_iconst_1 = 4, |
|
_iconst_2 = 5, |
|
_iconst_3 = 6, |
|
_iconst_4 = 7, |
|
_iconst_5 = 8, |
|
_lconst_0 = 9, |
|
_lconst_1 = 10, |
|
_fconst_0 = 11, |
|
_fconst_1 = 12, |
|
_fconst_2 = 13, |
|
_dconst_0 = 14, |
|
_dconst_1 = 15, |
|
_bipush = 16, |
|
_sipush = 17, |
|
_ldc = 18, |
|
_ldc_w = 19, |
|
_ldc2_w = 20, |
|
_iload = 21, |
|
_lload = 22, |
|
_fload = 23, |
|
_dload = 24, |
|
_aload = 25, |
|
_iload_0 = 26, |
|
_iload_1 = 27, |
|
_iload_2 = 28, |
|
_iload_3 = 29, |
|
_lload_0 = 30, |
|
_lload_1 = 31, |
|
_lload_2 = 32, |
|
_lload_3 = 33, |
|
_fload_0 = 34, |
|
_fload_1 = 35, |
|
_fload_2 = 36, |
|
_fload_3 = 37, |
|
_dload_0 = 38, |
|
_dload_1 = 39, |
|
_dload_2 = 40, |
|
_dload_3 = 41, |
|
_aload_0 = 42, |
|
_aload_1 = 43, |
|
_aload_2 = 44, |
|
_aload_3 = 45, |
|
_iaload = 46, |
|
_laload = 47, |
|
_faload = 48, |
|
_daload = 49, |
|
_aaload = 50, |
|
_baload = 51, |
|
_caload = 52, |
|
_saload = 53, |
|
_istore = 54, |
|
_lstore = 55, |
|
_fstore = 56, |
|
_dstore = 57, |
|
_astore = 58, |
|
_istore_0 = 59, |
|
_istore_1 = 60, |
|
_istore_2 = 61, |
|
_istore_3 = 62, |
|
_lstore_0 = 63, |
|
_lstore_1 = 64, |
|
_lstore_2 = 65, |
|
_lstore_3 = 66, |
|
_fstore_0 = 67, |
|
_fstore_1 = 68, |
|
_fstore_2 = 69, |
|
_fstore_3 = 70, |
|
_dstore_0 = 71, |
|
_dstore_1 = 72, |
|
_dstore_2 = 73, |
|
_dstore_3 = 74, |
|
_astore_0 = 75, |
|
_astore_1 = 76, |
|
_astore_2 = 77, |
|
_astore_3 = 78, |
|
_iastore = 79, |
|
_lastore = 80, |
|
_fastore = 81, |
|
_dastore = 82, |
|
_aastore = 83, |
|
_bastore = 84, |
|
_castore = 85, |
|
_sastore = 86, |
|
_pop = 87, |
|
_pop2 = 88, |
|
_dup = 89, |
|
_dup_x1 = 90, |
|
_dup_x2 = 91, |
|
_dup2 = 92, |
|
_dup2_x1 = 93, |
|
_dup2_x2 = 94, |
|
_swap = 95, |
|
_iadd = 96, |
|
_ladd = 97, |
|
_fadd = 98, |
|
_dadd = 99, |
|
_isub = 100, |
|
_lsub = 101, |
|
_fsub = 102, |
|
_dsub = 103, |
|
_imul = 104, |
|
_lmul = 105, |
|
_fmul = 106, |
|
_dmul = 107, |
|
_idiv = 108, |
|
_ldiv = 109, |
|
_fdiv = 110, |
|
_ddiv = 111, |
|
_irem = 112, |
|
_lrem = 113, |
|
_frem = 114, |
|
_drem = 115, |
|
_ineg = 116, |
|
_lneg = 117, |
|
_fneg = 118, |
|
_dneg = 119, |
|
_ishl = 120, |
|
_lshl = 121, |
|
_ishr = 122, |
|
_lshr = 123, |
|
_iushr = 124, |
|
_lushr = 125, |
|
_iand = 126, |
|
_land = 127, |
|
_ior = 128, |
|
_lor = 129, |
|
_ixor = 130, |
|
_lxor = 131, |
|
_iinc = 132, |
|
_i2l = 133, |
|
_i2f = 134, |
|
_i2d = 135, |
|
_l2i = 136, |
|
_l2f = 137, |
|
_l2d = 138, |
|
_f2i = 139, |
|
_f2l = 140, |
|
_f2d = 141, |
|
_d2i = 142, |
|
_d2l = 143, |
|
_d2f = 144, |
|
_i2b = 145, |
|
_i2c = 146, |
|
_i2s = 147, |
|
_lcmp = 148, |
|
_fcmpl = 149, |
|
_fcmpg = 150, |
|
_dcmpl = 151, |
|
_dcmpg = 152, |
|
_ifeq = 153, |
|
_ifne = 154, |
|
_iflt = 155, |
|
_ifge = 156, |
|
_ifgt = 157, |
|
_ifle = 158, |
|
_if_icmpeq = 159, |
|
_if_icmpne = 160, |
|
_if_icmplt = 161, |
|
_if_icmpge = 162, |
|
_if_icmpgt = 163, |
|
_if_icmple = 164, |
|
_if_acmpeq = 165, |
|
_if_acmpne = 166, |
|
_goto = 167, |
|
_jsr = 168, |
|
_ret = 169, |
|
_tableswitch = 170, |
|
_lookupswitch = 171, |
|
_ireturn = 172, |
|
_lreturn = 173, |
|
_freturn = 174, |
|
_dreturn = 175, |
|
_areturn = 176, |
|
_return = 177, |
|
_getstatic = 178, |
|
_putstatic = 179, |
|
_getfield = 180, |
|
_putfield = 181, |
|
_invokevirtual = 182, |
|
_invokespecial = 183, |
|
_invokestatic = 184, |
|
_invokeinterface = 185, |
|
_invokedynamic = 186, |
|
_new = 187, |
|
_newarray = 188, |
|
_anewarray = 189, |
|
_arraylength = 190, |
|
_athrow = 191, |
|
_checkcast = 192, |
|
_instanceof = 193, |
|
_monitorenter = 194, |
|
_monitorexit = 195, |
|
_wide = 196, |
|
_multianewarray = 197, |
|
_ifnull = 198, |
|
_ifnonnull = 199, |
|
_goto_w = 200, |
|
_jsr_w = 201, |
|
_bytecode_limit = 202; |
|
|
|
|
|
public final static int _end_marker = 255; |
|
|
|
public final static int _byte_escape = 254; |
|
public final static int _ref_escape = 253; |
|
|
|
// Self-relative pseudo-opcodes for better compression. |
|
// A "linker op" is a bytecode which links to a class member. |
|
// (But in what follows, "invokeinterface" ops are excluded.) |
|
// |
|
// A "self linker op" is a variant bytecode which works only |
|
// with the current class or its super. Because the number of |
|
// possible targets is small, it admits a more compact encoding. |
|
// Self linker ops are allowed to absorb a previous "aload_0" op. |
|
// There are (7 * 4) self linker ops (super or not, aload_0 or not). |
|
// |
|
// For simplicity, we define the full symmetric set of variants. |
|
// However, some of them are relatively useless. |
|
|
|
public final static int _first_linker_op = _getstatic; |
|
public final static int _last_linker_op = _invokestatic; |
|
public final static int _num_linker_ops = (_last_linker_op - _first_linker_op) + 1; |
|
public final static int _self_linker_op = _bytecode_limit; |
|
public final static int _self_linker_aload_flag = 1*_num_linker_ops; |
|
public final static int _self_linker_super_flag = 2*_num_linker_ops; |
|
public final static int _self_linker_limit = _self_linker_op + 4*_num_linker_ops; |
|
// An "invoke init" op is a variant of invokespecial which works |
|
// only with the method name "<init>". There are variants which |
|
// link to the current class, the super class, or the class of the |
|
// immediately previous "newinstance" op. There are 3 of these ops. |
|
// They all take method signature references as operands. |
|
|
|
public final static int _invokeinit_op = _self_linker_limit; |
|
public final static int _invokeinit_self_option = 0; |
|
public final static int _invokeinit_super_option = 1; |
|
public final static int _invokeinit_new_option = 2; |
|
public final static int _invokeinit_limit = _invokeinit_op+3; |
|
|
|
public final static int _pseudo_instruction_limit = _invokeinit_limit; |
|
// linker variant limit == 202+(7*4)+3 == 233 |
|
|
|
// Ldc variants support strongly typed references to constants. |
|
// This lets us index constant pool entries completely according to tag, |
|
// which is a great simplification. |
|
// Ldc variants gain us only 0.007% improvement in compression ratio, |
|
|
|
public final static int _xldc_op = _invokeinit_limit; |
|
public final static int _sldc = _ldc; |
|
public final static int _cldc = _xldc_op+0; |
|
public final static int _ildc = _xldc_op+1; |
|
public final static int _fldc = _xldc_op+2; |
|
public final static int _sldc_w = _ldc_w; |
|
public final static int _cldc_w = _xldc_op+3; |
|
public final static int _ildc_w = _xldc_op+4; |
|
public final static int _fldc_w = _xldc_op+5; |
|
public final static int _lldc2_w = _ldc2_w; |
|
public final static int _dldc2_w = _xldc_op+6; |
|
|
|
public final static int _qldc = _xldc_op+7; |
|
public final static int _qldc_w = _xldc_op+8; |
|
public final static int _xldc_limit = _xldc_op+9; |
|
|
|
|
|
public final static int _invoke_int_op = _xldc_limit; |
|
public final static int _invokespecial_int = _invoke_int_op+0; |
|
public final static int _invokestatic_int = _invoke_int_op+1; |
|
public final static int _invoke_int_limit = _invoke_int_op+2; |
|
} |