Skip to content
Permalink
Browse files
Avoid use C-style array declaration. (#282)
  • Loading branch information
arturobernalg committed Apr 22, 2022
1 parent 9273cfa commit cf7bcef58493cef99b90f1c9943893944f7598bc
Showing 13 changed files with 24 additions and 20 deletions.
@@ -321,6 +321,10 @@ Brotli, Zstandard and ar, cpio, jar, tar, zip, dump, 7z, arj.
<name>Michael Hausegger</name>
<email>hausegger.michael@googlemail.com</email>
</contributor>
<contributor>
<name>Arturo Bernal</name>
<email>arturobernalg@yahoo.com</email>
</contributor>
</contributors>

<scm>
@@ -145,7 +145,7 @@ public abstract class Codec {
*/
public int[] decodeInts(final int n, final InputStream in) throws IOException, Pack200Exception {
lastBandLength = 0;
final int result[] = new int[n];
final int[] result = new int[n];
int last = 0;
for (int i = 0; i < n; i++) {
result[i] = last = decode(in, last);
@@ -166,7 +166,7 @@ public int[] decodeInts(final int n, final InputStream in) throws IOException, P
*/
public int[] decodeInts(final int n, final InputStream in, final int firstValue)
throws IOException, Pack200Exception {
final int result[] = new int[n + 1];
final int[] result = new int[n + 1];
result[0] = firstValue;
int last = firstValue;
for (int i = 1; i < n + 1; i++) {
@@ -61,7 +61,7 @@ public int[] decodeInts(final int n, final InputStream in) throws IOException, P
lastBandLength = 0;
favoured = new int[n]; // there must be <= n values, but probably a lot
// less
int result[];
int[] result;
// read table of favorites first
int smallest = Integer.MAX_VALUE, absoluteSmallest;
int last = 0;
@@ -110,7 +110,7 @@ public void unpack() throws Pack200Exception, IOException {
inputStream.mark(4);
final int[] magic = {0xCA, 0xFE, 0xD0, 0x0D}; // Magic word for
// pack200
final int word[] = new int[4];
final int[] word = new int[4];
for (int i = 0; i < word.length; i++) {
word[i] = inputStream.read();
}
@@ -162,7 +162,7 @@ public long[] parseFlags(final String name, final InputStream in, final int coun
return parseFlags(name, in, new int[] {count}, (hasHi ? codec : null), codec)[0];
}

public long[][] parseFlags(final String name, final InputStream in, final int counts[], final BHSDCodec codec,
public long[][] parseFlags(final String name, final InputStream in, final int[] counts, final BHSDCodec codec,
final boolean hasHi) throws IOException, Pack200Exception {
return parseFlags(name, in, counts, (hasHi ? codec : null), codec);
}
@@ -172,7 +172,7 @@ public long[] parseFlags(final String name, final InputStream in, final int coun
return parseFlags(name, in, new int[] {count}, hiCodec, loCodec)[0];
}

public long[][] parseFlags(final String name, final InputStream in, final int counts[], final BHSDCodec hiCodec,
public long[][] parseFlags(final String name, final InputStream in, final int[] counts, final BHSDCodec hiCodec,
final BHSDCodec loCodec) throws IOException, Pack200Exception {
final int count = counts.length;
if (count == 0) {
@@ -244,7 +244,7 @@ public String[] parseReferences(final String name, final InputStream in, final B
* @throws Pack200Exception if a problem occurs with an unexpected value or unsupported Codec
*/
public String[][] parseReferences(final String name, final InputStream in, final BHSDCodec codec,
final int counts[], final String[] reference) throws IOException, Pack200Exception {
final int[] counts, final String[] reference) throws IOException, Pack200Exception {
final int count = counts.length;
if (count == 0) {
return new String[][] {{}};
@@ -214,7 +214,7 @@ private void parseCpField(final InputStream in) throws IOException, Pack200Excep
private void parseCpFloat(final InputStream in) throws IOException, Pack200Exception {
final int cpFloatCount = header.getCpFloatCount();
cpFloat = new float[cpFloatCount];
final int floatBits[] = decodeBandInt("cp_Float", in, Codec.UDELTA5, cpFloatCount);
final int[] floatBits = decodeBandInt("cp_Float", in, Codec.UDELTA5, cpFloatCount);
for (int i = 0; i < cpFloatCount; i++) {
cpFloat[i] = Float.intBitsToFloat(floatBits[i]);
}
@@ -376,7 +376,7 @@ private void parseCpUtf8(final InputStream in) throws IOException, Pack200Except
}

// Convert big suffix data to characters
final char bigSuffixData[][] = new char[bigSuffixCount][];
final char[][] bigSuffixData = new char[bigSuffixCount][];
for (int i = 0; i < bigSuffixDataBand.length; i++) {
bigSuffixData[i] = new char[bigSuffixDataBand[i].length];
for (int j = 0; j < bigSuffixDataBand[i].length; j++) {
@@ -200,7 +200,7 @@ private void initializeClassStrings() {
}
// Class names must be calculated from
// this class name.
final String nameComponents[] = innerBreakAtDollar(C);
final String[] nameComponents = innerBreakAtDollar(C);
if (nameComponents.length == 0) {
// Unable to predict outer class
// throw new Error("Unable to predict outer class name: " + C);
@@ -187,12 +187,12 @@ private ClassFile buildClassFile(final int classNum) {
final ClassFileEntry cfThis = cp.add(cpBands.cpClassValue(fullNameIndexInCpClass));
final ClassFileEntry cfSuper = cp.add(cpBands.cpClassValue(classBands.getClassSuperInts()[classNum]));
// add interfaces
final ClassFileEntry cfInterfaces[] = new ClassFileEntry[classBands.getClassInterfacesInts()[classNum].length];
final ClassFileEntry[] cfInterfaces = new ClassFileEntry[classBands.getClassInterfacesInts()[classNum].length];
for (i = 0; i < cfInterfaces.length; i++) {
cfInterfaces[i] = cp.add(cpBands.cpClassValue(classBands.getClassInterfacesInts()[classNum][i]));
}
// add fields
final ClassFileEntry cfFields[] = new ClassFileEntry[classBands.getClassFieldCount()[classNum]];
final ClassFileEntry[] cfFields = new ClassFileEntry[classBands.getClassFieldCount()[classNum]];
// fieldDescr and fieldFlags used to create this
for (i = 0; i < cfFields.length; i++) {
final int descriptorIndex = classBands.getFieldDescrInts()[classNum][i];
@@ -204,7 +204,7 @@ private ClassFile buildClassFile(final int classNum) {
classBands.getFieldAttributes()[classNum][i]));
}
// add methods
final ClassFileEntry cfMethods[] = new ClassFileEntry[classBands.getClassMethodCount()[classNum]];
final ClassFileEntry[] cfMethods = new ClassFileEntry[classBands.getClassMethodCount()[classNum]];
// methodDescr and methodFlags used to create this
for (i = 0; i < cfMethods.length; i++) {
final int descriptorIndex = classBands.getMethodDescrInts()[classNum][i];
@@ -109,7 +109,7 @@ public ConstantPoolEntry getClassSpecificPoolEntry(final int cp, final long desi
final String desiredClassName) throws Pack200Exception {
final int index = (int) desiredIndex;
int realIndex = -1;
String array[] = null;
String[] array = null;
if (cp == CP_FIELD) {
array = bands.getCpFieldClass();
} else if (cp == CP_METHOD) {
@@ -130,7 +130,7 @@ public ConstantPoolEntry getClassSpecificPoolEntry(final int cp, final long desi
* @return CPClass for that class name, or null if not found.
*/
public ConstantPoolEntry getClassPoolEntry(final String name) {
final String classes[] = bands.getCpClass();
final String[] classes = bands.getCpClass();
final int index = matchSpecificPoolEntryIndex(classes, name, 0);
if (index == -1) {
return null;
@@ -101,7 +101,7 @@ public int getArchiveSizeOffset() {

public void read(final InputStream in) throws IOException, Error, Pack200Exception {

final int word[] = decodeScalar("archive_magic_word", in, Codec.BYTE1, magic.length);
final int[] word = decodeScalar("archive_magic_word", in, Codec.BYTE1, magic.length);
for (int m = 0; m < magic.length; m++) {
if (word[m] != magic[m]) {
throw new Error("Bad header");
@@ -35,7 +35,7 @@ public class CodeAttribute extends BCIRenumberedAttribute {
public int maxStack;
private static CPUTF8 attributeName;

public CodeAttribute(final int maxStack, final int maxLocals, final byte codePacked[], final Segment segment,
public CodeAttribute(final int maxStack, final int maxLocals, final byte[] codePacked, final Segment segment,
final OperandManager operandManager, final List exceptionTable) {
super(attributeName);
this.maxLocals = maxLocals;
@@ -38,11 +38,11 @@ public void setByteCodeOperands(final ByteCode byteCode, final OperandManager op
final int codeLength) {
final int case_count = operandManager.nextCaseCount();
final int default_pc = operandManager.nextLabel();
final int case_values[] = new int[case_count];
final int[] case_values = new int[case_count];
for (int index = 0; index < case_count; index++) {
case_values[index] = operandManager.nextCaseValues();
}
final int case_pcs[] = new int[case_count];
final int[] case_pcs = new int[case_count];
for (int index = 0; index < case_count; index++) {
case_pcs[index] = operandManager.nextLabel();
}
@@ -41,7 +41,7 @@ public void setByteCodeOperands(final ByteCode byteCode, final OperandManager op
int case_value = -1;
case_value = operandManager.nextCaseValues();

final int case_pcs[] = new int[case_count];
final int[] case_pcs = new int[case_count];
for (int index = 0; index < case_count; index++) {
case_pcs[index] = operandManager.nextLabel();
}

0 comments on commit cf7bcef

Please sign in to comment.