Module io.github.sugarcubes.cloner
Class AsmBytecodeBackend
java.lang.Object
io.github.sugarcubes.cloner.bytecode.AsmBytecodeBackend
- All Implemented Interfaces:
BytecodeBackend
Backend on the ASM library; loading this class needs ASM, so its availability is checked without touching this
class. Uses only public members of this package: it may be defined by another class loader, which sees the ASM of
the class being changed.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]addMembers(byte[] bytes, List<FieldSpec> fields, List<MethodSpec> methods) Adds fields and methods to the class file, the rest of it stays as is.booleancanRead(byte[] bytes) Tells whether the engine reads the class file: a newer version than the engine knows cannot be read.read(byte[] bytes) Reads the structure of the class file.byte[]Writes a final synthetic class.
-
Constructor Details
-
AsmBytecodeBackend
public AsmBytecodeBackend()
-
-
Method Details
-
write
public byte[] write(int version, String name, String superName, List<FieldSpec> fields, List<MethodSpec> methods) Description copied from interface:BytecodeBackendWrites a final synthetic class.- Specified by:
writein interfaceBytecodeBackend- Parameters:
version- class file versionname- internal name of the classsuperName- internal name of the super classfields- fieldsmethods- methods- Returns:
- class file
-
canRead
public boolean canRead(byte[] bytes) Description copied from interface:BytecodeBackendTells whether the engine reads the class file: a newer version than the engine knows cannot be read.- Specified by:
canReadin interfaceBytecodeBackend- Parameters:
bytes- class file- Returns:
trueifBytecodeBackend.read(byte[])andBytecodeBackend.addMembers(byte[], List, List)accept it
-
read
Description copied from interface:BytecodeBackendReads the structure of the class file.- Specified by:
readin interfaceBytecodeBackend- Parameters:
bytes- class file- Returns:
- structure
-
addMembers
Description copied from interface:BytecodeBackendAdds fields and methods to the class file, the rest of it stays as is.- Specified by:
addMembersin interfaceBytecodeBackend- Parameters:
bytes- class filefields- fields to addmethods- methods to add, their code does not branch- Returns:
- new class file
-