Top Description Inners Fields Constructors Methods
com.google.inject.internal.util

pack-priv final Class LineNumbers

extends Object
Class Inheritance
Static Imports
com.google.common.base.Preconditions.checkNotNull

Looks up line numbers for classes and their members.
Author
Chris Nokleberg

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static volatile boolean
private static final int
private int
private final Map<String, Integer>
private static final Logger
private String
private final Class<?>

Constructor Summary

AccessConstructor and Description
public
LineNumbers(Class<?>
the class to read line number information from
type
)

Reads line number information from the given class, if available.

Method Summary

Modifier and TypeMethod and Description
public int
getFirstLine()

Gets the first line number.

public Integer

Returns:

the wrapped line number, or null if not available
getLineNumber
(Member
a field, constructor, or method belonging to the class used during construction
member
)

Get the line number associated with the given member.

public String

Returns:

the source file name if available, or null
getSource
()

Get the source file name as read from the bytecode.

private String
memberKey(Member member)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alreadyLoggedReadingFailureback to summary
private static volatile boolean alreadyLoggedReadingFailure
ASM_API_LEVELback to summary
private static final int ASM_API_LEVEL
firstLineback to summary
private int firstLine
linesback to summary
private final Map<String, Integer> lines
loggerback to summary
private static final Logger logger
sourceback to summary
private String source
typeback to summary
private final Class<?> type

Constructor Detail

LineNumbersback to summary
public LineNumbers(Class<?> type) throws IOException

Reads line number information from the given class, if available.

Parameters
type:Class<?>

the class to read line number information from

Method Detail

getFirstLineback to summary
public int getFirstLine()

Gets the first line number.

getLineNumberback to summary
public Integer getLineNumber(Member member)

Get the line number associated with the given member.

Parameters
member:Member

a field, constructor, or method belonging to the class used during construction

Returns:Integer

the wrapped line number, or null if not available

Exceptions
IllegalArgumentException:
if the member does not belong to the class used during construction
getSourceback to summary
public String getSource()

Get the source file name as read from the bytecode.

Returns:String

the source file name if available, or null

memberKeyback to summary
private String memberKey(Member member)
com.google.inject.internal.util back to summary

private Class LineNumbers.LineNumberReader

extends ClassVisitor
Class Inheritance

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
private int
private String
private String
Inherited from org.objectweb.asm.ClassVisitor:
apicv

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
visit(int
the class version. The minor version is stored in the 16 most significant bits, and the major version in the 16 least significant bits.
version
,
int
the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated Opcodes#ACC_DEPRECATED or a record Opcodes#ACC_RECORD.
access
,
String
the internal name of the class (see Type#getInternalName()).
name
,
String
the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.
signature
,
String
the internal of name of the super class (see Type#getInternalName()). For interfaces, the super class is Object. May be null, but only for the Object class.
superName
,
String[]
the internal names of the class's interfaces (see Type#getInternalName()). May be null.
interfaces
)

Overrides org.objectweb.asm.ClassVisitor.visit.

Visits the header of the class.
public AnnotationVisitor
visitAnnotation(String
the class descriptor of the annotation class.
desc
,
boolean
true if the annotation is visible at runtime.
visible
)

Overrides org.objectweb.asm.ClassVisitor.visitAnnotation.

Visits an annotation of the class.
public FieldVisitor
visitField(int
the field's access flags (see Opcodes). This parameter also indicates if the field is synthetic and/or deprecated.
access
,
String
the field's name.
name
,
String
the field's descriptor (see Type).
desc
,
String
the field's signature. May be null if the field's type does not use generic types.
signature
,
Object
the field's initial value. This parameter, which may be null if the field does not have an initial value, must be an Integer, a Float, a Long, a Double or a String (for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.
value
)

Overrides org.objectweb.asm.ClassVisitor.visitField.

Visits a field of the class.
public void
visitLineNumber(int line, Label start)

public MethodVisitor
visitMethod(int
the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.
access
,
String
the method's name.
name
,
String
the method's descriptor (see Type).
desc
,
String
the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.
signature
,
String[]
the internal names of the method's exception classes (see Type#getInternalName()). May be null.
exceptions
)

Overrides org.objectweb.asm.ClassVisitor.visitMethod.

Visits a method of the class.
public AnnotationVisitor
visitParameterAnnotation(int parameter, String desc, boolean visible)

public void
visitSource(String
the name of the source file from which the class was compiled. May be null.
source
,
String
additional debug information to compute the correspondence between source and compiled elements of the class. May be null.
debug
)

Overrides org.objectweb.asm.ClassVisitor.visitSource.

Visits the source of the class.
Inherited from org.objectweb.asm.ClassVisitor:
getDelegatevisitAttributevisitEndvisitInnerClassvisitModulevisitNestHostvisitNestMembervisitOuterClassvisitPermittedSubclassvisitRecordComponentvisitTypeAnnotation

Field Detail

lineback to summary
private int line
nameback to summary
private String name
pendingMethodback to summary
private String pendingMethod

Constructor Detail

LineNumberReaderback to summary
pack-priv LineNumberReader()

Method Detail

visitback to summary
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)

Overrides org.objectweb.asm.ClassVisitor.visit.

Doc from org.objectweb.asm.ClassVisitor.visit.

Visits the header of the class.

Parameters
version:int

the class version. The minor version is stored in the 16 most significant bits, and the major version in the 16 least significant bits.

access:int

the class's access flags (see Opcodes). This parameter also indicates if the class is deprecated Opcodes#ACC_DEPRECATED or a record Opcodes#ACC_RECORD.

name:String

the internal name of the class (see Type#getInternalName()).

signature:String

the signature of this class. May be null if the class is not a generic one, and does not extend or implement generic classes or interfaces.

superName:String

the internal of name of the super class (see Type#getInternalName()). For interfaces, the super class is Object. May be null, but only for the Object class.

interfaces:String[]

the internal names of the class's interfaces (see Type#getInternalName()). May be null.

Annotations
@Override
visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String desc, boolean visible)

Overrides org.objectweb.asm.ClassVisitor.visitAnnotation.

Doc from org.objectweb.asm.ClassVisitor.visitAnnotation.

Visits an annotation of the class.

Parameters
desc:String

the class descriptor of the annotation class.

visible:boolean

true if the annotation is visible at runtime.

Returns:AnnotationVisitor

a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.

Annotations
@Override
visitFieldback to summary
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)

Overrides org.objectweb.asm.ClassVisitor.visitField.

Doc from org.objectweb.asm.ClassVisitor.visitField.

Visits a field of the class.

Parameters
access:int

the field's access flags (see Opcodes). This parameter also indicates if the field is synthetic and/or deprecated.

name:String

the field's name.

desc:String

the field's descriptor (see Type).

signature:String

the field's signature. May be null if the field's type does not use generic types.

value:Object

the field's initial value. This parameter, which may be null if the field does not have an initial value, must be an Integer, a Float, a Long, a Double or a String (for int, float, long or String fields respectively). This parameter is only used for static fields. Its value is ignored for non static fields, which must be initialized through bytecode instructions in constructors or methods.

Returns:FieldVisitor

a visitor to visit field annotations and attributes, or null if this class visitor is not interested in visiting these annotations and attributes.

Annotations
@Override
visitLineNumberback to summary
public void visitLineNumber(int line, Label start)
visitMethodback to summary
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)

Overrides org.objectweb.asm.ClassVisitor.visitMethod.

Doc from org.objectweb.asm.ClassVisitor.visitMethod.

Visits a method of the class. This method must return a new MethodVisitor instance (or null) each time it is called, i.e., it should not return a previously returned visitor.

Parameters
access:int

the method's access flags (see Opcodes). This parameter also indicates if the method is synthetic and/or deprecated.

name:String

the method's name.

desc:String

the method's descriptor (see Type).

signature:String

the method's signature. May be null if the method parameters, return type and exceptions do not use generic types.

exceptions:String[]

the internal names of the method's exception classes (see Type#getInternalName()). May be null.

Returns:MethodVisitor

an object to visit the byte code of the method, or null if this class visitor is not interested in visiting the code of this method.

Annotations
@Override
visitParameterAnnotationback to summary
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible)
visitSourceback to summary
public void visitSource(String source, String debug)

Overrides org.objectweb.asm.ClassVisitor.visitSource.

Doc from org.objectweb.asm.ClassVisitor.visitSource.

Visits the source of the class.

Parameters
source:String

the name of the source file from which the class was compiled. May be null.

debug:String

additional debug information to compute the correspondence between source and compiled elements of the class. May be null.

Annotations
@Override
com.google.inject.internal.util back to summary

pack-priv Class LineNumbers.LineNumberReader.LineNumberAnnotationVisitor

extends AnnotationVisitor
Class Inheritance

Field Summary

Inherited from org.objectweb.asm.AnnotationVisitor:
apiav

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public AnnotationVisitor
visitAnnotation(String
the value name.
name
,
String
the class descriptor of the nested annotation class.
desc
)

Overrides org.objectweb.asm.AnnotationVisitor.visitAnnotation.

Visits a nested annotation value of the annotation.
public AnnotationVisitor
visitArray(String
the value name.
name
)

Overrides org.objectweb.asm.AnnotationVisitor.visitArray.

Visits an array value of the annotation.
public void
visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)

Inherited from org.objectweb.asm.AnnotationVisitor:
getDelegatevisitvisitEndvisitEnum

Constructor Detail

LineNumberAnnotationVisitorback to summary
pack-priv LineNumberAnnotationVisitor()

Method Detail

visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String name, String desc)

Overrides org.objectweb.asm.AnnotationVisitor.visitAnnotation.

Doc from org.objectweb.asm.AnnotationVisitor.visitAnnotation.

Visits a nested annotation value of the annotation.

Parameters
name:String

the value name.

desc:String

the class descriptor of the nested annotation class.

Returns:AnnotationVisitor

a visitor to visit the actual nested annotation value, or null if this visitor is not interested in visiting this nested annotation. The nested annotation value must be fully visited before calling other methods on this annotation visitor.

Annotations
@Override
visitArrayback to summary
public AnnotationVisitor visitArray(String name)

Overrides org.objectweb.asm.AnnotationVisitor.visitArray.

Doc from org.objectweb.asm.AnnotationVisitor.visitArray.

Visits an array value of the annotation. Note that arrays of primitive values (such as byte, boolean, short, char, int, long, float or double) can be passed as value to visit. This is what ClassReader does for non empty arrays of primitive values.

Parameters
name:String

the value name.

Returns:AnnotationVisitor

a visitor to visit the actual array value elements, or null if this visitor is not interested in visiting these values. The 'name' parameters passed to the methods of this visitor are ignored. All the array values must be visited before calling other methods on this annotation visitor.

Annotations
@Override
visitLocalVariableback to summary
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index)
com.google.inject.internal.util back to summary

pack-priv Class LineNumbers.LineNumberReader.LineNumberMethodVisitor

extends MethodVisitor
Class Inheritance

Field Summary

Inherited from org.objectweb.asm.MethodVisitor:
apimv

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public AnnotationVisitor
visitAnnotation(String
the class descriptor of the annotation class.
desc
,
boolean
true if the annotation is visible at runtime.
visible
)

Overrides org.objectweb.asm.MethodVisitor.visitAnnotation.

Visits an annotation of this method.
public AnnotationVisitor
visitAnnotationDefault()

Overrides org.objectweb.asm.MethodVisitor.visitAnnotationDefault.

Visits the default value of this annotation interface method.
public void
visitFieldInsn(int
the opcode of the type instruction to be visited. This opcode is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
opcode
,
String
the internal name of the field's owner class (see Type#getInternalName()).
owner
,
String
the field's name.
name
,
String
the field's descriptor (see Type).
desc
)

Overrides org.objectweb.asm.MethodVisitor.visitFieldInsn.

Visits a field instruction.
public void
visitLineNumber(int
a line number. This number refers to the source file from which the class was compiled.
line
,
Label
the first instruction corresponding to this line number.
start
)

Overrides org.objectweb.asm.MethodVisitor.visitLineNumber.

Visits a line number declaration.
Inherited from org.objectweb.asm.MethodVisitor:
getDelegatevisitAnnotableParameterCountvisitAttributevisitCodevisitEndvisitFramevisitIincInsnvisitInsnvisitInsnAnnotationvisitIntInsnvisitInvokeDynamicInsnvisitJumpInsnvisitLabelvisitLdcInsnvisitLocalVariablevisitLocalVariableAnnotationvisitLookupSwitchInsnvisitMaxsvisitMethodInsnvisitMethodInsnvisitMultiANewArrayInsnvisitParametervisitParameterAnnotationvisitTableSwitchInsnvisitTryCatchAnnotationvisitTryCatchBlockvisitTypeAnnotationvisitTypeInsnvisitVarInsn

Constructor Detail

LineNumberMethodVisitorback to summary
pack-priv LineNumberMethodVisitor()

Method Detail

visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String desc, boolean visible)

Overrides org.objectweb.asm.MethodVisitor.visitAnnotation.

Doc from org.objectweb.asm.MethodVisitor.visitAnnotation.

Visits an annotation of this method.

Parameters
desc:String

the class descriptor of the annotation class.

visible:boolean

true if the annotation is visible at runtime.

Returns:AnnotationVisitor

a visitor to visit the annotation values, or null if this visitor is not interested in visiting this annotation.

Annotations
@Override
visitAnnotationDefaultback to summary
public AnnotationVisitor visitAnnotationDefault()

Overrides org.objectweb.asm.MethodVisitor.visitAnnotationDefault.

Doc from org.objectweb.asm.MethodVisitor.visitAnnotationDefault.

Visits the default value of this annotation interface method.

Returns:AnnotationVisitor

a visitor to the visit the actual default value of this annotation interface method, or null if this visitor is not interested in visiting this default value. The 'name' parameters passed to the methods of this annotation visitor are ignored. Moreover, exactly one visit method must be called on this annotation visitor, followed by visitEnd.

Annotations
@Override
visitFieldInsnback to summary
public void visitFieldInsn(int opcode, String owner, String name, String desc)

Overrides org.objectweb.asm.MethodVisitor.visitFieldInsn.

Doc from org.objectweb.asm.MethodVisitor.visitFieldInsn.

Visits a field instruction. A field instruction is an instruction that loads or stores the value of a field of an object.

Parameters
opcode:int

the opcode of the type instruction to be visited. This opcode is either GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.

owner:String

the internal name of the field's owner class (see Type#getInternalName()).

name:String

the field's name.

desc:String

the field's descriptor (see Type).

Annotations
@Override
visitLineNumberback to summary
public void visitLineNumber(int line, Label start)

Overrides org.objectweb.asm.MethodVisitor.visitLineNumber.

Doc from org.objectweb.asm.MethodVisitor.visitLineNumber.

Visits a line number declaration.

Parameters
line:int

a line number. This number refers to the source file from which the class was compiled.

start:Label

the first instruction corresponding to this line number.

Annotations
@Override