How to generate static initialization block with jcodeModel

234 views Asked by At

I need to generate something like this with jcodemodel

package com.example;

    public class Main {

    static int a;

    static {
        a = 5;
    }

    public static void main (String[] args) {

    }

}

Google did not help. There is a class JBlock but there is nothing about initialization blocks.

1

There are 1 answers

0
user1745356 On BEST ANSWER

need to call JDefinedClass.init() which returns JBlock