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

public Class JNIWriter

extends Object
Class Inheritance
Imports
java.io.IOException, .PrintWriter, java.util.ArrayList, .Collections, .HashMap, .List, javax.tools.FileObject, .JavaFileManager, .JavaFileManager.Location, .StandardLocation, com.sun.tools.javac.code.Attribute, .Flags, .Symbol, .Symbol.ClassSymbol, .Symbol.ModuleSymbol, .Symbol.VarSymbol, .Symtab, .Type, .Types, com.sun.tools.javac.model.JavacElements, com.sun.tools.javac.util.Assert, .Context, .Log, .Options, .Pair

This class provides operations to write native header files for classes.

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 static enum
pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
private boolean
checkAll

Switch: check all nested classes of top level class

private Context
private final JavaFileManager
fileManager

Access to files.

private final HashMap<String, String>
filesWritten

Mapping from output file name to class name, for all classes we've written.

private static final boolean
protected static final Context.Key<JNIWriter>
private final Log
log

The log to use for verbose output.

public boolean
multiModuleMode

If true, class files will be written in module-specific subdirectories of the NATIVE_HEADER_OUTPUT location.

pack-priv Symtab
pack-priv Types
private boolean
verbose

Switch: verbose output.

Constructor Summary

AccessConstructor and Description
private
JNIWriter(Context context)

Construct a class writer, given an options table.

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
pack-priv static String
pack-priv static String
encodeChar(char ch)

pack-priv String
encodeMethod(Symbol msym, Symbol.ClassSymbol clazz, boolean isOverloaded)

protected void
protected void
protected void
private static boolean
hasFlag(Symbol m, int flag)

protected void
public static JNIWriter
instance(Context context)

Get the ClassWriter instance for this context.

private static boolean
isalnum(char ch)

pack-priv static boolean
pack-priv static boolean
private static boolean
isprint(char ch)

pack-priv static boolean
pack-priv static boolean
protected final String
private void
public boolean
private boolean
needsHeader(Symbol.ClassSymbol c, boolean checkNestedClasses)

pack-priv static void
public FileObject
write(Symbol.ClassSymbol
The class from which a class file is generated.
c
)

Emit a class file for a given class.

public void
protected void
protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checkAllback to summary
private boolean checkAll

Switch: check all nested classes of top level class

contextback to summary
private Context context
fileManagerback to summary
private final JavaFileManager fileManager

Access to files.

filesWrittenback to summary
private final HashMap<String, String> filesWritten

Mapping from output file name to class name, for all classes we've written. This is used to detect when two classes generate the same output file.

isWindowsback to summary
private static final boolean isWindows
jniWriterKeyback to summary
protected static final Context.Key<JNIWriter> jniWriterKey
logback to summary
private final Log log

The log to use for verbose output.

multiModuleModeback to summary
public boolean multiModuleMode

If true, class files will be written in module-specific subdirectories of the NATIVE_HEADER_OUTPUT location.

symsback to summary
pack-priv Symtab syms
typesback to summary
pack-priv Types types
verboseback to summary
private boolean verbose

Switch: verbose output.

Constructor Detail

JNIWriterback to summary
private JNIWriter(Context context)

Construct a class writer, given an options table.

Method Detail

cppGuardBeginback to summary
protected void cppGuardBegin(PrintWriter out)
cppGuardEndback to summary
protected void cppGuardEnd(PrintWriter out)
encodeback to summary
pack-priv static String encode(CharSequence name, JNIWriter.EncoderType mtype)
encodeCharback to summary
pack-priv static String encodeChar(char ch)
encodeMethodback to summary
pack-priv String encodeMethod(Symbol msym, Symbol.ClassSymbol clazz, boolean isOverloaded) throws SignatureException
fileTopback to summary
protected void fileTop(PrintWriter out)
guardBeginback to summary
protected void guardBegin(PrintWriter out, String cname)
guardEndback to summary
protected void guardEnd(PrintWriter out)
hasFlagback to summary
private static boolean hasFlag(Symbol m, int flag)
includesback to summary
protected void includes(PrintWriter out)
instanceback to summary
public static JNIWriter instance(Context context)

Get the ClassWriter instance for this context.

isalnumback to summary
private static boolean isalnum(char ch)
isFinalback to summary
pack-priv static boolean isFinal(Symbol s)
isNativeback to summary
pack-priv static boolean isNative(Symbol s)
isprintback to summary
private static boolean isprint(char ch)
isStaticback to summary
pack-priv static boolean isStatic(Symbol s)
isSyntheticback to summary
pack-priv static boolean isSynthetic(Symbol s)
jniTypeback to summary
protected final String jniType(Type t)
lazyInitback to summary
private void lazyInit()
needsHeaderback to summary
public boolean needsHeader(Symbol.ClassSymbol c)
needsHeaderback to summary
private boolean needsHeader(Symbol.ClassSymbol c, boolean checkNestedClasses)
printStaticDefinesback to summary
pack-priv static void printStaticDefines(PrintWriter out, Pair<Symbol.ClassSymbol, Symbol.VarSymbol> p)
writeback to summary
public FileObject write(Symbol.ClassSymbol c) throws IOException

Emit a class file for a given class.

Parameters
c:Symbol.ClassSymbol

The class from which a class file is generated.

writeback to summary
public void write(PrintWriter out, Symbol.ClassSymbol sym) throws IOException
writeMethodsback to summary
protected void writeMethods(PrintWriter out, Symbol.ClassSymbol sym, String cname) throws IOException, SignatureException
writeStaticsback to summary
protected void writeStatics(PrintWriter out, Symbol.ClassSymbol sym) throws IOException
com.sun.tools.javac.jvm back to summary

pack-priv final Enum JNIWriter.EncoderType

extends Enum<JNIWriter.EncoderType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final JNIWriter.EncoderType
public static final JNIWriter.EncoderType
public static final JNIWriter.EncoderType
public static final JNIWriter.EncoderType
public static final JNIWriter.EncoderType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static JNIWriter.EncoderType
public static JNIWriter.EncoderType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLASSback to summary
public static final JNIWriter.EncoderType CLASS
FIELDback to summary
public static final JNIWriter.EncoderType FIELD
FIELDSTUBback to summary
public static final JNIWriter.EncoderType FIELDSTUB
JNIback to summary
public static final JNIWriter.EncoderType JNI
SIGNATUREback to summary
public static final JNIWriter.EncoderType SIGNATURE

Constructor Detail

EncoderTypeback to summary
private EncoderType()

Method Detail

valueOfback to summary
public static JNIWriter.EncoderType valueOf(String name)
valuesback to summary
public static JNIWriter.EncoderType[] values()
com.sun.tools.javac.jvm back to summary

pack-priv Class JNIWriter.SimpleTypeVisitor<R, P>

extends Object
implements Type.Visitor<R, P>
Class Inheritance
All Implemented Interfaces
com.sun.tools.javac.code.Type.Visitor
Known Direct Subclasses
com.sun.tools.javac.jvm.JNIWriter.TypeSignature.JvmTypeVisitor

Field Summary

Modifier and TypeField and Description
protected final R

Constructor Summary

AccessConstructor and Description
protected
protected
SimpleTypeVisitor(R defaultValue)

Method Summary

Modifier and TypeMethod and Description
protected R
public R
public R
public R
public R
public R
public R
public R
public R
public R
public R
public R
public R
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_VALUEback to summary
protected final R DEFAULT_VALUE

Constructor Detail

SimpleTypeVisitorback to summary
protected SimpleTypeVisitor()
SimpleTypeVisitorback to summary
protected SimpleTypeVisitor(R defaultValue)

Method Detail

defaultActionback to summary
protected R defaultAction(Type t, P p)
visitArrayTypeback to summary
public R visitArrayType(Type.ArrayType t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitArrayType.

Annotations
@Override
visitCapturedTypeback to summary
public R visitCapturedType(Type.CapturedType t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitCapturedType.

Annotations
@Override
visitClassTypeback to summary
public R visitClassType(Type.ClassType t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitClassType.

Annotations
@Override
visitErrorTypeback to summary
public R visitErrorType(Type.ErrorType t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitErrorType.

Annotations
@Override
visitForAllback to summary
public R visitForAll(Type.ForAll t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitForAll.

Annotations
@Override
visitMethodTypeback to summary
public R visitMethodType(Type.MethodType t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitMethodType.

Annotations
@Override
visitModuleTypeback to summary
public R visitModuleType(Type.ModuleType t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitModuleType.

Annotations
@Override
visitPackageTypeback to summary
public R visitPackageType(Type.PackageType t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitPackageType.

Annotations
@Override
visitTypeback to summary
public R visitType(Type t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitType.

Annotations
@Override
visitTypeVarback to summary
public R visitTypeVar(Type.TypeVar t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitTypeVar.

Annotations
@Override
visitUndetVarback to summary
public R visitUndetVar(Type.UndetVar t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitUndetVar.

Annotations
@Override
visitWildcardTypeback to summary
public R visitWildcardType(Type.WildcardType t, P p)

Implements com.sun.tools.javac.code.Type.Visitor.visitWildcardType.

Annotations
@Override
com.sun.tools.javac.jvm back to summary

private Class JNIWriter.TypeSignature

extends Object
Class Inheritance

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
pack-priv JavacElements
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
pack-priv Types

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv StringBuilder
getJvmSignature(Type type, boolean useFlatname)

pack-priv StringBuilder
getParameterSignature(Type mType, boolean useFlatname)

pack-priv StringBuilder
pack-priv StringBuilder
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

elemsback to summary
pack-priv JavacElements elems
SIG_ARRAYback to summary
private static final String SIG_ARRAY
SIG_BOOLEANback to summary
private static final String SIG_BOOLEAN
SIG_BYTEback to summary
private static final String SIG_BYTE
SIG_CHARback to summary
private static final String SIG_CHAR
SIG_CLASSback to summary
private static final String SIG_CLASS
SIG_DOUBLEback to summary
private static final String SIG_DOUBLE
SIG_FLOATback to summary
private static final String SIG_FLOAT
SIG_INTback to summary
private static final String SIG_INT
SIG_LONGback to summary
private static final String SIG_LONG
SIG_SHORTback to summary
private static final String SIG_SHORT
SIG_VOIDback to summary
private static final String SIG_VOID
typesback to summary
pack-priv Types types

Constructor Detail

TypeSignatureback to summary
public TypeSignature(Types types)

Method Detail

getJvmSignatureback to summary
pack-priv StringBuilder getJvmSignature(Type type, boolean useFlatname)
getParameterSignatureback to summary
pack-priv StringBuilder getParameterSignature(Type mType, boolean useFlatname) throws SignatureException
getReturnSignatureback to summary
pack-priv StringBuilder getReturnSignature(Type mType) throws SignatureException
getSignatureback to summary
pack-priv StringBuilder getSignature(Type mType) throws SignatureException
com.sun.tools.javac.jvm back to summary

pack-priv Class JNIWriter.TypeSignature.JvmTypeVisitor

extends JNIWriter.SimpleTypeVisitor<Type, StringBuilder>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final boolean
Inherited from com.sun.tools.javac.jvm.JNIWriter.SimpleTypeVisitor:
DEFAULT_VALUE

Constructor Summary

AccessConstructor and Description
pack-priv
JvmTypeVisitor(boolean useFlatname)

Field Detail

useFlatnameback to summary
private final boolean useFlatname

Constructor Detail

JvmTypeVisitorback to summary
pack-priv JvmTypeVisitor(boolean useFlatname)
com.sun.tools.javac.jvm back to summary

pack-priv Class JNIWriter.TypeSignature.SignatureException

extends Exception
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

SignatureExceptionback to summary
pack-priv SignatureException(String reason)