1 /*
   2  * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.internal.classfile;
  26 
  27 import java.io.IOException;
  28 import java.lang.constant.ClassDesc;
  29 import java.nio.file.Files;
  30 import java.nio.file.Path;
  31 import java.util.function.Consumer;
  32 import java.util.function.Function;
  33 
  34 import jdk.internal.classfile.attribute.ModuleAttribute;
  35 import jdk.internal.classfile.attribute.UnknownAttribute;
  36 import jdk.internal.classfile.constantpool.ClassEntry;
  37 import jdk.internal.classfile.constantpool.ConstantPoolBuilder;
  38 import jdk.internal.classfile.constantpool.Utf8Entry;
  39 import jdk.internal.classfile.impl.ClassfileImpl;
  40 import jdk.internal.classfile.impl.TemporaryConstantPool;
  41 import java.lang.reflect.AccessFlag;
  42 import jdk.internal.classfile.attribute.CharacterRangeInfo;
  43 import jdk.internal.classfile.attribute.LocalVariableInfo;
  44 import jdk.internal.classfile.attribute.LocalVariableTypeInfo;
  45 import jdk.internal.classfile.instruction.ExceptionCatch;
  46 import static java.util.Objects.requireNonNull;
  47 
  48 /**
  49  * Represents a context for parsing, transforming, and generating classfiles.
  50  * A {@code Classfile} has a set of options that condition how parsing and
  51  * generation is done.
  52  */
  53 public sealed interface Classfile
  54         permits ClassfileImpl {
  55 
  56     /**
  57      * {@return a context with default options}
  58      */
  59     static Classfile of() {
  60         return ClassfileImpl.DEFAULT_CONTEXT;
  61     }
  62 
  63     /**
  64      * {@return a new context with options altered from the default}
  65      * @param options the desired processing options
  66      */
  67     static Classfile of(Option... options) {
  68         return of().withOptions(options);
  69     }
  70 
  71     /**
  72      * {@return a copy of the context with altered options}
  73      * @param options the desired processing options
  74      */
  75     Classfile withOptions(Option... options);
  76 
  77     /**
  78      * An option that affects the parsing and writing of classfiles.
  79      */
  80     sealed interface Option {
  81     }
  82 
  83     /**
  84      * Option describing attribute mappers for custom attributes.
  85      * Default is only to process standard attributes.
  86      */
  87     sealed interface AttributeMapperOption extends Option
  88             permits ClassfileImpl.AttributeMapperOptionImpl {
  89 
  90         /**
  91          * {@return an option describing attribute mappers for custom attributes}
  92          * @param attributeMapper a function mapping attribute names to attribute mappers
  93          */
  94         static AttributeMapperOption of(Function<Utf8Entry, AttributeMapper<?>> attributeMapper) {
  95             requireNonNull(attributeMapper);
  96             return new ClassfileImpl.AttributeMapperOptionImpl(attributeMapper);
  97         }
  98 
  99         /**
 100          * {@return the function mapping attribute names to attribute mappers}
 101          */
 102         Function<Utf8Entry, AttributeMapper<?>> attributeMapper();
 103     }
 104 
 105     /**
 106      * Option describing the class hierarchy resolver to use when generating
 107      * stack maps.
 108      */
 109     sealed interface ClassHierarchyResolverOption extends Option
 110             permits ClassfileImpl.ClassHierarchyResolverOptionImpl {
 111 
 112         /**
 113          * {@return an option describing the class hierarchy resolver to use when
 114          * generating stack maps}
 115          * @param classHierarchyResolver the resolver
 116          */
 117         static ClassHierarchyResolverOption of(ClassHierarchyResolver classHierarchyResolver) {
 118             requireNonNull(classHierarchyResolver);
 119             return new ClassfileImpl.ClassHierarchyResolverOptionImpl(classHierarchyResolver);
 120         }
 121 
 122         /**
 123          * {@return the class hierarchy resolver}
 124          */
 125         ClassHierarchyResolver classHierarchyResolver();
 126     }
 127 
 128     /**
 129      * Option describing whether to preserve the original constant pool when
 130      * transforming a classfile.  Reusing the constant pool enables significant
 131      * optimizations in processing time and minimizes differences between the
 132      * original and transformed classfile, but may result in a bigger classfile
 133      * when a classfile is significantly transformed.
 134      * Default is {@code SHARED_POOL} to preserve the original constant
 135      * pool.
 136      */
 137     enum ConstantPoolSharingOption implements Option {
 138 
 139         /** Preserves the original constant pool when transforming classfile */
 140         SHARED_POOL,
 141 
 142         /** Creates a new constant pool when transforming classfile */
 143         NEW_POOL
 144     }
 145 
 146     /**
 147      * Option describing whether or not to patch out unreachable code.
 148      * Default is {@code PATCH_DEAD_CODE} to automatically patch out unreachable
 149      * code with NOPs.
 150      */
 151     enum DeadCodeOption implements Option {
 152 
 153         /** Patch unreachable code */
 154         PATCH_DEAD_CODE,
 155 
 156         /** Keep the unreachable code */
 157         KEEP_DEAD_CODE
 158     }
 159 
 160     /**
 161      * Option describing whether or not to filter unresolved labels.
 162      * Default is {@code FAIL_ON_DEAD_LABELS} to throw IllegalStateException
 163      * when any {@link ExceptionCatch}, {@link LocalVariableInfo},
 164      * {@link LocalVariableTypeInfo}, or {@link CharacterRangeInfo}
 165      * reference to unresolved {@link Label} during bytecode serialization.
 166      * Setting this option to {@code DROP_DEAD_LABELS} filters the above
 167      * elements instead.
 168      */
 169     enum DeadLabelsOption implements Option {
 170 
 171         /** Fail on unresolved labels */
 172         FAIL_ON_DEAD_LABELS,
 173 
 174         /** Filter unresolved labels */
 175         DROP_DEAD_LABELS
 176     }
 177 
 178     /**
 179      * Option describing whether to process or discard debug elements.
 180      * Debug elements include the local variable table, local variable type
 181      * table, and character range table.  Discarding debug elements may
 182      * reduce the overhead of parsing or transforming classfiles.
 183      * Default is {@code PASS_DEBUG} to process debug elements.
 184      */
 185     enum DebugElementsOption implements Option {
 186 
 187         /** Process debug elements */
 188         PASS_DEBUG,
 189 
 190         /** Drop debug elements */
 191         DROP_DEBUG
 192     }
 193 
 194     /**
 195      * Option describing whether to process or discard line numbers.
 196      * Discarding line numbers may reduce the overhead of parsing or transforming
 197      * classfiles.
 198      * Default is {@code PASS_LINE_NUMBERS} to process line numbers.
 199      */
 200     enum LineNumbersOption implements Option {
 201 
 202         /** Process line numbers */
 203         PASS_LINE_NUMBERS,
 204 
 205         /** Drop line numbers */
 206         DROP_LINE_NUMBERS;
 207     }
 208 
 209     /**
 210      * Option describing whether or not to automatically rewrite short jumps to
 211      * long when necessary.
 212      * Default is {@code FIX_SHORT_JUMPS} to automatically rewrite jump
 213      * instructions.
 214      */
 215     enum ShortJumpsOption implements Option {
 216 
 217         /** Automatically convert short jumps to long when necessary */
 218         FIX_SHORT_JUMPS,
 219 
 220         /** Fail if short jump overflows */
 221         FAIL_ON_SHORT_JUMPS
 222     }
 223 
 224     /**
 225      * Option describing whether or not to generate stackmaps.
 226      * Default is {@code STACK_MAPS_WHEN_REQUIRED} to generate stack
 227      * maps for {@link #JAVA_6_VERSION} or above, where specifically for
 228      * {@link #JAVA_6_VERSION} the stack maps may not be generated.
 229      * @jvms 4.10.1 Verification by Type Checking
 230      */
 231     enum StackMapsOption implements Option {
 232 
 233         /** Generate stack maps when required */
 234         STACK_MAPS_WHEN_REQUIRED,
 235 
 236         /** Always generate stack maps */
 237         GENERATE_STACK_MAPS,
 238 
 239         /** Drop stack maps from code */
 240         DROP_STACK_MAPS
 241     }
 242 
 243     /**
 244      * Option describing whether to process or discard unrecognized or problematic
 245      * original attributes when a class, record component, field, method or code is
 246      * transformed in its exploded form.
 247      * Default is {@code PASS_ALL_ATTRIBUTES} to process all original attributes.
 248      * @see AttributeMapper.AttributeStability
 249      */
 250     enum AttributesProcessingOption implements Option {
 251 
 252         /** Process all original attributes during transformation */
 253         PASS_ALL_ATTRIBUTES,
 254 
 255         /** Drop unknown attributes during transformation */
 256         DROP_UNKNOWN_ATTRIBUTES,
 257 
 258         /** Drop unknown and unstable original attributes during transformation */
 259         DROP_UNSTABLE_ATRIBUTES;
 260     }
 261 
 262     /**
 263      * Parse a classfile into a {@link ClassModel}.
 264      * @param bytes the bytes of the classfile
 265      * @return the class model
 266      */
 267     ClassModel parse(byte[] bytes);
 268 
 269     /**
 270      * Parse a classfile into a {@link ClassModel}.
 271      * @param path the path to the classfile
 272      * @return the class model
 273      * @throws java.io.IOException
 274      */
 275     default ClassModel parse(Path path) throws IOException {
 276         return parse(Files.readAllBytes(path));
 277     }
 278 
 279     /**
 280      * Build a classfile into a byte array.
 281      * @param thisClass the name of the class to build
 282      * @param handler a handler that receives a {@link ClassBuilder}
 283      * @return the classfile bytes
 284      */
 285     default byte[] build(ClassDesc thisClass,
 286                          Consumer<? super ClassBuilder> handler) {
 287         ConstantPoolBuilder pool = ConstantPoolBuilder.of();
 288         return build(pool.classEntry(thisClass), pool, handler);
 289     }
 290 
 291     /**
 292      * Build a classfile into a byte array using the provided constant pool
 293      * builder.
 294      *
 295      * @param thisClassEntry the name of the class to build
 296      * @param constantPool the constant pool builder
 297      * @param handler a handler that receives a {@link ClassBuilder}
 298      * @return the classfile bytes
 299      */
 300     byte[] build(ClassEntry thisClassEntry,
 301                  ConstantPoolBuilder constantPool,
 302                  Consumer<? super ClassBuilder> handler);
 303 
 304     /**
 305      * Build a classfile into a file.
 306      * @param path the path to the file to write
 307      * @param thisClass the name of the class to build
 308      * @param handler a handler that receives a {@link ClassBuilder}
 309      * @throws java.io.IOException
 310      */
 311     default void buildTo(Path path,
 312                          ClassDesc thisClass,
 313                          Consumer<ClassBuilder> handler) throws IOException {
 314         Files.write(path, build(thisClass, handler));
 315     }
 316 
 317     /**
 318      * Build a classfile into a file using the provided constant pool
 319      * builder.
 320      *
 321      * @param path the path to the file to write
 322      * @param thisClassEntry the name of the class to build
 323      * @param constantPool the constant pool builder
 324      * @param handler a handler that receives a {@link ClassBuilder}
 325      * @throws java.io.IOException
 326      */
 327     default void buildTo(Path path,
 328                          ClassEntry thisClassEntry,
 329                          ConstantPoolBuilder constantPool,
 330                          Consumer<? super ClassBuilder> handler) throws IOException {
 331         Files.write(path, build(thisClassEntry, constantPool, handler));
 332     }
 333 
 334     /**
 335      * Build a module descriptor into a byte array.
 336      * @param moduleAttribute the {@code Module} attribute
 337      * @return the classfile bytes
 338      */
 339     default byte[] buildModule(ModuleAttribute moduleAttribute) {
 340         return buildModule(moduleAttribute, clb -> {});
 341     }
 342 
 343     /**
 344      * Build a module descriptor into a byte array.
 345      * @param moduleAttribute the {@code Module} attribute
 346      * @param handler a handler that receives a {@link ClassBuilder}
 347      * @return the classfile bytes
 348      */
 349     default byte[] buildModule(ModuleAttribute moduleAttribute,
 350                                      Consumer<? super ClassBuilder> handler) {
 351         return build(ClassDesc.of("module-info"), clb -> {
 352             clb.withFlags(AccessFlag.MODULE);
 353             clb.with(moduleAttribute);
 354             handler.accept(clb);
 355         });
 356     }
 357 
 358     /**
 359      * Build a module descriptor into a file.
 360      * @param path the file to write
 361      * @param moduleAttribute the {@code Module} attribute
 362      * @throws java.io.IOException
 363      */
 364     default void buildModuleTo(Path path,
 365                                      ModuleAttribute moduleAttribute) throws IOException {
 366         buildModuleTo(path, moduleAttribute, clb -> {});
 367     }
 368 
 369     /**
 370      * Build a module descriptor into a file.
 371      * @param path the file to write
 372      * @param moduleAttribute the {@code Module} attribute
 373      * @param handler a handler that receives a {@link ClassBuilder}
 374      * @throws java.io.IOException
 375      */
 376     default void buildModuleTo(Path path,
 377                                      ModuleAttribute moduleAttribute,
 378                                      Consumer<? super ClassBuilder> handler) throws IOException {
 379         Files.write(path, buildModule(moduleAttribute, handler));
 380     }
 381 
 382     /**
 383      * Transform one classfile into a new classfile with the aid of a
 384      * {@link ClassTransform}.  The transform will receive each element of
 385      * this class, as well as a {@link ClassBuilder} for building the new class.
 386      * The transform is free to preserve, remove, or replace elements as it
 387      * sees fit.
 388      *
 389      * @implNote
 390      * This method behaves as if:
 391      * {@snippet lang=java :
 392      *     this.build(model.thisClass(), ConstantPoolBuilder.of(model),
 393      *                     b -> b.transform(model, transform));
 394      * }
 395      *
 396      * @param model the class model to transform
 397      * @param transform the transform
 398      * @return the bytes of the new class
 399      */
 400     default byte[] transform(ClassModel model, ClassTransform transform) {
 401         return transform(model, model.thisClass(), transform);
 402     }
 403 
 404     /**
 405      * Transform one classfile into a new classfile with the aid of a
 406      * {@link ClassTransform}.  The transform will receive each element of
 407      * this class, as well as a {@link ClassBuilder} for building the new class.
 408      * The transform is free to preserve, remove, or replace elements as it
 409      * sees fit.
 410      *
 411      * @param model the class model to transform
 412      * @param newClassName new class name
 413      * @param transform the transform
 414      * @return the bytes of the new class
 415      */
 416     default byte[] transform(ClassModel model, ClassDesc newClassName, ClassTransform transform) {
 417         return transform(model, TemporaryConstantPool.INSTANCE.classEntry(newClassName), transform);
 418     }
 419 
 420     /**
 421      * Transform one classfile into a new classfile with the aid of a
 422      * {@link ClassTransform}.  The transform will receive each element of
 423      * this class, as well as a {@link ClassBuilder} for building the new class.
 424      * The transform is free to preserve, remove, or replace elements as it
 425      * sees fit.
 426      *
 427      * @implNote
 428      * This method behaves as if:
 429      * {@snippet lang=java :
 430      *     this.build(newClassName, ConstantPoolBuilder.of(model),
 431      *                     b -> b.transform(model, transform));
 432      * }
 433      *
 434      * @param model the class model to transform
 435      * @param newClassName new class name
 436      * @param transform the transform
 437      * @return the bytes of the new class
 438      */
 439     byte[] transform(ClassModel model, ClassEntry newClassName, ClassTransform transform);
 440 
 441     /** 0xCAFEBABE */
 442     int MAGIC_NUMBER = 0xCAFEBABE;
 443 
 444     /** 0 */
 445     int NOP             = 0;
 446 
 447     /** 1 */
 448     int ACONST_NULL     = 1;
 449 
 450     /** 2 */
 451     int ICONST_M1       = 2;
 452 
 453     /** 3 */
 454     int ICONST_0        = 3;
 455 
 456     /** 4 */
 457     int ICONST_1        = 4;
 458 
 459     /** 5 */
 460     int ICONST_2        = 5;
 461 
 462     /** 6 */
 463     int ICONST_3        = 6;
 464 
 465     /** 7 */
 466     int ICONST_4        = 7;
 467 
 468     /** 8 */
 469     int ICONST_5        = 8;
 470 
 471     /** 9 */
 472     int LCONST_0        = 9;
 473 
 474     /** 10 */
 475     int LCONST_1        = 10;
 476 
 477     /** 11 */
 478     int FCONST_0        = 11;
 479 
 480     /** 12 */
 481     int FCONST_1        = 12;
 482 
 483     /** 13 */
 484     int FCONST_2        = 13;
 485 
 486     /** 14 */
 487     int DCONST_0        = 14;
 488 
 489     /** 15 */
 490     int DCONST_1        = 15;
 491 
 492     /** 16 */
 493     int BIPUSH          = 16;
 494 
 495     /** 17 */
 496     int SIPUSH          = 17;
 497 
 498     /** 18 */
 499     int LDC             = 18;
 500 
 501     /** 19 */
 502     int LDC_W           = 19;
 503 
 504     /** 20 */
 505     int LDC2_W          = 20;
 506 
 507     /** 21 */
 508     int ILOAD           = 21;
 509 
 510     /** 22 */
 511     int LLOAD           = 22;
 512 
 513     /** 23 */
 514     int FLOAD           = 23;
 515 
 516     /** 24 */
 517     int DLOAD           = 24;
 518 
 519     /** 25 */
 520     int ALOAD           = 25;
 521 
 522     /** 26 */
 523     int ILOAD_0         = 26;
 524 
 525     /** 27 */
 526     int ILOAD_1         = 27;
 527 
 528     /** 28 */
 529     int ILOAD_2         = 28;
 530 
 531     /** 29 */
 532     int ILOAD_3         = 29;
 533 
 534     /** 30 */
 535     int LLOAD_0         = 30;
 536 
 537     /** 31 */
 538     int LLOAD_1         = 31;
 539 
 540     /** 32 */
 541     int LLOAD_2         = 32;
 542 
 543     /** 33 */
 544     int LLOAD_3         = 33;
 545 
 546     /** 34 */
 547     int FLOAD_0         = 34;
 548 
 549     /** 35 */
 550     int FLOAD_1         = 35;
 551 
 552     /** 36 */
 553     int FLOAD_2         = 36;
 554 
 555     /** 37 */
 556     int FLOAD_3         = 37;
 557 
 558     /** 38 */
 559     int DLOAD_0         = 38;
 560 
 561     /** 39 */
 562     int DLOAD_1         = 39;
 563 
 564     /** 40 */
 565     int DLOAD_2         = 40;
 566 
 567     /** 41 */
 568     int DLOAD_3         = 41;
 569 
 570     /** 42 */
 571     int ALOAD_0         = 42;
 572 
 573     /** 43 */
 574     int ALOAD_1         = 43;
 575 
 576     /** 44 */
 577     int ALOAD_2         = 44;
 578 
 579     /** 45 */
 580     int ALOAD_3         = 45;
 581 
 582     /** 46 */
 583     int IALOAD          = 46;
 584 
 585     /** 47 */
 586     int LALOAD          = 47;
 587 
 588     /** 48 */
 589     int FALOAD          = 48;
 590 
 591     /** 49 */
 592     int DALOAD          = 49;
 593 
 594     /** 50 */
 595     int AALOAD          = 50;
 596 
 597     /** 51 */
 598     int BALOAD          = 51;
 599 
 600     /** 52 */
 601     int CALOAD          = 52;
 602 
 603     /** 53 */
 604     int SALOAD          = 53;
 605 
 606     /** 54 */
 607     int ISTORE          = 54;
 608 
 609     /** 55 */
 610     int LSTORE          = 55;
 611 
 612     /** 56 */
 613     int FSTORE          = 56;
 614 
 615     /** 57 */
 616     int DSTORE          = 57;
 617 
 618     /** 58 */
 619     int ASTORE          = 58;
 620 
 621     /** 59 */
 622     int ISTORE_0        = 59;
 623 
 624     /** 60 */
 625     int ISTORE_1        = 60;
 626 
 627     /** 61 */
 628     int ISTORE_2        = 61;
 629 
 630     /** 62 */
 631     int ISTORE_3        = 62;
 632 
 633     /** 63 */
 634     int LSTORE_0        = 63;
 635 
 636     /** 64 */
 637     int LSTORE_1        = 64;
 638 
 639     /** 65 */
 640     int LSTORE_2        = 65;
 641 
 642     /** 66 */
 643     int LSTORE_3        = 66;
 644 
 645     /** 67 */
 646     int FSTORE_0        = 67;
 647 
 648     /** 68 */
 649     int FSTORE_1        = 68;
 650 
 651     /** 69 */
 652     int FSTORE_2        = 69;
 653 
 654     /** 70 */
 655     int FSTORE_3        = 70;
 656 
 657     /** 71 */
 658     int DSTORE_0        = 71;
 659 
 660     /** 72 */
 661     int DSTORE_1        = 72;
 662 
 663     /** 73 */
 664     int DSTORE_2        = 73;
 665 
 666     /** 74 */
 667     int DSTORE_3        = 74;
 668 
 669     /** 75 */
 670     int ASTORE_0        = 75;
 671 
 672     /** 76 */
 673     int ASTORE_1        = 76;
 674 
 675     /** 77 */
 676     int ASTORE_2        = 77;
 677 
 678     /** 78 */
 679     int ASTORE_3        = 78;
 680 
 681     /** 79 */
 682     int IASTORE         = 79;
 683 
 684     /** 80 */
 685     int LASTORE         = 80;
 686 
 687     /** 81 */
 688     int FASTORE         = 81;
 689 
 690     /** 82 */
 691     int DASTORE         = 82;
 692 
 693     /** 83 */
 694     int AASTORE         = 83;
 695 
 696     /** 84 */
 697     int BASTORE         = 84;
 698 
 699     /** 85 */
 700     int CASTORE         = 85;
 701 
 702     /** 86 */
 703     int SASTORE         = 86;
 704 
 705     /** 87 */
 706     int POP             = 87;
 707 
 708     /** 88 */
 709     int POP2            = 88;
 710 
 711     /** 89 */
 712     int DUP             = 89;
 713 
 714     /** 90 */
 715     int DUP_X1          = 90;
 716 
 717     /** 91 */
 718     int DUP_X2          = 91;
 719 
 720     /** 92 */
 721     int DUP2            = 92;
 722 
 723     /** 93 */
 724     int DUP2_X1         = 93;
 725 
 726     /** 94 */
 727     int DUP2_X2         = 94;
 728 
 729     /** 95 */
 730     int SWAP            = 95;
 731 
 732     /** 96 */
 733     int IADD            = 96;
 734 
 735     /** 97 */
 736     int LADD            = 97;
 737 
 738     /** 98 */
 739     int FADD            = 98;
 740 
 741     /** 99 */
 742     int DADD            = 99;
 743 
 744     /** 100 */
 745     int ISUB            = 100;
 746 
 747     /** 101 */
 748     int LSUB            = 101;
 749 
 750     /** 102 */
 751     int FSUB            = 102;
 752 
 753     /** 103 */
 754     int DSUB            = 103;
 755 
 756     /** 104 */
 757     int IMUL            = 104;
 758 
 759     /** 105 */
 760     int LMUL            = 105;
 761 
 762     /** 106 */
 763     int FMUL            = 106;
 764 
 765     /** 107 */
 766     int DMUL            = 107;
 767 
 768     /** 108 */
 769     int IDIV            = 108;
 770 
 771     /** 109 */
 772     int LDIV            = 109;
 773 
 774     /** 110 */
 775     int FDIV            = 110;
 776 
 777     /** 111 */
 778     int DDIV            = 111;
 779 
 780     /** 112 */
 781     int IREM            = 112;
 782 
 783     /** 113 */
 784     int LREM            = 113;
 785 
 786     /** 114 */
 787     int FREM            = 114;
 788 
 789     /** 115 */
 790     int DREM            = 115;
 791 
 792     /** 116 */
 793     int INEG            = 116;
 794 
 795     /** 117 */
 796     int LNEG            = 117;
 797 
 798     /** 118 */
 799     int FNEG            = 118;
 800 
 801     /** 119 */
 802     int DNEG            = 119;
 803 
 804     /** 120 */
 805     int ISHL            = 120;
 806 
 807     /** 121 */
 808     int LSHL            = 121;
 809 
 810     /** 122 */
 811     int ISHR            = 122;
 812 
 813     /** 123 */
 814     int LSHR            = 123;
 815 
 816     /** 124 */
 817     int IUSHR           = 124;
 818 
 819     /** 125 */
 820     int LUSHR           = 125;
 821 
 822     /** 126 */
 823     int IAND            = 126;
 824 
 825     /** 127 */
 826     int LAND            = 127;
 827 
 828     /** 128 */
 829     int IOR             = 128;
 830 
 831     /** 129 */
 832     int LOR             = 129;
 833 
 834     /** 130 */
 835     int IXOR            = 130;
 836 
 837     /** 131 */
 838     int LXOR            = 131;
 839 
 840     /** 132 */
 841     int IINC            = 132;
 842 
 843     /** 133 */
 844     int I2L             = 133;
 845 
 846     /** 134 */
 847     int I2F             = 134;
 848 
 849     /** 135 */
 850     int I2D             = 135;
 851 
 852     /** 136 */
 853     int L2I             = 136;
 854 
 855     /** 137 */
 856     int L2F             = 137;
 857 
 858     /** 138 */
 859     int L2D             = 138;
 860 
 861     /** 139 */
 862     int F2I             = 139;
 863 
 864     /** 140 */
 865     int F2L             = 140;
 866 
 867     /** 141 */
 868     int F2D             = 141;
 869 
 870     /** 142 */
 871     int D2I             = 142;
 872 
 873     /** 143 */
 874     int D2L             = 143;
 875 
 876     /** 144 */
 877     int D2F             = 144;
 878 
 879     /** 145 */
 880     int I2B             = 145;
 881 
 882     /** 146 */
 883     int I2C             = 146;
 884 
 885     /** 147 */
 886     int I2S             = 147;
 887 
 888     /** 148 */
 889     int LCMP            = 148;
 890 
 891     /** 149 */
 892     int FCMPL           = 149;
 893 
 894     /** 150 */
 895     int FCMPG           = 150;
 896 
 897     /** 151 */
 898     int DCMPL           = 151;
 899 
 900     /** 152 */
 901     int DCMPG           = 152;
 902 
 903     /** 153 */
 904     int IFEQ            = 153;
 905 
 906     /** 154 */
 907     int IFNE            = 154;
 908 
 909     /** 155 */
 910     int IFLT            = 155;
 911 
 912     /** 156 */
 913     int IFGE            = 156;
 914 
 915     /** 157 */
 916     int IFGT            = 157;
 917 
 918     /** 158 */
 919     int IFLE            = 158;
 920 
 921     /** 159 */
 922     int IF_ICMPEQ       = 159;
 923 
 924     /** 160 */
 925     int IF_ICMPNE       = 160;
 926 
 927     /** 161 */
 928     int IF_ICMPLT       = 161;
 929 
 930     /** 162 */
 931     int IF_ICMPGE       = 162;
 932 
 933     /** 163 */
 934     int IF_ICMPGT       = 163;
 935 
 936     /** 164 */
 937     int IF_ICMPLE       = 164;
 938 
 939     /** 165 */
 940     int IF_ACMPEQ       = 165;
 941 
 942     /** 166 */
 943     int IF_ACMPNE       = 166;
 944 
 945     /** 167 */
 946     int GOTO            = 167;
 947 
 948     /** 168 */
 949     int JSR             = 168;
 950 
 951     /** 169 */
 952     int RET             = 169;
 953 
 954     /** 170 */
 955     int TABLESWITCH     = 170;
 956 
 957     /** 171 */
 958     int LOOKUPSWITCH    = 171;
 959 
 960     /** 172 */
 961     int IRETURN         = 172;
 962 
 963     /** 173 */
 964     int LRETURN         = 173;
 965 
 966     /** 174 */
 967     int FRETURN         = 174;
 968 
 969     /** 175 */
 970     int DRETURN         = 175;
 971 
 972     /** 176 */
 973     int ARETURN         = 176;
 974 
 975     /** 177 */
 976     int RETURN          = 177;
 977 
 978     /** 178 */
 979     int GETSTATIC       = 178;
 980 
 981     /** 179 */
 982     int PUTSTATIC       = 179;
 983 
 984     /** 180 */
 985     int GETFIELD        = 180;
 986 
 987     /** 181 */
 988     int PUTFIELD        = 181;
 989 
 990     /** 182 */
 991     int INVOKEVIRTUAL   = 182;
 992 
 993     /** 183 */
 994     int INVOKESPECIAL   = 183;
 995 
 996     /** 184 */
 997     int INVOKESTATIC    = 184;
 998 
 999     /** 185 */
1000     int INVOKEINTERFACE = 185;
1001 
1002     /** 186 */
1003     int INVOKEDYNAMIC   = 186;
1004 
1005     /** 187 */
1006     int NEW             = 187;
1007 
1008     /** 188 */
1009     int NEWARRAY        = 188;
1010 
1011     /** 189 */
1012     int ANEWARRAY       = 189;
1013 
1014     /** 190 */
1015     int ARRAYLENGTH     = 190;
1016 
1017     /** 191 */
1018     int ATHROW          = 191;
1019 
1020     /** 192 */
1021     int CHECKCAST       = 192;
1022 
1023     /** 193 */
1024     int INSTANCEOF      = 193;
1025 
1026     /** 194 */
1027     int MONITORENTER    = 194;
1028 
1029     /** 195 */
1030     int MONITOREXIT     = 195;
1031 
1032     /** 196 */
1033     int WIDE            = 196;
1034 
1035     /** 197 */
1036     int MULTIANEWARRAY  = 197;
1037 
1038     /** 198 */
1039     int IFNULL          = 198;
1040 
1041     /** 199 */
1042     int IFNONNULL       = 199;
1043 
1044     /** 200 */
1045     int GOTO_W          = 200;
1046 
1047     /** 201 */
1048     int JSR_W           = 201;
1049 
1050     /** 0x0001 */
1051     int ACC_PUBLIC = 0x0001;
1052 
1053     /** 0x0004 */
1054     int ACC_PROTECTED = 0x0004;
1055 
1056     /** 0x0002 */
1057     int ACC_PRIVATE = 0x0002;
1058 
1059     /** 0x0200 */
1060     int ACC_INTERFACE = 0x0200;
1061 
1062     /** 0x4000 */
1063     int ACC_ENUM = 0x4000;
1064 
1065     /** 0x2000 */
1066     int ACC_ANNOTATION = 0x2000;
1067 
1068     /** 0x0020 */
1069     int ACC_SUPER = 0x0020;
1070     int ACC_IDENTITY = 0x0020;
1071 
1072     /** 0x0400 */
1073     int ACC_ABSTRACT = 0x0400;
1074 
1075     /** 0x0040 */
1076     int ACC_VOLATILE = 0x0040;
1077     int ACC_VALUE    = 0x0040;
1078 
1079     /** 0x0080 */
1080     int ACC_TRANSIENT = 0x0080;
1081 
1082     /** 0x1000 */
1083     int ACC_SYNTHETIC = 0x1000;
1084 
1085     /** 0x0008 */
1086     int ACC_STATIC = 0x0008;
1087 
1088     /** 0x0010 */
1089     int ACC_FINAL = 0x0010;
1090 
1091     /** 0x0020 */
1092     int ACC_SYNCHRONIZED = 0x0020;
1093 
1094     /** 0x0040 */
1095     int ACC_BRIDGE = 0x0040;
1096 
1097     /** 0x0080 */
1098     int ACC_VARARGS = 0x0080;
1099 
1100     /** 0x0100 */
1101     int ACC_NATIVE = 0x0100;
1102 
1103     /** 0x0800 */
1104     int ACC_STRICT = 0x0800;
1105 
1106     /** 0x8000 */
1107     int ACC_MODULE = 0x8000;
1108 
1109     /** 0x20 */
1110     int ACC_OPEN = 0x20;
1111 
1112     /** 0x8000 */
1113     int ACC_MANDATED = 0x8000;
1114 
1115     /** 0x20 */
1116     int ACC_TRANSITIVE = 0x20;
1117 
1118     /** 0x40 */
1119     int ACC_STATIC_PHASE = 0x40;
1120 
1121     /** 0x0001 */
1122     int CRT_STATEMENT       = 0x0001;
1123 
1124     /** 0x0002 */
1125     int CRT_BLOCK           = 0x0002;
1126 
1127     /** 0x0004 */
1128     int CRT_ASSIGNMENT      = 0x0004;
1129 
1130     /** 0x0008 */
1131     int CRT_FLOW_CONTROLLER = 0x0008;
1132 
1133     /** 0x0010 */
1134     int CRT_FLOW_TARGET     = 0x0010;
1135 
1136     /** 0x0020 */
1137     int CRT_INVOKE          = 0x0020;
1138 
1139     /** 0x0040 */
1140     int CRT_CREATE          = 0x0040;
1141 
1142     /** 0x0080 */
1143     int CRT_BRANCH_TRUE     = 0x0080;
1144 
1145     /** 0x0100 */
1146     int CRT_BRANCH_FALSE    = 0x0100;
1147 
1148     /** 7 */
1149     int TAG_CLASS = 7;
1150 
1151     /** 17 */
1152     int TAG_CONSTANTDYNAMIC = 17;
1153 
1154     /** 6 */
1155     int TAG_DOUBLE = 6;
1156 
1157     /** 9 */
1158     int TAG_FIELDREF = 9;
1159 
1160     /** 4 */
1161     int TAG_FLOAT = 4;
1162 
1163     /** 3 */
1164     int TAG_INTEGER = 3;
1165 
1166     /** 11 */
1167     int TAG_INTERFACEMETHODREF = 11;
1168 
1169     /** 18 */
1170     int TAG_INVOKEDYNAMIC = 18;
1171 
1172     /** 5 */
1173     int TAG_LONG = 5;
1174 
1175     /** 15 */
1176     int TAG_METHODHANDLE = 15;
1177 
1178     /** 10 */
1179     int TAG_METHODREF = 10;
1180 
1181     /** 16 */
1182     int TAG_METHODTYPE = 16;
1183 
1184     /** 19 */
1185     int TAG_MODULE = 19;
1186 
1187     /** 12 */
1188     int TAG_NAMEANDTYPE = 12;
1189 
1190     /** 20 */
1191     int TAG_PACKAGE = 20;
1192 
1193     /** 8 */
1194     int TAG_STRING = 8;
1195 
1196     /** 2 */
1197     int TAG_UNICODE = 2;
1198 
1199     /** 1 */
1200     int TAG_UTF8 = 1;
1201 
1202     // annotation element values
1203 
1204     /** 'B' */
1205     char AEV_BYTE = 'B';
1206 
1207     /** 'C' */
1208     char AEV_CHAR = 'C';
1209 
1210     /** 'D' */
1211     char AEV_DOUBLE = 'D';
1212 
1213     /** 'F' */
1214     char AEV_FLOAT = 'F';
1215 
1216     /** 'I' */
1217     char AEV_INT = 'I';
1218 
1219     /** 'J' */
1220     char AEV_LONG = 'J';
1221 
1222     /** 'S' */
1223     char AEV_SHORT = 'S';
1224 
1225     /** 'Z' */
1226     char AEV_BOOLEAN = 'Z';
1227 
1228     /** 's' */
1229     char AEV_STRING = 's';
1230 
1231     /** 'e' */
1232     char AEV_ENUM = 'e';
1233 
1234     /** 'c' */
1235     char AEV_CLASS = 'c';
1236 
1237     /** '@' */
1238     char AEV_ANNOTATION = '@';
1239 
1240     /** '[' */
1241     char AEV_ARRAY = '[';
1242 
1243     //type annotations
1244 
1245     /** 0x00 */
1246     int TAT_CLASS_TYPE_PARAMETER = 0x00;
1247 
1248     /** 0x01 */
1249     int TAT_METHOD_TYPE_PARAMETER = 0x01;
1250 
1251     /** 0x10 */
1252     int TAT_CLASS_EXTENDS = 0x10;
1253 
1254     /** 0x11 */
1255     int TAT_CLASS_TYPE_PARAMETER_BOUND = 0x11;
1256 
1257     /** 0x12 */
1258     int TAT_METHOD_TYPE_PARAMETER_BOUND = 0x12;
1259 
1260     /** 0x13 */
1261     int TAT_FIELD = 0x13;
1262 
1263     /** 0x14 */
1264     int TAT_METHOD_RETURN = 0x14;
1265 
1266     /** 0x15 */
1267     int TAT_METHOD_RECEIVER = 0x15;
1268 
1269     /** 0x16 */
1270     int TAT_METHOD_FORMAL_PARAMETER = 0x16;
1271 
1272     /** 0x17 */
1273     int TAT_THROWS = 0x17;
1274 
1275     /** 0x40 */
1276     int TAT_LOCAL_VARIABLE = 0x40;
1277 
1278     /** 0x41 */
1279     int TAT_RESOURCE_VARIABLE = 0x41;
1280 
1281     /** 0x42 */
1282     int TAT_EXCEPTION_PARAMETER = 0x42;
1283 
1284     /** 0x43 */
1285     int TAT_INSTANCEOF = 0x43;
1286 
1287     /** 0x44 */
1288     int TAT_NEW = 0x44;
1289 
1290     /** 0x45 */
1291     int TAT_CONSTRUCTOR_REFERENCE = 0x45;
1292 
1293     /** 0x46 */
1294     int TAT_METHOD_REFERENCE = 0x46;
1295 
1296     /** 0x47 */
1297     int TAT_CAST = 0x47;
1298 
1299     /** 0x48 */
1300     int TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48;
1301 
1302     /** 0x49 */
1303     int TAT_METHOD_INVOCATION_TYPE_ARGUMENT = 0x49;
1304 
1305     /** 0x4A */
1306     int TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A;
1307 
1308     /** 0x4B */
1309     int TAT_METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B;
1310 
1311     //stackmap verification types
1312 
1313     /** 0 */
1314     int VT_TOP = 0;
1315 
1316     /** 1 */
1317     int VT_INTEGER = 1;
1318 
1319     /** 2 */
1320     int VT_FLOAT = 2;
1321 
1322     /** 3 */
1323     int VT_DOUBLE = 3;
1324 
1325     /** 4 */
1326     int VT_LONG = 4;
1327 
1328     /** 5 */
1329     int VT_NULL = 5;
1330 
1331     /** 6 */
1332     int VT_UNINITIALIZED_THIS = 6;
1333 
1334     /** 7 */
1335     int VT_OBJECT = 7;
1336 
1337     /** 8 */
1338     int VT_UNINITIALIZED = 8;
1339 
1340     /** ACC_PUBLIC */
1341     int DEFAULT_CLASS_FLAGS = ACC_PUBLIC;
1342 
1343     /** 45 */
1344     int JAVA_1_VERSION = 45;
1345 
1346     /** 46 */
1347     int JAVA_2_VERSION = 46;
1348 
1349     /** 47 */
1350     int JAVA_3_VERSION = 47;
1351 
1352     /** 48 */
1353     int JAVA_4_VERSION = 48;
1354 
1355     /** 49 */
1356     int JAVA_5_VERSION = 49;
1357 
1358     /** 50 */
1359     int JAVA_6_VERSION = 50;
1360 
1361     /** 51 */
1362     int JAVA_7_VERSION = 51;
1363 
1364     /** 52 */
1365     int JAVA_8_VERSION = 52;
1366 
1367     /** 53 */
1368     int JAVA_9_VERSION = 53;
1369 
1370     /** 54 */
1371     int JAVA_10_VERSION = 54;
1372 
1373     /** 55 */
1374     int JAVA_11_VERSION = 55;
1375 
1376     /** 56 */
1377     int JAVA_12_VERSION = 56;
1378 
1379     /** 57 */
1380     int JAVA_13_VERSION = 57;
1381 
1382     /** 58 */
1383     int JAVA_14_VERSION = 58;
1384 
1385     /** 59 */
1386     int JAVA_15_VERSION = 59;
1387 
1388     /** 60 */
1389     int JAVA_16_VERSION = 60;
1390 
1391     /** 61 */
1392     int JAVA_17_VERSION = 61;
1393 
1394     /** 62 */
1395     int JAVA_18_VERSION = 62;
1396 
1397     /** 63 */
1398     int JAVA_19_VERSION = 63;
1399 
1400     /** 64 */
1401     int JAVA_20_VERSION = 64;
1402 
1403     /** 65 */
1404     int JAVA_21_VERSION = 65;
1405 
1406     /** 66 */
1407     int JAVA_22_VERSION = 66;
1408 
1409     /**
1410      * A minor version number indicating a class uses preview features
1411      * of a Java SE version since 12, for major versions {@value
1412      * #JAVA_12_VERSION} and above.
1413      */
1414     int PREVIEW_MINOR_VERSION = 65535;
1415 
1416     /**
1417      * {@return the latest major Java version}
1418      */
1419     static int latestMajorVersion() {
1420         return JAVA_22_VERSION;
1421     }
1422 
1423     /**
1424      * {@return the latest minor Java version}
1425      */
1426     static int latestMinorVersion() {
1427         return 0;
1428     }
1429 
1430 }