问题
Is there a anyway to add static code block into java class using javapoet library
static {
// whatever code is needed for initialization goes here
}
回答1:
Use TypeSpec.Builder::addStaticBlock. See test case.
来源:https://stackoverflow.com/questions/34319246/how-to-add-static-section-in-to-java-class-in-javapoet