Top Description Inners Fields Constructors Methods
com.sun.tools.javac.jvm

public Class PoolWriter

extends Object
Class Inheritance
Imports
com.sun.tools.javac.code.Kinds.Kind, .Symbol, .Symbol.ClassSymbol, .Symbol.DynamicMethodSymbol, .Symbol.MethodHandleSymbol, .Symbol.ModuleSymbol, .Symbol.PackageSymbol, .Type, .Types, com.sun.tools.javac.jvm.ClassWriter.PoolOverflow, .ClassWriter.StringOverflow, .PoolConstant.LoadableConstant, .PoolConstant.LoadableConstant.BasicConstant, .PoolConstant.Dynamic, .PoolConstant.Dynamic.BsmKey, .PoolConstant.NameAndType, com.sun.tools.javac.util.ByteBuffer, .InvalidUtfException, .List, .Name, .Names, java.io.IOException, .OutputStream, java.util.ArrayDeque, .HashMap, .LinkedHashMap, .LinkedHashSet, .Map

Pool interface towards ClassWriter. Exposes methods to encode and write javac entities into the constant pool.

This is NOT part of any supported API. 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 and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv Map<PoolConstant.Dynamic.BsmKey, Integer>
bootstrapMethods

The list of entries in the BootstrapMethods attribute.

pack-priv LinkedHashSet<Symbol.ClassSymbol>
innerClasses

The inner classes to be written, as an ordered set (enclosing first).

public static final int
MAX_ENTRIES

Max number of constant pool entries.

public static final int
MAX_STRING_LENGTH

Max number of char in a string constant.

private final Names
pack-priv final PoolWriter.WriteablePoolHelper
pool

Pool helper

private static final int
pack-priv final PoolWriter.SharedSignatureGenerator
signatureGen

Sole signature generator

private final Types

Constructor Summary

AccessConstructor and Description
public
PoolWriter(Types types, Names names)

Method Summary

Modifier and TypeMethod and Description
private Name
private Type
descriptorType(Symbol s)

Create a new Utf8 entry representing a descriptor for given (member) symbol.

pack-priv void
enterInner(Symbol.ClassSymbol c)

Enter an inner class into the `innerClasses' set.

private int
pack-priv int
putClass(Symbol.ClassSymbol csym)

Puts a class symbol into the pool and return its index.

pack-priv int
putClass(Type t)

Puts a type into the pool and return its index.

pack-priv int
putConstant(Object o)

Puts a constant value into the pool and return its index.

pack-priv int
putConstant(PoolConstant.LoadableConstant c)

Puts a constant into the pool and return its index.

pack-priv int
putDescriptor(Type t)

Puts a field or method descriptor into the constant pool and return its index.

pack-priv int
putDescriptor(Symbol s)

Puts a field or method descriptor into the constant pool and return its index.

pack-priv int
putDynamic(PoolConstant.Dynamic d)

Puts a dynamic reference into the constant pool and return its index.

pack-priv int
putMember(Symbol s)

Puts a member reference into the constant pool.

pack-priv int
putModule(Symbol.ModuleSymbol mod)

Puts a module entry into the pool and returns its index.

pack-priv int
putName(Name name)

pack-priv int
putNameAndType(Symbol s)

Puts a name and type pair into the pool and returns its index.

pack-priv int
putPackage(Symbol.PackageSymbol pkg)

Puts a package entry into the pool and returns its index.

pack-priv int
putSignature(Symbol s)

Puts a signature (see Signature attribute in JVMS 4.4) into the constant pool and return its index.

pack-priv void
pack-priv int
size()

private Name
typeSig(Type type)

Return signature of given type

pack-priv void
writePool(OutputStream out)

Write pool contents into given byte buffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bootstrapMethodsback to summary
pack-priv Map<PoolConstant.Dynamic.BsmKey, Integer> bootstrapMethods

The list of entries in the BootstrapMethods attribute.

innerClassesback to summary
pack-priv LinkedHashSet<Symbol.ClassSymbol> innerClasses

The inner classes to be written, as an ordered set (enclosing first).

MAX_ENTRIESback to summary
public static final int MAX_ENTRIES

Max number of constant pool entries.

MAX_STRING_LENGTHback to summary
public static final int MAX_STRING_LENGTH

Max number of char in a string constant.

namesback to summary
private final Names names
poolback to summary
pack-priv final PoolWriter.WriteablePoolHelper pool

Pool helper

POOL_BUF_SIZEback to summary
private static final int POOL_BUF_SIZE
signatureGenback to summary
pack-priv final PoolWriter.SharedSignatureGenerator signatureGen

Sole signature generator

typesback to summary
private final Types types

Constructor Detail

PoolWriterback to summary
public PoolWriter(Types types, Names names)

Method Detail

classSigback to summary
private Name classSig(Type t)
descriptorTypeback to summary
private Type descriptorType(Symbol s)

Create a new Utf8 entry representing a descriptor for given (member) symbol.

enterInnerback to summary
pack-priv void enterInner(Symbol.ClassSymbol c)

Enter an inner class into the `innerClasses' set.

makeBootstrapEntryback to summary
private int makeBootstrapEntry(PoolConstant.Dynamic dynamic)
putClassback to summary
pack-priv int putClass(Symbol.ClassSymbol csym)

Puts a class symbol into the pool and return its index.

putClassback to summary
pack-priv int putClass(Type t)

Puts a type into the pool and return its index. The type could be either a class, a type variable or an array type.

putConstantback to summary
pack-priv int putConstant(Object o)

Puts a constant value into the pool and return its index. Supported values are int, float, long, double and String.

putConstantback to summary
pack-priv int putConstant(PoolConstant.LoadableConstant c)

Puts a constant into the pool and return its index.

putDescriptorback to summary
pack-priv int putDescriptor(Type t)

Puts a field or method descriptor into the constant pool and return its index.

putDescriptorback to summary
pack-priv int putDescriptor(Symbol s)

Puts a field or method descriptor into the constant pool and return its index.

putDynamicback to summary
pack-priv int putDynamic(PoolConstant.Dynamic d)

Puts a dynamic reference into the constant pool and return its index.

putMemberback to summary
pack-priv int putMember(Symbol s)

Puts a member reference into the constant pool. Valid members are either field or method symbols.

putModuleback to summary
pack-priv int putModule(Symbol.ModuleSymbol mod)

Puts a module entry into the pool and returns its index.

putNameback to summary
pack-priv int putName(Name name)
putNameAndTypeback to summary
pack-priv int putNameAndType(Symbol s)

Puts a name and type pair into the pool and returns its index.

putPackageback to summary
pack-priv int putPackage(Symbol.PackageSymbol pkg)

Puts a package entry into the pool and returns its index.

putSignatureback to summary
pack-priv int putSignature(Symbol s)

Puts a signature (see Signature attribute in JVMS 4.4) into the constant pool and return its index.

resetback to summary
pack-priv void reset()
sizeback to summary
pack-priv int size()
typeSigback to summary
private Name typeSig(Type type)

Return signature of given type

writePoolback to summary
pack-priv void writePool(OutputStream out) throws IOException, PoolOverflow

Write pool contents into given byte buffer.

com.sun.tools.javac.jvm back to summary

pack-priv Class PoolWriter.SharedSignatureGenerator

extends SignatureGenerator
Class Inheritance

Signature Generation

Field Summary

Modifier and TypeField and Description
pack-priv ByteBuffer
sigbuf

An output buffer for type signatures.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
protected void
public void
assembleSig(Type type)

Overrides com.sun.tools.javac.code.Types.SignatureGenerator.assembleSig.

Assemble signature of given type in string buffer.
protected void
protected void
protected Name
Inherited from com.sun.tools.javac.code.Types.SignatureGenerator:
assembleClassSigassembleParamsSigassembleSighasTypeVarreportIllegalSignature

Field Detail

sigbufback to summary
pack-priv ByteBuffer sigbuf

An output buffer for type signatures.

Constructor Detail

SharedSignatureGeneratorback to summary
pack-priv SharedSignatureGenerator(Types types)

Method Detail

appendback to summary
protected void append(char ch)

Implements abstract com.sun.tools.javac.code.Types.SignatureGenerator.append.

Annotations
@Override
appendback to summary
protected void append(byte[] ba)

Implements abstract com.sun.tools.javac.code.Types.SignatureGenerator.append.

Annotations
@Override
appendback to summary
protected void append(Name name)

Implements abstract com.sun.tools.javac.code.Types.SignatureGenerator.append.

Annotations
@Override
assembleSigback to summary
public void assembleSig(Type type)

Overrides com.sun.tools.javac.code.Types.SignatureGenerator.assembleSig.

Assemble signature of given type in string buffer. Check for uninitialized types before calling the general case.

Annotations
@Override
classReferenceback to summary
protected void classReference(Symbol.ClassSymbol c)

Overrides com.sun.tools.javac.code.Types.SignatureGenerator.classReference.

Annotations
@Override
resetback to summary
protected void reset()
toNameback to summary
protected Name toName()
com.sun.tools.javac.jvm back to summary

pack-priv Class PoolWriter.WriteablePoolHelper

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int
private final Map<Object, Integer>
keysToPos

Pool entries.

pack-priv String
pack-priv final ByteBuffer
pack-priv ArrayDeque<PoolConstant>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
private <P extends PoolConstant> int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentIndexback to summary
pack-priv int currentIndex
keysToPosback to summary
private final Map<Object, Integer> keysToPos

Pool entries.

overflowStringback to summary
pack-priv String overflowString
poolbufback to summary
pack-priv final ByteBuffer poolbuf
todoback to summary
pack-priv ArrayDeque<PoolConstant> todo

Constructor Detail

WriteablePoolHelperback to summary
pack-priv WriteablePoolHelper()

Method Detail

resetback to summary
pack-priv void reset()
writeConstantback to summary
pack-priv void writeConstant(PoolConstant c)
writeIfNeededback to summary
private <P extends PoolConstant> int writeIfNeeded(P p)