Skip to content

Commit 4fe7020

Browse files
committed
Javadoc
1 parent d82b618 commit 4fe7020

File tree

8 files changed

+427
-0
lines changed

8 files changed

+427
-0
lines changed

src/main/java/org/apache/commons/compress/harmony/internal/AttributeLayoutParser.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ private UnionCaseData(final List<IntegerRange> tagRanges, final List<T> body) {
125125
private int p;
126126
private int depth;
127127

128+
/**
129+
* Constructs a new instance.
130+
*
131+
* @param definition the attribute layout definition.
132+
* @param factory the factory for creating layout elements.
133+
*/
128134
public AttributeLayoutParser(final CharSequence definition, final Factory<T> factory) {
129135
this.definition = definition;
130136
this.factory = factory;

src/main/java/org/apache/commons/compress/harmony/pack200/AttributeDefinitionBands.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,39 @@
3535
*/
3636
public class AttributeDefinitionBands extends BandSet {
3737

38+
/**
39+
* An attribute definition with context type, name, and layout information.
40+
*/
3841
public static class AttributeDefinition {
3942

43+
/**
44+
* The index of this attribute definition.
45+
*/
4046
public int index;
47+
48+
/**
49+
* The context type for this attribute definition.
50+
*/
4151
public int contextType;
52+
53+
/**
54+
* The name of this attribute.
55+
*/
4256
public CPUTF8 name;
57+
58+
/**
59+
* The layout of this attribute.
60+
*/
4361
public CPUTF8 layout;
4462

63+
/**
64+
* Constructs a new AttributeDefinition.
65+
*
66+
* @param index the index of the attribute.
67+
* @param contextType the context type.
68+
* @param name the attribute name.
69+
* @param layout the attribute layout.
70+
*/
4571
public AttributeDefinition(final int index, final int contextType, final CPUTF8 name, final CPUTF8 layout) {
4672
this.index = index;
4773
this.contextType = contextType;
@@ -82,6 +108,13 @@ public AttributeDefinition(final int index, final int contextType, final CPUTF8
82108

83109
private final Segment segment;
84110

111+
/**
112+
* Constructs a new instance.
113+
*
114+
* @param segment the segment.
115+
* @param effort the effort level.
116+
* @param attributePrototypes the attribute prototypes.
117+
*/
85118
public AttributeDefinitionBands(final Segment segment, final int effort, final Attribute[] attributePrototypes) {
86119
super(effort, segment.getSegmentHeader());
87120
this.cpBands = segment.getCpBands();
@@ -203,18 +236,38 @@ public void finaliseBands() {
203236
segmentHeader.setAttribute_definition_count(attributeDefinitions.size());
204237
}
205238

239+
/**
240+
* Gets the class attribute layouts.
241+
*
242+
* @return the class attribute layouts.
243+
*/
206244
public List<AttributeDefinition> getClassAttributeLayouts() {
207245
return classAttributeLayouts;
208246
}
209247

248+
/**
249+
* Gets the code attribute layouts.
250+
*
251+
* @return the code attribute layouts.
252+
*/
210253
public List<AttributeDefinition> getCodeAttributeLayouts() {
211254
return codeAttributeLayouts;
212255
}
213256

257+
/**
258+
* Gets the field attribute layouts.
259+
*
260+
* @return the field attribute layouts.
261+
*/
214262
public List<AttributeDefinition> getFieldAttributeLayouts() {
215263
return fieldAttributeLayouts;
216264
}
217265

266+
/**
267+
* Gets the method attribute layouts.
268+
*
269+
* @return the method attribute layouts.
270+
*/
218271
public List<AttributeDefinition> getMethodAttributeLayouts() {
219272
return methodAttributeLayouts;
220273
}

src/main/java/org/apache/commons/compress/harmony/pack200/BandSet.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ public boolean wellCorrelated() {
195195
// Note: these values have been tuned - please test carefully if changing them
196196
private static final int[] effortThresholds = { 0, 0, 1000, 500, 100, 100, 100, 100, 100, 0 };
197197

198+
/**
199+
* The segment header for this band set.
200+
*/
198201
protected final SegmentHeader segmentHeader;
199202
final int effort;
200203

@@ -486,6 +489,17 @@ protected byte[] encodeFlags(final String name, final long[] flags, final BHSDCo
486489
// }
487490
// }
488491

492+
/**
493+
* Encodes flags using the given codecs.
494+
*
495+
* @param name the name of the band.
496+
* @param flags the flags to encode.
497+
* @param loCodec the low codec.
498+
* @param hiCodec the high codec.
499+
* @param haveHiFlags whether high flags are present.
500+
* @return the encoded flags.
501+
* @throws Pack200Exception if an error occurs.
502+
*/
489503
protected byte[] encodeFlags(final String name, final long[][] flags, final BHSDCodec loCodec, final BHSDCodec hiCodec, final boolean haveHiFlags)
490504
throws Pack200Exception {
491505
return encodeFlags(name, flatten(flags), loCodec, hiCodec, haveHiFlags);

src/main/java/org/apache/commons/compress/harmony/pack200/BcBands.java

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ public class BcBands extends BandSet {
8585
private int renumberedOffset;
8686
private final IntList bcLabelRelativeOffsets = new IntList();
8787

88+
/**
89+
* Constructs a new instance.
90+
*
91+
* @param cpBands the constant pool bands
92+
* @param segment the segment
93+
* @param effort the packing effort
94+
*/
8895
public BcBands(final CpBands cpBands, final Segment segment, final int effort) {
8996
super(effort, segment.getSegmentHeader());
9097
this.cpBands = cpBands;
@@ -222,6 +229,9 @@ private void updateRenumbering() {
222229
bciRenumbering.add(renumberedOffset);
223230
}
224231

232+
/**
233+
* Visits the end of a method's bytecode.
234+
*/
225235
public void visitEnd() {
226236
for (int i = 0; i < bciRenumbering.size(); i++) {
227237
if (bciRenumbering.get(i) == -1) {
@@ -254,6 +264,14 @@ public void visitEnd() {
254264
}
255265
}
256266

267+
/**
268+
* Visits a field instruction.
269+
*
270+
* @param opcode the opcode.
271+
* @param owner the field owner class.
272+
* @param name the field name.
273+
* @param desc the field descriptor.
274+
*/
257275
public void visitFieldInsn(int opcode, final String owner, final String name, final String desc) {
258276
byteCodeOffset += 3;
259277
updateRenumbering();
@@ -285,6 +303,12 @@ public void visitFieldInsn(int opcode, final String owner, final String name, fi
285303
bcCodes.add(opcode);
286304
}
287305

306+
/**
307+
* Visits an IINC instruction.
308+
*
309+
* @param var the local variable index.
310+
* @param increment the increment amount.
311+
*/
288312
public void visitIincInsn(final int var, final int increment) {
289313
if (var > 255 || increment > 255) {
290314
byteCodeOffset += 6;
@@ -301,6 +325,11 @@ public void visitIincInsn(final int var, final int increment) {
301325
updateRenumbering();
302326
}
303327

328+
/**
329+
* Visits a simple instruction (no operands).
330+
*
331+
* @param opcode the opcode.
332+
*/
304333
public void visitInsn(final int opcode) {
305334
if (opcode >= 202) {
306335
throw new IllegalArgumentException("Non-standard bytecode instructions not supported");
@@ -310,6 +339,12 @@ public void visitInsn(final int opcode) {
310339
updateRenumbering();
311340
}
312341

342+
/**
343+
* Visits an instruction with a single int operand.
344+
*
345+
* @param opcode the opcode.
346+
* @param operand the operand.
347+
*/
313348
public void visitIntInsn(final int opcode, final int operand) {
314349
switch (opcode) {
315350
case 17: // sipush
@@ -326,6 +361,12 @@ public void visitIntInsn(final int opcode, final int operand) {
326361
updateRenumbering();
327362
}
328363

364+
/**
365+
* Visits a jump instruction.
366+
*
367+
* @param opcode the opcode.
368+
* @param label the target label.
369+
*/
329370
public void visitJumpInsn(final int opcode, final Label label) {
330371
bcCodes.add(opcode);
331372
bcLabel.add(label);
@@ -334,10 +375,20 @@ public void visitJumpInsn(final int opcode, final Label label) {
334375
updateRenumbering();
335376
}
336377

378+
/**
379+
* Visits a label.
380+
*
381+
* @param label the label.
382+
*/
337383
public void visitLabel(final Label label) {
338384
labelsToOffsets.put(label, Integer.valueOf(byteCodeOffset));
339385
}
340386

387+
/**
388+
* Visits an LDC instruction.
389+
*
390+
* @param cst the constant to load.
391+
*/
341392
public void visitLdcInsn(final Object cst) {
342393
final CPConstant<?> constant = cpBands.getConstant(cst);
343394
if (segment.lastConstantHadWideIndex() || constant instanceof CPLong || constant instanceof CPDouble) {
@@ -382,6 +433,13 @@ public void visitLdcInsn(final Object cst) {
382433
updateRenumbering();
383434
}
384435

436+
/**
437+
* Visits a LOOKUPSWITCH instruction.
438+
*
439+
* @param dflt the default label.
440+
* @param keys the case keys.
441+
* @param labels the case labels.
442+
*/
385443
public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels) {
386444
bcCodes.add(LOOKUPSWITCH);
387445
bcLabel.add(dflt);
@@ -397,6 +455,14 @@ public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Labe
397455
updateRenumbering();
398456
}
399457

458+
/**
459+
* Visits a method invocation instruction.
460+
*
461+
* @param opcode the opcode.
462+
* @param owner the method owner class.
463+
* @param name the method name.
464+
* @param desc the method descriptor.
465+
*/
400466
public void visitMethodInsn(int opcode, final String owner, final String name, final String desc) {
401467
byteCodeOffset += 3;
402468
switch (opcode) {
@@ -455,6 +521,12 @@ public void visitMethodInsn(int opcode, final String owner, final String name, f
455521
updateRenumbering();
456522
}
457523

524+
/**
525+
* Visits a MULTIANEWARRAY instruction.
526+
*
527+
* @param desc the array type descriptor.
528+
* @param dimensions the number of dimensions.
529+
*/
458530
public void visitMultiANewArrayInsn(final String desc, final int dimensions) {
459531
byteCodeOffset += 4;
460532
updateRenumbering();
@@ -463,6 +535,14 @@ public void visitMultiANewArrayInsn(final String desc, final int dimensions) {
463535
bcByte.add(dimensions & 0xFF);
464536
}
465537

538+
/**
539+
* Visits a TABLESWITCH instruction.
540+
*
541+
* @param min the minimum key value.
542+
* @param max the maximum key value.
543+
* @param dflt the default label.
544+
* @param labels the case labels.
545+
*/
466546
public void visitTableSwitchInsn(final int min, final int max, final Label dflt, final Label... labels) {
467547
bcCodes.add(TABLESWITCH);
468548
bcLabel.add(dflt);
@@ -479,6 +559,12 @@ public void visitTableSwitchInsn(final int min, final int max, final Label dflt,
479559
updateRenumbering();
480560
}
481561

562+
/**
563+
* Visits a type instruction.
564+
*
565+
* @param opcode the opcode (NEW, ANEWARRAY, CHECKCAST, or INSTANCEOF).
566+
* @param type the type descriptor.
567+
*/
482568
public void visitTypeInsn(final int opcode, final String type) {
483569
// NEW, ANEWARRAY, CHECKCAST or INSTANCEOF
484570
byteCodeOffset += 3;
@@ -490,6 +576,12 @@ public void visitTypeInsn(final int opcode, final String type) {
490576
}
491577
}
492578

579+
/**
580+
* Visits a local variable instruction.
581+
*
582+
* @param opcode the opcode.
583+
* @param var the local variable index.
584+
*/
493585
public void visitVarInsn(final int opcode, final int var) {
494586
// ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET
495587
if (var > 255) {

0 commit comments

Comments
 (0)