mockit.asm.methods.LineNumberTableWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmockit Show documentation
Show all versions of jmockit Show documentation
JMockit is a Java toolkit for automated developer testing.
It contains APIs for the creation of the objects to be tested, for mocking dependencies, and for faking external
APIs; JUnit (4 & 5) and TestNG test runners are supported.
It also contains an advanced code coverage tool.
The newest version!
package mockit.asm.methods;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import mockit.asm.constantPool.AttributeWriter;
import mockit.asm.constantPool.ConstantPoolGeneration;
import mockit.asm.controlFlow.Label;
import mockit.asm.util.ByteVector;
import org.checkerframework.checker.index.qual.NonNegative;
/**
* Writes the bytecode for the "LineNumberTable" method code attribute.
*/
final class LineNumberTableWriter extends AttributeWriter {
/**
* Number of entries in the LineNumberTable
attribute.
*/
@NonNegative
private int lineNumberCount;
/**
* The LineNumberTable
attribute.
*/
@Nullable
private ByteVector lineNumbers;
LineNumberTableWriter(@NonNull ConstantPoolGeneration cp) {
super(cp);
}
void addLineNumber(@NonNegative int line, @NonNull Label start) {
if (lineNumbers == null) {
setAttribute("LineNumberTable");
lineNumbers = new ByteVector();
}
lineNumberCount++;
lineNumbers.putShort(start.position);
lineNumbers.putShort(line);
}
boolean hasLineNumbers() {
return lineNumbers != null;
}
@NonNegative
@Override
public int getSize() {
return lineNumbers == null ? 0 : 8 + lineNumbers.getLength();
}
@Override
public void put(@NonNull ByteVector out) {
if (lineNumbers != null) {
put(out, 2 + lineNumbers.getLength());
out.putShort(lineNumberCount);
out.putByteVector(lineNumbers);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy