author | jjg |
Tue, 13 Oct 2009 14:02:53 -0700 | |
changeset 4071 | 10c876d2de66 |
parent 3543 | 58b72b096bcb |
child 5010 | c9fd6294653a |
permissions | -rw-r--r-- |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
1 |
/* |
2212 | 2 |
* Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
4 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Sun designates this |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
10 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
15 |
* accompanied this code). |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
16 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
20 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
23 |
* have any questions. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
24 |
*/ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
25 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
26 |
package com.sun.tools.classfile; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
27 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
28 |
import java.io.DataOutputStream; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
29 |
import java.io.IOException; |
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
30 |
import java.io.OutputStream; |
2978 | 31 |
import java.util.Iterator; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
32 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
33 |
/** |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
34 |
* See JVMS3, section 4.5. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
35 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
36 |
* <p><b>This is NOT part of any API supported by Sun Microsystems. If |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
37 |
* you write code that depends on this, you do so at your own risk. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
38 |
* This code and its internal interfaces are subject to change or |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
39 |
* deletion without notice.</b> |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
40 |
*/ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
41 |
public class ConstantPool { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
42 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
43 |
public class InvalidIndex extends ConstantPoolException { |
1870
57a1138dffc8
6795903: fix latent build warnings in langtools repository
jjg
parents:
735
diff
changeset
|
44 |
private static final long serialVersionUID = -4350294289300939730L; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
45 |
InvalidIndex(int index) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
46 |
super(index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
47 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
48 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
49 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
50 |
public String getMessage() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
51 |
// i18n |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
52 |
return "invalid index #" + index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
53 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
54 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
55 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
56 |
public class UnexpectedEntry extends ConstantPoolException { |
1870
57a1138dffc8
6795903: fix latent build warnings in langtools repository
jjg
parents:
735
diff
changeset
|
57 |
private static final long serialVersionUID = 6986335935377933211L; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
58 |
UnexpectedEntry(int index, int expected_tag, int found_tag) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
59 |
super(index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
60 |
this.expected_tag = expected_tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
61 |
this.found_tag = found_tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
62 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
63 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
64 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
65 |
public String getMessage() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
66 |
// i18n? |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
67 |
return "unexpected entry at #" + index + " -- expected tag " + expected_tag + ", found " + found_tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
68 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
69 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
70 |
public final int expected_tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
71 |
public final int found_tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
72 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
73 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
74 |
public class InvalidEntry extends ConstantPoolException { |
1870
57a1138dffc8
6795903: fix latent build warnings in langtools repository
jjg
parents:
735
diff
changeset
|
75 |
private static final long serialVersionUID = 1000087545585204447L; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
76 |
InvalidEntry(int index, int tag) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
77 |
super(index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
78 |
this.tag = tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
79 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
80 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
81 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
82 |
public String getMessage() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
83 |
// i18n? |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
84 |
return "unexpected tag at #" + index + ": " + tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
85 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
86 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
87 |
public final int tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
88 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
89 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
90 |
public class EntryNotFound extends ConstantPoolException { |
1870
57a1138dffc8
6795903: fix latent build warnings in langtools repository
jjg
parents:
735
diff
changeset
|
91 |
private static final long serialVersionUID = 2885537606468581850L; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
92 |
EntryNotFound(Object value) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
93 |
super(-1); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
94 |
this.value = value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
95 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
96 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
97 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
98 |
public String getMessage() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
99 |
// i18n? |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
100 |
return "value not found: " + value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
101 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
102 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
103 |
public final Object value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
104 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
105 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
106 |
public static final int CONSTANT_Utf8 = 1; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
107 |
public static final int CONSTANT_Integer = 3; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
108 |
public static final int CONSTANT_Float = 4; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
109 |
public static final int CONSTANT_Long = 5; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
110 |
public static final int CONSTANT_Double = 6; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
111 |
public static final int CONSTANT_Class = 7; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
112 |
public static final int CONSTANT_String = 8; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
113 |
public static final int CONSTANT_Fieldref = 9; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
114 |
public static final int CONSTANT_Methodref = 10; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
115 |
public static final int CONSTANT_InterfaceMethodref = 11; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
116 |
public static final int CONSTANT_NameAndType = 12; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
117 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
118 |
ConstantPool(ClassReader cr) throws IOException, InvalidEntry { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
119 |
int count = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
120 |
pool = new CPInfo[count]; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
121 |
for (int i = 1; i < count; i++) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
122 |
int tag = cr.readUnsignedByte(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
123 |
switch (tag) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
124 |
case CONSTANT_Class: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
125 |
pool[i] = new CONSTANT_Class_info(this, cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
126 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
127 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
128 |
case CONSTANT_Double: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
129 |
pool[i] = new CONSTANT_Double_info(cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
130 |
i++; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
131 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
132 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
133 |
case CONSTANT_Fieldref: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
134 |
pool[i] = new CONSTANT_Fieldref_info(this, cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
135 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
136 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
137 |
case CONSTANT_Float: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
138 |
pool[i] = new CONSTANT_Float_info(cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
139 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
140 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
141 |
case CONSTANT_Integer: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
142 |
pool[i] = new CONSTANT_Integer_info(cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
143 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
144 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
145 |
case CONSTANT_InterfaceMethodref: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
146 |
pool[i] = new CONSTANT_InterfaceMethodref_info(this, cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
147 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
148 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
149 |
case CONSTANT_Long: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
150 |
pool[i] = new CONSTANT_Long_info(cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
151 |
i++; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
152 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
153 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
154 |
case CONSTANT_Methodref: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
155 |
pool[i] = new CONSTANT_Methodref_info(this, cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
156 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
157 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
158 |
case CONSTANT_NameAndType: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
159 |
pool[i] = new CONSTANT_NameAndType_info(this, cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
160 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
161 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
162 |
case CONSTANT_String: |
733 | 163 |
pool[i] = new CONSTANT_String_info(this, cr); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
164 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
165 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
166 |
case CONSTANT_Utf8: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
167 |
pool[i] = new CONSTANT_Utf8_info(cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
168 |
break; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
169 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
170 |
default: |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
171 |
throw new InvalidEntry(i, tag); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
172 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
173 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
174 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
175 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
176 |
public ConstantPool(CPInfo[] pool) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
177 |
this.pool = pool; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
178 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
179 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
180 |
public int size() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
181 |
return pool.length; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
182 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
183 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
184 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
185 |
int length = 2; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
186 |
for (int i = 1; i < size(); ) { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
187 |
CPInfo cpInfo = pool[i]; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
188 |
length += cpInfo.byteLength(); |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
189 |
i += cpInfo.size(); |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
190 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
191 |
return length; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
192 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
193 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
194 |
public CPInfo get(int index) throws InvalidIndex { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
195 |
if (index <= 0 || index >= pool.length) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
196 |
throw new InvalidIndex(index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
197 |
CPInfo info = pool[index]; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
198 |
if (info == null) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
199 |
// this occurs for indices referencing the "second half" of an |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
200 |
// 8 byte constant, such as CONSTANT_Double or CONSTANT_Long |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
201 |
throw new InvalidIndex(index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
202 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
203 |
return pool[index]; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
204 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
205 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
206 |
private CPInfo get(int index, int expected_type) throws InvalidIndex, UnexpectedEntry { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
207 |
CPInfo info = get(index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
208 |
if (info.getTag() != expected_type) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
209 |
throw new UnexpectedEntry(index, expected_type, info.getTag()); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
210 |
return info; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
211 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
212 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
213 |
public CONSTANT_Utf8_info getUTF8Info(int index) throws InvalidIndex, UnexpectedEntry { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
214 |
return ((CONSTANT_Utf8_info) get(index, CONSTANT_Utf8)); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
215 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
216 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
217 |
public CONSTANT_Class_info getClassInfo(int index) throws InvalidIndex, UnexpectedEntry { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
218 |
return ((CONSTANT_Class_info) get(index, CONSTANT_Class)); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
219 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
220 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
221 |
public CONSTANT_NameAndType_info getNameAndTypeInfo(int index) throws InvalidIndex, UnexpectedEntry { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
222 |
return ((CONSTANT_NameAndType_info) get(index, CONSTANT_NameAndType)); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
223 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
224 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
225 |
public String getUTF8Value(int index) throws InvalidIndex, UnexpectedEntry { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
226 |
return getUTF8Info(index).value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
227 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
228 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
229 |
public int getUTF8Index(String value) throws EntryNotFound { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
230 |
for (int i = 1; i < pool.length; i++) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
231 |
CPInfo info = pool[i]; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
232 |
if (info instanceof CONSTANT_Utf8_info && |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
233 |
((CONSTANT_Utf8_info) info).value.equals(value)) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
234 |
return i; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
235 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
236 |
throw new EntryNotFound(value); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
237 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
238 |
|
2978 | 239 |
public Iterable<CPInfo> entries() { |
240 |
return new Iterable<CPInfo>() { |
|
241 |
public Iterator<CPInfo> iterator() { |
|
242 |
return new Iterator<CPInfo>() { |
|
243 |
||
244 |
public boolean hasNext() { |
|
245 |
return next < pool.length; |
|
246 |
} |
|
247 |
||
248 |
public CPInfo next() { |
|
249 |
current = pool[next]; |
|
250 |
switch (current.getTag()) { |
|
251 |
case CONSTANT_Double: |
|
252 |
case CONSTANT_Long: |
|
253 |
next += 2; |
|
254 |
break; |
|
255 |
default: |
|
256 |
next += 1; |
|
257 |
} |
|
258 |
return current; |
|
259 |
} |
|
260 |
||
261 |
public void remove() { |
|
262 |
throw new UnsupportedOperationException(); |
|
263 |
} |
|
264 |
||
265 |
private CPInfo current; |
|
266 |
private int next = 1; |
|
267 |
||
268 |
}; |
|
269 |
} |
|
270 |
}; |
|
271 |
} |
|
272 |
||
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
273 |
private CPInfo[] pool; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
274 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
275 |
public interface Visitor<R,P> { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
276 |
R visitClass(CONSTANT_Class_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
277 |
R visitDouble(CONSTANT_Double_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
278 |
R visitFieldref(CONSTANT_Fieldref_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
279 |
R visitFloat(CONSTANT_Float_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
280 |
R visitInteger(CONSTANT_Integer_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
281 |
R visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
282 |
R visitLong(CONSTANT_Long_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
283 |
R visitNameAndType(CONSTANT_NameAndType_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
284 |
R visitMethodref(CONSTANT_Methodref_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
285 |
R visitString(CONSTANT_String_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
286 |
R visitUtf8(CONSTANT_Utf8_info info, P p); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
287 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
288 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
289 |
public static abstract class CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
290 |
CPInfo() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
291 |
this.cp = null; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
292 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
293 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
294 |
CPInfo(ConstantPool cp) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
295 |
this.cp = cp; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
296 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
297 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
298 |
public abstract int getTag(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
299 |
|
2978 | 300 |
/** The number of slots in the constant pool used by this entry. |
301 |
* 2 for CONSTANT_Double and CONSTANT_Long; 1 for everything else. */ |
|
302 |
public int size() { |
|
303 |
return 1; |
|
304 |
} |
|
305 |
||
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
306 |
public abstract int byteLength(); |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
307 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
308 |
public abstract <R,D> R accept(Visitor<R,D> visitor, D data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
309 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
310 |
protected final ConstantPool cp; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
311 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
312 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
313 |
public static abstract class CPRefInfo extends CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
314 |
protected CPRefInfo(ConstantPool cp, ClassReader cr, int tag) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
315 |
super(cp); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
316 |
this.tag = tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
317 |
class_index = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
318 |
name_and_type_index = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
319 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
320 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
321 |
protected CPRefInfo(ConstantPool cp, int tag, int class_index, int name_and_type_index) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
322 |
super(cp); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
323 |
this.tag = tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
324 |
this.class_index = class_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
325 |
this.name_and_type_index = name_and_type_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
326 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
327 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
328 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
329 |
return tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
330 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
331 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
332 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
333 |
return 5; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
334 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
335 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
336 |
public CONSTANT_Class_info getClassInfo() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
337 |
return cp.getClassInfo(class_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
338 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
339 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
340 |
public String getClassName() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
341 |
return cp.getClassInfo(class_index).getName(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
342 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
343 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
344 |
public CONSTANT_NameAndType_info getNameAndTypeInfo() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
345 |
return cp.getNameAndTypeInfo(name_and_type_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
346 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
347 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
348 |
public final int tag; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
349 |
public final int class_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
350 |
public final int name_and_type_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
351 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
352 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
353 |
public static class CONSTANT_Class_info extends CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
354 |
CONSTANT_Class_info(ConstantPool cp, ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
355 |
super(cp); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
356 |
name_index = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
357 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
358 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
359 |
public CONSTANT_Class_info(ConstantPool cp, int name_index) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
360 |
super(cp); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
361 |
this.name_index = name_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
362 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
363 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
364 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
365 |
return CONSTANT_Class; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
366 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
367 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
368 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
369 |
return 3; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
370 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
371 |
|
4071
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
372 |
/** |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
373 |
* Get the raw value of the class referenced by this constant pool entry. |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
374 |
* This will either be the name of the class, in internal form, or a |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
375 |
* descriptor for an array class. |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
376 |
* @return the raw value of the class |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
377 |
*/ |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
378 |
public String getName() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
379 |
return cp.getUTF8Value(name_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
380 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
381 |
|
4071
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
382 |
/** |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
383 |
* If this constant pool entry identifies either a class or interface type, |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
384 |
* or a possibly multi-dimensional array of a class of interface type, |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
385 |
* return the name of the class or interface in internal form. Otherwise, |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
386 |
* (i.e. if this is a possibly multi-dimensional array of a primitive type), |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
387 |
* return null. |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
388 |
* @return the base class or interface name |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
389 |
*/ |
2977
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
390 |
public String getBaseName() throws ConstantPoolException { |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
391 |
String name = getName(); |
4071
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
392 |
if (name.startsWith("[")) { |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
393 |
int index = name.indexOf("[L"); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
394 |
if (index == -1) |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
395 |
return null; |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
396 |
return name.substring(index + 2, name.length() - 1); |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
397 |
} else |
10c876d2de66
6887895: CONSTANT_Class_info getBaseName does not handle arrays of primitives correctly
jjg
parents:
3543
diff
changeset
|
398 |
return name; |
2977
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
399 |
} |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
400 |
|
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
401 |
public int getDimensionCount() throws ConstantPoolException { |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
402 |
String name = getName(); |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
403 |
int count = 0; |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
404 |
while (name.charAt(count) == '[') |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
405 |
count++; |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
406 |
return count; |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
407 |
} |
fdbc11409428
6841420: classfile: add new methods to ConstantClassInfo
jjg
parents:
2212
diff
changeset
|
408 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
409 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
410 |
public String toString() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
411 |
return "CONSTANT_Class_info[name_index: " + name_index + "]"; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
412 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
413 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
414 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
415 |
return visitor.visitClass(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
416 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
417 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
418 |
public final int name_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
419 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
420 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
421 |
public static class CONSTANT_Double_info extends CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
422 |
CONSTANT_Double_info(ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
423 |
value = cr.readDouble(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
424 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
425 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
426 |
public CONSTANT_Double_info(double value) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
427 |
this.value = value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
428 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
429 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
430 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
431 |
return CONSTANT_Double; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
432 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
433 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
434 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
435 |
return 9; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
436 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
437 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
438 |
@Override |
2978 | 439 |
public int size() { |
440 |
return 2; |
|
441 |
} |
|
442 |
||
443 |
@Override |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
444 |
public String toString() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
445 |
return "CONSTANT_Double_info[value: " + value + "]"; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
446 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
447 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
448 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
449 |
return visitor.visitDouble(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
450 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
451 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
452 |
public final double value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
453 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
454 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
455 |
public static class CONSTANT_Fieldref_info extends CPRefInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
456 |
CONSTANT_Fieldref_info(ConstantPool cp, ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
457 |
super(cp, cr, CONSTANT_Fieldref); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
458 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
459 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
460 |
public CONSTANT_Fieldref_info(ConstantPool cp, int class_index, int name_and_type_index) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
461 |
super(cp, CONSTANT_Fieldref, class_index, name_and_type_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
462 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
463 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
464 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
465 |
public String toString() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
466 |
return "CONSTANT_Fieldref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]"; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
467 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
468 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
469 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
470 |
return visitor.visitFieldref(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
471 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
472 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
473 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
474 |
public static class CONSTANT_Float_info extends CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
475 |
CONSTANT_Float_info(ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
476 |
value = cr.readFloat(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
477 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
478 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
479 |
public CONSTANT_Float_info(float value) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
480 |
this.value = value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
481 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
482 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
483 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
484 |
return CONSTANT_Float; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
485 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
486 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
487 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
488 |
return 5; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
489 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
490 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
491 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
492 |
public String toString() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
493 |
return "CONSTANT_Float_info[value: " + value + "]"; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
494 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
495 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
496 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
497 |
return visitor.visitFloat(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
498 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
499 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
500 |
public final float value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
501 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
502 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
503 |
public static class CONSTANT_Integer_info extends CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
504 |
CONSTANT_Integer_info(ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
505 |
value = cr.readInt(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
506 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
507 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
508 |
public CONSTANT_Integer_info(int value) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
509 |
this.value = value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
510 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
511 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
512 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
513 |
return CONSTANT_Integer; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
514 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
515 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
516 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
517 |
return 5; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
518 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
519 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
520 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
521 |
public String toString() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
522 |
return "CONSTANT_Integer_info[value: " + value + "]"; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
523 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
524 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
525 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
526 |
return visitor.visitInteger(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
527 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
528 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
529 |
public final int value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
530 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
531 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
532 |
public static class CONSTANT_InterfaceMethodref_info extends CPRefInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
533 |
CONSTANT_InterfaceMethodref_info(ConstantPool cp, ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
534 |
super(cp, cr, CONSTANT_InterfaceMethodref); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
535 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
536 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
537 |
public CONSTANT_InterfaceMethodref_info(ConstantPool cp, int class_index, int name_and_type_index) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
538 |
super(cp, CONSTANT_InterfaceMethodref, class_index, name_and_type_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
539 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
540 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
541 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
542 |
public String toString() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
543 |
return "CONSTANT_InterfaceMethodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]"; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
544 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
545 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
546 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
547 |
return visitor.visitInterfaceMethodref(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
548 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
549 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
550 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
551 |
public static class CONSTANT_Long_info extends CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
552 |
CONSTANT_Long_info(ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
553 |
value = cr.readLong(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
554 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
555 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
556 |
public CONSTANT_Long_info(long value) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
557 |
this.value = value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
558 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
559 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
560 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
561 |
return CONSTANT_Long; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
562 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
563 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
564 |
@Override |
2978 | 565 |
public int size() { |
566 |
return 2; |
|
567 |
} |
|
568 |
||
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
569 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
570 |
return 9; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
571 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
572 |
|
2978 | 573 |
@Override |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
574 |
public String toString() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
575 |
return "CONSTANT_Long_info[value: " + value + "]"; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
576 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
577 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
578 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
579 |
return visitor.visitLong(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
580 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
581 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
582 |
public final long value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
583 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
584 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
585 |
public static class CONSTANT_Methodref_info extends CPRefInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
586 |
CONSTANT_Methodref_info(ConstantPool cp, ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
587 |
super(cp, cr, CONSTANT_Methodref); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
588 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
589 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
590 |
public CONSTANT_Methodref_info(ConstantPool cp, int class_index, int name_and_type_index) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
591 |
super(cp, CONSTANT_Methodref, class_index, name_and_type_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
592 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
593 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
594 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
595 |
public String toString() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
596 |
return "CONSTANT_Methodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]"; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
597 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
598 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
599 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
600 |
return visitor.visitMethodref(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
601 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
602 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
603 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
604 |
public static class CONSTANT_NameAndType_info extends CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
605 |
CONSTANT_NameAndType_info(ConstantPool cp, ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
606 |
super(cp); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
607 |
name_index = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
608 |
type_index = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
609 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
610 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
611 |
public CONSTANT_NameAndType_info(ConstantPool cp, int name_index, int type_index) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
612 |
super(cp); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
613 |
this.name_index = name_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
614 |
this.type_index = type_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
615 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
616 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
617 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
618 |
return CONSTANT_NameAndType; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
619 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
620 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
621 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
622 |
return 5; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
623 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
624 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
625 |
public String getName() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
626 |
return cp.getUTF8Value(name_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
627 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
628 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
629 |
public String getType() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
630 |
return cp.getUTF8Value(type_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
631 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
632 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
633 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
634 |
return visitor.visitNameAndType(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
635 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
636 |
|
3141
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
637 |
@Override |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
638 |
public String toString() { |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
639 |
return "CONSTANT_NameAndType_info[name_index: " + name_index + ", type_index: " + type_index + "]"; |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
640 |
} |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
641 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
642 |
public final int name_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
643 |
public final int type_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
644 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
645 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
646 |
public static class CONSTANT_String_info extends CPInfo { |
733 | 647 |
CONSTANT_String_info(ConstantPool cp, ClassReader cr) throws IOException { |
648 |
super(cp); |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
649 |
string_index = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
650 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
651 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
652 |
public CONSTANT_String_info(ConstantPool cp, int string_index) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
653 |
super(cp); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
654 |
this.string_index = string_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
655 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
656 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
657 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
658 |
return CONSTANT_String; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
659 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
660 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
661 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
662 |
return 3; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
663 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
664 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
665 |
public String getString() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
666 |
return cp.getUTF8Value(string_index); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
667 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
668 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
669 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
670 |
return visitor.visitString(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
671 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
672 |
|
3141
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
673 |
@Override |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
674 |
public String toString() { |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
675 |
return "CONSTANT_String_info[class_index: " + string_index + "]"; |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
676 |
} |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
677 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
678 |
public final int string_index; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
679 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
680 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
681 |
public static class CONSTANT_Utf8_info extends CPInfo { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
682 |
CONSTANT_Utf8_info(ClassReader cr) throws IOException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
683 |
value = cr.readUTF(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
684 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
685 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
686 |
public CONSTANT_Utf8_info(String value) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
687 |
this.value = value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
688 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
689 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
690 |
public int getTag() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
691 |
return CONSTANT_Utf8; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
692 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
693 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
694 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
695 |
class SizeOutputStream extends OutputStream { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
696 |
@Override |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
697 |
public void write(int b) throws IOException { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
698 |
size++; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
699 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
700 |
int size; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
701 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
702 |
SizeOutputStream sizeOut = new SizeOutputStream(); |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
703 |
DataOutputStream out = new DataOutputStream(sizeOut); |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
704 |
try { out.writeUTF(value); } catch (IOException ignore) { } |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
705 |
return 1 + sizeOut.size; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
706 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
3141
diff
changeset
|
707 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
708 |
@Override |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
709 |
public String toString() { |
3141
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
710 |
if (value.length() < 32 && isPrintableAscii(value)) |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
711 |
return "CONSTANT_Utf8_info[value: \"" + value + "\"]"; |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
712 |
else |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
713 |
return "CONSTANT_Utf8_info[value: (" + value.length() + " chars)]"; |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
714 |
} |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
715 |
|
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
716 |
static boolean isPrintableAscii(String s) { |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
717 |
for (int i = 0; i < s.length(); i++) { |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
718 |
char c = s.charAt(i); |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
719 |
if (c < 32 || c >= 127) |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
720 |
return false; |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
721 |
} |
79c119fae7fb
6852856: javap changes to facilitate subclassing javap for variants
jjg
parents:
2978
diff
changeset
|
722 |
return true; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
723 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
724 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
725 |
public <R, D> R accept(Visitor<R, D> visitor, D data) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
726 |
return visitor.visitUtf8(this, data); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
727 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
728 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
729 |
public final String value; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
730 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
731 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
732 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
733 |
} |