Class ConstructorUtils

java.lang.Object
org.jboss.weld.util.bytecode.ConstructorUtils

public class ConstructorUtils extends Object
Utility class for working with constructors in the low level javassist API
Author:
Stuart Douglas
  • Method Details

    • addDefaultConstructor

      public static void addDefaultConstructor(org.jboss.classfilewriter.ClassFile file, List<DeferredBytecode> initialValueBytecode, boolean useUnsafeInstantiators)
      adds a constructor that calls super()
    • addConstructor

      public static void addConstructor(String returnType, String[] params, String[] exceptions, org.jboss.classfilewriter.ClassFile file, List<DeferredBytecode> initialValueBytecode, boolean useUnsafeInstantiators)
      Adds a constructor that delegates to a super constructor with the same descriptor. The bytecode in initialValueBytecode will be executed at the start of the constructor and can be used to initialize fields to a default value. As the object is not properly constructed at this point this bytecode may not reference this (i.e. the variable at location 0)
      Parameters:
      returnType - the constructor descriptor
      exceptions - any exceptions that are thrown
      file - the classfile to add the constructor to
      initialValueBytecode - bytecode that can be used to set initial values