Class CodeGenerator
java.lang.Object
org.glassfish.pfl.dynamic.codegen.impl.CodeGenerator
Class used to define classes and interfaces, and to generator source or
byte code from the resulting definitions. This is the factory for the
codegen framework.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassGeneratorImpl
defineClass
(int modifiers, String name, Type superType, List<Type> impls) Define a ClassGeneratorImpl for a class.static ClassGeneratorImpl
defineInterface
(int modifiers, String name, List<Type> impls) Define a ClassGeneratorImpl for an interface.static byte[]
generateBytecode
(ClassGeneratorImpl cg, ClassLoader cl, ImportList imports, Properties options, PrintStream debugOutput) Convert the Java class or interface defined by ClassGeneratorImpl into an array of bytecodes.static void
generateSourceCode
(PrintStream ps, ClassGeneratorImpl cg, ImportList imports, Properties options) Write a source code representation of the class or interface defined by cg to the PrintStream ps.static void
generateSourceCode
(String sdir, ClassGeneratorImpl cg, ImportList imports, Properties options) Write a source code representation of the class or interface defined by cg to a file in the SOURCE_GENERATION_DIRECTORY specified in options.
-
Constructor Details
-
CodeGenerator
private CodeGenerator()
-
-
Method Details
-
defineClass
public static ClassGeneratorImpl defineClass(int modifiers, String name, Type superType, List<Type> impls) Define a ClassGeneratorImpl for a class. -
defineInterface
Define a ClassGeneratorImpl for an interface. -
generateBytecode
public static byte[] generateBytecode(ClassGeneratorImpl cg, ClassLoader cl, ImportList imports, Properties options, PrintStream debugOutput) Convert the Java class or interface defined by ClassGeneratorImpl into an array of bytecodes. -
generateSourceCode
public static void generateSourceCode(PrintStream ps, ClassGeneratorImpl cg, ImportList imports, Properties options) throws IOException Write a source code representation of the class or interface defined by cg to the PrintStream ps.- Throws:
IOException
-
generateSourceCode
public static void generateSourceCode(String sdir, ClassGeneratorImpl cg, ImportList imports, Properties options) throws IOException Write a source code representation of the class or interface defined by cg to a file in the SOURCE_GENERATION_DIRECTORY specified in options.- Throws:
IOException
-