Top Description Fields Constructors Methods
org.glassfish.pfl.dynamic.codegen.impl

public final Class ByteCodeUtility

extends Object
Class Inheritance
Imports
java.io.PrintStream, java.lang.reflect.Modifier, java.util.ArrayList, .Collections, .Comparator, .HashMap, .List, .Map, org.glassfish.pfl.dynamic.codegen.spi.ClassInfo, .MethodInfo, .Signature, .Type, .Variable, org.objectweb.asm.ClassWriter, .Label, .MethodVisitor, org.objectweb.asm.util.Textifier, .TraceMethodVisitor

Class that is responsible for low-level bytecode generation using ASM. It provides methods that directly generate bytecode in a MethodVisitor. This will often be accompanied by type analysis, such as in determining the correct sort of return instruction to use, or how to generate code for a constant.

Field Summary

Modifier and TypeField and Description
private ClassWriter
private boolean
private static final EmitterFactory.Emitter
E_D2B

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_D2C

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_D2F

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_D2I

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_D2L

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_D2S

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_F2B

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_F2C

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_F2D

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_F2I

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_F2L

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_F2S

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_I2B

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_I2C

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_I2D

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_I2F

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_I2L

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_I2S

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_L2B

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_L2C

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_L2D

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_L2F

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_L2I

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_L2S

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static final EmitterFactory.Emitter
E_NOP

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static Map<ExpressionFactory.BinaryOperator, Integer>
private String
private String
private MethodVisitor
pack-priv EmitterFactory.Emitter[][]
numericConversions

References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.
private static Map<ExpressionFactory.BinaryOperator, Map<Type, Integer>>
private PrintStream
private static Map<Type, Integer>

Constructor Summary

AccessConstructor and Description
public
ByteCodeUtility(ClassWriter cw, ClassGeneratorImpl cg, boolean debug, PrintStream ps)

Construct an instance of ByteCodeUtility from an ASM ClassWriter and a codegen ClassGeneratorImpl.

public

Method Summary

Modifier and TypeMethod and Description
public void
public void
callEmitter(EmitterFactory.Emitter emitter)
References Deprecated EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

private void
dump()

public void
public void
private void
private void
public void
public void
emitCast(Type from, Type to)

public void
public void
public void
public void
public void
emitExceptionTableEntry(Label start, Label end, Label handler, Type exceptionType)

public void
public void
emitInvoke(Type type, String name, Signature sig)

Emit the appropriate non-static INVOKE instruction as follows:

  1. If type is an interface, emit INVOKEINTERFACE.
  2. If name/sig has private access in type, emit INVOKESPECIAL. Note that the target must be "this" in this case.
  3. Otherwise emit INVOKEVIRTUAL.
public void
emitJsr(Label label)

public void
private void
private void
public void
emitMethodEnd(MethodGenerator mg, Label returnLabel, Variable returnVariable, boolean dump)

public void
public void
public void
emitNewCall(Type type)

Emit the NEW, DUP sequence required at the start of a new call.

public void
emitNewInvoke(Type type, Signature sig)

Emit the INVOKESPECIAL instruction for calling a constructor with the given signature.

public void
public void
private void
emitReturn(Type returnType)

public void
emitSpecialInvoke(Type type, String name, Signature sig)

Emit the INVOKESPECIAL instruction for calling a method with the given signature.

public void
emitStaticInvoke(Type type, String name, Signature sig)

Emit a static INVOKE instruction.

public void
public void
public int
typeCode(Type type)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cwback to summary
private ClassWriter cw
debugback to summary
private boolean debug
E_D2Bback to summary
private static final EmitterFactory.Emitter E_D2B

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_D2Cback to summary
private static final EmitterFactory.Emitter E_D2C

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_D2Fback to summary
private static final EmitterFactory.Emitter E_D2F

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_D2Iback to summary
private static final EmitterFactory.Emitter E_D2I

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_D2Lback to summary
private static final EmitterFactory.Emitter E_D2L

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_D2Sback to summary
private static final EmitterFactory.Emitter E_D2S

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_F2Bback to summary
private static final EmitterFactory.Emitter E_F2B

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_F2Cback to summary
private static final EmitterFactory.Emitter E_F2C

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_F2Dback to summary
private static final EmitterFactory.Emitter E_F2D

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_F2Iback to summary
private static final EmitterFactory.Emitter E_F2I

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_F2Lback to summary
private static final EmitterFactory.Emitter E_F2L

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_F2Sback to summary
private static final EmitterFactory.Emitter E_F2S

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_I2Bback to summary
private static final EmitterFactory.Emitter E_I2B

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_I2Cback to summary
private static final EmitterFactory.Emitter E_I2C

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_I2Dback to summary
private static final EmitterFactory.Emitter E_I2D

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_I2Fback to summary
private static final EmitterFactory.Emitter E_I2F

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_I2Lback to summary
private static final EmitterFactory.Emitter E_I2L

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_I2Sback to summary
private static final EmitterFactory.Emitter E_I2S

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_L2Bback to summary
private static final EmitterFactory.Emitter E_L2B

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_L2Cback to summary
private static final EmitterFactory.Emitter E_L2C

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_L2Dback to summary
private static final EmitterFactory.Emitter E_L2D

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_L2Fback to summary
private static final EmitterFactory.Emitter E_L2F

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_L2Iback to summary
private static final EmitterFactory.Emitter E_L2I

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_L2Sback to summary
private static final EmitterFactory.Emitter E_L2S

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

E_NOPback to summary
private static final EmitterFactory.Emitter E_NOP

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

ifOpInstructionsback to summary
private static Map<ExpressionFactory.BinaryOperator, Integer> ifOpInstructions
methodNameback to summary
private String methodName
methodSignatureback to summary
private String methodSignature
mvback to summary
private MethodVisitor mv
numericConversionsback to summary
pack-priv EmitterFactory.Emitter[][] numericConversions

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

opInstructionsback to summary
private static Map<ExpressionFactory.BinaryOperator, Map<Type, Integer>> opInstructions
psback to summary
private PrintStream ps
typeIndexback to summary
private static Map<Type, Integer> typeIndex

Constructor Detail

ByteCodeUtilityback to summary
public ByteCodeUtility(ClassWriter cw, ClassGeneratorImpl cg, boolean debug, PrintStream ps)

Construct an instance of ByteCodeUtility from an ASM ClassWriter and a codegen ClassGeneratorImpl. If debug is true, debugText() can be called to get a text representation of the generated code for debugging purposes.

ByteCodeUtilityback to summary
public ByteCodeUtility(ClassWriter cw, ClassGeneratorImpl cg)

Method Detail

addFieldback to summary
public void addField(FieldGenerator arg)
callEmitterback to summary
public void callEmitter(EmitterFactory.Emitter emitter)

References Deprecated

EmitterFactory.Emitter is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

dumpback to summary
private void dump()
emitArrayStoreback to summary
public void emitArrayStore()
emitBinaryOperatorback to summary
public void emitBinaryOperator(ExpressionFactory.BinaryOperatorExpression arg)
emitBooleanCodeForPrimitiveback to summary
private void emitBooleanCodeForPrimitive(ExpressionFactory.BinaryOperatorExpression arg)
emitBooleanCodeForReferenceback to summary
private void emitBooleanCodeForReference(ExpressionFactory.BinaryOperatorExpression arg)
emitBranchback to summary
public void emitBranch(MyLabel target)
emitCastback to summary
public void emitCast(Type from, Type to)
emitConditionalBranchback to summary
public void emitConditionalBranch(MyLabel falseBranch)
emitConstantExpressionback to summary
public void emitConstantExpression(Type type, Object value)
emitConversionback to summary
public void emitConversion(Type from, Type to)
emitDupback to summary
public void emitDup()
emitExceptionTableEntryback to summary
public void emitExceptionTableEntry(Label start, Label end, Label handler, Type exceptionType)
emitInstanceofback to summary
public void emitInstanceof(Type type)
emitInvokeback to summary
public void emitInvoke(Type type, String name, Signature sig)

Emit the appropriate non-static INVOKE instruction as follows:

  1. If type is an interface, emit INVOKEINTERFACE.
  2. If name/sig has private access in type, emit INVOKESPECIAL. Note that the target must be "this" in this case.
  3. Otherwise emit INVOKEVIRTUAL.
emitJsrback to summary
public void emitJsr(Label label)
emitLabelback to summary
public void emitLabel(Attribute<MyLabel> attr, Node node)
emitLineNumberTableback to summary
private void emitLineNumberTable(MethodGenerator mg)
emitLocalVariableTableback to summary
private void emitLocalVariableTable(MethodGenerator mg)
emitMethodEndback to summary
public void emitMethodEnd(MethodGenerator mg, Label returnLabel, Variable returnVariable, boolean dump)
emitMethodStartback to summary
public void emitMethodStart(MethodGenerator mg)
emitNewArrayCallback to summary
public void emitNewArrayCall(Type type)
emitNewCallback to summary
public void emitNewCall(Type type)

Emit the NEW, DUP sequence required at the start of a new call.

emitNewInvokeback to summary
public void emitNewInvoke(Type type, Signature sig)

Emit the INVOKESPECIAL instruction for calling a constructor with the given signature. This is used for new Foo() calls, and for super() and this() calls at the start of a constructor.

emitPopback to summary
public void emitPop()
emitRetback to summary
public void emitRet(Variable var)
emitReturnback to summary
private void emitReturn(Type returnType)
emitSpecialInvokeback to summary
public void emitSpecialInvoke(Type type, String name, Signature sig)

Emit the INVOKESPECIAL instruction for calling a method with the given signature. This is used for for super.name() and this.name() method calls.

emitStaticInvokeback to summary
public void emitStaticInvoke(Type type, String name, Signature sig)

Emit a static INVOKE instruction.

emitThisExpressionback to summary
public void emitThisExpression()
emitThrowback to summary
public void emitThrow()
typeCodeback to summary
public int typeCode(Type type)