View Javadoc
1   package mockit.asm.classes;
2   
3   import edu.umd.cs.findbugs.annotations.NonNull;
4   
5   import mockit.asm.constantPool.AttributeWriter;
6   import mockit.asm.constantPool.ConstantPoolGeneration;
7   import mockit.asm.util.ByteVector;
8   
9   import org.checkerframework.checker.index.qual.NonNegative;
10  
11  /**
12   * Writes out into the constant pool the item index containing the name of the source file from which the class was
13   * compiled.
14   */
15  final class SourceFileWriter extends AttributeWriter {
16      @NonNegative
17      private final int sourceFileIndex;
18  
19      SourceFileWriter(@NonNull ConstantPoolGeneration cp, @NonNull String fileName) {
20          super(cp, "SourceFile");
21          sourceFileIndex = cp.newUTF8(fileName);
22      }
23  
24      @NonNegative
25      @Override
26      public int getSize() {
27          return 8;
28      }
29  
30      @Override
31      public void put(@NonNull ByteVector out) {
32          super.put(out);
33          out.putShort(sourceFileIndex);
34      }
35  }