Interface ClassRemapper
- All Superinterfaces:
ClassFileTransformPREVIEW<ClassTransformPREVIEW,,ClassElementPREVIEW, ClassBuilderPREVIEW> ClassTransformPREVIEW
ClassRemapper is a preview API of the Java platform.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
ClassRemapper is a ClassTransformPREVIEW, FieldTransformPREVIEW,
MethodTransformPREVIEW and CodeTransformPREVIEW
deeply re-mapping all class references in any form, according to given map or
map function.
The re-mapping is applied to superclass, interfaces, all kinds of descriptors and signatures, all attributes referencing classes in any form (including all types of annotations), and to all instructions referencing to classes.
Primitive types and arrays are never subjects of mapping and are not allowed targets of mapping.
Arrays of reference types are always decomposed, mapped as the base reference types and composed back to arrays.
- Since:
- 22
-
Field Summary
Fields declared in interface java.lang.classfile.ClassTransformPREVIEW
ACCEPT_ALL -
Method Summary
Modifier and TypeMethodDescriptionAccess method to internal class mapping function.static ClassRemapperPREVIEWCreates new instance ofClassRemapperinstructed with a map function.static ClassRemapperPREVIEWCreates new instance ofClassRemapperinstructed with a class map.default byte[]remapClass(ClassFilePREVIEW context, ClassModelPREVIEW clm) Remaps the whole ClassModel into a new class file, including the class name.Methods declared in interface java.lang.classfile.ClassFileTransformPREVIEW
accept, atEnd, atStartMethods declared in interface java.lang.classfile.ClassTransformPREVIEW
andThen
-
Method Details
-
of
Creates new instance ofClassRemapperinstructed with a class map. Map may contain only re-mapping entries, identity mapping is applied by default.- Parameters:
classMap- class map- Returns:
- new instance of
ClassRemapper
-
of
Creates new instance ofClassRemapperinstructed with a map function. Map function must return validClassDescof an interface or a class, even for identity mappings.- Parameters:
mapFunction- class map function- Returns:
- new instance of
ClassRemapper
-
map
-
asFieldTransform
FieldTransformPREVIEW asFieldTransform()- Returns:
- this
ClassRemapperasFieldTransformPREVIEW instance
-
asMethodTransform
MethodTransformPREVIEW asMethodTransform()- Returns:
- this
ClassRemapperasMethodTransformPREVIEW instance
-
asCodeTransform
CodeTransformPREVIEW asCodeTransform()- Returns:
- this
ClassRemapperasCodeTransformPREVIEW instance
-
remapClass
Remaps the whole ClassModel into a new class file, including the class name.- Parameters:
context- ClassFile contextclm- class model to re-map- Returns:
- re-mapped class file bytes
-
ClassRemapperwhen preview features are enabled.