Package list findbugs / 4665aea
remove bcel 5.2 yesx 8 years ago
355 changed file(s) with 0 addition(s) and 49092 deletion(s). Raw diff Collapse all Expand all
+0
-204
build/bcel-5.2-src/bcel-5.2/LICENSE.txt less more
0 /*
1 * Apache License
2 * Version 2.0, January 2004
3 * http://www.apache.org/licenses/
4 *
5 * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 *
7 * 1. Definitions.
8 *
9 * "License" shall mean the terms and conditions for use, reproduction,
10 * and distribution as defined by Sections 1 through 9 of this document.
11 *
12 * "Licensor" shall mean the copyright owner or entity authorized by
13 * the copyright owner that is granting the License.
14 *
15 * "Legal Entity" shall mean the union of the acting entity and all
16 * other entities that control, are controlled by, or are under common
17 * control with that entity. For the purposes of this definition,
18 * "control" means (i) the power, direct or indirect, to cause the
19 * direction or management of such entity, whether by contract or
20 * otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 * outstanding shares, or (iii) beneficial ownership of such entity.
22 *
23 * "You" (or "Your") shall mean an individual or Legal Entity
24 * exercising permissions granted by this License.
25 *
26 * "Source" form shall mean the preferred form for making modifications,
27 * including but not limited to software source code, documentation
28 * source, and configuration files.
29 *
30 * "Object" form shall mean any form resulting from mechanical
31 * transformation or translation of a Source form, including but
32 * not limited to compiled object code, generated documentation,
33 * and conversions to other media types.
34 *
35 * "Work" shall mean the work of authorship, whether in Source or
36 * Object form, made available under the License, as indicated by a
37 * copyright notice that is included in or attached to the work
38 * (an example is provided in the Appendix below).
39 *
40 * "Derivative Works" shall mean any work, whether in Source or Object
41 * form, that is based on (or derived from) the Work and for which the
42 * editorial revisions, annotations, elaborations, or other modifications
43 * represent, as a whole, an original work of authorship. For the purposes
44 * of this License, Derivative Works shall not include works that remain
45 * separable from, or merely link (or bind by name) to the interfaces of,
46 * the Work and Derivative Works thereof.
47 *
48 * "Contribution" shall mean any work of authorship, including
49 * the original version of the Work and any modifications or additions
50 * to that Work or Derivative Works thereof, that is intentionally
51 * submitted to Licensor for inclusion in the Work by the copyright owner
52 * or by an individual or Legal Entity authorized to submit on behalf of
53 * the copyright owner. For the purposes of this definition, "submitted"
54 * means any form of electronic, verbal, or written communication sent
55 * to the Licensor or its representatives, including but not limited to
56 * communication on electronic mailing lists, source code control systems,
57 * and issue tracking systems that are managed by, or on behalf of, the
58 * Licensor for the purpose of discussing and improving the Work, but
59 * excluding communication that is conspicuously marked or otherwise
60 * designated in writing by the copyright owner as "Not a Contribution."
61 *
62 * "Contributor" shall mean Licensor and any individual or Legal Entity
63 * on behalf of whom a Contribution has been received by Licensor and
64 * subsequently incorporated within the Work.
65 *
66 * 2. Grant of Copyright License. Subject to the terms and conditions of
67 * this License, each Contributor hereby grants to You a perpetual,
68 * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 * copyright license to reproduce, prepare Derivative Works of,
70 * publicly display, publicly perform, sublicense, and distribute the
71 * Work and such Derivative Works in Source or Object form.
72 *
73 * 3. Grant of Patent License. Subject to the terms and conditions of
74 * this License, each Contributor hereby grants to You a perpetual,
75 * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 * (except as stated in this section) patent license to make, have made,
77 * use, offer to sell, sell, import, and otherwise transfer the Work,
78 * where such license applies only to those patent claims licensable
79 * by such Contributor that are necessarily infringed by their
80 * Contribution(s) alone or by combination of their Contribution(s)
81 * with the Work to which such Contribution(s) was submitted. If You
82 * institute patent litigation against any entity (including a
83 * cross-claim or counterclaim in a lawsuit) alleging that the Work
84 * or a Contribution incorporated within the Work constitutes direct
85 * or contributory patent infringement, then any patent licenses
86 * granted to You under this License for that Work shall terminate
87 * as of the date such litigation is filed.
88 *
89 * 4. Redistribution. You may reproduce and distribute copies of the
90 * Work or Derivative Works thereof in any medium, with or without
91 * modifications, and in Source or Object form, provided that You
92 * meet the following conditions:
93 *
94 * (a) You must give any other recipients of the Work or
95 * Derivative Works a copy of this License; and
96 *
97 * (b) You must cause any modified files to carry prominent notices
98 * stating that You changed the files; and
99 *
100 * (c) You must retain, in the Source form of any Derivative Works
101 * that You distribute, all copyright, patent, trademark, and
102 * attribution notices from the Source form of the Work,
103 * excluding those notices that do not pertain to any part of
104 * the Derivative Works; and
105 *
106 * (d) If the Work includes a "NOTICE" text file as part of its
107 * distribution, then any Derivative Works that You distribute must
108 * include a readable copy of the attribution notices contained
109 * within such NOTICE file, excluding those notices that do not
110 * pertain to any part of the Derivative Works, in at least one
111 * of the following places: within a NOTICE text file distributed
112 * as part of the Derivative Works; within the Source form or
113 * documentation, if provided along with the Derivative Works; or,
114 * within a display generated by the Derivative Works, if and
115 * wherever such third-party notices normally appear. The contents
116 * of the NOTICE file are for informational purposes only and
117 * do not modify the License. You may add Your own attribution
118 * notices within Derivative Works that You distribute, alongside
119 * or as an addendum to the NOTICE text from the Work, provided
120 * that such additional attribution notices cannot be construed
121 * as modifying the License.
122 *
123 * You may add Your own copyright statement to Your modifications and
124 * may provide additional or different license terms and conditions
125 * for use, reproduction, or distribution of Your modifications, or
126 * for any such Derivative Works as a whole, provided Your use,
127 * reproduction, and distribution of the Work otherwise complies with
128 * the conditions stated in this License.
129 *
130 * 5. Submission of Contributions. Unless You explicitly state otherwise,
131 * any Contribution intentionally submitted for inclusion in the Work
132 * by You to the Licensor shall be under the terms and conditions of
133 * this License, without any additional terms or conditions.
134 * Notwithstanding the above, nothing herein shall supersede or modify
135 * the terms of any separate license agreement you may have executed
136 * with Licensor regarding such Contributions.
137 *
138 * 6. Trademarks. This License does not grant permission to use the trade
139 * names, trademarks, service marks, or product names of the Licensor,
140 * except as required for reasonable and customary use in describing the
141 * origin of the Work and reproducing the content of the NOTICE file.
142 *
143 * 7. Disclaimer of Warranty. Unless required by applicable law or
144 * agreed to in writing, Licensor provides the Work (and each
145 * Contributor provides its Contributions) on an "AS IS" BASIS,
146 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 * implied, including, without limitation, any warranties or conditions
148 * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 * PARTICULAR PURPOSE. You are solely responsible for determining the
150 * appropriateness of using or redistributing the Work and assume any
151 * risks associated with Your exercise of permissions under this License.
152 *
153 * 8. Limitation of Liability. In no event and under no legal theory,
154 * whether in tort (including negligence), contract, or otherwise,
155 * unless required by applicable law (such as deliberate and grossly
156 * negligent acts) or agreed to in writing, shall any Contributor be
157 * liable to You for damages, including any direct, indirect, special,
158 * incidental, or consequential damages of any character arising as a
159 * result of this License or out of the use or inability to use the
160 * Work (including but not limited to damages for loss of goodwill,
161 * work stoppage, computer failure or malfunction, or any and all
162 * other commercial damages or losses), even if such Contributor
163 * has been advised of the possibility of such damages.
164 *
165 * 9. Accepting Warranty or Additional Liability. While redistributing
166 * the Work or Derivative Works thereof, You may choose to offer,
167 * and charge a fee for, acceptance of support, warranty, indemnity,
168 * or other liability obligations and/or rights consistent with this
169 * License. However, in accepting such obligations, You may act only
170 * on Your own behalf and on Your sole responsibility, not on behalf
171 * of any other Contributor, and only if You agree to indemnify,
172 * defend, and hold each Contributor harmless for any liability
173 * incurred by, or claims asserted against, such Contributor by reason
174 * of your accepting any such warranty or additional liability.
175 *
176 * END OF TERMS AND CONDITIONS
177 *
178 * APPENDIX: How to apply the Apache License to your work.
179 *
180 * To apply the Apache License to your work, attach the following
181 * boilerplate notice, with the fields enclosed by brackets "[]"
182 * replaced with your own identifying information. (Don't include
183 * the brackets!) The text should be enclosed in the appropriate
184 * comment syntax for the file format. We also recommend that a
185 * file or class name and description of purpose be included on the
186 * same "printed page" as the copyright notice for easier
187 * identification within third-party archives.
188 *
189 * Copyright [yyyy] [name of copyright owner]
190 *
191 * Licensed under the Apache License, Version 2.0 (the "License");
192 * you may not use this file except in compliance with the License.
193 * You may obtain a copy of the License at
194 *
195 * http://www.apache.org/licenses/LICENSE-2.0
196 *
197 * Unless required by applicable law or agreed to in writing, software
198 * distributed under the License is distributed on an "AS IS" BASIS,
199 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 * See the License for the specific language governing permissions and
201 * limitations under the License.
202 */
203
+0
-10
build/bcel-5.2-src/bcel-5.2/NOTICE.txt less more
0 =========================================================================
1 == NOTICE file corresponding to the section 4 d of ==
2 == the Apache License, Version 2.0, ==
3 == in this case for the Apache Jakarta-BCEL distribution. ==
4 =========================================================================
5
6 This product includes software developed by
7 The Apache Software Foundation (http://www.apache.org/).
8
9
+0
-36
build/bcel-5.2-src/bcel-5.2/README.txt less more
0 Running a console based verifier
1
2 java org.apache.bcel.verifier.Verifier fully.qualified.class.Name
3
4 lets JustIce work standalone.
5 If you get a "java.lang.OutOfMemoryError", you should increase the
6 maximum Java heap space. A command like
7
8 java -Xmx1887436800 org.apache.bcel.verifier.Verifier f.q.c.Name
9
10 will usually resolve the problem. The value above is suitable for
11 big server machines; if your machine starts swapping to disk, try
12 to lower the value.
13
14
15
16 Running a graphics based verifier
17
18 If you prefer a graphical application, you should use a command like
19
20 java org.apache.bcel.verifier.GraphicalVerifier
21
22 to launch one. Again, you may have to resolve a memory issue depending
23 on the classes to verify.
24
25
26 Contact
27
28 If you spot a bug in the BCEL or its accompanying verifier "JustIce" please
29 check with the BCEL mailing list
30
31 http://jakarta.apache.org/bcel
32
33 or enter the issue into the BCEL bug database
34
35 http://issues.apache.org/bugzilla/enter_bug.cgi?product=BCEL
+0
-39
build/bcel-5.2-src/bcel-5.2/build.xml less more
0 <project name="bcel" default="jar">
1
2 <property name="src.dir" value="src/java"/>
3 <property name="classes.dir" value="eclipse"/>
4 <property name="jar.dir" value="."/>
5
6 <target name="jar" depends="clean,classes">
7 <!-- Main engine and command line jar file. -->
8 <jar destfile="${jar.dir}/bcel.jar" >
9 <!-- Compiled classes, properties files. -->
10 <fileset dir="${classes.dir}">
11 <include name="**/*.class"/>
12 </fileset>
13 </jar>
14 </target>
15
16 <!-- Compile Java source files, and copy other files (properties,
17 images, html, XSL stylesheets) that need to be part of the codebase. -->
18 <target name="classes">
19 <mkdir dir="${classes.dir}"/>
20 <!-- Compile Java source files. -->
21 <javac srcdir="${src.dir}"
22 destdir="${classes.dir}"
23 source="1.5"
24 target="jsr14"
25 deprecation="on"
26 debug="on">
27 </javac>
28 </target>
29 <!-- Delete generated files. -->
30 <target name="clean">
31 <delete file="${classes.dir}"/>
32 <mkdir dir="${classes.dir}"/>
33 </target>
34
35
36 </project>
37
38 <!-- vim:set ts=4: -->
+0
-33
build/bcel-5.2-src/bcel-5.2/maven.xml less more
0 <!--
1
2 Copyright 2001-2004 The Apache Software Foundation.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 -->
17
18 <project default="jar:jar" xmlns:j="jelly:core">
19
20 <preGoal name="dist:build-bin">
21 <copy todir="${maven.dist.bin.assembly.dir}">
22 <fileset file='${basedir}/NOTICE.txt'/>
23 </copy>
24 </preGoal>
25
26 <preGoal name="dist:build-src">
27 <copy todir="${maven.dist.src.assembly.dir}">
28 <fileset file='${basedir}/NOTICE.txt'/>
29 </copy>
30 </preGoal>
31
32 </project>
+0
-52
build/bcel-5.2-src/bcel-5.2/project.properties less more
0 maven.repo.list=apache.snapshots
1
2 maven.repo.apache.snapshots=scp://cvs.apache.org
3 maven.repo.apache.snapshots.directory=/www/cvs.apache.org/repository
4 maven.repo.apache.snapshots.username=${maven.repo.apache.username}
5 maven.repo.apache.snapshots.privatekey=${maven.repo.apache.privatekey}
6 maven.repo.apache.snapshots.passphrase=${maven.repo.apache.passphrase}
7 maven.repo.apache.snapshots.group=apcvs
8
9 maven.repo.apache.releases=scp://people.apache.org
10 maven.repo.apache.releases.directory=/www/www.apache.org/dist/java-repository
11 maven.repo.apache.releases.group=apcvs
12 #maven.repo.apache.releases.username=
13 #maven.repo.apache.releases.privatekey=
14 #maven.repo.apache.releases.passphrase=
15
16 #maven.mode.online =
17
18 maven.username = ${user.name}
19
20 maven.compile.debug = on
21 maven.compile.deprecation = off
22 maven.compile.optimize = off
23 maven.compile.source = 1.3
24 maven.compile.target = 1.3
25
26 maven.jar.manifest.attributes.list=X-Compile-Source-JDK,X-Compile-Target-JDK
27 maven.jar.manifest.attribute.X-Compile-Source-JDK=${maven.compile.source}
28 maven.jar.manifest.attribute.X-Compile-Target-JDK=${maven.compile.target}
29
30 maven.jarResources.basedir = src/java
31 maven.jar.excludes = **/package.html
32 #maven.junit.fork = true
33
34 maven.test.failure.ignore = true
35 maven.test.skip = false
36
37 maven.javadoc.author = false
38 maven.javadoc.links = http://java.sun.com/j2se/1.4.2/docs/api/
39
40 maven.changelog.factory = org.apache.maven.svnlib.SvnChangeLogFactory
41
42 maven.changes.issue.template = %URL%/bugzilla/show_bug.cgi?id=%ISSUE%
43
44 maven.xdoc.jsl = ../commons-build/commons-site.jsl
45 maven.xdoc.date = left
46 maven.xdoc.poweredby.image = maven-feather.png
47 maven.xdoc.version = ${pom.currentVersion}
48 maven.xdoc.developmentProcessUrl = http://jakarta.apache.org/site/management.html
49 maven.xdoc.includeProjectDocumentation = yes
50
51 maven.jar.override = off
+0
-158
build/bcel-5.2-src/bcel-5.2/project.xml less more
0 <?xml version="1.0"?>
1 <project>
2
3 <pomVersion>3</pomVersion>
4 <name>jakarta-bcel</name>
5 <id>bcel</id>
6 <currentVersion>5.2</currentVersion>
7 <organization>
8 <name>Apache Software Foundation</name>
9 <url>http://www.apache.org</url>
10 <logo>http://jakarta.apache.org/images/jakarta-logo.gif</logo>
11 </organization>
12 <inceptionYear>2002</inceptionYear>
13 <package>org.apache.bcel</package>
14
15 <logo>/images/bcel-logo.gif</logo>
16
17 <shortDescription>Bytecode Engineering Library</shortDescription>
18
19 <description>
20 Bytecode Engineering Library
21 </description>
22
23 <licenses>
24 <license>
25 <name>The Apache Software License, Version 2.0</name>
26 <url>/LICENSE.txt</url>
27 <distribution>repo</distribution>
28 </license>
29 </licenses>
30
31 <gumpRepositoryId>jakarta</gumpRepositoryId>
32 <url>http://jakarta.apache.org/bcel/</url>
33 <issueTrackingUrl>http://issues.apache.org/bugzilla</issueTrackingUrl>
34 <siteAddress>people.apache.org</siteAddress>
35 <siteDirectory>/home/tcurdt/public_html/bcel/rc3/site</siteDirectory>
36 <!--
37 <siteDirectory>/www/jakarta.apache.org/bcel/</siteDirectory>
38 -->
39 <repository>
40 <connection>scm:svn:http://svn.apache.org/repos/asf/jakarta/bcel/trunk</connection>
41 <url>http://svn.apache.org/repos/asf/jakarta/bcel/trunk</url>
42 </repository>
43
44 <mailingLists>
45 <mailingList>
46 <name>BCEL User List</name>
47 <subscribe>bcel-user-subscribe@jakarta.apache.org</subscribe>
48 <unsubscribe>bcel-user-unsubscribe@jakarta.apache.org</unsubscribe>
49 <archive>http://www.mail-archive.com/bcel-user@jakarta.apache.org/</archive>
50 </mailingList>
51 <mailingList>
52 <name>BCEL Developer List</name>
53 <subscribe>bcel-dev-subscribe@jakarta.apache.org</subscribe>
54 <unsubscribe>bcel-dev-unsubscribe@jakarta.apache.org</unsubscribe>
55 <archive>http://www.mail-archive.com/bcel-dev@jakarta.apache.org/</archive>
56 </mailingList>
57 </mailingLists>
58
59 <developers>
60
61 <developer>
62 <name>Markus Dahm</name>
63 <id>mdahm</id>
64 <email>m.dahm at gmx.de</email>
65 <organization>it-frameworksolutions</organization>
66 </developer>
67
68 <developer>
69 <name>Jason van Zyl</name>
70 <id>jvanzyl</id>
71 <email>jason at zenplex.com</email>
72 <organization>Zenplex</organization>
73 </developer>
74
75 <developer>
76 <name>Enver Haase</name>
77 <id>ehaase</id>
78 <email>enver at convergence.de</email>
79 <organization>convergence</organization>
80 </developer>
81
82 <developer>
83 <name>Dave Brosius</name>
84 <id>dbrosius</id>
85 <email>dbrosius at mebigfatguy.com</email>
86 </developer>
87
88 <developer>
89 <name>Torsten Curdt</name>
90 <id>tcurdt</id>
91 <email>tcurdt at apache.org</email>
92 </developer>
93
94 </developers>
95
96 <dependencies>
97
98 <dependency>
99 <id>regexp</id>
100 <version>1.2</version>
101 </dependency>
102
103 <!--
104 <dependency>
105 <groupId>maven-plugins</groupId>
106 <artifactId>maven-cobertura-plugin</artifactId>
107 <version>1.1</version>
108 <type>plugin</type>
109 </dependency>
110 -->
111
112 </dependencies>
113
114 <build>
115
116 <sourceDirectory>src/java</sourceDirectory>
117
118 <resources>
119 <resource>
120 <directory>${basedir}</directory>
121 <includes>
122 <include>NOTICE.txt</include>
123 </includes>
124 <targetPath>META-INF</targetPath>
125 </resource>
126 </resources>
127
128 <!--
129 <testSourceDirectory>src/java</testSourceDirectory>
130
131 <unitTestPatterns>
132 <unitTestPattern>exclude = **/*.class</unitTestPattern>
133 </unitTestPatterns>
134 -->
135
136 </build>
137
138 <reports>
139 <report>maven-license-plugin</report>
140 <report>maven-changelog-plugin</report>
141 <report>maven-changes-plugin</report>
142 <report>maven-developer-activity-plugin</report>
143 <report>maven-javadoc-plugin</report>
144 <!-- <report>maven-junit-report-plugin</report> -->
145 <!-- <report>maven-cobertura-plugin</report> -->
146 <report>maven-jxr-plugin</report>
147 <report>maven-pmd-plugin</report>
148 <!-- <report>maven-tasklist-plugin</report> -->
149 <!-- <report>maven-linkcheck-plugin</report> -->
150 <!-- <report>maven-findbugs-plugin</report> -->
151 <!-- <report>maven-jellydoc-plugin</report> -->
152 <!-- <report>maven-statcvs-plugin</report> -->
153 </reports>
154
155 </project>
156
157
+0
-769
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/Constants.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel;
17
18 /**
19 * Constants for the project, mostly defined in the JVM specification.
20 *
21 * @version $Id: Constants.java 410087 2006-05-29 12:12:19Z tcurdt $
22 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
23 */
24 public interface Constants {
25 /** Major and minor version of the code.
26 */
27 public final static short MAJOR_1_1 = 45;
28 public final static short MINOR_1_1 = 3;
29 public final static short MAJOR_1_2 = 46;
30 public final static short MINOR_1_2 = 0;
31 public final static short MAJOR_1_3 = 47;
32 public final static short MINOR_1_3 = 0;
33 public final static short MAJOR_1_4 = 48;
34 public final static short MINOR_1_4 = 0;
35 public final static short MAJOR_1_5 = 49;
36 public final static short MINOR_1_5 = 0;
37 public final static short MAJOR = MAJOR_1_1; // Defaults
38 public final static short MINOR = MINOR_1_1;
39
40 /** Maximum value for an unsigned short.
41 */
42 public final static int MAX_SHORT = 65535; // 2^16 - 1
43
44 /** Maximum value for an unsigned byte.
45 */
46 public final static int MAX_BYTE = 255; // 2^8 - 1
47
48 /** Access flags for classes, fields and methods.
49 */
50 public final static short ACC_PUBLIC = 0x0001;
51 public final static short ACC_PRIVATE = 0x0002;
52 public final static short ACC_PROTECTED = 0x0004;
53 public final static short ACC_STATIC = 0x0008;
54
55 public final static short ACC_FINAL = 0x0010;
56 public final static short ACC_SYNCHRONIZED = 0x0020;
57 public final static short ACC_VOLATILE = 0x0040;
58 public final static short ACC_BRIDGE = 0x0040;
59 public final static short ACC_TRANSIENT = 0x0080;
60 public final static short ACC_VARARGS = 0x0080;
61
62 public final static short ACC_NATIVE = 0x0100;
63 public final static short ACC_INTERFACE = 0x0200;
64 public final static short ACC_ABSTRACT = 0x0400;
65 public final static short ACC_STRICT = 0x0800;
66
67 public final static short ACC_SYNTHETIC = 0x1000;
68 public final static short ACC_ANNOTATION = 0x2000;
69 public final static short ACC_ENUM = 0x4000;
70
71 // Applies to classes compiled by new compilers only
72 public final static short ACC_SUPER = 0x0020;
73
74 public final static short MAX_ACC_FLAG = ACC_ENUM;
75
76 public final static String[] ACCESS_NAMES = {
77 "public", "private", "protected", "static", "final", "synchronized",
78 "volatile", "transient", "native", "interface", "abstract", "strictfp",
79 "synthetic", "annotation", "enum"
80 };
81
82 /** Tags in constant pool to denote type of constant.
83 */
84 public final static byte CONSTANT_Utf8 = 1;
85 public final static byte CONSTANT_Integer = 3;
86 public final static byte CONSTANT_Float = 4;
87 public final static byte CONSTANT_Long = 5;
88 public final static byte CONSTANT_Double = 6;
89 public final static byte CONSTANT_Class = 7;
90 public final static byte CONSTANT_Fieldref = 9;
91 public final static byte CONSTANT_String = 8;
92 public final static byte CONSTANT_Methodref = 10;
93 public final static byte CONSTANT_InterfaceMethodref = 11;
94 public final static byte CONSTANT_NameAndType = 12;
95
96 public final static String[] CONSTANT_NAMES = {
97 "", "CONSTANT_Utf8", "", "CONSTANT_Integer",
98 "CONSTANT_Float", "CONSTANT_Long", "CONSTANT_Double",
99 "CONSTANT_Class", "CONSTANT_String", "CONSTANT_Fieldref",
100 "CONSTANT_Methodref", "CONSTANT_InterfaceMethodref",
101 "CONSTANT_NameAndType" };
102
103 /** The name of the static initializer, also called &quot;class
104 * initialization method&quot; or &quot;interface initialization
105 * method&quot;. This is &quot;&lt;clinit&gt;&quot;.
106 */
107 public final static String STATIC_INITIALIZER_NAME = "<clinit>";
108
109 /** The name of every constructor method in a class, also called
110 * &quot;instance initialization method&quot;. This is &quot;&lt;init&gt;&quot;.
111 */
112 public final static String CONSTRUCTOR_NAME = "<init>";
113
114 /** The names of the interfaces implemented by arrays */
115 public final static String[] INTERFACES_IMPLEMENTED_BY_ARRAYS = {"java.lang.Cloneable", "java.io.Serializable"};
116
117 /**
118 * Limitations of the Java Virtual Machine.
119 * See The Java Virtual Machine Specification, Second Edition, page 152, chapter 4.10.
120 */
121 public static final int MAX_CP_ENTRIES = 65535;
122 public static final int MAX_CODE_SIZE = 65536; //bytes
123
124 /** Java VM opcodes.
125 */
126 public static final short NOP = 0;
127 public static final short ACONST_NULL = 1;
128 public static final short ICONST_M1 = 2;
129 public static final short ICONST_0 = 3;
130 public static final short ICONST_1 = 4;
131 public static final short ICONST_2 = 5;
132 public static final short ICONST_3 = 6;
133 public static final short ICONST_4 = 7;
134 public static final short ICONST_5 = 8;
135 public static final short LCONST_0 = 9;
136 public static final short LCONST_1 = 10;
137 public static final short FCONST_0 = 11;
138 public static final short FCONST_1 = 12;
139 public static final short FCONST_2 = 13;
140 public static final short DCONST_0 = 14;
141 public static final short DCONST_1 = 15;
142 public static final short BIPUSH = 16;
143 public static final short SIPUSH = 17;
144 public static final short LDC = 18;
145 public static final short LDC_W = 19;
146 public static final short LDC2_W = 20;
147 public static final short ILOAD = 21;
148 public static final short LLOAD = 22;
149 public static final short FLOAD = 23;
150 public static final short DLOAD = 24;
151 public static final short ALOAD = 25;
152 public static final short ILOAD_0 = 26;
153 public static final short ILOAD_1 = 27;
154 public static final short ILOAD_2 = 28;
155 public static final short ILOAD_3 = 29;
156 public static final short LLOAD_0 = 30;
157 public static final short LLOAD_1 = 31;
158 public static final short LLOAD_2 = 32;
159 public static final short LLOAD_3 = 33;
160 public static final short FLOAD_0 = 34;
161 public static final short FLOAD_1 = 35;
162 public static final short FLOAD_2 = 36;
163 public static final short FLOAD_3 = 37;
164 public static final short DLOAD_0 = 38;
165 public static final short DLOAD_1 = 39;
166 public static final short DLOAD_2 = 40;
167 public static final short DLOAD_3 = 41;
168 public static final short ALOAD_0 = 42;
169 public static final short ALOAD_1 = 43;
170 public static final short ALOAD_2 = 44;
171 public static final short ALOAD_3 = 45;
172 public static final short IALOAD = 46;
173 public static final short LALOAD = 47;
174 public static final short FALOAD = 48;
175 public static final short DALOAD = 49;
176 public static final short AALOAD = 50;
177 public static final short BALOAD = 51;
178 public static final short CALOAD = 52;
179 public static final short SALOAD = 53;
180 public static final short ISTORE = 54;
181 public static final short LSTORE = 55;
182 public static final short FSTORE = 56;
183 public static final short DSTORE = 57;
184 public static final short ASTORE = 58;
185 public static final short ISTORE_0 = 59;
186 public static final short ISTORE_1 = 60;
187 public static final short ISTORE_2 = 61;
188 public static final short ISTORE_3 = 62;
189 public static final short LSTORE_0 = 63;
190 public static final short LSTORE_1 = 64;
191 public static final short LSTORE_2 = 65;
192 public static final short LSTORE_3 = 66;
193 public static final short FSTORE_0 = 67;
194 public static final short FSTORE_1 = 68;
195 public static final short FSTORE_2 = 69;
196 public static final short FSTORE_3 = 70;
197 public static final short DSTORE_0 = 71;
198 public static final short DSTORE_1 = 72;
199 public static final short DSTORE_2 = 73;
200 public static final short DSTORE_3 = 74;
201 public static final short ASTORE_0 = 75;
202 public static final short ASTORE_1 = 76;
203 public static final short ASTORE_2 = 77;
204 public static final short ASTORE_3 = 78;
205 public static final short IASTORE = 79;
206 public static final short LASTORE = 80;
207 public static final short FASTORE = 81;
208 public static final short DASTORE = 82;
209 public static final short AASTORE = 83;
210 public static final short BASTORE = 84;
211 public static final short CASTORE = 85;
212 public static final short SASTORE = 86;
213 public static final short POP = 87;
214 public static final short POP2 = 88;
215 public static final short DUP = 89;
216 public static final short DUP_X1 = 90;
217 public static final short DUP_X2 = 91;
218 public static final short DUP2 = 92;
219 public static final short DUP2_X1 = 93;
220 public static final short DUP2_X2 = 94;
221 public static final short SWAP = 95;
222 public static final short IADD = 96;
223 public static final short LADD = 97;
224 public static final short FADD = 98;
225 public static final short DADD = 99;
226 public static final short ISUB = 100;
227 public static final short LSUB = 101;
228 public static final short FSUB = 102;
229 public static final short DSUB = 103;
230 public static final short IMUL = 104;
231 public static final short LMUL = 105;
232 public static final short FMUL = 106;
233 public static final short DMUL = 107;
234 public static final short IDIV = 108;
235 public static final short LDIV = 109;
236 public static final short FDIV = 110;
237 public static final short DDIV = 111;
238 public static final short IREM = 112;
239 public static final short LREM = 113;
240 public static final short FREM = 114;
241 public static final short DREM = 115;
242 public static final short INEG = 116;
243 public static final short LNEG = 117;
244 public static final short FNEG = 118;
245 public static final short DNEG = 119;
246 public static final short ISHL = 120;
247 public static final short LSHL = 121;
248 public static final short ISHR = 122;
249 public static final short LSHR = 123;
250 public static final short IUSHR = 124;
251 public static final short LUSHR = 125;
252 public static final short IAND = 126;
253 public static final short LAND = 127;
254 public static final short IOR = 128;
255 public static final short LOR = 129;
256 public static final short IXOR = 130;
257 public static final short LXOR = 131;
258 public static final short IINC = 132;
259 public static final short I2L = 133;
260 public static final short I2F = 134;
261 public static final short I2D = 135;
262 public static final short L2I = 136;
263 public static final short L2F = 137;
264 public static final short L2D = 138;
265 public static final short F2I = 139;
266 public static final short F2L = 140;
267 public static final short F2D = 141;
268 public static final short D2I = 142;
269 public static final short D2L = 143;
270 public static final short D2F = 144;
271 public static final short I2B = 145;
272 public static final short INT2BYTE = 145; // Old notion
273 public static final short I2C = 146;
274 public static final short INT2CHAR = 146; // Old notion
275 public static final short I2S = 147;
276 public static final short INT2SHORT = 147; // Old notion
277 public static final short LCMP = 148;
278 public static final short FCMPL = 149;
279 public static final short FCMPG = 150;
280 public static final short DCMPL = 151;
281 public static final short DCMPG = 152;
282 public static final short IFEQ = 153;
283 public static final short IFNE = 154;
284 public static final short IFLT = 155;
285 public static final short IFGE = 156;
286 public static final short IFGT = 157;
287 public static final short IFLE = 158;
288 public static final short IF_ICMPEQ = 159;
289 public static final short IF_ICMPNE = 160;
290 public static final short IF_ICMPLT = 161;
291 public static final short IF_ICMPGE = 162;
292 public static final short IF_ICMPGT = 163;
293 public static final short IF_ICMPLE = 164;
294 public static final short IF_ACMPEQ = 165;
295 public static final short IF_ACMPNE = 166;
296 public static final short GOTO = 167;
297 public static final short JSR = 168;
298 public static final short RET = 169;
299 public static final short TABLESWITCH = 170;
300 public static final short LOOKUPSWITCH = 171;
301 public static final short IRETURN = 172;
302 public static final short LRETURN = 173;
303 public static final short FRETURN = 174;
304 public static final short DRETURN = 175;
305 public static final short ARETURN = 176;
306 public static final short RETURN = 177;
307 public static final short GETSTATIC = 178;
308 public static final short PUTSTATIC = 179;
309 public static final short GETFIELD = 180;
310 public static final short PUTFIELD = 181;
311 public static final short INVOKEVIRTUAL = 182;
312 public static final short INVOKESPECIAL = 183;
313 public static final short INVOKENONVIRTUAL = 183; // Old name in JDK 1.0
314 public static final short INVOKESTATIC = 184;
315 public static final short INVOKEINTERFACE = 185;
316 public static final short NEW = 187;
317 public static final short NEWARRAY = 188;
318 public static final short ANEWARRAY = 189;
319 public static final short ARRAYLENGTH = 190;
320 public static final short ATHROW = 191;
321 public static final short CHECKCAST = 192;
322 public static final short INSTANCEOF = 193;
323 public static final short MONITORENTER = 194;
324 public static final short MONITOREXIT = 195;
325 public static final short WIDE = 196;
326 public static final short MULTIANEWARRAY = 197;
327 public static final short IFNULL = 198;
328 public static final short IFNONNULL = 199;
329 public static final short GOTO_W = 200;
330 public static final short JSR_W = 201;
331
332 /**
333 * Non-legal opcodes, may be used by JVM internally.
334 */
335 public static final short BREAKPOINT = 202;
336 public static final short LDC_QUICK = 203;
337 public static final short LDC_W_QUICK = 204;
338 public static final short LDC2_W_QUICK = 205;
339 public static final short GETFIELD_QUICK = 206;
340 public static final short PUTFIELD_QUICK = 207;
341 public static final short GETFIELD2_QUICK = 208;
342 public static final short PUTFIELD2_QUICK = 209;
343 public static final short GETSTATIC_QUICK = 210;
344 public static final short PUTSTATIC_QUICK = 211;
345 public static final short GETSTATIC2_QUICK = 212;
346 public static final short PUTSTATIC2_QUICK = 213;
347 public static final short INVOKEVIRTUAL_QUICK = 214;
348 public static final short INVOKENONVIRTUAL_QUICK = 215;
349 public static final short INVOKESUPER_QUICK = 216;
350 public static final short INVOKESTATIC_QUICK = 217;
351 public static final short INVOKEINTERFACE_QUICK = 218;
352 public static final short INVOKEVIRTUALOBJECT_QUICK = 219;
353 public static final short NEW_QUICK = 221;
354 public static final short ANEWARRAY_QUICK = 222;
355 public static final short MULTIANEWARRAY_QUICK = 223;
356 public static final short CHECKCAST_QUICK = 224;
357 public static final short INSTANCEOF_QUICK = 225;
358 public static final short INVOKEVIRTUAL_QUICK_W = 226;
359 public static final short GETFIELD_QUICK_W = 227;
360 public static final short PUTFIELD_QUICK_W = 228;
361 public static final short IMPDEP1 = 254;
362 public static final short IMPDEP2 = 255;
363
364 /**
365 * For internal purposes only.
366 */
367 public static final short PUSH = 4711;
368 public static final short SWITCH = 4712;
369
370 /**
371 * Illegal codes
372 */
373 public static final short UNDEFINED = -1;
374 public static final short UNPREDICTABLE = -2;
375 public static final short RESERVED = -3;
376 public static final String ILLEGAL_OPCODE = "<illegal opcode>";
377 public static final String ILLEGAL_TYPE = "<illegal type>";
378
379 public static final byte T_BOOLEAN = 4;
380 public static final byte T_CHAR = 5;
381 public static final byte T_FLOAT = 6;
382 public static final byte T_DOUBLE = 7;
383 public static final byte T_BYTE = 8;
384 public static final byte T_SHORT = 9;
385 public static final byte T_INT = 10;
386 public static final byte T_LONG = 11;
387
388 public static final byte T_VOID = 12; // Non-standard
389 public static final byte T_ARRAY = 13;
390 public static final byte T_OBJECT = 14;
391 public static final byte T_REFERENCE = 14; // Deprecated
392 public static final byte T_UNKNOWN = 15;
393 public static final byte T_ADDRESS = 16;
394
395 /** The primitive type names corresponding to the T_XX constants,
396 * e.g., TYPE_NAMES[T_INT] = "int"
397 */
398 public static final String[] TYPE_NAMES = {
399 ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE,
400 "boolean", "char", "float", "double", "byte", "short", "int", "long",
401 "void", "array", "object", "unknown" // Non-standard
402 };
403
404 /** The primitive class names corresponding to the T_XX constants,
405 * e.g., CLASS_TYPE_NAMES[T_INT] = "java.lang.Integer"
406 */
407 public static final String[] CLASS_TYPE_NAMES = {
408 ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE,
409 "java.lang.Boolean", "java.lang.Character", "java.lang.Float",
410 "java.lang.Double", "java.lang.Byte", "java.lang.Short",
411 "java.lang.Integer", "java.lang.Long", "java.lang.Void",
412 ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE
413 };
414
415 /** The signature characters corresponding to primitive types,
416 * e.g., SHORT_TYPE_NAMES[T_INT] = "I"
417 */
418 public static final String[] SHORT_TYPE_NAMES = {
419 ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE,
420 "Z", "C", "F", "D", "B", "S", "I", "J",
421 "V", ILLEGAL_TYPE, ILLEGAL_TYPE, ILLEGAL_TYPE
422 };
423
424 /**
425 * Number of byte code operands, i.e., number of bytes after the tag byte
426 * itself.
427 */
428 public static final short[] NO_OF_OPERANDS = {
429 0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/,
430 0/*iconst_1*/, 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/,
431 0/*iconst_5*/, 0/*lconst_0*/, 0/*lconst_1*/, 0/*fconst_0*/,
432 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/, 0/*dconst_1*/,
433 1/*bipush*/, 2/*sipush*/, 1/*ldc*/, 2/*ldc_w*/, 2/*ldc2_w*/,
434 1/*iload*/, 1/*lload*/, 1/*fload*/, 1/*dload*/, 1/*aload*/,
435 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/, 0/*iload_3*/,
436 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/,
437 0/*fload_0*/, 0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/,
438 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/, 0/*dload_3*/,
439 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/,
440 0/*iaload*/, 0/*laload*/, 0/*faload*/, 0/*daload*/,
441 0/*aaload*/, 0/*baload*/, 0/*caload*/, 0/*saload*/,
442 1/*istore*/, 1/*lstore*/, 1/*fstore*/, 1/*dstore*/,
443 1/*astore*/, 0/*istore_0*/, 0/*istore_1*/, 0/*istore_2*/,
444 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/, 0/*lstore_2*/,
445 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/,
446 0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/,
447 0/*dstore_3*/, 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/,
448 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/, 0/*fastore*/,
449 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/,
450 0/*sastore*/, 0/*pop*/, 0/*pop2*/, 0/*dup*/, 0/*dup_x1*/,
451 0/*dup_x2*/, 0/*dup2*/, 0/*dup2_x1*/, 0/*dup2_x2*/, 0/*swap*/,
452 0/*iadd*/, 0/*ladd*/, 0/*fadd*/, 0/*dadd*/, 0/*isub*/,
453 0/*lsub*/, 0/*fsub*/, 0/*dsub*/, 0/*imul*/, 0/*lmul*/,
454 0/*fmul*/, 0/*dmul*/, 0/*idiv*/, 0/*ldiv*/, 0/*fdiv*/,
455 0/*ddiv*/, 0/*irem*/, 0/*lrem*/, 0/*frem*/, 0/*drem*/,
456 0/*ineg*/, 0/*lneg*/, 0/*fneg*/, 0/*dneg*/, 0/*ishl*/,
457 0/*lshl*/, 0/*ishr*/, 0/*lshr*/, 0/*iushr*/, 0/*lushr*/,
458 0/*iand*/, 0/*land*/, 0/*ior*/, 0/*lor*/, 0/*ixor*/, 0/*lxor*/,
459 2/*iinc*/, 0/*i2l*/, 0/*i2f*/, 0/*i2d*/, 0/*l2i*/, 0/*l2f*/,
460 0/*l2d*/, 0/*f2i*/, 0/*f2l*/, 0/*f2d*/, 0/*d2i*/, 0/*d2l*/,
461 0/*d2f*/, 0/*i2b*/, 0/*i2c*/, 0/*i2s*/, 0/*lcmp*/, 0/*fcmpl*/,
462 0/*fcmpg*/, 0/*dcmpl*/, 0/*dcmpg*/, 2/*ifeq*/, 2/*ifne*/,
463 2/*iflt*/, 2/*ifge*/, 2/*ifgt*/, 2/*ifle*/, 2/*if_icmpeq*/,
464 2/*if_icmpne*/, 2/*if_icmplt*/, 2/*if_icmpge*/, 2/*if_icmpgt*/,
465 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/, 2/*goto*/,
466 2/*jsr*/, 1/*ret*/, UNPREDICTABLE/*tableswitch*/, UNPREDICTABLE/*lookupswitch*/,
467 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/,
468 0/*dreturn*/, 0/*areturn*/, 0/*return*/,
469 2/*getstatic*/, 2/*putstatic*/, 2/*getfield*/,
470 2/*putfield*/, 2/*invokevirtual*/, 2/*invokespecial*/, 2/*invokestatic*/,
471 4/*invokeinterface*/, UNDEFINED, 2/*new*/,
472 1/*newarray*/, 2/*anewarray*/,
473 0/*arraylength*/, 0/*athrow*/, 2/*checkcast*/,
474 2/*instanceof*/, 0/*monitorenter*/,
475 0/*monitorexit*/, UNPREDICTABLE/*wide*/, 3/*multianewarray*/,
476 2/*ifnull*/, 2/*ifnonnull*/, 4/*goto_w*/,
477 4/*jsr_w*/, 0/*breakpoint*/, UNDEFINED,
478 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
479 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
480 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
481 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
482 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
483 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
484 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
485 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
486 UNDEFINED, UNDEFINED, RESERVED/*impdep1*/, RESERVED/*impdep2*/
487 };
488
489 /**
490 * How the byte code operands are to be interpreted.
491 */
492 public static final short[][] TYPE_OF_OPERANDS = {
493 {}/*nop*/, {}/*aconst_null*/, {}/*iconst_m1*/, {}/*iconst_0*/,
494 {}/*iconst_1*/, {}/*iconst_2*/, {}/*iconst_3*/, {}/*iconst_4*/,
495 {}/*iconst_5*/, {}/*lconst_0*/, {}/*lconst_1*/, {}/*fconst_0*/,
496 {}/*fconst_1*/, {}/*fconst_2*/, {}/*dconst_0*/, {}/*dconst_1*/,
497 {T_BYTE}/*bipush*/, {T_SHORT}/*sipush*/, {T_BYTE}/*ldc*/,
498 {T_SHORT}/*ldc_w*/, {T_SHORT}/*ldc2_w*/,
499 {T_BYTE}/*iload*/, {T_BYTE}/*lload*/, {T_BYTE}/*fload*/,
500 {T_BYTE}/*dload*/, {T_BYTE}/*aload*/, {}/*iload_0*/,
501 {}/*iload_1*/, {}/*iload_2*/, {}/*iload_3*/, {}/*lload_0*/,
502 {}/*lload_1*/, {}/*lload_2*/, {}/*lload_3*/, {}/*fload_0*/,
503 {}/*fload_1*/, {}/*fload_2*/, {}/*fload_3*/, {}/*dload_0*/,
504 {}/*dload_1*/, {}/*dload_2*/, {}/*dload_3*/, {}/*aload_0*/,
505 {}/*aload_1*/, {}/*aload_2*/, {}/*aload_3*/, {}/*iaload*/,
506 {}/*laload*/, {}/*faload*/, {}/*daload*/, {}/*aaload*/,
507 {}/*baload*/, {}/*caload*/, {}/*saload*/, {T_BYTE}/*istore*/,
508 {T_BYTE}/*lstore*/, {T_BYTE}/*fstore*/, {T_BYTE}/*dstore*/,
509 {T_BYTE}/*astore*/, {}/*istore_0*/, {}/*istore_1*/,
510 {}/*istore_2*/, {}/*istore_3*/, {}/*lstore_0*/, {}/*lstore_1*/,
511 {}/*lstore_2*/, {}/*lstore_3*/, {}/*fstore_0*/, {}/*fstore_1*/,
512 {}/*fstore_2*/, {}/*fstore_3*/, {}/*dstore_0*/, {}/*dstore_1*/,
513 {}/*dstore_2*/, {}/*dstore_3*/, {}/*astore_0*/, {}/*astore_1*/,
514 {}/*astore_2*/, {}/*astore_3*/, {}/*iastore*/, {}/*lastore*/,
515 {}/*fastore*/, {}/*dastore*/, {}/*aastore*/, {}/*bastore*/,
516 {}/*castore*/, {}/*sastore*/, {}/*pop*/, {}/*pop2*/, {}/*dup*/,
517 {}/*dup_x1*/, {}/*dup_x2*/, {}/*dup2*/, {}/*dup2_x1*/,
518 {}/*dup2_x2*/, {}/*swap*/, {}/*iadd*/, {}/*ladd*/, {}/*fadd*/,
519 {}/*dadd*/, {}/*isub*/, {}/*lsub*/, {}/*fsub*/, {}/*dsub*/,
520 {}/*imul*/, {}/*lmul*/, {}/*fmul*/, {}/*dmul*/, {}/*idiv*/,
521 {}/*ldiv*/, {}/*fdiv*/, {}/*ddiv*/, {}/*irem*/, {}/*lrem*/,
522 {}/*frem*/, {}/*drem*/, {}/*ineg*/, {}/*lneg*/, {}/*fneg*/,
523 {}/*dneg*/, {}/*ishl*/, {}/*lshl*/, {}/*ishr*/, {}/*lshr*/,
524 {}/*iushr*/, {}/*lushr*/, {}/*iand*/, {}/*land*/, {}/*ior*/,
525 {}/*lor*/, {}/*ixor*/, {}/*lxor*/, {T_BYTE, T_BYTE}/*iinc*/,
526 {}/*i2l*/, {}/*i2f*/, {}/*i2d*/, {}/*l2i*/, {}/*l2f*/, {}/*l2d*/,
527 {}/*f2i*/, {}/*f2l*/, {}/*f2d*/, {}/*d2i*/, {}/*d2l*/, {}/*d2f*/,
528 {}/*i2b*/, {}/*i2c*/,{}/*i2s*/, {}/*lcmp*/, {}/*fcmpl*/,
529 {}/*fcmpg*/, {}/*dcmpl*/, {}/*dcmpg*/, {T_SHORT}/*ifeq*/,
530 {T_SHORT}/*ifne*/, {T_SHORT}/*iflt*/, {T_SHORT}/*ifge*/,
531 {T_SHORT}/*ifgt*/, {T_SHORT}/*ifle*/, {T_SHORT}/*if_icmpeq*/,
532 {T_SHORT}/*if_icmpne*/, {T_SHORT}/*if_icmplt*/,
533 {T_SHORT}/*if_icmpge*/, {T_SHORT}/*if_icmpgt*/,
534 {T_SHORT}/*if_icmple*/, {T_SHORT}/*if_acmpeq*/,
535 {T_SHORT}/*if_acmpne*/, {T_SHORT}/*goto*/, {T_SHORT}/*jsr*/,
536 {T_BYTE}/*ret*/, {}/*tableswitch*/, {}/*lookupswitch*/,
537 {}/*ireturn*/, {}/*lreturn*/, {}/*freturn*/, {}/*dreturn*/,
538 {}/*areturn*/, {}/*return*/, {T_SHORT}/*getstatic*/,
539 {T_SHORT}/*putstatic*/, {T_SHORT}/*getfield*/,
540 {T_SHORT}/*putfield*/, {T_SHORT}/*invokevirtual*/,
541 {T_SHORT}/*invokespecial*/, {T_SHORT}/*invokestatic*/,
542 {T_SHORT, T_BYTE, T_BYTE}/*invokeinterface*/, {},
543 {T_SHORT}/*new*/, {T_BYTE}/*newarray*/,
544 {T_SHORT}/*anewarray*/, {}/*arraylength*/, {}/*athrow*/,
545 {T_SHORT}/*checkcast*/, {T_SHORT}/*instanceof*/,
546 {}/*monitorenter*/, {}/*monitorexit*/, {T_BYTE}/*wide*/,
547 {T_SHORT, T_BYTE}/*multianewarray*/, {T_SHORT}/*ifnull*/,
548 {T_SHORT}/*ifnonnull*/, {T_INT}/*goto_w*/, {T_INT}/*jsr_w*/,
549 {}/*breakpoint*/, {}, {}, {}, {}, {}, {}, {},
550 {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
551 {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
552 {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {},
553 {}/*impdep1*/, {}/*impdep2*/
554 };
555
556 /**
557 * Names of opcodes.
558 */
559 public static final String[] OPCODE_NAMES = {
560 "nop", "aconst_null", "iconst_m1", "iconst_0", "iconst_1",
561 "iconst_2", "iconst_3", "iconst_4", "iconst_5", "lconst_0",
562 "lconst_1", "fconst_0", "fconst_1", "fconst_2", "dconst_0",
563 "dconst_1", "bipush", "sipush", "ldc", "ldc_w", "ldc2_w", "iload",
564 "lload", "fload", "dload", "aload", "iload_0", "iload_1", "iload_2",
565 "iload_3", "lload_0", "lload_1", "lload_2", "lload_3", "fload_0",
566 "fload_1", "fload_2", "fload_3", "dload_0", "dload_1", "dload_2",
567 "dload_3", "aload_0", "aload_1", "aload_2", "aload_3", "iaload",
568 "laload", "faload", "daload", "aaload", "baload", "caload", "saload",
569 "istore", "lstore", "fstore", "dstore", "astore", "istore_0",
570 "istore_1", "istore_2", "istore_3", "lstore_0", "lstore_1",
571 "lstore_2", "lstore_3", "fstore_0", "fstore_1", "fstore_2",
572 "fstore_3", "dstore_0", "dstore_1", "dstore_2", "dstore_3",
573 "astore_0", "astore_1", "astore_2", "astore_3", "iastore", "lastore",
574 "fastore", "dastore", "aastore", "bastore", "castore", "sastore",
575 "pop", "pop2", "dup", "dup_x1", "dup_x2", "dup2", "dup2_x1",
576 "dup2_x2", "swap", "iadd", "ladd", "fadd", "dadd", "isub", "lsub",
577 "fsub", "dsub", "imul", "lmul", "fmul", "dmul", "idiv", "ldiv",
578 "fdiv", "ddiv", "irem", "lrem", "frem", "drem", "ineg", "lneg",
579 "fneg", "dneg", "ishl", "lshl", "ishr", "lshr", "iushr", "lushr",
580 "iand", "land", "ior", "lor", "ixor", "lxor", "iinc", "i2l", "i2f",
581 "i2d", "l2i", "l2f", "l2d", "f2i", "f2l", "f2d", "d2i", "d2l", "d2f",
582 "i2b", "i2c", "i2s", "lcmp", "fcmpl", "fcmpg",
583 "dcmpl", "dcmpg", "ifeq", "ifne", "iflt", "ifge", "ifgt", "ifle",
584 "if_icmpeq", "if_icmpne", "if_icmplt", "if_icmpge", "if_icmpgt",
585 "if_icmple", "if_acmpeq", "if_acmpne", "goto", "jsr", "ret",
586 "tableswitch", "lookupswitch", "ireturn", "lreturn", "freturn",
587 "dreturn", "areturn", "return", "getstatic", "putstatic", "getfield",
588 "putfield", "invokevirtual", "invokespecial", "invokestatic",
589 "invokeinterface", ILLEGAL_OPCODE, "new", "newarray", "anewarray",
590 "arraylength", "athrow", "checkcast", "instanceof", "monitorenter",
591 "monitorexit", "wide", "multianewarray", "ifnull", "ifnonnull",
592 "goto_w", "jsr_w", "breakpoint", ILLEGAL_OPCODE, ILLEGAL_OPCODE,
593 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
594 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
595 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
596 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
597 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
598 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
599 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
600 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
601 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
602 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
603 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
604 ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE, ILLEGAL_OPCODE,
605 ILLEGAL_OPCODE, "impdep1", "impdep2"
606 };
607
608 /**
609 * Number of words consumed on operand stack by instructions.
610 */
611 public static final int[] CONSUME_STACK = {
612 0/*nop*/, 0/*aconst_null*/, 0/*iconst_m1*/, 0/*iconst_0*/, 0/*iconst_1*/,
613 0/*iconst_2*/, 0/*iconst_3*/, 0/*iconst_4*/, 0/*iconst_5*/, 0/*lconst_0*/,
614 0/*lconst_1*/, 0/*fconst_0*/, 0/*fconst_1*/, 0/*fconst_2*/, 0/*dconst_0*/,
615 0/*dconst_1*/, 0/*bipush*/, 0/*sipush*/, 0/*ldc*/, 0/*ldc_w*/, 0/*ldc2_w*/, 0/*iload*/,
616 0/*lload*/, 0/*fload*/, 0/*dload*/, 0/*aload*/, 0/*iload_0*/, 0/*iload_1*/, 0/*iload_2*/,
617 0/*iload_3*/, 0/*lload_0*/, 0/*lload_1*/, 0/*lload_2*/, 0/*lload_3*/, 0/*fload_0*/,
618 0/*fload_1*/, 0/*fload_2*/, 0/*fload_3*/, 0/*dload_0*/, 0/*dload_1*/, 0/*dload_2*/,
619 0/*dload_3*/, 0/*aload_0*/, 0/*aload_1*/, 0/*aload_2*/, 0/*aload_3*/, 2/*iaload*/,
620 2/*laload*/, 2/*faload*/, 2/*daload*/, 2/*aaload*/, 2/*baload*/, 2/*caload*/, 2/*saload*/,
621 1/*istore*/, 2/*lstore*/, 1/*fstore*/, 2/*dstore*/, 1/*astore*/, 1/*istore_0*/,
622 1/*istore_1*/, 1/*istore_2*/, 1/*istore_3*/, 2/*lstore_0*/, 2/*lstore_1*/,
623 2/*lstore_2*/, 2/*lstore_3*/, 1/*fstore_0*/, 1/*fstore_1*/, 1/*fstore_2*/,
624 1/*fstore_3*/, 2/*dstore_0*/, 2/*dstore_1*/, 2/*dstore_2*/, 2/*dstore_3*/,
625 1/*astore_0*/, 1/*astore_1*/, 1/*astore_2*/, 1/*astore_3*/, 3/*iastore*/, 4/*lastore*/,
626 3/*fastore*/, 4/*dastore*/, 3/*aastore*/, 3/*bastore*/, 3/*castore*/, 3/*sastore*/,
627 1/*pop*/, 2/*pop2*/, 1/*dup*/, 2/*dup_x1*/, 3/*dup_x2*/, 2/*dup2*/, 3/*dup2_x1*/,
628 4/*dup2_x2*/, 2/*swap*/, 2/*iadd*/, 4/*ladd*/, 2/*fadd*/, 4/*dadd*/, 2/*isub*/, 4/*lsub*/,
629 2/*fsub*/, 4/*dsub*/, 2/*imul*/, 4/*lmul*/, 2/*fmul*/, 4/*dmul*/, 2/*idiv*/, 4/*ldiv*/,
630 2/*fdiv*/, 4/*ddiv*/, 2/*irem*/, 4/*lrem*/, 2/*frem*/, 4/*drem*/, 1/*ineg*/, 2/*lneg*/,
631 1/*fneg*/, 2/*dneg*/, 2/*ishl*/, 3/*lshl*/, 2/*ishr*/, 3/*lshr*/, 2/*iushr*/, 3/*lushr*/,
632 2/*iand*/, 4/*land*/, 2/*ior*/, 4/*lor*/, 2/*ixor*/, 4/*lxor*/, 0/*iinc*/,
633 1/*i2l*/, 1/*i2f*/, 1/*i2d*/, 2/*l2i*/, 2/*l2f*/, 2/*l2d*/, 1/*f2i*/, 1/*f2l*/,
634 1/*f2d*/, 2/*d2i*/, 2/*d2l*/, 2/*d2f*/, 1/*i2b*/, 1/*i2c*/, 1/*i2s*/,
635 4/*lcmp*/, 2/*fcmpl*/, 2/*fcmpg*/, 4/*dcmpl*/, 4/*dcmpg*/, 1/*ifeq*/, 1/*ifne*/,
636 1/*iflt*/, 1/*ifge*/, 1/*ifgt*/, 1/*ifle*/, 2/*if_icmpeq*/, 2/*if_icmpne*/, 2/*if_icmplt*/,
637 2 /*if_icmpge*/, 2/*if_icmpgt*/, 2/*if_icmple*/, 2/*if_acmpeq*/, 2/*if_acmpne*/,
638 0/*goto*/, 0/*jsr*/, 0/*ret*/, 1/*tableswitch*/, 1/*lookupswitch*/, 1/*ireturn*/,
639 2/*lreturn*/, 1/*freturn*/, 2/*dreturn*/, 1/*areturn*/, 0/*return*/, 0/*getstatic*/,
640 UNPREDICTABLE/*putstatic*/, 1/*getfield*/, UNPREDICTABLE/*putfield*/,
641 UNPREDICTABLE/*invokevirtual*/, UNPREDICTABLE/*invokespecial*/,
642 UNPREDICTABLE/*invokestatic*/,
643 UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 0/*new*/, 1/*newarray*/, 1/*anewarray*/,
644 1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 1/*monitorenter*/,
645 1/*monitorexit*/, 0/*wide*/, UNPREDICTABLE/*multianewarray*/, 1/*ifnull*/, 1/*ifnonnull*/,
646 0/*goto_w*/, 0/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED,
647 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
648 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
649 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
650 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
651 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
652 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
653 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
654 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
655 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
656 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
657 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
658 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
659 UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/
660 };
661
662 /**
663 * Number of words produced onto operand stack by instructions.
664 */
665 public static final int[] PRODUCE_STACK = {
666 0/*nop*/, 1/*aconst_null*/, 1/*iconst_m1*/, 1/*iconst_0*/, 1/*iconst_1*/,
667 1/*iconst_2*/, 1/*iconst_3*/, 1/*iconst_4*/, 1/*iconst_5*/, 2/*lconst_0*/,
668 2/*lconst_1*/, 1/*fconst_0*/, 1/*fconst_1*/, 1/*fconst_2*/, 2/*dconst_0*/,
669 2/*dconst_1*/, 1/*bipush*/, 1/*sipush*/, 1/*ldc*/, 1/*ldc_w*/, 2/*ldc2_w*/, 1/*iload*/,
670 2/*lload*/, 1/*fload*/, 2/*dload*/, 1/*aload*/, 1/*iload_0*/, 1/*iload_1*/, 1/*iload_2*/,
671 1/*iload_3*/, 2/*lload_0*/, 2/*lload_1*/, 2/*lload_2*/, 2/*lload_3*/, 1/*fload_0*/,
672 1/*fload_1*/, 1/*fload_2*/, 1/*fload_3*/, 2/*dload_0*/, 2/*dload_1*/, 2/*dload_2*/,
673 2/*dload_3*/, 1/*aload_0*/, 1/*aload_1*/, 1/*aload_2*/, 1/*aload_3*/, 1/*iaload*/,
674 2/*laload*/, 1/*faload*/, 2/*daload*/, 1/*aaload*/, 1/*baload*/, 1/*caload*/, 1/*saload*/,
675 0/*istore*/, 0/*lstore*/, 0/*fstore*/, 0/*dstore*/, 0/*astore*/, 0/*istore_0*/,
676 0/*istore_1*/, 0/*istore_2*/, 0/*istore_3*/, 0/*lstore_0*/, 0/*lstore_1*/,
677 0/*lstore_2*/, 0/*lstore_3*/, 0/*fstore_0*/, 0/*fstore_1*/, 0/*fstore_2*/,
678 0/*fstore_3*/, 0/*dstore_0*/, 0/*dstore_1*/, 0/*dstore_2*/, 0/*dstore_3*/,
679 0/*astore_0*/, 0/*astore_1*/, 0/*astore_2*/, 0/*astore_3*/, 0/*iastore*/, 0/*lastore*/,
680 0/*fastore*/, 0/*dastore*/, 0/*aastore*/, 0/*bastore*/, 0/*castore*/, 0/*sastore*/,
681 0/*pop*/, 0/*pop2*/, 2/*dup*/, 3/*dup_x1*/, 4/*dup_x2*/, 4/*dup2*/, 5/*dup2_x1*/,
682 6/*dup2_x2*/, 2/*swap*/, 1/*iadd*/, 2/*ladd*/, 1/*fadd*/, 2/*dadd*/, 1/*isub*/, 2/*lsub*/,
683 1/*fsub*/, 2/*dsub*/, 1/*imul*/, 2/*lmul*/, 1/*fmul*/, 2/*dmul*/, 1/*idiv*/, 2/*ldiv*/,
684 1/*fdiv*/, 2/*ddiv*/, 1/*irem*/, 2/*lrem*/, 1/*frem*/, 2/*drem*/, 1/*ineg*/, 2/*lneg*/,
685 1/*fneg*/, 2/*dneg*/, 1/*ishl*/, 2/*lshl*/, 1/*ishr*/, 2/*lshr*/, 1/*iushr*/, 2/*lushr*/,
686 1/*iand*/, 2/*land*/, 1/*ior*/, 2/*lor*/, 1/*ixor*/, 2/*lxor*/,
687 0/*iinc*/, 2/*i2l*/, 1/*i2f*/, 2/*i2d*/, 1/*l2i*/, 1/*l2f*/, 2/*l2d*/, 1/*f2i*/,
688 2/*f2l*/, 2/*f2d*/, 1/*d2i*/, 2/*d2l*/, 1/*d2f*/,
689 1/*i2b*/, 1/*i2c*/, 1/*i2s*/, 1/*lcmp*/, 1/*fcmpl*/, 1/*fcmpg*/,
690 1/*dcmpl*/, 1/*dcmpg*/, 0/*ifeq*/, 0/*ifne*/, 0/*iflt*/, 0/*ifge*/, 0/*ifgt*/, 0/*ifle*/,
691 0/*if_icmpeq*/, 0/*if_icmpne*/, 0/*if_icmplt*/, 0/*if_icmpge*/, 0/*if_icmpgt*/,
692 0/*if_icmple*/, 0/*if_acmpeq*/, 0/*if_acmpne*/, 0/*goto*/, 1/*jsr*/, 0/*ret*/,
693 0/*tableswitch*/, 0/*lookupswitch*/, 0/*ireturn*/, 0/*lreturn*/, 0/*freturn*/,
694 0/*dreturn*/, 0/*areturn*/, 0/*return*/, UNPREDICTABLE/*getstatic*/, 0/*putstatic*/,
695 UNPREDICTABLE/*getfield*/, 0/*putfield*/, UNPREDICTABLE/*invokevirtual*/,
696 UNPREDICTABLE/*invokespecial*/, UNPREDICTABLE/*invokestatic*/,
697 UNPREDICTABLE/*invokeinterface*/, UNDEFINED, 1/*new*/, 1/*newarray*/, 1/*anewarray*/,
698 1/*arraylength*/, 1/*athrow*/, 1/*checkcast*/, 1/*instanceof*/, 0/*monitorenter*/,
699 0/*monitorexit*/, 0/*wide*/, 1/*multianewarray*/, 0/*ifnull*/, 0/*ifnonnull*/,
700 0/*goto_w*/, 1/*jsr_w*/, 0/*breakpoint*/, UNDEFINED, UNDEFINED,
701 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
702 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
703 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
704 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
705 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
706 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
707 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
708 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
709 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
710 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
711 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
712 UNDEFINED, UNDEFINED, UNDEFINED, UNDEFINED,
713 UNDEFINED, UNPREDICTABLE/*impdep1*/, UNPREDICTABLE/*impdep2*/
714 };
715
716 /** Attributes and their corresponding names.
717 */
718 public static final byte ATTR_UNKNOWN = -1;
719 public static final byte ATTR_SOURCE_FILE = 0;
720 public static final byte ATTR_CONSTANT_VALUE = 1;
721 public static final byte ATTR_CODE = 2;
722 public static final byte ATTR_EXCEPTIONS = 3;
723 public static final byte ATTR_LINE_NUMBER_TABLE = 4;
724 public static final byte ATTR_LOCAL_VARIABLE_TABLE = 5;
725 public static final byte ATTR_INNER_CLASSES = 6;
726 public static final byte ATTR_SYNTHETIC = 7;
727 public static final byte ATTR_DEPRECATED = 8;
728 public static final byte ATTR_PMG = 9;
729 public static final byte ATTR_SIGNATURE = 10;
730 public static final byte ATTR_STACK_MAP = 11;
731 public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE = 12;
732 public static final byte ATTR_RUNTIMEVISIBLE_ANNOTATIONS = 13;
733 public static final byte ATTR_RUNTIMEINVISIBLE_ANNOTATIONS = 14;
734 public static final byte ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS = 15;
735 public static final byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS = 16;
736 public static final byte ATTR_ANNOTATION_DEFAULT = 17;
737
738
739
740 public static final short KNOWN_ATTRIBUTES = 13;//should be 17
741
742 public static final String[] ATTRIBUTE_NAMES = {
743 "SourceFile", "ConstantValue", "Code", "Exceptions",
744 "LineNumberTable", "LocalVariableTable",
745 "InnerClasses", "Synthetic", "Deprecated",
746 "PMGClass", "Signature", "StackMap", "LocalVariableTypeTable",
747 "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
748 "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations",
749 "AnnotationDefault"
750 };
751
752 /** Constants used in the StackMap attribute.
753 */
754 public static final byte ITEM_Bogus = 0;
755 public static final byte ITEM_Integer = 1;
756 public static final byte ITEM_Float = 2;
757 public static final byte ITEM_Double = 3;
758 public static final byte ITEM_Long = 4;
759 public static final byte ITEM_Null = 5;
760 public static final byte ITEM_InitObject = 6;
761 public static final byte ITEM_Object = 7;
762 public static final byte ITEM_NewObject = 8;
763
764 public static final String[] ITEM_NAMES = {
765 "Bogus", "Integer", "Float", "Double", "Long",
766 "Null", "InitObject", "Object", "NewObject"
767 };
768 }
+0
-76
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/ExceptionConstants.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel;
17
18 /**
19 * Exception constants.
20 *
21 * @version $Id: ExceptionConstants.java 386056 2006-03-15 11:31:56Z tcurdt $
22 * @author E. Haase
23 */
24 public interface ExceptionConstants {
25
26 /** The mother of all exceptions
27 */
28 public static final Class THROWABLE = Throwable.class;
29 /** Super class of any run-time exception
30 */
31 public static final Class RUNTIME_EXCEPTION = RuntimeException.class;
32 /** Super class of any linking exception (aka Linkage Error)
33 */
34 public static final Class LINKING_EXCEPTION = LinkageError.class;
35 /** Linking Exceptions
36 */
37 public static final Class CLASS_CIRCULARITY_ERROR = ClassCircularityError.class;
38 public static final Class CLASS_FORMAT_ERROR = ClassFormatError.class;
39 public static final Class EXCEPTION_IN_INITIALIZER_ERROR = ExceptionInInitializerError.class;
40 public static final Class INCOMPATIBLE_CLASS_CHANGE_ERROR = IncompatibleClassChangeError.class;
41 public static final Class ABSTRACT_METHOD_ERROR = AbstractMethodError.class;
42 public static final Class ILLEGAL_ACCESS_ERROR = IllegalAccessError.class;
43 public static final Class INSTANTIATION_ERROR = InstantiationError.class;
44 public static final Class NO_SUCH_FIELD_ERROR = NoSuchFieldError.class;
45 public static final Class NO_SUCH_METHOD_ERROR = NoSuchMethodError.class;
46 public static final Class NO_CLASS_DEF_FOUND_ERROR = NoClassDefFoundError.class;
47 public static final Class UNSATISFIED_LINK_ERROR = UnsatisfiedLinkError.class;
48 public static final Class VERIFY_ERROR = VerifyError.class;
49 /* UnsupportedClassVersionError is new in JDK 1.2 */
50 //public static final Class UnsupportedClassVersionError = UnsupportedClassVersionError.class;
51 /** Run-Time Exceptions
52 */
53 public static final Class NULL_POINTER_EXCEPTION = NullPointerException.class;
54 public static final Class ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION = ArrayIndexOutOfBoundsException.class;
55 public static final Class ARITHMETIC_EXCEPTION = ArithmeticException.class;
56 public static final Class NEGATIVE_ARRAY_SIZE_EXCEPTION = NegativeArraySizeException.class;
57 public static final Class CLASS_CAST_EXCEPTION = ClassCastException.class;
58 public static final Class ILLEGAL_MONITOR_STATE = IllegalMonitorStateException.class;
59 /** Pre-defined exception arrays according to chapters 5.1-5.4 of the Java Virtual
60 * Machine Specification
61 */
62 public static final Class[] EXCS_CLASS_AND_INTERFACE_RESOLUTION = {
63 NO_CLASS_DEF_FOUND_ERROR, CLASS_FORMAT_ERROR, VERIFY_ERROR, ABSTRACT_METHOD_ERROR,
64 EXCEPTION_IN_INITIALIZER_ERROR, ILLEGAL_ACCESS_ERROR
65 }; // Chapter 5.1
66 public static final Class[] EXCS_FIELD_AND_METHOD_RESOLUTION = {
67 NO_SUCH_FIELD_ERROR, ILLEGAL_ACCESS_ERROR, NO_SUCH_METHOD_ERROR
68 }; // Chapter 5.2
69 public static final Class[] EXCS_INTERFACE_METHOD_RESOLUTION = new Class[0]; // Chapter 5.3 (as below)
70 public static final Class[] EXCS_STRING_RESOLUTION = new Class[0];
71 // Chapter 5.4 (no errors but the ones that _always_ could happen! How stupid.)
72 public static final Class[] EXCS_ARRAY_EXCEPTION = {
73 NULL_POINTER_EXCEPTION, ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION
74 };
75 }
+0
-261
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/Repository.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel;
17
18 import java.io.IOException;
19 import org.apache.bcel.classfile.JavaClass;
20 import org.apache.bcel.util.ClassPath;
21 import org.apache.bcel.util.SyntheticRepository;
22
23 /**
24 * The repository maintains informations about class interdependencies, e.g.,
25 * whether a class is a sub-class of another. Delegates actual class loading
26 * to SyntheticRepository with current class path by default.
27 *
28 * @see org.apache.bcel.util.Repository
29 * @see org.apache.bcel.util.SyntheticRepository
30 *
31 * @version $Id: Repository.java 386056 2006-03-15 11:31:56Z tcurdt $
32 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
33 */
34 public abstract class Repository {
35
36 private static org.apache.bcel.util.Repository _repository = SyntheticRepository.getInstance();
37
38
39 /** @return currently used repository instance
40 */
41 public static org.apache.bcel.util.Repository getRepository() {
42 return _repository;
43 }
44
45
46 /** Set repository instance to be used for class loading
47 */
48 public static void setRepository( org.apache.bcel.util.Repository rep ) {
49 _repository = rep;
50 }
51
52
53 /** Lookup class somewhere found on your CLASSPATH, or whereever the
54 * repository instance looks for it.
55 *
56 * @return class object for given fully qualified class name
57 * @throws ClassNotFoundException if the class could not be found or
58 * parsed correctly
59 */
60 public static JavaClass lookupClass( String class_name ) throws ClassNotFoundException {
61 return _repository.loadClass(class_name);
62 }
63
64
65 /**
66 * Try to find class source using the internal repository instance.
67 * @see Class
68 * @return JavaClass object for given runtime class
69 * @throws ClassNotFoundException if the class could not be found or
70 * parsed correctly
71 */
72 public static JavaClass lookupClass( Class clazz ) throws ClassNotFoundException {
73 return _repository.loadClass(clazz);
74 }
75
76
77 /**
78 * @return class file object for given Java class by looking on the
79 * system class path; returns null if the class file can't be
80 * found
81 */
82 public static ClassPath.ClassFile lookupClassFile( String class_name ) {
83 try {
84 ClassPath path = _repository.getClassPath();
85 if (path == null) {
86 return null;
87 }
88 return path.getClassFile(class_name);
89 } catch (IOException e) {
90 return null;
91 }
92 }
93
94
95 /** Clear the repository.
96 */
97 public static void clearCache() {
98 _repository.clear();
99 }
100
101
102 /**
103 * Add clazz to repository if there isn't an equally named class already in there.
104 *
105 * @return old entry in repository
106 */
107 public static JavaClass addClass( JavaClass clazz ) {
108 JavaClass old = _repository.findClass(clazz.getClassName());
109 _repository.storeClass(clazz);
110 return old;
111 }
112
113
114 /**
115 * Remove class with given (fully qualified) name from repository.
116 */
117 public static void removeClass( String clazz ) {
118 _repository.removeClass(_repository.findClass(clazz));
119 }
120
121
122 /**
123 * Remove given class from repository.
124 */
125 public static void removeClass( JavaClass clazz ) {
126 _repository.removeClass(clazz);
127 }
128
129
130 /**
131 * @return list of super classes of clazz in ascending order, i.e.,
132 * Object is always the last element
133 * @throws ClassNotFoundException if any of the superclasses can't be found
134 */
135 public static JavaClass[] getSuperClasses( JavaClass clazz ) throws ClassNotFoundException {
136 return clazz.getSuperClasses();
137 }
138
139
140 /**
141 * @return list of super classes of clazz in ascending order, i.e.,
142 * Object is always the last element.
143 * @throws ClassNotFoundException if the named class or any of its
144 * superclasses can't be found
145 */
146 public static JavaClass[] getSuperClasses( String class_name ) throws ClassNotFoundException {
147 JavaClass jc = lookupClass(class_name);
148 return getSuperClasses(jc);
149 }
150
151
152 /**
153 * @return all interfaces implemented by class and its super
154 * classes and the interfaces that those interfaces extend, and so on.
155 * (Some people call this a transitive hull).
156 * @throws ClassNotFoundException if any of the class's
157 * superclasses or superinterfaces can't be found
158 */
159 public static JavaClass[] getInterfaces( JavaClass clazz ) throws ClassNotFoundException {
160 return clazz.getAllInterfaces();
161 }
162
163
164 /**
165 * @return all interfaces implemented by class and its super
166 * classes and the interfaces that extend those interfaces, and so on
167 * @throws ClassNotFoundException if the named class can't be found,
168 * or if any of its superclasses or superinterfaces can't be found
169 */
170 public static JavaClass[] getInterfaces( String class_name ) throws ClassNotFoundException {
171 return getInterfaces(lookupClass(class_name));
172 }
173
174
175 /**
176 * Equivalent to runtime "instanceof" operator.
177 * @return true, if clazz is an instance of super_class
178 * @throws ClassNotFoundException if any superclasses or superinterfaces
179 * of clazz can't be found
180 */
181 public static boolean instanceOf( JavaClass clazz, JavaClass super_class )
182 throws ClassNotFoundException {
183 return clazz.instanceOf(super_class);
184 }
185
186
187 /**
188 * @return true, if clazz is an instance of super_class
189 * @throws ClassNotFoundException if either clazz or super_class
190 * can't be found
191 */
192 public static boolean instanceOf( String clazz, String super_class )
193 throws ClassNotFoundException {
194 return instanceOf(lookupClass(clazz), lookupClass(super_class));
195 }
196
197
198 /**
199 * @return true, if clazz is an instance of super_class
200 * @throws ClassNotFoundException if super_class can't be found
201 */
202 public static boolean instanceOf( JavaClass clazz, String super_class )
203 throws ClassNotFoundException {
204 return instanceOf(clazz, lookupClass(super_class));
205 }
206
207
208 /**
209 * @return true, if clazz is an instance of super_class
210 * @throws ClassNotFoundException if clazz can't be found
211 */
212 public static boolean instanceOf( String clazz, JavaClass super_class )
213 throws ClassNotFoundException {
214 return instanceOf(lookupClass(clazz), super_class);
215 }
216
217
218 /**
219 * @return true, if clazz is an implementation of interface inter
220 * @throws ClassNotFoundException if any superclasses or superinterfaces
221 * of clazz can't be found
222 */
223 public static boolean implementationOf( JavaClass clazz, JavaClass inter )
224 throws ClassNotFoundException {
225 return clazz.implementationOf(inter);
226 }
227
228
229 /**
230 * @return true, if clazz is an implementation of interface inter
231 * @throws ClassNotFoundException if clazz, inter, or any superclasses
232 * or superinterfaces of clazz can't be found
233 */
234 public static boolean implementationOf( String clazz, String inter )
235 throws ClassNotFoundException {
236 return implementationOf(lookupClass(clazz), lookupClass(inter));
237 }
238
239
240 /**
241 * @return true, if clazz is an implementation of interface inter
242 * @throws ClassNotFoundException if inter or any superclasses
243 * or superinterfaces of clazz can't be found
244 */
245 public static boolean implementationOf( JavaClass clazz, String inter )
246 throws ClassNotFoundException {
247 return implementationOf(clazz, lookupClass(inter));
248 }
249
250
251 /**
252 * @return true, if clazz is an implementation of interface inter
253 * @throws ClassNotFoundException if clazz or any superclasses or
254 * superinterfaces of clazz can't be found
255 */
256 public static boolean implementationOf( String clazz, JavaClass inter )
257 throws ClassNotFoundException {
258 return implementationOf(lookupClass(clazz), inter);
259 }
260 }
+0
-187
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/AbstractLocalVariableTable.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 import java.io.DataInputStream;
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21 import org.apache.bcel.Constants;
22
23 /**
24 * This class represents colection of local variables in a
25 * method. This attribute is contained in the <em>Code</em> attribute.
26 *
27 * @version $Id: bcel.diff,v 1.2 2007/08/14 03:33:02 wpugh Exp $
28 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
29 * @see Code
30 * @see LocalVariable
31 */
32 abstract public class AbstractLocalVariableTable extends Attribute {
33
34 private int local_variable_table_length; // Table of local
35 private LocalVariable[] local_variable_table; // variables
36
37
38 /**
39 * Initialize from another object. Note that both objects use the same
40 * references (shallow copy). Use copy() for a physical copy.
41 */
42 public AbstractLocalVariableTable(AbstractLocalVariableTable c) {
43 this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool());
44 }
45
46
47 /**
48 * @param name_index Index in constant pool to `LocalVariableTable'
49 * @param length Content length in bytes
50 * @param local_variable_table Table of local variables
51 * @param constant_pool Array of constants
52 */
53 public AbstractLocalVariableTable(int name_index, int length, LocalVariable[] local_variable_table,
54 ConstantPool constant_pool) {
55 super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool);
56 setLocalVariableTable(local_variable_table);
57 }
58
59
60 /**
61 * Construct object from file stream.
62 * @param name_index Index in constant pool
63 * @param length Content length in bytes
64 * @param file Input stream
65 * @param constant_pool Array of constants
66 * @throws IOException
67 */
68 AbstractLocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
69 throws IOException {
70 this(name_index, length, (LocalVariable[]) null, constant_pool);
71 local_variable_table_length = (file.readUnsignedShort());
72 local_variable_table = new LocalVariable[local_variable_table_length];
73 for (int i = 0; i < local_variable_table_length; i++) {
74 local_variable_table[i] = new LocalVariable(file, constant_pool);
75 }
76 }
77
78
79
80
81 /**
82 * Dump local variable table attribute to file stream in binary format.
83 *
84 * @param file Output file stream
85 * @throws IOException
86 */
87 public final void dump( DataOutputStream file ) throws IOException {
88 super.dump(file);
89 file.writeShort(local_variable_table_length);
90 for (int i = 0; i < local_variable_table_length; i++) {
91 local_variable_table[i].dump(file);
92 }
93 }
94
95
96 /**
97 * @return Array of local variables of method.
98 */
99 public final LocalVariable[] getLocalVariableTable() {
100 return local_variable_table;
101 }
102
103
104 /**
105 * @return first matching variable using index
106 *
107 * @param index the variable slot
108 *
109 * @return the first LocalVariable that matches the slot or null if not found
110 *
111 * @deprecated since 5.2 because multiple variables can share the
112 * same slot, use getLocalVariable(int index, int pc) instead.
113 */
114 public final LocalVariable getLocalVariable( int index ) {
115 for (int i = 0; i < local_variable_table_length; i++) {
116 if (local_variable_table[i].getIndex() == index) {
117 return local_variable_table[i];
118 }
119 }
120 return null;
121 }
122
123
124 /**
125 * @return matching variable using index when variable is used at supplied pc
126 *
127 * @param index the variable slot
128 * @param pc the current pc that this variable is alive
129 *
130 * @return the LocalVariable that matches or null if not found
131 */
132 public final LocalVariable getLocalVariable( int index, int pc ) {
133 for (int i = 0; i < local_variable_table_length; i++) {
134 if (local_variable_table[i].getIndex() == index) {
135 int start_pc = local_variable_table[i].getStartPC();
136 int end_pc = start_pc + local_variable_table[i].getLength();
137 if ((pc >= start_pc) && (pc < end_pc)) {
138 return local_variable_table[i];
139 }
140 }
141 }
142 return null;
143 }
144
145
146 public final void setLocalVariableTable( LocalVariable[] local_variable_table ) {
147 this.local_variable_table = local_variable_table;
148 local_variable_table_length = (local_variable_table == null)
149 ? 0
150 : local_variable_table.length;
151 }
152
153
154 /**
155 * @return String representation.
156 */
157 public final String toString() {
158 StringBuffer buf = new StringBuffer("");
159 for (int i = 0; i < local_variable_table_length; i++) {
160 buf.append(local_variable_table[i].toString());
161 if (i < local_variable_table_length - 1) {
162 buf.append('\n');
163 }
164 }
165 return buf.toString();
166 }
167
168
169 /**
170 * @return deep copy of this attribute
171 */
172 public Attribute copy( ConstantPool _constant_pool ) {
173 AbstractLocalVariableTable c = (AbstractLocalVariableTable) clone();
174 c.local_variable_table = new LocalVariable[local_variable_table_length];
175 for (int i = 0; i < local_variable_table_length; i++) {
176 c.local_variable_table[i] = local_variable_table[i].copy();
177 }
178 c.constant_pool = _constant_pool;
179 return c;
180 }
181
182
183 public final int getTableLength() {
184 return local_variable_table_length;
185 }
186 }
+0
-238
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/AccessFlags.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 import org.apache.bcel.Constants;
19
20 /**
21 * Super class for all objects that have modifiers like private, final, ...
22 * I.e. classes, fields, and methods.
23 *
24 * @version $Id: AccessFlags.java 386056 2006-03-15 11:31:56Z tcurdt $
25 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
26 */
27 public abstract class AccessFlags implements java.io.Serializable {
28
29 protected int access_flags;
30
31
32 public AccessFlags() {
33 }
34
35
36 /**
37 * @param a inital access flags
38 */
39 public AccessFlags(int a) {
40 access_flags = a;
41 }
42
43
44 /**
45 * @return Access flags of the object aka. "modifiers".
46 */
47 public final int getAccessFlags() {
48 return access_flags;
49 }
50
51
52 /**
53 * @return Access flags of the object aka. "modifiers".
54 */
55 public final int getModifiers() {
56 return access_flags;
57 }
58
59
60 /** Set access flags aka "modifiers".
61 * @param access_flags Access flags of the object.
62 */
63 public final void setAccessFlags( int access_flags ) {
64 this.access_flags = access_flags;
65 }
66
67
68 /** Set access flags aka "modifiers".
69 * @param access_flags Access flags of the object.
70 */
71 public final void setModifiers( int access_flags ) {
72 setAccessFlags(access_flags);
73 }
74
75
76 private final void setFlag( int flag, boolean set ) {
77 if ((access_flags & flag) != 0) { // Flag is set already
78 if (!set) {
79 access_flags ^= flag;
80 }
81 } else { // Flag not set
82 if (set) {
83 access_flags |= flag;
84 }
85 }
86 }
87
88
89 public final void isPublic( boolean flag ) {
90 setFlag(Constants.ACC_PUBLIC, flag);
91 }
92
93
94 public final boolean isPublic() {
95 return (access_flags & Constants.ACC_PUBLIC) != 0;
96 }
97
98
99 public final void isPrivate( boolean flag ) {
100 setFlag(Constants.ACC_PRIVATE, flag);
101 }
102
103
104 public final boolean isPrivate() {
105 return (access_flags & Constants.ACC_PRIVATE) != 0;
106 }
107
108
109 public final void isProtected( boolean flag ) {
110 setFlag(Constants.ACC_PROTECTED, flag);
111 }
112
113
114 public final boolean isProtected() {
115 return (access_flags & Constants.ACC_PROTECTED) != 0;
116 }
117
118
119 public final void isStatic( boolean flag ) {
120 setFlag(Constants.ACC_STATIC, flag);
121 }
122
123
124 public final boolean isStatic() {
125 return (access_flags & Constants.ACC_STATIC) != 0;
126 }
127
128
129 public final void isFinal( boolean flag ) {
130 setFlag(Constants.ACC_FINAL, flag);
131 }
132
133
134 public final boolean isFinal() {
135 return (access_flags & Constants.ACC_FINAL) != 0;
136 }
137
138
139 public final void isSynchronized( boolean flag ) {
140 setFlag(Constants.ACC_SYNCHRONIZED, flag);
141 }
142
143
144 public final boolean isSynchronized() {
145 return (access_flags & Constants.ACC_SYNCHRONIZED) != 0;
146 }
147
148
149 public final void isVolatile( boolean flag ) {
150 setFlag(Constants.ACC_VOLATILE, flag);
151 }
152
153
154 public final boolean isVolatile() {
155 return (access_flags & Constants.ACC_VOLATILE) != 0;
156 }
157
158
159 public final void isTransient( boolean flag ) {
160 setFlag(Constants.ACC_TRANSIENT, flag);
161 }
162
163
164 public final boolean isTransient() {
165 return (access_flags & Constants.ACC_TRANSIENT) != 0;
166 }
167
168
169 public final void isNative( boolean flag ) {
170 setFlag(Constants.ACC_NATIVE, flag);
171 }
172
173
174 public final boolean isNative() {
175 return (access_flags & Constants.ACC_NATIVE) != 0;
176 }
177
178
179 public final void isInterface( boolean flag ) {
180 setFlag(Constants.ACC_INTERFACE, flag);
181 }
182
183
184 public final boolean isInterface() {
185 return (access_flags & Constants.ACC_INTERFACE) != 0;
186 }
187
188
189 public final void isAbstract( boolean flag ) {
190 setFlag(Constants.ACC_ABSTRACT, flag);
191 }
192
193
194 public final boolean isAbstract() {
195 return (access_flags & Constants.ACC_ABSTRACT) != 0;
196 }
197
198
199 public final void isStrictfp( boolean flag ) {
200 setFlag(Constants.ACC_STRICT, flag);
201 }
202
203
204 public final boolean isStrictfp() {
205 return (access_flags & Constants.ACC_STRICT) != 0;
206 }
207
208
209 public final void isSynthetic( boolean flag ) {
210 setFlag(Constants.ACC_SYNTHETIC, flag);
211 }
212
213
214 public final boolean isSynthetic() {
215 return (access_flags & Constants.ACC_SYNTHETIC) != 0;
216 }
217
218
219 public final void isAnnotation( boolean flag ) {
220 setFlag(Constants.ACC_ANNOTATION, flag);
221 }
222
223
224 public final boolean isAnnotation() {
225 return (access_flags & Constants.ACC_ANNOTATION) != 0;
226 }
227
228
229 public final void isEnum( boolean flag ) {
230 setFlag(Constants.ACC_ENUM, flag);
231 }
232
233
234 public final boolean isEnum() {
235 return (access_flags & Constants.ACC_ENUM) != 0;
236 }
237 }
+0
-280
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/Attribute.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 import java.io.DataInputStream;
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21 import java.io.Serializable;
22 import java.util.HashMap;
23 import java.util.Map;
24 import org.apache.bcel.Constants;
25
26 /**
27 * Abstract super class for <em>Attribute</em> objects. Currently the
28 * <em>ConstantValue</em>, <em>SourceFile</em>, <em>Code</em>,
29 * <em>Exceptiontable</em>, <em>LineNumberTable</em>,
30 * <em>LocalVariableTable</em>, <em>InnerClasses</em> and
31 * <em>Synthetic</em> attributes are supported. The
32 * <em>Unknown</em> attribute stands for non-standard-attributes.
33 *
34 * @version $Id: Attribute.java 386056 2006-03-15 11:31:56Z tcurdt $
35 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
36 * @see ConstantValue
37 * @see SourceFile
38 * @see Code
39 * @see Unknown
40 * @see ExceptionTable
41 * @see LineNumberTable
42 * @see LocalVariableTable
43 * @see InnerClasses
44 * @see Synthetic
45 * @see Deprecated
46 * @see Signature
47 */
48 public abstract class Attribute implements Cloneable, Node, Serializable {
49
50 protected int name_index; // Points to attribute name in constant pool
51 protected int length; // Content length of attribute field
52 protected byte tag; // Tag to distiguish subclasses
53 protected ConstantPool constant_pool;
54
55
56 protected Attribute(byte tag, int name_index, int length, ConstantPool constant_pool) {
57 this.tag = tag;
58 this.name_index = name_index;
59 this.length = length;
60 this.constant_pool = constant_pool;
61 }
62
63
64 /**
65 * Called by objects that are traversing the nodes of the tree implicitely
66 * defined by the contents of a Java class. I.e., the hierarchy of methods,
67 * fields, attributes, etc. spawns a tree of objects.
68 *
69 * @param v Visitor object
70 */
71 public abstract void accept( Visitor v );
72
73
74 /**
75 * Dump attribute to file stream in binary format.
76 *
77 * @param file Output file stream
78 * @throws IOException
79 */
80 public void dump( DataOutputStream file ) throws IOException {
81 file.writeShort(name_index);
82 file.writeInt(length);
83 }
84
85 private static Map readers = new HashMap();
86
87
88 /** Add an Attribute reader capable of parsing (user-defined) attributes
89 * named "name". You should not add readers for the standard attributes
90 * such as "LineNumberTable", because those are handled internally.
91 *
92 * @param name the name of the attribute as stored in the class file
93 * @param r the reader object
94 */
95 public static void addAttributeReader( String name, AttributeReader r ) {
96 readers.put(name, r);
97 }
98
99
100 /** Remove attribute reader
101 *
102 * @param name the name of the attribute as stored in the class file
103 */
104 public static void removeAttributeReader( String name ) {
105 readers.remove(name);
106 }
107
108
109 /* Class method reads one attribute from the input data stream.
110 * This method must not be accessible from the outside. It is
111 * called by the Field and Method constructor methods.
112 *
113 * @see Field
114 * @see Method
115 * @param file Input stream
116 * @param constant_pool Array of constants
117 * @return Attribute
118 * @throws IOException
119 * @throws ClassFormatException
120 */
121 public static final Attribute readAttribute( DataInputStream file, ConstantPool constant_pool )
122 throws IOException, ClassFormatException {
123 ConstantUtf8 c;
124 String name;
125 int name_index;
126 int length;
127 byte tag = Constants.ATTR_UNKNOWN; // Unknown attribute
128 // Get class name from constant pool via `name_index' indirection
129 name_index = file.readUnsignedShort();
130 c = (ConstantUtf8) constant_pool.getConstant(name_index, Constants.CONSTANT_Utf8);
131 name = c.getBytes();
132 // Length of data in bytes
133 length = file.readInt();
134 // Compare strings to find known attribute
135 for (byte i = 0; i < Constants.KNOWN_ATTRIBUTES; i++) {
136 if (name.equals(Constants.ATTRIBUTE_NAMES[i])) {
137 tag = i; // found!
138 break;
139 }
140 }
141 // Call proper constructor, depending on `tag'
142 switch (tag) {
143 case Constants.ATTR_UNKNOWN:
144 AttributeReader r = (AttributeReader) readers.get(name);
145 if (r != null) {
146 return r.createAttribute(name_index, length, file, constant_pool);
147 }
148 return new Unknown(name_index, length, file, constant_pool);
149 case Constants.ATTR_CONSTANT_VALUE:
150 return new ConstantValue(name_index, length, file, constant_pool);
151 case Constants.ATTR_SOURCE_FILE:
152 return new SourceFile(name_index, length, file, constant_pool);
153 case Constants.ATTR_CODE:
154 return new Code(name_index, length, file, constant_pool);
155 case Constants.ATTR_EXCEPTIONS:
156 return new ExceptionTable(name_index, length, file, constant_pool);
157 case Constants.ATTR_LINE_NUMBER_TABLE:
158 return new LineNumberTable(name_index, length, file, constant_pool);
159 case Constants.ATTR_LOCAL_VARIABLE_TABLE:
160 return new LocalVariableTable(name_index, length, file, constant_pool);
161 case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE:
162 return new LocalVariableTypeTable(name_index, length, file, constant_pool);
163 case Constants.ATTR_INNER_CLASSES:
164 return new InnerClasses(name_index, length, file, constant_pool);
165 case Constants.ATTR_SYNTHETIC:
166 return new Synthetic(name_index, length, file, constant_pool);
167 case Constants.ATTR_DEPRECATED:
168 return new Deprecated(name_index, length, file, constant_pool);
169 case Constants.ATTR_PMG:
170 return new PMGClass(name_index, length, file, constant_pool);
171 case Constants.ATTR_SIGNATURE:
172 return new Signature(name_index, length, file, constant_pool);
173 case Constants.ATTR_STACK_MAP:
174 return new StackMap(name_index, length, file, constant_pool);
175 // case Constants.ATTR_RUNTIMEVISIBLE_ANNOTATIONS:
176 // return new RuntimeVisibleAnnotations(name_index, length, file, constant_pool);
177 // case Constants.ATTR_RUNTIMEINVISIBLE_ANNOTATIONS:
178 // return new RuntimeInvisibleAnnotations(name_index, length, file, constant_pool);
179 // case Constants.ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS:
180 // return new RuntimeVisibleParameterAnnotations(name_index, length, file, constant_pool);
181 // case Constants.ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS:
182 // return new RuntimeInvisibleParameterAnnotations(name_index, length, file, constant_pool);
183 // case Constants.ATTR_ANNOTATION_DEFAULT:
184 // return new AnnotationDefault(name_index, length, file, constant_pool);
185 default: // Never reached
186 throw new IllegalStateException("Ooops! default case reached.");
187 }
188 }
189
190
191 /**
192 * @return Length of attribute field in bytes.
193 */
194 public final int getLength() {
195 return length;
196 }
197
198
199 /**
200 * @param length length in bytes.
201 */
202 public final void setLength( int length ) {
203 this.length = length;
204 }
205
206
207 /**
208 * @param name_index of attribute.
209 */
210 public final void setNameIndex( int name_index ) {
211 this.name_index = name_index;
212 }
213
214
215 /**
216 * @return Name index in constant pool of attribute name.
217 */
218 public final int getNameIndex() {
219 return name_index;
220 }
221
222
223 /**
224 * @return Tag of attribute, i.e., its type. Value may not be altered, thus
225 * there is no setTag() method.
226 */
227 public final byte getTag() {
228 return tag;
229 }
230
231
232 /**
233 * @return Constant pool used by this object.
234 * @see ConstantPool
235 */
236 public final ConstantPool getConstantPool() {
237 return constant_pool;
238 }
239
240
241 /**
242 * @param constant_pool Constant pool to be used for this object.
243 * @see ConstantPool
244 */
245 public final void setConstantPool( ConstantPool constant_pool ) {
246 this.constant_pool = constant_pool;
247 }
248
249
250 /**
251 * Use copy() if you want to have a deep copy(), i.e., with all references
252 * copied correctly.
253 *
254 * @return shallow copy of this attribute
255 */
256 public Object clone() {
257 Object o = null;
258 try {
259 o = super.clone();
260 } catch (CloneNotSupportedException e) {
261 e.printStackTrace(); // Never occurs
262 }
263 return o;
264 }
265
266
267 /**
268 * @return deep copy of this attribute
269 */
270 public abstract Attribute copy( ConstantPool _constant_pool );
271
272
273 /**
274 * @return attribute name.
275 */
276 public String toString() {
277 return Constants.ATTRIBUTE_NAMES[tag];
278 }
279 }
+0
-58
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/AttributeReader.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 /**
19 * Unknown (non-standard) attributes may be read via user-defined factory
20 * objects that can be registered with the Attribute.addAttributeReader
21 * method. These factory objects should implement this interface.
22
23 * @see Attribute
24 * @version $Id: AttributeReader.java 386056 2006-03-15 11:31:56Z tcurdt $
25 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
26 */
27 public interface AttributeReader {
28
29 /**
30 When this attribute reader is added via the static method
31 Attribute.addAttributeReader, an attribute name is associated with it.
32 As the class file parser parses attributes, it will call various
33 AttributeReaders based on the name of the attributes it is
34 constructing.
35
36 @param name_index An index into the constant pool, indexing a
37 ConstantUtf8 that represents the name of the attribute.
38
39 @param length The length of the data contained in the attribute. This
40 is written into the constant pool and should agree with what the
41 factory expects the length to be.
42
43 @param file This is the data input stream that the factory needs to read
44 its data from.
45
46 @param constant_pool This is the constant pool associated with the
47 Attribute that we are constructing.
48
49 @return The user-defined AttributeReader should take this data and use
50 it to construct an attribute. In the case of errors, a null can be
51 returned which will cause the parsing of the class file to fail.
52
53 @see Attribute#addAttributeReader( String, AttributeReader )
54 */
55 public Attribute createAttribute( int name_index, int length, java.io.DataInputStream file,
56 ConstantPool constant_pool );
57 }
+0
-37
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/ClassFormatException.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 /**
19 * Thrown when the BCEL attempts to read a class file and determines
20 * that the file is malformed or otherwise cannot be interpreted as a
21 * class file.
22 *
23 * @version $Id: ClassFormatException.java 386056 2006-03-15 11:31:56Z tcurdt $
24 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
25 */
26 public class ClassFormatException extends RuntimeException {
27
28 public ClassFormatException() {
29 super();
30 }
31
32
33 public ClassFormatException(String s) {
34 super(s);
35 }
36 }
+0
-295
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/ClassParser.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 import java.io.BufferedInputStream;
19 import java.io.DataInputStream;
20 import java.io.FileInputStream;
21 import java.io.IOException;
22 import java.io.InputStream;
23 import java.util.zip.ZipEntry;
24 import java.util.zip.ZipFile;
25 import org.apache.bcel.Constants;
26
27 /**
28 * Wrapper class that parses a given Java .class file. The method <A
29 * href ="#parse">parse</A> returns a <A href ="JavaClass.html">
30 * JavaClass</A> object on success. When an I/O error or an
31 * inconsistency occurs an appropiate exception is propagated back to
32 * the caller.
33 *
34 * The structure and the names comply, except for a few conveniences,
35 * exactly with the <A href="ftp://java.sun.com/docs/specs/vmspec.ps">
36 * JVM specification 1.0</a>. See this paper for
37 * further details about the structure of a bytecode file.
38 *
39 * @version $Id: ClassParser.java 386056 2006-03-15 11:31:56Z tcurdt $
40 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
41 */
42 public final class ClassParser {
43
44 private DataInputStream file;
45 private boolean fileOwned;
46 private String file_name;
47 private String zip_file;
48 private int class_name_index, superclass_name_index;
49 private int major, minor; // Compiler version
50 private int access_flags; // Access rights of parsed class
51 private int[] interfaces; // Names of implemented interfaces
52 private ConstantPool constant_pool; // collection of constants
53 private Field[] fields; // class fields, i.e., its variables
54 private Method[] methods; // methods defined in the class
55 private Attribute[] attributes; // attributes defined in the class
56 private boolean is_zip; // Loaded from zip file
57 private static final int BUFSIZE = 8192;
58
59
60 /**
61 * Parse class from the given stream.
62 *
63 * @param file Input stream
64 * @param file_name File name
65 */
66 public ClassParser(InputStream file, String file_name) {
67 this.file_name = file_name;
68 fileOwned = false;
69 String clazz = file.getClass().getName(); // Not a very clean solution ...
70 is_zip = clazz.startsWith("java.util.zip.") || clazz.startsWith("java.util.jar.");
71 if (file instanceof DataInputStream) {
72 this.file = (DataInputStream) file;
73 } else {
74 this.file = new DataInputStream(new BufferedInputStream(file, BUFSIZE));
75 }
76 }
77
78
79 /** Parse class from given .class file.
80 *
81 * @param file_name file name
82 */
83 public ClassParser(String file_name) throws IOException {
84 is_zip = false;
85 this.file_name = file_name;
86 fileOwned = true;
87 }
88
89
90 /** Parse class from given .class file in a ZIP-archive
91 *
92 * @param zip_file zip file name
93 * @param file_name file name
94 */
95 public ClassParser(String zip_file, String file_name) {
96 is_zip = true;
97 fileOwned = true;
98 this.zip_file = zip_file;
99 this.file_name = file_name;
100 }
101
102
103 /**
104 * Parse the given Java class file and return an object that represents
105 * the contained data, i.e., constants, methods, fields and commands.
106 * A <em>ClassFormatException</em> is raised, if the file is not a valid
107 * .class file. (This does not include verification of the byte code as it
108 * is performed by the java interpreter).
109 *
110 * @return Class object representing the parsed class file
111 * @throws IOException
112 * @throws ClassFormatException
113 */
114 public JavaClass parse() throws IOException, ClassFormatException {
115 ZipFile zip = null;
116 try {
117 if (fileOwned) {
118 if (is_zip) {
119 zip = new ZipFile(zip_file);
120 ZipEntry entry = zip.getEntry(file_name);
121 file = new DataInputStream(new BufferedInputStream(zip.getInputStream(entry),
122 BUFSIZE));
123 } else {
124 file = new DataInputStream(new BufferedInputStream(new FileInputStream(
125 file_name), BUFSIZE));
126 }
127 }
128 /****************** Read headers ********************************/
129 // Check magic tag of class file
130 readID();
131 // Get compiler version
132 readVersion();
133 /****************** Read constant pool and related **************/
134 // Read constant pool entries
135 readConstantPool();
136 // Get class information
137 readClassInfo();
138 // Get interface information, i.e., implemented interfaces
139 readInterfaces();
140 /****************** Read class fields and methods ***************/
141 // Read class fields, i.e., the variables of the class
142 readFields();
143 // Read class methods, i.e., the functions in the class
144 readMethods();
145 // Read class attributes
146 readAttributes();
147 // Check for unknown variables
148 //Unknown[] u = Unknown.getUnknownAttributes();
149 //for(int i=0; i < u.length; i++)
150 // System.err.println("WARNING: " + u[i]);
151 // Everything should have been read now
152 // if(file.available() > 0) {
153 // int bytes = file.available();
154 // byte[] buf = new byte[bytes];
155 // file.read(buf);
156 // if(!(is_zip && (buf.length == 1))) {
157 // System.err.println("WARNING: Trailing garbage at end of " + file_name);
158 // System.err.println(bytes + " extra bytes: " + Utility.toHexString(buf));
159 // }
160 // }
161 } finally {
162 // Read everything of interest, so close the file
163 if (fileOwned) {
164 file.close();
165 if (zip != null) {
166 zip.close();
167 }
168 }
169 }
170 // Return the information we have gathered in a new object
171 return new JavaClass(class_name_index, superclass_name_index, file_name, major, minor,
172 access_flags, constant_pool, interfaces, fields, methods, attributes, is_zip
173 ? JavaClass.ZIP
174 : JavaClass.FILE);
175 }
176
177
178 /**
179 * Read information about the attributes of the class.
180 * @throws IOException
181 * @throws ClassFormatException
182 */
183 private final void readAttributes() throws IOException, ClassFormatException {
184 int attributes_count;
185 attributes_count = file.readUnsignedShort();
186 attributes = new Attribute[attributes_count];
187 for (int i = 0; i < attributes_count; i++) {
188 attributes[i] = Attribute.readAttribute(file, constant_pool);
189 }
190 }
191
192
193 /**
194 * Read information about the class and its super class.
195 * @throws IOException
196 * @throws ClassFormatException
197 */
198 private final void readClassInfo() throws IOException, ClassFormatException {
199 access_flags = file.readUnsignedShort();
200 /* Interfaces are implicitely abstract, the flag should be set
201 * according to the JVM specification.
202 */
203 if ((access_flags & Constants.ACC_INTERFACE) != 0) {
204 access_flags |= Constants.ACC_ABSTRACT;
205 }
206 if (((access_flags & Constants.ACC_ABSTRACT) != 0)
207 && ((access_flags & Constants.ACC_FINAL) != 0)) {
208 throw new ClassFormatException("Class can't be both final and abstract");
209 }
210 class_name_index = file.readUnsignedShort();
211 superclass_name_index = file.readUnsignedShort();
212 }
213
214
215 /**
216 * Read constant pool entries.
217 * @throws IOException
218 * @throws ClassFormatException
219 */
220 private final void readConstantPool() throws IOException, ClassFormatException {
221 constant_pool = new ConstantPool(file);
222 }
223
224
225 /**
226 * Read information about the fields of the class, i.e., its variables.
227 * @throws IOException
228 * @throws ClassFormatException
229 */
230 private final void readFields() throws IOException, ClassFormatException {
231 int fields_count;
232 fields_count = file.readUnsignedShort();
233 fields = new Field[fields_count];
234 for (int i = 0; i < fields_count; i++) {
235 fields[i] = new Field(file, constant_pool);
236 }
237 }
238
239
240 /******************** Private utility methods **********************/
241 /**
242 * Check whether the header of the file is ok.
243 * Of course, this has to be the first action on successive file reads.
244 * @throws IOException
245 * @throws ClassFormatException
246 */
247 private final void readID() throws IOException, ClassFormatException {
248 int magic = 0xCAFEBABE;
249 if (file.readInt() != magic) {
250 throw new ClassFormatException(file_name + " is not a Java .class file");
251 }
252 }
253
254
255 /**
256 * Read information about the interfaces implemented by this class.
257 * @throws IOException
258 * @throws ClassFormatException
259 */
260 private final void readInterfaces() throws IOException, ClassFormatException {
261 int interfaces_count;
262 interfaces_count = file.readUnsignedShort();
263 interfaces = new int[interfaces_count];
264 for (int i = 0; i < interfaces_count; i++) {
265 interfaces[i] = file.readUnsignedShort();
266 }
267 }
268
269
270 /**
271 * Read information about the methods of the class.
272 * @throws IOException
273 * @throws ClassFormatException
274 */
275 private final void readMethods() throws IOException, ClassFormatException {
276 int methods_count;
277 methods_count = file.readUnsignedShort();
278 methods = new Method[methods_count];
279 for (int i = 0; i < methods_count; i++) {
280 methods[i] = new Method(file, constant_pool);
281 }
282 }
283
284
285 /**
286 * Read major and minor version of compiler which created the file.
287 * @throws IOException
288 * @throws ClassFormatException
289 */
290 private final void readVersion() throws IOException, ClassFormatException {
291 minor = file.readUnsignedShort();
292 major = file.readUnsignedShort();
293 }
294 }
+0
-352
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/Code.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 import java.io.DataInputStream;
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21 import org.apache.bcel.Constants;
22
23 /**
24 * This class represents a chunk of Java byte code contained in a
25 * method. It is instantiated by the
26 * <em>Attribute.readAttribute()</em> method. A <em>Code</em>
27 * attribute contains informations about operand stack, local
28 * variables, byte code and the exceptions handled within this
29 * method.
30 *
31 * This attribute has attributes itself, namely <em>LineNumberTable</em> which
32 * is used for debugging purposes and <em>LocalVariableTable</em> which
33 * contains information about the local variables.
34 *
35 * @version $Id: Code.java 386056 2006-03-15 11:31:56Z tcurdt $
36 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
37 * @see Attribute
38 * @see CodeException
39 * @see LineNumberTable
40 * @see LocalVariableTable
41 */
42 public final class Code extends Attribute {
43
44 private int max_stack; // Maximum size of stack used by this method
45 private int max_locals; // Number of local variables
46 private int code_length; // Length of code in bytes
47 private byte[] code; // Actual byte code
48 private int exception_table_length;
49 private CodeException[] exception_table; // Table of handled exceptions
50 private int attributes_count; // Attributes of code: LineNumber
51 private Attribute[] attributes; // or LocalVariable
52
53
54 /**
55 * Initialize from another object. Note that both objects use the same
56 * references (shallow copy). Use copy() for a physical copy.
57 */
58 public Code(Code c) {
59 this(c.getNameIndex(), c.getLength(), c.getMaxStack(), c.getMaxLocals(), c.getCode(), c
60 .getExceptionTable(), c.getAttributes(), c.getConstantPool());
61 }
62
63
64 /**
65 * @param name_index Index pointing to the name <em>Code</em>
66 * @param length Content length in bytes
67 * @param file Input stream
68 * @param constant_pool Array of constants
69 */
70 Code(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
71 throws IOException {
72 // Initialize with some default values which will be overwritten later
73 this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(), (byte[]) null,
74 (CodeException[]) null, (Attribute[]) null, constant_pool);
75 code_length = file.readInt();
76 code = new byte[code_length]; // Read byte code
77 file.readFully(code);
78 /* Read exception table that contains all regions where an exception
79 * handler is active, i.e., a try { ... } catch() block.
80 */
81 exception_table_length = file.readUnsignedShort();
82 exception_table = new CodeException[exception_table_length];
83 for (int i = 0; i < exception_table_length; i++) {
84 exception_table[i] = new CodeException(file);
85 }
86 /* Read all attributes, currently `LineNumberTable' and
87 * `LocalVariableTable'
88 */
89 attributes_count = file.readUnsignedShort();
90 attributes = new Attribute[attributes_count];
91 for (int i = 0; i < attributes_count; i++) {
92 attributes[i] = Attribute.readAttribute(file, constant_pool);
93 }
94 /* Adjust length, because of setAttributes in this(), s.b. length
95 * is incorrect, because it didn't take the internal attributes
96 * into account yet! Very subtle bug, fixed in 3.1.1.
97 */
98 this.length = length;
99 }
100
101
102 /**
103 * @param name_index Index pointing to the name <em>Code</em>
104 * @param length Content length in bytes
105 * @param max_stack Maximum size of stack
106 * @param max_locals Number of local variables
107 * @param code Actual byte code
108 * @param exception_table Table of handled exceptions
109 * @param attributes Attributes of code: LineNumber or LocalVariable
110 * @param constant_pool Array of constants
111 */
112 public Code(int name_index, int length, int max_stack, int max_locals, byte[] code,
113 CodeException[] exception_table, Attribute[] attributes, ConstantPool constant_pool) {
114 super(Constants.ATTR_CODE, name_index, length, constant_pool);
115 this.max_stack = max_stack;
116 this.max_locals = max_locals;
117 setCode(code);
118 setExceptionTable(exception_table);
119 setAttributes(attributes); // Overwrites length!
120 }
121
122
123 /**
124 * Called by objects that are traversing the nodes of the tree implicitely
125 * defined by the contents of a Java class. I.e., the hierarchy of methods,
126 * fields, attributes, etc. spawns a tree of objects.
127 *
128 * @param v Visitor object
129 */
130 public void accept( Visitor v ) {
131 v.visitCode(this);
132 }
133
134
135 /**
136 * Dump code attribute to file stream in binary format.
137 *
138 * @param file Output file stream
139 * @throws IOException
140 */
141 public final void dump( DataOutputStream file ) throws IOException {
142 super.dump(file);
143 file.writeShort(max_stack);
144 file.writeShort(max_locals);
145 file.writeInt(code_length);
146 file.write(code, 0, code_length);
147 file.writeShort(exception_table_length);
148 for (int i = 0; i < exception_table_length; i++) {
149 exception_table[i].dump(file);
150 }
151 file.writeShort(attributes_count);
152 for (int i = 0; i < attributes_count; i++) {
153 attributes[i].dump(file);
154 }
155 }
156
157
158 /**
159 * @return Collection of code attributes.
160 * @see Attribute
161 */
162 public final Attribute[] getAttributes() {
163 return attributes;
164 }
165
166
167 /**
168 * @return LineNumberTable of Code, if it has one
169 */
170 public LineNumberTable getLineNumberTable() {
171 for (int i = 0; i < attributes_count; i++) {
172 if (attributes[i] instanceof LineNumberTable) {
173 return (LineNumberTable) attributes[i];
174 }
175 }
176 return null;
177 }
178
179
180 /**
181 * @return LocalVariableTable of Code, if it has one
182 */
183 public LocalVariableTable getLocalVariableTable() {
184 for (int i = 0; i < attributes_count; i++) {
185 if (attributes[i] instanceof LocalVariableTable) {
186 return (LocalVariableTable) attributes[i];
187 }
188 }
189 return null;
190 }
191
192
193 /**
194 * @return Actual byte code of the method.
195 */
196 public final byte[] getCode() {
197 return code;
198 }
199
200
201 /**
202 * @return Table of handled exceptions.
203 * @see CodeException
204 */
205 public final CodeException[] getExceptionTable() {
206 return exception_table;
207 }
208
209
210 /**
211 * @return Number of local variables.
212 */
213 public final int getMaxLocals() {
214 return max_locals;
215 }
216
217
218 /**
219 * @return Maximum size of stack used by this method.
220 */
221 public final int getMaxStack() {
222 return max_stack;
223 }
224
225
226 /**
227 * @return the internal length of this code attribute (minus the first 6 bytes)
228 * and excluding all its attributes
229 */
230 private final int getInternalLength() {
231 return 2 /*max_stack*/+ 2 /*max_locals*/+ 4 /*code length*/
232 + code_length /*byte-code*/
233 + 2 /*exception-table length*/
234 + 8 * exception_table_length /* exception table */
235 + 2 /* attributes count */;
236 }
237
238
239 /**
240 * @return the full size of this code attribute, minus its first 6 bytes,
241 * including the size of all its contained attributes
242 */
243 private final int calculateLength() {
244 int len = 0;
245 for (int i = 0; i < attributes_count; i++) {
246 len += attributes[i].length + 6 /*attribute header size*/;
247 }
248 return len + getInternalLength();
249 }
250
251
252 /**
253 * @param attributes the attributes to set for this Code
254 */
255 public final void setAttributes( Attribute[] attributes ) {
256 this.attributes = attributes;
257 attributes_count = (attributes == null) ? 0 : attributes.length;
258 length = calculateLength(); // Adjust length
259 }
260
261
262 /**
263 * @param code byte code
264 */
265 public final void setCode( byte[] code ) {
266 this.code = code;
267 code_length = (code == null) ? 0 : code.length;
268 }
269
270
271 /**
272 * @param exception_table exception table
273 */
274 public final void setExceptionTable( CodeException[] exception_table ) {
275 this.exception_table = exception_table;
276 exception_table_length = (exception_table == null) ? 0 : exception_table.length;
277 }
278
279
280 /**
281 * @param max_locals maximum number of local variables
282 */
283 public final void setMaxLocals( int max_locals ) {
284 this.max_locals = max_locals;
285 }
286
287
288 /**
289 * @param max_stack maximum stack size
290 */
291 public final void setMaxStack( int max_stack ) {
292 this.max_stack = max_stack;
293 }
294
295
296 /**
297 * @return String representation of code chunk.
298 */
299 public final String toString( boolean verbose ) {
300 StringBuffer buf;
301 buf = new StringBuffer(100);
302 buf.append("Code(max_stack = ").append(max_stack).append(", max_locals = ").append(
303 max_locals).append(", code_length = ").append(code_length).append(")\n").append(
304 Utility.codeToString(code, constant_pool, 0, -1, verbose));
305 if (exception_table_length > 0) {
306 buf.append("\nException handler(s) = \n").append("From\tTo\tHandler\tType\n");
307 for (int i = 0; i < exception_table_length; i++) {
308 buf.append(exception_table[i].toString(constant_pool, verbose)).append("\n");
309 }
310 }
311 if (attributes_count > 0) {
312 buf.append("\nAttribute(s) = \n");
313 for (int i = 0; i < attributes_count; i++) {
314 buf.append(attributes[i].toString()).append("\n");
315 }
316 }
317 return buf.toString();
318 }
319
320
321 /**
322 * @return String representation of code chunk.
323 */
324 public final String toString() {
325 return toString(true);
326 }
327
328
329 /**
330 * @return deep copy of this attribute
331 *
332 * @param _constant_pool the constant pool to duplicate
333 */
334 public Attribute copy( ConstantPool _constant_pool ) {
335 Code c = (Code) clone();
336 if (code != null) {
337 c.code = new byte[code.length];
338 System.arraycopy(code, 0, c.code, 0, code.length);
339 }
340 c.constant_pool = _constant_pool;
341 c.exception_table = new CodeException[exception_table_length];
342 for (int i = 0; i < exception_table_length; i++) {
343 c.exception_table[i] = exception_table[i].copy();
344 }
345 c.attributes = new Attribute[attributes_count];
346 for (int i = 0; i < attributes_count; i++) {
347 c.attributes[i] = attributes[i].copy(_constant_pool);
348 }
349 return c;
350 }
351 }
+0
-214
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/CodeException.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 import java.io.DataInputStream;
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21 import java.io.Serializable;
22 import org.apache.bcel.Constants;
23
24 /**
25 * This class represents an entry in the exception table of the <em>Code</em>
26 * attribute and is used only there. It contains a range in which a
27 * particular exception handler is active.
28 *
29 * @version $Id: CodeException.java 386056 2006-03-15 11:31:56Z tcurdt $
30 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
31 * @see Code
32 */
33 public final class CodeException implements Cloneable, Constants, Node, Serializable {
34
35 private int start_pc; // Range in the code the exception handler is
36 private int end_pc; // active. start_pc is inclusive, end_pc exclusive
37 private int handler_pc; /* Starting address of exception handler, i.e.,
38 * an offset from start of code.
39 */
40 private int catch_type; /* If this is zero the handler catches any
41 * exception, otherwise it points to the
42 * exception class which is to be caught.
43 */
44
45
46 /**
47 * Initialize from another object.
48 */
49 public CodeException(CodeException c) {
50 this(c.getStartPC(), c.getEndPC(), c.getHandlerPC(), c.getCatchType());
51 }
52
53
54 /**
55 * Construct object from file stream.
56 * @param file Input stream
57 * @throws IOException
58 */
59 CodeException(DataInputStream file) throws IOException {
60 this(file.readUnsignedShort(), file.readUnsignedShort(), file.readUnsignedShort(), file
61 .readUnsignedShort());
62 }
63
64
65 /**
66 * @param start_pc Range in the code the exception handler is active,
67 * start_pc is inclusive while
68 * @param end_pc is exclusive
69 * @param handler_pc Starting address of exception handler, i.e.,
70 * an offset from start of code.
71 * @param catch_type If zero the handler catches any
72 * exception, otherwise it points to the exception class which is
73 * to be caught.
74 */
75 public CodeException(int start_pc, int end_pc, int handler_pc, int catch_type) {
76 this.start_pc = start_pc;
77 this.end_pc = end_pc;
78 this.handler_pc = handler_pc;
79 this.catch_type = catch_type;
80 }
81
82
83 /**
84 * Called by objects that are traversing the nodes of the tree implicitely
85 * defined by the contents of a Java class. I.e., the hierarchy of methods,
86 * fields, attributes, etc. spawns a tree of objects.
87 *
88 * @param v Visitor object
89 */
90 public void accept( Visitor v ) {
91 v.visitCodeException(this);
92 }
93
94
95 /**
96 * Dump code exception to file stream in binary format.
97 *
98 * @param file Output file stream
99 * @throws IOException
100 */
101 public final void dump( DataOutputStream file ) throws IOException {
102 file.writeShort(start_pc);
103 file.writeShort(end_pc);
104 file.writeShort(handler_pc);
105 file.writeShort(catch_type);
106 }
107
108
109 /**
110 * @return 0, if the handler catches any exception, otherwise it points to
111 * the exception class which is to be caught.
112 */
113 public final int getCatchType() {
114 return catch_type;
115 }
116
117
118 /**
119 * @return Exclusive end index of the region where the handler is active.
120 */
121 public final int getEndPC() {
122 return end_pc;
123 }
124
125
126 /**
127 * @return Starting address of exception handler, relative to the code.
128 */
129 public final int getHandlerPC() {
130 return handler_pc;
131 }
132
133
134 /**
135 * @return Inclusive start index of the region where the handler is active.
136 */
137 public final int getStartPC() {
138 return start_pc;
139 }
140
141
142 /**
143 * @param catch_type the type of exception that is caught
144 */
145 public final void setCatchType( int catch_type ) {
146 this.catch_type = catch_type;
147 }
148
149
150 /**
151 * @param end_pc end of handled block
152 */
153 public final void setEndPC( int end_pc ) {
154 this.end_pc = end_pc;
155 }
156
157
158 /**
159 * @param handler_pc where the actual code is
160 */
161 public final void setHandlerPC( int handler_pc ) {
162 this.handler_pc = handler_pc;
163 }
164
165
166 /**
167 * @param start_pc start of handled block
168 */
169 public final void setStartPC( int start_pc ) {
170 this.start_pc = start_pc;
171 }
172
173
174 /**
175 * @return String representation.
176 */
177 public final String toString() {
178 return "CodeException(start_pc = " + start_pc + ", end_pc = " + end_pc + ", handler_pc = "
179 + handler_pc + ", catch_type = " + catch_type + ")";
180 }
181
182
183 /**
184 * @return String representation.
185 */
186 public final String toString( ConstantPool cp, boolean verbose ) {
187 String str;
188 if (catch_type == 0) {
189 str = "<Any exception>(0)";
190 } else {
191 str = Utility.compactClassName(cp.getConstantString(catch_type, CONSTANT_Class), false)
192 + (verbose ? "(" + catch_type + ")" : "");
193 }
194 return start_pc + "\t" + end_pc + "\t" + handler_pc + "\t" + str;
195 }
196
197
198 public final String toString( ConstantPool cp ) {
199 return toString(cp, true);
200 }
201
202
203 /**
204 * @return deep copy of this object
205 */
206 public CodeException copy() {
207 try {
208 return (CodeException) clone();
209 } catch (CloneNotSupportedException e) {
210 }
211 return null;
212 }
213 }
+0
-188
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/Constant.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 import java.io.DataInputStream;
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21 import java.io.Serializable;
22 import org.apache.bcel.Constants;
23 import org.apache.bcel.util.BCELComparator;
24
25 /**
26 * Abstract superclass for classes to represent the different constant types
27 * in the constant pool of a class file. The classes keep closely to
28 * the JVM specification.
29 *
30 * @version $Id: Constant.java 386056 2006-03-15 11:31:56Z tcurdt $
31 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
32 */
33 public abstract class Constant implements Cloneable, Node, Serializable {
34
35 private static BCELComparator _cmp = new BCELComparator() {
36
37 public boolean equals( Object o1, Object o2 ) {
38 Constant THIS = (Constant) o1;
39 Constant THAT = (Constant) o2;
40 return THIS.toString().equals(THAT.toString());
41 }
42
43
44 public int hashCode( Object o ) {
45 Constant THIS = (Constant) o;
46 return THIS.toString().hashCode();
47 }
48 };
49 /* In fact this tag is redundant since we can distinguish different
50 * `Constant' objects by their type, i.e., via `instanceof'. In some
51 * places we will use the tag for switch()es anyway.
52 *
53 * First, we want match the specification as closely as possible. Second we
54 * need the tag as an index to select the corresponding class name from the
55 * `CONSTANT_NAMES' array.
56 */
57 protected byte tag;
58
59
60 Constant(byte tag) {
61 this.tag = tag;
62 }
63
64
65 /**
66 * Called by objects that are traversing the nodes of the tree implicitely
67 * defined by the contents of a Java class. I.e., the hierarchy of methods,
68 * fields, attributes, etc. spawns a tree of objects.
69 *
70 * @param v Visitor object
71 */
72 public abstract void accept( Visitor v );
73
74
75 public abstract void dump( DataOutputStream file ) throws IOException;
76
77
78 /**
79 * @return Tag of constant, i.e., its type. No setTag() method to avoid
80 * confusion.
81 */
82 public final byte getTag() {
83 return tag;
84 }
85
86
87 /**
88 * @return String representation.
89 */
90 public String toString() {
91 return Constants.CONSTANT_NAMES[tag] + "[" + tag + "]";
92 }
93
94
95 /**
96 * @return deep copy of this constant
97 */
98 public Constant copy() {
99 try {
100 return (Constant) super.clone();
101 } catch (CloneNotSupportedException e) {
102 }
103 return null;
104 }
105
106
107 public Object clone() throws CloneNotSupportedException {
108 return super.clone();
109 }
110
111
112 /**
113 * Read one constant from the given file, the type depends on a tag byte.
114 *
115 * @param file Input stream
116 * @return Constant object
117 */
118 static final Constant readConstant( DataInputStream file ) throws IOException,
119 ClassFormatException {
120 byte b = file.readByte(); // Read tag byte
121 switch (b) {
122 case Constants.CONSTANT_Class:
123 return new ConstantClass(file);
124 case Constants.CONSTANT_Fieldref:
125 return new ConstantFieldref(file);
126 case Constants.CONSTANT_Methodref:
127 return new ConstantMethodref(file);
128 case Constants.CONSTANT_InterfaceMethodref:
129 return new ConstantInterfaceMethodref(file);
130 case Constants.CONSTANT_String:
131 return new ConstantString(file);
132 case Constants.CONSTANT_Integer:
133 return new ConstantInteger(file);
134 case Constants.CONSTANT_Float:
135 return new ConstantFloat(file);
136 case Constants.CONSTANT_Long:
137 return new ConstantLong(file);
138 case Constants.CONSTANT_Double:
139 return new ConstantDouble(file);
140 case Constants.CONSTANT_NameAndType:
141 return new ConstantNameAndType(file);
142 case Constants.CONSTANT_Utf8:
143 return ConstantUtf8.getInstance(file);
144 default:
145 throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
146 }
147 }
148
149
150 /**
151 * @return Comparison strategy object
152 */
153 public static BCELComparator getComparator() {
154 return _cmp;
155 }
156
157
158 /**
159 * @param comparator Comparison strategy object
160 */
161 public static void setComparator( BCELComparator comparator ) {
162 _cmp = comparator;
163 }
164
165
166 /**
167 * Return value as defined by given BCELComparator strategy.
168 * By default two Constant objects are said to be equal when
169 * the result of toString() is equal.
170 *
171 * @see java.lang.Object#equals(java.lang.Object)
172 */
173 public boolean equals( Object obj ) {
174 return _cmp.equals(this, obj);
175 }
176
177
178 /**
179 * Return value as defined by given BCELComparator strategy.
180 * By default return the hashcode of the result of toString().
181 *
182 * @see java.lang.Object#hashCode()
183 */
184 public int hashCode() {
185 return _cmp.hashCode(this);
186 }
187 }
+0
-131
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/ConstantCP.java less more
0 /*
1 * Copyright 2000-2004 The Apache Software Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16 package org.apache.bcel.classfile;
17
18 import java.io.DataInputStream;
19 import java.io.DataOutputStream;
20 import java.io.IOException;
21 import org.apache.bcel.Constants;
22
23 /**
24 * Abstract super class for Fieldref and Methodref constants.
25 *
26 * @version $Id: ConstantCP.java 386056 2006-03-15 11:31:56Z tcurdt $
27 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
28 * @see ConstantFieldref
29 * @see ConstantMethodref
30 * @see ConstantInterfaceMethodref
31 */
32 public abstract class ConstantCP extends Constant {
33
34 /** References to the constants containing the class and the field signature
35 */
36 protected int class_index, name_and_type_index;
37
38
39 /**
40 * Initialize from another object.
41 */
42 public ConstantCP(ConstantCP c) {
43 this(c.getTag(), c.getClassIndex(), c.getNameAndTypeIndex());
44 }
45
46
47 /**
48 * Initialize instance from file data.
49 *
50 * @param tag Constant type tag
51 * @param file Input stream
52 * @throws IOException
53 */
54 ConstantCP(byte tag, DataInputStream file) throws IOException {
55 this(tag, file.readUnsignedShort(), file.readUnsignedShort());
56 }
57
58
59 /**
60 * @param class_index Reference to the class containing the field
61 * @param name_and_type_index and the field signature
62 */
63 protected ConstantCP(byte tag, int class_index, int name_and_type_index) {
64 super(tag);
65 this.class_index = class_index;
66 this.name_and_type_index = name_and_type_index;
67 }
68
69
70 /**
71 * Dump constant field reference to file stream in binary format.
72 *
73 * @param file Output file stream
74 * @throws IOException
75 */
76 public final void dump( DataOutputStream file ) throws IOException {
77 file.writeByte(tag);
78 file.writeShort(class_index);
79 file.writeShort(name_and_type_index);
80 }
81
82
83 /**
84 * @return Reference (index) to class this field or method belongs to.
85 */
86 public final int getClassIndex() {
87 return class_index;
88 }
89
90
91 /**
92 * @return Reference (index) to signature of the field.
93 */
94 public final int getNameAndTypeIndex() {
95 return name_and_type_index;
96 }
97
98
99 /**
100 * @param class_index points to Constant_class
101 */
102 public final void setClassIndex( int class_index ) {
103 this.class_index = class_index;
104 }
105
106
107 /**
108 * @return Class this field belongs to.
109 */
110 public String getClass( ConstantPool cp ) {
111 return cp.constantToString(class_index, Constants.CONSTANT_Class);
112 }
113
114
115 /**
116 * @param name_and_type_index points to Constant_NameAndType
117 */
118 public final void setNameAndTypeIndex( int name_and_type_index ) {
119 this.name_and_type_index = name_and_type_index;
120 }
121
122
123 /**
124 * @return String representation.
125 */
126 public final String toString() {
127 return super.toString() + "(class_index = " + class_index + ", name_and_type_index = "
128 + name_and_type_index + ")";
129 }
130 }
+0
-128
build/bcel-5.2-src/bcel-5.2/src/java/org/apache/bcel/classfile/ConstantClass.java less more
0 /*
1