|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.tools.javac.jvm.ClassFile
com.sun.tools.javac.jvm.ClassWriter
public class ClassWriter
This class provides operations to map an internal symbol table graph rooted in a ClassSymbol into a classfile.
This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
| Nested Class Summary | |
|---|---|
(package private) class |
ClassWriter.AttributeWriter
A visitor to write an attribute including its leading single-character marker. |
static class |
ClassWriter.PoolOverflow
Thrown when the constant pool is over full. |
(package private) static class |
ClassWriter.RetentionPolicy
A mirror of java.lang.annotation.RetentionPolicy. |
(package private) static class |
ClassWriter.StackMapTableFrame
An entry in the JSR202 StackMapTable |
static class |
ClassWriter.StringOverflow
|
| Nested classes/interfaces inherited from class com.sun.tools.javac.jvm.ClassFile |
|---|
ClassFile.NameAndType |
| Field Summary | |
|---|---|
(package private) ClassWriter.AttributeWriter |
awriter
|
protected static Context.Key<ClassWriter> |
classWriterKey
|
(package private) static int |
DATA_BUF_SIZE
The initial sizes of the data and constant pool buffers. |
(package private) ByteBuffer |
databuf
An output buffer for member info. |
(package private) boolean |
debugstackmap
Switch: describe the generated stackmap |
private boolean |
dumpClassModifiers
Value of option 'dumpmodifiers' is a string indicating which modifiers should be dumped for debugging: 'c' -- classes 'f' -- fields 'i' -- innerclass attributes 'm' -- methods For example, to dump everything: javac -XDdumpmodifiers=cifm MyProg.java |
private boolean |
dumpFieldModifiers
|
private boolean |
dumpInnerClassModifiers
|
private boolean |
dumpMethodModifiers
|
private boolean |
emitSourceFile
Switch: emit source file attribute. |
private JavaFileManager |
fileManager
Access to files. |
private static java.lang.String[] |
flagName
|
(package private) static int |
FULL_FRAME
|
private boolean |
genCrt
Switch: generate CharacterRangeTable attribute. |
(package private) java.util.Set<Symbol.ClassSymbol> |
innerClasses
The inner classes to be written, as a set. |
(package private) ListBuffer<Symbol.ClassSymbol> |
innerClassesQueue
The inner classes to be written, as a queue where enclosing classes come first. |
private Log |
log
The log to use for verbose output. |
(package private) static int |
MAX_LOCAL_LENGTH_DIFF
|
private Names |
names
The name table. |
private Options |
options
|
(package private) Pool |
pool
The constant pool. |
(package private) static int |
POOL_BUF_SIZE
|
(package private) ByteBuffer |
poolbuf
An output buffer for the constant pool. |
private boolean |
retrofit
Switch: retrofit mode. |
(package private) static int |
SAME_FRAME_EXTENDED
|
(package private) static int |
SAME_FRAME_SIZE
The tags and constants used in compressed stackmap. |
(package private) static int |
SAME_LOCALS_1_STACK_ITEM_EXTENDED
|
private boolean |
scramble
Switch: scrable private names. |
private boolean |
scrambleAll
Switch: scrable private names. |
(package private) ByteBuffer |
sigbuf
An output buffer for type signatures. |
private Source |
source
Source language version. |
private Symtab |
syms
|
private Target |
target
Target class version. |
private Types |
types
Type utilities. |
private boolean |
verbose
Switch: verbose output. |
| Fields inherited from class com.sun.tools.javac.jvm.ClassFile |
|---|
CONSTANT_Class, CONSTANT_Double, CONSTANT_Fieldref, CONSTANT_Float, CONSTANT_Integer, CONSTANT_InterfaceMethodref, CONSTANT_Long, CONSTANT_Methodref, CONSTANT_NameandType, CONSTANT_String, CONSTANT_Unicode, CONSTANT_Utf8, JAVA_MAGIC, MAX_CODE, MAX_DIMENSIONS, MAX_LOCALS, MAX_PARAMETERS, MAX_STACK |
| Constructor Summary | |
|---|---|
private |
ClassWriter(Context context)
Construct a class writer, given an options table. |
| Method Summary | |
|---|---|
(package private) int |
adjustFlags(long flags)
|
(package private) void |
assembleClassSig(Type type)
|
(package private) void |
assembleParamsSig(List<Type> typarams)
|
(package private) void |
assembleSig(List<Type> types)
|
(package private) void |
assembleSig(Type type)
Assemble signature of given type in string buffer. |
(package private) int |
beginAttrs()
Leave space for attribute count and return index for number of attributes field. |
(package private) void |
endAttr(int index)
Fill in attribute length. |
(package private) void |
endAttrs(int index,
int count)
Fill in number of attributes. |
(package private) void |
enterInner(Symbol.ClassSymbol c)
Enter an inner class into the `innerClasses' set/queue. |
(package private) Name |
fieldName(Symbol sym)
Given a field, return its name. |
static java.lang.String |
flagNames(long flags)
Return flags as a string, separated by " ". |
(package private) long |
getLastModified(FileObject filename)
|
(package private) ClassWriter.RetentionPolicy |
getRetention(Symbol.TypeSymbol annotationType)
|
(package private) boolean |
hasTypeVar(List<Type> l)
|
static ClassWriter |
instance(Context context)
Get the ClassWriter instance for this context. |
(package private) ClassFile.NameAndType |
nameType(Symbol sym)
Given a symbol, return its name-and-type. |
(package private) void |
putChar(ByteBuffer buf,
int op,
int x)
Write a character into given byte buffer; byte buffer will not be grown. |
(package private) void |
putInt(ByteBuffer buf,
int adr,
int x)
Write an integer into given byte buffer; byte buffer will not be grown. |
(package private) Name |
typeSig(Type type)
Return signature of given type |
(package private) int |
writeAttr(Name attrName)
Write header for an attribute to data buffer and return position past attribute length index. |
JavaFileObject |
writeClass(Symbol.ClassSymbol c)
Emit a class file for a given class. |
void |
writeClassFile(java.io.OutputStream out,
Symbol.ClassSymbol c)
Write class `c' to outstream `out'. |
(package private) void |
writeCode(Code code)
Write code attribute of method. |
(package private) void |
writeCompoundAttribute(Attribute.Compound c)
Write a compound attribute excluding the '@' marker. |
(package private) int |
writeEnclosingMethodAttribute(Symbol.ClassSymbol c)
Write the EnclosingMethod attribute if needed. |
(package private) void |
writeField(Symbol.VarSymbol v)
Write field symbol, entering all references into constant pool. |
(package private) void |
writeFields(Scope.Entry e)
|
(package private) int |
writeFlagAttrs(long flags)
Write flag attributes; return number of attributes written. |
(package private) void |
writeInnerClasses()
Write "inner classes" attribute. |
(package private) int |
writeJavaAnnotations(List<Attribute.Compound> attrs)
Write Java-language annotations; return number of JVM attributes written (zero or one). |
(package private) int |
writeMemberAttrs(Symbol sym)
Write member (field or method) attributes; return number of attributes written. |
(package private) void |
writeMethod(Symbol.MethodSymbol m)
Write method symbol, entering all references into constant pool. |
(package private) void |
writeMethods(Scope.Entry e)
|
(package private) int |
writeParameterAttrs(Symbol.MethodSymbol m)
Write method parameter annotations; return number of attributes written. |
(package private) void |
writePool(Pool pool)
Write constant pool to pool buffer. |
(package private) void |
writeStackMap(Code code)
|
(package private) void |
writeStackMapType(Type t)
|
Name |
xClassName(Type t)
Given a type t, return the extended class name of its erasure in external representation. |
| Methods inherited from class com.sun.tools.javac.jvm.ClassFile |
|---|
externalize, externalize, internalize, internalize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Context.Key<ClassWriter> classWriterKey
private final Symtab syms
private final Options options
private boolean verbose
private boolean scramble
private boolean scrambleAll
private boolean retrofit
private boolean emitSourceFile
private boolean genCrt
boolean debugstackmap
private Target target
private Source source
private Types types
static final int DATA_BUF_SIZE
static final int POOL_BUF_SIZE
ByteBuffer databuf
ByteBuffer poolbuf
ByteBuffer sigbuf
Pool pool
java.util.Set<Symbol.ClassSymbol> innerClasses
ListBuffer<Symbol.ClassSymbol> innerClassesQueue
private final Log log
private final Names names
private final JavaFileManager fileManager
static final int SAME_FRAME_SIZE
static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED
static final int SAME_FRAME_EXTENDED
static final int FULL_FRAME
static final int MAX_LOCAL_LENGTH_DIFF
private final boolean dumpClassModifiers
private final boolean dumpFieldModifiers
private final boolean dumpInnerClassModifiers
private final boolean dumpMethodModifiers
private static final java.lang.String[] flagName
ClassWriter.AttributeWriter awriter
| Constructor Detail |
|---|
private ClassWriter(Context context)
| Method Detail |
|---|
public static ClassWriter instance(Context context)
public static java.lang.String flagNames(long flags)
void putChar(ByteBuffer buf,
int op,
int x)
void putInt(ByteBuffer buf,
int adr,
int x)
void assembleSig(Type type)
boolean hasTypeVar(List<Type> l)
void assembleClassSig(Type type)
void assembleSig(List<Type> types)
void assembleParamsSig(List<Type> typarams)
Name typeSig(Type type)
public Name xClassName(Type t)
void writePool(Pool pool)
throws ClassWriter.PoolOverflow,
ClassWriter.StringOverflow
ClassWriter.PoolOverflow
ClassWriter.StringOverflowName fieldName(Symbol sym)
ClassFile.NameAndType nameType(Symbol sym)
int writeAttr(Name attrName)
void endAttr(int index)
int beginAttrs()
void endAttrs(int index,
int count)
int writeEnclosingMethodAttribute(Symbol.ClassSymbol c)
int writeFlagAttrs(long flags)
int writeMemberAttrs(Symbol sym)
int writeParameterAttrs(Symbol.MethodSymbol m)
int writeJavaAnnotations(List<Attribute.Compound> attrs)
ClassWriter.RetentionPolicy getRetention(Symbol.TypeSymbol annotationType)
void writeCompoundAttribute(Attribute.Compound c)
void enterInner(Symbol.ClassSymbol c)
void writeInnerClasses()
void writeField(Symbol.VarSymbol v)
void writeMethod(Symbol.MethodSymbol m)
void writeCode(Code code)
void writeStackMap(Code code)
void writeStackMapType(Type t)
void writeFields(Scope.Entry e)
void writeMethods(Scope.Entry e)
public JavaFileObject writeClass(Symbol.ClassSymbol c)
throws java.io.IOException,
ClassWriter.PoolOverflow,
ClassWriter.StringOverflow
c - The class from which a class file is generated.
java.io.IOException
ClassWriter.PoolOverflow
ClassWriter.StringOverflow
public void writeClassFile(java.io.OutputStream out,
Symbol.ClassSymbol c)
throws java.io.IOException,
ClassWriter.PoolOverflow,
ClassWriter.StringOverflow
java.io.IOException
ClassWriter.PoolOverflow
ClassWriter.StringOverflowint adjustFlags(long flags)
long getLastModified(FileObject filename)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||