1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.compress.harmony.unpack200.bytecode.forms;
18
19 import org.apache.commons.compress.harmony.pack200.Pack200Exception;
20 import org.apache.commons.compress.harmony.unpack200.SegmentConstantPool;
21 import org.apache.commons.compress.harmony.unpack200.bytecode.ByteCode;
22 import org.apache.commons.compress.harmony.unpack200.bytecode.ClassFileEntry;
23 import org.apache.commons.compress.harmony.unpack200.bytecode.OperandManager;
24
25
26
27
28 public class ClassRefForm extends ReferenceForm {
29
30 protected boolean widened;
31
32 public ClassRefForm(final int opcode, final String name, final int[] rewrite) {
33 super(opcode, name, rewrite);
34 }
35
36 public ClassRefForm(final int opcode, final String name, final int[] rewrite, final boolean widened) {
37 this(opcode, name, rewrite);
38 this.widened = widened;
39 }
40
41 @Override
42 protected int getOffset(final OperandManager operandManager) {
43 return operandManager.nextClassRef();
44 }
45
46 @Override
47 protected int getPoolID() {
48 return SegmentConstantPool.CP_CLASS;
49 }
50
51 @Override
52 protected void setNestedEntries(final ByteCode byteCode, final OperandManager operandManager, final int offset) throws Pack200Exception {
53
54 if (offset != 0) {
55 super.setNestedEntries(byteCode, operandManager, offset - 1);
56 return;
57 }
58
59
60
61
62
63 final SegmentConstantPool globalPool = operandManager.globalConstantPool();
64
65 final ClassFileEntry[] nested = { globalPool.getClassPoolEntry(operandManager.getCurrentClass()) };
66 byteCode.setNested(nested);
67 byteCode.setNestedPositions(new int[][] { { 0, 2 } });
68 }
69 }