jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java
changeset 32649 2ee9017c7597
parent 25859 3317bb8137f4
child 38421 f75f729fdc5c
equal deleted inserted replaced
32648:1fa861caf840 32649:2ee9017c7597
    34  */
    34  */
    35 class Constants {
    35 class Constants {
    36 
    36 
    37     private Constants(){}
    37     private Constants(){}
    38 
    38 
    39     public final static int JAVA_MAGIC = 0xCAFEBABE;
    39     public static final int JAVA_MAGIC = 0xCAFEBABE;
    40 
    40 
    41     /*
    41     /*
    42         Java Class Version numbers history
    42         Java Class Version numbers history
    43         1.0 to 1.3.X 45,3
    43         1.0 to 1.3.X 45,3
    44         1.4 to 1.4.X 46,0
    44         1.4 to 1.4.X 46,0
    46         1.6 to 1.5.x 50,0
    46         1.6 to 1.5.x 50,0
    47         1.7 to 1.6.x 51,0
    47         1.7 to 1.6.x 51,0
    48         1.8 to 1.7.x 52,0
    48         1.8 to 1.7.x 52,0
    49     */
    49     */
    50 
    50 
    51     public final static Package.Version JAVA_MIN_CLASS_VERSION =
    51     public static final Package.Version JAVA_MIN_CLASS_VERSION =
    52             Package.Version.of(45, 03);
    52             Package.Version.of(45, 03);
    53 
    53 
    54     public final static Package.Version JAVA5_MAX_CLASS_VERSION =
    54     public static final Package.Version JAVA5_MAX_CLASS_VERSION =
    55             Package.Version.of(49, 00);
    55             Package.Version.of(49, 00);
    56 
    56 
    57     public final static Package.Version JAVA6_MAX_CLASS_VERSION =
    57     public static final Package.Version JAVA6_MAX_CLASS_VERSION =
    58             Package.Version.of(50, 00);
    58             Package.Version.of(50, 00);
    59 
    59 
    60     public final static Package.Version JAVA7_MAX_CLASS_VERSION =
    60     public static final Package.Version JAVA7_MAX_CLASS_VERSION =
    61             Package.Version.of(51, 00);
    61             Package.Version.of(51, 00);
    62 
    62 
    63     public final static Package.Version JAVA8_MAX_CLASS_VERSION =
    63     public static final Package.Version JAVA8_MAX_CLASS_VERSION =
    64             Package.Version.of(52, 00);
    64             Package.Version.of(52, 00);
    65 
    65 
    66     public final static int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
    66     public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
    67 
    67 
    68     public final static Package.Version JAVA5_PACKAGE_VERSION =
    68     public static final Package.Version JAVA5_PACKAGE_VERSION =
    69             Package.Version.of(150, 7);
    69             Package.Version.of(150, 7);
    70 
    70 
    71     public final static Package.Version JAVA6_PACKAGE_VERSION =
    71     public static final Package.Version JAVA6_PACKAGE_VERSION =
    72             Package.Version.of(160, 1);
    72             Package.Version.of(160, 1);
    73 
    73 
    74     public final static Package.Version JAVA7_PACKAGE_VERSION =
    74     public static final Package.Version JAVA7_PACKAGE_VERSION =
    75             Package.Version.of(170, 1);
    75             Package.Version.of(170, 1);
    76 
    76 
    77     public final static Package.Version JAVA8_PACKAGE_VERSION =
    77     public static final Package.Version JAVA8_PACKAGE_VERSION =
    78             Package.Version.of(171, 0);
    78             Package.Version.of(171, 0);
    79 
    79 
    80     // upper limit, should point to the latest class version
    80     // upper limit, should point to the latest class version
    81     public final static Package.Version JAVA_MAX_CLASS_VERSION =
    81     public static final Package.Version JAVA_MAX_CLASS_VERSION =
    82             JAVA8_MAX_CLASS_VERSION;
    82             JAVA8_MAX_CLASS_VERSION;
    83 
    83 
    84     // upper limit should point to the latest package version, for version info!.
    84     // upper limit should point to the latest package version, for version info!.
    85     public final static Package.Version MAX_PACKAGE_VERSION =
    85     public static final Package.Version MAX_PACKAGE_VERSION =
    86             JAVA7_PACKAGE_VERSION;
    86             JAVA7_PACKAGE_VERSION;
    87 
    87 
    88     public final static int CONSTANT_POOL_INDEX_LIMIT  = 0x10000;
    88     public static final int CONSTANT_POOL_INDEX_LIMIT  = 0x10000;
    89     public final static int CONSTANT_POOL_NARROW_LIMIT = 0x00100;
    89     public static final int CONSTANT_POOL_NARROW_LIMIT = 0x00100;
    90 
    90 
    91     public final static String JAVA_SIGNATURE_CHARS = "BSCIJFDZLV([";
    91     public static final String JAVA_SIGNATURE_CHARS = "BSCIJFDZLV([";
    92 
    92 
    93     public final static byte CONSTANT_Utf8 = 1;
    93     public static final byte CONSTANT_Utf8 = 1;
    94     public final static byte CONSTANT_unused2 = 2;  // unused, was Unicode
    94     public static final byte CONSTANT_unused2 = 2;  // unused, was Unicode
    95     public final static byte CONSTANT_Integer = 3;
    95     public static final byte CONSTANT_Integer = 3;
    96     public final static byte CONSTANT_Float = 4;
    96     public static final byte CONSTANT_Float = 4;
    97     public final static byte CONSTANT_Long = 5;
    97     public static final byte CONSTANT_Long = 5;
    98     public final static byte CONSTANT_Double = 6;
    98     public static final byte CONSTANT_Double = 6;
    99     public final static byte CONSTANT_Class = 7;
    99     public static final byte CONSTANT_Class = 7;
   100     public final static byte CONSTANT_String = 8;
   100     public static final byte CONSTANT_String = 8;
   101     public final static byte CONSTANT_Fieldref = 9;
   101     public static final byte CONSTANT_Fieldref = 9;
   102     public final static byte CONSTANT_Methodref = 10;
   102     public static final byte CONSTANT_Methodref = 10;
   103     public final static byte CONSTANT_InterfaceMethodref = 11;
   103     public static final byte CONSTANT_InterfaceMethodref = 11;
   104     public final static byte CONSTANT_NameandType = 12;
   104     public static final byte CONSTANT_NameandType = 12;
   105     public final static byte CONSTANT_unused13 = 13;
   105     public static final byte CONSTANT_unused13 = 13;
   106     public final static byte CONSTANT_unused14 = 14;
   106     public static final byte CONSTANT_unused14 = 14;
   107     public final static byte CONSTANT_MethodHandle = 15;
   107     public static final byte CONSTANT_MethodHandle = 15;
   108     public final static byte CONSTANT_MethodType = 16;
   108     public static final byte CONSTANT_MethodType = 16;
   109     public final static byte CONSTANT_unused17 = 17;  // unused
   109     public static final byte CONSTANT_unused17 = 17;  // unused
   110     public final static byte CONSTANT_InvokeDynamic = 18;
   110     public static final byte CONSTANT_InvokeDynamic = 18;
   111 
   111 
   112     // pseudo-constants:
   112     // pseudo-constants:
   113     public final static byte CONSTANT_None = 0;
   113     public static final byte CONSTANT_None = 0;
   114     public final static byte CONSTANT_Signature = CONSTANT_unused13;
   114     public static final byte CONSTANT_Signature = CONSTANT_unused13;
   115     public final static byte CONSTANT_BootstrapMethod = CONSTANT_unused17; // used only in InvokeDynamic constants
   115     public static final byte CONSTANT_BootstrapMethod = CONSTANT_unused17; // used only in InvokeDynamic constants
   116     public final static byte CONSTANT_Limit = 19;
   116     public static final byte CONSTANT_Limit = 19;
   117 
   117 
   118     public final static byte CONSTANT_All = 50;  // combined global map
   118     public static final byte CONSTANT_All = 50;  // combined global map
   119     public final static byte CONSTANT_LoadableValue = 51; // used for 'KL' and qldc operands
   119     public static final byte CONSTANT_LoadableValue = 51; // used for 'KL' and qldc operands
   120     public final static byte CONSTANT_AnyMember = 52; // union of refs to field or (interface) method
   120     public static final byte CONSTANT_AnyMember = 52; // union of refs to field or (interface) method
   121     public final static byte CONSTANT_FieldSpecific = 53; // used only for 'KQ' ConstantValue attrs
   121     public static final byte CONSTANT_FieldSpecific = 53; // used only for 'KQ' ConstantValue attrs
   122     public final static byte CONSTANT_GroupFirst = CONSTANT_All;
   122     public static final byte CONSTANT_GroupFirst = CONSTANT_All;
   123     public final static byte CONSTANT_GroupLimit = CONSTANT_FieldSpecific+1;
   123     public static final byte CONSTANT_GroupLimit = CONSTANT_FieldSpecific+1;
   124 
   124 
   125     // CONSTANT_MethodHandle reference kinds
   125     // CONSTANT_MethodHandle reference kinds
   126     public final static byte REF_getField = 1;
   126     public static final byte REF_getField = 1;
   127     public final static byte REF_getStatic = 2;
   127     public static final byte REF_getStatic = 2;
   128     public final static byte REF_putField = 3;
   128     public static final byte REF_putField = 3;
   129     public final static byte REF_putStatic = 4;
   129     public static final byte REF_putStatic = 4;
   130     public final static byte REF_invokeVirtual = 5;
   130     public static final byte REF_invokeVirtual = 5;
   131     public final static byte REF_invokeStatic = 6;
   131     public static final byte REF_invokeStatic = 6;
   132     public final static byte REF_invokeSpecial = 7;
   132     public static final byte REF_invokeSpecial = 7;
   133     public final static byte REF_newInvokeSpecial = 8;
   133     public static final byte REF_newInvokeSpecial = 8;
   134     public final static byte REF_invokeInterface = 9;
   134     public static final byte REF_invokeInterface = 9;
   135 
   135 
   136     // pseudo-access bits
   136     // pseudo-access bits
   137     public final static int ACC_IC_LONG_FORM   = (1<<16); //for ic_flags
   137     public static final int ACC_IC_LONG_FORM   = (1<<16); //for ic_flags
   138 
   138 
   139     // attribute "context types"
   139     // attribute "context types"
   140     public static final int ATTR_CONTEXT_CLASS  = 0;
   140     public static final int ATTR_CONTEXT_CLASS  = 0;
   141     public static final int ATTR_CONTEXT_FIELD  = 1;
   141     public static final int ATTR_CONTEXT_FIELD  = 1;
   142     public static final int ATTR_CONTEXT_METHOD = 2;
   142     public static final int ATTR_CONTEXT_METHOD = 2;
   197     static final int VRM_PACKAGE = 1;
   197     static final int VRM_PACKAGE = 1;
   198 
   198 
   199     public static final int NO_MODTIME = 0;  // null modtime value
   199     public static final int NO_MODTIME = 0;  // null modtime value
   200 
   200 
   201     // some comstantly empty containers
   201     // some comstantly empty containers
   202     public final static int[]        noInts = {};
   202     public static final int[]        noInts = {};
   203     public final static byte[]       noBytes = {};
   203     public static final byte[]       noBytes = {};
   204     public final static Object[]     noValues = {};
   204     public static final Object[]     noValues = {};
   205     public final static String[]     noStrings = {};
   205     public static final String[]     noStrings = {};
   206     public final static List<Object> emptyList = Arrays.asList(noValues);
   206     public static final List<Object> emptyList = Arrays.asList(noValues);
   207 
   207 
   208     // meta-coding
   208     // meta-coding
   209     public final static int
   209     public static final int
   210         _meta_default = 0,
   210         _meta_default = 0,
   211         _meta_canon_min = 1,
   211         _meta_canon_min = 1,
   212         _meta_canon_max = 115,
   212         _meta_canon_max = 115,
   213         _meta_arb = 116,
   213         _meta_arb = 116,
   214         _meta_run = 117,
   214         _meta_run = 117,
   215         _meta_pop = 141,
   215         _meta_pop = 141,
   216         _meta_limit = 189;
   216         _meta_limit = 189;
   217 
   217 
   218     // bytecodes
   218     // bytecodes
   219     public final static int
   219     public static final int
   220         _nop                  =   0, // 0x00
   220         _nop                  =   0, // 0x00
   221         _aconst_null          =   1, // 0x01
   221         _aconst_null          =   1, // 0x01
   222         _iconst_m1            =   2, // 0x02
   222         _iconst_m1            =   2, // 0x02
   223         _iconst_0             =   3, // 0x03
   223         _iconst_0             =   3, // 0x03
   224         _iconst_1             =   4, // 0x04
   224         _iconst_1             =   4, // 0x04
   420         _goto_w               = 200, // 0xc8
   420         _goto_w               = 200, // 0xc8
   421         _jsr_w                = 201, // 0xc9
   421         _jsr_w                = 201, // 0xc9
   422         _bytecode_limit       = 202; // 0xca
   422         _bytecode_limit       = 202; // 0xca
   423 
   423 
   424     // End marker, used to terminate bytecode sequences:
   424     // End marker, used to terminate bytecode sequences:
   425     public final static int _end_marker = 255;
   425     public static final int _end_marker = 255;
   426     // Escapes:
   426     // Escapes:
   427     public final static int _byte_escape = 254;
   427     public static final int _byte_escape = 254;
   428     public final static int _ref_escape = 253;
   428     public static final int _ref_escape = 253;
   429 
   429 
   430     // Self-relative pseudo-opcodes for better compression.
   430     // Self-relative pseudo-opcodes for better compression.
   431     // A "linker op" is a bytecode which links to a class member.
   431     // A "linker op" is a bytecode which links to a class member.
   432     // (But in what follows, "invokeinterface" ops are excluded.)
   432     // (But in what follows, "invokeinterface" ops are excluded.)
   433     //
   433     //
   438     // There are (7 * 4) self linker ops (super or not, aload_0 or not).
   438     // There are (7 * 4) self linker ops (super or not, aload_0 or not).
   439     //
   439     //
   440     // For simplicity, we define the full symmetric set of variants.
   440     // For simplicity, we define the full symmetric set of variants.
   441     // However, some of them are relatively useless.
   441     // However, some of them are relatively useless.
   442     // Self linker ops are enabled by Pack.selfCallVariants (true).
   442     // Self linker ops are enabled by Pack.selfCallVariants (true).
   443     public final static int _first_linker_op = _getstatic;
   443     public static final int _first_linker_op = _getstatic;
   444     public final static int _last_linker_op  = _invokestatic;
   444     public static final int _last_linker_op  = _invokestatic;
   445     public final static int _num_linker_ops  = (_last_linker_op - _first_linker_op) + 1;
   445     public static final int _num_linker_ops  = (_last_linker_op - _first_linker_op) + 1;
   446     public final static int _self_linker_op  = _bytecode_limit;
   446     public static final int _self_linker_op  = _bytecode_limit;
   447     public final static int _self_linker_aload_flag = 1*_num_linker_ops;
   447     public static final int _self_linker_aload_flag = 1*_num_linker_ops;
   448     public final static int _self_linker_super_flag = 2*_num_linker_ops;
   448     public static final int _self_linker_super_flag = 2*_num_linker_ops;
   449     public final static int _self_linker_limit = _self_linker_op + 4*_num_linker_ops;
   449     public static final int _self_linker_limit = _self_linker_op + 4*_num_linker_ops;
   450     // An "invoke init" op is a variant of invokespecial which works
   450     // An "invoke init" op is a variant of invokespecial which works
   451     // only with the method name "<init>".  There are variants which
   451     // only with the method name "<init>".  There are variants which
   452     // link to the current class, the super class, or the class of the
   452     // link to the current class, the super class, or the class of the
   453     // immediately previous "newinstance" op.  There are 3 of these ops.
   453     // immediately previous "newinstance" op.  There are 3 of these ops.
   454     // They all take method signature references as operands.
   454     // They all take method signature references as operands.
   455     // Invoke init ops are enabled by Pack.initCallVariants (true).
   455     // Invoke init ops are enabled by Pack.initCallVariants (true).
   456     public final static int _invokeinit_op = _self_linker_limit;
   456     public static final int _invokeinit_op = _self_linker_limit;
   457     public final static int _invokeinit_self_option = 0;
   457     public static final int _invokeinit_self_option = 0;
   458     public final static int _invokeinit_super_option = 1;
   458     public static final int _invokeinit_super_option = 1;
   459     public final static int _invokeinit_new_option = 2;
   459     public static final int _invokeinit_new_option = 2;
   460     public final static int _invokeinit_limit = _invokeinit_op+3;
   460     public static final int _invokeinit_limit = _invokeinit_op+3;
   461 
   461 
   462     public final static int _pseudo_instruction_limit = _invokeinit_limit;
   462     public static final int _pseudo_instruction_limit = _invokeinit_limit;
   463     // linker variant limit == 202+(7*4)+3 == 233
   463     // linker variant limit == 202+(7*4)+3 == 233
   464 
   464 
   465     // Ldc variants support strongly typed references to constants.
   465     // Ldc variants support strongly typed references to constants.
   466     // This lets us index constant pool entries completely according to tag,
   466     // This lets us index constant pool entries completely according to tag,
   467     // which is a great simplification.
   467     // which is a great simplification.
   468     // Ldc variants gain us only 0.007% improvement in compression ratio,
   468     // Ldc variants gain us only 0.007% improvement in compression ratio,
   469     // but they simplify the file format greatly.
   469     // but they simplify the file format greatly.
   470     public final static int _xldc_op = _invokeinit_limit;
   470     public static final int _xldc_op = _invokeinit_limit;
   471     public final static int _sldc = _ldc;  // previously named _aldc
   471     public static final int _sldc = _ldc;  // previously named _aldc
   472     public final static int _cldc = _xldc_op+0;
   472     public static final int _cldc = _xldc_op+0;
   473     public final static int _ildc = _xldc_op+1;
   473     public static final int _ildc = _xldc_op+1;
   474     public final static int _fldc = _xldc_op+2;
   474     public static final int _fldc = _xldc_op+2;
   475     public final static int _sldc_w = _ldc_w;  // previously named _aldc_w
   475     public static final int _sldc_w = _ldc_w;  // previously named _aldc_w
   476     public final static int _cldc_w = _xldc_op+3;
   476     public static final int _cldc_w = _xldc_op+3;
   477     public final static int _ildc_w = _xldc_op+4;
   477     public static final int _ildc_w = _xldc_op+4;
   478     public final static int _fldc_w = _xldc_op+5;
   478     public static final int _fldc_w = _xldc_op+5;
   479     public final static int _lldc2_w = _ldc2_w;
   479     public static final int _lldc2_w = _ldc2_w;
   480     public final static int _dldc2_w = _xldc_op+6;
   480     public static final int _dldc2_w = _xldc_op+6;
   481     // anything other than primitive, string, or class must be handled with qldc:
   481     // anything other than primitive, string, or class must be handled with qldc:
   482     public final static int _qldc   = _xldc_op+7;
   482     public static final int _qldc   = _xldc_op+7;
   483     public final static int _qldc_w = _xldc_op+8;
   483     public static final int _qldc_w = _xldc_op+8;
   484     public final static int _xldc_limit = _xldc_op+9;
   484     public static final int _xldc_limit = _xldc_op+9;
   485 
   485 
   486     // handling of InterfaceMethodRef
   486     // handling of InterfaceMethodRef
   487     public final static int _invoke_int_op = _xldc_limit;
   487     public static final int _invoke_int_op = _xldc_limit;
   488     public final static int _invokespecial_int = _invoke_int_op+0;
   488     public static final int _invokespecial_int = _invoke_int_op+0;
   489     public final static int _invokestatic_int = _invoke_int_op+1;
   489     public static final int _invokestatic_int = _invoke_int_op+1;
   490     public final static int _invoke_int_limit = _invoke_int_op+2;
   490     public static final int _invoke_int_limit = _invoke_int_op+2;
   491 }
   491 }