| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
package org.apache.commons.compress.harmony.pack200; |
| 20 |
|
| 21 |
import org.objectweb.asm.ClassReader; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public class Pack200ClassReader extends ClassReader { |
| 27 |
|
| 28 |
private boolean lastConstantHadWideIndex; |
| 29 |
private int lastUnsignedShort; |
| 30 |
private boolean anySyntheticAttributes; |
| 31 |
private String fileName; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
public Pack200ClassReader(final byte[] b) { |
| 37 |
super(b); |
| 38 |
} |
| 39 |
|
| 40 |
public String getFileName() { |
| 41 |
return fileName; |
| 42 |
} |
| 43 |
|
| 44 |
public boolean hasSyntheticAttributes() { |
| 45 |
return anySyntheticAttributes; |
| 46 |
} |
| 47 |
|
| 48 |
public boolean lastConstantHadWideIndex() { |
| 49 |
return lastConstantHadWideIndex; |
| 50 |
} |
| 51 |
|
| 52 |
@Override |
| 53 |
public Object readConst(final int item, final char[] buf) { |
| 54 |
lastConstantHadWideIndex = item == lastUnsignedShort; |
| 55 |
return super.readConst(item, buf); |
| 56 |
} |
| 57 |
|
| 58 |
@Override |
| 59 |
public int readUnsignedShort(final int index) { |
| 60 |
|
| 61 |
|
| 62 |
final int unsignedShort = super.readUnsignedShort(index); |
| 63 |
if (index > 0 && b[index - 1] == 19) { |
| 64 |
lastUnsignedShort = unsignedShort; |
| 65 |
} else { |
| 66 |
lastUnsignedShort = Short.MIN_VALUE; |
| 67 |
} |
| 68 |
return unsignedShort; |
| 69 |
} |
| 70 |
|
| 71 |
@Override |
| 72 |
public String readUTF8(final int arg0, final char[] arg1) { |
| 73 |
final String utf8 = super.readUTF8(arg0, arg1); |
| 74 |
if (!anySyntheticAttributes && "Synthetic".equals(utf8)) { |
| 75 |
anySyntheticAttributes = true; |
| 76 |
} |
| 77 |
return utf8; |
| 78 |
} |
| 79 |
|
| 80 |
public void setFileName(final String name) { |
| 81 |
this.fileName = name; |
| 82 |
} |
| 83 |
|
| 84 |
} |