Skip to content

Commit caa5c5b

Browse files
committed
Merge some string literals
1 parent fe41010 commit caa5c5b

11 files changed

Lines changed: 44 additions & 31 deletions

File tree

src/main/java/org/apache/bcel/util/AttributeHTML.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ void writeAttribute(final Attribute attribute, final String anchor, final int me
160160
final int start = var.getStartPC();
161161
final int end = start + var.getLength();
162162
printWriter.println("<LI>" + Class2HTML.referenceType(signature) + "&nbsp;<B>" + var.getName() + "</B> in slot %" + var.getIndex()
163-
+ "<BR>Valid from lines " + "<A HREF=\"" + className + "_code.html#code" + methodNumber + "@" + start + "\" TARGET=Code>" + start
164-
+ "</A> to " + "<A HREF=\"" + className + "_code.html#code" + methodNumber + "@" + end + "\" TARGET=Code>" + end + "</A></LI>");
163+
+ "<BR>Valid from lines <A HREF=\"" + className + "_code.html#code" + methodNumber + "@" + start + "\" TARGET=Code>" + start
164+
+ "</A> to <A HREF=\"" + className + "_code.html#code" + methodNumber + "@" + end + "\" TARGET=Code>" + end + "</A></LI>");
165165
});
166166
printWriter.print("</UL>\n");
167167
break;

src/main/java/org/apache/bcel/util/BCELFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ private void updateExceptionHandlers() {
167167
final CodeExceptionGen[] handlers = methodGen.getExceptionHandlers();
168168
for (final CodeExceptionGen h : handlers) {
169169
final String type = h.getCatchType() == null ? "null" : BCELifier.printType(h.getCatchType());
170-
printWriter.println(" method.addExceptionHandler(" + "ih_" + h.getStartPC().getPosition() + ", " + "ih_" + h.getEndPC().getPosition() + ", "
171-
+ "ih_" + h.getHandlerPC().getPosition() + ", " + type + ");");
170+
printWriter.println(" method.addExceptionHandler(ih_" + h.getStartPC().getPosition() + ", ih_" + h.getEndPC().getPosition() + ", ih_"
171+
+ h.getHandlerPC().getPosition() + ", " + type + ");");
172172
}
173173
}
174174

src/main/java/org/apache/bcel/util/BCELifier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public void visitJavaClass(final JavaClass clazz) {
266266
printWriter.println();
267267
printWriter.println(" public " + className + "Creator() {");
268268
printWriter.println(" _cg = new ClassGen(\"" + (packageName.isEmpty() ? className : packageName + "." + className) + "\", \"" + superName
269-
+ "\", " + "\"" + clazz.getSourceFileName() + "\", " + printFlags(clazz.getAccessFlags(), FLAGS.CLASS) + ", " + "new String[] { " + inter + " });");
269+
+ "\", \"" + clazz.getSourceFileName() + "\", " + printFlags(clazz.getAccessFlags(), FLAGS.CLASS) + ", " + "new String[] { " + inter + " });");
270270
printWriter.println(" _cg.setMajor(" + clazz.getMajor() + ");");
271271
printWriter.println(" _cg.setMinor(" + clazz.getMinor() + ");");
272272
printWriter.println();
@@ -301,7 +301,7 @@ public void visitMethod(final Method method) {
301301
final MethodGen mg = new MethodGen(method, clazz.getClassName(), constantPoolGen);
302302
printWriter.println(" InstructionList il = new InstructionList();");
303303
printWriter.println(" MethodGen method = new MethodGen(" + printFlags(method.getAccessFlags(), FLAGS.METHOD) + ", " + printType(mg.getReturnType())
304-
+ ", " + printArgumentTypes(mg.getArgumentTypes()) + ", " + "new String[] { " + Utility.printArray(mg.getArgumentNames(), false, true) + " }, \""
304+
+ ", " + printArgumentTypes(mg.getArgumentTypes()) + ", new String[] { " + Utility.printArray(mg.getArgumentNames(), false, true) + " }, \""
305305
+ method.getName() + "\", \"" + clazz.getClassName() + "\", il, _cp);");
306306
final ExceptionTable exceptionTable = method.getExceptionTable();
307307
if (exceptionTable != null) {

src/main/java/org/apache/bcel/util/Class2HTML.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,26 @@ private Class2HTML(final JavaClass javaClass, final String dir, final Charset ch
213213

214214
private void writeMainHTML(final AttributeHTML attributeHtml, final Charset charset) throws FileNotFoundException, UnsupportedEncodingException {
215215
try (PrintWriter file = new PrintWriter(dir + className + ".html", charset.name())) {
216-
file.println("<HTML>\n" + "<HEAD><TITLE>Documentation for " + className + "</TITLE>" + "</HEAD>\n" + "<FRAMESET BORDER=1 cols=\"30%,*\">\n"
217-
+ "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"ConstantPool\" SRC=\"" + className + "_cp.html" + "\"\n MARGINWIDTH=\"0\" "
218-
+ "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "<FRAME NAME=\"Attributes\" SRC=\"" + className + "_attributes.html"
219-
+ "\"\n MARGINWIDTH=\"0\" " + "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n" + "</FRAMESET>\n"
220-
+ "<FRAMESET BORDER=1 rows=\"80%,*\">\n" + "<FRAME NAME=\"Code\" SRC=\"" + className + "_code.html\"\n MARGINWIDTH=0 "
221-
+ "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + "<FRAME NAME=\"Methods\" SRC=\"" + className + "_methods.html\"\n MARGINWIDTH=0 "
222-
+ "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n" + "</FRAMESET></FRAMESET></HTML>");
216+
// @formatter:off
217+
file.println("<HTML>\n"
218+
+ "<HEAD><TITLE>Documentation for " + className + "</TITLE></HEAD>\n"
219+
+ "<FRAMESET BORDER=1 cols=\"30%,*\">\n"
220+
+ "<FRAMESET BORDER=1 rows=\"80%,*\">\n"
221+
+ "<FRAME NAME=\"ConstantPool\" SRC=\"" + className + "_cp.html" + "\"\n"
222+
+ "MARGINWIDTH=\"0\" "
223+
+ "MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n"
224+
+ "<FRAME NAME=\"Attributes\" SRC=\"" + className + "_attributes.html\"\n"
225+
+ " MARGINWIDTH=\"0\" MARGINHEIGHT=\"0\" FRAMEBORDER=\"1\" SCROLLING=\"AUTO\">\n"
226+
+ "</FRAMESET>\n"
227+
+ "<FRAMESET BORDER=1 rows=\"80%,*\">\n"
228+
+ "<FRAME NAME=\"Code\" SRC=\"" + className + "_code.html\"\n"
229+
+ " MARGINWIDTH=0 "
230+
+ "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n"
231+
+ "<FRAME NAME=\"Methods\" SRC=\"" + className + "_methods.html\"\n"
232+
+ " MARGINWIDTH=0 "
233+
+ "MARGINHEIGHT=0 FRAMEBORDER=1 SCROLLING=\"AUTO\">\n"
234+
+ "</FRAMESET></FRAMESET></HTML>");
235+
// @formatter:on
223236
}
224237
final Attribute[] attributes = javaClass.getAttributes();
225238
for (int i = 0; i < attributes.length; i++) {

src/main/java/org/apache/bcel/util/CodeHTML.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ private void writeMethod(final Method method, final int methodNumber) throws IOE
490490
access = Utility.replace(access, " ", "&nbsp;");
491491
// Get the method's attributes, the Code Attribute in particular
492492
final Attribute[] attributes = method.getAttributes();
493-
printWriter.print("<P><B><FONT COLOR=\"#FF0000\">" + access + "</FONT>&nbsp;" + "<A NAME=method" + methodNumber + ">" + Class2HTML.referenceType(type)
493+
printWriter.print("<P><B><FONT COLOR=\"#FF0000\">" + access + "</FONT>&nbsp;<A NAME=method" + methodNumber + ">" + Class2HTML.referenceType(type)
494494
+ "</A>&nbsp<A HREF=\"" + className + "_methods.html#method" + methodNumber + "\" TARGET=Methods>" + htmlName + "</A>(");
495495
for (int i = 0; i < args.length; i++) {
496496
printWriter.print(Class2HTML.referenceType(args[i]));
@@ -518,7 +518,7 @@ private void writeMethod(final Method method, final int methodNumber) throws IOE
518518
printWriter.print("<UL>");
519519
for (int j = 0; j < attributes2.length; j++) {
520520
tag = attributes2[j].getTag();
521-
printWriter.print("<LI><A HREF=\"" + className + "_attributes.html#" + "method" + methodNumber + "@" + i + "@" + j
521+
printWriter.print("<LI><A HREF=\"" + className + "_attributes.html#method" + methodNumber + "@" + i + "@" + j
522522
+ "\" TARGET=Attributes>" + Const.getAttributeName(tag) + "</A></LI>\n");
523523
}
524524
printWriter.print("</UL>");
@@ -533,7 +533,7 @@ private void writeMethod(final Method method, final int methodNumber) throws IOE
533533
stream.mark(stream.available());
534534
findGotos(stream, c);
535535
stream.reset();
536-
printWriter.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Byte<BR>offset</TH>" + "<TH ALIGN=LEFT>Instruction</TH><TH ALIGN=LEFT>Argument</TH>");
536+
printWriter.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Byte<BR>offset</TH><TH ALIGN=LEFT>Instruction</TH><TH ALIGN=LEFT>Argument</TH>");
537537
while (stream.available() > 0) {
538538
final int offset = stream.getIndex();
539539
final String str = codeToHTML(stream, methodNumber);

src/main/java/org/apache/bcel/util/ConstantHTML.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ private void writeConstant(final int index) {
143143
if (methodClass.equals(className)) {
144144
ref = "<A HREF=\"" + className + "_code.html#method" + getMethodNumber(methodName + signature) + "\" TARGET=Code>" + htmlMethodName + "</A>";
145145
} else {
146-
ref = "<A HREF=\"" + methodClass + ".html" + "\" TARGET=_top>" + shortMethodClass + "</A>." + htmlMethodName;
146+
ref = "<A HREF=\"" + methodClass + ".html\" TARGET=_top>" + shortMethodClass + "</A>." + htmlMethodName;
147147
}
148148
constantRef[index] = retType + "&nbsp;<A HREF=\"" + className + "_cp.html#cp" + classIndex + "\" TARGET=Constants>" + shortMethodClass
149149
+ "</A>.<A HREF=\"" + className + "_cp.html#cp" + index + "\" TARGET=ConstantPool>" + htmlMethodName + "</A>&nbsp;" + argTypes;
150-
printWriter.println("<P><TT>" + retType + "&nbsp;" + ref + argTypes + "&nbsp;</TT>\n<UL>" + "<LI><A HREF=\"#cp" + classIndex + "\">Class index("
150+
printWriter.println("<P><TT>" + retType + "&nbsp;" + ref + argTypes + "&nbsp;</TT>\n<UL><LI><A HREF=\"#cp" + classIndex + "\">Class index("
151151
+ classIndex + ")</A>\n" + "<LI><A HREF=\"#cp" + nameIndex + "\">NameAndType index(" + nameIndex + ")</A></UL>");
152152
break;
153153
case Const.CONSTANT_Fieldref:

src/main/java/org/apache/bcel/util/MethodHTML.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ final class MethodHTML {
5252
printWriter.print(charset.name());
5353
printWriter.println("\"></head>");
5454
printWriter.println("<BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
55-
printWriter.println("<TR><TH ALIGN=LEFT>Access&nbsp;flags</TH><TH ALIGN=LEFT>Type</TH>" + "<TH ALIGN=LEFT>Field&nbsp;name</TH></TR>");
55+
printWriter.println("<TR><TH ALIGN=LEFT>Access&nbsp;flags</TH><TH ALIGN=LEFT>Type</TH><TH ALIGN=LEFT>Field&nbsp;name</TH></TR>");
5656
for (final Field field : fields) {
5757
writeField(field);
5858
}
5959
printWriter.println("</TABLE>");
6060
printWriter.println("<TABLE BORDER=0><TR><TH ALIGN=LEFT>Access&nbsp;flags</TH>"
61-
+ "<TH ALIGN=LEFT>Return&nbsp;type</TH><TH ALIGN=LEFT>Method&nbsp;name</TH>" + "<TH ALIGN=LEFT>Arguments</TH></TR>");
61+
+ "<TH ALIGN=LEFT>Return&nbsp;type</TH><TH ALIGN=LEFT>Method&nbsp;name</TH><TH ALIGN=LEFT>Arguments</TH></TR>");
6262
for (int i = 0; i < methods.length; i++) {
6363
writeMethod(methods[i], i);
6464
}
@@ -114,7 +114,7 @@ private void writeMethod(final Method method, final int methodNumber) {
114114
access = Utility.replace(access, " ", "&nbsp;");
115115
final String htmlName = Class2HTML.toHTML(name);
116116
printWriter.print("<TR VALIGN=TOP><TD><FONT COLOR=\"#FF0000\"><A NAME=method" + methodNumber + ">" + access + "</A></FONT></TD>");
117-
printWriter.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD>" + "<A HREF=" + className + "_code.html#method" + methodNumber + " TARGET=Code>"
117+
printWriter.print("<TD>" + Class2HTML.referenceType(type) + "</TD><TD><A HREF=" + className + "_code.html#method" + methodNumber + " TARGET=Code>"
118118
+ htmlName + "</A></TD>\n<TD>(");
119119
for (int i = 0; i < args.length; i++) {
120120
printWriter.print(Class2HTML.referenceType(args[i]));

src/main/java/org/apache/bcel/verifier/statics/Pass1Verifier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public VerificationResult do_verify() {
142142
} catch (final RuntimeException e) {
143143
// BCEL does not catch every possible RuntimeException; for example if
144144
// a constant pool index is referenced that does not exist.
145-
return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Parsing via BCEL did not succeed. " + " exception occurred:\n" + e.toString());
145+
return new VerificationResult(VerificationResult.VERIFIED_REJECTED, "Parsing via BCEL did not succeed. exception occurred:\n" + e.toString());
146146
// Don't think we want to dump a stack trace unless we have some sort of a debug option.
147147
// e.getClass().getName()+" occurred:\n"+Utility.getStackTrace(e));
148148
}

src/main/java/org/apache/bcel/verifier/statics/Pass2Verifier.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ public void visitJavaClass(final JavaClass obj) {
709709
foundInnerClasses = true;
710710
} else if (hasInnerClass) {
711711
throw new ClassConstraintException("A Classfile structure (like '" + tostring(obj) + "') must have exactly one InnerClasses attribute"
712-
+ " if at least one Inner Class is referenced (which is the case)." + " More than one InnerClasses attribute was found.");
712+
+ " if at least one Inner Class is referenced (which is the case). More than one InnerClasses attribute was found.");
713713
}
714714
if (!hasInnerClass) {
715715
addMessage("No referenced Inner Class found, but InnerClasses attribute '" + tostring(att)
@@ -837,7 +837,7 @@ public void visitMethod(final Method obj) {
837837
// it!
838838
if (name.equals(Const.STATIC_INITIALIZER_NAME) && ts.length != 0) {
839839
throw new ClassConstraintException("Method '" + tostring(obj) + "' has illegal name '" + name + "'."
840-
+ " Its name resembles the class or interface initialization method" + " which it isn't because of its arguments (==descriptor).");
840+
+ " Its name resembles the class or interface initialization method which it isn't because of its arguments (==descriptor).");
841841
}
842842

843843
if (jc.isClass()) {
@@ -888,7 +888,7 @@ public void visitMethod(final Method obj) {
888888
if (jc.getMajor() >= Const.MAJOR_1_8) {
889889
if (obj.isPublic() == obj.isPrivate()) {
890890
throw new ClassConstraintException(
891-
"Interface method '" + tostring(obj) + "' must have" + " exactly one of its ACC_PUBLIC and ACC_PRIVATE modifiers set.");
891+
"Interface method '" + tostring(obj) + "' must have exactly one of its ACC_PUBLIC and ACC_PRIVATE modifiers set.");
892892
}
893893
if (obj.isProtected() || obj.isFinal() || obj.isSynchronized() || obj.isNative()) {
894894
throw new ClassConstraintException("Interface method '" + tostring(obj) + "' must not have"
@@ -912,7 +912,7 @@ public void visitMethod(final Method obj) {
912912

913913
if ((obj.getAccessFlags() & ~(Const.ACC_PUBLIC | Const.ACC_PRIVATE | Const.ACC_PROTECTED | Const.ACC_STATIC | Const.ACC_FINAL |
914914
Const.ACC_SYNCHRONIZED | Const.ACC_NATIVE | Const.ACC_ABSTRACT | Const.ACC_STRICT)) > 0) {
915-
addMessage("Method '" + tostring(obj) + "' has access flag(s) other than" + " ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,"
915+
addMessage("Method '" + tostring(obj) + "' has access flag(s) other than ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL,"
916916
+ " ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT set (ignored).");
917917
}
918918

src/main/java/org/apache/bcel/verifier/statics/Pass3aVerifier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public void visitANEWARRAY(final ANEWARRAY o) {
254254
final int dimensions = ((ArrayType) t).getDimensions();
255255
if (dimensions > Const.MAX_ARRAY_DIMENSIONS) {
256256
constraintViolated(o,
257-
"Not allowed to create an array with more than " + Const.MAX_ARRAY_DIMENSIONS + " dimensions;" + " actual: " + dimensions);
257+
"Not allowed to create an array with more than " + Const.MAX_ARRAY_DIMENSIONS + " dimensions; actual: " + dimensions);
258258
}
259259
}
260260
}
@@ -926,7 +926,7 @@ private void delayedPass2Checks() {
926926
if (instructionPosition == offset) {
927927
if (offsets.contains(offset)) {
928928
addMessage("LineNumberTable attribute '" + code.getLineNumberTable() + "' refers to the same code offset ('" + offset
929-
+ "') more than once" + " which is violating the semantics [but is sometimes produced by IBM's 'jikes' compiler].");
929+
+ "') more than once which is violating the semantics [but is sometimes produced by IBM's 'jikes' compiler].");
930930
} else {
931931
offsets.add(offset);
932932
}
@@ -1127,7 +1127,7 @@ private void pass3StaticInstructionChecks() {
11271127
final Instruction last = instructionList.getEnd().getInstruction();
11281128
if (!(last instanceof ReturnInstruction || last instanceof RET || last instanceof GotoInstruction || last instanceof ATHROW)) {
11291129
throw new StaticCodeInstructionConstraintException(
1130-
"Execution must not fall off the bottom of the code array." + " This constraint is enforced statically as some existing verifiers do"
1130+
"Execution must not fall off the bottom of the code array. This constraint is enforced statically as some existing verifiers do"
11311131
+ " - so it may be a false alarm if the last instruction is not reachable.");
11321132
}
11331133
}

0 commit comments

Comments
 (0)