# Uses of Class
javassist.CannotCompileException

Packages that use CannotCompileException
Package
Description
javassist
The Javassist Core API.
javassist.bytecode
Bytecode-level API.
javassist.expr
This package contains the classes for modifying a method body.
javassist.tools
Covenient tools.
javassist.tools.reflect
Runtime Behavioral Reflection.
javassist.tools.rmi
Sample implementation of remote method invocation.
javassist.tools.web
Simple web server for running sample code.
javassist.util
Utility classes.
javassist.util.proxy
Dynamic proxy (similar to `Enhancer` of cglib).

## Uses of CannotCompileException in javassist

Methods in javassist that throw CannotCompileException
Modifier and Type
Method
Description
`void`
CtBehavior.`addCatch(String src, CtClass exceptionType)`
Adds a catch clause that handles an exception thrown in the body.
`void`
CtBehavior.`addCatch(String src, CtClass exceptionType, String exceptionName)`
Adds a catch clause that handles an exception thrown in the body.
`void`
CtClass.`addConstructor(CtConstructor c)`
Adds a constructor.
`void`
CtClass.`addField(CtField f)`
Adds a field.
`void`
CtClass.`addField(CtField f, String init)`
Adds a field with an initial value.
`void`
CtClass.`addField(CtField f, CtField.Initializer init)`
Adds a field with an initial value.
`void`
CtBehavior.`addLocalVariable(String name, CtClass type)`
Declares a new local variable.
`void`
CtClass.`addMethod(CtMethod m)`
Adds a method.
`void`
CtBehavior.`addParameter(CtClass type)`
Appends a new parameter, which becomes the last parameter.
`void`
Loader.`addTranslator(ClassPool cp, Translator t)`
Adds a translator, which is called whenever a class is loaded.
`static long`
SerialVersionUID.`calculateDefault(CtClass clazz)`
Calculate default value.
`boolean`
CtConstructor.`callsSuper()`
Returns true if this constructor calls a constructor of the super class.
`static CtConstructor`
CtNewConstructor.`copy(CtConstructor c, CtClass declaring, ClassMap map)`
Creates a copy of a constructor.
`static CtMethod`
CtNewMethod.`copy(CtMethod src, String name, CtClass declaring, ClassMap map)`
Creates a copy of a method with a new name.
`static CtMethod`
CtNewMethod.`copy(CtMethod src, CtClass declaring, ClassMap map)`
Creates a copy of a method.
`static CtConstructor`
CtNewConstructor.`defaultConstructor(CtClass declaring)`
Creates a default (public) constructor.
`static CtMethod`
CtNewMethod.`delegator(CtMethod delegate, CtClass declaring)`
Creates a method forwarding to a delegate in a super class.
`static CtMethod`
CtNewMethod.`getter(String methodName, CtField field)`
Creates a public getter method.
`void`
CtBehavior.`insertAfter(String src)`
Inserts bytecode at the end of the body.
`void`
CtBehavior.`insertAfter(String src, boolean asFinally)`
Inserts bytecode at the end of the body.
`void`
CtBehavior.`insertAfter(String src, boolean asFinally, boolean redundant)`
Inserts bytecode at the end of the body.
`void`
CodeConverter.`insertAfterMethod(CtMethod origMethod, CtMethod afterMethod)`
Inserts a call to another method after an existing method call.
`int`
CtBehavior.`insertAt(int lineNum, boolean modify, String src)`
Inserts bytecode at the specified line in the body.
`int`
CtBehavior.`insertAt(int lineNum, String src)`
Inserts bytecode at the specified line in the body.
`void`
CtBehavior.`insertBefore(String src)`
Inserts bytecode at the beginning of the body.
`void`
CtConstructor.`insertBeforeBody(String src)`
Inserts bytecode just after another constructor in the super class or this class is called.
`void`
CodeConverter.`insertBeforeMethod(CtMethod origMethod, CtMethod beforeMethod)`
Insert a call to another method before an existing method call.
`void`
CtBehavior.`insertParameter(CtClass type)`
Inserts a new parameter, which becomes the first parameter.
`void`
CtBehavior.`instrument(CodeConverter converter)`
Modifies the method/constructor body.
`void`
CtBehavior.`instrument(ExprEditor editor)`
Modifies the method/constructor body.
`void`
CtClass.`instrument(CodeConverter converter)`
Applies the given converter to all methods and constructors declared in the class.
`void`
CtClass.`instrument(ExprEditor editor)`
Modifies the bodies of all methods and constructors declared in the class.
`Class<?>`
Loader.Simple.`invokeDefineClass(CtClass cc)`
Invokes the protected `defineClass()` in `ClassLoader`.
`static CtField`
CtField.`make(String src, CtClass declaring)`
Compiles the given source code and creates a field.
`static CtMethod`
CtMethod.`make(String src, CtClass declaring)`
Compiles the given source code and creates a method.
`static CtMethod`
CtMethod.`make(MethodInfo minfo, CtClass declaring)`
Creates a method from a `MethodInfo` object.
`static CtConstructor`
CtNewConstructor.`make(String src, CtClass declaring)`
Compiles the given source code and creates a constructor.
`static CtConstructor`
CtNewConstructor.`make(CtClass[] parameters, CtClass[] exceptions, int howto, CtMethod body, CtMethod.ConstParameter cparam, CtClass declaring)`
Creates a public constructor.
`static CtConstructor`
CtNewConstructor.`make(CtClass[] parameters, CtClass[] exceptions, String body, CtClass declaring)`
Creates a public constructor.
`static CtConstructor`
CtNewConstructor.`make(CtClass[] parameters, CtClass[] exceptions, CtClass declaring)`
Creates a public constructor that only calls a constructor in the super class.
`static CtMethod`
CtNewMethod.`make(int modifiers, CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, String body, CtClass declaring)`
Creates a method.
`static CtMethod`
CtNewMethod.`make(String src, CtClass declaring)`
Compiles the given source code and creates a method.
`static CtMethod`
CtNewMethod.`make(String src, CtClass declaring, String delegateObj, String delegateMethod)`
Compiles the given source code and creates a method.
`static CtMethod`
CtNewMethod.`make(CtClass returnType, String mname, CtClass[] parameters, CtClass[] exceptions, String body, CtClass declaring)`
Creates a public (non-static) method.
`CtConstructor`
CtClass.`makeClassInitializer()`
Makes an empty class initializer (static constructor).
`void`
ClassPool.`makePackage(ClassLoader loader, String name)`
Deprecated.
`void`
Translator.`onLoad(ClassPool pool, String classname)`
Is invoked by a `Loader` for notifying that a class is loaded.
`void`
CodeConverter.`redirectMethodCall(String oldMethodName, CtMethod newMethod)`
Correct invocations to a method that has been renamed.
`void`
CodeConverter.`redirectMethodCall(CtMethod origMethod, CtMethod substMethod)`
Modify method invocations in a method body so that a different method will be invoked.
`void`
CtBehavior.`setBody(String src)`
Sets a method/constructor body.
`void`
CtBehavior.`setBody(String src, String delegateObj, String delegateMethod)`
Sets a method/constructor body.
`void`
CtConstructor.`setBody(String src)`
Sets a constructor body.
`void`
CtConstructor.`setBody(CtConstructor src, ClassMap map)`
Copies a constructor body from another constructor.
`void`
CtMethod.`setBody(CtMethod src, ClassMap map)`
Copies a method body from another method.
`static void`
SerialVersionUID.`setSerialVersionUID(CtClass clazz)`
Adds serialVersionUID if one does not already exist.
`void`
CtClass.`setSuperclass(CtClass clazz)`
Changes a super class unless this object represents an interface.
`static CtMethod`
CtNewMethod.`setter(String methodName, CtField field)`
Creates a public setter method.
`void`
CtMethod.`setWrappedBody(CtMethod mbody, CtMethod.ConstParameter constParam)`
Replace a method body with a new method body wrapping the given method.
`static CtConstructor`
CtNewConstructor.`skeleton(CtClass[] parameters, CtClass[] exceptions, CtClass declaring)`
Creates a public constructor that only calls a constructor in the super class.
`void`
Translator.`start(ClassPool pool)`
Is invoked by a `Loader` for initialization when the object is attached to the `Loader` object.
`byte[]`
CtClass.`toBytecode()`
Converts this class to a class file.
`void`
CtClass.`toBytecode(DataOutputStream out)`
Converts this class to a class file.
`Class`
ClassPool.`toClass(CtClass clazz)`
Converts the given class to a `java.lang.Class` object.
`Class<?>`
ClassPool.`toClass(CtClass ct, Class<?> neighbor)`
Converts the class to a `java.lang.Class` object.
`Class`
ClassPool.`toClass(CtClass ct, Class<?> neighbor, ClassLoader loader, ProtectionDomain domain)`
Converts the class to a `java.lang.Class` object.
`Class`
ClassPool.`toClass(CtClass ct, ClassLoader loader)`
Deprecated.
Replaced by `ClassPool.toClass(CtClass,Class,ClassLoader,ProtectionDomain)`.
`Class`
ClassPool.`toClass(CtClass ct, ClassLoader loader, ProtectionDomain domain)`
Deprecated.
Replaced by `ClassPool.toClass(CtClass,Class,ClassLoader,ProtectionDomain)`.
`Class<?>`
ClassPool.`toClass(CtClass ct, MethodHandles.Lookup lookup)`
Converts the class to a `java.lang.Class` object.
`Class<?>`
CtClass.`toClass()`
Converts this class to a `java.lang.Class` object.
`Class<?>`
CtClass.`toClass(Class<?> neighbor)`
Converts this class to a `java.lang.Class` object.
`final Class<?>`
CtClass.`toClass(ClassLoader loader)`
Deprecated.
Replaced by `CtClass.toClass(ClassLoader,ProtectionDomain)`
`Class<?>`
CtClass.`toClass(ClassLoader loader, ProtectionDomain domain)`
Converts this class to a `java.lang.Class` object.
`Class<?>`
CtClass.`toClass(MethodHandles.Lookup lookup)`
Converts this class to a `java.lang.Class` object.
`CtMethod`
CtConstructor.`toMethod(String name, CtClass declaring)`
Makes a copy of this constructor and converts it into a method.
`CtMethod`
CtConstructor.`toMethod(String name, CtClass declaring, ClassMap map)`
Makes a copy of this constructor and converts it into a method.
`void`
CtBehavior.`useCflow(String name)`
Declares to use `$cflow` for this method/constructor.
`static CtMethod`
CtNewMethod.`wrapped(CtClass returnType, String mname, CtClass[] parameterTypes, CtClass[] exceptionTypes, CtMethod body, CtMethod.ConstParameter constParam, CtClass declaring)`
Creates a wrapped method.
`void`
CtClass.`writeFile()`
Writes a class file represented by this `CtClass` object in the current directory.
`void`
CtClass.`writeFile(String directoryName)`
Writes a class file represented by this `CtClass` object on a local disk.
Constructors in javassist that throw CannotCompileException
Modifier
Constructor
Description
``
`CtConstructor(CtConstructor src, CtClass declaring, ClassMap map)`
Creates a copy of a `CtConstructor` object.
``
`CtField(CtClass type, String name, CtClass declaring)`
Creates a `CtField` object.
``
`CtField(CtField src, CtClass declaring)`
Creates a copy of the given field.
``
`CtMethod(CtMethod src, CtClass declaring, ClassMap map)`
Creates a copy of a `CtMethod` object.

## Uses of CannotCompileException in javassist.bytecode

Subclasses of CannotCompileException in javassist.bytecode
Modifier and Type
Class
Description
`class`
`DuplicateMemberException`
An exception thrown when adding a duplicate member is requested.
Methods in javassist.bytecode that throw CannotCompileException
Modifier and Type
Method
Description
`void`
StackMap.`removeNew(int where)`
Undocumented method.
`void`
StackMapTable.`removeNew(int where)`
Undocumented method.
`void`
ClassFile.`setSuperclass(String superclass)`
Sets the super class.

## Uses of CannotCompileException in javassist.expr

Methods in javassist.expr that throw CannotCompileException
Modifier and Type
Method
Description
`boolean`
ExprEditor.`doit(CtClass clazz, MethodInfo minfo)`
Undocumented method.
`void`
ExprEditor.`edit(Cast c)`
Edits an expression for explicit type casting (overridable).
`void`
ExprEditor.`edit(ConstructorCall c)`
Edits a constructor call (overridable).
`void`
ExprEditor.`edit(FieldAccess f)`
Edits a field-access expression (overridable).
`void`
ExprEditor.`edit(Handler h)`
Edits a catch clause (overridable).
`void`
ExprEditor.`edit(Instanceof i)`
Edits an instanceof expression (overridable).
`void`
ExprEditor.`edit(MethodCall m)`
Edits a method call (overridable).
`void`
ExprEditor.`edit(NewArray a)`
Edits an expression for array creation (overridable).
`void`
ExprEditor.`edit(NewExpr e)`
Edits a `new` expression (overridable).
`void`
Handler.`insertBefore(String src)`
Inserts bytecode at the beginning of the catch clause.
`void`
Cast.`replace(String statement)`
Replaces the explicit cast operator with the bytecode derived from the given source text.
`abstract void`
Expr.`replace(String statement)`
Replaces this expression with the bytecode derived from the given source text.
`void`
Expr.`replace(String statement, ExprEditor recursive)`
Replaces this expression with the bytecode derived from the given source text and `ExprEditor`.
`void`
FieldAccess.`replace(String statement)`
Replaces the method call with the bytecode derived from the given source text.
`void`
Handler.`replace(String statement)`
This method has not been implemented yet.
`void`
Instanceof.`replace(String statement)`
Replaces the instanceof operator with the bytecode derived from the given source text.
`void`
MethodCall.`replace(String statement)`
Replaces the method call with the bytecode derived from the given source text.
`void`
NewArray.`replace(String statement)`
Replaces the array creation with the bytecode derived from the given source text.
`void`
NewExpr.`replace(String statement)`
Replaces the `new` expression with the bytecode derived from the given source text.

## Uses of CannotCompileException in javassist.tools

Methods in javassist.tools that throw CannotCompileException
Modifier and Type
Method
Description
`static void`
Callback.`insertAfter(CtBehavior behavior, Callback callback)`
Utility method to inserts callback at the end of the body.
`static void`
Callback.`insertAfter(CtBehavior behavior, Callback callback, boolean asFinally)`
Utility method to inserts callback at the end of the body.
`static int`
Callback.`insertAt(CtBehavior behavior, Callback callback, int lineNum)`
Utility method to inserts callback at the specified line in the body.
`static void`
Callback.`insertBefore(CtBehavior behavior, Callback callback)`
Utility method to insert callback at the beginning of the body.

## Uses of CannotCompileException in javassist.tools.reflect

Subclasses of CannotCompileException in javassist.tools.reflect
Modifier and Type
Class
Description
`class`
`CannotReflectException`
Thrown by `makeReflective()` in `Reflection` when there is an attempt to reflect a class that is either an interface or a subclass of either ClassMetaobject or Metaobject.
Methods in javassist.tools.reflect that throw CannotCompileException
Modifier and Type
Method
Description
`boolean`
Loader.`makeReflective(String clazz, String metaobject, String metaclass)`
Produces a reflective class.
`boolean`
Reflection.`makeReflective(Class<?> clazz, Class<?> metaobject, Class<?> metaclass)`
Produces a reflective class.
`boolean`
Reflection.`makeReflective(String classname, String metaobject, String metaclass)`
Produces a reflective class.
`boolean`
Reflection.`makeReflective(CtClass clazz, CtClass metaobject, CtClass metaclass)`
Produces a reflective class.
`void`
Reflection.`onLoad(ClassPool pool, String classname)`
Inserts hooks for intercepting accesses to the fields declared in reflective classes.
Constructors in javassist.tools.reflect that throw CannotCompileException
Modifier
Constructor
Description
``
`Loader()`
Constructs a new class loader.

## Uses of CannotCompileException in javassist.tools.rmi

Methods in javassist.tools.rmi that throw CannotCompileException
Modifier and Type
Method
Description
`int`
AppletServer.`exportObject(String name, Object obj)`
Exports an object.
`boolean`
StubGenerator.`makeProxyClass(Class<?> clazz)`
Makes a proxy class.
Constructors in javassist.tools.rmi that throw CannotCompileException
Modifier
Constructor
Description
``
`AppletServer(int port)`
Constructs a web server.
``
`AppletServer(int port, ClassPool src)`
Constructs a web server.
``
`AppletServer(String port)`
Constructs a web server.

## Uses of CannotCompileException in javassist.tools.web

Methods in javassist.tools.web that throw CannotCompileException
Modifier and Type
Method
Description
`void`
Webserver.`addTranslator(ClassPool cp, Translator t)`
Adds a translator, which is called whenever a client requests a class file.

## Uses of CannotCompileException in javassist.util

Methods in javassist.util that throw CannotCompileException
Modifier and Type
Method
Description
`static File`
HotSwapAgent.`createAgentJarFile(String fileName)`
Creates an agent file for using `HotSwapAgent`.
`static void`
HotSwapAgent.`redefine(Class<?>[] oldClasses, CtClass[] newClasses)`
Redefines classes.
`static void`
HotSwapAgent.`redefine(Class<?> oldClass, CtClass newClass)`
Redefines a class.

## Uses of CannotCompileException in javassist.util.proxy

Methods in javassist.util.proxy that throw CannotCompileException
Modifier and Type
Method
Description
`static void`
DefinePackageHelper.`definePackage(String className, ClassLoader loader)`
Defines a new package.
`static Class<?>`
DefineClassHelper.`toClass(Class<?> neighbor, byte[] bcode)`
Loads a class file by `java.lang.invoke.MethodHandles.Lookup`.
`static Class<?>`
DefineClassHelper.`toClass(MethodHandles.Lookup lookup, byte[] bcode)`
Loads a class file by `java.lang.invoke.MethodHandles.Lookup`.
`static Class<?>`
DefineClassHelper.`toClass(String className, Class<?> neighbor, ClassLoader loader, ProtectionDomain domain, byte[] bcode)`
Loads a class file by a given class loader.
`static Class<?>`
FactoryHelper.`toClass(ClassFile cf, Class<?> neighbor, ClassLoader loader, ProtectionDomain domain)`
Loads a class file by a given class loader.
`static Class<?>`
FactoryHelper.`toClass(ClassFile cf, ClassLoader loader)`
Deprecated.
`static Class<?>`
FactoryHelper.`toClass(ClassFile cf, ClassLoader loader, ProtectionDomain domain)`
Deprecated.
`static Class<?>`
FactoryHelper.`toClass(ClassFile cf, MethodHandles.Lookup lookup)`
Loads a class file by a given lookup.
`static void`
FactoryHelper.`writeFile(ClassFile cf, String directoryName)`
Writes a class file.