Skip to content

Bytecode Generation steps

JonathanxD edited this page May 20, 2017 · 1 revision

Generation steps

After version 4, Bytecode generation was split in a two step processes:

  1. The structure is analyzed and verified, some important data is collected, like all TypeDeclarations including local classes, anonymous classes, etc... and the code is verified in a way that it ensures that generated code will be almost valid, see Verification limitations.

  2. The code is generated from structure using some collected data to improve the generation.

Bridge methods

Bridge methods is very special, CodeAPI-BytecodeWriter tries to generate bridge methods when option is set to true, but this feature is very limited. To CodeAPI-BytecodeWriter infer which methods should be bridged, the super type and implementations should be either TypeDeclaration or a Java Class. The BridgeResolver class also supports custom type resolution, which should resolve to either TypeDeclaration or Java Class.

Anonymous, Local classes and inner classes

The first step is mandatory, because of bytecode limitations, inner classes should be specified at the top of class. In CodeAPI 4, there is no inner class concept, to generate inner classes you should write the logic yourself, I will explain this later.

Clone this wiki locally