1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/javap/src/main/java/sun/tools/javap/ClassData.java Fri Nov 09 21:33:22 2012 +0100
1.3 @@ -0,0 +1,663 @@
1.4 +/*
1.5 + * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1.7 + *
1.8 + * This code is free software; you can redistribute it and/or modify it
1.9 + * under the terms of the GNU General Public License version 2 only, as
1.10 + * published by the Free Software Foundation. Oracle designates this
1.11 + * particular file as subject to the "Classpath" exception as provided
1.12 + * by Oracle in the LICENSE file that accompanied this code.
1.13 + *
1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1.17 + * version 2 for more details (a copy is included in the LICENSE file that
1.18 + * accompanied this code).
1.19 + *
1.20 + * You should have received a copy of the GNU General Public License version
1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1.23 + *
1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1.25 + * or visit www.oracle.com if you need additional information or have any
1.26 + * questions.
1.27 + */
1.28 +
1.29 +
1.30 +package sun.tools.javap;
1.31 +
1.32 +import java.util.*;
1.33 +import java.io.*;
1.34 +
1.35 +/**
1.36 + * Central data repository of the Java Disassembler.
1.37 + * Stores all the information in java class file.
1.38 + *
1.39 + * @author Sucheta Dambalkar (Adopted code from jdis)
1.40 + */
1.41 +public class ClassData implements RuntimeConstants {
1.42 +
1.43 + private int magic;
1.44 + private int minor_version;
1.45 + private int major_version;
1.46 + private int cpool_count;
1.47 + private Object cpool[];
1.48 + private int access;
1.49 + private int this_class = 0;;
1.50 + private int super_class;
1.51 + private int interfaces_count;
1.52 + private int[] interfaces = new int[0];;
1.53 + private int fields_count;
1.54 + private FieldData[] fields;
1.55 + private int methods_count;
1.56 + private MethodData[] methods;
1.57 + private InnerClassData[] innerClasses;
1.58 + private int attributes_count;
1.59 + private AttrData[] attrs;
1.60 + private String classname;
1.61 + private String superclassname;
1.62 + private int source_cpx=0;
1.63 + private byte tags[];
1.64 + private Hashtable indexHashAscii = new Hashtable();
1.65 + private String pkgPrefix="";
1.66 + private int pkgPrefixLen=0;
1.67 +
1.68 + /**
1.69 + * Read classfile to disassemble.
1.70 + */
1.71 + public ClassData(InputStream infile){
1.72 + try{
1.73 + this.read(new DataInputStream(infile));
1.74 + }catch (FileNotFoundException ee) {
1.75 + error("cant read file");
1.76 + }catch (Error ee) {
1.77 + ee.printStackTrace();
1.78 + error("fatal error");
1.79 + } catch (Exception ee) {
1.80 + ee.printStackTrace();
1.81 + error("fatal exception");
1.82 + }
1.83 + }
1.84 +
1.85 + /**
1.86 + * Reads and stores class file information.
1.87 + */
1.88 + public void read(DataInputStream in) throws IOException {
1.89 + // Read the header
1.90 + magic = in.readInt();
1.91 + if (magic != JAVA_MAGIC) {
1.92 + throw new ClassFormatError("wrong magic: " +
1.93 + toHex(magic) + ", expected " +
1.94 + toHex(JAVA_MAGIC));
1.95 + }
1.96 + minor_version = in.readShort();
1.97 + major_version = in.readShort();
1.98 + if (major_version != JAVA_VERSION) {
1.99 + }
1.100 +
1.101 + // Read the constant pool
1.102 + readCP(in);
1.103 + access = in.readUnsignedShort();
1.104 + this_class = in.readUnsignedShort();
1.105 + super_class = in.readUnsignedShort();
1.106 +
1.107 + //Read interfaces.
1.108 + interfaces_count = in.readUnsignedShort();
1.109 + if(interfaces_count > 0){
1.110 + interfaces = new int[interfaces_count];
1.111 + }
1.112 + for (int i = 0; i < interfaces_count; i++) {
1.113 + interfaces[i]=in.readShort();
1.114 + }
1.115 +
1.116 + // Read the fields
1.117 + readFields(in);
1.118 +
1.119 + // Read the methods
1.120 + readMethods(in);
1.121 +
1.122 + // Read the attributes
1.123 + attributes_count = in.readUnsignedShort();
1.124 + attrs=new AttrData[attributes_count];
1.125 + for (int k = 0; k < attributes_count; k++) {
1.126 + int name_cpx=in.readUnsignedShort();
1.127 + if (getTag(name_cpx)==CONSTANT_UTF8
1.128 + && getString(name_cpx).equals("SourceFile")
1.129 + ){ if (in.readInt()!=2)
1.130 + throw new ClassFormatError("invalid attr length");
1.131 + source_cpx=in.readUnsignedShort();
1.132 + AttrData attr=new AttrData(this);
1.133 + attr.read(name_cpx);
1.134 + attrs[k]=attr;
1.135 +
1.136 + } else if (getTag(name_cpx)==CONSTANT_UTF8
1.137 + && getString(name_cpx).equals("InnerClasses")
1.138 + ){ int length=in.readInt();
1.139 + int num=in.readUnsignedShort();
1.140 + if (2+num*8 != length)
1.141 + throw new ClassFormatError("invalid attr length");
1.142 + innerClasses=new InnerClassData[num];
1.143 + for (int j = 0; j < num; j++) {
1.144 + InnerClassData innerClass=new InnerClassData(this);
1.145 + innerClass.read(in);
1.146 + innerClasses[j]=innerClass;
1.147 + }
1.148 + AttrData attr=new AttrData(this);
1.149 + attr.read(name_cpx);
1.150 + attrs[k]=attr;
1.151 + } else {
1.152 + AttrData attr=new AttrData(this);
1.153 + attr.read(name_cpx, in);
1.154 + attrs[k]=attr;
1.155 + }
1.156 + }
1.157 + in.close();
1.158 + } // end ClassData.read()
1.159 +
1.160 + /**
1.161 + * Reads and stores constant pool info.
1.162 + */
1.163 + void readCP(DataInputStream in) throws IOException {
1.164 + cpool_count = in.readUnsignedShort();
1.165 + tags = new byte[cpool_count];
1.166 + cpool = new Object[cpool_count];
1.167 + for (int i = 1; i < cpool_count; i++) {
1.168 + byte tag = in.readByte();
1.169 +
1.170 + switch(tags[i] = tag) {
1.171 + case CONSTANT_UTF8:
1.172 + String str=in.readUTF();
1.173 + indexHashAscii.put(cpool[i] = str, new Integer(i));
1.174 + break;
1.175 + case CONSTANT_INTEGER:
1.176 + cpool[i] = new Integer(in.readInt());
1.177 + break;
1.178 + case CONSTANT_FLOAT:
1.179 + cpool[i] = new Float(in.readFloat());
1.180 + break;
1.181 + case CONSTANT_LONG:
1.182 + cpool[i++] = new Long(in.readLong());
1.183 + break;
1.184 + case CONSTANT_DOUBLE:
1.185 + cpool[i++] = new Double(in.readDouble());
1.186 + break;
1.187 + case CONSTANT_CLASS:
1.188 + case CONSTANT_STRING:
1.189 + cpool[i] = new CPX(in.readUnsignedShort());
1.190 + break;
1.191 +
1.192 + case CONSTANT_FIELD:
1.193 + case CONSTANT_METHOD:
1.194 + case CONSTANT_INTERFACEMETHOD:
1.195 + case CONSTANT_NAMEANDTYPE:
1.196 + cpool[i] = new CPX2(in.readUnsignedShort(), in.readUnsignedShort());
1.197 + break;
1.198 +
1.199 + case 0:
1.200 + default:
1.201 + throw new ClassFormatError("invalid constant type: " + (int)tags[i]);
1.202 + }
1.203 + }
1.204 + }
1.205 +
1.206 + /**
1.207 + * Reads and strores field info.
1.208 + */
1.209 + protected void readFields(DataInputStream in) throws IOException {
1.210 + int fields_count = in.readUnsignedShort();
1.211 + fields=new FieldData[fields_count];
1.212 + for (int k = 0; k < fields_count; k++) {
1.213 + FieldData field=new FieldData(this);
1.214 + field.read(in);
1.215 + fields[k]=field;
1.216 + }
1.217 + }
1.218 +
1.219 + /**
1.220 + * Reads and strores Method info.
1.221 + */
1.222 + protected void readMethods(DataInputStream in) throws IOException {
1.223 + int methods_count = in.readUnsignedShort();
1.224 + methods=new MethodData[methods_count];
1.225 + for (int k = 0; k < methods_count ; k++) {
1.226 + MethodData method=new MethodData(this);
1.227 + method.read(in);
1.228 + methods[k]=method;
1.229 + }
1.230 + }
1.231 +
1.232 + /**
1.233 + * get a string
1.234 + */
1.235 + public String getString(int n) {
1.236 + return (n == 0) ? null : (String)cpool[n];
1.237 + }
1.238 +
1.239 + /**
1.240 + * get the type of constant given an index
1.241 + */
1.242 + public byte getTag(int n) {
1.243 + try{
1.244 + return tags[n];
1.245 + } catch (ArrayIndexOutOfBoundsException e) {
1.246 + return (byte)100;
1.247 + }
1.248 + }
1.249 +
1.250 + static final String hexString="0123456789ABCDEF";
1.251 +
1.252 + public static char hexTable[]=hexString.toCharArray();
1.253 +
1.254 + static String toHex(long val, int width) {
1.255 + StringBuffer s = new StringBuffer();
1.256 + for (int i=width-1; i>=0; i--)
1.257 + s.append(hexTable[((int)(val>>(4*i)))&0xF]);
1.258 + return "0x"+s.toString();
1.259 + }
1.260 +
1.261 + static String toHex(long val) {
1.262 + int width;
1.263 + for (width=16; width>0; width--) {
1.264 + if ((val>>(width-1)*4)!=0) break;
1.265 + }
1.266 + return toHex(val, width);
1.267 + }
1.268 +
1.269 + static String toHex(int val) {
1.270 + int width;
1.271 + for (width=8; width>0; width--) {
1.272 + if ((val>>(width-1)*4)!=0) break;
1.273 + }
1.274 + return toHex(val, width);
1.275 + }
1.276 +
1.277 + public void error(String msg) {
1.278 + System.err.println("ERROR:" +msg);
1.279 + }
1.280 +
1.281 + /**
1.282 + * Returns the name of this class.
1.283 + */
1.284 + public String getClassName() {
1.285 + String res=null;
1.286 + if (this_class==0) {
1.287 + return res;
1.288 + }
1.289 + int tcpx;
1.290 + try {
1.291 + if (tags[this_class]!=CONSTANT_CLASS) {
1.292 + return res; //"<CP["+cpx+"] is not a Class> ";
1.293 + }
1.294 + tcpx=((CPX)cpool[this_class]).cpx;
1.295 + } catch (ArrayIndexOutOfBoundsException e) {
1.296 + return res; // "#"+cpx+"// invalid constant pool index";
1.297 + } catch (Throwable e) {
1.298 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
1.299 + }
1.300 +
1.301 + try {
1.302 + return (String)(cpool[tcpx]);
1.303 + } catch (ArrayIndexOutOfBoundsException e) {
1.304 + return res; // "class #"+scpx+"// invalid constant pool index";
1.305 + } catch (ClassCastException e) {
1.306 + return res; // "class #"+scpx+"// invalid constant pool reference";
1.307 + } catch (Throwable e) {
1.308 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
1.309 + }
1.310 +
1.311 + }
1.312 +
1.313 + /**
1.314 + * Returns the name of class at perticular index.
1.315 + */
1.316 + public String getClassName(int cpx) {
1.317 + String res="#"+cpx;
1.318 + if (cpx==0) {
1.319 + return res;
1.320 + }
1.321 + int scpx;
1.322 + try {
1.323 + if (tags[cpx]!=CONSTANT_CLASS) {
1.324 + return res; //"<CP["+cpx+"] is not a Class> ";
1.325 + }
1.326 + scpx=((CPX)cpool[cpx]).cpx;
1.327 + } catch (ArrayIndexOutOfBoundsException e) {
1.328 + return res; // "#"+cpx+"// invalid constant pool index";
1.329 + } catch (Throwable e) {
1.330 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
1.331 + }
1.332 + res="#"+scpx;
1.333 + try {
1.334 + return (String)(cpool[scpx]);
1.335 + } catch (ArrayIndexOutOfBoundsException e) {
1.336 + return res; // "class #"+scpx+"// invalid constant pool index";
1.337 + } catch (ClassCastException e) {
1.338 + return res; // "class #"+scpx+"// invalid constant pool reference";
1.339 + } catch (Throwable e) {
1.340 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
1.341 + }
1.342 + }
1.343 +
1.344 + /**
1.345 + * Returns true if it is a class
1.346 + */
1.347 + public boolean isClass() {
1.348 + if((access & ACC_INTERFACE) == 0) return true;
1.349 + return false;
1.350 + }
1.351 +
1.352 + /**
1.353 + * Returns true if it is a interface.
1.354 + */
1.355 + public boolean isInterface(){
1.356 + if((access & ACC_INTERFACE) != 0) return true;
1.357 + return false;
1.358 + }
1.359 +
1.360 + /**
1.361 + * Returns true if this member is public, false otherwise.
1.362 + */
1.363 + public boolean isPublic(){
1.364 + return (access & ACC_PUBLIC) != 0;
1.365 + }
1.366 +
1.367 + /**
1.368 + * Returns the access of this class or interface.
1.369 + */
1.370 + public String[] getAccess(){
1.371 + Vector v = new Vector();
1.372 + if ((access & ACC_PUBLIC) !=0) v.addElement("public");
1.373 + if ((access & ACC_FINAL) !=0) v.addElement("final");
1.374 + if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract");
1.375 + String[] accflags = new String[v.size()];
1.376 + v.copyInto(accflags);
1.377 + return accflags;
1.378 + }
1.379 +
1.380 + /**
1.381 + * Returns list of innerclasses.
1.382 + */
1.383 + public InnerClassData[] getInnerClasses(){
1.384 + return innerClasses;
1.385 + }
1.386 +
1.387 + /**
1.388 + * Returns list of attributes.
1.389 + */
1.390 + public AttrData[] getAttributes(){
1.391 + return attrs;
1.392 + }
1.393 +
1.394 + /**
1.395 + * Returns true if superbit is set.
1.396 + */
1.397 + public boolean isSuperSet(){
1.398 + if ((access & ACC_SUPER) !=0) return true;
1.399 + return false;
1.400 + }
1.401 +
1.402 + /**
1.403 + * Returns super class name.
1.404 + */
1.405 + public String getSuperClassName(){
1.406 + String res=null;
1.407 + if (super_class==0) {
1.408 + return res;
1.409 + }
1.410 + int scpx;
1.411 + try {
1.412 + if (tags[super_class]!=CONSTANT_CLASS) {
1.413 + return res; //"<CP["+cpx+"] is not a Class> ";
1.414 + }
1.415 + scpx=((CPX)cpool[super_class]).cpx;
1.416 + } catch (ArrayIndexOutOfBoundsException e) {
1.417 + return res; // "#"+cpx+"// invalid constant pool index";
1.418 + } catch (Throwable e) {
1.419 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
1.420 + }
1.421 +
1.422 + try {
1.423 + return (String)(cpool[scpx]);
1.424 + } catch (ArrayIndexOutOfBoundsException e) {
1.425 + return res; // "class #"+scpx+"// invalid constant pool index";
1.426 + } catch (ClassCastException e) {
1.427 + return res; // "class #"+scpx+"// invalid constant pool reference";
1.428 + } catch (Throwable e) {
1.429 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
1.430 + }
1.431 + }
1.432 +
1.433 + /**
1.434 + * Returns list of super interfaces.
1.435 + */
1.436 + public String[] getSuperInterfaces(){
1.437 + String interfacenames[] = new String[interfaces.length];
1.438 + int interfacecpx = -1;
1.439 + for(int i = 0; i < interfaces.length; i++){
1.440 + interfacecpx=((CPX)cpool[interfaces[i]]).cpx;
1.441 + interfacenames[i] = (String)(cpool[interfacecpx]);
1.442 + }
1.443 + return interfacenames;
1.444 + }
1.445 +
1.446 + /**
1.447 + * Returns string at prticular constant pool index.
1.448 + */
1.449 + public String getStringValue(int cpoolx) {
1.450 + try {
1.451 + return ((String)cpool[cpoolx]);
1.452 + } catch (ArrayIndexOutOfBoundsException e) {
1.453 + return "//invalid constant pool index:"+cpoolx;
1.454 + } catch (ClassCastException e) {
1.455 + return "//invalid constant pool ref:"+cpoolx;
1.456 + }
1.457 + }
1.458 +
1.459 + /**
1.460 + * Returns list of field info.
1.461 + */
1.462 + public FieldData[] getFields(){
1.463 + return fields;
1.464 + }
1.465 +
1.466 + /**
1.467 + * Returns list of method info.
1.468 + */
1.469 + public MethodData[] getMethods(){
1.470 + return methods;
1.471 + }
1.472 +
1.473 + /**
1.474 + * Returns constant pool entry at that index.
1.475 + */
1.476 + public CPX2 getCpoolEntry(int cpx){
1.477 + return ((CPX2)(cpool[cpx]));
1.478 + }
1.479 +
1.480 + public Object getCpoolEntryobj(int cpx){
1.481 + return (cpool[cpx]);
1.482 + }
1.483 +
1.484 + /**
1.485 + * Returns index of this class.
1.486 + */
1.487 + public int getthis_cpx(){
1.488 + return this_class;
1.489 + }
1.490 +
1.491 + public String TagString (int tag) {
1.492 + String res=Tables.tagName(tag);
1.493 + if (res==null) return "BOGUS_TAG:"+tag;
1.494 + return res;
1.495 + }
1.496 +
1.497 + /**
1.498 + * Returns string at that index.
1.499 + */
1.500 + public String StringValue(int cpx) {
1.501 + if (cpx==0) return "#0";
1.502 + int tag;
1.503 + Object x;
1.504 + String suffix="";
1.505 + try {
1.506 + tag=tags[cpx];
1.507 + x=cpool[cpx];
1.508 + } catch (IndexOutOfBoundsException e) {
1.509 + return "<Incorrect CP index:"+cpx+">";
1.510 + }
1.511 +
1.512 + if (x==null) return "<NULL>";
1.513 + switch (tag) {
1.514 + case CONSTANT_UTF8: {
1.515 + StringBuffer sb=new StringBuffer();
1.516 + String s=(String)x;
1.517 + for (int k=0; k<s.length(); k++) {
1.518 + char c=s.charAt(k);
1.519 + switch (c) {
1.520 + case '\t': sb.append('\\').append('t'); break;
1.521 + case '\n': sb.append('\\').append('n'); break;
1.522 + case '\r': sb.append('\\').append('r'); break;
1.523 + case '\"': sb.append('\\').append('\"'); break;
1.524 + default: sb.append(c);
1.525 + }
1.526 + }
1.527 + return sb.toString();
1.528 + }
1.529 + case CONSTANT_DOUBLE: {
1.530 + Double d=(Double)x;
1.531 + String sd=d.toString();
1.532 + return sd+"d";
1.533 + }
1.534 + case CONSTANT_FLOAT: {
1.535 + Float f=(Float)x;
1.536 + String sf=(f).toString();
1.537 + return sf+"f";
1.538 + }
1.539 + case CONSTANT_LONG: {
1.540 + Long ln = (Long)x;
1.541 + return ln.toString()+'l';
1.542 + }
1.543 + case CONSTANT_INTEGER: {
1.544 + Integer in = (Integer)x;
1.545 + return in.toString();
1.546 + }
1.547 + case CONSTANT_CLASS:
1.548 + return javaName(getClassName(cpx));
1.549 + case CONSTANT_STRING:
1.550 + return StringValue(((CPX)x).cpx);
1.551 + case CONSTANT_FIELD:
1.552 + case CONSTANT_METHOD:
1.553 + case CONSTANT_INTERFACEMETHOD:
1.554 + //return getShortClassName(((CPX2)x).cpx1)+"."+StringValue(((CPX2)x).cpx2);
1.555 + return javaName(getClassName(((CPX2)x).cpx1))+"."+StringValue(((CPX2)x).cpx2);
1.556 +
1.557 + case CONSTANT_NAMEANDTYPE:
1.558 + return getName(((CPX2)x).cpx1)+":"+StringValue(((CPX2)x).cpx2);
1.559 + default:
1.560 + return "UnknownTag"; //TBD
1.561 + }
1.562 + }
1.563 +
1.564 + /**
1.565 + * Returns resolved java type name.
1.566 + */
1.567 + public String javaName(String name) {
1.568 + if( name==null) return "null";
1.569 + int len=name.length();
1.570 + if (len==0) return "\"\"";
1.571 + int cc='/';
1.572 + fullname: { // xxx/yyy/zzz
1.573 + int cp;
1.574 + for (int k=0; k<len; k += Character.charCount(cp)) {
1.575 + cp=name.codePointAt(k);
1.576 + if (cc=='/') {
1.577 + if (!Character.isJavaIdentifierStart(cp)) break fullname;
1.578 + } else if (cp!='/') {
1.579 + if (!Character.isJavaIdentifierPart(cp)) break fullname;
1.580 + }
1.581 + cc=cp;
1.582 + }
1.583 + return name;
1.584 + }
1.585 + return "\""+name+"\"";
1.586 + }
1.587 +
1.588 + public String getName(int cpx) {
1.589 + String res;
1.590 + try {
1.591 + return javaName((String)cpool[cpx]); //.replace('/','.');
1.592 + } catch (ArrayIndexOutOfBoundsException e) {
1.593 + return "<invalid constant pool index:"+cpx+">";
1.594 + } catch (ClassCastException e) {
1.595 + return "<invalid constant pool ref:"+cpx+">";
1.596 + }
1.597 + }
1.598 +
1.599 + /**
1.600 + * Returns unqualified class name.
1.601 + */
1.602 + public String getShortClassName(int cpx) {
1.603 + String classname=javaName(getClassName(cpx));
1.604 + pkgPrefixLen=classname.lastIndexOf("/")+1;
1.605 + if (pkgPrefixLen!=0) {
1.606 + pkgPrefix=classname.substring(0,pkgPrefixLen);
1.607 + if (classname.startsWith(pkgPrefix)) {
1.608 + return classname.substring(pkgPrefixLen);
1.609 + }
1.610 + }
1.611 + return classname;
1.612 + }
1.613 +
1.614 + /**
1.615 + * Returns source file name.
1.616 + */
1.617 + public String getSourceName(){
1.618 + return getName(source_cpx);
1.619 + }
1.620 +
1.621 + /**
1.622 + * Returns package name.
1.623 + */
1.624 + public String getPkgName(){
1.625 + String classname=getClassName(this_class);
1.626 + pkgPrefixLen=classname.lastIndexOf("/")+1;
1.627 + if (pkgPrefixLen!=0) {
1.628 + pkgPrefix=classname.substring(0,pkgPrefixLen);
1.629 + return("package "+pkgPrefix.substring(0,pkgPrefixLen-1)+";\n");
1.630 + }else return null;
1.631 + }
1.632 +
1.633 + /**
1.634 + * Returns total constant pool entry count.
1.635 + */
1.636 + public int getCpoolCount(){
1.637 + return cpool_count;
1.638 + }
1.639 +
1.640 + public String StringTag(int cpx) {
1.641 + byte tag=0;
1.642 + String str=null;
1.643 + try {
1.644 + if (cpx==0) throw new IndexOutOfBoundsException();
1.645 + tag=tags[cpx];
1.646 + return TagString(tag);
1.647 + } catch (IndexOutOfBoundsException e) {
1.648 + str="Incorrect CP index:"+cpx;
1.649 + }
1.650 + return str;
1.651 + }
1.652 +
1.653 + /**
1.654 + * Returns minor version of class file.
1.655 + */
1.656 + public int getMinor_version(){
1.657 + return minor_version;
1.658 + }
1.659 +
1.660 + /**
1.661 + * Returns major version of class file.
1.662 + */
1.663 + public int getMajor_version(){
1.664 + return major_version;
1.665 + }
1.666 +}