< prev index next >

src/java.base/share/classes/jdk/internal/classfile/impl/AbstractAttributeMapper.java

Print this page

294         private LineNumberTableMapper() {
295             super(NAME_LINE_NUMBER_TABLE, AttributeStability.LABELS, true);
296         }
297 
298         @Override
299         public LineNumberTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
300             return new BoundAttribute.BoundLineNumberTableAttribute(cf, this, p);
301         }
302 
303         @Override
304         protected void writeBody(BufWriter bufWriter, LineNumberTableAttribute attr) {
305             List<LineNumberInfo> lines = attr.lineNumbers();
306             BufWriterImpl buf = (BufWriterImpl) bufWriter;
307             buf.writeU2(lines.size());
308             for (LineNumberInfo line : lines) {
309                 buf.writeU2U2(line.startPc(), line.lineNumber());
310             }
311         }
312     }
313 


















314     public static final class LocalVariableTableMapper extends AbstractAttributeMapper<LocalVariableTableAttribute> {
315         public static final LocalVariableTableMapper INSTANCE = new LocalVariableTableMapper();
316 
317         private LocalVariableTableMapper() {
318             super(NAME_LOCAL_VARIABLE_TABLE, AttributeStability.LABELS, true);
319         }
320 
321         @Override
322         public LocalVariableTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
323             return new BoundAttribute.BoundLocalVariableTableAttribute(e, cf, this, p);
324         }
325 
326         @Override
327         protected void writeBody(BufWriter bufWriter, LocalVariableTableAttribute attr) {
328             List<LocalVariableInfo> infos = attr.localVariables();
329             BufWriterImpl buf = (BufWriterImpl) bufWriter;
330             buf.writeU2(infos.size());
331             for (LocalVariableInfo info : infos) {
332                 buf.writeU2U2(info.startPc(), info.length());
333                 buf.writeU2U2U2(buf.cpIndex(info.name()), buf.cpIndex(info.type()), info.slot());

294         private LineNumberTableMapper() {
295             super(NAME_LINE_NUMBER_TABLE, AttributeStability.LABELS, true);
296         }
297 
298         @Override
299         public LineNumberTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
300             return new BoundAttribute.BoundLineNumberTableAttribute(cf, this, p);
301         }
302 
303         @Override
304         protected void writeBody(BufWriter bufWriter, LineNumberTableAttribute attr) {
305             List<LineNumberInfo> lines = attr.lineNumbers();
306             BufWriterImpl buf = (BufWriterImpl) bufWriter;
307             buf.writeU2(lines.size());
308             for (LineNumberInfo line : lines) {
309                 buf.writeU2U2(line.startPc(), line.lineNumber());
310             }
311         }
312     }
313 
314     public static final class LoadableDescriptorsMapper extends AbstractAttributeMapper<LoadableDescriptorsAttribute> {
315         public static final LoadableDescriptorsMapper INSTANCE = new LoadableDescriptorsMapper();
316 
317         private LoadableDescriptorsMapper() {
318             super(NAME_LOADABLE_DESCRIPTORS, AttributeStability.CP_REFS);
319         }
320 
321         @Override
322         public LoadableDescriptorsAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
323             return new BoundAttribute.BoundLoadableDescriptorsAttribute(cf, this, p);
324         }
325 
326         @Override
327         protected void writeBody(BufWriter buf, LoadableDescriptorsAttribute attr) {
328             Util.writeListIndices(buf, attr.loadableDescriptors());
329         }
330     }
331 
332     public static final class LocalVariableTableMapper extends AbstractAttributeMapper<LocalVariableTableAttribute> {
333         public static final LocalVariableTableMapper INSTANCE = new LocalVariableTableMapper();
334 
335         private LocalVariableTableMapper() {
336             super(NAME_LOCAL_VARIABLE_TABLE, AttributeStability.LABELS, true);
337         }
338 
339         @Override
340         public LocalVariableTableAttribute readAttribute(AttributedElement e, ClassReader cf, int p) {
341             return new BoundAttribute.BoundLocalVariableTableAttribute(e, cf, this, p);
342         }
343 
344         @Override
345         protected void writeBody(BufWriter bufWriter, LocalVariableTableAttribute attr) {
346             List<LocalVariableInfo> infos = attr.localVariables();
347             BufWriterImpl buf = (BufWriterImpl) bufWriter;
348             buf.writeU2(infos.size());
349             for (LocalVariableInfo info : infos) {
350                 buf.writeU2U2(info.startPc(), info.length());
351                 buf.writeU2U2U2(buf.cpIndex(info.name()), buf.cpIndex(info.type()), info.slot());
< prev index next >