Skip to content

Commit 73e8427

Browse files
committed
Javadoc
1 parent 8485c2d commit 73e8427

49 files changed

Lines changed: 275 additions & 57 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/examples/HelloWorldBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ public static void main(final String[] argv) {
7979

8080
// Create BufferedReader object and store it in local variable 'in'.
8181
il.append(factory.createNew("java.io.BufferedReader"));
82-
il.append(InstructionConst.DUP); // Use predefined constant, i.e. flyweight
82+
il.append(InstructionConst.DUP); // Use predefined constant, for example flyweight
8383
il.append(factory.createNew("java.io.InputStreamReader"));
8484
il.append(InstructionConst.DUP);
8585
il.append(factory.createFieldAccess("java.lang.System", "in", iStream, Const.GETSTATIC));
8686

87-
// Call constructors, i.e. BufferedReader(InputStreamReader())
87+
// Call constructors, for example BufferedReader(InputStreamReader())
8888
il.append(factory.createInvoke("java.io.InputStreamReader", "<init>", Type.VOID, new Type[] {iStream}, Const.INVOKESPECIAL));
8989
il.append(factory.createInvoke("java.io.BufferedReader", "<init>", Type.VOID, new Type[] {new ObjectType("java.io.Reader")}, Const.INVOKESPECIAL));
9090

@@ -147,7 +147,7 @@ public static void main(final String[] argv) {
147147

148148
il.dispose(); // Reuse instruction handles
149149

150-
// Add public <init> method, i.e. empty constructor
150+
// Add public <init> method, for example empty constructor
151151
cg.addEmptyConstructor(Const.ACC_PUBLIC);
152152

153153
// Get JavaClass object and dump it to file.

src/examples/JasminVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public void visitCode(final Code code) {
160160
final InstructionHandle[] ihs = il.getInstructionHandles();
161161

162162
/*
163-
* Pass 1: Give all referenced instruction handles a symbolic name, i.e. a label.
163+
* Pass 1: Give all referenced instruction handles a symbolic name, for example a label.
164164
*/
165165
map = new Hashtable<>();
166166

src/examples/Mini/ASTExpr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
/**
4040
* Represents arithmetic expressions such as '(a + 12 == b) OR c'. The parse tree is built initially by the parser and
41-
* modified, i.e. compacted with 'traverse()'. Each (Expr, Term, Factor) node with kind == -1 is replaced which its
41+
* modified, for example compacted with 'traverse()'. Each (Expr, Term, Factor) node with kind == -1 is replaced which its
4242
* successor node, which is converted to type 'Expr'
4343
*
4444
* A node with kind == -1 denotes the fact that this expression node has just one child branch and thus may be replaced

src/examples/Mini/ASTIfExpr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void byte_code(final InstructionList il, final MethodGen method, final Co
6363

6464
BranchHandle i, g;
6565

66-
i = il.append(new IFEQ(null)); // If POP() == FALSE(i.e. 0) then branch to ELSE
66+
i = il.append(new IFEQ(null)); // If POP() == FALSE(for example 0) then branch to ELSE
6767
ASTFunDecl.pop();
6868
il.append(then_code);
6969
g = il.append(new GOTO(null));

src/examples/Mini/ASTProgram.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public void eval(final int pass) {
258258
/**
259259
* First pass of parse tree.
260260
*
261-
* Put everything into the environment, which is copied appropriately to each recursion level, i.e. each FunDecl gets its
261+
* Put everything into the environment, which is copied appropriately to each recursion level, for example each FunDecl gets its
262262
* own copy that it can further manipulate.
263263
*
264264
* Checks for name clashes of function declarations.

src/main/java/org/apache/bcel/classfile/AnnotationDefault.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,18 @@ public final void dump(final DataOutputStream dos) throws IOException {
7979
}
8080

8181
/**
82-
* @return the default value
82+
* Gets the default value.
83+
*
84+
* @return the default value.
8385
*/
8486
public final ElementValue getDefaultValue() {
8587
return defaultValue;
8688
}
8789

8890
/**
89-
* @param defaultValue the default value of this methodinfo's annotation
91+
* Sets the default value of this methodinfo's annotation.
92+
*
93+
* @param defaultValue the default value of this methodinfo's annotation.
9094
*/
9195
public final void setDefaultValue(final ElementValue defaultValue) {
9296
this.defaultValue = defaultValue;

src/main/java/org/apache/bcel/classfile/AnnotationElementValue.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,21 @@
2222
import java.io.IOException;
2323

2424
/**
25+
* Represents an annotation element value.
26+
*
2527
* @since 6.0
2628
*/
2729
public class AnnotationElementValue extends ElementValue {
2830
// For annotation element values, this is the annotation
2931
private final AnnotationEntry annotationEntry;
3032

33+
/**
34+
* Constructs an AnnotationElementValue.
35+
*
36+
* @param type the type.
37+
* @param annotationEntry the annotation entry.
38+
* @param cpool the constant pool.
39+
*/
3140
public AnnotationElementValue(final int type, final AnnotationEntry annotationEntry, final ConstantPool cpool) {
3241
super(type, cpool);
3342
if (type != ANNOTATION) {
@@ -42,6 +51,11 @@ public void dump(final DataOutputStream dos) throws IOException {
4251
annotationEntry.dump(dos);
4352
}
4453

54+
/**
55+
* Gets the annotation entry.
56+
*
57+
* @return the annotation entry.
58+
*/
4559
public AnnotationEntry getAnnotationEntry() {
4660
return annotationEntry;
4761
}

src/main/java/org/apache/bcel/classfile/AnnotationEntry.java

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public static AnnotationEntry[] createAnnotationEntries(final Attribute[] attrib
4343
}
4444

4545
/**
46-
* Factory method to create an AnnotionEntry from a DataInput
46+
* Factory method to create an AnnotionEntry from a DataInput.
4747
*
48-
* @param input
49-
* @param constantPool
50-
* @param isRuntimeVisible
51-
* @return the entry
48+
* @param input the input stream.
49+
* @param constantPool the constant pool.
50+
* @param isRuntimeVisible whether the annotation is runtime visible.
51+
* @return the entry.
5252
* @throws IOException if an I/O error occurs.
5353
*/
5454
public static AnnotationEntry read(final DataInput input, final ConstantPool constantPool, final boolean isRuntimeVisible) throws IOException {
@@ -87,10 +87,21 @@ public void accept(final Visitor v) {
8787
v.visitAnnotationEntry(this);
8888
}
8989

90+
/**
91+
* Adds an element name value pair.
92+
*
93+
* @param elementNameValuePair the element name value pair.
94+
*/
9095
public void addElementNameValuePair(final ElementValuePair elementNameValuePair) {
9196
elementValuePairs.add(elementNameValuePair);
9297
}
9398

99+
/**
100+
* Dumps this annotation entry to a DataOutputStream.
101+
*
102+
* @param dos the output stream.
103+
* @throws IOException if an I/O error occurs.
104+
*/
94105
public void dump(final DataOutputStream dos) throws IOException {
95106
dos.writeShort(typeIndex); // u2 index of type name in cpool
96107
dos.writeShort(elementValuePairs.size()); // u2 element_value pair
@@ -101,46 +112,74 @@ public void dump(final DataOutputStream dos) throws IOException {
101112
}
102113

103114
/**
104-
* @return the annotation type name
115+
* Gets the annotation type name.
116+
*
117+
* @return the annotation type name.
105118
*/
106119
public String getAnnotationType() {
107120
return constantPool.getConstantUtf8(typeIndex).getBytes();
108121
}
109122

110123
/**
111-
* @return the annotation type index
124+
* Gets the annotation type index.
125+
*
126+
* @return the annotation type index.
112127
*/
113128
public int getAnnotationTypeIndex() {
114129
return typeIndex;
115130
}
116131

132+
/**
133+
* Gets the constant pool.
134+
*
135+
* @return the constant pool.
136+
*/
117137
public ConstantPool getConstantPool() {
118138
return constantPool;
119139
}
120140

121141
/**
122-
* @return the element value pairs in this annotation entry
142+
* Gets the element value pairs in this annotation entry.
143+
*
144+
* @return the element value pairs in this annotation entry.
123145
*/
124146
public ElementValuePair[] getElementValuePairs() {
125147
// TODO return List
126148
return elementValuePairs.toArray(ElementValuePair.EMPTY_ARRAY);
127149
}
128150

129151
/**
130-
* @return the number of element value pairs in this annotation entry
152+
* Gets the number of element value pairs in this annotation entry.
153+
*
154+
* @return the number of element value pairs in this annotation entry.
131155
*/
132156
public final int getNumElementValuePairs() {
133157
return elementValuePairs.size();
134158
}
135159

160+
/**
161+
* Gets the type index.
162+
*
163+
* @return the type index.
164+
*/
136165
public int getTypeIndex() {
137166
return typeIndex;
138167
}
139168

169+
/**
170+
* Gets whether this annotation is runtime visible.
171+
*
172+
* @return true if this annotation is runtime visible.
173+
*/
140174
public boolean isRuntimeVisible() {
141175
return isRuntimeVisible;
142176
}
143177

178+
/**
179+
* Gets a short string representation of this annotation.
180+
*
181+
* @return a short string representation of this annotation.
182+
*/
144183
public String toShortString() {
145184
final StringBuilder result = new StringBuilder();
146185
result.append("@");

src/main/java/org/apache/bcel/classfile/ArrayElementValue.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.io.IOException;
2323

2424
/**
25+
* Represents an array element value in an annotation.
26+
*
2527
* @since 6.0
2628
*/
2729
public class ArrayElementValue extends ElementValue {

src/main/java/org/apache/bcel/classfile/Attribute.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ public static void addAttributeReader(final String name, final UnknownAttributeR
9090
READERS.put(name, unknownAttributeReader);
9191
}
9292

93+
/**
94+
* Prints a message to stderr if debug mode is enabled.
95+
*
96+
* @param msg the message to print.
97+
*/
9398
protected static void println(final String msg) {
9499
if (debug) {
95100
System.err.println(msg);
@@ -297,6 +302,8 @@ public Object clone() {
297302
}
298303

299304
/**
305+
* Creates a deep copy of this attribute.
306+
*
300307
* @param constantPool constant pool to save.
301308
* @return deep copy of this attribute.
302309
*/
@@ -314,6 +321,8 @@ public void dump(final DataOutputStream file) throws IOException {
314321
}
315322

316323
/**
324+
* Gets the constant pool used by this object.
325+
*
317326
* @return Constant pool used by this object.
318327
* @see ConstantPool
319328
*/
@@ -322,35 +331,45 @@ public final ConstantPool getConstantPool() {
322331
}
323332

324333
/**
334+
* Gets the length of attribute field in bytes.
335+
*
325336
* @return Length of attribute field in bytes.
326337
*/
327338
public final int getLength() {
328339
return length;
329340
}
330341

331342
/**
332-
* @return Name of attribute
343+
* Gets the name of attribute.
344+
*
345+
* @return Name of attribute.
333346
* @since 6.0
334347
*/
335348
public String getName() {
336349
return constant_pool.getConstantUtf8(name_index).getBytes();
337350
}
338351

339352
/**
353+
* Gets the name index in constant pool of attribute name.
354+
*
340355
* @return Name index in constant pool of attribute name.
341356
*/
342357
public final int getNameIndex() {
343358
return name_index;
344359
}
345360

346361
/**
362+
* Gets the tag of attribute, i.e., its type.
363+
*
347364
* @return Tag of attribute, i.e., its type. Value may not be altered, thus there is no setTag() method.
348365
*/
349366
public final byte getTag() {
350367
return tag;
351368
}
352369

353370
/**
371+
* Sets the constant pool to be used for this object.
372+
*
354373
* @param constantPool Constant pool to be used for this object.
355374
* @see ConstantPool
356375
*/
@@ -359,13 +378,17 @@ public final void setConstantPool(final ConstantPool constantPool) {
359378
}
360379

361380
/**
381+
* Sets the length in bytes.
382+
*
362383
* @param length length in bytes.
363384
*/
364385
public final void setLength(final int length) {
365386
this.length = length;
366387
}
367388

368389
/**
390+
* Sets the name index of attribute.
391+
*
369392
* @param nameIndex of attribute.
370393
*/
371394
public final void setNameIndex(final int nameIndex) {

0 commit comments

Comments
 (0)