protected void buildConstructorWithFields ( ClassVisitor cw , ClassDefinition classDef , Collection < FieldDefinition > fieldDefs ) { Type [ ] params = new Type [ fieldDefs . size ( ) ] ; int index = 0 ; for ( FieldDefinition field : fieldDefs ) { params [ index ++ ] = Type . getType ( BuildUtils . getTypeDescriptor ( field . getTypeName ( ) ) ) ; } MethodVisitor mv = cw . visitMethod ( Opcodes . ACC_PUBLIC , "<init>" , Type . getMethodDescriptor ( Type . VOID_TYPE , params ) , null , null ) ; mv . visitCode ( ) ; Label l0 = null ; if ( this . debug ) { l0 = new Label ( ) ; mv . visitLabel ( l0 ) ; } fieldConstructorStart ( mv , classDef , fieldDefs ) ; mv . visitInsn ( Opcodes . RETURN ) ; Label l1 = null ; if ( this . debug ) { l1 = new Label ( ) ; mv . visitLabel ( l1 ) ; mv . visitLocalVariable ( "this" , BuildUtils . getTypeDescriptor ( classDef . getClassName ( ) ) , null , l0 , l1 , 0 ) ; for ( FieldDefinition field : classDef . getFieldsDefinitions ( ) ) { Label l11 = new Label ( ) ; mv . visitLabel ( l11 ) ; mv . visitLocalVariable ( field . getName ( ) , BuildUtils . getTypeDescriptor ( field . getTypeName ( ) ) , null , l0 , l1 , 0 ) ; } } mv . visitMaxs ( 0 , 0 ) ; mv . visitEnd ( ) ; }
Creates a constructor that takes and assigns values to all fields in the order they are declared .