removed dead code

This commit is contained in:
Sander Hautvast 2020-11-11 11:07:10 +01:00
parent 72ef703e40
commit a1e78f5ed9
2 changed files with 4 additions and 41 deletions

View file

@ -7,15 +7,6 @@ import java.util.ArrayList;
public class ConstantPool extends ArrayList<ConstantPoolEntry>{
public int getIndex(ConstantPoolEntry entry) {
for (int i = 0; i < size(); i++) {
if (get(i) == entry) {
return i + 1;
}
}
return -1;
}
public byte[] getBytes() {
ByteBuf bytes = new ByteBuf();
forEach(entry -> bytes.addU8(entry.getBytes()));
@ -23,7 +14,10 @@ public class ConstantPool extends ArrayList<ConstantPoolEntry>{
}
/**
* get the length +1
* get the length for constant_pool_count in the class file
*
* 4.1. The ClassFile Structure
* The value of the constant_pool_count item is equal to the number of entries in the constant_pool table plus one
*/
public int getLength() {
return size() + 1;

View file

@ -18,37 +18,6 @@ public class ByteBuf {
data = ByteBuffer.allocate(initialSize);
}
public String toString() {
return toString(StandardCharsets.UTF_8);
}
public String toString(Charset charset) {
data.flip();
CharsetDecoder decoder = charset.newDecoder(); // decode is not threadsafe, might put it in threadlocal
// but I don't think this (newDecoder()+config) is expensive
decoder.onMalformedInput(CodingErrorAction.REPLACE)
.onUnmappableCharacter(CodingErrorAction.REPLACE);
try {
return decoder.decode(data).toString();
} catch (CharacterCodingException e) {
throw new RuntimeException(e);
}
}
public void clear() {
data.clear();
}
public void addU8(final byte c) {
if (data.remaining() == 0) {
enlarge(1);
}
data.put(c);
}
public void addU8(final byte[] bytes) {
if (data.remaining() < bytes.length) {
enlarge(bytes.length);