From 2b00ac0d02a110326846c75ea7ea535dccbb1924 Mon Sep 17 00:00:00 2001 From: Adam Sotona Date: Mon, 4 Dec 2023 07:07:57 +0000 Subject: [PATCH] 8308753: Class-File API transition to Preview Reviewed-by: ihse, mchung, vromero --- .../tools/module/GenModuleInfoSource.java | 5 + make/modules/java.base/Java.gmk | 4 +- make/test/BuildMicrobenchmark.gmk | 5 - .../share/classes/java/lang/Module.java | 16 +- .../lang}/classfile/AccessFlags.java | 6 +- .../lang}/classfile/Annotation.java | 17 +- .../lang}/classfile/AnnotationElement.java | 8 +- .../lang}/classfile/AnnotationValue.java | 128 ++- .../lang}/classfile/Attribute.java | 83 +- .../lang}/classfile/AttributeMapper.java | 24 +- .../lang}/classfile/AttributedElement.java | 13 +- .../lang}/classfile/Attributes.java | 158 ++-- .../lang}/classfile/BootstrapMethodEntry.java | 12 +- .../lang}/classfile/BufWriter.java | 14 +- .../lang}/classfile/ClassBuilder.java | 21 +- .../lang}/classfile/ClassElement.java | 63 +- .../lang/classfile/ClassFile.java} | 769 +++++++++--------- .../lang/classfile/ClassFileBuilder.java} | 25 +- .../lang/classfile/ClassFileElement.java} | 10 +- .../lang/classfile/ClassFileTransform.java} | 42 +- .../lang/classfile/ClassFileVersion.java} | 20 +- .../classfile/ClassHierarchyResolver.java | 21 +- .../lang}/classfile/ClassModel.java | 10 +- .../lang}/classfile/ClassReader.java | 27 +- .../lang}/classfile/ClassSignature.java | 10 +- .../lang}/classfile/ClassTransform.java | 23 +- .../lang}/classfile/CodeBuilder.java | 120 +-- .../lang}/classfile/CodeElement.java | 19 +- .../lang}/classfile/CodeModel.java | 10 +- .../lang}/classfile/CodeTransform.java | 21 +- .../lang}/classfile/CompoundElement.java | 13 +- .../lang}/classfile/CustomAttribute.java | 36 +- .../lang}/classfile/FieldBuilder.java | 12 +- .../lang}/classfile/FieldElement.java | 31 +- .../lang}/classfile/FieldModel.java | 8 +- .../lang}/classfile/FieldTransform.java | 21 +- .../lang}/classfile/Instruction.java | 56 +- .../lang}/classfile/Interfaces.java | 10 +- .../lang}/classfile/Label.java | 8 +- .../lang}/classfile/MethodBuilder.java | 12 +- .../lang}/classfile/MethodElement.java | 39 +- .../lang}/classfile/MethodModel.java | 8 +- .../lang}/classfile/MethodSignature.java | 12 +- .../lang}/classfile/MethodTransform.java | 21 +- .../lang}/classfile/Opcode.java | 457 ++++++----- .../lang}/classfile/PseudoInstruction.java | 22 +- .../lang}/classfile/Signature.java | 38 +- .../lang}/classfile/Superclass.java | 10 +- .../lang}/classfile/TypeAnnotation.java | 120 ++- .../lang}/classfile/TypeKind.java | 6 +- .../lang}/classfile/WritableElement.java | 13 +- .../attribute/AnnotationDefaultAttribute.java | 16 +- .../attribute/BootstrapMethodsAttribute.java | 14 +- .../attribute/CharacterRangeInfo.java | 24 +- .../CharacterRangeTableAttribute.java | 8 +- .../classfile/attribute/CodeAttribute.java | 16 +- .../attribute/CompilationIDAttribute.java | 16 +- .../attribute/ConstantValueAttribute.java | 16 +- .../attribute/DeprecatedAttribute.java | 14 +- .../attribute/EnclosingMethodAttribute.java | 30 +- .../attribute/ExceptionsAttribute.java | 14 +- .../classfile/attribute/InnerClassInfo.java | 12 +- .../attribute/InnerClassesAttribute.java | 14 +- .../classfile/attribute/LineNumberInfo.java | 6 +- .../attribute/LineNumberTableAttribute.java | 14 +- .../attribute/LocalVariableInfo.java | 8 +- .../LocalVariableTableAttribute.java | 14 +- .../attribute/LocalVariableTypeInfo.java | 8 +- .../LocalVariableTypeTableAttribute.java | 16 +- .../attribute/MethodParameterInfo.java | 14 +- .../attribute/MethodParametersAttribute.java | 16 +- .../classfile/attribute/ModuleAttribute.java | 32 +- .../classfile/attribute/ModuleExportInfo.java | 16 +- .../classfile/attribute/ModuleHashInfo.java | 8 +- .../attribute/ModuleHashesAttribute.java | 16 +- .../attribute/ModuleMainClassAttribute.java | 19 +- .../classfile/attribute/ModuleOpenInfo.java | 14 +- .../attribute/ModulePackagesAttribute.java | 18 +- .../attribute/ModuleProvideInfo.java | 10 +- .../attribute/ModuleRequireInfo.java | 18 +- .../attribute/ModuleResolutionAttribute.java | 17 +- .../attribute/ModuleTargetAttribute.java | 16 +- .../attribute/NestHostAttribute.java | 19 +- .../attribute/NestMembersAttribute.java | 18 +- .../PermittedSubclassesAttribute.java | 18 +- .../classfile/attribute/RecordAttribute.java | 16 +- .../attribute/RecordComponentInfo.java | 14 +- .../RuntimeInvisibleAnnotationsAttribute.java | 14 +- ...nvisibleParameterAnnotationsAttribute.java | 18 +- ...timeInvisibleTypeAnnotationsAttribute.java | 24 +- .../RuntimeVisibleAnnotationsAttribute.java | 14 +- ...eVisibleParameterAnnotationsAttribute.java | 18 +- ...untimeVisibleTypeAnnotationsAttribute.java | 24 +- .../attribute/SignatureAttribute.java | 28 +- .../SourceDebugExtensionAttribute.java | 16 +- .../attribute/SourceFileAttribute.java | 16 +- .../attribute/SourceIDAttribute.java | 16 +- .../attribute/StackMapFrameInfo.java | 25 +- .../attribute/StackMapTableAttribute.java | 12 +- .../attribute/SyntheticAttribute.java | 14 +- .../classfile/attribute/UnknownAttribute.java | 14 +- .../classfile/attribute/package-info.java | 36 + .../classfile/components/ClassPrinter.java | 37 +- .../classfile/components/ClassRemapper.java | 22 +- .../components/CodeLocalsShifter.java | 12 +- .../classfile/components/CodeRelabeler.java | 20 +- .../components/CodeStackTracker.java | 12 +- .../classfile/components/package-info.java | 37 +- .../snippet-files/PackageSnippets.java | 44 +- .../AnnotationConstantValueEntry.java | 7 +- .../classfile/constantpool/ClassEntry.java | 6 +- .../constantpool/ConstantDynamicEntry.java | 8 +- .../classfile/constantpool/ConstantPool.java | 13 +- .../constantpool/ConstantPoolBuilder.java | 26 +- .../constantpool/ConstantPoolException.java | 7 +- .../constantpool/ConstantValueEntry.java | 7 +- .../classfile/constantpool/DoubleEntry.java | 8 +- .../DynamicConstantPoolEntry.java | 10 +- .../classfile/constantpool/FieldRefEntry.java | 7 +- .../classfile/constantpool/FloatEntry.java | 8 +- .../classfile/constantpool/IntegerEntry.java | 8 +- .../constantpool/InterfaceMethodRefEntry.java | 7 +- .../constantpool/InvokeDynamicEntry.java | 6 +- .../constantpool/LoadableConstantEntry.java | 9 +- .../classfile/constantpool/LongEntry.java | 8 +- .../constantpool/MemberRefEntry.java | 7 +- .../constantpool/MethodHandleEntry.java | 6 +- .../constantpool/MethodRefEntry.java | 7 +- .../constantpool/MethodTypeEntry.java | 6 +- .../classfile/constantpool/ModuleEntry.java | 6 +- .../constantpool/NameAndTypeEntry.java | 6 +- .../classfile/constantpool/PackageEntry.java | 6 +- .../classfile/constantpool/PoolEntry.java | 9 +- .../classfile/constantpool/StringEntry.java | 6 +- .../classfile/constantpool/Utf8Entry.java | 6 +- .../classfile/constantpool/package-info.java | 36 + .../instruction/ArrayLoadInstruction.java | 16 +- .../instruction/ArrayStoreInstruction.java | 16 +- .../instruction/BranchInstruction.java | 16 +- .../classfile/instruction/CharacterRange.java | 44 +- .../instruction/ConstantInstruction.java | 27 +- .../instruction/ConvertInstruction.java | 16 +- .../instruction/DiscontinuedInstruction.java | 22 +- .../classfile/instruction/ExceptionCatch.java | 16 +- .../instruction/FieldInstruction.java | 23 +- .../instruction/IncrementInstruction.java | 14 +- .../instruction/InvokeDynamicInstruction.java | 19 +- .../instruction/InvokeInstruction.java | 30 +- .../classfile/instruction/LabelTarget.java | 14 +- .../classfile/instruction/LineNumber.java | 18 +- .../instruction/LoadInstruction.java | 16 +- .../classfile/instruction/LocalVariable.java | 24 +- .../instruction/LocalVariableType.java | 26 +- .../instruction/LookupSwitchInstruction.java | 14 +- .../instruction/MonitorInstruction.java | 14 +- .../instruction/NewMultiArrayInstruction.java | 14 +- .../instruction/NewObjectInstruction.java | 14 +- .../NewPrimitiveArrayInstruction.java | 14 +- .../NewReferenceArrayInstruction.java | 14 +- .../classfile/instruction/NopInstruction.java | 12 +- .../instruction/OperatorInstruction.java | 16 +- .../instruction/ReturnInstruction.java | 16 +- .../instruction/StackInstruction.java | 14 +- .../instruction/StoreInstruction.java | 16 +- .../classfile/instruction/SwitchCase.java | 8 +- .../instruction/TableSwitchInstruction.java | 14 +- .../instruction/ThrowInstruction.java | 12 +- .../instruction/TypeCheckInstruction.java | 16 +- .../classfile/instruction/package-info.java | 36 + .../lang}/classfile/package-info.java | 202 +++-- .../snippet-files/PackageSnippets.java | 159 +++- .../java/lang/invoke/MethodHandleProxies.java | 12 +- .../java/lang/runtime/SwitchBootstraps.java | 10 +- .../impl/AbstractAttributeMapper.java | 30 +- .../impl/AbstractBoundLocalVariable.java | 6 +- .../classfile/impl/AbstractDirectBuilder.java | 6 +- .../classfile/impl/AbstractInstruction.java | 78 +- .../classfile/impl/AbstractPoolEntry.java | 95 ++- .../impl/AbstractPseudoInstruction.java | 18 +- .../classfile/impl/AbstractUnboundModel.java | 10 +- .../classfile/impl/AccessFlagsImpl.java | 2 +- .../classfile/impl/AnnotationImpl.java | 6 +- .../classfile/impl/AnnotationReader.java | 20 +- .../classfile/impl/AttributeHolder.java | 6 +- .../classfile/impl/BlockCodeBuilderImpl.java | 12 +- .../impl/BootstrapMethodEntryImpl.java | 10 +- .../classfile/impl/BoundAttribute.java | 20 +- .../classfile/impl/BoundCharacterRange.java | 4 +- .../classfile/impl/BoundLocalVariable.java | 6 +- .../impl/BoundLocalVariableType.java | 6 +- .../impl/BoundRecordComponentInfo.java | 8 +- .../classfile/impl/BufWriterImpl.java | 22 +- .../classfile/impl/BufferedCodeBuilder.java | 28 +- .../classfile/impl/BufferedFieldBuilder.java | 10 +- .../classfile/impl/BufferedMethodBuilder.java | 26 +- .../classfile/impl/BytecodeHelpers.java | 20 +- .../classfile/impl/CatchBuilderImpl.java | 6 +- .../classfile/impl/ChainedClassBuilder.java | 6 +- .../classfile/impl/ChainedCodeBuilder.java | 8 +- .../classfile/impl/ChainedFieldBuilder.java | 8 +- .../classfile/impl/ChainedMethodBuilder.java | 14 +- ...{ClassfileImpl.java => ClassFileImpl.java} | 30 +- ...ionImpl.java => ClassFileVersionImpl.java} | 10 +- .../classfile/impl/ClassHierarchyImpl.java | 4 +- .../internal/classfile/impl/ClassImpl.java | 42 +- .../classfile/impl/ClassPrinterImpl.java | 36 +- .../classfile/impl/ClassReaderImpl.java | 57 +- .../classfile/impl/ClassRemapperImpl.java | 110 +-- .../jdk/internal/classfile/impl/CodeImpl.java | 26 +- .../classfile/impl/CodeLocalsShifterImpl.java | 20 +- .../classfile/impl/CodeRelabelerImpl.java | 26 +- .../classfile/impl/CodeStackTrackerImpl.java | 62 +- .../classfile/impl/DirectClassBuilder.java | 47 +- .../classfile/impl/DirectCodeBuilder.java | 105 +-- .../classfile/impl/DirectFieldBuilder.java | 21 +- .../classfile/impl/DirectMethodBuilder.java | 33 +- .../internal/classfile/impl/FieldImpl.java | 4 +- .../classfile/impl/InterfacesImpl.java | 4 +- .../internal/classfile/impl/LabelContext.java | 2 +- .../internal/classfile/impl/LabelImpl.java | 4 +- .../classfile/impl/LineNumberImpl.java | 2 +- .../internal/classfile/impl/MethodImpl.java | 4 +- .../internal/classfile/impl/MethodInfo.java | 4 +- .../impl/ModuleAttributeBuilderImpl.java | 10 +- .../impl/NonterminalCodeBuilder.java | 8 +- .../classfile/impl/RawBytecodeHelper.java | 10 +- .../classfile/impl/SignaturesImpl.java | 8 +- .../classfile/impl/SplitConstantPool.java | 74 +- .../internal/classfile/impl/StackCounter.java | 10 +- .../classfile/impl/StackMapDecoder.java | 16 +- .../classfile/impl/StackMapGenerator.java | 36 +- .../classfile/impl/SuperclassImpl.java | 4 +- .../classfile/impl/TargetInfoImpl.java | 6 +- .../classfile/impl/TemporaryConstantPool.java | 46 +- .../classfile/impl/TerminalCodeBuilder.java | 2 +- .../classfile/impl/TerminalFieldBuilder.java | 2 +- .../classfile/impl/TerminalMethodBuilder.java | 4 +- .../classfile/impl/TransformImpl.java | 38 +- .../impl/TransformingCodeBuilder.java | 12 +- .../classfile/impl/UnboundAttribute.java | 137 ++-- .../jdk/internal/classfile/impl/Util.java | 20 +- .../impl/verifier/VerificationBytecodes.java | 484 +++++------ .../impl/verifier/VerificationWrapper.java | 18 +- .../classfile/impl/verifier/VerifierImpl.java | 484 +++++------ .../foreign/abi/BindingSpecializer.java | 18 +- .../jdk/internal/javac/PreviewFeature.java | 2 + .../internal/module/ModuleInfoExtender.java | 20 +- src/java.base/share/classes/module-info.java | 35 +- .../share/classes/module-info.java | 3 + .../classes/sun/tools/jar/FingerPrint.java | 20 +- .../com/sun/tools/javap/AnnotationWriter.java | 14 +- .../com/sun/tools/javap/AttributeWriter.java | 10 +- .../com/sun/tools/javap/ClassWriter.java | 68 +- .../com/sun/tools/javap/CodeWriter.java | 18 +- .../com/sun/tools/javap/ConstantWriter.java | 4 +- .../tools/javap/InstructionDetailWriter.java | 2 +- .../com/sun/tools/javap/JavapTask.java | 12 +- .../tools/javap/LocalVariableTableWriter.java | 10 +- .../javap/LocalVariableTypeTableWriter.java | 10 +- .../classes/com/sun/tools/javap/Options.java | 2 +- .../com/sun/tools/javap/SourceWriter.java | 8 +- .../com/sun/tools/javap/StackMapWriter.java | 14 +- .../com/sun/tools/javap/TryBlockWriter.java | 6 +- .../sun/tools/javap/TypeAnnotationWriter.java | 10 +- src/jdk.jdeps/share/classes/module-info.java | 3 + .../jdk/jfr/internal/EventClassBuilder.java | 26 +- .../jfr/internal/EventInstrumentation.java | 32 +- .../jdk/jfr/internal/util/Bytecode.java | 10 +- src/jdk.jfr/share/classes/module-info.java | 3 + .../classes/jdk/tools/jimage/JImageTask.java | 10 +- .../internal/plugins/AbstractPlugin.java | 12 +- .../plugins/IncludeLocalesPlugin.java | 2 +- .../internal/plugins/StringSharingPlugin.java | 14 +- .../StripJavaDebugAttributesPlugin.java | 20 +- .../internal/plugins/SystemModulesPlugin.java | 18 +- .../internal/plugins/VersionPropsPlugin.java | 16 +- src/jdk.jlink/share/classes/module-info.java | 3 + .../execution/LocalExecutionControl.java | 16 +- src/jdk.jshell/share/classes/module-info.java | 3 + .../runtime/test/TestResolvedJavaMethod.java | 22 +- .../dcmd/framework/VMVersionTest.java | 6 +- .../securityManager/ClassLoaderTest.java | 6 +- .../lang/ModuleTests/AnnotationsTest.java | 4 +- .../invoke/MethodHandleProxies/BasicTest.java | 12 +- .../WrapperHiddenClassTest.java | 10 +- .../lang/invoke/lib/InstructionHelper.java | 16 +- .../condy/BootstrapMethodJumboArgsTest.java | 6 +- .../lang/invoke/condy/CondyBSMException.java | 6 +- .../lang/invoke/condy/CondyBSMInvocation.java | 6 +- .../invoke/condy/CondyBSMValidationTest.java | 6 +- .../CondyInterfaceWithOverpassMethods.java | 14 +- .../invoke/condy/CondyNameValidationTest.java | 6 +- .../lang/invoke/condy/CondyNestedTest.java | 22 +- .../condy/CondyRepeatFailedResolution.java | 42 +- .../condy/CondyReturnPrimitiveTest.java | 42 +- .../condy/CondyStaticArgumentsTest.java | 6 +- .../invoke/condy/CondyTypeValidationTest.java | 6 +- .../invoke/condy/CondyWithGarbageTest.java | 22 +- .../lang/invoke/condy/CondyWrongType.java | 6 +- .../invoke/condy/ConstantBootstrapsTest.java | 6 +- .../lang/module/ClassFileVersionsTest.java | 6 +- .../java/lang/module/ConfigurationTest.java | 4 +- .../lang/module/ModuleDescriptorTest.java | 10 +- .../java/lang/module/ModuleFinderTest.java | 6 +- .../jdk/java/lang/module/ModuleNamesTest.java | 4 +- .../java/lang/module/MultiReleaseJarTest.java | 6 +- .../lang/runtime/SwitchBootstrapsTest.java | 7 +- .../Provider/SecurityProviderModularTest.java | 6 +- .../java/time/chrono/HijrahConfigTest.java | 6 +- .../login/modules/JaasModularClientTest.java | 6 +- .../JaasModularDefaultHandlerTest.java | 6 +- test/jdk/jdk/classfile/AccessFlagsTest.java | 4 +- test/jdk/jdk/classfile/AdaptCodeTest.java | 18 +- .../AdvancedTransformationsTest.java | 56 +- .../jdk/classfile/AnnotationModelTest.java | 8 +- test/jdk/jdk/classfile/AnnotationTest.java | 12 +- test/jdk/jdk/classfile/ArrayTest.java | 22 +- test/jdk/jdk/classfile/BSMTest.java | 18 +- test/jdk/jdk/classfile/BasicBlockTest.java | 6 +- .../jdk/jdk/classfile/BoundAttributeTest.java | 14 +- test/jdk/jdk/classfile/BuilderBlockTest.java | 42 +- test/jdk/jdk/classfile/BuilderParamTest.java | 8 +- .../jdk/classfile/BuilderTryCatchTest.java | 26 +- test/jdk/jdk/classfile/ClassBuildingTest.java | 16 +- .../jdk/classfile/ClassHierarchyInfoTest.java | 25 +- test/jdk/jdk/classfile/ClassPrinterTest.java | 20 +- .../jdk/classfile/ConstantPoolCopyTest.java | 56 +- test/jdk/jdk/classfile/CorpusTest.java | 38 +- .../DiscontinuedInstructionsTest.java | 12 +- .../jdk/classfile/FilterDeadLabelsTest.java | 12 +- test/jdk/jdk/classfile/LDCTest.java | 16 +- test/jdk/jdk/classfile/LimitsTest.java | 20 +- test/jdk/jdk/classfile/LowAdaptTest.java | 16 +- .../jdk/classfile/LowJCovAttributeTest.java | 20 +- test/jdk/jdk/classfile/LowModuleTest.java | 22 +- test/jdk/jdk/classfile/LvtTest.java | 38 +- .../jdk/classfile/MassAdaptCopyCodeTest.java | 16 +- .../MassAdaptCopyPrimitiveMatchCodeTest.java | 22 +- test/jdk/jdk/classfile/ModuleBuilderTest.java | 26 +- test/jdk/jdk/classfile/OneToOneTest.java | 36 +- .../jdk/classfile/OpcodesValidationTest.java | 12 +- test/jdk/jdk/classfile/OptionsTest.java | 33 +- .../classfile/PreviewMinorVersionTest.java | 12 +- .../classfile/PrimitiveClassConstantTest.java | 6 +- test/jdk/jdk/classfile/ShortJumpsFixTest.java | 36 +- test/jdk/jdk/classfile/SignaturesTest.java | 16 +- test/jdk/jdk/classfile/SnippetsTest.java | 13 +- test/jdk/jdk/classfile/StackMapsTest.java | 36 +- test/jdk/jdk/classfile/StackTrackerTest.java | 10 +- .../jdk/jdk/classfile/StreamedVsListTest.java | 44 +- test/jdk/jdk/classfile/SwapTest.java | 6 +- test/jdk/jdk/classfile/TEST.properties | 6 +- .../TempConstantPoolBuilderTest.java | 14 +- .../jdk/classfile/TestRecordComponent.java | 22 +- test/jdk/jdk/classfile/TransformTests.java | 22 +- test/jdk/jdk/classfile/Utf8EntryTest.java | 28 +- test/jdk/jdk/classfile/UtilTest.java | 2 +- test/jdk/jdk/classfile/VerifierSelfTest.java | 16 +- test/jdk/jdk/classfile/WriteTest.java | 24 +- .../examples/AnnotationsExamples.java | 32 +- .../classfile/examples/ExampleGallery.java | 94 +-- .../ExperimentalTransformExamples.java | 10 +- .../classfile/examples/ModuleExamples.java | 26 +- .../classfile/examples/TransformExamples.java | 24 +- .../jdk/classfile/helpers/ClassRecord.java | 26 +- .../InstructionModelToCodeBuilder.java | 6 +- .../helpers/RebuildingTransformation.java | 14 +- test/jdk/jdk/classfile/helpers/TestUtil.java | 4 +- .../jdk/jdk/classfile/helpers/Transforms.java | 54 +- test/jdk/jdk/lambda/TEST.properties | 6 +- .../separate/ClassToInterfaceConverter.java | 10 +- .../jdk/modules/incubator/ServiceBinding.java | 6 +- .../jdk/sun/tools/jcmd/TestProcessHelper.java | 4 +- .../tools/jimage/JImageNonAsciiNameTest.java | 6 +- test/jdk/tools/jimage/JImageTest.java | 6 +- test/jdk/tools/jlink/DefaultProviderTest.java | 6 +- .../tools/jlink/ExplodedModuleNameTest.java | 6 +- test/jdk/tools/jlink/IntegrationTest.java | 6 +- test/jdk/tools/jlink/JLink100Modules.java | 6 +- test/jdk/tools/jlink/JLink2Test.java | 6 +- .../jlink/JLinkDedupTestBatchSizeOne.java | 6 +- test/jdk/tools/jlink/JLinkNegativeTest.java | 11 +- test/jdk/tools/jlink/JLinkOptionsTest.java | 6 +- test/jdk/tools/jlink/JLinkPluginsTest.java | 6 +- test/jdk/tools/jlink/JLinkTest.java | 6 +- .../jdk/tools/jlink/ModuleNamesOrderTest.java | 6 +- test/jdk/tools/jlink/NativeTest.java | 6 +- .../jlink/plugins/AddOptionsPluginTest.java | 6 +- .../tools/jlink/plugins/CDSPluginTest.java | 6 +- .../plugins/GenerateJLIClassesPluginTest.java | 6 +- .../plugins/IncludeLocalesPluginTest.java | 6 +- .../plugins/SaveJlinkArgfilesPluginTest.java | 6 +- .../plugins/StringSharingPluginTest.java | 6 +- .../StripJavaDebugAttributesPluginTest.java | 12 +- .../jlink/plugins/VendorInfoPluginsTest.java | 6 +- test/jdk/tools/lib/tests/JImageValidator.java | 6 +- .../classfile/ClassfileInspector.java | 6 +- .../tools/javac/4241573/T4241573.java | 16 +- .../tools/javac/7003595/T7003595.java | 14 +- .../CPoolRefClassContainingInlinedCts.java | 16 +- .../CheckACC_STRICTFlagOnclinitTest.java | 52 +- .../8000518/DuplicateConstantPoolEntry.java | 16 +- ...eckACC_STRICTFlagOnPkgAccessClassTest.java | 14 +- .../8009170/RedundantByteCodeInArrayTest.java | 14 +- .../AnonymousClass/AnonymousClassFlags.java | 24 +- .../MethodParameters/AnnotationTest.java | 8 +- .../MethodParameters/AnonymousClass.java | 8 +- .../MethodParameters/ClassFileVisitor.java | 26 +- .../javac/MethodParameters/Constructors.java | 8 +- .../javac/MethodParameters/EnumTest.java | 8 +- .../MethodParameters/InstanceMethods.java | 8 +- .../javac/MethodParameters/LambdaTest.java | 8 +- .../LegacyOutputTest/LegacyOutputTest.java | 16 +- .../MethodParameters/LocalClassTest.java | 8 +- .../MethodParameters/MemberClassTest.java | 8 +- .../javac/MethodParameters/StaticMethods.java | 8 +- .../MethodParameters/UncommonParamNames.java | 8 +- .../tools/javac/MethodParametersTest.java | 22 +- .../tools/javac/NoStringToLower.java | 14 +- .../ImplicitParameters.java | 32 +- .../StringConcat/TestIndyStringConcat.java | 75 +- .../StringConcat/WellKnownTypeSignatures.java | 18 +- .../javac/StringConcat/WellKnownTypes.java | 6 +- .../tools/javac/StringConcat/access/Test.java | 16 +- ...ationsAreNotCopiedToBridgeMethodsTest.java | 16 +- .../DebugPointerAtBadPositionTest.java | 14 +- .../InlinedFinallyConfuseDebuggersTest.java | 14 +- .../tools/javac/T7053059/DoubleCastTest.java | 18 +- test/langtools/tools/javac/T7093325.java | 18 +- ...rClassAttrMustNotHaveStrictFPFlagTest.java | 16 +- .../T8003967/DetectMutableStaticFields.java | 20 +- ...rNamesAreNotCopiedToAnonymousInitTest.java | 19 +- .../EmptyUTF8ForInnerClassNameTest.java | 14 +- .../javac/T8019486/WrongLNTForLambdaTest.java | 12 +- .../DeadCodeGeneratedForEmptyTryTest.java | 18 +- .../NoDeadCodeGenerationOnTrySmtTest.java | 14 +- .../DontGenerateLVTForGNoneOpTest.java | 12 +- .../MissingLNTEntryForBreakContinueTest.java | 14 +- .../MissingLNTEntryForFinalizerTest.java | 14 +- .../T8187805/BogusRTTAForUnusedVarTest.java | 16 +- ...TargetIsNotAddedAsMarkerInterfaceTest.java | 16 +- .../T8209173/CodeCompletionExceptTest.java | 8 +- ...oLocalsMustBeReservedForDCEedVarsTest.java | 14 +- .../javac/T8222949/TestConstantDynamic.java | 18 +- .../TryWithResources/TwrSimpleClose.java | 18 +- .../ApplicableAnnotationsOnRecords.java | 10 +- .../annotations/SyntheticParameters.java | 10 +- .../TypeAnnotationsPositionsOnRecords.java | 12 +- .../VariablesDeclaredWithVarTest.java | 12 +- .../classfile/AnonymousClassTest.java | 24 +- .../classfile/ClassfileTestHelper.java | 8 +- .../classfile/CombinationsTargetTest1.java | 12 +- .../classfile/CombinationsTargetTest2.java | 12 +- .../classfile/CombinationsTargetTest3.java | 6 +- .../typeAnnotations/classfile/DeadCode.java | 10 +- .../classfile/InstanceInitializer.java | 10 +- .../classfile/NewTypeArguments.java | 10 +- .../classfile/NoTargetAnnotations.java | 14 +- .../typeAnnotations/classfile/Scopes.java | 12 +- .../classfile/StaticInitializer.java | 10 +- .../classfile/SyntheticParameters.java | 12 +- .../typeAnnotations/classfile/T8008762.java | 10 +- .../typeAnnotations/classfile/T8008769.java | 10 +- .../typeAnnotations/classfile/T8010015.java | 10 +- .../classfile/TestAnonInnerClasses.java | 14 +- .../classfile/TestNewCastArray.java | 14 +- .../TypeAnnotationPropagationTest.java | 14 +- .../typeAnnotations/classfile/TypeCasts.java | 8 +- .../typeAnnotations/classfile/Wildcards.java | 8 +- .../referenceinfos/ClassExtends.java | 10 +- .../referenceinfos/ClassTypeParam.java | 10 +- .../ConstructorInvocationTypeArgument.java | 10 +- .../referenceinfos/Constructors.java | 10 +- .../referenceinfos/Driver.java | 4 +- .../referenceinfos/ExceptionParameters.java | 10 +- .../referenceinfos/Fields.java | 10 +- .../referenceinfos/FromSpecification.java | 10 +- .../referenceinfos/Initializers.java | 10 +- .../referenceinfos/Lambda.java | 10 +- .../MethodInvocationTypeArgument.java | 10 +- .../referenceinfos/MethodParameters.java | 10 +- .../referenceinfos/MethodReceivers.java | 10 +- .../referenceinfos/MethodReturns.java | 10 +- .../referenceinfos/MethodThrows.java | 10 +- .../referenceinfos/MethodTypeParam.java | 10 +- .../referenceinfos/MultiCatch.java | 10 +- .../referenceinfos/NestedTypes.java | 10 +- .../referenceinfos/NewObjects.java | 10 +- .../referenceinfos/ReferenceInfoUtil.java | 4 +- .../RepeatingTypeAnnotations.java | 10 +- .../referenceinfos/ResourceVariable.java | 10 +- .../referenceinfos/TypeCasts.java | 10 +- .../referenceinfos/TypeTests.java | 10 +- .../intersection/DuplicatedCheckcastTest.java | 16 +- .../InnerClasses/SyntheticClasses.java | 14 +- .../javac/classfiles/T8255757/T8255757.java | 12 +- .../AnnotationDefaultTest.java | 10 +- .../AnnotationDefaultVerifier.java | 8 +- .../EnclosingMethod/EnclosingMethodTest.java | 10 +- .../LineNumberTable/LineNumberTest.java | 6 +- .../LineNumberTable/LineNumberTestBase.java | 6 +- .../MultipleRecordPatterns.java | 6 +- .../LineNumberTable/RuleSwitchBreaks.java | 6 +- .../LineNumberTable/StringSwitchBreaks.java | 6 +- .../attributes/LineNumberTable/T8050993.java | 14 +- .../LocalVariableTableTest.java | 8 +- .../LocalVariableTestBase.java | 6 +- .../LocalVariableTypeTableTest.java | 8 +- .../attributes/Module/ModuleFlagTest.java | 14 +- .../attributes/Module/ModuleTest.java | 6 +- .../attributes/Module/ModuleTestBase.java | 20 +- .../attributes/Signature/ConstructorTest.java | 6 +- .../attributes/Signature/Driver.java | 4 +- .../attributes/Signature/EnumTest.java | 6 +- .../attributes/Signature/ExceptionTest.java | 6 +- .../attributes/Signature/FieldTest.java | 6 +- .../attributes/Signature/InnerClassTest.java | 6 +- .../Signature/MethodParameterTest.java | 6 +- .../Signature/MethodTypeBoundTest.java | 6 +- .../attributes/Signature/ReturnTypeTest.java | 6 +- .../SourceFile/AnonymousClassTest.java | 6 +- .../attributes/SourceFile/InnerClassTest.java | 6 +- .../attributes/SourceFile/LocalClassTest.java | 6 +- .../attributes/SourceFile/MixTest.java | 6 +- .../attributes/SourceFile/ModuleInfoTest.java | 6 +- .../SourceFile/NoSourceFileAttribute.java | 12 +- .../SourceFile/SourceFileTestBase.java | 12 +- .../SourceFile/SourceFileTestBase_legacy.java | 117 +++ .../SourceFile/SyntheticClassTest.java | 13 +- .../TopLevelClassesOneFileTest.java | 6 +- ...ssToPrivateInnerClassConstructorsTest.java | 6 +- .../AccessToPrivateInnerClassMembersTest.java | 6 +- .../AccessToPrivateSiblingsTest.java | 6 +- .../attributes/Synthetic/AssertFieldTest.java | 6 +- .../BridgeMethodForGenericMethodTest.java | 6 +- ...geMethodsForLambdaTargetRelease14Test.java | 13 +- .../Synthetic/BridgeMethodsForLambdaTest.java | 6 +- .../attributes/Synthetic/EnumTest.java | 6 +- .../attributes/Synthetic/PackageInfoTest.java | 6 +- .../Synthetic/SyntheticTestDriver.java | 4 +- .../Synthetic/SyntheticTestDriver_legacy.java | 212 +++++ .../attributes/Synthetic/ThisFieldTest.java | 6 +- .../annotations/AnnotationsTestBase.java | 2 +- ...untimeAnnotationsForGenericMethodTest.java | 8 +- ...timeAnnotationsForInnerAnnotationTest.java | 8 +- .../RuntimeAnnotationsForInnerClassTest.java | 8 +- .../RuntimeAnnotationsForInnerEnumTest.java | 8 +- ...ntimeAnnotationsForInnerInterfaceTest.java | 8 +- ...untimeAnnotationsForTopLevelClassTest.java | 8 +- .../RuntimeAnnotationsTestBase.java | 4 +- ...ameterAnnotationsForGenericMethodTest.java | 8 +- ...timeParameterAnnotationsForLambdaTest.java | 18 +- .../RuntimeParameterAnnotationsTest.java | 8 +- .../RuntimeParameterAnnotationsTestBase.java | 4 +- .../annotations/TestAnnotationInfo.java | 4 +- .../deprecated/DeprecatedPackageTest.java | 12 +- .../attributes/deprecated/DeprecatedTest.java | 10 +- ...InnerAnnotationsInInnerAnnotationTest.java | 6 +- .../InnerAnnotationsInInnerClassTest.java | 6 +- .../InnerAnnotationsInInnerEnumTest.java | 6 +- .../InnerAnnotationsInInnerInterfaceTest.java | 6 +- .../InnerClassesHierarchyTest.java | 12 +- .../InnerClassesInAnonymousClassTest.java | 6 +- .../InnerClassesInInnerAnnotationTest.java | 6 +- .../InnerClassesInInnerClassTest.java | 6 +- .../InnerClassesInInnerEnumTest.java | 6 +- .../InnerClassesInInnerInterfaceTest.java | 6 +- .../InnerClassesInLocalClassTest.java | 8 +- .../innerclasses/InnerClassesIndexTest.java | 12 +- .../innerclasses/InnerClassesTest.java | 6 +- .../innerclasses/InnerClassesTestBase.java | 6 +- .../InnerEnumInInnerAnnotationTest.java | 6 +- .../InnerEnumInInnerEnumTest.java | 6 +- .../InnerEnumInInnerInterfaceTest.java | 6 +- .../InnerEnumsInInnerClassTest.java | 6 +- .../InnerInterfacesInInnerAnnotationTest.java | 6 +- .../InnerInterfacesInInnerClassTest.java | 6 +- .../InnerInterfacesInInnerEnumTest.java | 6 +- .../InnerInterfacesInInnerInterfaceTest.java | 6 +- .../innerclasses/NoInnerClassesTest.java | 10 +- .../classfiles/attributes/lib/TestBase.java | 4 +- .../attributes/lib_legacy/TestBase.java | 284 +++++++ .../attributes/lib_legacy/TestResult.java | 191 +++++ .../classreader/8171132/BadConstantValue.java | 16 +- .../IndyCorrectInvocationName.java | 16 +- .../tools/javac/code/CharImmediateValue.java | 12 +- .../javac/constDebug/ConstDebugTest.java | 10 +- .../javac/defaultMethods/BadClassfile.java | 14 +- ...heckACC_STRICTFlagOnDefaultMethodTest.java | 57 +- .../javac/defaultMethods/TestDefaultBody.java | 20 +- .../TestNoBridgeOnDefaults.java | 12 +- .../super/TestDirectSuperInterfaceInvoke.java | 18 +- .../tools/javac/diags/CheckResourceKeys.java | 12 +- test/langtools/tools/javac/diags/Example.java | 8 +- .../BadConstantValueType.java | 2 +- .../processors/CreateBadClassFile.java | 6 +- .../InvalidDefaultInterface.java | 2 +- .../processors/CreateBadClassFile.java | 6 +- .../InvalidStaticInterface.java | 2 +- .../processors/CreateBadClassFile.java | 6 +- .../_super/NonDirectSuper/NonDirectSuper.java | 20 +- .../tools/javac/file/SymLinkArchiveTest.java | 6 +- .../javac/file/SymLinkShortNameTest.java | 6 +- .../tools/javac/file/SymLinkTest.java | 12 +- .../tools/javac/flow/LVTHarness.java | 14 +- .../javac/generics/bridges/BridgeHarness.java | 14 +- .../tools/javac/importscope/T8193717.java | 14 +- .../jvm/ClassRefDupInConstantPoolTest.java | 12 +- .../tools/javac/lambda/ByteCodeTest.java | 16 +- .../javac/lambda/LambdaTestStrictFPFlag.java | 44 +- .../javac/lambda/LocalVariableTable.java | 14 +- .../lambda/TestBootstrapMethodsCount.java | 14 +- .../tools/javac/lambda/TestInvokeDynamic.java | 18 +- .../lambda/bytecode/TestLambdaBytecode.java | 18 +- .../TestLambdaBytecodeTargetRelease14.java | 20 +- .../deduplication/DeduplicationTest.java | 17 +- ...estNonSerializableLambdaNameStability.java | 12 +- .../tools/javac/launcher/GetResourceTest.java | 4 +- .../javac/launcher/SourceLauncherTest.java | 20 +- .../tools/javac/launcher/src/CLTest.java | 8 +- .../ConditionalLineNumberTest.java | 12 +- .../linenumbers/FinallyLineNumberTest.java | 12 +- .../linenumbers/NestedLineNumberTest.java | 16 +- .../linenumbers/NullCheckLineNumberTest.java | 30 +- test/langtools/tools/javac/meth/TestCP.java | 18 +- .../javac/modules/AnnotationsOnModules.java | 24 +- .../tools/javac/modules/IncubatingTest.java | 16 +- .../tools/javac/modules/JavaBaseTest.java | 18 +- .../tools/javac/modules/ModuleVersion.java | 12 +- .../tools/javac/modules/OpenModulesTest.java | 16 +- .../javac/multicatch/7005371/T7005371.java | 16 +- .../tools/javac/multicatch/Pos05.java | 16 +- .../tools/javac/patterns/Annotations.java | 16 +- .../javac/patterns/LocalVariableTable.java | 14 +- .../javac/patterns/MatchExceptionTest.java | 16 +- .../NestedPatternVariablesBytecode.java | 12 +- .../javac/patterns/NoUnnecessaryCast.java | 16 +- .../javac/platform/ModuleVersionTest.java | 16 +- .../javac/preview/PreviewAutoSuppress.java | 10 +- .../tools/javac/preview/PreviewErrors.java | 12 +- .../tools/javac/preview/PreviewTest.java | 12 +- .../model/element/TestFileObjectOf.java | 6 +- .../processing/model/element/TestOrigin.java | 26 +- .../javac/records/RecordCompilationTests.java | 36 +- .../RecordsBinaryCompatibilityTests.java | 6 +- .../RecordComponentTypeTest.java | 12 +- .../javac/recovery/AnnotationRecovery.java | 6 +- .../tools/javac/recovery/AttrRecovery.java | 6 +- .../tools/javac/recovery/LambdaRecovery.java | 6 +- .../tools/javac/recovery/MethodModifiers.java | 6 +- .../tools/javac/resolve/NoObjectToString.java | 12 +- .../sealed/BinaryCompatibilityTests.java | 6 +- .../sealed/CheckSubtypesOfSealedTest.java | 12 +- .../sealed/SealedDiffConfigurationsTest.java | 22 +- .../tools/javac/sym/ElementStructureTest.java | 10 +- .../tools/javac/varargs/6199075/T6199075.java | 18 +- .../tools/javac/varargs/7042566/T7042566.java | 20 +- test/langtools/tools/javap/T6716452.java | 12 +- .../tools/javap/TestClassNameWarning.java | 12 +- .../javap/classfile/6888367/T6888367.java | 16 +- .../tools/javap/classfile/T6887895.java | 12 +- .../typeAnnotations/JSR175Annotations.java | 16 +- .../tools/javap/typeAnnotations/NewArray.java | 12 +- .../tools/javap/typeAnnotations/Presence.java | 12 +- .../javap/typeAnnotations/PresenceInner.java | 14 +- .../javap/typeAnnotations/TypeCasts.java | 12 +- .../javap/typeAnnotations/Visibility.java | 14 +- .../javap/typeAnnotations/Wildcards.java | 12 +- .../jdk/test/lib/util/ModuleInfoWriter.java | 44 +- .../java/lang/invoke/LazyStaticColdStart.java | 12 +- .../classfile/AbstractCorpusBenchmark.java | 6 +- .../bench/jdk/classfile/AdHocAdapt.java | 8 +- .../jdk/classfile/ClassfileBenchmark.java | 26 +- .../jdk/classfile/GenerateStackMaps.java | 22 +- .../bench/jdk/classfile/ParseOptions.java | 10 +- .../openjdk/bench/jdk/classfile/ReadDeep.java | 22 +- .../bench/jdk/classfile/ReadMetadata.java | 16 +- .../jdk/classfile/RebuildMethodBodies.java | 32 +- .../jdk/classfile/RepeatedModelTraversal.java | 11 +- .../bench/jdk/classfile/Transforms.java | 48 +- .../openjdk/bench/jdk/classfile/Write.java | 30 +- 681 files changed, 7518 insertions(+), 6502 deletions(-) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/AccessFlags.java (96%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Annotation.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/AnnotationElement.java (96%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/AnnotationValue.java (83%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Attribute.java (58%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/AttributeMapper.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/AttributedElement.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Attributes.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/BootstrapMethodEntry.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/BufWriter.java (94%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/ClassBuilder.java (94%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/ClassElement.java (51%) rename src/java.base/share/classes/{jdk/internal/classfile/Classfile.java => java/lang/classfile/ClassFile.java} (50%) rename src/java.base/share/classes/{jdk/internal/classfile/ClassfileBuilder.java => java/lang/classfile/ClassFileBuilder.java} (78%) rename src/java.base/share/classes/{jdk/internal/classfile/ClassfileElement.java => java/lang/classfile/ClassFileElement.java} (89%) rename src/java.base/share/classes/{jdk/internal/classfile/ClassfileTransform.java => java/lang/classfile/ClassFileTransform.java} (83%) rename src/java.base/share/classes/{jdk/internal/classfile/ClassfileVersion.java => java/lang/classfile/ClassFileVersion.java} (75%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/ClassHierarchyResolver.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/ClassModel.java (93%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/ClassReader.java (93%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/ClassSignature.java (93%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/ClassTransform.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/CodeBuilder.java (94%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/CodeElement.java (74%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/CodeModel.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/CodeTransform.java (82%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/CompoundElement.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/CustomAttribute.java (69%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/FieldBuilder.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/FieldElement.java (62%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/FieldModel.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/FieldTransform.java (84%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Instruction.java (57%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Interfaces.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Label.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/MethodBuilder.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/MethodElement.java (60%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/MethodModel.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/MethodSignature.java (93%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/MethodTransform.java (85%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Opcode.java (62%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/PseudoInstruction.java (76%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Signature.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/Superclass.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/TypeAnnotation.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/TypeKind.java (97%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/WritableElement.java (84%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/AnnotationDefaultAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/BootstrapMethodsAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/CharacterRangeInfo.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/CharacterRangeTableAttribute.java (95%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/CodeAttribute.java (84%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/CompilationIDAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ConstantValueAttribute.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/DeprecatedAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/EnclosingMethodAttribute.java (79%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ExceptionsAttribute.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/InnerClassInfo.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/InnerClassesAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/LineNumberInfo.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/LineNumberTableAttribute.java (83%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/LocalVariableInfo.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/LocalVariableTableAttribute.java (83%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/LocalVariableTypeInfo.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/LocalVariableTypeTableAttribute.java (81%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/MethodParameterInfo.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/MethodParametersAttribute.java (85%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleAttribute.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleExportInfo.java (94%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleHashInfo.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleHashesAttribute.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleMainClassAttribute.java (81%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleOpenInfo.java (94%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModulePackagesAttribute.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleProvideInfo.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleRequireInfo.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleResolutionAttribute.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/ModuleTargetAttribute.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/NestHostAttribute.java (81%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/NestMembersAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/PermittedSubclassesAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/RecordAttribute.java (84%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/RecordComponentInfo.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/RuntimeInvisibleAnnotationsAttribute.java (85%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/RuntimeInvisibleParameterAnnotationsAttribute.java (84%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/RuntimeInvisibleTypeAnnotationsAttribute.java (81%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/RuntimeVisibleAnnotationsAttribute.java (85%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/RuntimeVisibleParameterAnnotationsAttribute.java (84%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/RuntimeVisibleTypeAnnotationsAttribute.java (81%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/SignatureAttribute.java (84%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/SourceDebugExtensionAttribute.java (82%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/SourceFileAttribute.java (85%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/SourceIDAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/StackMapFrameInfo.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/StackMapTableAttribute.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/SyntheticAttribute.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/attribute/UnknownAttribute.java (83%) create mode 100644 src/java.base/share/classes/java/lang/classfile/attribute/package-info.java rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/components/ClassPrinter.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/components/ClassRemapper.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/components/CodeLocalsShifter.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/components/CodeRelabeler.java (82%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/components/CodeStackTracker.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/components/package-info.java (78%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/components/snippet-files/PackageSnippets.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/AnnotationConstantValueEntry.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/ClassEntry.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/ConstantDynamicEntry.java (93%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/ConstantPool.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/ConstantPoolBuilder.java (96%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/ConstantPoolException.java (94%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/ConstantValueEntry.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/DoubleEntry.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/DynamicConstantPoolEntry.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/FieldRefEntry.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/FloatEntry.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/IntegerEntry.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/InterfaceMethodRefEntry.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/InvokeDynamicEntry.java (93%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/LoadableConstantEntry.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/LongEntry.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/MemberRefEntry.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/MethodHandleEntry.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/MethodRefEntry.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/MethodTypeEntry.java (92%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/ModuleEntry.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/NameAndTypeEntry.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/PackageEntry.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/PoolEntry.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/StringEntry.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/constantpool/Utf8Entry.java (91%) create mode 100644 src/java.base/share/classes/java/lang/classfile/constantpool/package-info.java rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/ArrayLoadInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/ArrayStoreInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/BranchInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/CharacterRange.java (74%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/ConstantInstruction.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/ConvertInstruction.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/DiscontinuedInstruction.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/ExceptionCatch.java (90%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/FieldInstruction.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/IncrementInstruction.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/InvokeDynamicInstruction.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/InvokeInstruction.java (85%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/LabelTarget.java (84%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/LineNumber.java (80%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/LoadInstruction.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/LocalVariable.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/LocalVariableType.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/LookupSwitchInstruction.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/MonitorInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/NewMultiArrayInstruction.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/NewObjectInstruction.java (85%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/NewPrimitiveArrayInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/NewReferenceArrayInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/NopInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/OperatorInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/ReturnInstruction.java (87%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/StackInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/StoreInstruction.java (88%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/SwitchCase.java (91%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/TableSwitchInstruction.java (89%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/ThrowInstruction.java (86%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/instruction/TypeCheckInstruction.java (88%) create mode 100644 src/java.base/share/classes/java/lang/classfile/instruction/package-info.java rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/package-info.java (70%) rename src/java.base/share/classes/{jdk/internal => java/lang}/classfile/snippet-files/PackageSnippets.java (75%) rename src/java.base/share/classes/jdk/internal/classfile/impl/{ClassfileImpl.java => ClassFileImpl.java} (87%) rename src/java.base/share/classes/jdk/internal/classfile/impl/{ClassfileVersionImpl.java => ClassFileVersionImpl.java} (87%) create mode 100644 test/langtools/tools/javac/classfiles/attributes/SourceFile/SourceFileTestBase_legacy.java create mode 100644 test/langtools/tools/javac/classfiles/attributes/Synthetic/SyntheticTestDriver_legacy.java create mode 100644 test/langtools/tools/javac/classfiles/attributes/lib_legacy/TestBase.java create mode 100644 test/langtools/tools/javac/classfiles/attributes/lib_legacy/TestResult.java diff --git a/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java b/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java index ce9b94db7a6..82bd065efce 100644 --- a/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java +++ b/make/jdk/src/classes/build/tools/module/GenModuleInfoSource.java @@ -473,6 +473,11 @@ public class GenModuleInfoSource { if (parser.peekToken() != null) { // must be EOF throw parser.newError("is malformed"); } + } else if (token.equals("import")) { + nextIdentifier(parser); + skipTokenOrThrow(parser, ";", "missing semicolon"); + } else if (token.startsWith("@")) { + continue; } else { throw parser.newError("missing keyword"); } diff --git a/make/modules/java.base/Java.gmk b/make/modules/java.base/Java.gmk index 9d960402f76..8621ff945cc 100644 --- a/make/modules/java.base/Java.gmk +++ b/make/modules/java.base/Java.gmk @@ -36,8 +36,8 @@ EXCLUDE_FILES += \ $(TOPDIR)/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java EXCLUDES += java/lang/doc-files \ - jdk/internal/classfile/snippet-files \ - jdk/internal/classfile/components/snippet-files + java/lang/classfile/snippet-files \ + java/lang/classfile/components/snippet-files # Exclude BreakIterator classes that are just used in compile process to generate # data files and shouldn't go in the product diff --git a/make/test/BuildMicrobenchmark.gmk b/make/test/BuildMicrobenchmark.gmk index 0785688f09c..7660de061d2 100644 --- a/make/test/BuildMicrobenchmark.gmk +++ b/make/test/BuildMicrobenchmark.gmk @@ -98,11 +98,6 @@ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \ BIN := $(MICROBENCHMARK_CLASSES), \ JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \ --add-exports java.base/sun.invoke.util=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.constantpool=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.instruction=ALL-UNNAMED \ - --add-exports java.base/jdk.internal.classfile.components=ALL-UNNAMED \ --add-exports java.base/jdk.internal.classfile.impl=ALL-UNNAMED \ --add-exports java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ --add-exports java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED \ diff --git a/src/java.base/share/classes/java/lang/Module.java b/src/java.base/share/classes/java/lang/Module.java index 694281bcca8..7157ace8c47 100644 --- a/src/java.base/share/classes/java/lang/Module.java +++ b/src/java.base/share/classes/java/lang/Module.java @@ -52,13 +52,13 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; -import jdk.internal.classfile.AccessFlags; -import jdk.internal.classfile.Attribute; -import jdk.internal.classfile.ClassModel; -import jdk.internal.classfile.ClassTransform; -import jdk.internal.classfile.Classfile; -import jdk.internal.classfile.attribute.ModuleAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.AccessFlags; +import java.lang.classfile.Attribute; +import java.lang.classfile.ClassModel; +import java.lang.classfile.ClassTransform; +import java.lang.classfile.ClassFile; +import java.lang.classfile.attribute.ModuleAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import jdk.internal.javac.PreviewFeature; import jdk.internal.loader.BuiltinClassLoader; @@ -1591,7 +1591,7 @@ public final class Module implements AnnotatedElement { */ private Class loadModuleInfoClass(InputStream in) throws IOException { final String MODULE_INFO = "module-info"; - var cc = Classfile.of(Classfile.ConstantPoolSharingOption.NEW_POOL); + var cc = ClassFile.of(ClassFile.ConstantPoolSharingOption.NEW_POOL); byte[] bytes = cc.transform(cc.parse(in.readAllBytes()), (clb, cle) -> { switch (cle) { case AccessFlags af -> clb.withFlags(AccessFlag.INTERFACE, diff --git a/src/java.base/share/classes/jdk/internal/classfile/AccessFlags.java b/src/java.base/share/classes/java/lang/classfile/AccessFlags.java similarity index 96% rename from src/java.base/share/classes/jdk/internal/classfile/AccessFlags.java rename to src/java.base/share/classes/java/lang/classfile/AccessFlags.java index 5eb98f8295f..283094b81d6 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/AccessFlags.java +++ b/src/java.base/share/classes/java/lang/classfile/AccessFlags.java @@ -22,17 +22,21 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.Set; import jdk.internal.classfile.impl.AccessFlagsImpl; import java.lang.reflect.AccessFlag; +import jdk.internal.javac.PreviewFeature; /** * Models the access flags for a class, method, or field. Delivered as a * {@link ClassElement}, {@link FieldElement}, or {@link MethodElement} * when traversing the corresponding model type. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface AccessFlags extends ClassElement, MethodElement, FieldElement permits AccessFlagsImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/Annotation.java b/src/java.base/share/classes/java/lang/classfile/Annotation.java similarity index 87% rename from src/java.base/share/classes/jdk/internal/classfile/Annotation.java rename to src/java.base/share/classes/java/lang/classfile/Annotation.java index 116bedf16ed..3e7548d0859 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Annotation.java +++ b/src/java.base/share/classes/java/lang/classfile/Annotation.java @@ -22,18 +22,19 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.AnnotationImpl; import jdk.internal.classfile.impl.TemporaryConstantPool; import java.lang.constant.ClassDesc; import java.util.List; +import jdk.internal.javac.PreviewFeature; /** * Models an annotation on a declaration. @@ -44,7 +45,11 @@ import java.util.List; * @see RuntimeInvisibleAnnotationsAttribute * @see RuntimeVisibleParameterAnnotationsAttribute * @see RuntimeInvisibleParameterAnnotationsAttribute + * + * @sealedGraph + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface Annotation extends WritableElement permits TypeAnnotation, AnnotationImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/AnnotationElement.java b/src/java.base/share/classes/java/lang/classfile/AnnotationElement.java similarity index 96% rename from src/java.base/share/classes/jdk/internal/classfile/AnnotationElement.java rename to src/java.base/share/classes/java/lang/classfile/AnnotationElement.java index 4f21be3bc2e..41acb18e788 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/AnnotationElement.java +++ b/src/java.base/share/classes/java/lang/classfile/AnnotationElement.java @@ -22,20 +22,24 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ClassDesc; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.AnnotationImpl; import jdk.internal.classfile.impl.TemporaryConstantPool; +import jdk.internal.javac.PreviewFeature; /** * Models a key-value pair of an annotation. * * @see Annotation * @see AnnotationValue + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface AnnotationElement extends WritableElement permits AnnotationImpl.AnnotationElementImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/AnnotationValue.java b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java similarity index 83% rename from src/java.base/share/classes/jdk/internal/classfile/AnnotationValue.java rename to src/java.base/share/classes/java/lang/classfile/AnnotationValue.java index 1401b8b4e81..2882296b6bc 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/AnnotationValue.java +++ b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java @@ -22,14 +22,14 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.constantpool.AnnotationConstantValueEntry; -import jdk.internal.classfile.constantpool.DoubleEntry; -import jdk.internal.classfile.constantpool.FloatEntry; -import jdk.internal.classfile.constantpool.IntegerEntry; -import jdk.internal.classfile.constantpool.LongEntry; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.AnnotationConstantValueEntry; +import java.lang.classfile.constantpool.DoubleEntry; +import java.lang.classfile.constantpool.FloatEntry; +import java.lang.classfile.constantpool.IntegerEntry; +import java.lang.classfile.constantpool.LongEntry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.AnnotationImpl; import jdk.internal.classfile.impl.TemporaryConstantPool; @@ -37,34 +37,54 @@ import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDesc; import java.util.ArrayList; import java.util.List; +import jdk.internal.javac.PreviewFeature; /** * Models the value of a key-value pair of an annotation. * * @see Annotation * @see AnnotationElement + * + * @sealedGraph + * @since 22 */ - +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface AnnotationValue extends WritableElement permits AnnotationValue.OfAnnotation, AnnotationValue.OfArray, AnnotationValue.OfConstant, AnnotationValue.OfClass, AnnotationValue.OfEnum { - /** Models an annotation-valued element */ + /** + * Models an annotation-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfAnnotation extends AnnotationValue permits AnnotationImpl.OfAnnotationImpl { /** {@return the annotation} */ Annotation annotation(); } - /** Models an array-valued element */ + /** + * Models an array-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfArray extends AnnotationValue permits AnnotationImpl.OfArrayImpl { /** {@return the values} */ List values(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @sealedGraph + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfConstant extends AnnotationValue permits AnnotationValue.OfString, AnnotationValue.OfDouble, AnnotationValue.OfFloat, AnnotationValue.OfLong, @@ -77,70 +97,120 @@ public sealed interface AnnotationValue extends WritableElement ConstantDesc constantValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfString extends AnnotationValue.OfConstant permits AnnotationImpl.OfStringImpl { /** {@return the constant} */ String stringValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfDouble extends AnnotationValue.OfConstant permits AnnotationImpl.OfDoubleImpl { /** {@return the constant} */ double doubleValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfFloat extends AnnotationValue.OfConstant permits AnnotationImpl.OfFloatImpl { /** {@return the constant} */ float floatValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfLong extends AnnotationValue.OfConstant permits AnnotationImpl.OfLongImpl { /** {@return the constant} */ long longValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfInteger extends AnnotationValue.OfConstant permits AnnotationImpl.OfIntegerImpl { /** {@return the constant} */ int intValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfShort extends AnnotationValue.OfConstant permits AnnotationImpl.OfShortImpl { /** {@return the constant} */ short shortValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfCharacter extends AnnotationValue.OfConstant permits AnnotationImpl.OfCharacterImpl { /** {@return the constant} */ char charValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfByte extends AnnotationValue.OfConstant permits AnnotationImpl.OfByteImpl { /** {@return the constant} */ byte byteValue(); } - /** Models a constant-valued element */ + /** + * Models a constant-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfBoolean extends AnnotationValue.OfConstant permits AnnotationImpl.OfBooleanImpl { /** {@return the constant} */ boolean booleanValue(); } - /** Models a class-valued element */ + /** + * Models a class-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfClass extends AnnotationValue permits AnnotationImpl.OfClassImpl { /** {@return the class name} */ @@ -152,7 +222,12 @@ public sealed interface AnnotationValue extends WritableElement } } - /** Models an enum-valued element */ + /** + * Models an enum-valued element + * + * @since 22 + */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OfEnum extends AnnotationValue permits AnnotationImpl.OfEnumImpl { /** {@return the enum class name} */ @@ -168,7 +243,7 @@ public sealed interface AnnotationValue extends WritableElement } /** - * @return the tag character for this type as per {@jvms 4.7.16.1} + * {@return the tag character for this type as per {@jvms 4.7.16.1}} */ char tag(); @@ -379,10 +454,13 @@ public sealed interface AnnotationValue extends WritableElement /** * {@return an annotation element} The {@code value} parameter must be - * a primitive, a String, a ClassDesc, an enum constant, or an array of - * one of these. + * a primitive, a wrapper of primitive, a String, a ClassDesc, an enum + * constant, or an array of one of these. * * @param value the annotation value + * @throws IllegalArgumentException when the {@code value} parameter is not + * a primitive, a wrapper of primitive, a String, a ClassDesc, + * an enum constant, or an array of one of these. */ static AnnotationValue of(Object value) { if (value instanceof String s) { diff --git a/src/java.base/share/classes/jdk/internal/classfile/Attribute.java b/src/java.base/share/classes/java/lang/classfile/Attribute.java similarity index 58% rename from src/java.base/share/classes/jdk/internal/classfile/Attribute.java rename to src/java.base/share/classes/java/lang/classfile/Attribute.java index 13df75e1514..ad67bdf5365 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Attribute.java +++ b/src/java.base/share/classes/java/lang/classfile/Attribute.java @@ -22,47 +22,48 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.attribute.AnnotationDefaultAttribute; -import jdk.internal.classfile.attribute.BootstrapMethodsAttribute; -import jdk.internal.classfile.attribute.CharacterRangeTableAttribute; -import jdk.internal.classfile.attribute.CodeAttribute; -import jdk.internal.classfile.attribute.CompilationIDAttribute; -import jdk.internal.classfile.attribute.ConstantValueAttribute; -import jdk.internal.classfile.attribute.DeprecatedAttribute; -import jdk.internal.classfile.attribute.EnclosingMethodAttribute; -import jdk.internal.classfile.attribute.ExceptionsAttribute; -import jdk.internal.classfile.attribute.InnerClassesAttribute; -import jdk.internal.classfile.attribute.LineNumberTableAttribute; -import jdk.internal.classfile.attribute.LocalVariableTableAttribute; -import jdk.internal.classfile.attribute.LocalVariableTypeTableAttribute; -import jdk.internal.classfile.attribute.MethodParametersAttribute; -import jdk.internal.classfile.attribute.ModuleAttribute; -import jdk.internal.classfile.attribute.ModuleHashesAttribute; -import jdk.internal.classfile.attribute.ModuleMainClassAttribute; -import jdk.internal.classfile.attribute.ModulePackagesAttribute; -import jdk.internal.classfile.attribute.ModuleResolutionAttribute; -import jdk.internal.classfile.attribute.ModuleTargetAttribute; -import jdk.internal.classfile.attribute.NestHostAttribute; -import jdk.internal.classfile.attribute.NestMembersAttribute; -import jdk.internal.classfile.attribute.PermittedSubclassesAttribute; -import jdk.internal.classfile.attribute.RecordAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.SignatureAttribute; -import jdk.internal.classfile.attribute.SourceDebugExtensionAttribute; -import jdk.internal.classfile.attribute.SourceFileAttribute; -import jdk.internal.classfile.attribute.SourceIDAttribute; -import jdk.internal.classfile.attribute.StackMapTableAttribute; -import jdk.internal.classfile.attribute.SyntheticAttribute; -import jdk.internal.classfile.attribute.UnknownAttribute; +import java.lang.classfile.attribute.AnnotationDefaultAttribute; +import java.lang.classfile.attribute.BootstrapMethodsAttribute; +import java.lang.classfile.attribute.CharacterRangeTableAttribute; +import java.lang.classfile.attribute.CodeAttribute; +import java.lang.classfile.attribute.CompilationIDAttribute; +import java.lang.classfile.attribute.ConstantValueAttribute; +import java.lang.classfile.attribute.DeprecatedAttribute; +import java.lang.classfile.attribute.EnclosingMethodAttribute; +import java.lang.classfile.attribute.ExceptionsAttribute; +import java.lang.classfile.attribute.InnerClassesAttribute; +import java.lang.classfile.attribute.LineNumberTableAttribute; +import java.lang.classfile.attribute.LocalVariableTableAttribute; +import java.lang.classfile.attribute.LocalVariableTypeTableAttribute; +import java.lang.classfile.attribute.MethodParametersAttribute; +import java.lang.classfile.attribute.ModuleAttribute; +import java.lang.classfile.attribute.ModuleHashesAttribute; +import java.lang.classfile.attribute.ModuleMainClassAttribute; +import java.lang.classfile.attribute.ModulePackagesAttribute; +import java.lang.classfile.attribute.ModuleResolutionAttribute; +import java.lang.classfile.attribute.ModuleTargetAttribute; +import java.lang.classfile.attribute.NestHostAttribute; +import java.lang.classfile.attribute.NestMembersAttribute; +import java.lang.classfile.attribute.PermittedSubclassesAttribute; +import java.lang.classfile.attribute.RecordAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.SignatureAttribute; +import java.lang.classfile.attribute.SourceDebugExtensionAttribute; +import java.lang.classfile.attribute.SourceFileAttribute; +import java.lang.classfile.attribute.SourceIDAttribute; +import java.lang.classfile.attribute.StackMapTableAttribute; +import java.lang.classfile.attribute.SyntheticAttribute; +import java.lang.classfile.attribute.UnknownAttribute; import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.UnboundAttribute; +import jdk.internal.javac.PreviewFeature; /** * Models a classfile attribute {@jvms 4.7}. Many, though not all, subtypes of @@ -73,7 +74,11 @@ import jdk.internal.classfile.impl.UnboundAttribute; * directly from the corresponding model type through {@link * AttributedElement#findAttribute(AttributeMapper)}. * @param the attribute type + * + * @sealedGraph + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface Attribute> extends WritableElement permits AnnotationDefaultAttribute, BootstrapMethodsAttribute, @@ -91,7 +96,7 @@ public sealed interface Attribute> RuntimeVisibleTypeAnnotationsAttribute, SignatureAttribute, SourceDebugExtensionAttribute, SourceFileAttribute, SourceIDAttribute, StackMapTableAttribute, SyntheticAttribute, - UnknownAttribute, BoundAttribute, UnboundAttribute { + UnknownAttribute, BoundAttribute, UnboundAttribute, CustomAttribute { /** * {@return the name of the attribute} */ diff --git a/src/java.base/share/classes/jdk/internal/classfile/AttributeMapper.java b/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java similarity index 90% rename from src/java.base/share/classes/jdk/internal/classfile/AttributeMapper.java rename to src/java.base/share/classes/java/lang/classfile/AttributeMapper.java index 2914a9d5110..0e7d625290e 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/AttributeMapper.java +++ b/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java @@ -22,7 +22,9 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; + +import jdk.internal.javac.PreviewFeature; /** * Bidirectional mapper between the classfile representation of an attribute and @@ -34,12 +36,18 @@ package jdk.internal.classfile; * Classes that model nonstandard attributes should extend {@link * CustomAttribute}. * @param the attribute type + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public interface AttributeMapper { /** * Attribute stability indicator + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum AttributeStability { /** @@ -60,13 +68,13 @@ public interface AttributeMapper { /** * The attribute may contain indexes into structured not managed by the library (type variable lists, etc) - * and so we consult the {@link Classfile.AttributesProcessingOption} option to determine whether to preserve + * and so we consult the {@link ClassFile.AttributesProcessingOption} option to determine whether to preserve * or drop it during transformation. */ UNSTABLE, /** - * The attribute is completely unknown and so we consult the {@link Classfile.AttributesProcessingOption} option + * The attribute is completely unknown and so we consult the {@link ClassFile.AttributesProcessingOption} option * to determine whether to preserve or drop it during transformation. */ UNKNOWN @@ -96,16 +104,10 @@ public interface AttributeMapper { */ void writeAttribute(BufWriter buf, A attr); - /** - * {@return The earliest classfile version for which this attribute is - * applicable} - */ - default int validSince() { - return Classfile.JAVA_1_VERSION; - } - /** * {@return whether this attribute may appear more than once in a given location} + * + * @implSpec The default implementation returns {@code false} */ default boolean allowMultiple() { return false; diff --git a/src/java.base/share/classes/jdk/internal/classfile/AttributedElement.java b/src/java.base/share/classes/java/lang/classfile/AttributedElement.java similarity index 89% rename from src/java.base/share/classes/jdk/internal/classfile/AttributedElement.java rename to src/java.base/share/classes/java/lang/classfile/AttributedElement.java index f3f497f3008..63b2f1e03a9 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/AttributedElement.java +++ b/src/java.base/share/classes/java/lang/classfile/AttributedElement.java @@ -22,20 +22,25 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.ArrayList; import java.util.List; import java.util.Optional; -import jdk.internal.classfile.attribute.RecordComponentInfo; +import java.lang.classfile.attribute.RecordComponentInfo; import jdk.internal.classfile.impl.AbstractUnboundModel; +import jdk.internal.javac.PreviewFeature; /** - * A {@link ClassfileElement} describing an entity that has attributes, such + * A {@link ClassFileElement} describing an entity that has attributes, such * as a class, field, method, code attribute, or record component. + * + * @sealedGraph + * @since 22 */ -public sealed interface AttributedElement extends ClassfileElement +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface AttributedElement extends ClassFileElement permits ClassModel, CodeModel, FieldModel, MethodModel, RecordComponentInfo, AbstractUnboundModel { diff --git a/src/java.base/share/classes/jdk/internal/classfile/Attributes.java b/src/java.base/share/classes/java/lang/classfile/Attributes.java similarity index 90% rename from src/java.base/share/classes/jdk/internal/classfile/Attributes.java rename to src/java.base/share/classes/java/lang/classfile/Attributes.java index 4e230a161ac..75e06e7c3f3 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Attributes.java +++ b/src/java.base/share/classes/java/lang/classfile/Attributes.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.Collections; import java.util.HashMap; @@ -30,66 +30,70 @@ import java.util.List; import java.util.Map; import java.util.Set; -import jdk.internal.classfile.attribute.AnnotationDefaultAttribute; -import jdk.internal.classfile.attribute.BootstrapMethodsAttribute; -import jdk.internal.classfile.attribute.CharacterRangeInfo; -import jdk.internal.classfile.attribute.CharacterRangeTableAttribute; -import jdk.internal.classfile.attribute.CodeAttribute; -import jdk.internal.classfile.attribute.CompilationIDAttribute; -import jdk.internal.classfile.attribute.ConstantValueAttribute; -import jdk.internal.classfile.attribute.DeprecatedAttribute; -import jdk.internal.classfile.attribute.EnclosingMethodAttribute; -import jdk.internal.classfile.attribute.ExceptionsAttribute; -import jdk.internal.classfile.attribute.InnerClassInfo; -import jdk.internal.classfile.attribute.InnerClassesAttribute; -import jdk.internal.classfile.attribute.LineNumberInfo; -import jdk.internal.classfile.attribute.LineNumberTableAttribute; -import jdk.internal.classfile.attribute.LocalVariableInfo; -import jdk.internal.classfile.attribute.LocalVariableTableAttribute; -import jdk.internal.classfile.attribute.LocalVariableTypeInfo; -import jdk.internal.classfile.attribute.LocalVariableTypeTableAttribute; -import jdk.internal.classfile.attribute.MethodParameterInfo; -import jdk.internal.classfile.attribute.MethodParametersAttribute; -import jdk.internal.classfile.attribute.ModuleAttribute; -import jdk.internal.classfile.attribute.ModuleExportInfo; -import jdk.internal.classfile.attribute.ModuleHashInfo; -import jdk.internal.classfile.attribute.ModuleHashesAttribute; -import jdk.internal.classfile.attribute.ModuleMainClassAttribute; -import jdk.internal.classfile.attribute.ModuleOpenInfo; -import jdk.internal.classfile.attribute.ModulePackagesAttribute; -import jdk.internal.classfile.attribute.ModuleProvideInfo; -import jdk.internal.classfile.attribute.ModuleRequireInfo; -import jdk.internal.classfile.attribute.ModuleResolutionAttribute; -import jdk.internal.classfile.attribute.ModuleTargetAttribute; -import jdk.internal.classfile.attribute.NestHostAttribute; -import jdk.internal.classfile.attribute.NestMembersAttribute; -import jdk.internal.classfile.attribute.PermittedSubclassesAttribute; -import jdk.internal.classfile.attribute.RecordAttribute; -import jdk.internal.classfile.attribute.RecordComponentInfo; -import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.SignatureAttribute; -import jdk.internal.classfile.attribute.SourceDebugExtensionAttribute; -import jdk.internal.classfile.attribute.SourceFileAttribute; -import jdk.internal.classfile.attribute.SourceIDAttribute; -import jdk.internal.classfile.attribute.StackMapTableAttribute; -import jdk.internal.classfile.attribute.SyntheticAttribute; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.attribute.AnnotationDefaultAttribute; +import java.lang.classfile.attribute.BootstrapMethodsAttribute; +import java.lang.classfile.attribute.CharacterRangeInfo; +import java.lang.classfile.attribute.CharacterRangeTableAttribute; +import java.lang.classfile.attribute.CodeAttribute; +import java.lang.classfile.attribute.CompilationIDAttribute; +import java.lang.classfile.attribute.ConstantValueAttribute; +import java.lang.classfile.attribute.DeprecatedAttribute; +import java.lang.classfile.attribute.EnclosingMethodAttribute; +import java.lang.classfile.attribute.ExceptionsAttribute; +import java.lang.classfile.attribute.InnerClassInfo; +import java.lang.classfile.attribute.InnerClassesAttribute; +import java.lang.classfile.attribute.LineNumberInfo; +import java.lang.classfile.attribute.LineNumberTableAttribute; +import java.lang.classfile.attribute.LocalVariableInfo; +import java.lang.classfile.attribute.LocalVariableTableAttribute; +import java.lang.classfile.attribute.LocalVariableTypeInfo; +import java.lang.classfile.attribute.LocalVariableTypeTableAttribute; +import java.lang.classfile.attribute.MethodParameterInfo; +import java.lang.classfile.attribute.MethodParametersAttribute; +import java.lang.classfile.attribute.ModuleAttribute; +import java.lang.classfile.attribute.ModuleExportInfo; +import java.lang.classfile.attribute.ModuleHashInfo; +import java.lang.classfile.attribute.ModuleHashesAttribute; +import java.lang.classfile.attribute.ModuleMainClassAttribute; +import java.lang.classfile.attribute.ModuleOpenInfo; +import java.lang.classfile.attribute.ModulePackagesAttribute; +import java.lang.classfile.attribute.ModuleProvideInfo; +import java.lang.classfile.attribute.ModuleRequireInfo; +import java.lang.classfile.attribute.ModuleResolutionAttribute; +import java.lang.classfile.attribute.ModuleTargetAttribute; +import java.lang.classfile.attribute.NestHostAttribute; +import java.lang.classfile.attribute.NestMembersAttribute; +import java.lang.classfile.attribute.PermittedSubclassesAttribute; +import java.lang.classfile.attribute.RecordAttribute; +import java.lang.classfile.attribute.RecordComponentInfo; +import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.SignatureAttribute; +import java.lang.classfile.attribute.SourceDebugExtensionAttribute; +import java.lang.classfile.attribute.SourceFileAttribute; +import java.lang.classfile.attribute.SourceIDAttribute; +import java.lang.classfile.attribute.StackMapTableAttribute; +import java.lang.classfile.attribute.SyntheticAttribute; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.AbstractAttributeMapper; import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.CodeImpl; import jdk.internal.classfile.impl.AbstractPoolEntry; import jdk.internal.classfile.impl.StackMapDecoder; +import jdk.internal.javac.PreviewFeature; /** * Attribute mappers for standard classfile attributes. * * @see AttributeMapper + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public class Attributes { /** AnnotationDefault */ @@ -167,10 +171,10 @@ public class Attributes { /** RuntimeInvisibleAnnotations */ public static final String NAME_RUNTIME_INVISIBLE_ANNOTATIONS = "RuntimeInvisibleAnnotations"; - /** RuntimeInvisibleTypeAnnotations */ + /** RuntimeInvisibleParameterAnnotations */ public static final String NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = "RuntimeInvisibleParameterAnnotations"; - /** */ + /** RuntimeInvisibleTypeAnnotations */ public static final String NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = "RuntimeInvisibleTypeAnnotations"; /** RuntimeVisibleAnnotations */ @@ -205,7 +209,7 @@ public class Attributes { /** Attribute mapper for the {@code AnnotationDefault} attribute */ public static final AttributeMapper - ANNOTATION_DEFAULT = new AbstractAttributeMapper<>(NAME_ANNOTATION_DEFAULT, Classfile.JAVA_5_VERSION) { + ANNOTATION_DEFAULT = new AbstractAttributeMapper<>(NAME_ANNOTATION_DEFAULT) { @Override public AnnotationDefaultAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundAnnotationDefaultAttr(cf, this, p); @@ -224,7 +228,7 @@ public class Attributes { /** Attribute mapper for the {@code BootstrapMethods} attribute */ public static final AttributeMapper - BOOTSTRAP_METHODS = new AbstractAttributeMapper<>(NAME_BOOTSTRAP_METHODS, Classfile.JAVA_17_VERSION) { + BOOTSTRAP_METHODS = new AbstractAttributeMapper<>(NAME_BOOTSTRAP_METHODS) { @Override public BootstrapMethodsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundBootstrapMethodsAttribute(cf, this, p); @@ -243,7 +247,7 @@ public class Attributes { /** Attribute mapper for the {@code CharacterRangeTable} attribute */ public static final AttributeMapper - CHARACTER_RANGE_TABLE = new AbstractAttributeMapper<>(NAME_CHARACTER_RANGE_TABLE, true, Classfile.JAVA_4_VERSION) { + CHARACTER_RANGE_TABLE = new AbstractAttributeMapper<>(NAME_CHARACTER_RANGE_TABLE, true) { @Override public CharacterRangeTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundCharacterRangeTableAttribute(cf, this, p); @@ -347,7 +351,7 @@ public class Attributes { /** Attribute mapper for the {@code EnclosingMethod} attribute */ public static final AttributeMapper - ENCLOSING_METHOD = new AbstractAttributeMapper<>(NAME_ENCLOSING_METHOD, Classfile.JAVA_5_VERSION) { + ENCLOSING_METHOD = new AbstractAttributeMapper<>(NAME_ENCLOSING_METHOD) { @Override public EnclosingMethodAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundEnclosingMethodAttribute(cf, this, p); @@ -463,7 +467,7 @@ public class Attributes { /** Attribute mapper for the {@code LocalVariableTypeTable} attribute */ public static final AttributeMapper - LOCAL_VARIABLE_TYPE_TABLE = new AbstractAttributeMapper<>(NAME_LOCAL_VARIABLE_TYPE_TABLE, true, Classfile.JAVA_5_VERSION) { + LOCAL_VARIABLE_TYPE_TABLE = new AbstractAttributeMapper<>(NAME_LOCAL_VARIABLE_TYPE_TABLE, true) { @Override public LocalVariableTypeTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundLocalVariableTypeTableAttribute(e, cf, this, p); @@ -490,7 +494,7 @@ public class Attributes { /** Attribute mapper for the {@code MethodParameters} attribute */ public static final AttributeMapper - METHOD_PARAMETERS = new AbstractAttributeMapper<>(NAME_METHOD_PARAMETERS, Classfile.JAVA_8_VERSION) { + METHOD_PARAMETERS = new AbstractAttributeMapper<>(NAME_METHOD_PARAMETERS) { @Override public MethodParametersAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundMethodParametersAttribute(cf, this, p); @@ -514,7 +518,7 @@ public class Attributes { /** Attribute mapper for the {@code Module} attribute */ public static final AttributeMapper - MODULE = new AbstractAttributeMapper<>(NAME_MODULE, Classfile.JAVA_9_VERSION) { + MODULE = new AbstractAttributeMapper<>(NAME_MODULE) { @Override public ModuleAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundModuleAttribute(cf, this, p); @@ -559,7 +563,7 @@ public class Attributes { /** Attribute mapper for the {@code ModuleHashes} attribute */ public static final AttributeMapper - MODULE_HASHES = new AbstractAttributeMapper<>(NAME_MODULE_HASHES, Classfile.JAVA_9_VERSION) { + MODULE_HASHES = new AbstractAttributeMapper<>(NAME_MODULE_HASHES) { @Override public ModuleHashesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundModuleHashesAttribute(cf, this, p); @@ -585,7 +589,7 @@ public class Attributes { /** Attribute mapper for the {@code ModuleMainClass} attribute */ public static final AttributeMapper - MODULE_MAIN_CLASS = new AbstractAttributeMapper<>(NAME_MODULE_MAIN_CLASS, Classfile.JAVA_9_VERSION) { + MODULE_MAIN_CLASS = new AbstractAttributeMapper<>(NAME_MODULE_MAIN_CLASS) { @Override public ModuleMainClassAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundModuleMainClassAttribute(cf, this, p); @@ -604,7 +608,7 @@ public class Attributes { /** Attribute mapper for the {@code ModulePackages} attribute */ public static final AttributeMapper - MODULE_PACKAGES = new AbstractAttributeMapper<>(NAME_MODULE_PACKAGES, Classfile.JAVA_9_VERSION) { + MODULE_PACKAGES = new AbstractAttributeMapper<>(NAME_MODULE_PACKAGES) { @Override public ModulePackagesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundModulePackagesAttribute(cf, this, p); @@ -623,7 +627,7 @@ public class Attributes { /** Attribute mapper for the {@code ModuleResolution} attribute */ public static final AttributeMapper - MODULE_RESOLUTION = new AbstractAttributeMapper<>(NAME_MODULE_RESOLUTION, Classfile.JAVA_9_VERSION) { + MODULE_RESOLUTION = new AbstractAttributeMapper<>(NAME_MODULE_RESOLUTION) { @Override public ModuleResolutionAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundModuleResolutionAttribute(cf, this, p); @@ -642,7 +646,7 @@ public class Attributes { /** Attribute mapper for the {@code ModuleTarget} attribute */ public static final AttributeMapper - MODULE_TARGET = new AbstractAttributeMapper<>(NAME_MODULE_TARGET, Classfile.JAVA_9_VERSION) { + MODULE_TARGET = new AbstractAttributeMapper<>(NAME_MODULE_TARGET) { @Override public ModuleTargetAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundModuleTargetAttribute(cf, this, p); @@ -661,7 +665,7 @@ public class Attributes { /** Attribute mapper for the {@code NestHost} attribute */ public static final AttributeMapper - NEST_HOST = new AbstractAttributeMapper<>(NAME_NEST_HOST, Classfile.JAVA_11_VERSION) { + NEST_HOST = new AbstractAttributeMapper<>(NAME_NEST_HOST) { @Override public NestHostAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundNestHostAttribute(cf, this, p); @@ -680,7 +684,7 @@ public class Attributes { /** Attribute mapper for the {@code NestMembers} attribute */ public static final AttributeMapper - NEST_MEMBERS = new AbstractAttributeMapper<>(NAME_NEST_MEMBERS, Classfile.JAVA_11_VERSION) { + NEST_MEMBERS = new AbstractAttributeMapper<>(NAME_NEST_MEMBERS) { @Override public NestMembersAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundNestMembersAttribute(cf, this, p); @@ -699,7 +703,7 @@ public class Attributes { /** Attribute mapper for the {@code PermittedSubclasses} attribute */ public static final AttributeMapper - PERMITTED_SUBCLASSES = new AbstractAttributeMapper<>(NAME_PERMITTED_SUBCLASSES, Classfile.JAVA_15_VERSION) { + PERMITTED_SUBCLASSES = new AbstractAttributeMapper<>(NAME_PERMITTED_SUBCLASSES) { @Override public PermittedSubclassesAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundPermittedSubclassesAttribute(cf, this, p); @@ -718,7 +722,7 @@ public class Attributes { /** Attribute mapper for the {@code Record} attribute */ public static final AttributeMapper - RECORD = new AbstractAttributeMapper<>(NAME_RECORD, Classfile.JAVA_16_VERSION) { + RECORD = new AbstractAttributeMapper<>(NAME_RECORD) { @Override public RecordAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundRecordAttribute(cf, this, p); @@ -743,7 +747,7 @@ public class Attributes { /** Attribute mapper for the {@code RuntimeInvisibleAnnotations} attribute */ public static final AttributeMapper - RUNTIME_INVISIBLE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_ANNOTATIONS, Classfile.JAVA_5_VERSION) { + RUNTIME_INVISIBLE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_ANNOTATIONS) { @Override public RuntimeInvisibleAnnotationsAttribute readAttribute(AttributedElement enclosing, ClassReader cf, int pos) { return new BoundAttribute.BoundRuntimeInvisibleAnnotationsAttribute(cf, pos); @@ -762,7 +766,7 @@ public class Attributes { /** Attribute mapper for the {@code RuntimeInvisibleParameterAnnotations} attribute */ public static final AttributeMapper - RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS, Classfile.JAVA_5_VERSION) { + RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS) { @Override public RuntimeInvisibleParameterAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundRuntimeInvisibleParameterAnnotationsAttribute(cf, this, p); @@ -784,7 +788,7 @@ public class Attributes { /** Attribute mapper for the {@code RuntimeInvisibleTypeAnnotations} attribute */ public static final AttributeMapper - RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS, Classfile.JAVA_8_VERSION) { + RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_INVISIBLE_TYPE_ANNOTATIONS) { @Override public RuntimeInvisibleTypeAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundRuntimeInvisibleTypeAnnotationsAttribute(e, cf, this, p); @@ -803,7 +807,7 @@ public class Attributes { /** Attribute mapper for the {@code RuntimeVisibleAnnotations} attribute */ public static final AttributeMapper - RUNTIME_VISIBLE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_ANNOTATIONS, Classfile.JAVA_5_VERSION) { + RUNTIME_VISIBLE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_ANNOTATIONS) { @Override public RuntimeVisibleAnnotationsAttribute readAttribute(AttributedElement enclosing, ClassReader cf, int pos) { return new BoundAttribute.BoundRuntimeVisibleAnnotationsAttribute(cf, pos); @@ -822,7 +826,7 @@ public class Attributes { /** Attribute mapper for the {@code RuntimeVisibleParameterAnnotations} attribute */ public static final AttributeMapper - RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS, Classfile.JAVA_5_VERSION) { + RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS) { @Override public RuntimeVisibleParameterAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundRuntimeVisibleParameterAnnotationsAttribute(cf, this, p); @@ -844,7 +848,7 @@ public class Attributes { /** Attribute mapper for the {@code RuntimeVisibleTypeAnnotations} attribute */ public static final AttributeMapper - RUNTIME_VISIBLE_TYPE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_TYPE_ANNOTATIONS, Classfile.JAVA_8_VERSION) { + RUNTIME_VISIBLE_TYPE_ANNOTATIONS = new AbstractAttributeMapper<>(NAME_RUNTIME_VISIBLE_TYPE_ANNOTATIONS) { @Override public RuntimeVisibleTypeAnnotationsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundRuntimeVisibleTypeAnnotationsAttribute(e, cf, this, p); @@ -863,7 +867,7 @@ public class Attributes { /** Attribute mapper for the {@code Signature} attribute */ public static final AttributeMapper - SIGNATURE = new AbstractAttributeMapper<>(NAME_SIGNATURE, Classfile.JAVA_5_VERSION) { + SIGNATURE = new AbstractAttributeMapper<>(NAME_SIGNATURE) { @Override public SignatureAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundSignatureAttribute(cf, this, p); @@ -882,7 +886,7 @@ public class Attributes { /** Attribute mapper for the {@code SourceDebugExtension} attribute */ public static final AttributeMapper - SOURCE_DEBUG_EXTENSION = new AbstractAttributeMapper<>(NAME_SOURCE_DEBUG_EXTENSION, Classfile.JAVA_5_VERSION) { + SOURCE_DEBUG_EXTENSION = new AbstractAttributeMapper<>(NAME_SOURCE_DEBUG_EXTENSION) { @Override public SourceDebugExtensionAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundSourceDebugExtensionAttribute(cf, this, p); @@ -939,7 +943,7 @@ public class Attributes { /** Attribute mapper for the {@code StackMapTable} attribute */ public static final AttributeMapper - STACK_MAP_TABLE = new AbstractAttributeMapper<>(NAME_STACK_MAP_TABLE, Classfile.JAVA_6_VERSION) { + STACK_MAP_TABLE = new AbstractAttributeMapper<>(NAME_STACK_MAP_TABLE) { @Override public StackMapTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) { return new BoundAttribute.BoundStackMapTableAttribute((CodeImpl)e, cf, this, p); diff --git a/src/java.base/share/classes/jdk/internal/classfile/BootstrapMethodEntry.java b/src/java.base/share/classes/java/lang/classfile/BootstrapMethodEntry.java similarity index 86% rename from src/java.base/share/classes/jdk/internal/classfile/BootstrapMethodEntry.java rename to src/java.base/share/classes/java/lang/classfile/BootstrapMethodEntry.java index fb7a8d1401f..c472dca8530 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/BootstrapMethodEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/BootstrapMethodEntry.java @@ -23,21 +23,25 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.List; -import jdk.internal.classfile.constantpool.ConstantPool; -import jdk.internal.classfile.constantpool.LoadableConstantEntry; -import jdk.internal.classfile.constantpool.MethodHandleEntry; +import java.lang.classfile.constantpool.ConstantPool; +import java.lang.classfile.constantpool.LoadableConstantEntry; +import java.lang.classfile.constantpool.MethodHandleEntry; import jdk.internal.classfile.impl.BootstrapMethodEntryImpl; +import jdk.internal.javac.PreviewFeature; /** * Models an entry in the bootstrap method table. The bootstrap method table * is stored in the {@code BootstrapMethods} attribute, but is modeled by * the {@link ConstantPool}, since the bootstrap method table is logically * part of the constant pool. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface BootstrapMethodEntry extends WritableElement permits BootstrapMethodEntryImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/BufWriter.java b/src/java.base/share/classes/java/lang/classfile/BufWriter.java similarity index 94% rename from src/java.base/share/classes/jdk/internal/classfile/BufWriter.java rename to src/java.base/share/classes/java/lang/classfile/BufWriter.java index a572dd16a53..bab8ebda4b8 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/BufWriter.java +++ b/src/java.base/share/classes/java/lang/classfile/BufWriter.java @@ -22,21 +22,25 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.nio.ByteBuffer; import java.util.List; -import jdk.internal.classfile.constantpool.ConstantPool; -import jdk.internal.classfile.constantpool.ConstantPoolBuilder; -import jdk.internal.classfile.constantpool.PoolEntry; +import java.lang.classfile.constantpool.ConstantPool; +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.classfile.constantpool.PoolEntry; import jdk.internal.classfile.impl.BufWriterImpl; +import jdk.internal.javac.PreviewFeature; /** - * Supports writing portions of a classfile to a growable buffer. Method + * Supports writing portions of a classfile to a growable buffer. Methods * are provided to write various standard entities (e.g., {@code u2}, {@code u4}) * to the end of the buffer, as well as to create constant pool entries. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface BufWriter permits BufWriterImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassBuilder.java b/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java similarity index 94% rename from src/java.base/share/classes/jdk/internal/classfile/ClassBuilder.java rename to src/java.base/share/classes/java/lang/classfile/ClassBuilder.java index 13af4df047a..f1b8bb13d27 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassBuilder.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ClassDesc; @@ -33,25 +33,29 @@ import java.util.List; import java.util.Optional; import java.util.function.Consumer; -import jdk.internal.classfile.constantpool.ClassEntry; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.ChainedClassBuilder; import jdk.internal.classfile.impl.DirectClassBuilder; import jdk.internal.classfile.impl.Util; import java.lang.reflect.AccessFlag; -import jdk.internal.classfile.attribute.CodeAttribute; +import java.lang.classfile.attribute.CodeAttribute; +import jdk.internal.javac.PreviewFeature; /** * A builder for classfiles. Builders are not created directly; they are passed - * to handlers by methods such as {@link Classfile#build(ClassDesc, Consumer)} + * to handlers by methods such as {@link ClassFile#build(ClassDesc, Consumer)} * or to class transforms. The elements of a classfile can be specified - * abstractly (by passing a {@link ClassElement} to {@link #with(ClassfileElement)}) + * abstractly (by passing a {@link ClassElement} to {@link #with(ClassFileElement)}) * or concretely by calling the various {@code withXxx} methods. * * @see ClassTransform + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface ClassBuilder - extends ClassfileBuilder + extends ClassFileBuilder permits ChainedClassBuilder, DirectClassBuilder { /** @@ -67,7 +71,7 @@ public sealed interface ClassBuilder * @return this builder */ default ClassBuilder withVersion(int major, int minor) { - return with(ClassfileVersion.of(major, minor)); + return with(ClassFileVersion.of(major, minor)); } /** @@ -101,6 +105,7 @@ public sealed interface ClassBuilder * Sets the superclass of this class. * @param desc the superclass * @return this builder + * @throws IllegalArgumentException if {@code desc} represents a primitive type */ default ClassBuilder withSuperclass(ClassDesc desc) { return withSuperclass(constantPool().classEntry(desc)); diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassElement.java b/src/java.base/share/classes/java/lang/classfile/ClassElement.java similarity index 51% rename from src/java.base/share/classes/jdk/internal/classfile/ClassElement.java rename to src/java.base/share/classes/java/lang/classfile/ClassElement.java index 29c07cafcaa..3852f7d1293 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassElement.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassElement.java @@ -22,39 +22,44 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.attribute.CompilationIDAttribute; -import jdk.internal.classfile.attribute.DeprecatedAttribute; -import jdk.internal.classfile.attribute.EnclosingMethodAttribute; -import jdk.internal.classfile.attribute.InnerClassesAttribute; -import jdk.internal.classfile.attribute.ModuleAttribute; -import jdk.internal.classfile.attribute.ModuleHashesAttribute; -import jdk.internal.classfile.attribute.ModuleMainClassAttribute; -import jdk.internal.classfile.attribute.ModulePackagesAttribute; -import jdk.internal.classfile.attribute.ModuleResolutionAttribute; -import jdk.internal.classfile.attribute.ModuleTargetAttribute; -import jdk.internal.classfile.attribute.NestHostAttribute; -import jdk.internal.classfile.attribute.NestMembersAttribute; -import jdk.internal.classfile.attribute.PermittedSubclassesAttribute; -import jdk.internal.classfile.attribute.RecordAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.SignatureAttribute; -import jdk.internal.classfile.attribute.SourceDebugExtensionAttribute; -import jdk.internal.classfile.attribute.SourceFileAttribute; -import jdk.internal.classfile.attribute.SourceIDAttribute; -import jdk.internal.classfile.attribute.SyntheticAttribute; -import jdk.internal.classfile.attribute.UnknownAttribute; +import java.lang.classfile.attribute.CompilationIDAttribute; +import java.lang.classfile.attribute.DeprecatedAttribute; +import java.lang.classfile.attribute.EnclosingMethodAttribute; +import java.lang.classfile.attribute.InnerClassesAttribute; +import java.lang.classfile.attribute.ModuleAttribute; +import java.lang.classfile.attribute.ModuleHashesAttribute; +import java.lang.classfile.attribute.ModuleMainClassAttribute; +import java.lang.classfile.attribute.ModulePackagesAttribute; +import java.lang.classfile.attribute.ModuleResolutionAttribute; +import java.lang.classfile.attribute.ModuleTargetAttribute; +import java.lang.classfile.attribute.NestHostAttribute; +import java.lang.classfile.attribute.NestMembersAttribute; +import java.lang.classfile.attribute.PermittedSubclassesAttribute; +import java.lang.classfile.attribute.RecordAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.SignatureAttribute; +import java.lang.classfile.attribute.SourceDebugExtensionAttribute; +import java.lang.classfile.attribute.SourceFileAttribute; +import java.lang.classfile.attribute.SourceIDAttribute; +import java.lang.classfile.attribute.SyntheticAttribute; +import java.lang.classfile.attribute.UnknownAttribute; +import jdk.internal.javac.PreviewFeature; /** - * A {@link ClassfileElement} that can appear when traversing the elements - * of a {@link ClassModel} or be presented to a {@link ClassBuilder}. + * A marker interface for elements that can appear when traversing + * a {@link ClassModel} or be presented to a {@link ClassBuilder}. + * + * @sealedGraph + * @since 22 */ -public sealed interface ClassElement extends ClassfileElement - permits AccessFlags, Superclass, Interfaces, ClassfileVersion, +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface ClassElement extends ClassFileElement + permits AccessFlags, Superclass, Interfaces, ClassFileVersion, FieldModel, MethodModel, CustomAttribute, CompilationIDAttribute, DeprecatedAttribute, EnclosingMethodAttribute, InnerClassesAttribute, diff --git a/src/java.base/share/classes/jdk/internal/classfile/Classfile.java b/src/java.base/share/classes/java/lang/classfile/ClassFile.java similarity index 50% rename from src/java.base/share/classes/jdk/internal/classfile/Classfile.java rename to src/java.base/share/classes/java/lang/classfile/ClassFile.java index 7ee9a8299ca..7b1ef16ba6d 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Classfile.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFile.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.io.IOException; import java.lang.constant.ClassDesc; @@ -31,40 +31,44 @@ import java.nio.file.Path; import java.util.function.Consumer; import java.util.function.Function; -import jdk.internal.classfile.attribute.ModuleAttribute; -import jdk.internal.classfile.attribute.UnknownAttribute; -import jdk.internal.classfile.constantpool.ClassEntry; -import jdk.internal.classfile.constantpool.ConstantPoolBuilder; -import jdk.internal.classfile.constantpool.Utf8Entry; -import jdk.internal.classfile.impl.ClassfileImpl; +import java.lang.classfile.attribute.ModuleAttribute; +import java.lang.classfile.attribute.UnknownAttribute; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.classfile.constantpool.Utf8Entry; +import jdk.internal.classfile.impl.ClassFileImpl; import jdk.internal.classfile.impl.TemporaryConstantPool; import java.lang.reflect.AccessFlag; -import jdk.internal.classfile.attribute.CharacterRangeInfo; -import jdk.internal.classfile.attribute.LocalVariableInfo; -import jdk.internal.classfile.attribute.LocalVariableTypeInfo; -import jdk.internal.classfile.instruction.ExceptionCatch; +import java.lang.classfile.attribute.CharacterRangeInfo; +import java.lang.classfile.attribute.LocalVariableInfo; +import java.lang.classfile.attribute.LocalVariableTypeInfo; +import java.lang.classfile.instruction.ExceptionCatch; import static java.util.Objects.requireNonNull; +import jdk.internal.javac.PreviewFeature; /** * Represents a context for parsing, transforming, and generating classfiles. - * A {@code Classfile} has a set of options that condition how parsing and + * A {@code ClassFile} has a set of options that condition how parsing and * generation is done. + * + * @since 22 */ -public sealed interface Classfile - permits ClassfileImpl { +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface ClassFile + permits ClassFileImpl { /** * {@return a context with default options} */ - static Classfile of() { - return ClassfileImpl.DEFAULT_CONTEXT; + static ClassFile of() { + return ClassFileImpl.DEFAULT_CONTEXT; } /** * {@return a new context with options altered from the default} * @param options the desired processing options */ - static Classfile of(Option... options) { + static ClassFile of(Option... options) { return of().withOptions(options); } @@ -72,20 +76,27 @@ public sealed interface Classfile * {@return a copy of the context with altered options} * @param options the desired processing options */ - Classfile withOptions(Option... options); + ClassFile withOptions(Option... options); /** * An option that affects the parsing and writing of classfiles. + * + * @sealedGraph + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface Option { } /** * Option describing attribute mappers for custom attributes. * Default is only to process standard attributes. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface AttributeMapperOption extends Option - permits ClassfileImpl.AttributeMapperOptionImpl { + permits ClassFileImpl.AttributeMapperOptionImpl { /** * {@return an option describing attribute mappers for custom attributes} @@ -93,7 +104,7 @@ public sealed interface Classfile */ static AttributeMapperOption of(Function> attributeMapper) { requireNonNull(attributeMapper); - return new ClassfileImpl.AttributeMapperOptionImpl(attributeMapper); + return new ClassFileImpl.AttributeMapperOptionImpl(attributeMapper); } /** @@ -105,9 +116,12 @@ public sealed interface Classfile /** * Option describing the class hierarchy resolver to use when generating * stack maps. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface ClassHierarchyResolverOption extends Option - permits ClassfileImpl.ClassHierarchyResolverOptionImpl { + permits ClassFileImpl.ClassHierarchyResolverOptionImpl { /** * {@return an option describing the class hierarchy resolver to use when @@ -116,7 +130,7 @@ public sealed interface Classfile */ static ClassHierarchyResolverOption of(ClassHierarchyResolver classHierarchyResolver) { requireNonNull(classHierarchyResolver); - return new ClassfileImpl.ClassHierarchyResolverOptionImpl(classHierarchyResolver); + return new ClassFileImpl.ClassHierarchyResolverOptionImpl(classHierarchyResolver); } /** @@ -133,7 +147,10 @@ public sealed interface Classfile * when a classfile is significantly transformed. * Default is {@code SHARED_POOL} to preserve the original constant * pool. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum ConstantPoolSharingOption implements Option { /** Preserves the original constant pool when transforming classfile */ @@ -144,10 +161,13 @@ public sealed interface Classfile } /** - * Option describing whether or not to patch out unreachable code. + * Option describing whether to patch out unreachable code. * Default is {@code PATCH_DEAD_CODE} to automatically patch out unreachable * code with NOPs. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum DeadCodeOption implements Option { /** Patch unreachable code */ @@ -158,14 +178,17 @@ public sealed interface Classfile } /** - * Option describing whether or not to filter unresolved labels. + * Option describing whether to filter unresolved labels. * Default is {@code FAIL_ON_DEAD_LABELS} to throw IllegalStateException * when any {@link ExceptionCatch}, {@link LocalVariableInfo}, * {@link LocalVariableTypeInfo}, or {@link CharacterRangeInfo} * reference to unresolved {@link Label} during bytecode serialization. * Setting this option to {@code DROP_DEAD_LABELS} filters the above * elements instead. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum DeadLabelsOption implements Option { /** Fail on unresolved labels */ @@ -181,7 +204,10 @@ public sealed interface Classfile * table, and character range table. Discarding debug elements may * reduce the overhead of parsing or transforming classfiles. * Default is {@code PASS_DEBUG} to process debug elements. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum DebugElementsOption implements Option { /** Process debug elements */ @@ -196,7 +222,10 @@ public sealed interface Classfile * Discarding line numbers may reduce the overhead of parsing or transforming * classfiles. * Default is {@code PASS_LINE_NUMBERS} to process line numbers. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum LineNumbersOption implements Option { /** Process line numbers */ @@ -207,11 +236,14 @@ public sealed interface Classfile } /** - * Option describing whether or not to automatically rewrite short jumps to + * Option describing whether to automatically rewrite short jumps to * long when necessary. * Default is {@code FIX_SHORT_JUMPS} to automatically rewrite jump * instructions. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum ShortJumpsOption implements Option { /** Automatically convert short jumps to long when necessary */ @@ -222,12 +254,15 @@ public sealed interface Classfile } /** - * Option describing whether or not to generate stackmaps. + * Option describing whether to generate stackmaps. * Default is {@code STACK_MAPS_WHEN_REQUIRED} to generate stack * maps for {@link #JAVA_6_VERSION} or above, where specifically for * {@link #JAVA_6_VERSION} the stack maps may not be generated. * @jvms 4.10.1 Verification by Type Checking + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum StackMapsOption implements Option { /** Generate stack maps when required */ @@ -246,7 +281,10 @@ public sealed interface Classfile * transformed in its exploded form. * Default is {@code PASS_ALL_ATTRIBUTES} to process all original attributes. * @see AttributeMapper.AttributeStability + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) enum AttributesProcessingOption implements Option { /** Process all original attributes during transformation */ @@ -263,6 +301,8 @@ public sealed interface Classfile * Parse a classfile into a {@link ClassModel}. * @param bytes the bytes of the classfile * @return the class model + * @throws IllegalArgumentException or its subclass if the classfile format is + * not supported or an incompatibility prevents parsing of the classfile */ ClassModel parse(byte[] bytes); @@ -270,7 +310,9 @@ public sealed interface Classfile * Parse a classfile into a {@link ClassModel}. * @param path the path to the classfile * @return the class model - * @throws java.io.IOException + * @throws java.io.IOException if an I/O error occurs + * @throws IllegalArgumentException or its subclass if the classfile format is + * not supported or an incompatibility prevents parsing of the classfile */ default ClassModel parse(Path path) throws IOException { return parse(Files.readAllBytes(path)); @@ -281,6 +323,7 @@ public sealed interface Classfile * @param thisClass the name of the class to build * @param handler a handler that receives a {@link ClassBuilder} * @return the classfile bytes + * @throws IllegalArgumentException if {@code thisClass} represents a primitive type */ default byte[] build(ClassDesc thisClass, Consumer handler) { @@ -306,7 +349,7 @@ public sealed interface Classfile * @param path the path to the file to write * @param thisClass the name of the class to build * @param handler a handler that receives a {@link ClassBuilder} - * @throws java.io.IOException + * @throws java.io.IOException if an I/O error occurs */ default void buildTo(Path path, ClassDesc thisClass, @@ -322,7 +365,7 @@ public sealed interface Classfile * @param thisClassEntry the name of the class to build * @param constantPool the constant pool builder * @param handler a handler that receives a {@link ClassBuilder} - * @throws java.io.IOException + * @throws java.io.IOException if an I/O error occurs */ default void buildTo(Path path, ClassEntry thisClassEntry, @@ -359,7 +402,7 @@ public sealed interface Classfile * Build a module descriptor into a file. * @param path the file to write * @param moduleAttribute the {@code Module} attribute - * @throws java.io.IOException + * @throws java.io.IOException if an I/O error occurs */ default void buildModuleTo(Path path, ModuleAttribute moduleAttribute) throws IOException { @@ -371,7 +414,7 @@ public sealed interface Classfile * @param path the file to write * @param moduleAttribute the {@code Module} attribute * @param handler a handler that receives a {@link ClassBuilder} - * @throws java.io.IOException + * @throws java.io.IOException if an I/O error occurs */ default void buildModuleTo(Path path, ModuleAttribute moduleAttribute, @@ -441,967 +484,967 @@ public sealed interface Classfile /** 0xCAFEBABE */ int MAGIC_NUMBER = 0xCAFEBABE; - /** 0 */ + /** The integer value used to encode the NOP instruction. */ int NOP = 0; - /** 1 */ + /** The integer value used to encode the ACONST_NULL instruction. */ int ACONST_NULL = 1; - /** 2 */ + /** The integer value used to encode the ICONST_M1 instruction. */ int ICONST_M1 = 2; - /** 3 */ + /** The integer value used to encode the ICONST_0 instruction. */ int ICONST_0 = 3; - /** 4 */ + /** The integer value used to encode the ICONST_1 instruction. */ int ICONST_1 = 4; - /** 5 */ + /** The integer value used to encode the ICONST_2 instruction. */ int ICONST_2 = 5; - /** 6 */ + /** The integer value used to encode the ICONST_3 instruction. */ int ICONST_3 = 6; - /** 7 */ + /** The integer value used to encode the ICONST_4 instruction. */ int ICONST_4 = 7; - /** 8 */ + /** The integer value used to encode the ICONST_5 instruction. */ int ICONST_5 = 8; - /** 9 */ + /** The integer value used to encode the LCONST_0 instruction. */ int LCONST_0 = 9; - /** 10 */ + /** The integer value used to encode the LCONST_1 instruction. */ int LCONST_1 = 10; - /** 11 */ + /** The integer value used to encode the FCONST_0 instruction. */ int FCONST_0 = 11; - /** 12 */ + /** The integer value used to encode the FCONST_1 instruction. */ int FCONST_1 = 12; - /** 13 */ + /** The integer value used to encode the FCONST_2 instruction. */ int FCONST_2 = 13; - /** 14 */ + /** The integer value used to encode the DCONST_0 instruction. */ int DCONST_0 = 14; - /** 15 */ + /** The integer value used to encode the DCONST_1 instruction. */ int DCONST_1 = 15; - /** 16 */ + /** The integer value used to encode the BIPUSH instruction. */ int BIPUSH = 16; - /** 17 */ + /** The integer value used to encode the SIPUSH instruction. */ int SIPUSH = 17; - /** 18 */ + /** The integer value used to encode the LDC instruction. */ int LDC = 18; - /** 19 */ + /** The integer value used to encode the LDC_W instruction. */ int LDC_W = 19; - /** 20 */ + /** The integer value used to encode the LDC2_W instruction. */ int LDC2_W = 20; - /** 21 */ + /** The integer value used to encode the ILOAD instruction. */ int ILOAD = 21; - /** 22 */ + /** The integer value used to encode the LLOAD instruction. */ int LLOAD = 22; - /** 23 */ + /** The integer value used to encode the FLOAD instruction. */ int FLOAD = 23; - /** 24 */ + /** The integer value used to encode the DLOAD instruction. */ int DLOAD = 24; - /** 25 */ + /** The integer value used to encode the ALOAD instruction. */ int ALOAD = 25; - /** 26 */ + /** The integer value used to encode the ILOAD_0 instruction. */ int ILOAD_0 = 26; - /** 27 */ + /** The integer value used to encode the ILOAD_1 instruction. */ int ILOAD_1 = 27; - /** 28 */ + /** The integer value used to encode the ILOAD_2 instruction. */ int ILOAD_2 = 28; - /** 29 */ + /** The integer value used to encode the ILOAD_3 instruction. */ int ILOAD_3 = 29; - /** 30 */ + /** The integer value used to encode the LLOAD_0 instruction. */ int LLOAD_0 = 30; - /** 31 */ + /** The integer value used to encode the LLOAD_1 instruction. */ int LLOAD_1 = 31; - /** 32 */ + /** The integer value used to encode the LLOAD_2 instruction. */ int LLOAD_2 = 32; - /** 33 */ + /** The integer value used to encode the LLOAD_3 instruction. */ int LLOAD_3 = 33; - /** 34 */ + /** The integer value used to encode the FLOAD_0 instruction. */ int FLOAD_0 = 34; - /** 35 */ + /** The integer value used to encode the FLOAD_1 instruction. */ int FLOAD_1 = 35; - /** 36 */ + /** The integer value used to encode the FLOAD_2 instruction. */ int FLOAD_2 = 36; - /** 37 */ + /** The integer value used to encode the FLOAD_3 instruction. */ int FLOAD_3 = 37; - /** 38 */ + /** The integer value used to encode the DLOAD_0 instruction. */ int DLOAD_0 = 38; - /** 39 */ + /** The integer value used to encode the DLOAD_1 instruction. */ int DLOAD_1 = 39; - /** 40 */ + /** The integer value used to encode the DLOAD_2 instruction. */ int DLOAD_2 = 40; - /** 41 */ + /** The integer value used to encode the DLOAD_3 instruction. */ int DLOAD_3 = 41; - /** 42 */ + /** The integer value used to encode the ALOAD_0 instruction. */ int ALOAD_0 = 42; - /** 43 */ + /** The integer value used to encode the ALOAD_1 instruction. */ int ALOAD_1 = 43; - /** 44 */ + /** The integer value used to encode the ALOAD_2 instruction. */ int ALOAD_2 = 44; - /** 45 */ + /** The integer value used to encode the ALOAD_3 instruction. */ int ALOAD_3 = 45; - /** 46 */ + /** The integer value used to encode the IALOAD instruction. */ int IALOAD = 46; - /** 47 */ + /** The integer value used to encode the LALOAD instruction. */ int LALOAD = 47; - /** 48 */ + /** The integer value used to encode the FALOAD instruction. */ int FALOAD = 48; - /** 49 */ + /** The integer value used to encode the DALOAD instruction. */ int DALOAD = 49; - /** 50 */ + /** The integer value used to encode the AALOAD instruction. */ int AALOAD = 50; - /** 51 */ + /** The integer value used to encode the BALOAD instruction. */ int BALOAD = 51; - /** 52 */ + /** The integer value used to encode the CALOAD instruction. */ int CALOAD = 52; - /** 53 */ + /** The integer value used to encode the SALOAD instruction. */ int SALOAD = 53; - /** 54 */ + /** The integer value used to encode the ISTORE instruction. */ int ISTORE = 54; - /** 55 */ + /** The integer value used to encode the LSTORE instruction. */ int LSTORE = 55; - /** 56 */ + /** The integer value used to encode the FSTORE instruction. */ int FSTORE = 56; - /** 57 */ + /** The integer value used to encode the DSTORE instruction. */ int DSTORE = 57; - /** 58 */ + /** The integer value used to encode the ASTORE instruction. */ int ASTORE = 58; - /** 59 */ + /** The integer value used to encode the ISTORE_0 instruction. */ int ISTORE_0 = 59; - /** 60 */ + /** The integer value used to encode the ISTORE_1 instruction. */ int ISTORE_1 = 60; - /** 61 */ + /** The integer value used to encode the ISTORE_2 instruction. */ int ISTORE_2 = 61; - /** 62 */ + /** The integer value used to encode the ISTORE_3 instruction. */ int ISTORE_3 = 62; - /** 63 */ + /** The integer value used to encode the LSTORE_0 instruction. */ int LSTORE_0 = 63; - /** 64 */ + /** The integer value used to encode the LSTORE_1 instruction. */ int LSTORE_1 = 64; - /** 65 */ + /** The integer value used to encode the LSTORE_2 instruction. */ int LSTORE_2 = 65; - /** 66 */ + /** The integer value used to encode the LSTORE_3 instruction. */ int LSTORE_3 = 66; - /** 67 */ + /** The integer value used to encode the FSTORE_0 instruction. */ int FSTORE_0 = 67; - /** 68 */ + /** The integer value used to encode the FSTORE_1 instruction. */ int FSTORE_1 = 68; - /** 69 */ + /** The integer value used to encode the FSTORE_2 instruction. */ int FSTORE_2 = 69; - /** 70 */ + /** The integer value used to encode the FSTORE_3 instruction. */ int FSTORE_3 = 70; - /** 71 */ + /** The integer value used to encode the DSTORE_0 instruction. */ int DSTORE_0 = 71; - /** 72 */ + /** The integer value used to encode the DSTORE_1 instruction. */ int DSTORE_1 = 72; - /** 73 */ + /** The integer value used to encode the DSTORE_2 instruction. */ int DSTORE_2 = 73; - /** 74 */ + /** The integer value used to encode the DSTORE_3 instruction. */ int DSTORE_3 = 74; - /** 75 */ + /** The integer value used to encode the ASTORE_0 instruction. */ int ASTORE_0 = 75; - /** 76 */ + /** The integer value used to encode the ASTORE_1 instruction. */ int ASTORE_1 = 76; - /** 77 */ + /** The integer value used to encode the ASTORE_2 instruction. */ int ASTORE_2 = 77; - /** 78 */ + /** The integer value used to encode the ASTORE_3 instruction. */ int ASTORE_3 = 78; - /** 79 */ + /** The integer value used to encode the IASTORE instruction. */ int IASTORE = 79; - /** 80 */ + /** The integer value used to encode the LASTORE instruction. */ int LASTORE = 80; - /** 81 */ + /** The integer value used to encode the FASTORE instruction. */ int FASTORE = 81; - /** 82 */ + /** The integer value used to encode the DASTORE instruction. */ int DASTORE = 82; - /** 83 */ + /** The integer value used to encode the AASTORE instruction. */ int AASTORE = 83; - /** 84 */ + /** The integer value used to encode the BASTORE instruction. */ int BASTORE = 84; - /** 85 */ + /** The integer value used to encode the CASTORE instruction. */ int CASTORE = 85; - /** 86 */ + /** The integer value used to encode the SASTORE instruction. */ int SASTORE = 86; - /** 87 */ + /** The integer value used to encode the POP instruction. */ int POP = 87; - /** 88 */ + /** The integer value used to encode the POP2 instruction. */ int POP2 = 88; - /** 89 */ + /** The integer value used to encode the DUP instruction. */ int DUP = 89; - /** 90 */ + /** The integer value used to encode the DUP_X1 instruction. */ int DUP_X1 = 90; - /** 91 */ + /** The integer value used to encode the DUP_X2 instruction. */ int DUP_X2 = 91; - /** 92 */ + /** The integer value used to encode the DUP2 instruction. */ int DUP2 = 92; - /** 93 */ + /** The integer value used to encode the DUP2_X1 instruction. */ int DUP2_X1 = 93; - /** 94 */ + /** The integer value used to encode the DUP2_X2 instruction. */ int DUP2_X2 = 94; - /** 95 */ + /** The integer value used to encode the SWAP instruction. */ int SWAP = 95; - /** 96 */ + /** The integer value used to encode the IADD instruction. */ int IADD = 96; - /** 97 */ + /** The integer value used to encode the LADD instruction. */ int LADD = 97; - /** 98 */ + /** The integer value used to encode the FADD instruction. */ int FADD = 98; - /** 99 */ + /** The integer value used to encode the DADD instruction. */ int DADD = 99; - /** 100 */ + /** The integer value used to encode the ISUB instruction. */ int ISUB = 100; - /** 101 */ + /** The integer value used to encode the LSUB instruction. */ int LSUB = 101; - /** 102 */ + /** The integer value used to encode the FSUB instruction. */ int FSUB = 102; - /** 103 */ + /** The integer value used to encode the DSUB instruction. */ int DSUB = 103; - /** 104 */ + /** The integer value used to encode the IMUL instruction. */ int IMUL = 104; - /** 105 */ + /** The integer value used to encode the LMUL instruction. */ int LMUL = 105; - /** 106 */ + /** The integer value used to encode the FMUL instruction. */ int FMUL = 106; - /** 107 */ + /** The integer value used to encode the DMUL instruction. */ int DMUL = 107; - /** 108 */ + /** The integer value used to encode the IDIV instruction. */ int IDIV = 108; - /** 109 */ + /** The integer value used to encode the LDIV instruction. */ int LDIV = 109; - /** 110 */ + /** The integer value used to encode the FDIV instruction. */ int FDIV = 110; - /** 111 */ + /** The integer value used to encode the DDIV instruction. */ int DDIV = 111; - /** 112 */ + /** The integer value used to encode the IREM instruction. */ int IREM = 112; - /** 113 */ + /** The integer value used to encode the LREM instruction. */ int LREM = 113; - /** 114 */ + /** The integer value used to encode the FREM instruction. */ int FREM = 114; - /** 115 */ + /** The integer value used to encode the DREM instruction. */ int DREM = 115; - /** 116 */ + /** The integer value used to encode the INEG instruction. */ int INEG = 116; - /** 117 */ + /** The integer value used to encode the LNEG instruction. */ int LNEG = 117; - /** 118 */ + /** The integer value used to encode the FNEG instruction. */ int FNEG = 118; - /** 119 */ + /** The integer value used to encode the DNEG instruction. */ int DNEG = 119; - /** 120 */ + /** The integer value used to encode the ISHL instruction. */ int ISHL = 120; - /** 121 */ + /** The integer value used to encode the LSHL instruction. */ int LSHL = 121; - /** 122 */ + /** The integer value used to encode the ISHR instruction. */ int ISHR = 122; - /** 123 */ + /** The integer value used to encode the LSHR instruction. */ int LSHR = 123; - /** 124 */ + /** The integer value used to encode the IUSHR instruction. */ int IUSHR = 124; - /** 125 */ + /** The integer value used to encode the LUSHR instruction. */ int LUSHR = 125; - /** 126 */ + /** The integer value used to encode the IAND instruction. */ int IAND = 126; - /** 127 */ + /** The integer value used to encode the LAND instruction. */ int LAND = 127; - /** 128 */ + /** The integer value used to encode the IOR instruction. */ int IOR = 128; - /** 129 */ + /** The integer value used to encode the LOR instruction. */ int LOR = 129; - /** 130 */ + /** The integer value used to encode the IXOR instruction. */ int IXOR = 130; - /** 131 */ + /** The integer value used to encode the LXOR instruction. */ int LXOR = 131; - /** 132 */ + /** The integer value used to encode the IINC instruction. */ int IINC = 132; - /** 133 */ + /** The integer value used to encode the I2L instruction. */ int I2L = 133; - /** 134 */ + /** The integer value used to encode the I2F instruction. */ int I2F = 134; - /** 135 */ + /** The integer value used to encode the I2D instruction. */ int I2D = 135; - /** 136 */ + /** The integer value used to encode the L2I instruction. */ int L2I = 136; - /** 137 */ + /** The integer value used to encode the L2F instruction. */ int L2F = 137; - /** 138 */ + /** The integer value used to encode the L2D instruction. */ int L2D = 138; - /** 139 */ + /** The integer value used to encode the F2I instruction. */ int F2I = 139; - /** 140 */ + /** The integer value used to encode the F2L instruction. */ int F2L = 140; - /** 141 */ + /** The integer value used to encode the F2D instruction. */ int F2D = 141; - /** 142 */ + /** The integer value used to encode the D2I instruction. */ int D2I = 142; - /** 143 */ + /** The integer value used to encode the D2L instruction. */ int D2L = 143; - /** 144 */ + /** The integer value used to encode the D2F instruction. */ int D2F = 144; - /** 145 */ + /** The integer value used to encode the I2B instruction. */ int I2B = 145; - /** 146 */ + /** The integer value used to encode the I2C instruction. */ int I2C = 146; - /** 147 */ + /** The integer value used to encode the I2S instruction. */ int I2S = 147; - /** 148 */ + /** The integer value used to encode the LCMP instruction. */ int LCMP = 148; - /** 149 */ + /** The integer value used to encode the FCMPL instruction. */ int FCMPL = 149; - /** 150 */ + /** The integer value used to encode the FCMPG instruction. */ int FCMPG = 150; - /** 151 */ + /** The integer value used to encode the DCMPL instruction. */ int DCMPL = 151; - /** 152 */ + /** The integer value used to encode the DCMPG instruction. */ int DCMPG = 152; - /** 153 */ + /** The integer value used to encode the IFEQ instruction. */ int IFEQ = 153; - /** 154 */ + /** The integer value used to encode the IFNE instruction. */ int IFNE = 154; - /** 155 */ + /** The integer value used to encode the IFLT instruction. */ int IFLT = 155; - /** 156 */ + /** The integer value used to encode the IFGE instruction. */ int IFGE = 156; - /** 157 */ + /** The integer value used to encode the IFGT instruction. */ int IFGT = 157; - /** 158 */ + /** The integer value used to encode the IFLE instruction. */ int IFLE = 158; - /** 159 */ + /** The integer value used to encode the IF_ICMPEQ instruction. */ int IF_ICMPEQ = 159; - /** 160 */ + /** The integer value used to encode the IF_ICMPNE instruction. */ int IF_ICMPNE = 160; - /** 161 */ + /** The integer value used to encode the IF_ICMPLT instruction. */ int IF_ICMPLT = 161; - /** 162 */ + /** The integer value used to encode the IF_ICMPGE instruction. */ int IF_ICMPGE = 162; - /** 163 */ + /** The integer value used to encode the IF_ICMPGT instruction. */ int IF_ICMPGT = 163; - /** 164 */ + /** The integer value used to encode the IF_ICMPLE instruction. */ int IF_ICMPLE = 164; - /** 165 */ + /** The integer value used to encode the IF_ACMPEQ instruction. */ int IF_ACMPEQ = 165; - /** 166 */ + /** The integer value used to encode the IF_ACMPNE instruction. */ int IF_ACMPNE = 166; - /** 167 */ + /** The integer value used to encode the GOTO instruction. */ int GOTO = 167; - /** 168 */ + /** The integer value used to encode the JSR instruction. */ int JSR = 168; - /** 169 */ + /** The integer value used to encode the RET instruction. */ int RET = 169; - /** 170 */ + /** The integer value used to encode the TABLESWITCH instruction. */ int TABLESWITCH = 170; - /** 171 */ + /** The integer value used to encode the LOOKUPSWITCH instruction. */ int LOOKUPSWITCH = 171; - /** 172 */ + /** The integer value used to encode the IRETURN instruction. */ int IRETURN = 172; - /** 173 */ + /** The integer value used to encode the LRETURN instruction. */ int LRETURN = 173; - /** 174 */ + /** The integer value used to encode the FRETURN instruction. */ int FRETURN = 174; - /** 175 */ + /** The integer value used to encode the DRETURN instruction. */ int DRETURN = 175; - /** 176 */ + /** The integer value used to encode the ARETURN instruction. */ int ARETURN = 176; - /** 177 */ + /** The integer value used to encode the RETURN instruction. */ int RETURN = 177; - /** 178 */ + /** The integer value used to encode the GETSTATIC instruction. */ int GETSTATIC = 178; - /** 179 */ + /** The integer value used to encode the PUTSTATIC instruction. */ int PUTSTATIC = 179; - /** 180 */ + /** The integer value used to encode the GETFIELD instruction. */ int GETFIELD = 180; - /** 181 */ + /** The integer value used to encode the PUTFIELD instruction. */ int PUTFIELD = 181; - /** 182 */ + /** The integer value used to encode the INVOKEVIRTUAL instruction. */ int INVOKEVIRTUAL = 182; - /** 183 */ + /** The integer value used to encode the INVOKESPECIAL instruction. */ int INVOKESPECIAL = 183; - /** 184 */ + /** The integer value used to encode the INVOKESTATIC instruction. */ int INVOKESTATIC = 184; - /** 185 */ + /** The integer value used to encode the INVOKEINTERFACE instruction. */ int INVOKEINTERFACE = 185; - /** 186 */ + /** The integer value used to encode the INVOKEDYNAMIC instruction. */ int INVOKEDYNAMIC = 186; - /** 187 */ + /** The integer value used to encode the NEW instruction. */ int NEW = 187; - /** 188 */ + /** The integer value used to encode the NEWARRAY instruction. */ int NEWARRAY = 188; - /** 189 */ + /** The integer value used to encode the ANEWARRAY instruction. */ int ANEWARRAY = 189; - /** 190 */ + /** The integer value used to encode the ARRAYLENGTH instruction. */ int ARRAYLENGTH = 190; - /** 191 */ + /** The integer value used to encode the ATHROW instruction. */ int ATHROW = 191; - /** 192 */ + /** The integer value used to encode the CHECKCAST instruction. */ int CHECKCAST = 192; - /** 193 */ + /** The integer value used to encode the INSTANCEOF instruction. */ int INSTANCEOF = 193; - /** 194 */ + /** The integer value used to encode the MONITORENTER instruction. */ int MONITORENTER = 194; - /** 195 */ + /** The integer value used to encode the MONITOREXIT instruction. */ int MONITOREXIT = 195; - /** 196 */ + /** The integer value used to encode the WIDE instruction. */ int WIDE = 196; - /** 197 */ + /** The integer value used to encode the MULTIANEWARRAY instruction. */ int MULTIANEWARRAY = 197; - /** 198 */ + /** The integer value used to encode the IFNULL instruction. */ int IFNULL = 198; - /** 199 */ + /** The integer value used to encode the IFNONNULL instruction. */ int IFNONNULL = 199; - /** 200 */ + /** The integer value used to encode the GOTO_W instruction. */ int GOTO_W = 200; - /** 201 */ + /** The integer value used to encode the JSR_W instruction. */ int JSR_W = 201; - /** 0x0001 */ + /** The value of PUBLIC access and property modifier. */ int ACC_PUBLIC = 0x0001; - /** 0x0004 */ + /** The value of PROTECTED access and property modifier. */ int ACC_PROTECTED = 0x0004; - /** 0x0002 */ + /** The value of PRIVATE access and property modifier. */ int ACC_PRIVATE = 0x0002; - /** 0x0200 */ + /** The value of INTERFACE access and property modifier. */ int ACC_INTERFACE = 0x0200; - /** 0x4000 */ + /** The value of ENUM access and property modifier. */ int ACC_ENUM = 0x4000; - /** 0x2000 */ + /** The value of ANNOTATION access and property modifier. */ int ACC_ANNOTATION = 0x2000; - /** 0x0020 */ + /** The value of SUPER access and property modifier. */ int ACC_SUPER = 0x0020; - /** 0x0400 */ + /** The value of ABSTRACT access and property modifier. */ int ACC_ABSTRACT = 0x0400; - /** 0x0040 */ + /** The value of VOLATILE access and property modifier. */ int ACC_VOLATILE = 0x0040; - /** 0x0080 */ + /** The value of TRANSIENT access and property modifier. */ int ACC_TRANSIENT = 0x0080; - /** 0x1000 */ + /** The value of SYNTHETIC access and property modifier. */ int ACC_SYNTHETIC = 0x1000; - /** 0x0008 */ + /** The value of STATIC access and property modifier. */ int ACC_STATIC = 0x0008; - /** 0x0010 */ + /** The value of FINAL access and property modifier. */ int ACC_FINAL = 0x0010; - /** 0x0020 */ + /** The value of SYNCHRONIZED access and property modifier. */ int ACC_SYNCHRONIZED = 0x0020; - /** 0x0040 */ + /** The value of BRIDGE access and property modifier. */ int ACC_BRIDGE = 0x0040; - /** 0x0080 */ + /** The value of VARARGS access and property modifier. */ int ACC_VARARGS = 0x0080; - /** 0x0100 */ + /** The value of NATIVE access and property modifier. */ int ACC_NATIVE = 0x0100; - /** 0x0800 */ + /** The value of STRICT access and property modifier. */ int ACC_STRICT = 0x0800; - /** 0x8000 */ + /** The value of MODULE access and property modifier. */ int ACC_MODULE = 0x8000; - /** 0x20 */ + /** The value of OPEN access and property modifier. */ int ACC_OPEN = 0x20; - /** 0x8000 */ + /** The value of MANDATED access and property modifier. */ int ACC_MANDATED = 0x8000; - /** 0x20 */ + /** The value of TRANSITIVE access and property modifier. */ int ACC_TRANSITIVE = 0x20; - /** 0x40 */ + /** The value of STATIC_PHASE access and property modifier. */ int ACC_STATIC_PHASE = 0x40; - /** 0x0001 */ + /** The value of STATEMENT {@link CharacterRangeInfo} kind. */ int CRT_STATEMENT = 0x0001; - /** 0x0002 */ + /** The value of BLOCK {@link CharacterRangeInfo} kind. */ int CRT_BLOCK = 0x0002; - /** 0x0004 */ + /** The value of ASSIGNMENT {@link CharacterRangeInfo} kind. */ int CRT_ASSIGNMENT = 0x0004; - /** 0x0008 */ + /** The value of FLOW_CONTROLLER {@link CharacterRangeInfo} kind. */ int CRT_FLOW_CONTROLLER = 0x0008; - /** 0x0010 */ + /** The value of FLOW_TARGET {@link CharacterRangeInfo} kind. */ int CRT_FLOW_TARGET = 0x0010; - /** 0x0020 */ + /** The value of INVOKE {@link CharacterRangeInfo} kind. */ int CRT_INVOKE = 0x0020; - /** 0x0040 */ + /** The value of CREATE {@link CharacterRangeInfo} kind. */ int CRT_CREATE = 0x0040; - /** 0x0080 */ + /** The value of BRANCH_TRUE {@link CharacterRangeInfo} kind. */ int CRT_BRANCH_TRUE = 0x0080; - /** 0x0100 */ + /** The value of BRANCH_FALSE {@link CharacterRangeInfo} kind. */ int CRT_BRANCH_FALSE = 0x0100; - /** 7 */ + /** The value of constant pool tag CLASS. */ int TAG_CLASS = 7; - /** 17 */ + /** The value of constant pool tag CONSTANTDYNAMIC. */ int TAG_CONSTANTDYNAMIC = 17; - /** 6 */ + /** The value of constant pool tag DOUBLE. */ int TAG_DOUBLE = 6; - /** 9 */ + /** The value of constant pool tag FIELDREF. */ int TAG_FIELDREF = 9; - /** 4 */ + /** The value of constant pool tag FLOAT. */ int TAG_FLOAT = 4; - /** 3 */ + /** The value of constant pool tag INTEGER. */ int TAG_INTEGER = 3; - /** 11 */ + /** The value of constant pool tag INTERFACEMETHODREF. */ int TAG_INTERFACEMETHODREF = 11; - /** 18 */ + /** The value of constant pool tag INVOKEDYNAMIC. */ int TAG_INVOKEDYNAMIC = 18; - /** 5 */ + /** The value of constant pool tag LONG. */ int TAG_LONG = 5; - /** 15 */ + /** The value of constant pool tag METHODHANDLE. */ int TAG_METHODHANDLE = 15; - /** 10 */ + /** The value of constant pool tag METHODREF. */ int TAG_METHODREF = 10; - /** 16 */ + /** The value of constant pool tag METHODTYPE. */ int TAG_METHODTYPE = 16; - /** 19 */ + /** The value of constant pool tag MODULE. */ int TAG_MODULE = 19; - /** 12 */ + /** The value of constant pool tag NAMEANDTYPE. */ int TAG_NAMEANDTYPE = 12; - /** 20 */ + /** The value of constant pool tag PACKAGE. */ int TAG_PACKAGE = 20; - /** 8 */ + /** The value of constant pool tag STRING. */ int TAG_STRING = 8; - /** 2 */ + /** The value of constant pool tag UNICODE. */ int TAG_UNICODE = 2; - /** 1 */ + /** The value of constant pool tag UTF8. */ int TAG_UTF8 = 1; // annotation element values - /** 'B' */ - char AEV_BYTE = 'B'; + /** The value of annotation element value type AEV_BYTE. */ + int AEV_BYTE = 'B'; - /** 'C' */ - char AEV_CHAR = 'C'; + /** The value of annotation element value type AEV_CHAR. */ + int AEV_CHAR = 'C'; - /** 'D' */ - char AEV_DOUBLE = 'D'; + /** The value of annotation element value type AEV_DOUBLE. */ + int AEV_DOUBLE = 'D'; - /** 'F' */ - char AEV_FLOAT = 'F'; + /** The value of annotation element value type AEV_FLOAT. */ + int AEV_FLOAT = 'F'; - /** 'I' */ - char AEV_INT = 'I'; + /** The value of annotation element value type AEV_INT. */ + int AEV_INT = 'I'; - /** 'J' */ - char AEV_LONG = 'J'; + /** The value of annotation element value type AEV_LONG. */ + int AEV_LONG = 'J'; - /** 'S' */ - char AEV_SHORT = 'S'; + /** The value of annotation element value type AEV_SHORT. */ + int AEV_SHORT = 'S'; - /** 'Z' */ - char AEV_BOOLEAN = 'Z'; + /** The value of annotation element value type AEV_BOOLEAN. */ + int AEV_BOOLEAN = 'Z'; - /** 's' */ - char AEV_STRING = 's'; + /** The value of annotation element value type AEV_STRING. */ + int AEV_STRING = 's'; - /** 'e' */ - char AEV_ENUM = 'e'; + /** The value of annotation element value type AEV_ENUM. */ + int AEV_ENUM = 'e'; - /** 'c' */ - char AEV_CLASS = 'c'; + /** The value of annotation element value type AEV_CLASS. */ + int AEV_CLASS = 'c'; - /** '@' */ - char AEV_ANNOTATION = '@'; + /** The value of annotation element value type AEV_ANNOTATION. */ + int AEV_ANNOTATION = '@'; - /** '[' */ - char AEV_ARRAY = '['; + /** The value of annotation element value type AEV_ARRAY. */ + int AEV_ARRAY = '['; //type annotations - /** 0x00 */ + /** The value of type annotation target type CLASS_TYPE_PARAMETER. */ int TAT_CLASS_TYPE_PARAMETER = 0x00; - /** 0x01 */ + /** The value of type annotation target type METHOD_TYPE_PARAMETER. */ int TAT_METHOD_TYPE_PARAMETER = 0x01; - /** 0x10 */ + /** The value of type annotation target type CLASS_EXTENDS. */ int TAT_CLASS_EXTENDS = 0x10; - /** 0x11 */ + /** The value of type annotation target type CLASS_TYPE_PARAMETER_BOUND. */ int TAT_CLASS_TYPE_PARAMETER_BOUND = 0x11; - /** 0x12 */ + /** The value of type annotation target type METHOD_TYPE_PARAMETER_BOUND. */ int TAT_METHOD_TYPE_PARAMETER_BOUND = 0x12; - /** 0x13 */ + /** The value of type annotation target type FIELD. */ int TAT_FIELD = 0x13; - /** 0x14 */ + /** The value of type annotation target type METHOD_RETURN. */ int TAT_METHOD_RETURN = 0x14; - /** 0x15 */ + /** The value of type annotation target type METHOD_RECEIVER. */ int TAT_METHOD_RECEIVER = 0x15; - /** 0x16 */ + /** The value of type annotation target type METHOD_FORMAL_PARAMETER. */ int TAT_METHOD_FORMAL_PARAMETER = 0x16; - /** 0x17 */ + /** The value of type annotation target type THROWS. */ int TAT_THROWS = 0x17; - /** 0x40 */ + /** The value of type annotation target type LOCAL_VARIABLE. */ int TAT_LOCAL_VARIABLE = 0x40; - /** 0x41 */ + /** The value of type annotation target type RESOURCE_VARIABLE. */ int TAT_RESOURCE_VARIABLE = 0x41; - /** 0x42 */ + /** The value of type annotation target type EXCEPTION_PARAMETER. */ int TAT_EXCEPTION_PARAMETER = 0x42; - /** 0x43 */ + /** The value of type annotation target type INSTANCEOF. */ int TAT_INSTANCEOF = 0x43; - /** 0x44 */ + /** The value of type annotation target type NEW. */ int TAT_NEW = 0x44; - /** 0x45 */ + /** The value of type annotation target type CONSTRUCTOR_REFERENCE. */ int TAT_CONSTRUCTOR_REFERENCE = 0x45; - /** 0x46 */ + /** The value of type annotation target type METHOD_REFERENCE. */ int TAT_METHOD_REFERENCE = 0x46; - /** 0x47 */ + /** The value of type annotation target type CAST. */ int TAT_CAST = 0x47; - /** 0x48 */ + /** The value of type annotation target type CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT. */ int TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = 0x48; - /** 0x49 */ + /** The value of type annotation target type METHOD_INVOCATION_TYPE_ARGUMENT. */ int TAT_METHOD_INVOCATION_TYPE_ARGUMENT = 0x49; - /** 0x4A */ + /** The value of type annotation target type CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT. */ int TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = 0x4A; - /** 0x4B */ + /** The value of type annotation target type METHOD_REFERENCE_TYPE_ARGUMENT. */ int TAT_METHOD_REFERENCE_TYPE_ARGUMENT = 0x4B; //stackmap verification types - /** 0 */ + /** The value of verification type TOP. */ int VT_TOP = 0; - /** 1 */ + /** The value of verification type INTEGER. */ int VT_INTEGER = 1; - /** 2 */ + /** The value of verification type FLOAT. */ int VT_FLOAT = 2; - /** 3 */ + /** The value of verification type DOUBLE. */ int VT_DOUBLE = 3; - /** 4 */ + /** The value of verification type LONG. */ int VT_LONG = 4; - /** 5 */ + /** The value of verification type NULL. */ int VT_NULL = 5; - /** 6 */ + /** The value of verification type UNINITIALIZED_THIS. */ int VT_UNINITIALIZED_THIS = 6; - /** 7 */ + /** The value of verification type OBJECT. */ int VT_OBJECT = 7; - /** 8 */ + /** The value of verification type UNINITIALIZED. */ int VT_UNINITIALIZED = 8; - /** ACC_PUBLIC */ + /** The value of default class access flags */ int DEFAULT_CLASS_FLAGS = ACC_PUBLIC; - /** 45 */ + /** The class major version of JAVA_1. */ int JAVA_1_VERSION = 45; - /** 46 */ + /** The class major version of JAVA_2. */ int JAVA_2_VERSION = 46; - /** 47 */ + /** The class major version of JAVA_3. */ int JAVA_3_VERSION = 47; - /** 48 */ + /** The class major version of JAVA_4. */ int JAVA_4_VERSION = 48; - /** 49 */ + /** The class major version of JAVA_5. */ int JAVA_5_VERSION = 49; - /** 50 */ + /** The class major version of JAVA_6. */ int JAVA_6_VERSION = 50; - /** 51 */ + /** The class major version of JAVA_7. */ int JAVA_7_VERSION = 51; - /** 52 */ + /** The class major version of JAVA_8. */ int JAVA_8_VERSION = 52; - /** 53 */ + /** The class major version of JAVA_9. */ int JAVA_9_VERSION = 53; - /** 54 */ + /** The class major version of JAVA_10. */ int JAVA_10_VERSION = 54; - /** 55 */ + /** The class major version of JAVA_11. */ int JAVA_11_VERSION = 55; - /** 56 */ + /** The class major version of JAVA_12. */ int JAVA_12_VERSION = 56; - /** 57 */ + /** The class major version of JAVA_13. */ int JAVA_13_VERSION = 57; - /** 58 */ + /** The class major version of JAVA_14. */ int JAVA_14_VERSION = 58; - /** 59 */ + /** The class major version of JAVA_15. */ int JAVA_15_VERSION = 59; - /** 60 */ + /** The class major version of JAVA_16. */ int JAVA_16_VERSION = 60; - /** 61 */ + /** The class major version of JAVA_17. */ int JAVA_17_VERSION = 61; - /** 62 */ + /** The class major version of JAVA_18. */ int JAVA_18_VERSION = 62; - /** 63 */ + /** The class major version of JAVA_19. */ int JAVA_19_VERSION = 63; - /** 64 */ + /** The class major version of JAVA_20. */ int JAVA_20_VERSION = 64; - /** 65 */ + /** The class major version of JAVA_21. */ int JAVA_21_VERSION = 65; - /** 66 */ + /** The class major version of JAVA_22. */ int JAVA_22_VERSION = 66; /** diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassfileBuilder.java b/src/java.base/share/classes/java/lang/classfile/ClassFileBuilder.java similarity index 78% rename from src/java.base/share/classes/jdk/internal/classfile/ClassfileBuilder.java rename to src/java.base/share/classes/java/lang/classfile/ClassFileBuilder.java index 965bfb293e7..9381c0510ef 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassfileBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileBuilder.java @@ -22,31 +22,36 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ClassDesc; import java.util.function.Consumer; -import jdk.internal.classfile.constantpool.ConstantPool; -import jdk.internal.classfile.constantpool.ConstantPoolBuilder; +import java.lang.classfile.constantpool.ConstantPool; +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import jdk.internal.javac.PreviewFeature; /** * A builder for a classfile or portion of a classfile. Builders are rarely * created directly; they are passed to handlers by methods such as - * {@link Classfile#build(ClassDesc, Consumer)} or to transforms. + * {@link ClassFile#build(ClassDesc, Consumer)} or to transforms. * Elements of the newly built entity can be specified - * abstractly (by passing a {@link ClassfileElement} to {@link #with(ClassfileElement)} + * abstractly (by passing a {@link ClassFileElement} to {@link #with(ClassFileElement)} * or concretely by calling the various {@code withXxx} methods. * * @param the element type * @param the builder type - * @see ClassfileTransform + * @see ClassFileTransform + * + * @sealedGraph + * @since 22 */ -public sealed interface ClassfileBuilder> +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface ClassFileBuilder> extends Consumer permits ClassBuilder, FieldBuilder, MethodBuilder, CodeBuilder { /** - * Integrate the {@link ClassfileElement} into the entity being built. + * Integrate the {@link ClassFileElement} into the entity being built. * @param e the element */ @Override @@ -55,7 +60,7 @@ public sealed interface ClassfileBuilder model, ClassfileTransform transform) { + default void transform(CompoundElement model, ClassFileTransform transform) { @SuppressWarnings("unchecked") B builder = (B) this; var resolved = transform.resolve(builder); diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassfileElement.java b/src/java.base/share/classes/java/lang/classfile/ClassFileElement.java similarity index 89% rename from src/java.base/share/classes/jdk/internal/classfile/ClassfileElement.java rename to src/java.base/share/classes/java/lang/classfile/ClassFileElement.java index 7b100da4e42..6452f52e042 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassfileElement.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileElement.java @@ -22,7 +22,9 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; + +import jdk.internal.javac.PreviewFeature; /** * Immutable model for a portion of (or the entirety of) a classfile. Elements @@ -31,8 +33,12 @@ package jdk.internal.classfile; * themselves contain their own child elements will implement {@link * CompoundElement}. Elements specific to various locations in the classfile * will implement {@link ClassElement}, {@link MethodElement}, etc. + * + * @sealedGraph + * @since 22 */ -public sealed interface ClassfileElement +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface ClassFileElement permits AttributedElement, CompoundElement, WritableElement, ClassElement, CodeElement, FieldElement, MethodElement { } diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassfileTransform.java b/src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java similarity index 83% rename from src/java.base/share/classes/jdk/internal/classfile/ClassfileTransform.java rename to src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java index 299e5153835..677478ec650 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassfileTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileTransform.java @@ -22,33 +22,34 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.function.Consumer; import java.util.function.Supplier; -import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import jdk.internal.javac.PreviewFeature; /** * A transformation on streams of elements. Transforms are used during * transformation of classfile entities; a transform is provided to a method like - * {@link Classfile#transform(ClassModel, ClassTransform)}, and the elements of the class, + * {@link ClassFile#transform(ClassModel, ClassTransform)}, and the elements of the class, * along with a builder, are presented to the transform. * *

The subtypes of {@linkplain - * ClassfileTransform} (e.g., {@link ClassTransform}) are functional interfaces + * ClassFileTransform} (e.g., {@link ClassTransform}) are functional interfaces * that accept an element and a corresponding builder. Since any element can be - * reproduced on the builder via {@link ClassBuilder#with(ClassfileElement)}, a + * reproduced on the builder via {@link ClassBuilder#with(ClassFileElement)}, a * transform can easily leave elements in place, remove them, replace them, or * augment them with other elements. This enables localized transforms to be * represented concisely. * - *

Transforms also have an {@link #atEnd(ClassfileBuilder)} method, for + *

Transforms also have an {@link #atEnd(ClassFileBuilder)} method, for * which the default implementation does nothing, so that a transform can * perform additional building after the stream of elements is exhausted. * *

Transforms can be chained together via the {@link - * #andThen(ClassfileTransform)} method, so that the output of one becomes the + * #andThen(ClassFileTransform)} method, so that the output of one becomes the * input to another. This allows smaller units of transformation to be captured * and reused. * @@ -56,7 +57,7 @@ import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; * annotation on a class may watch for the {@link RuntimeVisibleAnnotationsAttribute} * element and transform it if found, but if it is not found, will generate a * {@linkplain RuntimeVisibleAnnotationsAttribute} element containing the - * injected annotation from the {@linkplain #atEnd(ClassfileBuilder)} handler. + * injected annotation from the {@linkplain #atEnd(ClassFileBuilder)} handler. * To do this, the transform must accumulate some state during the traversal so * that the end handler knows what to do. If such a transform is to be reused, * its state must be reset for each traversal; this will happen automatically if @@ -71,17 +72,21 @@ import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; * @param the transform type * @param the element type * @param the builder type + * + * @sealedGraph + * @since 22 */ -public sealed interface ClassfileTransform< - C extends ClassfileTransform, - E extends ClassfileElement, - B extends ClassfileBuilder> +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface ClassFileTransform< + C extends ClassFileTransform, + E extends ClassFileElement, + B extends ClassFileBuilder> permits ClassTransform, FieldTransform, MethodTransform, CodeTransform { /** * Transform an element by taking the appropriate actions on the builder. * Used when transforming a classfile entity (class, method, field, method * body.) If no transformation is desired, the element can be presented to - * {@link B#with(ClassfileElement)}. If the element is to be dropped, no + * {@link B#with(ClassFileElement)}. If the element is to be dropped, no * action is required. * * @param builder the builder for the new entity @@ -92,7 +97,7 @@ public sealed interface ClassfileTransform< /** * Take any final action during transformation of a classfile entity. Called * after all elements of the class are presented to {@link - * #accept(ClassfileBuilder, ClassfileElement)}. + * #accept(ClassFileBuilder, ClassFileElement)}. * * @param builder the builder for the new entity * @implSpec The default implementation does nothing. @@ -103,7 +108,7 @@ public sealed interface ClassfileTransform< /** * Take any preliminary action during transformation of a classfile entity. * Called before any elements of the class are presented to {@link - * #accept(ClassfileBuilder, ClassfileElement)}. + * #accept(ClassFileBuilder, ClassFileElement)}. * * @param builder the builder for the new entity * @implSpec The default implementation does nothing. @@ -125,8 +130,11 @@ public sealed interface ClassfileTransform< * the implementation to perform transformation. * * @param the element type + * + * @since 22 */ - interface ResolvedTransform { + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) + interface ResolvedTransform { /** * {@return a {@link Consumer} to receive elements} */ @@ -151,7 +159,7 @@ public sealed interface ClassfileTransform< * *

This method is a low-level method that should rarely be used by * user code; most of the time, user code should prefer - * {@link ClassfileBuilder#transform(CompoundElement, ClassfileTransform)}, + * {@link ClassFileBuilder#transform(CompoundElement, ClassFileTransform)}, * which resolves the transform and executes it on the current builder. * * @param builder the builder to bind to diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassfileVersion.java b/src/java.base/share/classes/java/lang/classfile/ClassFileVersion.java similarity index 75% rename from src/java.base/share/classes/jdk/internal/classfile/ClassfileVersion.java rename to src/java.base/share/classes/java/lang/classfile/ClassFileVersion.java index a3989e92b26..b6ef3e57f61 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassfileVersion.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassFileVersion.java @@ -22,18 +22,22 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.impl.ClassfileVersionImpl; +import jdk.internal.classfile.impl.ClassFileVersionImpl; +import jdk.internal.javac.PreviewFeature; /** * Models the classfile version information for a class. Delivered as a {@link - * jdk.internal.classfile.ClassElement} when traversing the elements of a {@link + * java.lang.classfile.ClassElement} when traversing the elements of a {@link * ClassModel}. + * + * @since 22 */ -public sealed interface ClassfileVersion +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface ClassFileVersion extends ClassElement - permits ClassfileVersionImpl { + permits ClassFileVersionImpl { /** * {@return the major classfile version} */ @@ -45,11 +49,11 @@ public sealed interface ClassfileVersion int minorVersion(); /** - * {@return a {@link ClassfileVersion} element} + * {@return a {@link ClassFileVersion} element} * @param majorVersion the major classfile version * @param minorVersion the minor classfile version */ - static ClassfileVersion of(int majorVersion, int minorVersion) { - return new ClassfileVersionImpl(majorVersion, minorVersion); + static ClassFileVersion of(int majorVersion, int minorVersion) { + return new ClassFileVersionImpl(majorVersion, minorVersion); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassHierarchyResolver.java b/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java similarity index 90% rename from src/java.base/share/classes/jdk/internal/classfile/ClassHierarchyResolver.java rename to src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java index f1c072a2f41..589713c8e95 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassHierarchyResolver.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassHierarchyResolver.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.io.InputStream; import java.lang.constant.ClassDesc; @@ -39,11 +39,15 @@ import jdk.internal.classfile.impl.ClassHierarchyImpl.StaticClassHierarchyResolv import jdk.internal.classfile.impl.Util; import static java.lang.constant.ConstantDescs.CD_Object; +import jdk.internal.javac.PreviewFeature; /** * Provides class hierarchy information for generating correct stack maps * during code building. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) @FunctionalInterface public interface ClassHierarchyResolver { @@ -65,7 +69,10 @@ public interface ClassHierarchyResolver { /** * Information about a resolved class. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface ClassHierarchyInfo permits ClassHierarchyImpl.ClassHierarchyInfoImpl { /** @@ -94,6 +101,9 @@ public interface ClassHierarchyResolver { * * @param other the other resolver * @return the chained resolver + * + * @implSpec The default implementation returns resolver implemented to ask + * other resolver in cases where this resolver returns {@code null}. */ default ClassHierarchyResolver orElse(ClassHierarchyResolver other) { return new ClassHierarchyResolver() { @@ -115,6 +125,12 @@ public interface ClassHierarchyResolver { * * @param cacheFactory the factory for the cache * @return the ClassHierarchyResolver with caching + * + * @implSpec The default implementation returns resolver holding an instance + * of the cache map provided by the {@code cacheFactory}. It asks + * the cache map always first and fills the cache map with all + * resolved and also unresolved class info. The cache map may refuse + * {@code null} keys and values. */ default ClassHierarchyResolver cached(Supplier> cacheFactory) { return new ClassHierarchyImpl.CachedClassHierarchyResolver(this, cacheFactory.get()); @@ -127,6 +143,9 @@ public interface ClassHierarchyResolver { * {@snippet file="PackageSnippets.java" region="lookup-class-hierarchy-resolver"} * * @return the ClassHierarchyResolver + * + * @implSpec The default implementation calls {@link #cached(Supplier)} with + * {@link HashMap} supplier as {@code cacheFactory}. */ default ClassHierarchyResolver cached() { record Factory() implements Supplier> { diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassModel.java b/src/java.base/share/classes/java/lang/classfile/ClassModel.java similarity index 93% rename from src/java.base/share/classes/jdk/internal/classfile/ClassModel.java rename to src/java.base/share/classes/java/lang/classfile/ClassModel.java index 200f5e8cb78..e0ce7e33865 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassModel.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassModel.java @@ -23,22 +23,26 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.List; import java.util.Optional; import java.util.function.Consumer; -import jdk.internal.classfile.constantpool.ClassEntry; -import jdk.internal.classfile.constantpool.ConstantPool; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.ConstantPool; import jdk.internal.classfile.impl.ClassImpl; import jdk.internal.classfile.impl.verifier.VerifierImpl; +import jdk.internal.javac.PreviewFeature; /** * Models a classfile. The contents of the classfile can be traversed via * a streaming view (e.g., {@link #elements()}), or via random access (e.g., * {@link #flags()}), or by freely mixing the two. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface ClassModel extends CompoundElement, AttributedElement permits ClassImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassReader.java b/src/java.base/share/classes/java/lang/classfile/ClassReader.java similarity index 93% rename from src/java.base/share/classes/jdk/internal/classfile/ClassReader.java rename to src/java.base/share/classes/java/lang/classfile/ClassReader.java index 7884714dfde..a8678715080 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassReader.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassReader.java @@ -22,21 +22,22 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.constantpool.ClassEntry; -import jdk.internal.classfile.constantpool.ConstantPool; -import jdk.internal.classfile.constantpool.ConstantPoolException; -import jdk.internal.classfile.constantpool.MethodHandleEntry; -import jdk.internal.classfile.constantpool.ModuleEntry; -import jdk.internal.classfile.constantpool.NameAndTypeEntry; -import jdk.internal.classfile.constantpool.PackageEntry; -import jdk.internal.classfile.constantpool.PoolEntry; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.ConstantPool; +import java.lang.classfile.constantpool.ConstantPoolException; +import java.lang.classfile.constantpool.MethodHandleEntry; +import java.lang.classfile.constantpool.ModuleEntry; +import java.lang.classfile.constantpool.NameAndTypeEntry; +import java.lang.classfile.constantpool.PackageEntry; +import java.lang.classfile.constantpool.PoolEntry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.ClassReaderImpl; import java.util.Optional; import java.util.function.Function; +import jdk.internal.javac.PreviewFeature; /** * Supports reading from a classfile. Methods are provided to read data of @@ -44,7 +45,10 @@ import java.util.function.Function; * the classfile, copying raw bytes, and reading constant pool entries. * Encapsulates additional reading context such as mappers for custom attributes * and processing options. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface ClassReader extends ConstantPool permits ClassReaderImpl { @@ -52,7 +56,7 @@ public sealed interface ClassReader extends ConstantPool /** * {@return the table of custom attribute mappers} This is derived from - * the processing option {@link Classfile.AttributeMapperOption}. + * the processing option {@link ClassFile.AttributeMapperOption}. */ Function> customAttributes(); @@ -105,6 +109,7 @@ public sealed interface ClassReader extends ConstantPool /** * {@return the constant pool entry of a given type whose index is given * at the specified offset within the classfile} + * @param the entry type * @param offset the offset of the index within the classfile * @param cls the entry type * @throws ConstantPoolException if the index is out of range of the diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassSignature.java b/src/java.base/share/classes/java/lang/classfile/ClassSignature.java similarity index 93% rename from src/java.base/share/classes/jdk/internal/classfile/ClassSignature.java rename to src/java.base/share/classes/java/lang/classfile/ClassSignature.java index 8199d67ed09..10fbdd2045f 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassSignature.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassSignature.java @@ -22,15 +22,19 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.List; import jdk.internal.classfile.impl.SignaturesImpl; import static java.util.Objects.requireNonNull; +import jdk.internal.javac.PreviewFeature; /** * Models the generic signature of a class file, as defined by {@jvms 4.7.9}. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface ClassSignature permits SignaturesImpl.ClassSignatureImpl { @@ -47,7 +51,7 @@ public sealed interface ClassSignature String signatureString(); /** - * @return class signature + * {@return a class signature} * @param superclassSignature the superclass * @param superinterfaceSignatures the interfaces */ @@ -57,7 +61,7 @@ public sealed interface ClassSignature } /** - * @return class signature + * {@return a class signature} * @param typeParameters the type parameters * @param superclassSignature the superclass * @param superinterfaceSignatures the interfaces diff --git a/src/java.base/share/classes/jdk/internal/classfile/ClassTransform.java b/src/java.base/share/classes/java/lang/classfile/ClassTransform.java similarity index 88% rename from src/java.base/share/classes/jdk/internal/classfile/ClassTransform.java rename to src/java.base/share/classes/java/lang/classfile/ClassTransform.java index 8d714ebed61..a2391b320f9 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/ClassTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/ClassTransform.java @@ -22,23 +22,27 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; -import jdk.internal.classfile.attribute.CodeAttribute; +import java.lang.classfile.attribute.CodeAttribute; import jdk.internal.classfile.impl.TransformImpl; +import jdk.internal.javac.PreviewFeature; /** * A transformation on streams of {@link ClassElement}. * - * @see ClassfileTransform + * @see ClassFileTransform + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) @FunctionalInterface public non-sealed interface ClassTransform - extends ClassfileTransform { + extends ClassFileTransform { /** * A class transform that sends all elements to the builder. @@ -156,11 +160,22 @@ public non-sealed interface ClassTransform return new TransformImpl.ClassFieldTransform(xform, f -> true); } + /** + * @implSpec + * The default implementation returns this class transform chained with another + * class transform from the argument. Chaining of two transforms requires to + * involve a chained builder serving as a target builder for this transform + * and also as a source of elements for the downstream transform. + */ @Override default ClassTransform andThen(ClassTransform t) { return new TransformImpl.ChainedClassTransform(this, t); } + /** + * @implSpec The default implementation returns a resolved transform bound + * to the given class builder. + */ @Override default ResolvedTransform resolve(ClassBuilder builder) { return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e), diff --git a/src/java.base/share/classes/jdk/internal/classfile/CodeBuilder.java b/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java similarity index 94% rename from src/java.base/share/classes/jdk/internal/classfile/CodeBuilder.java rename to src/java.base/share/classes/java/lang/classfile/CodeBuilder.java index 3379e673e73..544d7322c1c 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/CodeBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeBuilder.java @@ -23,7 +23,7 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDesc; @@ -36,16 +36,16 @@ import java.util.List; import java.util.Optional; import java.util.function.Consumer; -import jdk.internal.classfile.constantpool.ClassEntry; -import jdk.internal.classfile.constantpool.FieldRefEntry; -import jdk.internal.classfile.constantpool.InterfaceMethodRefEntry; -import jdk.internal.classfile.constantpool.InvokeDynamicEntry; -import jdk.internal.classfile.constantpool.LoadableConstantEntry; -import jdk.internal.classfile.constantpool.MemberRefEntry; -import jdk.internal.classfile.constantpool.MethodRefEntry; -import jdk.internal.classfile.constantpool.MethodHandleEntry; -import jdk.internal.classfile.constantpool.NameAndTypeEntry; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.FieldRefEntry; +import java.lang.classfile.constantpool.InterfaceMethodRefEntry; +import java.lang.classfile.constantpool.InvokeDynamicEntry; +import java.lang.classfile.constantpool.LoadableConstantEntry; +import java.lang.classfile.constantpool.MemberRefEntry; +import java.lang.classfile.constantpool.MethodRefEntry; +import java.lang.classfile.constantpool.MethodHandleEntry; +import java.lang.classfile.constantpool.NameAndTypeEntry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.BlockCodeBuilderImpl; import jdk.internal.classfile.impl.BytecodeHelpers; import jdk.internal.classfile.impl.CatchBuilderImpl; @@ -53,53 +53,57 @@ import jdk.internal.classfile.impl.ChainedCodeBuilder; import jdk.internal.classfile.impl.LabelImpl; import jdk.internal.classfile.impl.NonterminalCodeBuilder; import jdk.internal.classfile.impl.TerminalCodeBuilder; -import jdk.internal.classfile.instruction.ArrayLoadInstruction; -import jdk.internal.classfile.instruction.ArrayStoreInstruction; -import jdk.internal.classfile.instruction.BranchInstruction; -import jdk.internal.classfile.instruction.CharacterRange; -import jdk.internal.classfile.instruction.ConstantInstruction; -import jdk.internal.classfile.instruction.ConvertInstruction; -import jdk.internal.classfile.instruction.ExceptionCatch; -import jdk.internal.classfile.instruction.FieldInstruction; -import jdk.internal.classfile.instruction.IncrementInstruction; -import jdk.internal.classfile.instruction.InvokeDynamicInstruction; -import jdk.internal.classfile.instruction.InvokeInstruction; -import jdk.internal.classfile.instruction.LineNumber; -import jdk.internal.classfile.instruction.LoadInstruction; -import jdk.internal.classfile.instruction.LocalVariable; -import jdk.internal.classfile.instruction.LocalVariableType; -import jdk.internal.classfile.instruction.LookupSwitchInstruction; -import jdk.internal.classfile.instruction.MonitorInstruction; -import jdk.internal.classfile.instruction.NewMultiArrayInstruction; -import jdk.internal.classfile.instruction.NewObjectInstruction; -import jdk.internal.classfile.instruction.NewPrimitiveArrayInstruction; -import jdk.internal.classfile.instruction.NewReferenceArrayInstruction; -import jdk.internal.classfile.instruction.NopInstruction; -import jdk.internal.classfile.instruction.OperatorInstruction; -import jdk.internal.classfile.instruction.ReturnInstruction; -import jdk.internal.classfile.instruction.StackInstruction; -import jdk.internal.classfile.instruction.StoreInstruction; -import jdk.internal.classfile.instruction.SwitchCase; -import jdk.internal.classfile.instruction.TableSwitchInstruction; -import jdk.internal.classfile.instruction.ThrowInstruction; -import jdk.internal.classfile.instruction.TypeCheckInstruction; +import java.lang.classfile.instruction.ArrayLoadInstruction; +import java.lang.classfile.instruction.ArrayStoreInstruction; +import java.lang.classfile.instruction.BranchInstruction; +import java.lang.classfile.instruction.CharacterRange; +import java.lang.classfile.instruction.ConstantInstruction; +import java.lang.classfile.instruction.ConvertInstruction; +import java.lang.classfile.instruction.ExceptionCatch; +import java.lang.classfile.instruction.FieldInstruction; +import java.lang.classfile.instruction.IncrementInstruction; +import java.lang.classfile.instruction.InvokeDynamicInstruction; +import java.lang.classfile.instruction.InvokeInstruction; +import java.lang.classfile.instruction.LineNumber; +import java.lang.classfile.instruction.LoadInstruction; +import java.lang.classfile.instruction.LocalVariable; +import java.lang.classfile.instruction.LocalVariableType; +import java.lang.classfile.instruction.LookupSwitchInstruction; +import java.lang.classfile.instruction.MonitorInstruction; +import java.lang.classfile.instruction.NewMultiArrayInstruction; +import java.lang.classfile.instruction.NewObjectInstruction; +import java.lang.classfile.instruction.NewPrimitiveArrayInstruction; +import java.lang.classfile.instruction.NewReferenceArrayInstruction; +import java.lang.classfile.instruction.NopInstruction; +import java.lang.classfile.instruction.OperatorInstruction; +import java.lang.classfile.instruction.ReturnInstruction; +import java.lang.classfile.instruction.StackInstruction; +import java.lang.classfile.instruction.StoreInstruction; +import java.lang.classfile.instruction.SwitchCase; +import java.lang.classfile.instruction.TableSwitchInstruction; +import java.lang.classfile.instruction.ThrowInstruction; +import java.lang.classfile.instruction.TypeCheckInstruction; import static java.util.Objects.requireNonNull; import static jdk.internal.classfile.impl.BytecodeHelpers.handleDescToHandleInfo; import jdk.internal.classfile.impl.TransformingCodeBuilder; +import jdk.internal.javac.PreviewFeature; /** * A builder for code attributes (method bodies). Builders are not created * directly; they are passed to handlers by methods such as {@link * MethodBuilder#withCode(Consumer)} or to code transforms. The elements of a * code can be specified abstractly, by passing a {@link CodeElement} to {@link - * #with(ClassfileElement)} or concretely by calling the various {@code withXxx} + * #with(ClassFileElement)} or concretely by calling the various {@code withXxx} * methods. * * @see CodeTransform + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface CodeBuilder - extends ClassfileBuilder + extends ClassFileBuilder permits CodeBuilder.BlockCodeBuilder, ChainedCodeBuilder, TerminalCodeBuilder, NonterminalCodeBuilder { /** @@ -174,7 +178,10 @@ public sealed interface CodeBuilder /** * A builder for blocks of code. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface BlockCodeBuilder extends CodeBuilder permits BlockCodeBuilderImpl { /** @@ -315,7 +322,10 @@ public sealed interface CodeBuilder * A builder to add catch blocks. * * @see #trying + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface CatchBuilder permits CatchBuilderImpl { /** * Adds a catch block that catches an exception of the given type. @@ -328,7 +338,8 @@ public sealed interface CodeBuilder * @param catchHandler handler that receives a {@linkplain CodeBuilder} to * generate the body of the catch block. * @return this builder - * @throws IllegalArgumentException if an existing catch block catches an exception of the given type. + * @throws IllegalArgumentException if an existing catch block catches an exception of the given type + * or {@code exceptionType} represents a primitive type * @see #catchingMulti * @see #catchingAll */ @@ -582,6 +593,7 @@ public sealed interface CodeBuilder * Generate an instruction to create a new object * @param type the object type * @return this builder + * @throws IllegalArgumentException if {@code type} represents a primitive type */ default CodeBuilder newObjectInstruction(ClassDesc type) { return newObjectInstruction(constantPool().classEntry(type)); @@ -611,6 +623,7 @@ public sealed interface CodeBuilder * Generate an instruction to create a new array of reference * @param type the component type * @return this builder + * @throws IllegalArgumentException if {@code type} represents a primitive type */ default CodeBuilder newReferenceArrayInstruction(ClassDesc type) { return newReferenceArrayInstruction(constantPool().classEntry(type)); @@ -1005,6 +1018,7 @@ public sealed interface CodeBuilder * Generate an instruction to create a new array of reference * @param className the component type * @return this builder + * @throws IllegalArgumentException if {@code className} represents a primitive type */ default CodeBuilder anewarray(ClassDesc className) { return newReferenceArrayInstruction(constantPool().classEntry(className)); @@ -1097,6 +1111,7 @@ public sealed interface CodeBuilder * Generate an instruction to check whether an object is of the given type * @param type the object type * @return this builder + * @throws IllegalArgumentException if {@code type} represents a primitive type */ default CodeBuilder checkcast(ClassDesc type) { return typeCheckInstruction(Opcode.CHECKCAST, type); @@ -1467,6 +1482,7 @@ public sealed interface CodeBuilder * @param name the field name * @param type the field type * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder getfield(ClassDesc owner, String name, ClassDesc type) { return fieldInstruction(Opcode.GETFIELD, owner, name, type); @@ -1487,6 +1503,7 @@ public sealed interface CodeBuilder * @param name the field name * @param type the field type * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder getstatic(ClassDesc owner, String name, ClassDesc type) { return fieldInstruction(Opcode.GETSTATIC, owner, name, type); @@ -1655,7 +1672,7 @@ public sealed interface CodeBuilder } /** - * Generate an instruction to branch if int comparison succeeds + * Generate an instruction to branch if reference comparison succeeds * @param target the branch target * @return this builder */ @@ -1664,7 +1681,7 @@ public sealed interface CodeBuilder } /** - * Generate an instruction to branch if int comparison succeeds + * Generate an instruction to branch if reference comparison succeeds * @param target the branch target * @return this builder */ @@ -1846,6 +1863,7 @@ public sealed interface CodeBuilder * Generate an instruction to determine if an object is of the given type * @param target the target type * @return this builder + * @throws IllegalArgumentException if {@code target} represents a primitive type */ default CodeBuilder instanceof_(ClassDesc target) { return typeCheckInstruction(Opcode.INSTANCEOF, constantPool().classEntry(target)); @@ -1884,6 +1902,7 @@ public sealed interface CodeBuilder * @param name the method name * @param type the method type * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder invokeinterface(ClassDesc owner, String name, MethodTypeDesc type) { return invokeInstruction(Opcode.INVOKEINTERFACE, constantPool().interfaceMethodRefEntry(owner, name, type)); @@ -1916,6 +1935,7 @@ public sealed interface CodeBuilder * @param name the method name * @param type the method type * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type) { return invokeInstruction(Opcode.INVOKESPECIAL, owner, name, type, false); @@ -1929,6 +1949,7 @@ public sealed interface CodeBuilder * @param type the method type * @param isInterface the interface method invocation indication * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder invokespecial(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) { return invokeInstruction(Opcode.INVOKESPECIAL, owner, name, type, isInterface); @@ -1958,6 +1979,7 @@ public sealed interface CodeBuilder * @param name the method name * @param type the method type * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type) { return invokeInstruction(Opcode.INVOKESTATIC, owner, name, type, false); @@ -1970,6 +1992,7 @@ public sealed interface CodeBuilder * @param type the method type * @param isInterface the interface method invocation indication * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder invokestatic(ClassDesc owner, String name, MethodTypeDesc type, boolean isInterface) { return invokeInstruction(Opcode.INVOKESTATIC, owner, name, type, isInterface); @@ -1990,6 +2013,7 @@ public sealed interface CodeBuilder * @param name the method name * @param type the method type * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder invokevirtual(ClassDesc owner, String name, MethodTypeDesc type) { return invokeInstruction(Opcode.INVOKEVIRTUAL, owner, name, type, false); @@ -2316,6 +2340,7 @@ public sealed interface CodeBuilder * @param array the array type * @param dims the number of dimensions * @return this builder + * @throws IllegalArgumentException if {@code array} represents a primitive type */ default CodeBuilder multianewarray(ClassDesc array, int dims) { return newMultidimensionalArrayInstruction(dims, constantPool().classEntry(array)); @@ -2334,6 +2359,7 @@ public sealed interface CodeBuilder * Generate an instruction to create a new object * @param clazz the new class type * @return this builder + * @throws IllegalArgumentException if {@code clazz} represents a primitive type */ default CodeBuilder new_(ClassDesc clazz) { return newObjectInstruction(constantPool().classEntry(clazz)); @@ -2379,6 +2405,7 @@ public sealed interface CodeBuilder * @param name the field name * @param type the field type * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder putfield(ClassDesc owner, String name, ClassDesc type) { return fieldInstruction(Opcode.PUTFIELD, owner, name, type); @@ -2399,6 +2426,7 @@ public sealed interface CodeBuilder * @param name the field name * @param type the field type * @return this builder + * @throws IllegalArgumentException if {@code owner} represents a primitive type */ default CodeBuilder putstatic(ClassDesc owner, String name, ClassDesc type) { return fieldInstruction(Opcode.PUTSTATIC, owner, name, type); diff --git a/src/java.base/share/classes/jdk/internal/classfile/CodeElement.java b/src/java.base/share/classes/java/lang/classfile/CodeElement.java similarity index 74% rename from src/java.base/share/classes/jdk/internal/classfile/CodeElement.java rename to src/java.base/share/classes/java/lang/classfile/CodeElement.java index 8578e19fcac..cd4fafdd5bb 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/CodeElement.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeElement.java @@ -22,21 +22,26 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.StackMapTableAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.StackMapTableAttribute; +import jdk.internal.javac.PreviewFeature; /** - * A {@link ClassfileElement} that can appear when traversing the elements - * of a {@link CodeModel} or be presented to a {@link CodeBuilder}. Code elements + * A marker interface for elements that can appear when traversing + * a {@link CodeModel} or be presented to a {@link CodeBuilder}. Code elements * are either an {@link Instruction}, which models an instruction in the body * of a method, or a {@link PseudoInstruction}, which models metadata from * the code attribute, such as line number metadata, local variable metadata, * exception metadata, label target metadata, etc. + * + * @sealedGraph + * @since 22 */ -public sealed interface CodeElement extends ClassfileElement +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface CodeElement extends ClassFileElement permits Instruction, PseudoInstruction, CustomAttribute, RuntimeVisibleTypeAnnotationsAttribute, RuntimeInvisibleTypeAnnotationsAttribute, StackMapTableAttribute { diff --git a/src/java.base/share/classes/jdk/internal/classfile/CodeModel.java b/src/java.base/share/classes/java/lang/classfile/CodeModel.java similarity index 89% rename from src/java.base/share/classes/jdk/internal/classfile/CodeModel.java rename to src/java.base/share/classes/java/lang/classfile/CodeModel.java index 8f52f9196a1..b48802d02ac 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/CodeModel.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeModel.java @@ -23,21 +23,25 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.List; import java.util.Optional; -import jdk.internal.classfile.attribute.CodeAttribute; +import java.lang.classfile.attribute.CodeAttribute; import jdk.internal.classfile.impl.BufferedCodeBuilder; import jdk.internal.classfile.impl.CodeImpl; -import jdk.internal.classfile.instruction.ExceptionCatch; +import java.lang.classfile.instruction.ExceptionCatch; +import jdk.internal.javac.PreviewFeature; /** * Models the body of a method (the {@code Code} attribute). The instructions * of the method body are accessed via a streaming view (e.g., {@link * #elements()}). + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface CodeModel extends CompoundElement, AttributedElement, MethodElement permits CodeAttribute, BufferedCodeBuilder.Model, CodeImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/CodeTransform.java b/src/java.base/share/classes/java/lang/classfile/CodeTransform.java similarity index 82% rename from src/java.base/share/classes/jdk/internal/classfile/CodeTransform.java rename to src/java.base/share/classes/java/lang/classfile/CodeTransform.java index 3aa41baea6c..a0996a9cb34 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/CodeTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/CodeTransform.java @@ -22,21 +22,25 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.function.Consumer; import java.util.function.Supplier; import jdk.internal.classfile.impl.TransformImpl; +import jdk.internal.javac.PreviewFeature; /** * A transformation on streams of {@link CodeElement}. * - * @see ClassfileTransform + * @see ClassFileTransform + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) @FunctionalInterface public non-sealed interface CodeTransform - extends ClassfileTransform { + extends ClassFileTransform { /** * A code transform that sends all elements to the builder. @@ -81,11 +85,22 @@ public non-sealed interface CodeTransform }; } + /** + * @implSpec + * The default implementation returns this code transform chained with another + * code transform from the argument. Chaining of two transforms requires to + * involve a chained builder serving as a target builder for this transform + * and also as a source of elements for the downstream transform. + */ @Override default CodeTransform andThen(CodeTransform t) { return new TransformImpl.ChainedCodeTransform(this, t); } + /** + * @implSpec The default implementation returns a resolved transform bound + * to the given code builder. + */ @Override default ResolvedTransform resolve(CodeBuilder builder) { return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e), diff --git a/src/java.base/share/classes/jdk/internal/classfile/CompoundElement.java b/src/java.base/share/classes/java/lang/classfile/CompoundElement.java similarity index 91% rename from src/java.base/share/classes/jdk/internal/classfile/CompoundElement.java rename to src/java.base/share/classes/java/lang/classfile/CompoundElement.java index 40f85aea705..42f0fabadc6 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/CompoundElement.java +++ b/src/java.base/share/classes/java/lang/classfile/CompoundElement.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.ArrayList; import java.util.Iterator; @@ -32,18 +32,23 @@ import java.util.Spliterators; import java.util.function.Consumer; import java.util.stream.Stream; import java.util.stream.StreamSupport; +import jdk.internal.javac.PreviewFeature; /** - * A {@link ClassfileElement} that has complex structure defined in terms of + * A {@link ClassFileElement} that has complex structure defined in terms of * other classfile elements, such as a method, field, method body, or entire * class. When encountering a {@linkplain CompoundElement}, clients have the * option to treat the element as a single entity (e.g., an entire method) * or to traverse the contents of that element with the methods in this class * (e.g., {@link #elements()}, {@link #forEachElement(Consumer)}, etc.) * @param the element type + * + * @sealedGraph + * @since 22 */ -public sealed interface CompoundElement - extends ClassfileElement, Iterable +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface CompoundElement + extends ClassFileElement, Iterable permits ClassModel, CodeModel, FieldModel, MethodModel, jdk.internal.classfile.impl.AbstractUnboundModel { /** * Invoke the provided handler with each element contained in this diff --git a/src/java.base/share/classes/jdk/internal/classfile/CustomAttribute.java b/src/java.base/share/classes/java/lang/classfile/CustomAttribute.java similarity index 69% rename from src/java.base/share/classes/jdk/internal/classfile/CustomAttribute.java rename to src/java.base/share/classes/java/lang/classfile/CustomAttribute.java index cd4d430403a..31544a0ba92 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/CustomAttribute.java +++ b/src/java.base/share/classes/java/lang/classfile/CustomAttribute.java @@ -22,9 +22,9 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.impl.UnboundAttribute; +import jdk.internal.javac.PreviewFeature; /** * Models a non-standard attribute of a classfile. Clients should extend @@ -32,17 +32,41 @@ import jdk.internal.classfile.impl.UnboundAttribute; * and provide an {@link AttributeMapper} to mediate between the classfile * format and the {@linkplain CustomAttribute} representation. * @param the custom attribute type + * + * @since 22 */ -@SuppressWarnings("exports") +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public abstract non-sealed class CustomAttribute> - extends UnboundAttribute.CustomAttribute - implements CodeElement, ClassElement, MethodElement, FieldElement { + implements Attribute, CodeElement, ClassElement, MethodElement, FieldElement { + + private final AttributeMapper mapper; /** * Construct a {@linkplain CustomAttribute}. * @param mapper the attribute mapper */ protected CustomAttribute(AttributeMapper mapper) { - super(mapper); + this.mapper = mapper; + } + + @Override + public final AttributeMapper attributeMapper() { + return mapper; + } + + @Override + public final String attributeName() { + return mapper.name(); + } + + @Override + @SuppressWarnings("unchecked") + public final void writeTo(BufWriter buf) { + mapper.writeAttribute(buf, (T) this); + } + + @Override + public String toString() { + return String.format("CustomAttribute[name=%s]", mapper.name()); } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/FieldBuilder.java b/src/java.base/share/classes/java/lang/classfile/FieldBuilder.java similarity index 90% rename from src/java.base/share/classes/jdk/internal/classfile/FieldBuilder.java rename to src/java.base/share/classes/java/lang/classfile/FieldBuilder.java index 610a8aae76f..18a598398ec 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/FieldBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldBuilder.java @@ -23,27 +23,31 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.ChainedFieldBuilder; import jdk.internal.classfile.impl.TerminalFieldBuilder; import java.lang.reflect.AccessFlag; import java.util.Optional; import java.util.function.Consumer; +import jdk.internal.javac.PreviewFeature; /** * A builder for fields. Builders are not created directly; they are passed * to handlers by methods such as {@link ClassBuilder#withField(Utf8Entry, Utf8Entry, Consumer)} * or to field transforms. The elements of a field can be specified - * abstractly (by passing a {@link FieldElement} to {@link #with(ClassfileElement)} + * abstractly (by passing a {@link FieldElement} to {@link #with(ClassFileElement)} * or concretely by calling the various {@code withXxx} methods. * * @see FieldTransform + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface FieldBuilder - extends ClassfileBuilder + extends ClassFileBuilder permits TerminalFieldBuilder, ChainedFieldBuilder { /** diff --git a/src/java.base/share/classes/jdk/internal/classfile/FieldElement.java b/src/java.base/share/classes/java/lang/classfile/FieldElement.java similarity index 62% rename from src/java.base/share/classes/jdk/internal/classfile/FieldElement.java rename to src/java.base/share/classes/java/lang/classfile/FieldElement.java index 6a25045482c..c41c9224bd3 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/FieldElement.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldElement.java @@ -22,23 +22,28 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.attribute.ConstantValueAttribute; -import jdk.internal.classfile.attribute.DeprecatedAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.SignatureAttribute; -import jdk.internal.classfile.attribute.SyntheticAttribute; -import jdk.internal.classfile.attribute.UnknownAttribute; +import java.lang.classfile.attribute.ConstantValueAttribute; +import java.lang.classfile.attribute.DeprecatedAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.SignatureAttribute; +import java.lang.classfile.attribute.SyntheticAttribute; +import java.lang.classfile.attribute.UnknownAttribute; +import jdk.internal.javac.PreviewFeature; /** - * A {@link ClassfileElement} that can appear when traversing the elements - * of a {@link FieldModel} or be presented to a {@link FieldBuilder}. + * A marker interface for elements that can appear when traversing + * a {@link FieldModel} or be presented to a {@link FieldBuilder}. + * + * @sealedGraph + * @since 22 */ -public sealed interface FieldElement extends ClassfileElement +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface FieldElement extends ClassFileElement permits AccessFlags, CustomAttribute, ConstantValueAttribute, DeprecatedAttribute, RuntimeInvisibleAnnotationsAttribute, RuntimeInvisibleTypeAnnotationsAttribute, diff --git a/src/java.base/share/classes/jdk/internal/classfile/FieldModel.java b/src/java.base/share/classes/java/lang/classfile/FieldModel.java similarity index 91% rename from src/java.base/share/classes/jdk/internal/classfile/FieldModel.java rename to src/java.base/share/classes/java/lang/classfile/FieldModel.java index c12098cfd82..cb2e167b9cf 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/FieldModel.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldModel.java @@ -23,20 +23,24 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ClassDesc; import java.util.Optional; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.BufferedFieldBuilder; import jdk.internal.classfile.impl.FieldImpl; +import jdk.internal.javac.PreviewFeature; /** * Models a field. The contents of the field can be traversed via * a streaming view (e.g., {@link #elements()}), or via random access (e.g., * {@link #flags()}), or by freely mixing the two. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface FieldModel extends WritableElement, CompoundElement, AttributedElement, ClassElement permits BufferedFieldBuilder.Model, FieldImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/FieldTransform.java b/src/java.base/share/classes/java/lang/classfile/FieldTransform.java similarity index 84% rename from src/java.base/share/classes/jdk/internal/classfile/FieldTransform.java rename to src/java.base/share/classes/java/lang/classfile/FieldTransform.java index 05ffa167a08..1a27a1d6ee6 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/FieldTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/FieldTransform.java @@ -22,22 +22,26 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; import jdk.internal.classfile.impl.TransformImpl; +import jdk.internal.javac.PreviewFeature; /** * A transformation on streams of {@link FieldElement}. * - * @see ClassfileTransform + * @see ClassFileTransform + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) @FunctionalInterface public non-sealed interface FieldTransform - extends ClassfileTransform { + extends ClassFileTransform { /** * A field transform that sends all elements to the builder. @@ -96,11 +100,22 @@ public non-sealed interface FieldTransform }; } + /** + * @implSpec + * The default implementation returns this field transform chained with another + * field transform from the argument. Chaining of two transforms requires to + * involve a chained builder serving as a target builder for this transform + * and also as a source of elements for the downstream transform. + */ @Override default FieldTransform andThen(FieldTransform t) { return new TransformImpl.ChainedFieldTransform(this, t); } + /** + * @implSpec The default implementation returns a resolved transform bound + * to the given field builder. + */ @Override default ResolvedTransform resolve(FieldBuilder builder) { return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e), diff --git a/src/java.base/share/classes/jdk/internal/classfile/Instruction.java b/src/java.base/share/classes/java/lang/classfile/Instruction.java similarity index 57% rename from src/java.base/share/classes/jdk/internal/classfile/Instruction.java rename to src/java.base/share/classes/java/lang/classfile/Instruction.java index 9a1a81d548e..08255d8a5b1 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Instruction.java +++ b/src/java.base/share/classes/java/lang/classfile/Instruction.java @@ -23,38 +23,42 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import jdk.internal.classfile.impl.AbstractInstruction; -import jdk.internal.classfile.instruction.ArrayLoadInstruction; -import jdk.internal.classfile.instruction.ArrayStoreInstruction; -import jdk.internal.classfile.instruction.BranchInstruction; -import jdk.internal.classfile.instruction.ConstantInstruction; -import jdk.internal.classfile.instruction.ConvertInstruction; -import jdk.internal.classfile.instruction.DiscontinuedInstruction; -import jdk.internal.classfile.instruction.FieldInstruction; -import jdk.internal.classfile.instruction.IncrementInstruction; -import jdk.internal.classfile.instruction.InvokeDynamicInstruction; -import jdk.internal.classfile.instruction.InvokeInstruction; -import jdk.internal.classfile.instruction.LoadInstruction; -import jdk.internal.classfile.instruction.LookupSwitchInstruction; -import jdk.internal.classfile.instruction.MonitorInstruction; -import jdk.internal.classfile.instruction.NewMultiArrayInstruction; -import jdk.internal.classfile.instruction.NewObjectInstruction; -import jdk.internal.classfile.instruction.NewPrimitiveArrayInstruction; -import jdk.internal.classfile.instruction.NewReferenceArrayInstruction; -import jdk.internal.classfile.instruction.NopInstruction; -import jdk.internal.classfile.instruction.OperatorInstruction; -import jdk.internal.classfile.instruction.ReturnInstruction; -import jdk.internal.classfile.instruction.StackInstruction; -import jdk.internal.classfile.instruction.StoreInstruction; -import jdk.internal.classfile.instruction.TableSwitchInstruction; -import jdk.internal.classfile.instruction.ThrowInstruction; -import jdk.internal.classfile.instruction.TypeCheckInstruction; +import java.lang.classfile.instruction.ArrayLoadInstruction; +import java.lang.classfile.instruction.ArrayStoreInstruction; +import java.lang.classfile.instruction.BranchInstruction; +import java.lang.classfile.instruction.ConstantInstruction; +import java.lang.classfile.instruction.ConvertInstruction; +import java.lang.classfile.instruction.DiscontinuedInstruction; +import java.lang.classfile.instruction.FieldInstruction; +import java.lang.classfile.instruction.IncrementInstruction; +import java.lang.classfile.instruction.InvokeDynamicInstruction; +import java.lang.classfile.instruction.InvokeInstruction; +import java.lang.classfile.instruction.LoadInstruction; +import java.lang.classfile.instruction.LookupSwitchInstruction; +import java.lang.classfile.instruction.MonitorInstruction; +import java.lang.classfile.instruction.NewMultiArrayInstruction; +import java.lang.classfile.instruction.NewObjectInstruction; +import java.lang.classfile.instruction.NewPrimitiveArrayInstruction; +import java.lang.classfile.instruction.NewReferenceArrayInstruction; +import java.lang.classfile.instruction.NopInstruction; +import java.lang.classfile.instruction.OperatorInstruction; +import java.lang.classfile.instruction.ReturnInstruction; +import java.lang.classfile.instruction.StackInstruction; +import java.lang.classfile.instruction.StoreInstruction; +import java.lang.classfile.instruction.TableSwitchInstruction; +import java.lang.classfile.instruction.ThrowInstruction; +import java.lang.classfile.instruction.TypeCheckInstruction; +import jdk.internal.javac.PreviewFeature; /** * Models an executable instruction in a method body. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface Instruction extends CodeElement permits ArrayLoadInstruction, ArrayStoreInstruction, BranchInstruction, ConstantInstruction, ConvertInstruction, DiscontinuedInstruction, diff --git a/src/java.base/share/classes/jdk/internal/classfile/Interfaces.java b/src/java.base/share/classes/java/lang/classfile/Interfaces.java similarity index 90% rename from src/java.base/share/classes/jdk/internal/classfile/Interfaces.java rename to src/java.base/share/classes/java/lang/classfile/Interfaces.java index f6e6fa7ed55..9092334bfb4 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Interfaces.java +++ b/src/java.base/share/classes/java/lang/classfile/Interfaces.java @@ -22,20 +22,24 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ClassDesc; import java.util.Arrays; import java.util.List; -import jdk.internal.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.ClassEntry; import jdk.internal.classfile.impl.InterfacesImpl; import jdk.internal.classfile.impl.Util; +import jdk.internal.javac.PreviewFeature; /** * Models the interfaces of a class. Delivered as a {@link - * jdk.internal.classfile.ClassElement} when traversing a {@link ClassModel}. + * java.lang.classfile.ClassElement} when traversing a {@link ClassModel}. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface Interfaces extends ClassElement permits InterfacesImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/Label.java b/src/java.base/share/classes/java/lang/classfile/Label.java similarity index 92% rename from src/java.base/share/classes/jdk/internal/classfile/Label.java rename to src/java.base/share/classes/java/lang/classfile/Label.java index 0ef6ea9248c..5069b935935 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Label.java +++ b/src/java.base/share/classes/java/lang/classfile/Label.java @@ -22,9 +22,10 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import jdk.internal.classfile.impl.LabelImpl; +import jdk.internal.javac.PreviewFeature; /** * A marker for a position within the instructions of a method body. The @@ -37,8 +38,11 @@ import jdk.internal.classfile.impl.LabelImpl; * traversing the elements of a {@linkplain CodeModel}, {@linkplain Label} * markers will be delivered at the position to which they correspond. A label * can be bound to the current position within a {@linkplain CodeBuilder} via - * {@link CodeBuilder#labelBinding(Label)} or {@link CodeBuilder#with(ClassfileElement)}. + * {@link CodeBuilder#labelBinding(Label)} or {@link CodeBuilder#with(ClassFileElement)}. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface Label permits LabelImpl { } diff --git a/src/java.base/share/classes/jdk/internal/classfile/MethodBuilder.java b/src/java.base/share/classes/java/lang/classfile/MethodBuilder.java similarity index 92% rename from src/java.base/share/classes/jdk/internal/classfile/MethodBuilder.java rename to src/java.base/share/classes/java/lang/classfile/MethodBuilder.java index 6b57d0599d1..ece292c361b 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/MethodBuilder.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodBuilder.java @@ -23,27 +23,31 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.Optional; import java.util.function.Consumer; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.ChainedMethodBuilder; import jdk.internal.classfile.impl.TerminalMethodBuilder; import java.lang.reflect.AccessFlag; +import jdk.internal.javac.PreviewFeature; /** * A builder for methods. Builders are not created directly; they are passed * to handlers by methods such as {@link ClassBuilder#withMethod(Utf8Entry, Utf8Entry, int, Consumer)} * or to method transforms. The elements of a method can be specified - * abstractly (by passing a {@link MethodElement} to {@link #with(ClassfileElement)} + * abstractly (by passing a {@link MethodElement} to {@link #with(ClassFileElement)} * or concretely by calling the various {@code withXxx} methods. * * @see MethodTransform + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface MethodBuilder - extends ClassfileBuilder + extends ClassFileBuilder permits ChainedMethodBuilder, TerminalMethodBuilder { /** diff --git a/src/java.base/share/classes/jdk/internal/classfile/MethodElement.java b/src/java.base/share/classes/java/lang/classfile/MethodElement.java similarity index 60% rename from src/java.base/share/classes/jdk/internal/classfile/MethodElement.java rename to src/java.base/share/classes/java/lang/classfile/MethodElement.java index 28334b57e8f..a744952de7a 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/MethodElement.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodElement.java @@ -22,28 +22,33 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.attribute.AnnotationDefaultAttribute; -import jdk.internal.classfile.attribute.DeprecatedAttribute; -import jdk.internal.classfile.attribute.ExceptionsAttribute; -import jdk.internal.classfile.attribute.MethodParametersAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.SignatureAttribute; -import jdk.internal.classfile.attribute.SyntheticAttribute; -import jdk.internal.classfile.attribute.UnknownAttribute; +import java.lang.classfile.attribute.AnnotationDefaultAttribute; +import java.lang.classfile.attribute.DeprecatedAttribute; +import java.lang.classfile.attribute.ExceptionsAttribute; +import java.lang.classfile.attribute.MethodParametersAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleParameterAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.SignatureAttribute; +import java.lang.classfile.attribute.SyntheticAttribute; +import java.lang.classfile.attribute.UnknownAttribute; +import jdk.internal.javac.PreviewFeature; /** - * A {@link ClassfileElement} that can appear when traversing the elements - * of a {@link MethodModel} or be presented to a {@link MethodBuilder}. + * A marker interface for elements that can appear when traversing + * a {@link MethodModel} or be presented to a {@link MethodBuilder}. + * + * @sealedGraph + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface MethodElement - extends ClassfileElement + extends ClassFileElement permits AccessFlags, CodeModel, CustomAttribute, AnnotationDefaultAttribute, DeprecatedAttribute, ExceptionsAttribute, MethodParametersAttribute, diff --git a/src/java.base/share/classes/jdk/internal/classfile/MethodModel.java b/src/java.base/share/classes/java/lang/classfile/MethodModel.java similarity index 92% rename from src/java.base/share/classes/jdk/internal/classfile/MethodModel.java rename to src/java.base/share/classes/java/lang/classfile/MethodModel.java index 84d0aeb69c8..49cbb6ac7fd 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/MethodModel.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodModel.java @@ -23,20 +23,24 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.MethodTypeDesc; import java.util.Optional; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.BufferedMethodBuilder; import jdk.internal.classfile.impl.MethodImpl; +import jdk.internal.javac.PreviewFeature; /** * Models a method. The contents of the method can be traversed via * a streaming view (e.g., {@link #elements()}), or via random access (e.g., * {@link #flags()}), or by freely mixing the two. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface MethodModel extends WritableElement, CompoundElement, AttributedElement, ClassElement permits BufferedMethodBuilder.Model, MethodImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/MethodSignature.java b/src/java.base/share/classes/java/lang/classfile/MethodSignature.java similarity index 93% rename from src/java.base/share/classes/jdk/internal/classfile/MethodSignature.java rename to src/java.base/share/classes/java/lang/classfile/MethodSignature.java index e08b0bd392b..4c331ec5156 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/MethodSignature.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodSignature.java @@ -22,17 +22,21 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.MethodTypeDesc; import java.util.List; import jdk.internal.classfile.impl.SignaturesImpl; import static java.util.Objects.requireNonNull; import jdk.internal.classfile.impl.Util; +import jdk.internal.javac.PreviewFeature; /** * Models the generic signature of a method, as defined by {@jvms 4.7.9}. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface MethodSignature permits SignaturesImpl.MethodSignatureImpl { @@ -52,7 +56,7 @@ public sealed interface MethodSignature String signatureString(); /** - * @return method signature for a raw (no generic information) method descriptor + * {@return a method signature for a raw (no generic information) method descriptor} * @param methodDescriptor the method descriptor */ public static MethodSignature of(MethodTypeDesc methodDescriptor) { @@ -66,7 +70,7 @@ public sealed interface MethodSignature } /** - * @return method signature + * {@return a method signature} * @param result signature for the return type * @param arguments signatures for the method arguments */ @@ -80,7 +84,7 @@ public sealed interface MethodSignature } /** - * @return method signature + * {@return a method signature} * @param typeParameters signatures for the type parameters * @param exceptions signatures for the exceptions * @param result signature for the return type diff --git a/src/java.base/share/classes/jdk/internal/classfile/MethodTransform.java b/src/java.base/share/classes/java/lang/classfile/MethodTransform.java similarity index 85% rename from src/java.base/share/classes/jdk/internal/classfile/MethodTransform.java rename to src/java.base/share/classes/java/lang/classfile/MethodTransform.java index 1aa1f5e6a08..829ca041c5a 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/MethodTransform.java +++ b/src/java.base/share/classes/java/lang/classfile/MethodTransform.java @@ -22,22 +22,26 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; import jdk.internal.classfile.impl.TransformImpl; +import jdk.internal.javac.PreviewFeature; /** * A transformation on streams of {@link MethodElement}. * - * @see ClassfileTransform + * @see ClassFileTransform + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) @FunctionalInterface public non-sealed interface MethodTransform - extends ClassfileTransform { + extends ClassFileTransform { /** * A method transform that sends all elements to the builder. @@ -107,6 +111,10 @@ public non-sealed interface MethodTransform return new TransformImpl.MethodCodeTransform(xform); } + /** + * @implSpec The default implementation returns a resolved transform bound + * to the given method builder. + */ @Override default ResolvedTransform resolve(MethodBuilder builder) { return new TransformImpl.ResolvedTransformImpl<>(e -> accept(builder, e), @@ -114,6 +122,13 @@ public non-sealed interface MethodTransform () -> atStart(builder)); } + /** + * @implSpec + * The default implementation returns this method transform chained with another + * method transform from the argument. Chaining of two transforms requires to + * involve a chained builder serving as a target builder for this transform + * and also as a source of elements for the downstream transform. + */ @Override default MethodTransform andThen(MethodTransform t) { return new TransformImpl.ChainedMethodTransform(this, t); diff --git a/src/java.base/share/classes/jdk/internal/classfile/Opcode.java b/src/java.base/share/classes/java/lang/classfile/Opcode.java similarity index 62% rename from src/java.base/share/classes/jdk/internal/classfile/Opcode.java rename to src/java.base/share/classes/java/lang/classfile/Opcode.java index af1027baeca..9c4a1a80625 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Opcode.java +++ b/src/java.base/share/classes/java/lang/classfile/Opcode.java @@ -22,10 +22,11 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ConstantDesc; import java.lang.constant.ConstantDescs; +import jdk.internal.javac.PreviewFeature; /** * Describes the opcodes of the JVM instruction set, as described in {@jvms 6.5}. @@ -34,654 +35,672 @@ import java.lang.constant.ConstantDescs; * * @see Instruction * @see PseudoInstruction + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public enum Opcode { /** Do nothing */ - NOP(Classfile.NOP, 1, Kind.NOP), + NOP(ClassFile.NOP, 1, Kind.NOP), /** Push null */ - ACONST_NULL(Classfile.ACONST_NULL, 1, Kind.CONSTANT, TypeKind.ReferenceType, 0, ConstantDescs.NULL), + ACONST_NULL(ClassFile.ACONST_NULL, 1, Kind.CONSTANT, TypeKind.ReferenceType, 0, ConstantDescs.NULL), /** Push int constant -1 */ - ICONST_M1(Classfile.ICONST_M1, 1, Kind.CONSTANT, TypeKind.IntType, 0, -1), + ICONST_M1(ClassFile.ICONST_M1, 1, Kind.CONSTANT, TypeKind.IntType, 0, -1), /** Push int constant 0 */ - ICONST_0(Classfile.ICONST_0, 1, Kind.CONSTANT, TypeKind.IntType, 0, 0), + ICONST_0(ClassFile.ICONST_0, 1, Kind.CONSTANT, TypeKind.IntType, 0, 0), /** Push int constant 1 */ - ICONST_1(Classfile.ICONST_1, 1, Kind.CONSTANT, TypeKind.IntType, 0, 1), + ICONST_1(ClassFile.ICONST_1, 1, Kind.CONSTANT, TypeKind.IntType, 0, 1), /** Push int constant 2 */ - ICONST_2(Classfile.ICONST_2, 1, Kind.CONSTANT, TypeKind.IntType, 0, 2), + ICONST_2(ClassFile.ICONST_2, 1, Kind.CONSTANT, TypeKind.IntType, 0, 2), /** Push int constant 3 */ - ICONST_3(Classfile.ICONST_3, 1, Kind.CONSTANT, TypeKind.IntType, 0, 3), + ICONST_3(ClassFile.ICONST_3, 1, Kind.CONSTANT, TypeKind.IntType, 0, 3), /** Push int constant 4 */ - ICONST_4(Classfile.ICONST_4, 1, Kind.CONSTANT, TypeKind.IntType, 0, 4), + ICONST_4(ClassFile.ICONST_4, 1, Kind.CONSTANT, TypeKind.IntType, 0, 4), /** Push int constant 5 */ - ICONST_5(Classfile.ICONST_5, 1, Kind.CONSTANT, TypeKind.IntType, 0, 5), + ICONST_5(ClassFile.ICONST_5, 1, Kind.CONSTANT, TypeKind.IntType, 0, 5), /** Push long constant 0 */ - LCONST_0(Classfile.LCONST_0, 1, Kind.CONSTANT, TypeKind.LongType, 0, 0L), + LCONST_0(ClassFile.LCONST_0, 1, Kind.CONSTANT, TypeKind.LongType, 0, 0L), /** Push long constant 1 */ - LCONST_1(Classfile.LCONST_1, 1, Kind.CONSTANT, TypeKind.LongType, 0, 1L), + LCONST_1(ClassFile.LCONST_1, 1, Kind.CONSTANT, TypeKind.LongType, 0, 1L), /** Push float constant 0 */ - FCONST_0(Classfile.FCONST_0, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 0.0f), + FCONST_0(ClassFile.FCONST_0, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 0.0f), /** Push float constant 1 */ - FCONST_1(Classfile.FCONST_1, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 1.0f), + FCONST_1(ClassFile.FCONST_1, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 1.0f), /** Push float constant 2 */ - FCONST_2(Classfile.FCONST_2, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 2.0f), + FCONST_2(ClassFile.FCONST_2, 1, Kind.CONSTANT, TypeKind.FloatType, 0, 2.0f), /** Push double constant 0 */ - DCONST_0(Classfile.DCONST_0, 1, Kind.CONSTANT, TypeKind.DoubleType, 0, 0.0d), + DCONST_0(ClassFile.DCONST_0, 1, Kind.CONSTANT, TypeKind.DoubleType, 0, 0.0d), /** Push double constant 1 */ - DCONST_1(Classfile.DCONST_1, 1, Kind.CONSTANT, TypeKind.DoubleType, 0, 1.0d), + DCONST_1(ClassFile.DCONST_1, 1, Kind.CONSTANT, TypeKind.DoubleType, 0, 1.0d), /** Push byte */ - BIPUSH(Classfile.BIPUSH, 2, Kind.CONSTANT, TypeKind.ByteType), + BIPUSH(ClassFile.BIPUSH, 2, Kind.CONSTANT, TypeKind.ByteType), /** Push short */ - SIPUSH(Classfile.SIPUSH, 3, Kind.CONSTANT, TypeKind.ShortType), + SIPUSH(ClassFile.SIPUSH, 3, Kind.CONSTANT, TypeKind.ShortType), /** Push item from run-time constant pool */ - LDC(Classfile.LDC, 2, Kind.CONSTANT), + LDC(ClassFile.LDC, 2, Kind.CONSTANT), /** Push item from run-time constant pool (wide index) */ - LDC_W(Classfile.LDC_W, 3, Kind.CONSTANT), + LDC_W(ClassFile.LDC_W, 3, Kind.CONSTANT), /** Push long or double from run-time constant pool (wide index) */ - LDC2_W(Classfile.LDC2_W, 3, Kind.CONSTANT), + LDC2_W(ClassFile.LDC2_W, 3, Kind.CONSTANT), /** Load int from local variable */ - ILOAD(Classfile.ILOAD, 2, Kind.LOAD, TypeKind.IntType, -1), + ILOAD(ClassFile.ILOAD, 2, Kind.LOAD, TypeKind.IntType, -1), /** Load long from local variable */ - LLOAD(Classfile.LLOAD, 2, Kind.LOAD, TypeKind.LongType, -1), + LLOAD(ClassFile.LLOAD, 2, Kind.LOAD, TypeKind.LongType, -1), /** Load float from local variable */ - FLOAD(Classfile.FLOAD, 2, Kind.LOAD, TypeKind.FloatType, -1), + FLOAD(ClassFile.FLOAD, 2, Kind.LOAD, TypeKind.FloatType, -1), /** Load double from local variable */ - DLOAD(Classfile.DLOAD, 2, Kind.LOAD, TypeKind.DoubleType, -1), + DLOAD(ClassFile.DLOAD, 2, Kind.LOAD, TypeKind.DoubleType, -1), /** Load reference from local variable */ - ALOAD(Classfile.ALOAD, 2, Kind.LOAD, TypeKind.ReferenceType, -1), + ALOAD(ClassFile.ALOAD, 2, Kind.LOAD, TypeKind.ReferenceType, -1), /** Load int from local variable 0 */ - ILOAD_0(Classfile.ILOAD_0, 1, Kind.LOAD, TypeKind.IntType, 0), + ILOAD_0(ClassFile.ILOAD_0, 1, Kind.LOAD, TypeKind.IntType, 0), /** Load int from local variable 1 */ - ILOAD_1(Classfile.ILOAD_1, 1, Kind.LOAD, TypeKind.IntType, 1), + ILOAD_1(ClassFile.ILOAD_1, 1, Kind.LOAD, TypeKind.IntType, 1), /** Load int from local variable 2 */ - ILOAD_2(Classfile.ILOAD_2, 1, Kind.LOAD, TypeKind.IntType, 2), + ILOAD_2(ClassFile.ILOAD_2, 1, Kind.LOAD, TypeKind.IntType, 2), /** Load int from local variable3 */ - ILOAD_3(Classfile.ILOAD_3, 1, Kind.LOAD, TypeKind.IntType, 3), + ILOAD_3(ClassFile.ILOAD_3, 1, Kind.LOAD, TypeKind.IntType, 3), /** Load long from local variable 0 */ - LLOAD_0(Classfile.LLOAD_0, 1, Kind.LOAD, TypeKind.LongType, 0), + LLOAD_0(ClassFile.LLOAD_0, 1, Kind.LOAD, TypeKind.LongType, 0), /** Load long from local variable 1 */ - LLOAD_1(Classfile.LLOAD_1, 1, Kind.LOAD, TypeKind.LongType, 1), + LLOAD_1(ClassFile.LLOAD_1, 1, Kind.LOAD, TypeKind.LongType, 1), /** Load long from local variable 2 */ - LLOAD_2(Classfile.LLOAD_2, 1, Kind.LOAD, TypeKind.LongType, 2), + LLOAD_2(ClassFile.LLOAD_2, 1, Kind.LOAD, TypeKind.LongType, 2), /** Load long from local variable 3 */ - LLOAD_3(Classfile.LLOAD_3, 1, Kind.LOAD, TypeKind.LongType, 3), + LLOAD_3(ClassFile.LLOAD_3, 1, Kind.LOAD, TypeKind.LongType, 3), /** Load float from local variable 0 */ - FLOAD_0(Classfile.FLOAD_0, 1, Kind.LOAD, TypeKind.FloatType, 0), + FLOAD_0(ClassFile.FLOAD_0, 1, Kind.LOAD, TypeKind.FloatType, 0), /** Load float from local variable 1 */ - FLOAD_1(Classfile.FLOAD_1, 1, Kind.LOAD, TypeKind.FloatType, 1), + FLOAD_1(ClassFile.FLOAD_1, 1, Kind.LOAD, TypeKind.FloatType, 1), /** Load float from local variable 2 */ - FLOAD_2(Classfile.FLOAD_2, 1, Kind.LOAD, TypeKind.FloatType, 2), + FLOAD_2(ClassFile.FLOAD_2, 1, Kind.LOAD, TypeKind.FloatType, 2), /** Load float from local variable 3 */ - FLOAD_3(Classfile.FLOAD_3, 1, Kind.LOAD, TypeKind.FloatType, 3), + FLOAD_3(ClassFile.FLOAD_3, 1, Kind.LOAD, TypeKind.FloatType, 3), /** Load double from local variable 0 */ - DLOAD_0(Classfile.DLOAD_0, 1, Kind.LOAD, TypeKind.DoubleType, 0), + DLOAD_0(ClassFile.DLOAD_0, 1, Kind.LOAD, TypeKind.DoubleType, 0), /** Load double from local variable 1 */ - DLOAD_1(Classfile.DLOAD_1, 1, Kind.LOAD, TypeKind.DoubleType, 1), + DLOAD_1(ClassFile.DLOAD_1, 1, Kind.LOAD, TypeKind.DoubleType, 1), /** Load double from local variable 2 */ - DLOAD_2(Classfile.DLOAD_2, 1, Kind.LOAD, TypeKind.DoubleType, 2), + DLOAD_2(ClassFile.DLOAD_2, 1, Kind.LOAD, TypeKind.DoubleType, 2), /** Load double from local variable 3 */ - DLOAD_3(Classfile.DLOAD_3, 1, Kind.LOAD, TypeKind.DoubleType, 3), + DLOAD_3(ClassFile.DLOAD_3, 1, Kind.LOAD, TypeKind.DoubleType, 3), /** Load reference from local variable 0 */ - ALOAD_0(Classfile.ALOAD_0, 1, Kind.LOAD, TypeKind.ReferenceType, 0), + ALOAD_0(ClassFile.ALOAD_0, 1, Kind.LOAD, TypeKind.ReferenceType, 0), /** Load reference from local variable 1 */ - ALOAD_1(Classfile.ALOAD_1, 1, Kind.LOAD, TypeKind.ReferenceType, 1), + ALOAD_1(ClassFile.ALOAD_1, 1, Kind.LOAD, TypeKind.ReferenceType, 1), /** Load reference from local variable 2 */ - ALOAD_2(Classfile.ALOAD_2, 1, Kind.LOAD, TypeKind.ReferenceType, 2), + ALOAD_2(ClassFile.ALOAD_2, 1, Kind.LOAD, TypeKind.ReferenceType, 2), /** Load reference from local variable 3 */ - ALOAD_3(Classfile.ALOAD_3, 1, Kind.LOAD, TypeKind.ReferenceType, 3), + ALOAD_3(ClassFile.ALOAD_3, 1, Kind.LOAD, TypeKind.ReferenceType, 3), /** Load int from array */ - IALOAD(Classfile.IALOAD, 1, Kind.ARRAY_LOAD, TypeKind.IntType), + IALOAD(ClassFile.IALOAD, 1, Kind.ARRAY_LOAD, TypeKind.IntType), /** Load long from array */ - LALOAD(Classfile.LALOAD, 1, Kind.ARRAY_LOAD, TypeKind.LongType), + LALOAD(ClassFile.LALOAD, 1, Kind.ARRAY_LOAD, TypeKind.LongType), /** Load float from array */ - FALOAD(Classfile.FALOAD, 1, Kind.ARRAY_LOAD, TypeKind.FloatType), + FALOAD(ClassFile.FALOAD, 1, Kind.ARRAY_LOAD, TypeKind.FloatType), /** Load double from array */ - DALOAD(Classfile.DALOAD, 1, Kind.ARRAY_LOAD, TypeKind.DoubleType), + DALOAD(ClassFile.DALOAD, 1, Kind.ARRAY_LOAD, TypeKind.DoubleType), /** Load reference from array */ - AALOAD(Classfile.AALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ReferenceType), + AALOAD(ClassFile.AALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ReferenceType), /** Load byte from array */ - BALOAD(Classfile.BALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ByteType), + BALOAD(ClassFile.BALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ByteType), /** Load char from array */ - CALOAD(Classfile.CALOAD, 1, Kind.ARRAY_LOAD, TypeKind.CharType), + CALOAD(ClassFile.CALOAD, 1, Kind.ARRAY_LOAD, TypeKind.CharType), /** Load short from array */ - SALOAD(Classfile.SALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ShortType), + SALOAD(ClassFile.SALOAD, 1, Kind.ARRAY_LOAD, TypeKind.ShortType), /** Store int into local variable */ - ISTORE(Classfile.ISTORE, 2, Kind.STORE, TypeKind.IntType, -1), + ISTORE(ClassFile.ISTORE, 2, Kind.STORE, TypeKind.IntType, -1), /** Store long into local variable */ - LSTORE(Classfile.LSTORE, 2, Kind.STORE, TypeKind.LongType, -1), + LSTORE(ClassFile.LSTORE, 2, Kind.STORE, TypeKind.LongType, -1), /** Store float into local variable */ - FSTORE(Classfile.FSTORE, 2, Kind.STORE, TypeKind.FloatType, -1), + FSTORE(ClassFile.FSTORE, 2, Kind.STORE, TypeKind.FloatType, -1), /** Store double into local variable */ - DSTORE(Classfile.DSTORE, 2, Kind.STORE, TypeKind.DoubleType, -1), + DSTORE(ClassFile.DSTORE, 2, Kind.STORE, TypeKind.DoubleType, -1), /** Store reference into local variable */ - ASTORE(Classfile.ASTORE, 2, Kind.STORE, TypeKind.ReferenceType, -1), + ASTORE(ClassFile.ASTORE, 2, Kind.STORE, TypeKind.ReferenceType, -1), /** Store int into local variable 0 */ - ISTORE_0(Classfile.ISTORE_0, 1, Kind.STORE, TypeKind.IntType, 0), + ISTORE_0(ClassFile.ISTORE_0, 1, Kind.STORE, TypeKind.IntType, 0), /** Store int into local variable 1 */ - ISTORE_1(Classfile.ISTORE_1, 1, Kind.STORE, TypeKind.IntType, 1), + ISTORE_1(ClassFile.ISTORE_1, 1, Kind.STORE, TypeKind.IntType, 1), /** Store int into local variable 2 */ - ISTORE_2(Classfile.ISTORE_2, 1, Kind.STORE, TypeKind.IntType, 2), + ISTORE_2(ClassFile.ISTORE_2, 1, Kind.STORE, TypeKind.IntType, 2), /** Store int into local variable 3 */ - ISTORE_3(Classfile.ISTORE_3, 1, Kind.STORE, TypeKind.IntType, 3), + ISTORE_3(ClassFile.ISTORE_3, 1, Kind.STORE, TypeKind.IntType, 3), /** Store long into local variable 0 */ - LSTORE_0(Classfile.LSTORE_0, 1, Kind.STORE, TypeKind.LongType, 0), + LSTORE_0(ClassFile.LSTORE_0, 1, Kind.STORE, TypeKind.LongType, 0), /** Store long into local variable 1 */ - LSTORE_1(Classfile.LSTORE_1, 1, Kind.STORE, TypeKind.LongType, 1), + LSTORE_1(ClassFile.LSTORE_1, 1, Kind.STORE, TypeKind.LongType, 1), /** Store long into local variable 2 */ - LSTORE_2(Classfile.LSTORE_2, 1, Kind.STORE, TypeKind.LongType, 2), + LSTORE_2(ClassFile.LSTORE_2, 1, Kind.STORE, TypeKind.LongType, 2), /** Store long into local variable 3 */ - LSTORE_3(Classfile.LSTORE_3, 1, Kind.STORE, TypeKind.LongType, 3), + LSTORE_3(ClassFile.LSTORE_3, 1, Kind.STORE, TypeKind.LongType, 3), /** Store float into local variable 0 */ - FSTORE_0(Classfile.FSTORE_0, 1, Kind.STORE, TypeKind.FloatType, 0), + FSTORE_0(ClassFile.FSTORE_0, 1, Kind.STORE, TypeKind.FloatType, 0), /** Store float into local variable 1 */ - FSTORE_1(Classfile.FSTORE_1, 1, Kind.STORE, TypeKind.FloatType, 1), + FSTORE_1(ClassFile.FSTORE_1, 1, Kind.STORE, TypeKind.FloatType, 1), /** Store float into local variable 2 */ - FSTORE_2(Classfile.FSTORE_2, 1, Kind.STORE, TypeKind.FloatType, 2), + FSTORE_2(ClassFile.FSTORE_2, 1, Kind.STORE, TypeKind.FloatType, 2), /** Store float into local variable 3 */ - FSTORE_3(Classfile.FSTORE_3, 1, Kind.STORE, TypeKind.FloatType, 3), + FSTORE_3(ClassFile.FSTORE_3, 1, Kind.STORE, TypeKind.FloatType, 3), /** Store double into local variable 0 */ - DSTORE_0(Classfile.DSTORE_0, 1, Kind.STORE, TypeKind.DoubleType, 0), + DSTORE_0(ClassFile.DSTORE_0, 1, Kind.STORE, TypeKind.DoubleType, 0), /** Store double into local variable 1 */ - DSTORE_1(Classfile.DSTORE_1, 1, Kind.STORE, TypeKind.DoubleType, 1), + DSTORE_1(ClassFile.DSTORE_1, 1, Kind.STORE, TypeKind.DoubleType, 1), /** Store double into local variable 2 */ - DSTORE_2(Classfile.DSTORE_2, 1, Kind.STORE, TypeKind.DoubleType, 2), + DSTORE_2(ClassFile.DSTORE_2, 1, Kind.STORE, TypeKind.DoubleType, 2), /** Store double into local variable 3 */ - DSTORE_3(Classfile.DSTORE_3, 1, Kind.STORE, TypeKind.DoubleType, 3), + DSTORE_3(ClassFile.DSTORE_3, 1, Kind.STORE, TypeKind.DoubleType, 3), /** Store reference into local variable 0 */ - ASTORE_0(Classfile.ASTORE_0, 1, Kind.STORE, TypeKind.ReferenceType, 0), + ASTORE_0(ClassFile.ASTORE_0, 1, Kind.STORE, TypeKind.ReferenceType, 0), /** Store reference into local variable 1 */ - ASTORE_1(Classfile.ASTORE_1, 1, Kind.STORE, TypeKind.ReferenceType, 1), + ASTORE_1(ClassFile.ASTORE_1, 1, Kind.STORE, TypeKind.ReferenceType, 1), /** Store reference into local variable 2 */ - ASTORE_2(Classfile.ASTORE_2, 1, Kind.STORE, TypeKind.ReferenceType, 2), + ASTORE_2(ClassFile.ASTORE_2, 1, Kind.STORE, TypeKind.ReferenceType, 2), /** Store reference into local variable 3 */ - ASTORE_3(Classfile.ASTORE_3, 1, Kind.STORE, TypeKind.ReferenceType, 3), + ASTORE_3(ClassFile.ASTORE_3, 1, Kind.STORE, TypeKind.ReferenceType, 3), /** Store into int array */ - IASTORE(Classfile.IASTORE, 1, Kind.ARRAY_STORE, TypeKind.IntType), + IASTORE(ClassFile.IASTORE, 1, Kind.ARRAY_STORE, TypeKind.IntType), /** Store into long array */ - LASTORE(Classfile.LASTORE, 1, Kind.ARRAY_STORE, TypeKind.LongType), + LASTORE(ClassFile.LASTORE, 1, Kind.ARRAY_STORE, TypeKind.LongType), /** Store into float array */ - FASTORE(Classfile.FASTORE, 1, Kind.ARRAY_STORE, TypeKind.FloatType), + FASTORE(ClassFile.FASTORE, 1, Kind.ARRAY_STORE, TypeKind.FloatType), /** Store into double array */ - DASTORE(Classfile.DASTORE, 1, Kind.ARRAY_STORE, TypeKind.DoubleType), + DASTORE(ClassFile.DASTORE, 1, Kind.ARRAY_STORE, TypeKind.DoubleType), /** Store into reference array */ - AASTORE(Classfile.AASTORE, 1, Kind.ARRAY_STORE, TypeKind.ReferenceType), + AASTORE(ClassFile.AASTORE, 1, Kind.ARRAY_STORE, TypeKind.ReferenceType), /** Store into byte array */ - BASTORE(Classfile.BASTORE, 1, Kind.ARRAY_STORE, TypeKind.ByteType), + BASTORE(ClassFile.BASTORE, 1, Kind.ARRAY_STORE, TypeKind.ByteType), /** Store into char array */ - CASTORE(Classfile.CASTORE, 1, Kind.ARRAY_STORE, TypeKind.CharType), + CASTORE(ClassFile.CASTORE, 1, Kind.ARRAY_STORE, TypeKind.CharType), /** Store into short array */ - SASTORE(Classfile.SASTORE, 1, Kind.ARRAY_STORE, TypeKind.ShortType), + SASTORE(ClassFile.SASTORE, 1, Kind.ARRAY_STORE, TypeKind.ShortType), /** Pop the top operand stack value */ - POP(Classfile.POP, 1, Kind.STACK), + POP(ClassFile.POP, 1, Kind.STACK), /** Pop the top one or two operand stack values */ - POP2(Classfile.POP2, 1, Kind.STACK), + POP2(ClassFile.POP2, 1, Kind.STACK), /** Duplicate the top operand stack value */ - DUP(Classfile.DUP, 1, Kind.STACK), + DUP(ClassFile.DUP, 1, Kind.STACK), /** Duplicate the top operand stack value and insert two values down */ - DUP_X1(Classfile.DUP_X1, 1, Kind.STACK), + DUP_X1(ClassFile.DUP_X1, 1, Kind.STACK), /** Duplicate the top operand stack value and insert two or three values down */ - DUP_X2(Classfile.DUP_X2, 1, Kind.STACK), + DUP_X2(ClassFile.DUP_X2, 1, Kind.STACK), /** Duplicate the top one or two operand stack values */ - DUP2(Classfile.DUP2, 1, Kind.STACK), + DUP2(ClassFile.DUP2, 1, Kind.STACK), /** Duplicate the top one or two operand stack values and insert two or three values down */ - DUP2_X1(Classfile.DUP2_X1, 1, Kind.STACK), + DUP2_X1(ClassFile.DUP2_X1, 1, Kind.STACK), /** Duplicate the top one or two operand stack values and insert two, three, or four values down */ - DUP2_X2(Classfile.DUP2_X2, 1, Kind.STACK), + DUP2_X2(ClassFile.DUP2_X2, 1, Kind.STACK), /** Swap the top two operand stack values */ - SWAP(Classfile.SWAP, 1, Kind.STACK), + SWAP(ClassFile.SWAP, 1, Kind.STACK), /** Add int */ - IADD(Classfile.IADD, 1, Kind.OPERATOR, TypeKind.IntType), + IADD(ClassFile.IADD, 1, Kind.OPERATOR, TypeKind.IntType), /** Add long */ - LADD(Classfile.LADD, 1, Kind.OPERATOR, TypeKind.LongType), + LADD(ClassFile.LADD, 1, Kind.OPERATOR, TypeKind.LongType), /** Add float */ - FADD(Classfile.FADD, 1, Kind.OPERATOR, TypeKind.FloatType), + FADD(ClassFile.FADD, 1, Kind.OPERATOR, TypeKind.FloatType), /** Add double */ - DADD(Classfile.DADD, 1, Kind.OPERATOR, TypeKind.DoubleType), + DADD(ClassFile.DADD, 1, Kind.OPERATOR, TypeKind.DoubleType), /** Subtract int */ - ISUB(Classfile.ISUB, 1, Kind.OPERATOR, TypeKind.IntType), + ISUB(ClassFile.ISUB, 1, Kind.OPERATOR, TypeKind.IntType), /** Subtract long */ - LSUB(Classfile.LSUB, 1, Kind.OPERATOR, TypeKind.LongType), + LSUB(ClassFile.LSUB, 1, Kind.OPERATOR, TypeKind.LongType), /** Subtract float */ - FSUB(Classfile.FSUB, 1, Kind.OPERATOR, TypeKind.FloatType), + FSUB(ClassFile.FSUB, 1, Kind.OPERATOR, TypeKind.FloatType), /** Subtract double */ - DSUB(Classfile.DSUB, 1, Kind.OPERATOR, TypeKind.DoubleType), + DSUB(ClassFile.DSUB, 1, Kind.OPERATOR, TypeKind.DoubleType), /** Multiply int */ - IMUL(Classfile.IMUL, 1, Kind.OPERATOR, TypeKind.IntType), + IMUL(ClassFile.IMUL, 1, Kind.OPERATOR, TypeKind.IntType), /** Multiply long */ - LMUL(Classfile.LMUL, 1, Kind.OPERATOR, TypeKind.LongType), + LMUL(ClassFile.LMUL, 1, Kind.OPERATOR, TypeKind.LongType), /** Multiply float */ - FMUL(Classfile.FMUL, 1, Kind.OPERATOR, TypeKind.FloatType), + FMUL(ClassFile.FMUL, 1, Kind.OPERATOR, TypeKind.FloatType), /** Multiply double */ - DMUL(Classfile.DMUL, 1, Kind.OPERATOR, TypeKind.DoubleType), + DMUL(ClassFile.DMUL, 1, Kind.OPERATOR, TypeKind.DoubleType), /** Divide int */ - IDIV(Classfile.IDIV, 1, Kind.OPERATOR, TypeKind.IntType), + IDIV(ClassFile.IDIV, 1, Kind.OPERATOR, TypeKind.IntType), /** Divide long */ - LDIV(Classfile.LDIV, 1, Kind.OPERATOR, TypeKind.LongType), + LDIV(ClassFile.LDIV, 1, Kind.OPERATOR, TypeKind.LongType), /** Divide float */ - FDIV(Classfile.FDIV, 1, Kind.OPERATOR, TypeKind.FloatType), + FDIV(ClassFile.FDIV, 1, Kind.OPERATOR, TypeKind.FloatType), /** Divide double */ - DDIV(Classfile.DDIV, 1, Kind.OPERATOR, TypeKind.DoubleType), + DDIV(ClassFile.DDIV, 1, Kind.OPERATOR, TypeKind.DoubleType), /** Remainder int */ - IREM(Classfile.IREM, 1, Kind.OPERATOR, TypeKind.IntType), + IREM(ClassFile.IREM, 1, Kind.OPERATOR, TypeKind.IntType), /** Remainder long */ - LREM(Classfile.LREM, 1, Kind.OPERATOR, TypeKind.LongType), + LREM(ClassFile.LREM, 1, Kind.OPERATOR, TypeKind.LongType), /** Remainder float */ - FREM(Classfile.FREM, 1, Kind.OPERATOR, TypeKind.FloatType), + FREM(ClassFile.FREM, 1, Kind.OPERATOR, TypeKind.FloatType), /** Remainder double */ - DREM(Classfile.DREM, 1, Kind.OPERATOR, TypeKind.DoubleType), + DREM(ClassFile.DREM, 1, Kind.OPERATOR, TypeKind.DoubleType), /** Negate int */ - INEG(Classfile.INEG, 1, Kind.OPERATOR, TypeKind.IntType), + INEG(ClassFile.INEG, 1, Kind.OPERATOR, TypeKind.IntType), /** Negate long */ - LNEG(Classfile.LNEG, 1, Kind.OPERATOR, TypeKind.LongType), + LNEG(ClassFile.LNEG, 1, Kind.OPERATOR, TypeKind.LongType), /** Negate float */ - FNEG(Classfile.FNEG, 1, Kind.OPERATOR, TypeKind.FloatType), + FNEG(ClassFile.FNEG, 1, Kind.OPERATOR, TypeKind.FloatType), /** Negate double */ - DNEG(Classfile.DNEG, 1, Kind.OPERATOR, TypeKind.DoubleType), + DNEG(ClassFile.DNEG, 1, Kind.OPERATOR, TypeKind.DoubleType), /** Shift left int */ - ISHL(Classfile.ISHL, 1, Kind.OPERATOR, TypeKind.IntType), + ISHL(ClassFile.ISHL, 1, Kind.OPERATOR, TypeKind.IntType), /** Shift left long */ - LSHL(Classfile.LSHL, 1, Kind.OPERATOR, TypeKind.LongType), + LSHL(ClassFile.LSHL, 1, Kind.OPERATOR, TypeKind.LongType), /** Shift right int */ - ISHR(Classfile.ISHR, 1, Kind.OPERATOR, TypeKind.IntType), + ISHR(ClassFile.ISHR, 1, Kind.OPERATOR, TypeKind.IntType), /** Shift right long */ - LSHR(Classfile.LSHR, 1, Kind.OPERATOR, TypeKind.LongType), + LSHR(ClassFile.LSHR, 1, Kind.OPERATOR, TypeKind.LongType), /** Logical shift right int */ - IUSHR(Classfile.IUSHR, 1, Kind.OPERATOR, TypeKind.IntType), + IUSHR(ClassFile.IUSHR, 1, Kind.OPERATOR, TypeKind.IntType), /** Logical shift right long */ - LUSHR(Classfile.LUSHR, 1, Kind.OPERATOR, TypeKind.LongType), + LUSHR(ClassFile.LUSHR, 1, Kind.OPERATOR, TypeKind.LongType), /** Boolean AND int */ - IAND(Classfile.IAND, 1, Kind.OPERATOR, TypeKind.IntType), + IAND(ClassFile.IAND, 1, Kind.OPERATOR, TypeKind.IntType), /** Boolean AND long */ - LAND(Classfile.LAND, 1, Kind.OPERATOR, TypeKind.LongType), + LAND(ClassFile.LAND, 1, Kind.OPERATOR, TypeKind.LongType), /** Boolean OR int */ - IOR(Classfile.IOR, 1, Kind.OPERATOR, TypeKind.IntType), + IOR(ClassFile.IOR, 1, Kind.OPERATOR, TypeKind.IntType), /** Boolean OR long */ - LOR(Classfile.LOR, 1, Kind.OPERATOR, TypeKind.LongType), + LOR(ClassFile.LOR, 1, Kind.OPERATOR, TypeKind.LongType), /** Boolean XOR int */ - IXOR(Classfile.IXOR, 1, Kind.OPERATOR, TypeKind.IntType), + IXOR(ClassFile.IXOR, 1, Kind.OPERATOR, TypeKind.IntType), /** Boolean XOR long */ - LXOR(Classfile.LXOR, 1, Kind.OPERATOR, TypeKind.LongType), + LXOR(ClassFile.LXOR, 1, Kind.OPERATOR, TypeKind.LongType), /** Increment local variable by constant */ - IINC(Classfile.IINC, 3, Kind.INCREMENT, TypeKind.IntType, -1), + IINC(ClassFile.IINC, 3, Kind.INCREMENT, TypeKind.IntType, -1), /** Convert int to long */ - I2L(Classfile.I2L, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.LongType), + I2L(ClassFile.I2L, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.LongType), /** Convert int to float */ - I2F(Classfile.I2F, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.FloatType), + I2F(ClassFile.I2F, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.FloatType), /** Convert int to double */ - I2D(Classfile.I2D, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.DoubleType), + I2D(ClassFile.I2D, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.DoubleType), /** Convert long to int */ - L2I(Classfile.L2I, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.IntType), + L2I(ClassFile.L2I, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.IntType), /** Convert long to float */ - L2F(Classfile.L2F, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.FloatType), + L2F(ClassFile.L2F, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.FloatType), /** Convert long to double */ - L2D(Classfile.L2D, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.DoubleType), + L2D(ClassFile.L2D, 1, Kind.CONVERT, TypeKind.LongType, TypeKind.DoubleType), /** Convert float to int */ - F2I(Classfile.F2I, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.IntType), + F2I(ClassFile.F2I, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.IntType), /** Convert float to long */ - F2L(Classfile.F2L, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.LongType), + F2L(ClassFile.F2L, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.LongType), /** Convert float to double */ - F2D(Classfile.F2D, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.DoubleType), + F2D(ClassFile.F2D, 1, Kind.CONVERT, TypeKind.FloatType, TypeKind.DoubleType), /** Convert double to int */ - D2I(Classfile.D2I, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.IntType), + D2I(ClassFile.D2I, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.IntType), /** Convert double to long */ - D2L(Classfile.D2L, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.LongType), + D2L(ClassFile.D2L, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.LongType), /** Convert double to float */ - D2F(Classfile.D2F, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.FloatType), + D2F(ClassFile.D2F, 1, Kind.CONVERT, TypeKind.DoubleType, TypeKind.FloatType), /** Convert int to byte */ - I2B(Classfile.I2B, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.ByteType), + I2B(ClassFile.I2B, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.ByteType), /** Convert int to char */ - I2C(Classfile.I2C, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.CharType), + I2C(ClassFile.I2C, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.CharType), /** Convert int to short */ - I2S(Classfile.I2S, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.ShortType), + I2S(ClassFile.I2S, 1, Kind.CONVERT, TypeKind.IntType, TypeKind.ShortType), /** Compare long */ - LCMP(Classfile.LCMP, 1, Kind.OPERATOR, TypeKind.LongType), + LCMP(ClassFile.LCMP, 1, Kind.OPERATOR, TypeKind.LongType), /** Compare float */ - FCMPL(Classfile.FCMPL, 1, Kind.OPERATOR, TypeKind.FloatType), + FCMPL(ClassFile.FCMPL, 1, Kind.OPERATOR, TypeKind.FloatType), /** Compare float */ - FCMPG(Classfile.FCMPG, 1, Kind.OPERATOR, TypeKind.FloatType), + FCMPG(ClassFile.FCMPG, 1, Kind.OPERATOR, TypeKind.FloatType), /** Compare double */ - DCMPL(Classfile.DCMPL, 1, Kind.OPERATOR, TypeKind.DoubleType), + DCMPL(ClassFile.DCMPL, 1, Kind.OPERATOR, TypeKind.DoubleType), /** Compare double */ - DCMPG(Classfile.DCMPG, 1, Kind.OPERATOR, TypeKind.DoubleType), + DCMPG(ClassFile.DCMPG, 1, Kind.OPERATOR, TypeKind.DoubleType), /** Branch if int comparison with zero succeeds */ - IFEQ(Classfile.IFEQ, 3, Kind.BRANCH, TypeKind.IntType), + IFEQ(ClassFile.IFEQ, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison with zero succeeds */ - IFNE(Classfile.IFNE, 3, Kind.BRANCH, TypeKind.IntType), + IFNE(ClassFile.IFNE, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison with zero succeeds */ - IFLT(Classfile.IFLT, 3, Kind.BRANCH, TypeKind.IntType), + IFLT(ClassFile.IFLT, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison with zero succeeds */ - IFGE(Classfile.IFGE, 3, Kind.BRANCH, TypeKind.IntType), + IFGE(ClassFile.IFGE, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison with zero succeeds */ - IFGT(Classfile.IFGT, 3, Kind.BRANCH, TypeKind.IntType), + IFGT(ClassFile.IFGT, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison with zero succeeds */ - IFLE(Classfile.IFLE, 3, Kind.BRANCH, TypeKind.IntType), + IFLE(ClassFile.IFLE, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison succeeds */ - IF_ICMPEQ(Classfile.IF_ICMPEQ, 3, Kind.BRANCH, TypeKind.IntType), + IF_ICMPEQ(ClassFile.IF_ICMPEQ, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison succeeds */ - IF_ICMPNE(Classfile.IF_ICMPNE, 3, Kind.BRANCH, TypeKind.IntType), + IF_ICMPNE(ClassFile.IF_ICMPNE, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison succeeds */ - IF_ICMPLT(Classfile.IF_ICMPLT, 3, Kind.BRANCH, TypeKind.IntType), + IF_ICMPLT(ClassFile.IF_ICMPLT, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison succeeds */ - IF_ICMPGE(Classfile.IF_ICMPGE, 3, Kind.BRANCH, TypeKind.IntType), + IF_ICMPGE(ClassFile.IF_ICMPGE, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison succeeds */ - IF_ICMPGT(Classfile.IF_ICMPGT, 3, Kind.BRANCH, TypeKind.IntType), + IF_ICMPGT(ClassFile.IF_ICMPGT, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if int comparison succeeds */ - IF_ICMPLE(Classfile.IF_ICMPLE, 3, Kind.BRANCH, TypeKind.IntType), + IF_ICMPLE(ClassFile.IF_ICMPLE, 3, Kind.BRANCH, TypeKind.IntType), /** Branch if reference comparison succeeds */ - IF_ACMPEQ(Classfile.IF_ACMPEQ, 3, Kind.BRANCH, TypeKind.ReferenceType), + IF_ACMPEQ(ClassFile.IF_ACMPEQ, 3, Kind.BRANCH, TypeKind.ReferenceType), /** Branch if reference comparison succeeds */ - IF_ACMPNE(Classfile.IF_ACMPNE, 3, Kind.BRANCH, TypeKind.ReferenceType), + IF_ACMPNE(ClassFile.IF_ACMPNE, 3, Kind.BRANCH, TypeKind.ReferenceType), /** Branch always */ - GOTO(Classfile.GOTO, 3, Kind.BRANCH, TypeKind.VoidType), + GOTO(ClassFile.GOTO, 3, Kind.BRANCH, TypeKind.VoidType), - /** Jump subroutine */ - JSR(Classfile.JSR, 3, Kind.DISCONTINUED_JSR), + /** + * Jump subroutine is discontinued opcode + * @see java.lang.classfile.instruction.DiscontinuedInstruction + */ + JSR(ClassFile.JSR, 3, Kind.DISCONTINUED_JSR), - /** Return from subroutine */ - RET(Classfile.RET, 2, Kind.DISCONTINUED_RET), + /** + * Return from subroutine is discontinued opcode + * @see java.lang.classfile.instruction.DiscontinuedInstruction + */ + RET(ClassFile.RET, 2, Kind.DISCONTINUED_RET), /** Access jump table by index and jump */ - TABLESWITCH(Classfile.TABLESWITCH, -1, Kind.TABLE_SWITCH), + TABLESWITCH(ClassFile.TABLESWITCH, -1, Kind.TABLE_SWITCH), /** Access jump table by key match and jump */ - LOOKUPSWITCH(Classfile.LOOKUPSWITCH, -1, Kind.LOOKUP_SWITCH), + LOOKUPSWITCH(ClassFile.LOOKUPSWITCH, -1, Kind.LOOKUP_SWITCH), /** Return int from method */ - IRETURN(Classfile.IRETURN, 1, Kind.RETURN, TypeKind.IntType), + IRETURN(ClassFile.IRETURN, 1, Kind.RETURN, TypeKind.IntType), /** Return long from method */ - LRETURN(Classfile.LRETURN, 1, Kind.RETURN, TypeKind.LongType), + LRETURN(ClassFile.LRETURN, 1, Kind.RETURN, TypeKind.LongType), /** Return float from method */ - FRETURN(Classfile.FRETURN, 1, Kind.RETURN, TypeKind.FloatType), + FRETURN(ClassFile.FRETURN, 1, Kind.RETURN, TypeKind.FloatType), /** Return double from method */ - DRETURN(Classfile.DRETURN, 1, Kind.RETURN, TypeKind.DoubleType), + DRETURN(ClassFile.DRETURN, 1, Kind.RETURN, TypeKind.DoubleType), /** Return reference from method */ - ARETURN(Classfile.ARETURN, 1, Kind.RETURN, TypeKind.ReferenceType), + ARETURN(ClassFile.ARETURN, 1, Kind.RETURN, TypeKind.ReferenceType), /** Return void from method */ - RETURN(Classfile.RETURN, 1, Kind.RETURN, TypeKind.VoidType), + RETURN(ClassFile.RETURN, 1, Kind.RETURN, TypeKind.VoidType), /** Get static field from class */ - GETSTATIC(Classfile.GETSTATIC, 3, Kind.FIELD_ACCESS), + GETSTATIC(ClassFile.GETSTATIC, 3, Kind.FIELD_ACCESS), /** Set static field in class */ - PUTSTATIC(Classfile.PUTSTATIC, 3, Kind.FIELD_ACCESS), + PUTSTATIC(ClassFile.PUTSTATIC, 3, Kind.FIELD_ACCESS), /** Fetch field from object */ - GETFIELD(Classfile.GETFIELD, 3, Kind.FIELD_ACCESS), + GETFIELD(ClassFile.GETFIELD, 3, Kind.FIELD_ACCESS), /** Set field in object */ - PUTFIELD(Classfile.PUTFIELD, 3, Kind.FIELD_ACCESS), + PUTFIELD(ClassFile.PUTFIELD, 3, Kind.FIELD_ACCESS), /** Invoke instance method; dispatch based on class */ - INVOKEVIRTUAL(Classfile.INVOKEVIRTUAL, 3, Kind.INVOKE), + INVOKEVIRTUAL(ClassFile.INVOKEVIRTUAL, 3, Kind.INVOKE), /** * Invoke instance method; direct invocation of instance initialization * methods and methods of the current class and its supertypes */ - INVOKESPECIAL(Classfile.INVOKESPECIAL, 3, Kind.INVOKE), + INVOKESPECIAL(ClassFile.INVOKESPECIAL, 3, Kind.INVOKE), /** Invoke a class (static) method */ - INVOKESTATIC(Classfile.INVOKESTATIC, 3, Kind.INVOKE), + INVOKESTATIC(ClassFile.INVOKESTATIC, 3, Kind.INVOKE), /** Invoke interface method */ - INVOKEINTERFACE(Classfile.INVOKEINTERFACE, 5, Kind.INVOKE), + INVOKEINTERFACE(ClassFile.INVOKEINTERFACE, 5, Kind.INVOKE), /** Invoke a dynamically-computed call site */ - INVOKEDYNAMIC(Classfile.INVOKEDYNAMIC, 5, Kind.INVOKE_DYNAMIC), + INVOKEDYNAMIC(ClassFile.INVOKEDYNAMIC, 5, Kind.INVOKE_DYNAMIC), /** Create new object */ - NEW(Classfile.NEW, 3, Kind.NEW_OBJECT), + NEW(ClassFile.NEW, 3, Kind.NEW_OBJECT), /** Create new array */ - NEWARRAY(Classfile.NEWARRAY, 2, Kind.NEW_PRIMITIVE_ARRAY), + NEWARRAY(ClassFile.NEWARRAY, 2, Kind.NEW_PRIMITIVE_ARRAY), /** Create new array of reference */ - ANEWARRAY(Classfile.ANEWARRAY, 3, Kind.NEW_REF_ARRAY), + ANEWARRAY(ClassFile.ANEWARRAY, 3, Kind.NEW_REF_ARRAY), /** Get length of array */ - ARRAYLENGTH(Classfile.ARRAYLENGTH, 1, Kind.OPERATOR, TypeKind.IntType), + ARRAYLENGTH(ClassFile.ARRAYLENGTH, 1, Kind.OPERATOR, TypeKind.IntType), /** Throw exception or error */ - ATHROW(Classfile.ATHROW, 1, Kind.THROW_EXCEPTION), + ATHROW(ClassFile.ATHROW, 1, Kind.THROW_EXCEPTION), /** Check whether object is of given type */ - CHECKCAST(Classfile.CHECKCAST, 3, Kind.TYPE_CHECK), + CHECKCAST(ClassFile.CHECKCAST, 3, Kind.TYPE_CHECK), /** Determine if object is of given type */ - INSTANCEOF(Classfile.INSTANCEOF, 3, Kind.TYPE_CHECK), + INSTANCEOF(ClassFile.INSTANCEOF, 3, Kind.TYPE_CHECK), /** Enter monitor for object */ - MONITORENTER(Classfile.MONITORENTER, 1, Kind.MONITOR), + MONITORENTER(ClassFile.MONITORENTER, 1, Kind.MONITOR), /** Exit monitor for object */ - MONITOREXIT(Classfile.MONITOREXIT, 1, Kind.MONITOR), + MONITOREXIT(ClassFile.MONITOREXIT, 1, Kind.MONITOR), /** Create new multidimensional array */ - MULTIANEWARRAY(Classfile.MULTIANEWARRAY, 4, Kind.NEW_MULTI_ARRAY), + MULTIANEWARRAY(ClassFile.MULTIANEWARRAY, 4, Kind.NEW_MULTI_ARRAY), /** Branch if reference is null */ - IFNULL(Classfile.IFNULL, 3, Kind.BRANCH, TypeKind.ReferenceType), + IFNULL(ClassFile.IFNULL, 3, Kind.BRANCH, TypeKind.ReferenceType), /** Branch if reference not null */ - IFNONNULL(Classfile.IFNONNULL, 3, Kind.BRANCH, TypeKind.IntType), + IFNONNULL(ClassFile.IFNONNULL, 3, Kind.BRANCH, TypeKind.IntType), /** Branch always (wide index) */ - GOTO_W(Classfile.GOTO_W, 5, Kind.BRANCH, TypeKind.VoidType), + GOTO_W(ClassFile.GOTO_W, 5, Kind.BRANCH, TypeKind.VoidType), - /** Jump subroutine (wide index) */ - JSR_W(Classfile.JSR_W, 5, Kind.DISCONTINUED_JSR), + /** + * Jump subroutine (wide index) is discontinued opcode + * @see java.lang.classfile.instruction.DiscontinuedInstruction + */ + JSR_W(ClassFile.JSR_W, 5, Kind.DISCONTINUED_JSR), /** Load int from local variable (wide index) */ - ILOAD_W((Classfile.WIDE << 8) | Classfile.ILOAD, 4, Kind.LOAD, TypeKind.IntType, -1), + ILOAD_W((ClassFile.WIDE << 8) | ClassFile.ILOAD, 4, Kind.LOAD, TypeKind.IntType, -1), /** Load long from local variable (wide index) */ - LLOAD_W((Classfile.WIDE << 8) | Classfile.LLOAD, 4, Kind.LOAD, TypeKind.LongType, -1), + LLOAD_W((ClassFile.WIDE << 8) | ClassFile.LLOAD, 4, Kind.LOAD, TypeKind.LongType, -1), /** Load float from local variable (wide index) */ - FLOAD_W((Classfile.WIDE << 8) | Classfile.FLOAD, 4, Kind.LOAD, TypeKind.FloatType, -1), + FLOAD_W((ClassFile.WIDE << 8) | ClassFile.FLOAD, 4, Kind.LOAD, TypeKind.FloatType, -1), /** Load double from local variable (wide index) */ - DLOAD_W((Classfile.WIDE << 8) | Classfile.DLOAD, 4, Kind.LOAD, TypeKind.DoubleType, -1), + DLOAD_W((ClassFile.WIDE << 8) | ClassFile.DLOAD, 4, Kind.LOAD, TypeKind.DoubleType, -1), /** Load reference from local variable (wide index) */ - ALOAD_W((Classfile.WIDE << 8) | Classfile.ALOAD, 4, Kind.LOAD, TypeKind.ReferenceType, -1), + ALOAD_W((ClassFile.WIDE << 8) | ClassFile.ALOAD, 4, Kind.LOAD, TypeKind.ReferenceType, -1), /** Store int into local variable (wide index) */ - ISTORE_W((Classfile.WIDE << 8) | Classfile.ISTORE, 4, Kind.STORE, TypeKind.IntType, -1), + ISTORE_W((ClassFile.WIDE << 8) | ClassFile.ISTORE, 4, Kind.STORE, TypeKind.IntType, -1), /** Store long into local variable (wide index) */ - LSTORE_W((Classfile.WIDE << 8) | Classfile.LSTORE, 4, Kind.STORE, TypeKind.LongType, -1), + LSTORE_W((ClassFile.WIDE << 8) | ClassFile.LSTORE, 4, Kind.STORE, TypeKind.LongType, -1), /** Store float into local variable (wide index) */ - FSTORE_W((Classfile.WIDE << 8) | Classfile.FSTORE, 4, Kind.STORE, TypeKind.FloatType, -1), + FSTORE_W((ClassFile.WIDE << 8) | ClassFile.FSTORE, 4, Kind.STORE, TypeKind.FloatType, -1), /** Store double into local variable (wide index) */ - DSTORE_W((Classfile.WIDE << 8) | Classfile.DSTORE, 4, Kind.STORE, TypeKind.DoubleType, -1), + DSTORE_W((ClassFile.WIDE << 8) | ClassFile.DSTORE, 4, Kind.STORE, TypeKind.DoubleType, -1), /** Store reference into local variable (wide index) */ - ASTORE_W((Classfile.WIDE << 8) | Classfile.ASTORE, 4, Kind.STORE, TypeKind.ReferenceType, -1), + ASTORE_W((ClassFile.WIDE << 8) | ClassFile.ASTORE, 4, Kind.STORE, TypeKind.ReferenceType, -1), - /** Return from subroutine (wide index) */ - RET_W((Classfile.WIDE << 8) | Classfile.RET, 4, Kind.DISCONTINUED_RET), + /** + * Return from subroutine (wide index) is discontinued opcode + * @see java.lang.classfile.instruction.DiscontinuedInstruction + */ + RET_W((ClassFile.WIDE << 8) | ClassFile.RET, 4, Kind.DISCONTINUED_RET), /** Increment local variable by constant (wide index) */ - IINC_W((Classfile.WIDE << 8) | Classfile.IINC, 6, Kind.INCREMENT, TypeKind.IntType, -1); + IINC_W((ClassFile.WIDE << 8) | ClassFile.IINC, 6, Kind.INCREMENT, TypeKind.IntType, -1); /** * Kinds of opcodes. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public static enum Kind { /** @@ -1042,6 +1061,7 @@ public enum Opcode { * * @see Opcode#JSR * @see Opcode#JSR_W + * @see java.lang.classfile.instruction.DiscontinuedInstruction */ DISCONTINUED_JSR, @@ -1050,6 +1070,7 @@ public enum Opcode { * * @see Opcode#RET * @see Opcode#RET_W + * @see java.lang.classfile.instruction.DiscontinuedInstruction */ DISCONTINUED_RET; } diff --git a/src/java.base/share/classes/jdk/internal/classfile/PseudoInstruction.java b/src/java.base/share/classes/java/lang/classfile/PseudoInstruction.java similarity index 76% rename from src/java.base/share/classes/jdk/internal/classfile/PseudoInstruction.java rename to src/java.base/share/classes/java/lang/classfile/PseudoInstruction.java index d419e2314e9..8a2db569ba0 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/PseudoInstruction.java +++ b/src/java.base/share/classes/java/lang/classfile/PseudoInstruction.java @@ -22,16 +22,17 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.attribute.CodeAttribute; -import jdk.internal.classfile.instruction.CharacterRange; -import jdk.internal.classfile.instruction.ExceptionCatch; -import jdk.internal.classfile.instruction.LabelTarget; -import jdk.internal.classfile.instruction.LineNumber; -import jdk.internal.classfile.instruction.LocalVariable; -import jdk.internal.classfile.instruction.LocalVariableType; +import java.lang.classfile.attribute.CodeAttribute; +import java.lang.classfile.instruction.CharacterRange; +import java.lang.classfile.instruction.ExceptionCatch; +import java.lang.classfile.instruction.LabelTarget; +import java.lang.classfile.instruction.LineNumber; +import java.lang.classfile.instruction.LocalVariable; +import java.lang.classfile.instruction.LocalVariableType; import jdk.internal.classfile.impl.AbstractPseudoInstruction; +import jdk.internal.javac.PreviewFeature; /** * Models metadata about a {@link CodeAttribute}, such as entries in the @@ -39,8 +40,11 @@ import jdk.internal.classfile.impl.AbstractPseudoInstruction; * between instructions and labels. Pseudo-instructions are delivered as part * of the element stream of a {@link CodeModel}. Delivery of some * pseudo-instructions can be disabled by modifying the value of classfile - * options (e.g., {@link Classfile.DebugElementsOption}). + * options (e.g., {@link ClassFile.DebugElementsOption}). + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface PseudoInstruction extends CodeElement permits CharacterRange, ExceptionCatch, LabelTarget, LineNumber, LocalVariable, LocalVariableType, AbstractPseudoInstruction { diff --git a/src/java.base/share/classes/jdk/internal/classfile/Signature.java b/src/java.base/share/classes/java/lang/classfile/Signature.java similarity index 91% rename from src/java.base/share/classes/jdk/internal/classfile/Signature.java rename to src/java.base/share/classes/java/lang/classfile/Signature.java index c9c7ae1c705..e5ed92acb83 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Signature.java +++ b/src/java.base/share/classes/java/lang/classfile/Signature.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ClassDesc; import jdk.internal.classfile.impl.SignaturesImpl; @@ -31,10 +31,15 @@ import java.util.List; import static java.util.Objects.requireNonNull; import java.util.Optional; import jdk.internal.classfile.impl.Util; +import jdk.internal.javac.PreviewFeature; /** * Models generic Java type signatures, as defined in {@jvms 4.7.9.1}. + * + * @sealedGraph + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface Signature { /** {@return the raw signature string} */ @@ -50,8 +55,8 @@ public sealed interface Signature { } /** + * {@return a Java type signature} * @param classDesc the symbolic description of the Java type - * @return Java type signature */ public static Signature of(ClassDesc classDesc) { requireNonNull(classDesc); @@ -64,7 +69,10 @@ public sealed interface Signature { /** * Models the signature of a primitive type or void + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface BaseTypeSig extends Signature permits SignaturesImpl.BaseTypeSigImpl { @@ -97,7 +105,11 @@ public sealed interface Signature { /** * Models the signature of a reference type, which may be a class, interface, * type variable, or array type. + * + * @sealedGraph + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface RefTypeSig extends Signature permits ArrayTypeSig, ClassTypeSig, TypeVarSig { @@ -105,7 +117,10 @@ public sealed interface Signature { /** * Models the signature of a possibly-parameterized class or interface type. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface ClassTypeSig extends RefTypeSig, ThrowableSig permits SignaturesImpl.ClassTypeSigImpl { @@ -169,14 +184,20 @@ public sealed interface Signature { /** * Models the type argument. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface TypeArg permits SignaturesImpl.TypeArgImpl { /** * Indicator for whether a wildcard has default bound, no bound, * an upper bound, or a lower bound + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public enum WildcardIndicator { /** @@ -252,7 +273,10 @@ public sealed interface Signature { /** * Models the signature of a type variable. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface TypeVarSig extends RefTypeSig, ThrowableSig permits SignaturesImpl.TypeVarSigImpl { @@ -271,7 +295,10 @@ public sealed interface Signature { /** * Models the signature of an array type. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface ArrayTypeSig extends RefTypeSig permits SignaturesImpl.ArrayTypeSigImpl { @@ -304,7 +331,10 @@ public sealed interface Signature { /** * Models a signature for a type parameter of a generic class or method. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface TypeParam permits SignaturesImpl.TypeParamImpl { @@ -346,7 +376,11 @@ public sealed interface Signature { /** * Models a signature for a throwable type. + * + * @sealedGraph + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface ThrowableSig extends Signature { } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/Superclass.java b/src/java.base/share/classes/java/lang/classfile/Superclass.java similarity index 86% rename from src/java.base/share/classes/jdk/internal/classfile/Superclass.java rename to src/java.base/share/classes/java/lang/classfile/Superclass.java index f8ca2359b5c..70b18bb14d0 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/Superclass.java +++ b/src/java.base/share/classes/java/lang/classfile/Superclass.java @@ -22,15 +22,19 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.constantpool.ClassEntry; +import java.lang.classfile.constantpool.ClassEntry; import jdk.internal.classfile.impl.SuperclassImpl; +import jdk.internal.javac.PreviewFeature; /** * Models the superclass of a class. Delivered as a {@link - * jdk.internal.classfile.ClassElement} when traversing a {@link ClassModel}. + * java.lang.classfile.ClassElement} when traversing a {@link ClassModel}. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface Superclass extends ClassElement permits SuperclassImpl { diff --git a/src/java.base/share/classes/jdk/internal/classfile/TypeAnnotation.java b/src/java.base/share/classes/java/lang/classfile/TypeAnnotation.java similarity index 89% rename from src/java.base/share/classes/jdk/internal/classfile/TypeAnnotation.java rename to src/java.base/share/classes/java/lang/classfile/TypeAnnotation.java index 4b9c1f1bbc4..add1872f641 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/TypeAnnotation.java +++ b/src/java.base/share/classes/java/lang/classfile/TypeAnnotation.java @@ -23,54 +23,61 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.constant.ClassDesc; import java.util.List; -import jdk.internal.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; -import jdk.internal.classfile.constantpool.Utf8Entry; +import java.lang.classfile.attribute.RuntimeInvisibleTypeAnnotationsAttribute; +import java.lang.classfile.attribute.RuntimeVisibleTypeAnnotationsAttribute; +import java.lang.classfile.constantpool.Utf8Entry; import jdk.internal.classfile.impl.TargetInfoImpl; import jdk.internal.classfile.impl.UnboundAttribute; -import static jdk.internal.classfile.Classfile.TAT_CAST; -import static jdk.internal.classfile.Classfile.TAT_CLASS_EXTENDS; -import static jdk.internal.classfile.Classfile.TAT_CLASS_TYPE_PARAMETER; -import static jdk.internal.classfile.Classfile.TAT_CLASS_TYPE_PARAMETER_BOUND; -import static jdk.internal.classfile.Classfile.TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT; -import static jdk.internal.classfile.Classfile.TAT_CONSTRUCTOR_REFERENCE; -import static jdk.internal.classfile.Classfile.TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT; -import static jdk.internal.classfile.Classfile.TAT_EXCEPTION_PARAMETER; -import static jdk.internal.classfile.Classfile.TAT_FIELD; -import static jdk.internal.classfile.Classfile.TAT_INSTANCEOF; -import static jdk.internal.classfile.Classfile.TAT_LOCAL_VARIABLE; -import static jdk.internal.classfile.Classfile.TAT_METHOD_FORMAL_PARAMETER; -import static jdk.internal.classfile.Classfile.TAT_METHOD_INVOCATION_TYPE_ARGUMENT; -import static jdk.internal.classfile.Classfile.TAT_METHOD_RECEIVER; -import static jdk.internal.classfile.Classfile.TAT_METHOD_REFERENCE; -import static jdk.internal.classfile.Classfile.TAT_METHOD_REFERENCE_TYPE_ARGUMENT; -import static jdk.internal.classfile.Classfile.TAT_METHOD_RETURN; -import static jdk.internal.classfile.Classfile.TAT_METHOD_TYPE_PARAMETER; -import static jdk.internal.classfile.Classfile.TAT_METHOD_TYPE_PARAMETER_BOUND; -import static jdk.internal.classfile.Classfile.TAT_NEW; -import static jdk.internal.classfile.Classfile.TAT_RESOURCE_VARIABLE; -import static jdk.internal.classfile.Classfile.TAT_THROWS; +import static java.lang.classfile.ClassFile.TAT_CAST; +import static java.lang.classfile.ClassFile.TAT_CLASS_EXTENDS; +import static java.lang.classfile.ClassFile.TAT_CLASS_TYPE_PARAMETER; +import static java.lang.classfile.ClassFile.TAT_CLASS_TYPE_PARAMETER_BOUND; +import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT; +import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_REFERENCE; +import static java.lang.classfile.ClassFile.TAT_CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT; +import static java.lang.classfile.ClassFile.TAT_EXCEPTION_PARAMETER; +import static java.lang.classfile.ClassFile.TAT_FIELD; +import static java.lang.classfile.ClassFile.TAT_INSTANCEOF; +import static java.lang.classfile.ClassFile.TAT_LOCAL_VARIABLE; +import static java.lang.classfile.ClassFile.TAT_METHOD_FORMAL_PARAMETER; +import static java.lang.classfile.ClassFile.TAT_METHOD_INVOCATION_TYPE_ARGUMENT; +import static java.lang.classfile.ClassFile.TAT_METHOD_RECEIVER; +import static java.lang.classfile.ClassFile.TAT_METHOD_REFERENCE; +import static java.lang.classfile.ClassFile.TAT_METHOD_REFERENCE_TYPE_ARGUMENT; +import static java.lang.classfile.ClassFile.TAT_METHOD_RETURN; +import static java.lang.classfile.ClassFile.TAT_METHOD_TYPE_PARAMETER; +import static java.lang.classfile.ClassFile.TAT_METHOD_TYPE_PARAMETER_BOUND; +import static java.lang.classfile.ClassFile.TAT_NEW; +import static java.lang.classfile.ClassFile.TAT_RESOURCE_VARIABLE; +import static java.lang.classfile.ClassFile.TAT_THROWS; import jdk.internal.classfile.impl.TemporaryConstantPool; +import jdk.internal.javac.PreviewFeature; /** * Models an annotation on a type use, as defined in {@jvms 4.7.19} and {@jvms 4.7.20}. * * @see RuntimeVisibleTypeAnnotationsAttribute * @see RuntimeInvisibleTypeAnnotationsAttribute + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface TypeAnnotation extends Annotation permits UnboundAttribute.UnboundTypeAnnotation { /** * The kind of target on which the annotation appears, as defined in {@jvms 4.7.20.1}. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public enum TargetType { /** For annotations on a class type parameter declaration. */ CLASS_TYPE_PARAMETER(TAT_CLASS_TYPE_PARAMETER, 1), @@ -228,7 +235,11 @@ public sealed interface TypeAnnotation /** * Specifies which type in a declaration or expression is being annotated. + * + * @sealedGraph + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface TargetInfo { /** @@ -392,9 +403,9 @@ public sealed interface TypeAnnotation /** * {@return a target for annotations on the type in an instanceof expression or a new expression, * or the type before the :: in a method reference expression} - * {@param targetType {@link TargetType#INSTANCEOF}, {@link TargetType#NEW}, - * {@link TargetType#CONSTRUCTOR_REFERENCE}, - * or {@link TargetType#METHOD_REFERENCE}} + * @param targetType {@link TargetType#INSTANCEOF}, {@link TargetType#NEW}, + * {@link TargetType#CONSTRUCTOR_REFERENCE}, + * or {@link TargetType#METHOD_REFERENCE} * @param target the code label corresponding to the instruction */ static OffsetTarget ofOffset(TargetType targetType, Label target) { @@ -438,10 +449,10 @@ public sealed interface TypeAnnotation * or on the i'th type argument in the explicit type argument list for any of the following: * a new expression, an explicit constructor invocation statement, a method invocation expression, * or a method reference expression} - * {@param targetType {@link TargetType#CAST}, {@link TargetType#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, - * {@link TargetType#METHOD_INVOCATION_TYPE_ARGUMENT}, - * {@link TargetType#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, - * or {@link TargetType#METHOD_REFERENCE_TYPE_ARGUMENT}} + * @param targetType {@link TargetType#CAST}, {@link TargetType#CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT}, + * {@link TargetType#METHOD_INVOCATION_TYPE_ARGUMENT}, + * {@link TargetType#CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT}, + * or {@link TargetType#METHOD_REFERENCE_TYPE_ARGUMENT} * @param target the code label corresponding to the instruction * @param typeArgumentIndex specifies which type in the cast operator or argument is annotated */ @@ -503,7 +514,10 @@ public sealed interface TypeAnnotation * Indicates that an annotation appears on the declaration of the i'th type * parameter of a generic class, generic interface, generic method, or * generic constructor. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface TypeParameterTarget extends TargetInfo permits TargetInfoImpl.TypeParameterTargetImpl { @@ -519,7 +533,10 @@ public sealed interface TypeAnnotation /** * Indicates that an annotation appears on a type in the extends or implements * clause of a class or interface declaration. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface SupertypeTarget extends TargetInfo permits TargetInfoImpl.SupertypeTargetImpl { @@ -540,7 +557,10 @@ public sealed interface TypeAnnotation * Indicates that an annotation appears on the i'th bound of the j'th * type parameter declaration of a generic class, interface, method, or * constructor. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface TypeParameterBoundTarget extends TargetInfo permits TargetInfoImpl.TypeParameterBoundTargetImpl { @@ -563,7 +583,10 @@ public sealed interface TypeAnnotation * Indicates that an annotation appears on either the type in a field * declaration, the return type of a method, the type of a newly constructed * object, or the receiver type of a method or constructor. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface EmptyTarget extends TargetInfo permits TargetInfoImpl.EmptyTargetImpl { } @@ -571,7 +594,10 @@ public sealed interface TypeAnnotation /** * Indicates that an annotation appears on the type in a formal parameter * declaration of a method, constructor, or lambda expression. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface FormalParameterTarget extends TargetInfo permits TargetInfoImpl.FormalParameterTargetImpl { @@ -587,7 +613,10 @@ public sealed interface TypeAnnotation /** * Indicates that an annotation appears on the i'th type in the throws * clause of a method or constructor declaration. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface ThrowsTarget extends TargetInfo permits TargetInfoImpl.ThrowsTargetImpl { @@ -596,7 +625,7 @@ public sealed interface TypeAnnotation * Exceptions attribute of the method_info structure enclosing the * RuntimeVisibleTypeAnnotations attribute. * - * @return the index into the list jdk.internal.classfile.attribute.ExceptionsAttribute.exceptions() + * @return the index into the list java.lang.classfile.attribute.ExceptionsAttribute.exceptions() */ int throwsTargetIndex(); } @@ -604,12 +633,15 @@ public sealed interface TypeAnnotation /** * Indicates that an annotation appears on the type in a local variable declaration, * including a variable declared as a resource in a try-with-resources statement. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface LocalVarTarget extends TargetInfo permits TargetInfoImpl.LocalVarTargetImpl { /** - * @return the table of local variable location/indices. + * {@return the table of local variable location/indices.} */ List table(); } @@ -618,7 +650,10 @@ public sealed interface TypeAnnotation * Indicates a range of code array offsets within which a local variable * has a value, and the index into the local variable array of the current * frame at which that local variable can be found. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface LocalVarTargetInfo permits TargetInfoImpl.LocalVarTargetInfoImpl { @@ -662,7 +697,10 @@ public sealed interface TypeAnnotation /** * Indicates that an annotation appears on the i'th type in an exception parameter * declaration. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface CatchTarget extends TargetInfo permits TargetInfoImpl.CatchTargetImpl { @@ -678,7 +716,10 @@ public sealed interface TypeAnnotation /** * Indicates that an annotation appears on either the type in an instanceof expression * or a new expression, or the type before the :: in a method reference expression. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface OffsetTarget extends TargetInfo permits TargetInfoImpl.OffsetTargetImpl { @@ -697,7 +738,10 @@ public sealed interface TypeAnnotation * expression, or on the i'th type argument in the explicit type argument list for any of the following: a new * expression, an explicit constructor invocation statement, a method invocation expression, or a method reference * expression. + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface TypeArgumentTarget extends TargetInfo permits TargetInfoImpl.TypeArgumentTargetImpl { @@ -730,13 +774,19 @@ public sealed interface TypeAnnotation /** * JVMS: Type_path structure identifies which part of the type is annotated, * as defined in {@jvms 4.7.20.2} + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) sealed interface TypePathComponent permits UnboundAttribute.TypePathComponentImpl { /** * Type path kind, as defined in {@jvms 4.7.20.2} + * + * @since 22 */ + @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public enum Kind { /** Annotation is deeper in an array type */ diff --git a/src/java.base/share/classes/jdk/internal/classfile/TypeKind.java b/src/java.base/share/classes/java/lang/classfile/TypeKind.java similarity index 97% rename from src/java.base/share/classes/jdk/internal/classfile/TypeKind.java rename to src/java.base/share/classes/java/lang/classfile/TypeKind.java index cc61c840dac..bf2435f43ef 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/TypeKind.java +++ b/src/java.base/share/classes/java/lang/classfile/TypeKind.java @@ -23,13 +23,17 @@ * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; import java.lang.invoke.TypeDescriptor; +import jdk.internal.javac.PreviewFeature; /** * Describes the types that can be part of a field or method descriptor. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public enum TypeKind { /** the primitive type byte */ ByteType("byte", "B", 8), diff --git a/src/java.base/share/classes/jdk/internal/classfile/WritableElement.java b/src/java.base/share/classes/java/lang/classfile/WritableElement.java similarity index 84% rename from src/java.base/share/classes/jdk/internal/classfile/WritableElement.java rename to src/java.base/share/classes/java/lang/classfile/WritableElement.java index 8e75f996acc..9a4db4e370f 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/WritableElement.java +++ b/src/java.base/share/classes/java/lang/classfile/WritableElement.java @@ -22,20 +22,25 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile; +package java.lang.classfile; -import jdk.internal.classfile.constantpool.ConstantPoolBuilder; -import jdk.internal.classfile.constantpool.PoolEntry; +import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.classfile.constantpool.PoolEntry; import jdk.internal.classfile.impl.DirectFieldBuilder; import jdk.internal.classfile.impl.DirectMethodBuilder; +import jdk.internal.javac.PreviewFeature; /** * A classfile element that can encode itself as a stream of bytes in the * encoding expected by the classfile format. * * @param the type of the entity + * + * @sealedGraph + * @since 22 */ -public sealed interface WritableElement extends ClassfileElement +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) +public sealed interface WritableElement extends ClassFileElement permits Annotation, AnnotationElement, AnnotationValue, Attribute, PoolEntry, BootstrapMethodEntry, FieldModel, MethodModel, ConstantPoolBuilder, DirectFieldBuilder, DirectMethodBuilder { diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/AnnotationDefaultAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/AnnotationDefaultAttribute.java similarity index 86% rename from src/java.base/share/classes/jdk/internal/classfile/attribute/AnnotationDefaultAttribute.java rename to src/java.base/share/classes/java/lang/classfile/attribute/AnnotationDefaultAttribute.java index 3a0842cc5f6..16149ff66c5 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/AnnotationDefaultAttribute.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/AnnotationDefaultAttribute.java @@ -23,14 +23,15 @@ * questions. */ -package jdk.internal.classfile.attribute; +package java.lang.classfile.attribute; -import jdk.internal.classfile.AnnotationValue; -import jdk.internal.classfile.Attribute; -import jdk.internal.classfile.MethodElement; -import jdk.internal.classfile.MethodModel; +import java.lang.classfile.AnnotationValue; +import java.lang.classfile.Attribute; +import java.lang.classfile.MethodElement; +import java.lang.classfile.MethodModel; import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.UnboundAttribute; +import jdk.internal.javac.PreviewFeature; /** * Models the {@code AnnotationDefault} attribute {@jvms 4.7.22}, which can @@ -41,7 +42,12 @@ import jdk.internal.classfile.impl.UnboundAttribute; * The attribute does not permit multiple instances in a given location. * Subsequent occurrence of the attribute takes precedence during the attributed * element build or transformation. + *

+ * The attribute was introduced in the Java SE Platform version 5.0. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface AnnotationDefaultAttribute extends Attribute, MethodElement permits BoundAttribute.BoundAnnotationDefaultAttr, diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/BootstrapMethodsAttribute.java b/src/java.base/share/classes/java/lang/classfile/attribute/BootstrapMethodsAttribute.java similarity index 86% rename from src/java.base/share/classes/jdk/internal/classfile/attribute/BootstrapMethodsAttribute.java rename to src/java.base/share/classes/java/lang/classfile/attribute/BootstrapMethodsAttribute.java index 638043f0e09..436a7f80b1c 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/BootstrapMethodsAttribute.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/BootstrapMethodsAttribute.java @@ -23,15 +23,16 @@ * questions. */ -package jdk.internal.classfile.attribute; +package java.lang.classfile.attribute; import java.util.List; -import jdk.internal.classfile.Attribute; -import jdk.internal.classfile.BootstrapMethodEntry; -import jdk.internal.classfile.constantpool.ConstantPool; +import java.lang.classfile.Attribute; +import java.lang.classfile.BootstrapMethodEntry; +import java.lang.classfile.constantpool.ConstantPool; import jdk.internal.classfile.impl.BoundAttribute; import jdk.internal.classfile.impl.UnboundAttribute; +import jdk.internal.javac.PreviewFeature; /** * Models the {@code BootstrapMethods} attribute {@jvms 4.7.23}, which serves as @@ -41,7 +42,12 @@ import jdk.internal.classfile.impl.UnboundAttribute; * The attribute does not permit multiple instances in a given location. * Subsequent occurrence of the attribute takes precedence during the attributed * element build or transformation. + *

+ * The attribute was introduced in the Java SE Platform version 7. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface BootstrapMethodsAttribute extends Attribute permits BoundAttribute.BoundBootstrapMethodsAttribute, diff --git a/src/java.base/share/classes/jdk/internal/classfile/attribute/CharacterRangeInfo.java b/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeInfo.java similarity index 88% rename from src/java.base/share/classes/jdk/internal/classfile/attribute/CharacterRangeInfo.java rename to src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeInfo.java index cf995ef6fea..37abcb02713 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/attribute/CharacterRangeInfo.java +++ b/src/java.base/share/classes/java/lang/classfile/attribute/CharacterRangeInfo.java @@ -22,13 +22,17 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package jdk.internal.classfile.attribute; +package java.lang.classfile.attribute; import jdk.internal.classfile.impl.UnboundAttribute; +import jdk.internal.javac.PreviewFeature; /** * Models a single character range in the {@link CharacterRangeTableAttribute}. + * + * @since 22 */ +@PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) public sealed interface CharacterRangeInfo permits UnboundAttribute.UnboundCharacterRangeInfo { @@ -66,17 +70,17 @@ public sealed interface CharacterRangeInfo * The value of the flags item describes the kind of range. Multiple flags * may be set within flags. *