Commit 7c4bfe68 authored by Eric Bruneton's avatar Eric Bruneton

Fix a few 'code smells' found by SonarQube.

parent 48845e14
Pipeline #4326 passed with stage
in 11 minutes and 10 seconds
......@@ -120,7 +120,9 @@ public class Frame<V extends Value> {
* this frame corresponds to the successor of the jump instruction (i.e. the next instruction
* in the instructions sequence).
*/
public void initJumpTarget(final int opcode, final LabelNode target) {}
public void initJumpTarget(final int opcode, final LabelNode target) {
// Does nothing by default.
}
/**
* Sets the expected return type of the analyzed method.
......@@ -206,7 +208,7 @@ public class Frame<V extends Value> {
* @param value the new value of the stack slot.
* @throws IndexOutOfBoundsException if the stack slot does not exist.
*/
public void setStack(final int index, final V value) throws IndexOutOfBoundsException {
public void setStack(final int index, final V value) {
values[numLocals + index] = value;
}
......
......@@ -160,9 +160,10 @@ public class ClassFile {
*
* @return a new instance of the class, or {@literal null} if the class is abstract, is an enum,
* or a module info.
* @throws Exception if the class is invalid or if an error occurs in its constructor.
* @throws ReflectiveOperationException if the class is invalid or if an error occurs in its
* constructor.
*/
public Object newInstance() throws Exception {
public Object newInstance() throws ReflectiveOperationException {
if (className == null) {
computeNameAndDumps();
}
......@@ -176,8 +177,11 @@ public class ClassFile {
* @param classContent the content of the class to load.
* @return a new instance of the class, or {@literal null} if the class is abstract, is an enum,
* or a module info.
* @throws ReflectiveOperationException if the class is invalid or if an error occurs in its
* constructor.
*/
static Object newInstance(final String className, final byte[] classContent) throws Exception {
static Object newInstance(final String className, final byte[] classContent)
throws ReflectiveOperationException {
if (className.endsWith(MODULE_INFO)) {
if (Util.getMajorJavaVersion() < 9) {
throw new UnsupportedClassVersionError("Module info is not supported before JDK 9");
......
......@@ -263,7 +263,7 @@ public class ASMifier extends Printer {
stringBuilder.setLength(0);
stringBuilder.append("classWriter.visitNestHost(");
appendConstant(nestHost);
stringBuilder.append(");\n\n");
stringBuilder.append(END_PARAMETERS);
text.add(stringBuilder.toString());
}
......@@ -1413,7 +1413,7 @@ public class ASMifier extends Printer {
stringBuilder.append(constantDynamic.getName()).append("\", \"");
stringBuilder.append(constantDynamic.getDescriptor()).append("\", ");
appendConstant(constantDynamic.getBootstrapMethod());
stringBuilder.append(", new Object[] {");
stringBuilder.append(NEW_OBJECT_ARRAY);
int bootstrapMethodArgumentCount = constantDynamic.getBootstrapMethodArgumentCount();
for (int i = 0; i < bootstrapMethodArgumentCount; ++i) {
appendConstant(constantDynamic.getBootstrapMethodArgument(i));
......
......@@ -438,7 +438,7 @@ public class ClassWriter extends ClassVisitor {
* @throws ClassTooLargeException if the constant pool of the class is too large.
* @throws MethodTooLargeException if the Code attribute of a method is too large.
*/
public byte[] toByteArray() throws ClassTooLargeException, MethodTooLargeException {
public byte[] toByteArray() {
// First step: compute the size in bytes of the ClassFile structure.
// The magic field uses 4 bytes, 10 mandatory fields (minor_version, major_version,
// constant_pool_count, access_flags, this_class, super_class, interfaces_count, fields_count,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment