Remove use of deprecated ClassReader.b field

master
Graham 5 years ago
parent c4611f8bb4
commit 08f5ff034a
  1. 2
      src/main/java/org/apache/harmony/pack200/NewAttribute.java
  2. 4
      src/main/java/org/apache/harmony/pack200/Pack200ClassReader.java

@ -104,7 +104,7 @@ public class NewAttribute extends Attribute {
protected Attribute read(ClassReader cr, int off, int len, char[] buf, protected Attribute read(ClassReader cr, int off, int len, char[] buf,
int codeOff, Label[] labels) { int codeOff, Label[] labels) {
byte[] attributeContents = new byte[len]; byte[] attributeContents = new byte[len];
System.arraycopy(cr.b, off, attributeContents, 0, len); System.arraycopy(((Pack200ClassReader) cr).b, off, attributeContents, 0, len);
return new NewAttribute(cr, type, layout, attributeContents, buf, codeOff, return new NewAttribute(cr, type, layout, attributeContents, buf, codeOff,
labels); labels);
} }

@ -24,6 +24,7 @@ import org.objectweb.asm.ClassReader;
*/ */
public class Pack200ClassReader extends ClassReader { public class Pack200ClassReader extends ClassReader {
final byte[] b;
private boolean lastConstantHadWideIndex; private boolean lastConstantHadWideIndex;
private int lastUnsignedShort; private int lastUnsignedShort;
private boolean anySyntheticAttributes; private boolean anySyntheticAttributes;
@ -35,13 +36,14 @@ public class Pack200ClassReader extends ClassReader {
*/ */
public Pack200ClassReader(byte[] b) { public Pack200ClassReader(byte[] b) {
super(b); super(b);
this.b = b;
} }
public int readUnsignedShort(int index) { public int readUnsignedShort(int index) {
// Doing this to check whether last load-constant instruction was ldc (18) or ldc_w (19) // Doing this to check whether last load-constant instruction was ldc (18) or ldc_w (19)
// TODO: Assess whether this impacts on performance // TODO: Assess whether this impacts on performance
int unsignedShort = super.readUnsignedShort(index); int unsignedShort = super.readUnsignedShort(index);
if(index > 0 && b[index - 1] == 19) { if(index > 0 && readByte(index - 1) == 19) {
lastUnsignedShort = unsignedShort; lastUnsignedShort = unsignedShort;
} else { } else {
lastUnsignedShort = Short.MIN_VALUE; lastUnsignedShort = Short.MIN_VALUE;

Loading…
Cancel
Save