From 994ac95e67e049b4391cb6bfb158b33b8723d6a7 Mon Sep 17 00:00:00 2001 From: "David M. Lloyd" Date: Thu, 12 Dec 2024 09:26:23 -0600 Subject: [PATCH] Update JDK --- jdk | 2 +- .../github/dmlloyd/classfile/ClassFile.java | 26 +- .../github/dmlloyd/classfile/CodeBuilder.java | 2 +- .../dmlloyd/classfile/CompoundElement.java | 12 + .../github/dmlloyd/classfile/Instruction.java | 13 +- .../io/github/dmlloyd/classfile/Label.java | 59 +- .../io/github/dmlloyd/classfile/Opcode.java | 1696 ++++++++++++++--- .../io/github/dmlloyd/classfile/TypeKind.java | 35 +- .../classfile/extras/constant/ModuleDesc.java | 2 +- .../classfile/impl/AccessFlagsImpl.java | 2 +- .../classfile/impl/BoundLocalVariable.java | 2 +- .../classfile/impl/CatchBuilderImpl.java | 2 +- .../dmlloyd/classfile/impl/EntryMap.java | 2 +- .../classfile/impl/InterfacesImpl.java | 2 +- .../dmlloyd/classfile/impl/LabelImpl.java | 2 +- .../classfile/impl/SuperclassImpl.java | 2 +- .../impl/verifier/VerificationBytecodes.java | 2 +- .../impl/verifier/VerificationTable.java | 2 +- .../impl/verifier/VerificationType.java | 2 +- .../instruction/ArrayLoadInstruction.java | 22 +- .../instruction/ArrayStoreInstruction.java | 22 +- .../instruction/BranchInstruction.java | 33 +- .../classfile/instruction/CharacterRange.java | 29 +- .../instruction/ConstantInstruction.java | 102 +- .../instruction/ConvertInstruction.java | 32 +- .../instruction/DiscontinuedInstruction.java | 98 +- .../classfile/instruction/ExceptionCatch.java | 36 +- .../instruction/FieldInstruction.java | 26 +- .../instruction/IncrementInstruction.java | 26 +- .../instruction/InvokeDynamicInstruction.java | 22 +- .../instruction/InvokeInstruction.java | 52 +- .../classfile/instruction/LabelTarget.java | 26 +- .../classfile/instruction/LineNumber.java | 31 +- .../instruction/LoadInstruction.java | 41 +- .../classfile/instruction/LocalVariable.java | 46 +- .../instruction/LocalVariableType.java | 52 +- .../instruction/LookupSwitchInstruction.java | 23 +- .../instruction/MonitorInstruction.java | 15 +- .../instruction/NewMultiArrayInstruction.java | 19 +- .../instruction/NewObjectInstruction.java | 14 +- .../NewPrimitiveArrayInstruction.java | 23 +- .../NewReferenceArrayInstruction.java | 13 +- .../classfile/instruction/NopInstruction.java | 8 +- .../instruction/OperatorInstruction.java | 12 +- .../instruction/ReturnInstruction.java | 18 +- .../instruction/StackInstruction.java | 9 +- .../instruction/StoreInstruction.java | 44 +- .../classfile/instruction/SwitchCase.java | 17 +- .../instruction/TableSwitchInstruction.java | 31 +- .../instruction/ThrowInstruction.java | 8 +- .../instruction/TypeCheckInstruction.java | 27 +- .../classfile/instruction/package-info.java | 38 +- 52 files changed, 2430 insertions(+), 452 deletions(-) diff --git a/jdk b/jdk index bedb68a..22845a7 160000 --- a/jdk +++ b/jdk @@ -1 +1 @@ -Subproject commit bedb68aba126c6400ce9f2182105b5294ff42021 +Subproject commit 22845a77a2175202876d0029f75fa32271e07b91 diff --git a/src/main/java/io/github/dmlloyd/classfile/ClassFile.java b/src/main/java/io/github/dmlloyd/classfile/ClassFile.java index e85f698..8e35b4f 100644 --- a/src/main/java/io/github/dmlloyd/classfile/ClassFile.java +++ b/src/main/java/io/github/dmlloyd/classfile/ClassFile.java @@ -32,6 +32,8 @@ import io.github.dmlloyd.classfile.constantpool.ClassEntry; import io.github.dmlloyd.classfile.constantpool.ConstantPoolBuilder; import io.github.dmlloyd.classfile.constantpool.Utf8Entry; +import io.github.dmlloyd.classfile.instruction.BranchInstruction; +import io.github.dmlloyd.classfile.instruction.DiscontinuedInstruction; import io.github.dmlloyd.classfile.instruction.ExceptionCatch; import java.lang.constant.ClassDesc; import io.github.dmlloyd.classfile.extras.reflect.AccessFlag; @@ -230,17 +232,35 @@ enum LineNumbersOption implements Option { /** * Option describing whether to automatically rewrite short jumps to * long when necessary. - * Default is {@code FIX_SHORT_JUMPS} to automatically rewrite jump + * Default is {@link #FIX_SHORT_JUMPS} to automatically rewrite jump * instructions. + *

+ * Due to physical restrictions, some types of instructions cannot encode + * certain jump targets with bci offsets less than -32768 or greater than + * 32767, as they use a {@code s2} to encode such an offset. (The maximum + * length of the {@code code} array is 65535.) These types of instructions + * are called "short jumps". * + * @see BranchInstruction + * @see DiscontinuedInstruction.JsrInstruction * @since 24 */ enum ShortJumpsOption implements Option { - /** Automatically convert short jumps to long when necessary */ + /** + * Automatically convert short jumps to long when necessary. + *

+ * For an invalid instruction model, a {@link CodeBuilder} may generate + * another or a few other instructions to accomplish the same effect. + */ FIX_SHORT_JUMPS, - /** Fail if short jump overflows */ + /** + * Fail with an {@link IllegalArgumentException} if short jump overflows. + *

+ * This is useful to ensure the physical accuracy of a generated {@code + * class} file. + */ FAIL_ON_SHORT_JUMPS } diff --git a/src/main/java/io/github/dmlloyd/classfile/CodeBuilder.java b/src/main/java/io/github/dmlloyd/classfile/CodeBuilder.java index 193cb9d..697ff22 100644 --- a/src/main/java/io/github/dmlloyd/classfile/CodeBuilder.java +++ b/src/main/java/io/github/dmlloyd/classfile/CodeBuilder.java @@ -51,7 +51,7 @@ * #with(ClassFileElement)} or concretely by calling the various {@code withXxx} * methods. * - *

Instruction Factories

+ *

Instruction Factories

* {@code CodeBuilder} provides convenience methods to create instructions (See * JVMS {@jvms 6.5} Instructions) by their mnemonic, taking necessary operands. *