java-decompiler: fixes and cleanups

- unified attribute loading code
- common methods for checking member flags
- verifying skip()
- correct resource closing
- typos
This commit is contained in:
Roman Shevchenko
2014-09-02 20:56:03 +04:00
parent c0c83126a6
commit 2df49d32a7
31 changed files with 586 additions and 1012 deletions

View File

@@ -25,20 +25,19 @@ public class DataInputFullStream extends DataInputStream {
super(in);
}
public final int readFull(byte[] b) throws IOException {
public int readFull(byte[] b) throws IOException {
int length = b.length;
byte[] btemp = new byte[length];
byte[] temp = new byte[length];
int pos = 0;
int bytes_read = -1;
int bytes_read;
while (true) {
bytes_read = read(btemp, 0, length - pos);
bytes_read = read(temp, 0, length - pos);
if (bytes_read == -1) {
return -1;
}
System.arraycopy(btemp, 0, b, pos, bytes_read);
System.arraycopy(temp, 0, b, pos, bytes_read);
pos += bytes_read;
if (pos == length) {
break;
@@ -47,4 +46,10 @@ public class DataInputFullStream extends DataInputStream {
return length;
}
public void discard(int n) throws IOException {
if (super.skip(n) != n) {
throw new IOException("Skip failed");
}
}
}