author | mikael |
Tue, 22 Dec 2015 20:47:40 -0800 | |
changeset 35023 | ee10ca0129b2 |
parent 30846 | 2b3f379840f0 |
permissions | -rw-r--r-- |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
1 |
/* |
17809
c9d1984367b6
8012333: javac, ClassFile should have a read(Path) method
vromero
parents:
9303
diff
changeset
|
2 |
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. 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 |
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
727
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 |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
727
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 |
* |
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
727
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 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
28 |
import java.io.File; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
29 |
import java.io.IOException; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
30 |
import java.io.InputStream; |
18656
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
31 |
import java.nio.file.Files; |
17809
c9d1984367b6
8012333: javac, ClassFile should have a read(Path) method
vromero
parents:
9303
diff
changeset
|
32 |
import java.nio.file.Path; |
727
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 |
import static com.sun.tools.classfile.AccessFlags.*; |
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 |
/** |
9303
eae35c201e19
7032975: API files in javax.annotation.processing need to be updated for references to JLS
jjh
parents:
5847
diff
changeset
|
37 |
* See JVMS, section 4.2. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
38 |
* |
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
39 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
40 |
* If you write code that depends on this, you do so at your own risk. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
41 |
* 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
|
42 |
* deletion without notice.</b> |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
43 |
*/ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
44 |
public class ClassFile { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
45 |
public static ClassFile read(File file) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
46 |
throws IOException, ConstantPoolException { |
18656
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
47 |
return read(file.toPath(), new Attribute.Factory()); |
727
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 |
|
18656
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
50 |
public static ClassFile read(Path input) |
17809
c9d1984367b6
8012333: javac, ClassFile should have a read(Path) method
vromero
parents:
9303
diff
changeset
|
51 |
throws IOException, ConstantPoolException { |
18656
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
52 |
return read(input, new Attribute.Factory()); |
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
53 |
} |
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
54 |
|
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
55 |
public static ClassFile read(Path input, Attribute.Factory attributeFactory) |
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
56 |
throws IOException, ConstantPoolException { |
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
57 |
try (InputStream in = Files.newInputStream(input)) { |
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
58 |
return new ClassFile(in, attributeFactory); |
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
59 |
} |
17809
c9d1984367b6
8012333: javac, ClassFile should have a read(Path) method
vromero
parents:
9303
diff
changeset
|
60 |
} |
c9d1984367b6
8012333: javac, ClassFile should have a read(Path) method
vromero
parents:
9303
diff
changeset
|
61 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
62 |
public static ClassFile read(File file, Attribute.Factory attributeFactory) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
63 |
throws IOException, ConstantPoolException { |
18656
d66c77f01912
8017609: javac, ClassFile.read(Path) should be ClassFile.read(Path, Attribute.Factory)
vromero
parents:
17809
diff
changeset
|
64 |
return read(file.toPath(), attributeFactory); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
65 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
66 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
67 |
public static ClassFile read(InputStream in) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
68 |
throws IOException, ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
69 |
return new ClassFile(in, new Attribute.Factory()); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
70 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
71 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
72 |
public static ClassFile read(InputStream in, Attribute.Factory attributeFactory) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
73 |
throws IOException, ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
74 |
return new ClassFile(in, attributeFactory); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
75 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
76 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
77 |
ClassFile(InputStream in, Attribute.Factory attributeFactory) throws IOException, ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
78 |
ClassReader cr = new ClassReader(this, in, attributeFactory); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
79 |
magic = cr.readInt(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
80 |
minor_version = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
81 |
major_version = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
82 |
constant_pool = new ConstantPool(cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
83 |
access_flags = new AccessFlags(cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
84 |
this_class = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
85 |
super_class = cr.readUnsignedShort(); |
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 |
int interfaces_count = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
88 |
interfaces = new int[interfaces_count]; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
89 |
for (int i = 0; i < interfaces_count; i++) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
90 |
interfaces[i] = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
91 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
92 |
int fields_count = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
93 |
fields = new Field[fields_count]; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
94 |
for (int i = 0; i < fields_count; i++) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
95 |
fields[i] = new Field(cr); |
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 |
int methods_count = cr.readUnsignedShort(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
98 |
methods = new Method[methods_count]; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
99 |
for (int i = 0; i < methods_count; i++) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
100 |
methods[i] = new Method(cr); |
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 |
attributes = new Attributes(cr); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
103 |
} |
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 |
public ClassFile(int magic, int minor_version, int major_version, |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
106 |
ConstantPool constant_pool, AccessFlags access_flags, |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
107 |
int this_class, int super_class, int[] interfaces, |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
108 |
Field[] fields, Method[] methods, Attributes attributes) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
109 |
this.magic = magic; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
110 |
this.minor_version = minor_version; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
111 |
this.major_version = major_version; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
112 |
this.constant_pool = constant_pool; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
113 |
this.access_flags = access_flags; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
114 |
this.this_class = this_class; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
115 |
this.super_class = super_class; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
116 |
this.interfaces = interfaces; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
117 |
this.fields = fields; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
118 |
this.methods = methods; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
119 |
this.attributes = attributes; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
120 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
121 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
122 |
public String getName() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
123 |
return constant_pool.getClassInfo(this_class).getName(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
124 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
125 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
126 |
public String getSuperclassName() throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
127 |
return constant_pool.getClassInfo(super_class).getName(); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
128 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
129 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
130 |
public String getInterfaceName(int i) throws ConstantPoolException { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
131 |
return constant_pool.getClassInfo(interfaces[i]).getName(); |
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 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
134 |
public Attribute getAttribute(String name) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
135 |
return attributes.get(name); |
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 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
138 |
public boolean isClass() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
139 |
return !isInterface(); |
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 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
142 |
public boolean isInterface() { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
143 |
return access_flags.is(ACC_INTERFACE); |
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 |
|
3543
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
146 |
public int byteLength() { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
147 |
return 4 + // magic |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
148 |
2 + // minor |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
149 |
2 + // major |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
150 |
constant_pool.byteLength() + |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
151 |
2 + // access flags |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
152 |
2 + // this_class |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
153 |
2 + // super_class |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
154 |
byteLength(interfaces) + |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
155 |
byteLength(fields) + |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
156 |
byteLength(methods) + |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
157 |
attributes.byteLength(); |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
158 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
159 |
|
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
160 |
private int byteLength(int[] indices) { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
161 |
return 2 + 2 * indices.length; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
162 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
163 |
|
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
164 |
private int byteLength(Field[] fields) { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
165 |
int length = 2; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
166 |
for (Field f: fields) |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
167 |
length += f.byteLength(); |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
168 |
return length; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
169 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
170 |
|
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
171 |
private int byteLength(Method[] methods) { |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
172 |
int length = 2; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
173 |
for (Method m: methods) |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
174 |
length += m.byteLength(); |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
175 |
return length; |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
176 |
} |
58b72b096bcb
6866657: add byteLength method to primary classfile types
jjg
parents:
735
diff
changeset
|
177 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
178 |
public final int magic; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
179 |
public final int minor_version; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
180 |
public final int major_version; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
181 |
public final ConstantPool constant_pool; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
182 |
public final AccessFlags access_flags; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
183 |
public final int this_class; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
184 |
public final int super_class; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
185 |
public final int[] interfaces; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
186 |
public final Field[] fields; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
187 |
public final Method[] methods; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
188 |
public final Attributes attributes; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
189 |
} |