Fri, 29 May 2009 16:26:41 -0700
6838199: remove support for old javap
Reviewed-by: ohair, mcimadamore
1.1 --- a/make/build.xml Thu May 28 09:49:56 2009 -0700 1.2 +++ b/make/build.xml Fri May 29 16:26:41 2009 -0700 1.3 @@ -308,7 +308,7 @@ 1.4 <target name="build-javap" depends="build-javac"> 1.5 <build-tool name="javap" 1.6 includes="${javap.includes}" 1.7 - jarmainclass="sun.tools.javap.Main" 1.8 + jarmainclass="com.sun.tools.javap.Main" 1.9 jarclasspath="javac.jar"/> 1.10 </target> 1.11
2.1 --- a/src/share/classes/com/sun/tools/javap/JavapTask.java Thu May 28 09:49:56 2009 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javap/JavapTask.java Fri May 29 16:26:41 2009 -0700 2.3 @@ -212,9 +212,7 @@ 2.4 2.5 new Option(false, "-Xold") { 2.6 void process(JavapTask task, String opt, String arg) throws BadArgs { 2.7 - // -Xold is only supported as first arg when invoked from 2.8 - // command line; this is handled in Main,main 2.9 - throw task.new BadArgs("err.Xold.not.supported.here"); 2.10 + task.log.println(task.getMessage("warn.Xold.not.supported")); 2.11 } 2.12 }, 2.13
3.1 --- a/src/share/classes/com/sun/tools/javap/Main.java Thu May 28 09:49:56 2009 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javap/Main.java Fri May 29 16:26:41 2009 -0700 3.3 @@ -42,13 +42,6 @@ 3.4 * @param args command line arguments 3.5 */ 3.6 public static void main(String[] args) { 3.7 - if (args.length >= 1 && args[0].equals("-Xold")) { 3.8 - String[] nArgs = new String[args.length - 1]; 3.9 - System.arraycopy(args, 1, nArgs, 0, nArgs.length); 3.10 - sun.tools.javap.Main.main(args); // calls System.exit 3.11 - System.exit(1); 3.12 - } 3.13 - 3.14 JavapTask t = new JavapTask(); 3.15 int rc = t.run(args); 3.16 System.exit(rc);
4.1 --- a/src/share/classes/com/sun/tools/javap/resources/javap.properties Thu May 28 09:49:56 2009 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javap/resources/javap.properties Fri May 29 16:26:41 2009 -0700 4.3 @@ -16,9 +16,9 @@ 4.4 err.not.standard.file.manager=can only specify class files when using a standard file manager 4.5 err.unknown.option=unknown option: {0} 4.6 err.verify.not.supported=-verify not supported 4.7 -err.Xold.not.supported.here=-Xold must be given as the first option 4.8 err.no.SourceFile.attribute=no SourceFile attribute 4.9 err.source.file.not.found=source file not found 4.10 +warn.Xold.not.supported=-Xold is no longer available 4.11 4.12 main.usage.summary=\ 4.13 Usage: {0} <options> <classes>\n\
5.1 --- a/src/share/classes/sun/tools/javap/AttrData.java Thu May 28 09:49:56 2009 -0700 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,77 +0,0 @@ 5.4 -/* 5.5 - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 5.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 - * 5.8 - * This code is free software; you can redistribute it and/or modify it 5.9 - * under the terms of the GNU General Public License version 2 only, as 5.10 - * published by the Free Software Foundation. Sun designates this 5.11 - * particular file as subject to the "Classpath" exception as provided 5.12 - * by Sun in the LICENSE file that accompanied this code. 5.13 - * 5.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 5.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.17 - * version 2 for more details (a copy is included in the LICENSE file that 5.18 - * accompanied this code). 5.19 - * 5.20 - * You should have received a copy of the GNU General Public License version 5.21 - * 2 along with this work; if not, write to the Free Software Foundation, 5.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.23 - * 5.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 5.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 5.26 - * have any questions. 5.27 - */ 5.28 - 5.29 - 5.30 - 5.31 -package sun.tools.javap; 5.32 - 5.33 -import java.io.*; 5.34 - 5.35 -/** 5.36 - * Reads and stores attribute information. 5.37 - * 5.38 - * @author Sucheta Dambalkar (Adopted code from jdis) 5.39 - */ 5.40 -class AttrData { 5.41 - ClassData cls; 5.42 - int name_cpx; 5.43 - int datalen; 5.44 - byte data[]; 5.45 - 5.46 - public AttrData (ClassData cls) { 5.47 - this.cls=cls; 5.48 - } 5.49 - 5.50 - /** 5.51 - * Reads unknown attribute. 5.52 - */ 5.53 - public void read(int name_cpx, DataInputStream in) throws IOException { 5.54 - this.name_cpx=name_cpx; 5.55 - datalen=in.readInt(); 5.56 - data=new byte[datalen]; 5.57 - in.readFully(data); 5.58 - } 5.59 - 5.60 - /** 5.61 - * Reads just the name of known attribute. 5.62 - */ 5.63 - public void read(int name_cpx){ 5.64 - this.name_cpx=name_cpx; 5.65 - } 5.66 - 5.67 - /** 5.68 - * Returns attribute name. 5.69 - */ 5.70 - public String getAttrName(){ 5.71 - return cls.getString(name_cpx); 5.72 - } 5.73 - 5.74 - /** 5.75 - * Returns attribute data. 5.76 - */ 5.77 - public byte[] getData(){ 5.78 - return data; 5.79 - } 5.80 -}
6.1 --- a/src/share/classes/sun/tools/javap/CPX.java Thu May 28 09:49:56 2009 -0700 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,40 +0,0 @@ 6.4 -/* 6.5 - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 6.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 - * 6.8 - * This code is free software; you can redistribute it and/or modify it 6.9 - * under the terms of the GNU General Public License version 2 only, as 6.10 - * published by the Free Software Foundation. Sun designates this 6.11 - * particular file as subject to the "Classpath" exception as provided 6.12 - * by Sun in the LICENSE file that accompanied this code. 6.13 - * 6.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 6.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.17 - * version 2 for more details (a copy is included in the LICENSE file that 6.18 - * accompanied this code). 6.19 - * 6.20 - * You should have received a copy of the GNU General Public License version 6.21 - * 2 along with this work; if not, write to the Free Software Foundation, 6.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.23 - * 6.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 6.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 6.26 - * have any questions. 6.27 - */ 6.28 - 6.29 - 6.30 -package sun.tools.javap; 6.31 - 6.32 -/** 6.33 - * Stores constant pool entry information with one field. 6.34 - * 6.35 - * @author Sucheta Dambalkar (Adopted code from jdis) 6.36 - */ 6.37 -class CPX { 6.38 - int cpx; 6.39 - 6.40 - CPX (int cpx) { 6.41 - this.cpx=cpx; 6.42 - } 6.43 -}
7.1 --- a/src/share/classes/sun/tools/javap/CPX2.java Thu May 28 09:49:56 2009 -0700 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,41 +0,0 @@ 7.4 -/* 7.5 - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 7.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 - * 7.8 - * This code is free software; you can redistribute it and/or modify it 7.9 - * under the terms of the GNU General Public License version 2 only, as 7.10 - * published by the Free Software Foundation. Sun designates this 7.11 - * particular file as subject to the "Classpath" exception as provided 7.12 - * by Sun in the LICENSE file that accompanied this code. 7.13 - * 7.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 7.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.17 - * version 2 for more details (a copy is included in the LICENSE file that 7.18 - * accompanied this code). 7.19 - * 7.20 - * You should have received a copy of the GNU General Public License version 7.21 - * 2 along with this work; if not, write to the Free Software Foundation, 7.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.23 - * 7.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 7.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 7.26 - * have any questions. 7.27 - */ 7.28 - 7.29 - 7.30 -package sun.tools.javap; 7.31 - 7.32 -/** 7.33 - * Stores constant pool entry information with two fields. 7.34 - * 7.35 - * @author Sucheta Dambalkar (Adopted code from jdis) 7.36 - */ 7.37 -class CPX2 { 7.38 - int cpx1,cpx2; 7.39 - 7.40 - CPX2 (int cpx1, int cpx2) { 7.41 - this.cpx1=cpx1; 7.42 - this.cpx2=cpx2; 7.43 - } 7.44 -}
8.1 --- a/src/share/classes/sun/tools/javap/ClassData.java Thu May 28 09:49:56 2009 -0700 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,663 +0,0 @@ 8.4 -/* 8.5 - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. 8.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 - * 8.8 - * This code is free software; you can redistribute it and/or modify it 8.9 - * under the terms of the GNU General Public License version 2 only, as 8.10 - * published by the Free Software Foundation. Sun designates this 8.11 - * particular file as subject to the "Classpath" exception as provided 8.12 - * by Sun in the LICENSE file that accompanied this code. 8.13 - * 8.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 8.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.17 - * version 2 for more details (a copy is included in the LICENSE file that 8.18 - * accompanied this code). 8.19 - * 8.20 - * You should have received a copy of the GNU General Public License version 8.21 - * 2 along with this work; if not, write to the Free Software Foundation, 8.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.23 - * 8.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 8.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 8.26 - * have any questions. 8.27 - */ 8.28 - 8.29 - 8.30 -package sun.tools.javap; 8.31 - 8.32 -import java.util.*; 8.33 -import java.io.*; 8.34 - 8.35 -/** 8.36 - * Central data repository of the Java Disassembler. 8.37 - * Stores all the information in java class file. 8.38 - * 8.39 - * @author Sucheta Dambalkar (Adopted code from jdis) 8.40 - */ 8.41 -public class ClassData implements RuntimeConstants { 8.42 - 8.43 - private int magic; 8.44 - private int minor_version; 8.45 - private int major_version; 8.46 - private int cpool_count; 8.47 - private Object cpool[]; 8.48 - private int access; 8.49 - private int this_class = 0;; 8.50 - private int super_class; 8.51 - private int interfaces_count; 8.52 - private int[] interfaces = new int[0];; 8.53 - private int fields_count; 8.54 - private FieldData[] fields; 8.55 - private int methods_count; 8.56 - private MethodData[] methods; 8.57 - private InnerClassData[] innerClasses; 8.58 - private int attributes_count; 8.59 - private AttrData[] attrs; 8.60 - private String classname; 8.61 - private String superclassname; 8.62 - private int source_cpx=0; 8.63 - private byte tags[]; 8.64 - private Hashtable<Object,Integer> indexHashAscii = new Hashtable<Object,Integer>(); 8.65 - private String pkgPrefix=""; 8.66 - private int pkgPrefixLen=0; 8.67 - 8.68 - /** 8.69 - * Read classfile to disassemble. 8.70 - */ 8.71 - public ClassData(InputStream infile){ 8.72 - try{ 8.73 - this.read(new DataInputStream(infile)); 8.74 - }catch (FileNotFoundException ee) { 8.75 - error("cant read file"); 8.76 - }catch (Error ee) { 8.77 - ee.printStackTrace(); 8.78 - error("fatal error"); 8.79 - } catch (Exception ee) { 8.80 - ee.printStackTrace(); 8.81 - error("fatal exception"); 8.82 - } 8.83 - } 8.84 - 8.85 - /** 8.86 - * Reads and stores class file information. 8.87 - */ 8.88 - public void read(DataInputStream in) throws IOException { 8.89 - // Read the header 8.90 - magic = in.readInt(); 8.91 - if (magic != JAVA_MAGIC) { 8.92 - throw new ClassFormatError("wrong magic: " + 8.93 - toHex(magic) + ", expected " + 8.94 - toHex(JAVA_MAGIC)); 8.95 - } 8.96 - minor_version = in.readShort(); 8.97 - major_version = in.readShort(); 8.98 - if (major_version != JAVA_VERSION) { 8.99 - } 8.100 - 8.101 - // Read the constant pool 8.102 - readCP(in); 8.103 - access = in.readUnsignedShort(); 8.104 - this_class = in.readUnsignedShort(); 8.105 - super_class = in.readUnsignedShort(); 8.106 - 8.107 - //Read interfaces. 8.108 - interfaces_count = in.readUnsignedShort(); 8.109 - if(interfaces_count > 0){ 8.110 - interfaces = new int[interfaces_count]; 8.111 - } 8.112 - for (int i = 0; i < interfaces_count; i++) { 8.113 - interfaces[i]=in.readShort(); 8.114 - } 8.115 - 8.116 - // Read the fields 8.117 - readFields(in); 8.118 - 8.119 - // Read the methods 8.120 - readMethods(in); 8.121 - 8.122 - // Read the attributes 8.123 - attributes_count = in.readUnsignedShort(); 8.124 - attrs=new AttrData[attributes_count]; 8.125 - for (int k = 0; k < attributes_count; k++) { 8.126 - int name_cpx=in.readUnsignedShort(); 8.127 - if (getTag(name_cpx)==CONSTANT_UTF8 8.128 - && getString(name_cpx).equals("SourceFile") 8.129 - ){ if (in.readInt()!=2) 8.130 - throw new ClassFormatError("invalid attr length"); 8.131 - source_cpx=in.readUnsignedShort(); 8.132 - AttrData attr=new AttrData(this); 8.133 - attr.read(name_cpx); 8.134 - attrs[k]=attr; 8.135 - 8.136 - } else if (getTag(name_cpx)==CONSTANT_UTF8 8.137 - && getString(name_cpx).equals("InnerClasses") 8.138 - ){ int length=in.readInt(); 8.139 - int num=in.readUnsignedShort(); 8.140 - if (2+num*8 != length) 8.141 - throw new ClassFormatError("invalid attr length"); 8.142 - innerClasses=new InnerClassData[num]; 8.143 - for (int j = 0; j < num; j++) { 8.144 - InnerClassData innerClass=new InnerClassData(this); 8.145 - innerClass.read(in); 8.146 - innerClasses[j]=innerClass; 8.147 - } 8.148 - AttrData attr=new AttrData(this); 8.149 - attr.read(name_cpx); 8.150 - attrs[k]=attr; 8.151 - } else { 8.152 - AttrData attr=new AttrData(this); 8.153 - attr.read(name_cpx, in); 8.154 - attrs[k]=attr; 8.155 - } 8.156 - } 8.157 - in.close(); 8.158 - } // end ClassData.read() 8.159 - 8.160 - /** 8.161 - * Reads and stores constant pool info. 8.162 - */ 8.163 - void readCP(DataInputStream in) throws IOException { 8.164 - cpool_count = in.readUnsignedShort(); 8.165 - tags = new byte[cpool_count]; 8.166 - cpool = new Object[cpool_count]; 8.167 - for (int i = 1; i < cpool_count; i++) { 8.168 - byte tag = in.readByte(); 8.169 - 8.170 - switch(tags[i] = tag) { 8.171 - case CONSTANT_UTF8: 8.172 - String str=in.readUTF(); 8.173 - indexHashAscii.put(cpool[i] = str, i); 8.174 - break; 8.175 - case CONSTANT_INTEGER: 8.176 - cpool[i] = Integer.valueOf(in.readInt()); 8.177 - break; 8.178 - case CONSTANT_FLOAT: 8.179 - cpool[i] = Float.valueOf(in.readFloat()); 8.180 - break; 8.181 - case CONSTANT_LONG: 8.182 - cpool[i++] = Long.valueOf(in.readLong()); 8.183 - break; 8.184 - case CONSTANT_DOUBLE: 8.185 - cpool[i++] = Double.valueOf(in.readDouble()); 8.186 - break; 8.187 - case CONSTANT_CLASS: 8.188 - case CONSTANT_STRING: 8.189 - cpool[i] = new CPX(in.readUnsignedShort()); 8.190 - break; 8.191 - 8.192 - case CONSTANT_FIELD: 8.193 - case CONSTANT_METHOD: 8.194 - case CONSTANT_INTERFACEMETHOD: 8.195 - case CONSTANT_NAMEANDTYPE: 8.196 - cpool[i] = new CPX2(in.readUnsignedShort(), in.readUnsignedShort()); 8.197 - break; 8.198 - 8.199 - case 0: 8.200 - default: 8.201 - throw new ClassFormatError("invalid constant type: " + (int)tags[i]); 8.202 - } 8.203 - } 8.204 - } 8.205 - 8.206 - /** 8.207 - * Reads and strores field info. 8.208 - */ 8.209 - protected void readFields(DataInputStream in) throws IOException { 8.210 - int fields_count = in.readUnsignedShort(); 8.211 - fields=new FieldData[fields_count]; 8.212 - for (int k = 0; k < fields_count; k++) { 8.213 - FieldData field=new FieldData(this); 8.214 - field.read(in); 8.215 - fields[k]=field; 8.216 - } 8.217 - } 8.218 - 8.219 - /** 8.220 - * Reads and strores Method info. 8.221 - */ 8.222 - protected void readMethods(DataInputStream in) throws IOException { 8.223 - int methods_count = in.readUnsignedShort(); 8.224 - methods=new MethodData[methods_count]; 8.225 - for (int k = 0; k < methods_count ; k++) { 8.226 - MethodData method=new MethodData(this); 8.227 - method.read(in); 8.228 - methods[k]=method; 8.229 - } 8.230 - } 8.231 - 8.232 - /** 8.233 - * get a string 8.234 - */ 8.235 - public String getString(int n) { 8.236 - return (n == 0) ? null : (String)cpool[n]; 8.237 - } 8.238 - 8.239 - /** 8.240 - * get the type of constant given an index 8.241 - */ 8.242 - public byte getTag(int n) { 8.243 - try{ 8.244 - return tags[n]; 8.245 - } catch (ArrayIndexOutOfBoundsException e) { 8.246 - return (byte)100; 8.247 - } 8.248 - } 8.249 - 8.250 - static final String hexString="0123456789ABCDEF"; 8.251 - 8.252 - public static char hexTable[]=hexString.toCharArray(); 8.253 - 8.254 - static String toHex(long val, int width) { 8.255 - StringBuffer s = new StringBuffer(); 8.256 - for (int i=width-1; i>=0; i--) 8.257 - s.append(hexTable[((int)(val>>(4*i)))&0xF]); 8.258 - return "0x"+s.toString(); 8.259 - } 8.260 - 8.261 - static String toHex(long val) { 8.262 - int width; 8.263 - for (width=16; width>0; width--) { 8.264 - if ((val>>(width-1)*4)!=0) break; 8.265 - } 8.266 - return toHex(val, width); 8.267 - } 8.268 - 8.269 - static String toHex(int val) { 8.270 - int width; 8.271 - for (width=8; width>0; width--) { 8.272 - if ((val>>(width-1)*4)!=0) break; 8.273 - } 8.274 - return toHex(val, width); 8.275 - } 8.276 - 8.277 - public void error(String msg) { 8.278 - System.err.println("ERROR:" +msg); 8.279 - } 8.280 - 8.281 - /** 8.282 - * Returns the name of this class. 8.283 - */ 8.284 - public String getClassName() { 8.285 - String res=null; 8.286 - if (this_class==0) { 8.287 - return res; 8.288 - } 8.289 - int tcpx; 8.290 - try { 8.291 - if (tags[this_class]!=CONSTANT_CLASS) { 8.292 - return res; //"<CP["+cpx+"] is not a Class> "; 8.293 - } 8.294 - tcpx=((CPX)cpool[this_class]).cpx; 8.295 - } catch (ArrayIndexOutOfBoundsException e) { 8.296 - return res; // "#"+cpx+"// invalid constant pool index"; 8.297 - } catch (Throwable e) { 8.298 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER"; 8.299 - } 8.300 - 8.301 - try { 8.302 - return (String)(cpool[tcpx]); 8.303 - } catch (ArrayIndexOutOfBoundsException e) { 8.304 - return res; // "class #"+scpx+"// invalid constant pool index"; 8.305 - } catch (ClassCastException e) { 8.306 - return res; // "class #"+scpx+"// invalid constant pool reference"; 8.307 - } catch (Throwable e) { 8.308 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER"; 8.309 - } 8.310 - 8.311 - } 8.312 - 8.313 - /** 8.314 - * Returns the name of class at perticular index. 8.315 - */ 8.316 - public String getClassName(int cpx) { 8.317 - String res="#"+cpx; 8.318 - if (cpx==0) { 8.319 - return res; 8.320 - } 8.321 - int scpx; 8.322 - try { 8.323 - if (tags[cpx]!=CONSTANT_CLASS) { 8.324 - return res; //"<CP["+cpx+"] is not a Class> "; 8.325 - } 8.326 - scpx=((CPX)cpool[cpx]).cpx; 8.327 - } catch (ArrayIndexOutOfBoundsException e) { 8.328 - return res; // "#"+cpx+"// invalid constant pool index"; 8.329 - } catch (Throwable e) { 8.330 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER"; 8.331 - } 8.332 - res="#"+scpx; 8.333 - try { 8.334 - return (String)(cpool[scpx]); 8.335 - } catch (ArrayIndexOutOfBoundsException e) { 8.336 - return res; // "class #"+scpx+"// invalid constant pool index"; 8.337 - } catch (ClassCastException e) { 8.338 - return res; // "class #"+scpx+"// invalid constant pool reference"; 8.339 - } catch (Throwable e) { 8.340 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER"; 8.341 - } 8.342 - } 8.343 - 8.344 - /** 8.345 - * Returns true if it is a class 8.346 - */ 8.347 - public boolean isClass() { 8.348 - if((access & ACC_INTERFACE) == 0) return true; 8.349 - return false; 8.350 - } 8.351 - 8.352 - /** 8.353 - * Returns true if it is a interface. 8.354 - */ 8.355 - public boolean isInterface(){ 8.356 - if((access & ACC_INTERFACE) != 0) return true; 8.357 - return false; 8.358 - } 8.359 - 8.360 - /** 8.361 - * Returns true if this member is public, false otherwise. 8.362 - */ 8.363 - public boolean isPublic(){ 8.364 - return (access & ACC_PUBLIC) != 0; 8.365 - } 8.366 - 8.367 - /** 8.368 - * Returns the access of this class or interface. 8.369 - */ 8.370 - public String[] getAccess(){ 8.371 - Vector<String> v = new Vector<String>(); 8.372 - if ((access & ACC_PUBLIC) !=0) v.addElement("public"); 8.373 - if ((access & ACC_FINAL) !=0) v.addElement("final"); 8.374 - if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract"); 8.375 - String[] accflags = new String[v.size()]; 8.376 - v.copyInto(accflags); 8.377 - return accflags; 8.378 - } 8.379 - 8.380 - /** 8.381 - * Returns list of innerclasses. 8.382 - */ 8.383 - public InnerClassData[] getInnerClasses(){ 8.384 - return innerClasses; 8.385 - } 8.386 - 8.387 - /** 8.388 - * Returns list of attributes. 8.389 - */ 8.390 - public AttrData[] getAttributes(){ 8.391 - return attrs; 8.392 - } 8.393 - 8.394 - /** 8.395 - * Returns true if superbit is set. 8.396 - */ 8.397 - public boolean isSuperSet(){ 8.398 - if ((access & ACC_SUPER) !=0) return true; 8.399 - return false; 8.400 - } 8.401 - 8.402 - /** 8.403 - * Returns super class name. 8.404 - */ 8.405 - public String getSuperClassName(){ 8.406 - String res=null; 8.407 - if (super_class==0) { 8.408 - return res; 8.409 - } 8.410 - int scpx; 8.411 - try { 8.412 - if (tags[super_class]!=CONSTANT_CLASS) { 8.413 - return res; //"<CP["+cpx+"] is not a Class> "; 8.414 - } 8.415 - scpx=((CPX)cpool[super_class]).cpx; 8.416 - } catch (ArrayIndexOutOfBoundsException e) { 8.417 - return res; // "#"+cpx+"// invalid constant pool index"; 8.418 - } catch (Throwable e) { 8.419 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER"; 8.420 - } 8.421 - 8.422 - try { 8.423 - return (String)(cpool[scpx]); 8.424 - } catch (ArrayIndexOutOfBoundsException e) { 8.425 - return res; // "class #"+scpx+"// invalid constant pool index"; 8.426 - } catch (ClassCastException e) { 8.427 - return res; // "class #"+scpx+"// invalid constant pool reference"; 8.428 - } catch (Throwable e) { 8.429 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER"; 8.430 - } 8.431 - } 8.432 - 8.433 - /** 8.434 - * Returns list of super interfaces. 8.435 - */ 8.436 - public String[] getSuperInterfaces(){ 8.437 - String interfacenames[] = new String[interfaces.length]; 8.438 - int interfacecpx = -1; 8.439 - for(int i = 0; i < interfaces.length; i++){ 8.440 - interfacecpx=((CPX)cpool[interfaces[i]]).cpx; 8.441 - interfacenames[i] = (String)(cpool[interfacecpx]); 8.442 - } 8.443 - return interfacenames; 8.444 - } 8.445 - 8.446 - /** 8.447 - * Returns string at prticular constant pool index. 8.448 - */ 8.449 - public String getStringValue(int cpoolx) { 8.450 - try { 8.451 - return ((String)cpool[cpoolx]); 8.452 - } catch (ArrayIndexOutOfBoundsException e) { 8.453 - return "//invalid constant pool index:"+cpoolx; 8.454 - } catch (ClassCastException e) { 8.455 - return "//invalid constant pool ref:"+cpoolx; 8.456 - } 8.457 - } 8.458 - 8.459 - /** 8.460 - * Returns list of field info. 8.461 - */ 8.462 - public FieldData[] getFields(){ 8.463 - return fields; 8.464 - } 8.465 - 8.466 - /** 8.467 - * Returns list of method info. 8.468 - */ 8.469 - public MethodData[] getMethods(){ 8.470 - return methods; 8.471 - } 8.472 - 8.473 - /** 8.474 - * Returns constant pool entry at that index. 8.475 - */ 8.476 - public CPX2 getCpoolEntry(int cpx){ 8.477 - return ((CPX2)(cpool[cpx])); 8.478 - } 8.479 - 8.480 - public Object getCpoolEntryobj(int cpx){ 8.481 - return (cpool[cpx]); 8.482 - } 8.483 - 8.484 - /** 8.485 - * Returns index of this class. 8.486 - */ 8.487 - public int getthis_cpx(){ 8.488 - return this_class; 8.489 - } 8.490 - 8.491 - public String TagString (int tag) { 8.492 - String res=Tables.tagName(tag); 8.493 - if (res==null) return "BOGUS_TAG:"+tag; 8.494 - return res; 8.495 - } 8.496 - 8.497 - /** 8.498 - * Returns string at that index. 8.499 - */ 8.500 - public String StringValue(int cpx) { 8.501 - if (cpx==0) return "#0"; 8.502 - int tag; 8.503 - Object x; 8.504 - String suffix=""; 8.505 - try { 8.506 - tag=tags[cpx]; 8.507 - x=cpool[cpx]; 8.508 - } catch (IndexOutOfBoundsException e) { 8.509 - return "<Incorrect CP index:"+cpx+">"; 8.510 - } 8.511 - 8.512 - if (x==null) return "<NULL>"; 8.513 - switch (tag) { 8.514 - case CONSTANT_UTF8: { 8.515 - StringBuffer sb=new StringBuffer(); 8.516 - String s=(String)x; 8.517 - for (int k=0; k<s.length(); k++) { 8.518 - char c=s.charAt(k); 8.519 - switch (c) { 8.520 - case '\t': sb.append('\\').append('t'); break; 8.521 - case '\n': sb.append('\\').append('n'); break; 8.522 - case '\r': sb.append('\\').append('r'); break; 8.523 - case '\"': sb.append('\\').append('\"'); break; 8.524 - default: sb.append(c); 8.525 - } 8.526 - } 8.527 - return sb.toString(); 8.528 - } 8.529 - case CONSTANT_DOUBLE: { 8.530 - Double d=(Double)x; 8.531 - String sd=d.toString(); 8.532 - return sd+"d"; 8.533 - } 8.534 - case CONSTANT_FLOAT: { 8.535 - Float f=(Float)x; 8.536 - String sf=(f).toString(); 8.537 - return sf+"f"; 8.538 - } 8.539 - case CONSTANT_LONG: { 8.540 - Long ln = (Long)x; 8.541 - return ln.toString()+'l'; 8.542 - } 8.543 - case CONSTANT_INTEGER: { 8.544 - Integer in = (Integer)x; 8.545 - return in.toString(); 8.546 - } 8.547 - case CONSTANT_CLASS: 8.548 - return javaName(getClassName(cpx)); 8.549 - case CONSTANT_STRING: 8.550 - return StringValue(((CPX)x).cpx); 8.551 - case CONSTANT_FIELD: 8.552 - case CONSTANT_METHOD: 8.553 - case CONSTANT_INTERFACEMETHOD: 8.554 - //return getShortClassName(((CPX2)x).cpx1)+"."+StringValue(((CPX2)x).cpx2); 8.555 - return javaName(getClassName(((CPX2)x).cpx1))+"."+StringValue(((CPX2)x).cpx2); 8.556 - 8.557 - case CONSTANT_NAMEANDTYPE: 8.558 - return getName(((CPX2)x).cpx1)+":"+StringValue(((CPX2)x).cpx2); 8.559 - default: 8.560 - return "UnknownTag"; //TBD 8.561 - } 8.562 - } 8.563 - 8.564 - /** 8.565 - * Returns resolved java type name. 8.566 - */ 8.567 - public String javaName(String name) { 8.568 - if( name==null) return "null"; 8.569 - int len=name.length(); 8.570 - if (len==0) return "\"\""; 8.571 - int cc='/'; 8.572 - fullname: { // xxx/yyy/zzz 8.573 - int cp; 8.574 - for (int k=0; k<len; k += Character.charCount(cp)) { 8.575 - cp=name.codePointAt(k); 8.576 - if (cc=='/') { 8.577 - if (!Character.isJavaIdentifierStart(cp)) break fullname; 8.578 - } else if (cp!='/') { 8.579 - if (!Character.isJavaIdentifierPart(cp)) break fullname; 8.580 - } 8.581 - cc=cp; 8.582 - } 8.583 - return name; 8.584 - } 8.585 - return "\""+name+"\""; 8.586 - } 8.587 - 8.588 - public String getName(int cpx) { 8.589 - String res; 8.590 - try { 8.591 - return javaName((String)cpool[cpx]); //.replace('/','.'); 8.592 - } catch (ArrayIndexOutOfBoundsException e) { 8.593 - return "<invalid constant pool index:"+cpx+">"; 8.594 - } catch (ClassCastException e) { 8.595 - return "<invalid constant pool ref:"+cpx+">"; 8.596 - } 8.597 - } 8.598 - 8.599 - /** 8.600 - * Returns unqualified class name. 8.601 - */ 8.602 - public String getShortClassName(int cpx) { 8.603 - String classname=javaName(getClassName(cpx)); 8.604 - pkgPrefixLen=classname.lastIndexOf("/")+1; 8.605 - if (pkgPrefixLen!=0) { 8.606 - pkgPrefix=classname.substring(0,pkgPrefixLen); 8.607 - if (classname.startsWith(pkgPrefix)) { 8.608 - return classname.substring(pkgPrefixLen); 8.609 - } 8.610 - } 8.611 - return classname; 8.612 - } 8.613 - 8.614 - /** 8.615 - * Returns source file name. 8.616 - */ 8.617 - public String getSourceName(){ 8.618 - return getName(source_cpx); 8.619 - } 8.620 - 8.621 - /** 8.622 - * Returns package name. 8.623 - */ 8.624 - public String getPkgName(){ 8.625 - String classname=getClassName(this_class); 8.626 - pkgPrefixLen=classname.lastIndexOf("/")+1; 8.627 - if (pkgPrefixLen!=0) { 8.628 - pkgPrefix=classname.substring(0,pkgPrefixLen); 8.629 - return("package "+pkgPrefix.substring(0,pkgPrefixLen-1)+";\n"); 8.630 - }else return null; 8.631 - } 8.632 - 8.633 - /** 8.634 - * Returns total constant pool entry count. 8.635 - */ 8.636 - public int getCpoolCount(){ 8.637 - return cpool_count; 8.638 - } 8.639 - 8.640 - public String StringTag(int cpx) { 8.641 - byte tag=0; 8.642 - String str=null; 8.643 - try { 8.644 - if (cpx==0) throw new IndexOutOfBoundsException(); 8.645 - tag=tags[cpx]; 8.646 - return TagString(tag); 8.647 - } catch (IndexOutOfBoundsException e) { 8.648 - str="Incorrect CP index:"+cpx; 8.649 - } 8.650 - return str; 8.651 - } 8.652 - 8.653 - /** 8.654 - * Returns minor version of class file. 8.655 - */ 8.656 - public int getMinor_version(){ 8.657 - return minor_version; 8.658 - } 8.659 - 8.660 - /** 8.661 - * Returns major version of class file. 8.662 - */ 8.663 - public int getMajor_version(){ 8.664 - return major_version; 8.665 - } 8.666 -}
9.1 --- a/src/share/classes/sun/tools/javap/Constants.java Thu May 28 09:49:56 2009 -0700 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,372 +0,0 @@ 9.4 -/* 9.5 - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 9.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 - * 9.8 - * This code is free software; you can redistribute it and/or modify it 9.9 - * under the terms of the GNU General Public License version 2 only, as 9.10 - * published by the Free Software Foundation. Sun designates this 9.11 - * particular file as subject to the "Classpath" exception as provided 9.12 - * by Sun in the LICENSE file that accompanied this code. 9.13 - * 9.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 9.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.17 - * version 2 for more details (a copy is included in the LICENSE file that 9.18 - * accompanied this code). 9.19 - * 9.20 - * You should have received a copy of the GNU General Public License version 9.21 - * 2 along with this work; if not, write to the Free Software Foundation, 9.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.23 - * 9.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 9.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 9.26 - * have any questions. 9.27 - */ 9.28 - 9.29 - 9.30 - 9.31 -package sun.tools.javap; 9.32 - 9.33 -/** 9.34 - * This interface defines constant that are used 9.35 - * throughout the compiler. It inherits from RuntimeConstants, 9.36 - * which is an autogenerated class that contains contstants 9.37 - * defined in the interpreter. 9.38 - */ 9.39 - 9.40 -public 9.41 -interface Constants extends RuntimeConstants { 9.42 - 9.43 - /** 9.44 - * End of input 9.45 - */ 9.46 - public static final int EOF = -1; 9.47 - 9.48 - /* 9.49 - * Flags 9.50 - */ 9.51 - public static final int F_VERBOSE = 1 << 0; 9.52 - public static final int F_DUMP = 1 << 1; 9.53 - public static final int F_WARNINGS = 1 << 2; 9.54 - public static final int F_DEBUG = 1 << 3; 9.55 - public static final int F_OPTIMIZE = 1 << 4; 9.56 - public static final int F_DEPENDENCIES = 1 << 5; 9.57 - 9.58 - /* 9.59 - * Type codes 9.60 - */ 9.61 - public static final int TC_BOOLEAN = 0; 9.62 - public static final int TC_BYTE = 1; 9.63 - public static final int TC_CHAR = 2; 9.64 - public static final int TC_SHORT = 3; 9.65 - public static final int TC_INT = 4; 9.66 - public static final int TC_LONG = 5; 9.67 - public static final int TC_FLOAT = 6; 9.68 - public static final int TC_DOUBLE = 7; 9.69 - public static final int TC_NULL = 8; 9.70 - public static final int TC_ARRAY = 9; 9.71 - public static final int TC_CLASS = 10; 9.72 - public static final int TC_VOID = 11; 9.73 - public static final int TC_METHOD = 12; 9.74 - public static final int TC_ERROR = 13; 9.75 - 9.76 - /* 9.77 - * Type Masks 9.78 - */ 9.79 - public static final int TM_NULL = 1 << TC_NULL; 9.80 - public static final int TM_VOID = 1 << TC_VOID; 9.81 - public static final int TM_BOOLEAN = 1 << TC_BOOLEAN; 9.82 - public static final int TM_BYTE = 1 << TC_BYTE; 9.83 - public static final int TM_CHAR = 1 << TC_CHAR; 9.84 - public static final int TM_SHORT = 1 << TC_SHORT; 9.85 - public static final int TM_INT = 1 << TC_INT; 9.86 - public static final int TM_LONG = 1 << TC_LONG; 9.87 - public static final int TM_FLOAT = 1 << TC_FLOAT; 9.88 - public static final int TM_DOUBLE = 1 << TC_DOUBLE; 9.89 - public static final int TM_ARRAY = 1 << TC_ARRAY; 9.90 - public static final int TM_CLASS = 1 << TC_CLASS; 9.91 - public static final int TM_METHOD = 1 << TC_METHOD; 9.92 - public static final int TM_ERROR = 1 << TC_ERROR; 9.93 - 9.94 - public static final int TM_INT32 = TM_BYTE | TM_SHORT | TM_CHAR | TM_INT; 9.95 - public static final int TM_NUM32 = TM_INT32 | TM_FLOAT; 9.96 - public static final int TM_NUM64 = TM_LONG | TM_DOUBLE; 9.97 - public static final int TM_INTEGER = TM_INT32 | TM_LONG; 9.98 - public static final int TM_REAL = TM_FLOAT | TM_DOUBLE; 9.99 - public static final int TM_NUMBER = TM_INTEGER | TM_REAL; 9.100 - public static final int TM_REFERENCE = TM_ARRAY | TM_CLASS | TM_NULL; 9.101 - 9.102 - /* 9.103 - * Class status 9.104 - */ 9.105 - public static final int CS_UNDEFINED = 0; 9.106 - public static final int CS_UNDECIDED = 1; 9.107 - public static final int CS_BINARY = 2; 9.108 - public static final int CS_SOURCE = 3; 9.109 - public static final int CS_PARSED = 4; 9.110 - public static final int CS_COMPILED = 5; 9.111 - public static final int CS_NOTFOUND = 6; 9.112 - 9.113 - /* 9.114 - * Attributes 9.115 - */ 9.116 - public static final int ATT_ALL = -1; 9.117 - public static final int ATT_CODE = 1; 9.118 - 9.119 - /* 9.120 - * Number of bits used in file offsets 9.121 - */ 9.122 - public static final int OFFSETBITS = 19; 9.123 - public static final int MAXFILESIZE = (1 << OFFSETBITS) - 1; 9.124 - public static final int MAXLINENUMBER = (1 << (32 - OFFSETBITS)) - 1; 9.125 - 9.126 - /* 9.127 - * Operators 9.128 - */ 9.129 - public final int COMMA = 0; 9.130 - public final int ASSIGN = 1; 9.131 - 9.132 - public final int ASGMUL = 2; 9.133 - public final int ASGDIV = 3; 9.134 - public final int ASGREM = 4; 9.135 - public final int ASGADD = 5; 9.136 - public final int ASGSUB = 6; 9.137 - public final int ASGLSHIFT = 7; 9.138 - public final int ASGRSHIFT = 8; 9.139 - public final int ASGURSHIFT = 9; 9.140 - public final int ASGBITAND = 10; 9.141 - public final int ASGBITOR = 11; 9.142 - public final int ASGBITXOR = 12; 9.143 - 9.144 - public final int COND = 13; 9.145 - public final int OR = 14; 9.146 - public final int AND = 15; 9.147 - public final int BITOR = 16; 9.148 - public final int BITXOR = 17; 9.149 - public final int BITAND = 18; 9.150 - public final int NE = 19; 9.151 - public final int EQ = 20; 9.152 - public final int GE = 21; 9.153 - public final int GT = 22; 9.154 - public final int LE = 23; 9.155 - public final int LT = 24; 9.156 - public final int INSTANCEOF = 25; 9.157 - public final int LSHIFT = 26; 9.158 - public final int RSHIFT = 27; 9.159 - public final int URSHIFT = 28; 9.160 - public final int ADD = 29; 9.161 - public final int SUB = 30; 9.162 - public final int DIV = 31; 9.163 - public final int REM = 32; 9.164 - public final int MUL = 33; 9.165 - public final int CAST = 34; // (x)y 9.166 - public final int POS = 35; // +x 9.167 - public final int NEG = 36; // -x 9.168 - public final int NOT = 37; 9.169 - public final int BITNOT = 38; 9.170 - public final int PREINC = 39; // ++x 9.171 - public final int PREDEC = 40; // --x 9.172 - public final int NEWARRAY = 41; 9.173 - public final int NEWINSTANCE = 42; 9.174 - public final int NEWFROMNAME = 43; 9.175 - public final int POSTINC = 44; // x++ 9.176 - public final int POSTDEC = 45; // x-- 9.177 - public final int FIELD = 46; 9.178 - public final int METHOD = 47; // x(y) 9.179 - public final int ARRAYACCESS = 48; // x[y] 9.180 - public final int NEW = 49; 9.181 - public final int INC = 50; 9.182 - public final int DEC = 51; 9.183 - 9.184 - public final int CONVERT = 55; // implicit conversion 9.185 - public final int EXPR = 56; // (x) 9.186 - public final int ARRAY = 57; // {x, y, ...} 9.187 - public final int GOTO = 58; 9.188 - 9.189 - /* 9.190 - * Value tokens 9.191 - */ 9.192 - public final int IDENT = 60; 9.193 - public final int BOOLEANVAL = 61; 9.194 - public final int BYTEVAL = 62; 9.195 - public final int CHARVAL = 63; 9.196 - public final int SHORTVAL = 64; 9.197 - public final int INTVAL = 65; 9.198 - public final int LONGVAL = 66; 9.199 - public final int FLOATVAL = 67; 9.200 - public final int DOUBLEVAL = 68; 9.201 - public final int STRINGVAL = 69; 9.202 - 9.203 - /* 9.204 - * Type keywords 9.205 - */ 9.206 - public final int BYTE = 70; 9.207 - public final int CHAR = 71; 9.208 - public final int SHORT = 72; 9.209 - public final int INT = 73; 9.210 - public final int LONG = 74; 9.211 - public final int FLOAT = 75; 9.212 - public final int DOUBLE = 76; 9.213 - public final int VOID = 77; 9.214 - public final int BOOLEAN = 78; 9.215 - 9.216 - /* 9.217 - * Expression keywords 9.218 - */ 9.219 - public final int TRUE = 80; 9.220 - public final int FALSE = 81; 9.221 - public final int THIS = 82; 9.222 - public final int SUPER = 83; 9.223 - public final int NULL = 84; 9.224 - 9.225 - /* 9.226 - * Statement keywords 9.227 - */ 9.228 - public final int IF = 90; 9.229 - public final int ELSE = 91; 9.230 - public final int FOR = 92; 9.231 - public final int WHILE = 93; 9.232 - public final int DO = 94; 9.233 - public final int SWITCH = 95; 9.234 - public final int CASE = 96; 9.235 - public final int DEFAULT = 97; 9.236 - public final int BREAK = 98; 9.237 - public final int CONTINUE = 99; 9.238 - public final int RETURN = 100; 9.239 - public final int TRY = 101; 9.240 - public final int CATCH = 102; 9.241 - public final int FINALLY = 103; 9.242 - public final int THROW = 104; 9.243 - public final int STAT = 105; 9.244 - public final int EXPRESSION = 106; 9.245 - public final int DECLARATION = 107; 9.246 - public final int VARDECLARATION = 108; 9.247 - 9.248 - /* 9.249 - * Declaration keywords 9.250 - */ 9.251 - public final int IMPORT = 110; 9.252 - public final int CLASS = 111; 9.253 - public final int EXTENDS = 112; 9.254 - public final int IMPLEMENTS = 113; 9.255 - public final int INTERFACE = 114; 9.256 - public final int PACKAGE = 115; 9.257 - 9.258 - /* 9.259 - * Modifier keywords 9.260 - */ 9.261 - public final int PRIVATE = 120; 9.262 - public final int PUBLIC = 121; 9.263 - public final int PROTECTED = 122; 9.264 - public final int CONST = 123; 9.265 - public final int STATIC = 124; 9.266 - public final int TRANSIENT = 125; 9.267 - public final int SYNCHRONIZED = 126; 9.268 - public final int NATIVE = 127; 9.269 - public final int FINAL = 128; 9.270 - public final int VOLATILE = 129; 9.271 - public final int ABSTRACT = 130; 9.272 - public final int STRICT = 165; 9.273 - 9.274 - /* 9.275 - * Punctuation 9.276 - */ 9.277 - public final int SEMICOLON = 135; 9.278 - public final int COLON = 136; 9.279 - public final int QUESTIONMARK = 137; 9.280 - public final int LBRACE = 138; 9.281 - public final int RBRACE = 139; 9.282 - public final int LPAREN = 140; 9.283 - public final int RPAREN = 141; 9.284 - public final int LSQBRACKET = 142; 9.285 - public final int RSQBRACKET = 143; 9.286 - public final int THROWS = 144; 9.287 - 9.288 - /* 9.289 - * Special tokens 9.290 - */ 9.291 - public final int ERROR = 145; // an error 9.292 - public final int COMMENT = 146; // not used anymore. 9.293 - public final int TYPE = 147; 9.294 - public final int LENGTH = 148; 9.295 - public final int INLINERETURN = 149; 9.296 - public final int INLINEMETHOD = 150; 9.297 - public final int INLINENEWINSTANCE = 151; 9.298 - 9.299 - /* 9.300 - * Added for jasm 9.301 - */ 9.302 - public final int METHODREF = 152; 9.303 - public final int FIELDREF = 153; 9.304 - public final int STACK = 154; 9.305 - public final int LOCAL = 155; 9.306 - public final int CPINDEX = 156; 9.307 - public final int CPNAME = 157; 9.308 - public final int SIGN = 158; 9.309 - public final int BITS = 159; 9.310 - public final int INF = 160; 9.311 - public final int NAN = 161; 9.312 - public final int INNERCLASS = 162; 9.313 - public final int OF = 163; 9.314 - public final int SYNTHETIC = 164; 9.315 -// last used=165; 9.316 - 9.317 - /* 9.318 - * Operator precedence 9.319 - */ 9.320 - public static final int opPrecedence[] = { 9.321 - 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9.322 - 11, 11, 11, 12, 13, 14, 15, 16, 17, 18, 9.323 - 18, 19, 19, 19, 19, 19, 20, 20, 20, 21, 9.324 - 21, 22, 22, 22, 23, 24, 24, 24, 24, 24, 9.325 - 24, 25, 25, 26, 26, 26, 26, 26, 26 9.326 - }; 9.327 - 9.328 - /* 9.329 - * Operator names 9.330 - */ 9.331 - public static final String opNames[] = { 9.332 - ",", "=", "*=", "/=", "%=", 9.333 - "+=", "-=", "<<=", ">>=", "<<<=", 9.334 - "&=", "|=", "^=", "?:", "||", 9.335 - "&&", "|", "^", "&", "!=", 9.336 - "==", ">=", ">", "<=", "<", 9.337 - "instanceof", "<<", ">>", "<<<", "+", 9.338 - "-", "/", "%", "*", "cast", 9.339 - "+", "-", "!", "~", "++", 9.340 - "--", "new", "new", "new", "++", 9.341 - "--", "field", "method", "[]", "new", 9.342 - "++", "--", null, null, null, 9.343 - 9.344 - "convert", "expr", "array", "goto", null, 9.345 - 9.346 - "Identifier", "Boolean", "Byte", "Char", "Short", 9.347 - "Integer", "Long", "Float", "Double", "String", 9.348 - 9.349 - "byte", "char", "short", "int", "long", 9.350 - "float", "double", "void", "boolean", null, 9.351 - 9.352 - "true", "false", "this", "super", "null", 9.353 - null, null, null, null, null, 9.354 - 9.355 - "if", "else", "for", "while", "do", 9.356 - "switch", "case", "default", "break", "continue", 9.357 - "return", "try", "catch", "finally", "throw", 9.358 - "stat", "expression", "declaration", "declaration", null, 9.359 - 9.360 - "import", "class", "extends", "implements", "interface", 9.361 - "package", null, null, null, null, 9.362 - 9.363 - "private", "public", "protected", "const", "static", 9.364 - "transient", "synchronized", "native", "final", "volatile", 9.365 - "abstract", null, null, null, null, 9.366 - 9.367 - ";", ":", "?", "{", "}", 9.368 - "(", ")", "[", "]", "throws", 9.369 - "error", "comment", "type", "length", "inline-return", 9.370 - "inline-method", "inline-new", 9.371 - "method", "field", "stack", "locals", "CPINDEX", "CPName", "SIGN", 9.372 - "bits", "INF", "NaN", "InnerClass", "of", "synthetic" 9.373 - }; 9.374 - 9.375 -}
10.1 --- a/src/share/classes/sun/tools/javap/FieldData.java Thu May 28 09:49:56 2009 -0700 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,163 +0,0 @@ 10.4 -/* 10.5 - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. 10.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 - * 10.8 - * This code is free software; you can redistribute it and/or modify it 10.9 - * under the terms of the GNU General Public License version 2 only, as 10.10 - * published by the Free Software Foundation. Sun designates this 10.11 - * particular file as subject to the "Classpath" exception as provided 10.12 - * by Sun in the LICENSE file that accompanied this code. 10.13 - * 10.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 10.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.17 - * version 2 for more details (a copy is included in the LICENSE file that 10.18 - * accompanied this code). 10.19 - * 10.20 - * You should have received a copy of the GNU General Public License version 10.21 - * 2 along with this work; if not, write to the Free Software Foundation, 10.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.23 - * 10.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 10.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 10.26 - * have any questions. 10.27 - */ 10.28 - 10.29 - 10.30 -package sun.tools.javap; 10.31 - 10.32 -import java.util.*; 10.33 -import java.io.*; 10.34 - 10.35 -/** 10.36 - * Strores field data informastion. 10.37 - * 10.38 - * @author Sucheta Dambalkar (Adopted code from jdis) 10.39 - */ 10.40 - 10.41 -public class FieldData implements RuntimeConstants { 10.42 - 10.43 - ClassData cls; 10.44 - int access; 10.45 - int name_index; 10.46 - int descriptor_index; 10.47 - int attributes_count; 10.48 - int value_cpx=0; 10.49 - boolean isSynthetic=false; 10.50 - boolean isDeprecated=false; 10.51 - Vector<AttrData> attrs; 10.52 - 10.53 - public FieldData(ClassData cls){ 10.54 - this.cls=cls; 10.55 - } 10.56 - 10.57 - /** 10.58 - * Read and store field info. 10.59 - */ 10.60 - public void read(DataInputStream in) throws IOException { 10.61 - access = in.readUnsignedShort(); 10.62 - name_index = in.readUnsignedShort(); 10.63 - descriptor_index = in.readUnsignedShort(); 10.64 - // Read the attributes 10.65 - int attributes_count = in.readUnsignedShort(); 10.66 - attrs=new Vector<AttrData>(attributes_count); 10.67 - for (int i = 0; i < attributes_count; i++) { 10.68 - int attr_name_index=in.readUnsignedShort(); 10.69 - if (cls.getTag(attr_name_index)!=CONSTANT_UTF8) continue; 10.70 - String attr_name=cls.getString(attr_name_index); 10.71 - if (attr_name.equals("ConstantValue")){ 10.72 - if (in.readInt()!=2) 10.73 - throw new ClassFormatError("invalid ConstantValue attr length"); 10.74 - value_cpx=in.readUnsignedShort(); 10.75 - AttrData attr=new AttrData(cls); 10.76 - attr.read(attr_name_index); 10.77 - attrs.addElement(attr); 10.78 - } else if (attr_name.equals("Synthetic")){ 10.79 - if (in.readInt()!=0) 10.80 - throw new ClassFormatError("invalid Synthetic attr length"); 10.81 - isSynthetic=true; 10.82 - AttrData attr=new AttrData(cls); 10.83 - attr.read(attr_name_index); 10.84 - attrs.addElement(attr); 10.85 - } else if (attr_name.equals("Deprecated")){ 10.86 - if (in.readInt()!=0) 10.87 - throw new ClassFormatError("invalid Synthetic attr length"); 10.88 - isDeprecated = true; 10.89 - AttrData attr=new AttrData(cls); 10.90 - attr.read(attr_name_index); 10.91 - attrs.addElement(attr); 10.92 - } else { 10.93 - AttrData attr=new AttrData(cls); 10.94 - attr.read(attr_name_index, in); 10.95 - attrs.addElement(attr); 10.96 - } 10.97 - } 10.98 - 10.99 - } // end read 10.100 - 10.101 - /** 10.102 - * Returns access of a field. 10.103 - */ 10.104 - public String[] getAccess(){ 10.105 - Vector<String> v = new Vector<String>(); 10.106 - if ((access & ACC_PUBLIC) !=0) v.addElement("public"); 10.107 - if ((access & ACC_PRIVATE) !=0) v.addElement("private"); 10.108 - if ((access & ACC_PROTECTED) !=0) v.addElement("protected"); 10.109 - if ((access & ACC_STATIC) !=0) v.addElement("static"); 10.110 - if ((access & ACC_FINAL) !=0) v.addElement("final"); 10.111 - if ((access & ACC_VOLATILE) !=0) v.addElement("volatile"); 10.112 - if ((access & ACC_TRANSIENT) !=0) v.addElement("transient"); 10.113 - String[] accflags = new String[v.size()]; 10.114 - v.copyInto(accflags); 10.115 - return accflags; 10.116 - } 10.117 - 10.118 - /** 10.119 - * Returns name of a field. 10.120 - */ 10.121 - public String getName(){ 10.122 - return cls.getStringValue(name_index); 10.123 - } 10.124 - 10.125 - /** 10.126 - * Returns internal signature of a field 10.127 - */ 10.128 - public String getInternalSig(){ 10.129 - return cls.getStringValue(descriptor_index); 10.130 - } 10.131 - 10.132 - /** 10.133 - * Returns java type signature of a field. 10.134 - */ 10.135 - public String getType(){ 10.136 - return new TypeSignature(getInternalSig()).getFieldType(); 10.137 - } 10.138 - 10.139 - /** 10.140 - * Returns true if field is synthetic. 10.141 - */ 10.142 - public boolean isSynthetic(){ 10.143 - return isSynthetic; 10.144 - } 10.145 - 10.146 - /** 10.147 - * Returns true if field is deprecated. 10.148 - */ 10.149 - public boolean isDeprecated(){ 10.150 - return isDeprecated; 10.151 - } 10.152 - 10.153 - /** 10.154 - * Returns index of constant value in cpool. 10.155 - */ 10.156 - public int getConstantValueIndex(){ 10.157 - return (value_cpx); 10.158 - } 10.159 - 10.160 - /** 10.161 - * Returns list of attributes of field. 10.162 - */ 10.163 - public Vector<?> getAttributes(){ 10.164 - return attrs; 10.165 - } 10.166 -}
11.1 --- a/src/share/classes/sun/tools/javap/InnerClassData.java Thu May 28 09:49:56 2009 -0700 11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 11.3 @@ -1,75 +0,0 @@ 11.4 -/* 11.5 - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. 11.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 - * 11.8 - * This code is free software; you can redistribute it and/or modify it 11.9 - * under the terms of the GNU General Public License version 2 only, as 11.10 - * published by the Free Software Foundation. Sun designates this 11.11 - * particular file as subject to the "Classpath" exception as provided 11.12 - * by Sun in the LICENSE file that accompanied this code. 11.13 - * 11.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 11.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.17 - * version 2 for more details (a copy is included in the LICENSE file that 11.18 - * accompanied this code). 11.19 - * 11.20 - * You should have received a copy of the GNU General Public License version 11.21 - * 2 along with this work; if not, write to the Free Software Foundation, 11.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.23 - * 11.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 11.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 11.26 - * have any questions. 11.27 - */ 11.28 - 11.29 - 11.30 -package sun.tools.javap; 11.31 - 11.32 -import java.io.*; 11.33 -import java.util.*; 11.34 - 11.35 -/** 11.36 - * Strores InnerClass data informastion. 11.37 - * 11.38 - * @author Sucheta Dambalkar (Adopted code from jdis) 11.39 - */ 11.40 -class InnerClassData implements RuntimeConstants { 11.41 - ClassData cls; 11.42 - 11.43 - 11.44 - int inner_class_info_index 11.45 - ,outer_class_info_index 11.46 - ,inner_name_index 11.47 - ,access 11.48 - ; 11.49 - 11.50 - public InnerClassData(ClassData cls) { 11.51 - this.cls=cls; 11.52 - 11.53 - } 11.54 - 11.55 - /** 11.56 - * Read Innerclass attribute data. 11.57 - */ 11.58 - public void read(DataInputStream in) throws IOException { 11.59 - inner_class_info_index = in.readUnsignedShort(); 11.60 - outer_class_info_index = in.readUnsignedShort(); 11.61 - inner_name_index = in.readUnsignedShort(); 11.62 - access = in.readUnsignedShort(); 11.63 - } // end read 11.64 - 11.65 - /** 11.66 - * Returns the access of this class or interface. 11.67 - */ 11.68 - public String[] getAccess(){ 11.69 - Vector<String> v = new Vector<String>(); 11.70 - if ((access & ACC_PUBLIC) !=0) v.addElement("public"); 11.71 - if ((access & ACC_FINAL) !=0) v.addElement("final"); 11.72 - if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract"); 11.73 - String[] accflags = new String[v.size()]; 11.74 - v.copyInto(accflags); 11.75 - return accflags; 11.76 - } 11.77 - 11.78 -} // end InnerClassData
12.1 --- a/src/share/classes/sun/tools/javap/JavapEnvironment.java Thu May 28 09:49:56 2009 -0700 12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 12.3 @@ -1,355 +0,0 @@ 12.4 -/* 12.5 - * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved. 12.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 - * 12.8 - * This code is free software; you can redistribute it and/or modify it 12.9 - * under the terms of the GNU General Public License version 2 only, as 12.10 - * published by the Free Software Foundation. Sun designates this 12.11 - * particular file as subject to the "Classpath" exception as provided 12.12 - * by Sun in the LICENSE file that accompanied this code. 12.13 - * 12.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 12.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.17 - * version 2 for more details (a copy is included in the LICENSE file that 12.18 - * accompanied this code). 12.19 - * 12.20 - * You should have received a copy of the GNU General Public License version 12.21 - * 2 along with this work; if not, write to the Free Software Foundation, 12.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.23 - * 12.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 12.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 12.26 - * have any questions. 12.27 - */ 12.28 - 12.29 - 12.30 -package sun.tools.javap; 12.31 - 12.32 -import java.util.*; 12.33 -import java.io.*; 12.34 -import java.util.jar.*; 12.35 - 12.36 - 12.37 -/** 12.38 - * Strores flag values according to command line options 12.39 - * and sets path where to find classes. 12.40 - * 12.41 - * @author Sucheta Dambalkar 12.42 - */ 12.43 -public class JavapEnvironment { 12.44 - 12.45 - //Access flags 12.46 - public static final int PRIVATE = 0; 12.47 - public static final int PROTECTED = 1; 12.48 - public static final int PACKAGE = 2; 12.49 - public static final int PUBLIC = 3; 12.50 - 12.51 - //search path flags. 12.52 - private static final int start = 0; 12.53 - private static final int cmdboot= 1; 12.54 - private static final int sunboot = 2; 12.55 - private static final int javaclass= 3; 12.56 - private static final int cmdextdir= 4; 12.57 - private static final int javaext= 5; 12.58 - private static final int cmdclasspath= 6; 12.59 - private static final int envclasspath= 7; 12.60 - private static final int javaclasspath= 8; 12.61 - private static final int currentdir = 9; 12.62 - 12.63 - 12.64 - // JavapEnvironment flag settings 12.65 - boolean showLineAndLocal = false; 12.66 - int showAccess = PACKAGE; 12.67 - boolean showDisassembled = false; 12.68 - boolean showVerbose = false; 12.69 - boolean showInternalSigs = false; 12.70 - String classPathString = null; 12.71 - String bootClassPathString = null; 12.72 - String extDirsString = null; 12.73 - boolean extDirflag = false; 12.74 - boolean nothingToDo = true; 12.75 - boolean showallAttr = false; 12.76 - String classpath = null; 12.77 - int searchpath = start; 12.78 - 12.79 - /** 12.80 - * According to which flags are set, 12.81 - * returns file input stream for classfile to disassemble. 12.82 - */ 12.83 - 12.84 - public InputStream getFileInputStream(String Name){ 12.85 - InputStream fileInStream = null; 12.86 - searchpath = cmdboot; 12.87 - try{ 12.88 - if(searchpath == cmdboot){ 12.89 - if(bootClassPathString != null){ 12.90 - //search in specified bootclasspath. 12.91 - classpath = bootClassPathString; 12.92 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.93 - //no classes found in search path. 12.94 - else searchpath = cmdextdir; 12.95 - } 12.96 - else searchpath = sunboot; 12.97 - } 12.98 - 12.99 - if(searchpath == sunboot){ 12.100 - if(System.getProperty("sun.boot.class.path") != null){ 12.101 - //search in sun.boot.class.path 12.102 - classpath = System.getProperty("sun.boot.class.path"); 12.103 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.104 - //no classes found in search path 12.105 - else searchpath = cmdextdir; 12.106 - } 12.107 - else searchpath = javaclass; 12.108 - } 12.109 - 12.110 - if(searchpath == javaclass){ 12.111 - if(System.getProperty("java.class.path") != null){ 12.112 - //search in java.class.path 12.113 - classpath =System.getProperty("java.class.path"); 12.114 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.115 - //no classes found in search path 12.116 - else searchpath = cmdextdir; 12.117 - } 12.118 - else searchpath = cmdextdir; 12.119 - } 12.120 - 12.121 - if(searchpath == cmdextdir){ 12.122 - if(extDirsString != null){ 12.123 - //search in specified extdir. 12.124 - classpath = extDirsString; 12.125 - extDirflag = true; 12.126 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.127 - //no classes found in search path 12.128 - else { 12.129 - searchpath = cmdclasspath; 12.130 - extDirflag = false; 12.131 - } 12.132 - } 12.133 - else searchpath = javaext; 12.134 - } 12.135 - 12.136 - if(searchpath == javaext){ 12.137 - if(System.getProperty("java.ext.dirs") != null){ 12.138 - //search in java.ext.dirs 12.139 - classpath = System.getProperty("java.ext.dirs"); 12.140 - extDirflag = true; 12.141 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.142 - //no classes found in search path 12.143 - else { 12.144 - searchpath = cmdclasspath; 12.145 - extDirflag = false; 12.146 - } 12.147 - } 12.148 - else searchpath = cmdclasspath; 12.149 - } 12.150 - if(searchpath == cmdclasspath){ 12.151 - if(classPathString != null){ 12.152 - //search in specified classpath. 12.153 - classpath = classPathString; 12.154 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.155 - //no classes found in search path 12.156 - else searchpath = 8; 12.157 - } 12.158 - else searchpath = envclasspath; 12.159 - } 12.160 - 12.161 - if(searchpath == envclasspath){ 12.162 - if(System.getProperty("env.class.path")!= null){ 12.163 - //search in env.class.path 12.164 - classpath = System.getProperty("env.class.path"); 12.165 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.166 - //no classes found in search path. 12.167 - else searchpath = javaclasspath; 12.168 - } 12.169 - else searchpath = javaclasspath; 12.170 - } 12.171 - 12.172 - if(searchpath == javaclasspath){ 12.173 - if(("application.home") == null){ 12.174 - //search in java.class.path 12.175 - classpath = System.getProperty("java.class.path"); 12.176 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.177 - //no classes found in search path. 12.178 - else searchpath = currentdir; 12.179 - } 12.180 - else searchpath = currentdir; 12.181 - } 12.182 - 12.183 - if(searchpath == currentdir){ 12.184 - classpath = "."; 12.185 - //search in current dir. 12.186 - if((fileInStream = resolvefilename(Name)) != null) return fileInStream; 12.187 - else { 12.188 - //no classes found in search path. 12.189 - error("Could not find "+ Name); 12.190 - System.exit(1); 12.191 - } 12.192 - } 12.193 - }catch(SecurityException excsec){ 12.194 - excsec.printStackTrace(); 12.195 - error("fatal exception"); 12.196 - }catch(NullPointerException excnull){ 12.197 - excnull.printStackTrace(); 12.198 - error("fatal exception"); 12.199 - }catch(IllegalArgumentException excill){ 12.200 - excill.printStackTrace(); 12.201 - error("fatal exception"); 12.202 - } 12.203 - 12.204 - return null; 12.205 - } 12.206 - 12.207 - 12.208 - public void error(String msg) { 12.209 - System.err.println("ERROR:" +msg); 12.210 - } 12.211 - 12.212 - /** 12.213 - * Resolves file name for classfile to disassemble. 12.214 - */ 12.215 - public InputStream resolvefilename(String name){ 12.216 - String classname = name.replace('.', '/') + ".class"; 12.217 - while (true) { 12.218 - InputStream instream = extDirflag 12.219 - ? resolveExdirFilename(classname) 12.220 - : resolveclasspath(classname); 12.221 - if (instream != null) 12.222 - return instream; 12.223 - int lastindex = classname.lastIndexOf('/'); 12.224 - if (lastindex == -1) return null; 12.225 - classname = classname.substring(0, lastindex) + "$" + 12.226 - classname.substring(lastindex + 1); 12.227 - } 12.228 - } 12.229 - 12.230 - /** 12.231 - * Resolves file name for classfile to disassemble if flag exdir is set. 12.232 - */ 12.233 - public InputStream resolveExdirFilename(String classname){ 12.234 - if(classpath.indexOf(File.pathSeparator) != -1){ 12.235 - //separates path 12.236 - StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator); 12.237 - while(st.hasMoreTokens()){ 12.238 - String path = st.nextToken(); 12.239 - InputStream in = resolveExdirFilenamehelper(path, classname); 12.240 - if (in != null) 12.241 - return in; 12.242 - } 12.243 - }else return (resolveExdirFilenamehelper(classpath, classname)); 12.244 - 12.245 - return null; 12.246 - } 12.247 - 12.248 - /** 12.249 - * Resolves file name for classfile to disassemble. 12.250 - */ 12.251 - public InputStream resolveclasspath(String classname){ 12.252 - if(classpath.indexOf(File.pathSeparator) != -1){ 12.253 - StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator); 12.254 - //separates path. 12.255 - while(st.hasMoreTokens()){ 12.256 - String path = (st.nextToken()).trim(); 12.257 - InputStream in = resolveclasspathhelper(path, classname); 12.258 - if(in != null) return in; 12.259 - 12.260 - } 12.261 - return null; 12.262 - } 12.263 - else return (resolveclasspathhelper(classpath, classname)); 12.264 - } 12.265 - 12.266 - 12.267 - /** 12.268 - * Returns file input stream for classfile to disassemble if exdir is set. 12.269 - */ 12.270 - public InputStream resolveExdirFilenamehelper(String path, String classname){ 12.271 - File fileobj = new File(path); 12.272 - if(fileobj.isDirectory()){ 12.273 - // gets list of files in that directory. 12.274 - File[] filelist = fileobj.listFiles(); 12.275 - for(int i = 0; i < filelist.length; i++){ 12.276 - try{ 12.277 - //file is a jar file. 12.278 - if(filelist[i].toString().endsWith(".jar")){ 12.279 - JarFile jfile = new JarFile(filelist[i]); 12.280 - if((jfile.getEntry(classname)) != null){ 12.281 - 12.282 - InputStream filein = jfile.getInputStream(jfile.getEntry(classname)); 12.283 - int bytearraysize = filein.available(); 12.284 - byte []b = new byte[bytearraysize]; 12.285 - int totalread = 0; 12.286 - while(totalread < bytearraysize){ 12.287 - totalread += filein.read(b, totalread, bytearraysize-totalread); 12.288 - } 12.289 - InputStream inbyte = new ByteArrayInputStream(b); 12.290 - filein.close(); 12.291 - return inbyte; 12.292 - } 12.293 - } else { 12.294 - //not a jar file. 12.295 - String filename = path+"/"+ classname; 12.296 - File file = new File(filename); 12.297 - if(file.isFile()){ 12.298 - return (new FileInputStream(file)); 12.299 - } 12.300 - } 12.301 - }catch(FileNotFoundException fnexce){ 12.302 - fnexce.printStackTrace(); 12.303 - error("cant read file"); 12.304 - error("fatal exception"); 12.305 - }catch(IOException ioexc){ 12.306 - ioexc.printStackTrace(); 12.307 - error("fatal exception"); 12.308 - } 12.309 - } 12.310 - } 12.311 - 12.312 - return null; 12.313 - } 12.314 - 12.315 - 12.316 - /** 12.317 - * Returns file input stream for classfile to disassemble. 12.318 - */ 12.319 - public InputStream resolveclasspathhelper(String path, String classname){ 12.320 - File fileobj = new File(path); 12.321 - try{ 12.322 - if(fileobj.isDirectory()){ 12.323 - //is a directory. 12.324 - String filename = path+"/"+ classname; 12.325 - File file = new File(filename); 12.326 - if(file.isFile()){ 12.327 - return (new FileInputStream(file)); 12.328 - } 12.329 - 12.330 - }else if(fileobj.isFile()){ 12.331 - if(fileobj.toString().endsWith(".jar")){ 12.332 - //is a jar file. 12.333 - JarFile jfile = new JarFile(fileobj); 12.334 - if((jfile.getEntry(classname)) != null){ 12.335 - InputStream filein = jfile.getInputStream(jfile.getEntry(classname)); 12.336 - int bytearraysize = filein.available(); 12.337 - byte []b = new byte[bytearraysize]; 12.338 - int totalread = 0; 12.339 - while(totalread < bytearraysize){ 12.340 - totalread += filein.read(b, totalread, bytearraysize-totalread); 12.341 - } 12.342 - InputStream inbyte = new ByteArrayInputStream(b); 12.343 - filein.close(); 12.344 - return inbyte; 12.345 - } 12.346 - } 12.347 - } 12.348 - }catch(FileNotFoundException fnexce){ 12.349 - fnexce.printStackTrace(); 12.350 - error("cant read file"); 12.351 - error("fatal exception"); 12.352 - }catch(IOException ioexce){ 12.353 - ioexce.printStackTrace(); 12.354 - error("fatal exception"); 12.355 - } 12.356 - return null; 12.357 - } 12.358 -}
13.1 --- a/src/share/classes/sun/tools/javap/JavapPrinter.java Thu May 28 09:49:56 2009 -0700 13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 13.3 @@ -1,919 +0,0 @@ 13.4 -/* 13.5 - * Copyright 2002-2009 Sun Microsystems, Inc. All Rights Reserved. 13.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 - * 13.8 - * This code is free software; you can redistribute it and/or modify it 13.9 - * under the terms of the GNU General Public License version 2 only, as 13.10 - * published by the Free Software Foundation. Sun designates this 13.11 - * particular file as subject to the "Classpath" exception as provided 13.12 - * by Sun in the LICENSE file that accompanied this code. 13.13 - * 13.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 13.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.17 - * version 2 for more details (a copy is included in the LICENSE file that 13.18 - * accompanied this code). 13.19 - * 13.20 - * You should have received a copy of the GNU General Public License version 13.21 - * 2 along with this work; if not, write to the Free Software Foundation, 13.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.23 - * 13.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 13.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 13.26 - * have any questions. 13.27 - */ 13.28 - 13.29 - 13.30 -package sun.tools.javap; 13.31 - 13.32 -import java.util.*; 13.33 -import java.io.*; 13.34 - 13.35 -import static sun.tools.javap.RuntimeConstants.*; 13.36 - 13.37 -/** 13.38 - * Program to print information about class files 13.39 - * 13.40 - * @author Sucheta Dambalkar 13.41 - */ 13.42 -public class JavapPrinter { 13.43 - JavapEnvironment env; 13.44 - ClassData cls; 13.45 - byte[] code; 13.46 - String lP= ""; 13.47 - PrintWriter out; 13.48 - 13.49 - public JavapPrinter(InputStream cname, PrintWriter out, JavapEnvironment env){ 13.50 - this.out = out; 13.51 - this.cls = new ClassData(cname); 13.52 - this.env = env; 13.53 - } 13.54 - 13.55 - /** 13.56 - * Entry point to print class file information. 13.57 - */ 13.58 - public void print(){ 13.59 - printclassHeader(); 13.60 - printfields(); 13.61 - printMethods(); 13.62 - printend(); 13.63 - } 13.64 - 13.65 - /** 13.66 - * Print a description of the class (not members). 13.67 - */ 13.68 - public void printclassHeader(){ 13.69 - String srcName=""; 13.70 - if ((srcName = cls.getSourceName()) != "null") // requires debug info 13.71 - out.println("Compiled from " + javaclassname(srcName)); 13.72 - 13.73 - if(cls.isInterface()) { 13.74 - // The only useful access modifier of an interface is 13.75 - // public; interfaces are always marked as abstract and 13.76 - // cannot be final. 13.77 - out.print((cls.isPublic()?"public ":"") + 13.78 - "interface "+ javaclassname(cls.getClassName())); 13.79 - } 13.80 - else if(cls.isClass()) { 13.81 - String []accflags = cls.getAccess(); 13.82 - printAccess(accflags); 13.83 - out.print("class "+ javaclassname(cls.getClassName())); 13.84 - 13.85 - if(cls.getSuperClassName() != null){ 13.86 - out.print(" extends " + javaclassname(cls.getSuperClassName())); 13.87 - } 13.88 - } 13.89 - 13.90 - String []interfacelist = cls.getSuperInterfaces(); 13.91 - if(interfacelist.length > 0){ 13.92 - if(cls.isClass()) { 13.93 - out.print(" implements "); 13.94 - } 13.95 - else if(cls.isInterface()){ 13.96 - out.print(" extends "); 13.97 - } 13.98 - 13.99 - for(int j = 0; j < interfacelist.length; j++){ 13.100 - out.print(javaclassname(interfacelist[j])); 13.101 - 13.102 - if((j+1) < interfacelist.length) { 13.103 - out.print(","); 13.104 - } 13.105 - } 13.106 - } 13.107 - 13.108 - // Print class attribute information. 13.109 - if((env.showallAttr) || (env.showVerbose)){ 13.110 - printClassAttributes(); 13.111 - } 13.112 - // Print verbose output. 13.113 - if(env.showVerbose){ 13.114 - printverbosecls(); 13.115 - } 13.116 - out.println("{"); 13.117 - } 13.118 - 13.119 - /** 13.120 - * Print verbose output. 13.121 - */ 13.122 - public void printverbosecls(){ 13.123 - out.println(" minor version: "+cls.getMinor_version()); 13.124 - out.println(" major version: "+cls.getMajor_version()); 13.125 - out.println(" Constant pool:"); 13.126 - printcp(); 13.127 - env.showallAttr = true; 13.128 - } 13.129 - 13.130 - /** 13.131 - * Print class attribute information. 13.132 - */ 13.133 - public void printClassAttributes(){ 13.134 - out.println(); 13.135 - AttrData[] clsattrs = cls.getAttributes(); 13.136 - for(int i = 0; i < clsattrs.length; i++){ 13.137 - String clsattrname = clsattrs[i].getAttrName(); 13.138 - if(clsattrname.equals("SourceFile")){ 13.139 - out.println(" SourceFile: "+ cls.getSourceName()); 13.140 - }else if(clsattrname.equals("InnerClasses")){ 13.141 - printInnerClasses(); 13.142 - }else { 13.143 - printAttrData(clsattrs[i]); 13.144 - } 13.145 - } 13.146 - } 13.147 - 13.148 - /** 13.149 - * Print the fields 13.150 - */ 13.151 - public void printfields(){ 13.152 - FieldData[] fields = cls.getFields(); 13.153 - for(int f = 0; f < fields.length; f++){ 13.154 - String[] accflags = fields[f].getAccess(); 13.155 - if(checkAccess(accflags)){ 13.156 - if(!(env. showLineAndLocal || env.showDisassembled || env.showVerbose 13.157 - || env.showInternalSigs || env.showallAttr)){ 13.158 - out.print(" "); 13.159 - } 13.160 - printAccess(accflags); 13.161 - out.println(fields[f].getType()+" " +fields[f].getName()+";"); 13.162 - if (env.showInternalSigs) { 13.163 - out.println(" Signature: " + (fields[f].getInternalSig())); 13.164 - } 13.165 - 13.166 - // print field attribute information. 13.167 - if (env.showallAttr){ 13.168 - printFieldAttributes(fields[f]); 13.169 - 13.170 - } 13.171 - if((env.showDisassembled) || (env.showLineAndLocal)){ 13.172 - out.println(); 13.173 - } 13.174 - } 13.175 - } 13.176 - } 13.177 - 13.178 - 13.179 - /* print field attribute information. */ 13.180 - public void printFieldAttributes(FieldData field){ 13.181 - Vector<?> fieldattrs = field.getAttributes(); 13.182 - for(int j = 0; j < fieldattrs.size(); j++){ 13.183 - String fieldattrname = ((AttrData)fieldattrs.elementAt(j)).getAttrName(); 13.184 - if(fieldattrname.equals("ConstantValue")){ 13.185 - printConstantValue(field); 13.186 - }else if (fieldattrname.equals("Deprecated")){ 13.187 - out.println("Deprecated: "+ field.isDeprecated()); 13.188 - }else if (fieldattrname.equals("Synthetic")){ 13.189 - out.println(" Synthetic: "+ field.isSynthetic()); 13.190 - }else { 13.191 - printAttrData((AttrData)fieldattrs.elementAt(j)); 13.192 - } 13.193 - } 13.194 - out.println(); 13.195 - } 13.196 - 13.197 - /** 13.198 - * Print the methods 13.199 - */ 13.200 - public void printMethods(){ 13.201 - MethodData[] methods = cls.getMethods(); 13.202 - for(int m = 0; m < methods.length; m++){ 13.203 - String[] accflags = methods[m].getAccess(); 13.204 - if(checkAccess(accflags)){ 13.205 - if(!(env. showLineAndLocal || env.showDisassembled || env.showVerbose 13.206 - || env.showInternalSigs || env.showallAttr)){ 13.207 - out.print(" "); 13.208 - } 13.209 - printMethodSignature(methods[m], accflags); 13.210 - printExceptions(methods[m]); 13.211 - out.println(";"); 13.212 - 13.213 - // Print internal signature of method. 13.214 - if (env.showInternalSigs){ 13.215 - out.println(" Signature: " + (methods[m].getInternalSig())); 13.216 - } 13.217 - 13.218 - //Print disassembled code. 13.219 - if(env.showDisassembled && ! env.showallAttr) { 13.220 - printcodeSequence(methods[m]); 13.221 - printExceptionTable(methods[m]); 13.222 - out.println(); 13.223 - } 13.224 - 13.225 - // Print line and local variable attribute information. 13.226 - if (env.showLineAndLocal) { 13.227 - printLineNumTable(methods[m]); 13.228 - printLocVarTable(methods[m]); 13.229 - out.println(); 13.230 - } 13.231 - 13.232 - // Print method attribute information. 13.233 - if (env.showallAttr){ 13.234 - printMethodAttributes(methods[m]); 13.235 - } 13.236 - } 13.237 - } 13.238 - } 13.239 - 13.240 - /** 13.241 - * Print method signature. 13.242 - */ 13.243 - public void printMethodSignature(MethodData method, String[] accflags){ 13.244 - printAccess(accflags); 13.245 - 13.246 - if((method.getName()).equals("<init>")){ 13.247 - out.print(javaclassname(cls.getClassName())); 13.248 - out.print(method.getParameters()); 13.249 - }else if((method.getName()).equals("<clinit>")){ 13.250 - out.print("{}"); 13.251 - }else{ 13.252 - out.print(method.getReturnType()+" "); 13.253 - out.print(method.getName()); 13.254 - out.print(method.getParameters()); 13.255 - } 13.256 - } 13.257 - 13.258 - /** 13.259 - * print method attribute information. 13.260 - */ 13.261 - public void printMethodAttributes(MethodData method){ 13.262 - Vector<?> methodattrs = method.getAttributes(); 13.263 - Vector<?> codeattrs = method.getCodeAttributes(); 13.264 - for(int k = 0; k < methodattrs.size(); k++){ 13.265 - String methodattrname = ((AttrData)methodattrs.elementAt(k)).getAttrName(); 13.266 - if(methodattrname.equals("Code")){ 13.267 - printcodeSequence(method); 13.268 - printExceptionTable(method); 13.269 - for(int c = 0; c < codeattrs.size(); c++){ 13.270 - String codeattrname = ((AttrData)codeattrs.elementAt(c)).getAttrName(); 13.271 - if(codeattrname.equals("LineNumberTable")){ 13.272 - printLineNumTable(method); 13.273 - }else if(codeattrname.equals("LocalVariableTable")){ 13.274 - printLocVarTable(method); 13.275 - }else if(codeattrname.equals("StackMapTable")) { 13.276 - // Java SE JSR 202 stack map tables 13.277 - printStackMapTable(method); 13.278 - }else if(codeattrname.equals("StackMap")) { 13.279 - // Java ME CLDC stack maps 13.280 - printStackMap(method); 13.281 - } else { 13.282 - printAttrData((AttrData)codeattrs.elementAt(c)); 13.283 - } 13.284 - } 13.285 - }else if(methodattrname.equals("Exceptions")){ 13.286 - out.println(" Exceptions: "); 13.287 - printExceptions(method); 13.288 - }else if (methodattrname.equals("Deprecated")){ 13.289 - out.println(" Deprecated: "+ method.isDeprecated()); 13.290 - }else if (methodattrname.equals("Synthetic")){ 13.291 - out.println(" Synthetic: "+ method.isSynthetic()); 13.292 - }else { 13.293 - printAttrData((AttrData)methodattrs.elementAt(k)); 13.294 - } 13.295 - } 13.296 - out.println(); 13.297 - } 13.298 - 13.299 - /** 13.300 - * Print exceptions. 13.301 - */ 13.302 - public void printExceptions(MethodData method){ 13.303 - int []exc_index_table = method.get_exc_index_table(); 13.304 - if (exc_index_table != null) { 13.305 - if(!(env. showLineAndLocal || env.showDisassembled || env.showVerbose 13.306 - || env.showInternalSigs || env.showallAttr)){ 13.307 - out.print(" "); 13.308 - } 13.309 - out.print(" throws "); 13.310 - int k; 13.311 - int l = exc_index_table.length; 13.312 - 13.313 - for (k=0; k<l; k++) { 13.314 - out.print(javaclassname(cls.getClassName(exc_index_table[k]))); 13.315 - if (k<l-1) out.print(", "); 13.316 - } 13.317 - } 13.318 - } 13.319 - 13.320 - /** 13.321 - * Print code sequence. 13.322 - */ 13.323 - public void printcodeSequence(MethodData method){ 13.324 - code = method.getCode(); 13.325 - if(code != null){ 13.326 - out.println(" Code:"); 13.327 - if(env.showVerbose){ 13.328 - printVerboseHeader(method); 13.329 - } 13.330 - 13.331 - for (int pc=0; pc < code.length; ) { 13.332 - out.print(" "+pc+":\t"); 13.333 - pc=pc+printInstr(pc); 13.334 - out.println(); 13.335 - } 13.336 - } 13.337 - } 13.338 - 13.339 - /** 13.340 - * Print instructions. 13.341 - */ 13.342 - public int printInstr(int pc){ 13.343 - int opcode = getUbyte(pc); 13.344 - int opcode2; 13.345 - String mnem; 13.346 - switch (opcode) { 13.347 - case opc_nonpriv: 13.348 - case opc_priv: 13.349 - opcode2 = getUbyte(pc+1); 13.350 - mnem=Tables.opcName((opcode<<8)+opcode2); 13.351 - if (mnem==null) 13.352 - // assume all (even nonexistent) priv and nonpriv instructions 13.353 - // are 2 bytes long 13.354 - mnem=Tables.opcName(opcode)+" "+opcode2; 13.355 - out.print(mnem); 13.356 - return 2; 13.357 - case opc_wide: { 13.358 - opcode2 = getUbyte(pc+1); 13.359 - mnem=Tables.opcName((opcode<<8)+opcode2); 13.360 - if (mnem==null) { 13.361 - // nonexistent opcode - but we have to print something 13.362 - out.print("bytecode "+opcode); 13.363 - return 1; 13.364 - } 13.365 - out.print(mnem+" "+getUShort(pc+2)); 13.366 - if (opcode2==opc_iinc) { 13.367 - out.print(", "+getShort(pc+4)); 13.368 - return 6; 13.369 - } 13.370 - return 4; 13.371 - } 13.372 - } 13.373 - mnem=Tables.opcName(opcode); 13.374 - if (mnem==null) { 13.375 - // nonexistent opcode - but we have to print something 13.376 - out.print("bytecode "+opcode); 13.377 - return 1; 13.378 - } 13.379 - if (opcode>opc_jsr_w) { 13.380 - // pseudo opcodes should be printed as bytecodes 13.381 - out.print("bytecode "+opcode); 13.382 - return 1; 13.383 - } 13.384 - out.print(Tables.opcName(opcode)); 13.385 - switch (opcode) { 13.386 - case opc_aload: case opc_astore: 13.387 - case opc_fload: case opc_fstore: 13.388 - case opc_iload: case opc_istore: 13.389 - case opc_lload: case opc_lstore: 13.390 - case opc_dload: case opc_dstore: 13.391 - case opc_ret: 13.392 - out.print("\t"+getUbyte(pc+1)); 13.393 - return 2; 13.394 - case opc_iinc: 13.395 - out.print("\t"+getUbyte(pc+1)+", "+getbyte(pc+2)); 13.396 - return 3; 13.397 - case opc_tableswitch:{ 13.398 - int tb=align(pc+1); 13.399 - int default_skip = getInt(tb); /* default skip pamount */ 13.400 - int low = getInt(tb+4); 13.401 - int high = getInt(tb+8); 13.402 - int count = high - low; 13.403 - out.print("{ //"+low+" to "+high); 13.404 - for (int i = 0; i <= count; i++) 13.405 - out.print( "\n\t\t" + (i+low) + ": "+lP+(pc+getInt(tb+12+4*i))+";"); 13.406 - out.print("\n\t\tdefault: "+lP+(default_skip + pc) + " }"); 13.407 - return tb-pc+16+count*4; 13.408 - } 13.409 - 13.410 - case opc_lookupswitch:{ 13.411 - int tb=align(pc+1); 13.412 - int default_skip = getInt(tb); 13.413 - int npairs = getInt(tb+4); 13.414 - out.print("{ //"+npairs); 13.415 - for (int i = 1; i <= npairs; i++) 13.416 - out.print("\n\t\t"+getInt(tb+i*8) 13.417 - +": "+lP+(pc+getInt(tb+4+i*8))+";" 13.418 - ); 13.419 - out.print("\n\t\tdefault: "+lP+(default_skip + pc) + " }"); 13.420 - return tb-pc+(npairs+1)*8; 13.421 - } 13.422 - case opc_newarray: 13.423 - int type=getUbyte(pc+1); 13.424 - switch (type) { 13.425 - case T_BOOLEAN:out.print(" boolean");break; 13.426 - case T_BYTE: out.print(" byte"); break; 13.427 - case T_CHAR: out.print(" char"); break; 13.428 - case T_SHORT: out.print(" short"); break; 13.429 - case T_INT: out.print(" int"); break; 13.430 - case T_LONG: out.print(" long"); break; 13.431 - case T_FLOAT: out.print(" float"); break; 13.432 - case T_DOUBLE: out.print(" double"); break; 13.433 - case T_CLASS: out.print(" class"); break; 13.434 - default: out.print(" BOGUS TYPE:"+type); 13.435 - } 13.436 - return 2; 13.437 - 13.438 - case opc_anewarray: { 13.439 - int index = getUShort(pc+1); 13.440 - out.print("\t#"+index+"; //"); 13.441 - PrintConstant(index); 13.442 - return 3; 13.443 - } 13.444 - 13.445 - case opc_sipush: 13.446 - out.print("\t"+getShort(pc+1)); 13.447 - return 3; 13.448 - 13.449 - case opc_bipush: 13.450 - out.print("\t"+getbyte(pc+1)); 13.451 - return 2; 13.452 - 13.453 - case opc_ldc: { 13.454 - int index = getUbyte(pc+1); 13.455 - out.print("\t#"+index+"; //"); 13.456 - PrintConstant(index); 13.457 - return 2; 13.458 - } 13.459 - 13.460 - case opc_ldc_w: case opc_ldc2_w: 13.461 - case opc_instanceof: case opc_checkcast: 13.462 - case opc_new: 13.463 - case opc_putstatic: case opc_getstatic: 13.464 - case opc_putfield: case opc_getfield: 13.465 - case opc_invokevirtual: 13.466 - case opc_invokespecial: 13.467 - case opc_invokestatic: { 13.468 - int index = getUShort(pc+1); 13.469 - out.print("\t#"+index+"; //"); 13.470 - PrintConstant(index); 13.471 - return 3; 13.472 - } 13.473 - 13.474 - case opc_invokeinterface: { 13.475 - int index = getUShort(pc+1), nargs=getUbyte(pc+3); 13.476 - out.print("\t#"+index+", "+nargs+"; //"); 13.477 - PrintConstant(index); 13.478 - return 5; 13.479 - } 13.480 - 13.481 - case opc_invokedynamic: { 13.482 - int index = getUShort(pc+1); 13.483 - out.print("\t#"+index+"; //"); 13.484 - PrintConstant(index); 13.485 - return 5; 13.486 - } 13.487 - 13.488 - case opc_multianewarray: { 13.489 - int index = getUShort(pc+1), dimensions=getUbyte(pc+3); 13.490 - out.print("\t#"+index+", "+dimensions+"; //"); 13.491 - PrintConstant(index); 13.492 - return 4; 13.493 - } 13.494 - case opc_jsr: case opc_goto: 13.495 - case opc_ifeq: case opc_ifge: case opc_ifgt: 13.496 - case opc_ifle: case opc_iflt: case opc_ifne: 13.497 - case opc_if_icmpeq: case opc_if_icmpne: case opc_if_icmpge: 13.498 - case opc_if_icmpgt: case opc_if_icmple: case opc_if_icmplt: 13.499 - case opc_if_acmpeq: case opc_if_acmpne: 13.500 - case opc_ifnull: case opc_ifnonnull: 13.501 - out.print("\t"+lP+(pc + getShort(pc+1)) ); 13.502 - return 3; 13.503 - 13.504 - case opc_jsr_w: 13.505 - case opc_goto_w: 13.506 - out.print("\t"+lP+(pc + getInt(pc+1))); 13.507 - return 5; 13.508 - 13.509 - default: 13.510 - return 1; 13.511 - } 13.512 - } 13.513 - /** 13.514 - * Print code attribute details. 13.515 - */ 13.516 - public void printVerboseHeader(MethodData method) { 13.517 - int argCount = method.getArgumentlength(); 13.518 - if (!method.isStatic()) 13.519 - ++argCount; // for 'this' 13.520 - 13.521 - out.println(" Stack=" + method.getMaxStack() 13.522 - + ", Locals=" + method.getMaxLocals() 13.523 - + ", Args_size=" + argCount); 13.524 - 13.525 - } 13.526 - 13.527 - 13.528 - /** 13.529 - * Print the exception table for this method code 13.530 - */ 13.531 - void printExceptionTable(MethodData method){//throws IOException 13.532 - Vector<?> exception_table = method.getexception_table(); 13.533 - if (exception_table.size() > 0) { 13.534 - out.println(" Exception table:"); 13.535 - out.println(" from to target type"); 13.536 - for (int idx = 0; idx < exception_table.size(); ++idx) { 13.537 - TrapData handler = (TrapData)exception_table.elementAt(idx); 13.538 - printFixedWidthInt(handler.start_pc, 6); 13.539 - printFixedWidthInt(handler.end_pc, 6); 13.540 - printFixedWidthInt(handler.handler_pc, 6); 13.541 - out.print(" "); 13.542 - int catch_cpx = handler.catch_cpx; 13.543 - if (catch_cpx == 0) { 13.544 - out.println("any"); 13.545 - }else { 13.546 - out.print("Class "); 13.547 - out.println(cls.getClassName(catch_cpx)); 13.548 - out.println(""); 13.549 - } 13.550 - } 13.551 - } 13.552 - } 13.553 - 13.554 - /** 13.555 - * Print LineNumberTable attribute information. 13.556 - */ 13.557 - public void printLineNumTable(MethodData method) { 13.558 - int numlines = method.getnumlines(); 13.559 - Vector<?> lin_num_tb = method.getlin_num_tb(); 13.560 - if( lin_num_tb.size() > 0){ 13.561 - out.println(" LineNumberTable: "); 13.562 - for (int i=0; i<numlines; i++) { 13.563 - LineNumData linnumtb_entry=(LineNumData)lin_num_tb.elementAt(i); 13.564 - out.println(" line " + linnumtb_entry.line_number + ": " 13.565 - + linnumtb_entry.start_pc); 13.566 - } 13.567 - } 13.568 - out.println(); 13.569 - } 13.570 - 13.571 - /** 13.572 - * Print LocalVariableTable attribute information. 13.573 - */ 13.574 - public void printLocVarTable(MethodData method){ 13.575 - int siz = method.getloc_var_tbsize(); 13.576 - if(siz > 0){ 13.577 - out.println(" LocalVariableTable: "); 13.578 - out.print(" "); 13.579 - out.println("Start Length Slot Name Signature"); 13.580 - } 13.581 - Vector<?> loc_var_tb = method.getloc_var_tb(); 13.582 - 13.583 - for (int i=0; i<siz; i++) { 13.584 - LocVarData entry=(LocVarData)loc_var_tb.elementAt(i); 13.585 - 13.586 - out.println(" "+entry.start_pc+" "+entry.length+" "+ 13.587 - entry.slot+" "+cls.StringValue(entry.name_cpx) + 13.588 - " "+cls.StringValue(entry.sig_cpx)); 13.589 - } 13.590 - out.println(); 13.591 - } 13.592 - 13.593 - /** 13.594 - * Print StackMap attribute information. 13.595 - */ 13.596 - public void printStackMap(MethodData method) { 13.597 - StackMapData[] stack_map_tb = method.getStackMap(); 13.598 - int number_of_entries = stack_map_tb.length; 13.599 - if (number_of_entries > 0) { 13.600 - out.println(" StackMap: number_of_entries = " + number_of_entries); 13.601 - 13.602 - for (StackMapData frame : stack_map_tb) { 13.603 - frame.print(this); 13.604 - } 13.605 - } 13.606 - out.println(); 13.607 - } 13.608 - 13.609 - /** 13.610 - * Print StackMapTable attribute information. 13.611 - */ 13.612 - public void printStackMapTable(MethodData method) { 13.613 - StackMapTableData[] stack_map_tb = method.getStackMapTable(); 13.614 - int number_of_entries = stack_map_tb.length; 13.615 - if (number_of_entries > 0) { 13.616 - out.println(" StackMapTable: number_of_entries = " + number_of_entries); 13.617 - 13.618 - for (StackMapTableData frame : stack_map_tb) { 13.619 - frame.print(this); 13.620 - } 13.621 - } 13.622 - out.println(); 13.623 - } 13.624 - 13.625 - void printMap(String name, int[] map) { 13.626 - out.print(name); 13.627 - for (int i=0; i<map.length; i++) { 13.628 - int fulltype = map[i]; 13.629 - int type = fulltype & 0xFF; 13.630 - int argument = fulltype >> 8; 13.631 - switch (type) { 13.632 - case ITEM_Object: 13.633 - out.print(" "); 13.634 - PrintConstant(argument); 13.635 - break; 13.636 - case ITEM_NewObject: 13.637 - out.print(" " + Tables.mapTypeName(type)); 13.638 - out.print(" " + argument); 13.639 - break; 13.640 - default: 13.641 - out.print(" " + Tables.mapTypeName(type)); 13.642 - } 13.643 - out.print( (i==(map.length-1)? ' ' : ',')); 13.644 - } 13.645 - out.println("]"); 13.646 - } 13.647 - 13.648 - /** 13.649 - * Print ConstantValue attribute information. 13.650 - */ 13.651 - public void printConstantValue(FieldData field){ 13.652 - out.print(" Constant value: "); 13.653 - int cpx = (field.getConstantValueIndex()); 13.654 - byte tag=0; 13.655 - try { 13.656 - tag=cls.getTag(cpx); 13.657 - 13.658 - } catch (IndexOutOfBoundsException e) { 13.659 - out.print("Error:"); 13.660 - return; 13.661 - } 13.662 - switch (tag) { 13.663 - case CONSTANT_METHOD: 13.664 - case CONSTANT_INTERFACEMETHOD: 13.665 - case CONSTANT_FIELD: { 13.666 - CPX2 x = cls.getCpoolEntry(cpx); 13.667 - if (x.cpx1 == cls.getthis_cpx()) { 13.668 - // don't print class part for local references 13.669 - cpx=x.cpx2; 13.670 - } 13.671 - } 13.672 - } 13.673 - out.print(cls.TagString(tag)+" "+ cls.StringValue(cpx)); 13.674 - } 13.675 - 13.676 - /** 13.677 - * Print InnerClass attribute information. 13.678 - */ 13.679 - public void printInnerClasses(){//throws ioexception 13.680 - 13.681 - InnerClassData[] innerClasses = cls.getInnerClasses(); 13.682 - if(innerClasses != null){ 13.683 - if(innerClasses.length > 0){ 13.684 - out.print(" "); 13.685 - out.println("InnerClass: "); 13.686 - for(int i = 0 ; i < innerClasses.length; i++){ 13.687 - out.print(" "); 13.688 - //access 13.689 - String[] accflags = innerClasses[i].getAccess(); 13.690 - if(checkAccess(accflags)){ 13.691 - printAccess(accflags); 13.692 - if (innerClasses[i].inner_name_index!=0) { 13.693 - out.print("#"+innerClasses[i].inner_name_index+"= "); 13.694 - } 13.695 - out.print("#"+innerClasses[i].inner_class_info_index); 13.696 - if (innerClasses[i].outer_class_info_index!=0) { 13.697 - out.print(" of #"+innerClasses[i].outer_class_info_index); 13.698 - } 13.699 - out.print("; //"); 13.700 - if (innerClasses[i].inner_name_index!=0) { 13.701 - out.print(cls.getName(innerClasses[i].inner_name_index)+"="); 13.702 - } 13.703 - PrintConstant(innerClasses[i].inner_class_info_index); 13.704 - if (innerClasses[i].outer_class_info_index!=0) { 13.705 - out.print(" of "); 13.706 - PrintConstant(innerClasses[i].outer_class_info_index); 13.707 - } 13.708 - out.println(); 13.709 - } 13.710 - } 13.711 - 13.712 - } 13.713 - } 13.714 - } 13.715 - 13.716 - /** 13.717 - * Print constant pool information. 13.718 - */ 13.719 - public void printcp(){ 13.720 - int cpx = 1 ; 13.721 - 13.722 - while (cpx < cls.getCpoolCount()) { 13.723 - out.print("const #"+cpx+" = "); 13.724 - cpx+=PrintlnConstantEntry(cpx); 13.725 - } 13.726 - out.println(); 13.727 - } 13.728 - 13.729 - /** 13.730 - * Print constant pool entry information. 13.731 - */ 13.732 - @SuppressWarnings("fallthrough") 13.733 - public int PrintlnConstantEntry(int cpx) { 13.734 - int size=1; 13.735 - byte tag=0; 13.736 - try { 13.737 - tag=cls.getTag(cpx); 13.738 - } catch (IndexOutOfBoundsException e) { 13.739 - out.println(" <Incorrect CP index>"); 13.740 - return 1; 13.741 - } 13.742 - out.print(cls.StringTag(cpx)+"\t"); 13.743 - Object x=cls.getCpoolEntryobj(cpx); 13.744 - if (x==null) { 13.745 - switch (tag) { 13.746 - case CONSTANT_LONG: 13.747 - case CONSTANT_DOUBLE: 13.748 - size=2; 13.749 - } 13.750 - out.println("null;"); 13.751 - return size; 13.752 - } 13.753 - String str=cls.StringValue(cpx); 13.754 - 13.755 - switch (tag) { 13.756 - case CONSTANT_CLASS: 13.757 - case CONSTANT_STRING: 13.758 - out.println("#"+(((CPX)x).cpx)+";\t// "+str); 13.759 - break; 13.760 - case CONSTANT_FIELD: 13.761 - case CONSTANT_METHOD: 13.762 - case CONSTANT_INTERFACEMETHOD: 13.763 - out.println("#"+((CPX2)x).cpx1+".#"+((CPX2)x).cpx2+";\t// "+str); 13.764 - break; 13.765 - case CONSTANT_NAMEANDTYPE: 13.766 - out.println("#"+((CPX2)x).cpx1+":#"+((CPX2)x).cpx2+";// "+str); 13.767 - break; 13.768 - case CONSTANT_LONG: 13.769 - case CONSTANT_DOUBLE: 13.770 - size=2; 13.771 - // fall through 13.772 - default: 13.773 - out.println(str+";"); 13.774 - } 13.775 - return size; 13.776 - } 13.777 - 13.778 - /** 13.779 - * Checks access of class, field or method. 13.780 - */ 13.781 - public boolean checkAccess(String accflags[]){ 13.782 - 13.783 - boolean ispublic = false; 13.784 - boolean isprotected = false; 13.785 - boolean isprivate = false; 13.786 - boolean ispackage = false; 13.787 - 13.788 - for(int i= 0; i < accflags.length; i++){ 13.789 - if(accflags[i].equals("public")) ispublic = true; 13.790 - else if (accflags[i].equals("protected")) isprotected = true; 13.791 - else if (accflags[i].equals("private")) isprivate = true; 13.792 - } 13.793 - 13.794 - if(!(ispublic || isprotected || isprivate)) ispackage = true; 13.795 - 13.796 - if((env.showAccess == env.PUBLIC) && (isprotected || isprivate || ispackage)) return false; 13.797 - else if((env.showAccess == env.PROTECTED) && (isprivate || ispackage)) return false; 13.798 - else if((env.showAccess == env.PACKAGE) && (isprivate)) return false; 13.799 - else return true; 13.800 - } 13.801 - 13.802 - /** 13.803 - * Prints access of class, field or method. 13.804 - */ 13.805 - public void printAccess(String []accflags){ 13.806 - for(int j = 0; j < accflags.length; j++){ 13.807 - out.print(accflags[j]+" "); 13.808 - } 13.809 - } 13.810 - 13.811 - /** 13.812 - * Print an integer so that it takes 'length' characters in 13.813 - * the output. Temporary until formatting code is stable. 13.814 - */ 13.815 - public void printFixedWidthInt(long x, int length) { 13.816 - CharArrayWriter baStream = new CharArrayWriter(); 13.817 - PrintWriter pStream = new PrintWriter(baStream); 13.818 - pStream.print(x); 13.819 - String str = baStream.toString(); 13.820 - for (int cnt = length - str.length(); cnt > 0; --cnt) 13.821 - out.print(' '); 13.822 - out.print(str); 13.823 - } 13.824 - 13.825 - protected int getbyte (int pc) { 13.826 - return code[pc]; 13.827 - } 13.828 - 13.829 - protected int getUbyte (int pc) { 13.830 - return code[pc]&0xFF; 13.831 - } 13.832 - 13.833 - int getShort (int pc) { 13.834 - return (code[pc]<<8) | (code[pc+1]&0xFF); 13.835 - } 13.836 - 13.837 - int getUShort (int pc) { 13.838 - return ((code[pc]<<8) | (code[pc+1]&0xFF))&0xFFFF; 13.839 - } 13.840 - 13.841 - protected int getInt (int pc) { 13.842 - return (getShort(pc)<<16) | (getShort(pc+2)&0xFFFF); 13.843 - } 13.844 - 13.845 - /** 13.846 - * Print constant value at that index. 13.847 - */ 13.848 - void PrintConstant(int cpx) { 13.849 - if (cpx==0) { 13.850 - out.print("#0"); 13.851 - return; 13.852 - } 13.853 - byte tag=0; 13.854 - try { 13.855 - tag=cls.getTag(cpx); 13.856 - 13.857 - } catch (IndexOutOfBoundsException e) { 13.858 - out.print("#"+cpx); 13.859 - return; 13.860 - } 13.861 - switch (tag) { 13.862 - case CONSTANT_METHOD: 13.863 - case CONSTANT_INTERFACEMETHOD: 13.864 - case CONSTANT_FIELD: { 13.865 - // CPX2 x=(CPX2)(cpool[cpx]); 13.866 - CPX2 x = cls.getCpoolEntry(cpx); 13.867 - if (x.cpx1 == cls.getthis_cpx()) { 13.868 - // don't print class part for local references 13.869 - cpx=x.cpx2; 13.870 - } 13.871 - } 13.872 - } 13.873 - out.print(cls.TagString(tag)+" "+ cls.StringValue(cpx)); 13.874 - } 13.875 - 13.876 - protected static int align (int n) { 13.877 - return (n+3) & ~3 ; 13.878 - } 13.879 - 13.880 - public void printend(){ 13.881 - out.println("}"); 13.882 - out.println(); 13.883 - } 13.884 - 13.885 - public String javaclassname(String name){ 13.886 - return name.replace('/','.'); 13.887 - } 13.888 - 13.889 - /** 13.890 - * Print attribute data in hex. 13.891 - */ 13.892 - public void printAttrData(AttrData attr){ 13.893 - byte []data = attr.getData(); 13.894 - int i = 0; 13.895 - int j = 0; 13.896 - out.print(" "+attr.getAttrName()+": "); 13.897 - out.println("length = " + cls.toHex(attr.datalen)); 13.898 - 13.899 - out.print(" "); 13.900 - 13.901 - 13.902 - while (i < data.length){ 13.903 - String databytestring = cls.toHex(data[i]); 13.904 - if(databytestring.equals("0x")) out.print("00"); 13.905 - else if(databytestring.substring(2).length() == 1){ 13.906 - out.print("0"+databytestring.substring(2)); 13.907 - } else{ 13.908 - out.print(databytestring.substring(2)); 13.909 - } 13.910 - 13.911 - j++; 13.912 - if(j == 16) { 13.913 - out.println(); 13.914 - out.print(" "); 13.915 - j = 0; 13.916 - } 13.917 - else out.print(" "); 13.918 - i++; 13.919 - } 13.920 - out.println(); 13.921 - } 13.922 -}
14.1 --- a/src/share/classes/sun/tools/javap/LineNumData.java Thu May 28 09:49:56 2009 -0700 14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 14.3 @@ -1,50 +0,0 @@ 14.4 -/* 14.5 - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 14.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 - * 14.8 - * This code is free software; you can redistribute it and/or modify it 14.9 - * under the terms of the GNU General Public License version 2 only, as 14.10 - * published by the Free Software Foundation. Sun designates this 14.11 - * particular file as subject to the "Classpath" exception as provided 14.12 - * by Sun in the LICENSE file that accompanied this code. 14.13 - * 14.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 14.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.17 - * version 2 for more details (a copy is included in the LICENSE file that 14.18 - * accompanied this code). 14.19 - * 14.20 - * You should have received a copy of the GNU General Public License version 14.21 - * 2 along with this work; if not, write to the Free Software Foundation, 14.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.23 - * 14.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 14.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 14.26 - * have any questions. 14.27 - */ 14.28 - 14.29 - 14.30 -package sun.tools.javap; 14.31 - 14.32 -import java.util.*; 14.33 -import java.io.*; 14.34 - 14.35 -/** 14.36 - * Strores LineNumberTable data information. 14.37 - * 14.38 - * @author Sucheta Dambalkar (Adopted code from jdis) 14.39 - */ 14.40 -class LineNumData { 14.41 - short start_pc, line_number; 14.42 - 14.43 - public LineNumData() {} 14.44 - 14.45 - /** 14.46 - * Read LineNumberTable attribute. 14.47 - */ 14.48 - public LineNumData(DataInputStream in) throws IOException { 14.49 - start_pc = in.readShort(); 14.50 - line_number=in.readShort(); 14.51 - 14.52 - } 14.53 -}
15.1 --- a/src/share/classes/sun/tools/javap/LocVarData.java Thu May 28 09:49:56 2009 -0700 15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 15.3 @@ -1,54 +0,0 @@ 15.4 -/* 15.5 - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 15.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 - * 15.8 - * This code is free software; you can redistribute it and/or modify it 15.9 - * under the terms of the GNU General Public License version 2 only, as 15.10 - * published by the Free Software Foundation. Sun designates this 15.11 - * particular file as subject to the "Classpath" exception as provided 15.12 - * by Sun in the LICENSE file that accompanied this code. 15.13 - * 15.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 15.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.17 - * version 2 for more details (a copy is included in the LICENSE file that 15.18 - * accompanied this code). 15.19 - * 15.20 - * You should have received a copy of the GNU General Public License version 15.21 - * 2 along with this work; if not, write to the Free Software Foundation, 15.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.23 - * 15.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 15.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 15.26 - * have any questions. 15.27 - */ 15.28 - 15.29 - 15.30 -package sun.tools.javap; 15.31 - 15.32 -import java.util.*; 15.33 -import java.io.*; 15.34 - 15.35 -/** 15.36 - * Strores LocalVariableTable data information. 15.37 - * 15.38 - * @author Sucheta Dambalkar (Adopted code from jdis) 15.39 - */ 15.40 -class LocVarData { 15.41 - short start_pc, length, name_cpx, sig_cpx, slot; 15.42 - 15.43 - public LocVarData() { 15.44 - } 15.45 - 15.46 - /** 15.47 - * Read LocalVariableTable attribute. 15.48 - */ 15.49 - public LocVarData(DataInputStream in) throws IOException { 15.50 - start_pc = in.readShort(); 15.51 - length=in.readShort(); 15.52 - name_cpx=in.readShort(); 15.53 - sig_cpx=in.readShort(); 15.54 - slot=in.readShort(); 15.55 - 15.56 - } 15.57 -}
16.1 --- a/src/share/classes/sun/tools/javap/Main.java Thu May 28 09:49:56 2009 -0700 16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 16.3 @@ -1,224 +0,0 @@ 16.4 -/* 16.5 - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. 16.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.7 - * 16.8 - * This code is free software; you can redistribute it and/or modify it 16.9 - * under the terms of the GNU General Public License version 2 only, as 16.10 - * published by the Free Software Foundation. Sun designates this 16.11 - * particular file as subject to the "Classpath" exception as provided 16.12 - * by Sun in the LICENSE file that accompanied this code. 16.13 - * 16.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 16.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16.17 - * version 2 for more details (a copy is included in the LICENSE file that 16.18 - * accompanied this code). 16.19 - * 16.20 - * You should have received a copy of the GNU General Public License version 16.21 - * 2 along with this work; if not, write to the Free Software Foundation, 16.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 16.23 - * 16.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 16.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 16.26 - * have any questions. 16.27 - */ 16.28 - 16.29 - 16.30 - 16.31 -package sun.tools.javap; 16.32 - 16.33 -import java.util.*; 16.34 -import java.io.*; 16.35 - 16.36 -/** 16.37 - * Entry point for javap, class file disassembler. 16.38 - * 16.39 - * @author Sucheta Dambalkar (Adopted code from old javap) 16.40 - */ 16.41 -public class Main { 16.42 - 16.43 - private Vector<String> classList = new Vector<String>(); 16.44 - private PrintWriter out; 16.45 - JavapEnvironment env = new JavapEnvironment(); 16.46 - private static boolean errorOccurred = false; 16.47 - private static final String progname = "javap"; 16.48 - 16.49 - 16.50 - public Main(PrintWriter out){ 16.51 - this.out = out; 16.52 - } 16.53 - 16.54 - public static void main(String argv[]) { 16.55 - // unless first arg is -Xold, use new javap 16.56 - if (!(argv.length >= 1 && argv[0].equals("-Xold"))) { 16.57 - com.sun.tools.javap.Main.main(argv); 16.58 - return; 16.59 - } 16.60 - 16.61 - entry(argv); 16.62 - if (errorOccurred) { 16.63 - System.exit(1); 16.64 - } 16.65 - } 16.66 - 16.67 - 16.68 - /** 16.69 - * Entry point for tool if you don't want System.exit() called. 16.70 - */ 16.71 - public static void entry(String argv[]) { 16.72 - PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); 16.73 - try { 16.74 - 16.75 - Main jpmain = new Main(out); 16.76 - jpmain.perform(argv); 16.77 - 16.78 - } finally { 16.79 - out.close(); 16.80 - } 16.81 - } 16.82 - 16.83 - /** 16.84 - * Process the arguments and perform the desired action 16.85 - */ 16.86 - private void perform(String argv[]) { 16.87 - if (parseArguments(argv)) { 16.88 - displayResults(); 16.89 - 16.90 - } 16.91 - } 16.92 - 16.93 - private void error(String msg) { 16.94 - errorOccurred = true; 16.95 - System.err.println(msg); 16.96 - System.err.flush(); 16.97 - } 16.98 - 16.99 - /** 16.100 - * Print usage information 16.101 - */ 16.102 - private void usage() { 16.103 - java.io.PrintStream out = System.out; 16.104 - out.println("Usage: " + progname + " <options> <classes>..."); 16.105 - out.println(); 16.106 - out.println("where options include:"); 16.107 - out.println(" -c Disassemble the code"); 16.108 - out.println(" -classpath <pathlist> Specify where to find user class files"); 16.109 - out.println(" -extdirs <dirs> Override location of installed extensions"); 16.110 - out.println(" -help Print this usage message"); 16.111 - out.println(" -J<flag> Pass <flag> directly to the runtime system"); 16.112 - out.println(" -l Print line number and local variable tables"); 16.113 - out.println(" -public Show only public classes and members"); 16.114 - out.println(" -protected Show protected/public classes and members"); 16.115 - out.println(" -package Show package/protected/public classes"); 16.116 - out.println(" and members (default)"); 16.117 - out.println(" -private Show all classes and members"); 16.118 - out.println(" -s Print internal type signatures"); 16.119 - out.println(" -bootclasspath <pathlist> Override location of class files loaded"); 16.120 - out.println(" by the bootstrap class loader"); 16.121 - out.println(" -verbose Print stack size, number of locals and args for methods"); 16.122 - out.println(" If verifying, print reasons for failure"); 16.123 - out.println(); 16.124 - } 16.125 - 16.126 - /** 16.127 - * Parse the command line arguments. 16.128 - * Set flags, construct the class list and create environment. 16.129 - */ 16.130 - private boolean parseArguments(String argv[]) { 16.131 - for (int i = 0 ; i < argv.length ; i++) { 16.132 - String arg = argv[i]; 16.133 - if (arg.startsWith("-")) { 16.134 - if (arg.equals("-l")) { 16.135 - env.showLineAndLocal = true; 16.136 - } else if (arg.equals("-private") || arg.equals("-p")) { 16.137 - env.showAccess = env.PRIVATE; 16.138 - } else if (arg.equals("-package")) { 16.139 - env.showAccess = env.PACKAGE; 16.140 - } else if (arg.equals("-protected")) { 16.141 - env.showAccess = env.PROTECTED; 16.142 - } else if (arg.equals("-public")) { 16.143 - env.showAccess = env.PUBLIC; 16.144 - } else if (arg.equals("-c")) { 16.145 - env.showDisassembled = true; 16.146 - } else if (arg.equals("-s")) { 16.147 - env.showInternalSigs = true; 16.148 - } else if (arg.equals("-verbose")) { 16.149 - env.showVerbose = true; 16.150 - } else if (arg.equals("-v")) { 16.151 - env.showVerbose = true; 16.152 - } else if (arg.equals("-h")) { 16.153 - error("-h is no longer available - use the 'javah' program"); 16.154 - return false; 16.155 - } else if (arg.equals("-verify")) { 16.156 - error("-verify is no longer available - use 'java -verify'"); 16.157 - return false; 16.158 - } else if (arg.equals("-verify-verbose")) { 16.159 - error("-verify is no longer available - use 'java -verify'"); 16.160 - return false; 16.161 - } else if (arg.equals("-help")) { 16.162 - usage(); 16.163 - return false; 16.164 - } else if (arg.equals("-classpath")) { 16.165 - if ((i + 1) < argv.length) { 16.166 - env.classPathString = argv[++i]; 16.167 - } else { 16.168 - error("-classpath requires argument"); 16.169 - usage(); 16.170 - return false; 16.171 - } 16.172 - } else if (arg.equals("-bootclasspath")) { 16.173 - if ((i + 1) < argv.length) { 16.174 - env.bootClassPathString = argv[++i]; 16.175 - } else { 16.176 - error("-bootclasspath requires argument"); 16.177 - usage(); 16.178 - return false; 16.179 - } 16.180 - } else if (arg.equals("-extdirs")) { 16.181 - if ((i + 1) < argv.length) { 16.182 - env.extDirsString = argv[++i]; 16.183 - } else { 16.184 - error("-extdirs requires argument"); 16.185 - usage(); 16.186 - return false; 16.187 - } 16.188 - } else if (arg.equals("-all")) { 16.189 - env.showallAttr = true; 16.190 - } else if (arg.equals("-Xold")) { 16.191 - // ignore: this is old javap 16.192 - } else { 16.193 - error("invalid flag: " + arg); 16.194 - usage(); 16.195 - return false; 16.196 - } 16.197 - } else { 16.198 - classList.addElement(arg); 16.199 - env.nothingToDo = false; 16.200 - } 16.201 - } 16.202 - if (env.nothingToDo) { 16.203 - System.out.println("No classes were specified on the command line. Try -help."); 16.204 - errorOccurred = true; 16.205 - return false; 16.206 - } 16.207 - return true; 16.208 - } 16.209 - 16.210 - /** 16.211 - * Display results 16.212 - */ 16.213 - private void displayResults() { 16.214 - for (int i = 0; i < classList.size() ; i++ ) { 16.215 - String Name = classList.elementAt(i); 16.216 - InputStream classin = env.getFileInputStream(Name); 16.217 - 16.218 - try { 16.219 - JavapPrinter printer = new JavapPrinter(classin, out, env); 16.220 - printer.print(); // actual do display 16.221 - 16.222 - } catch (IllegalArgumentException exc) { 16.223 - error(exc.getMessage()); 16.224 - } 16.225 - } 16.226 - } 16.227 -}
17.1 --- a/src/share/classes/sun/tools/javap/MethodData.java Thu May 28 09:49:56 2009 -0700 17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 17.3 @@ -1,416 +0,0 @@ 17.4 -/* 17.5 - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. 17.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.7 - * 17.8 - * This code is free software; you can redistribute it and/or modify it 17.9 - * under the terms of the GNU General Public License version 2 only, as 17.10 - * published by the Free Software Foundation. Sun designates this 17.11 - * particular file as subject to the "Classpath" exception as provided 17.12 - * by Sun in the LICENSE file that accompanied this code. 17.13 - * 17.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 17.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17.17 - * version 2 for more details (a copy is included in the LICENSE file that 17.18 - * accompanied this code). 17.19 - * 17.20 - * You should have received a copy of the GNU General Public License version 17.21 - * 2 along with this work; if not, write to the Free Software Foundation, 17.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17.23 - * 17.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 17.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 17.26 - * have any questions. 17.27 - */ 17.28 - 17.29 -package sun.tools.javap; 17.30 - 17.31 -import java.util.*; 17.32 -import java.io.*; 17.33 - 17.34 -import static sun.tools.javap.RuntimeConstants.*; 17.35 - 17.36 -/** 17.37 - * Strores method data informastion. 17.38 - * 17.39 - * @author Sucheta Dambalkar (Adopted code from jdis) 17.40 - */ 17.41 -public class MethodData { 17.42 - 17.43 - ClassData cls; 17.44 - int access; 17.45 - int name_index; 17.46 - int descriptor_index; 17.47 - int attributes_count; 17.48 - byte[] code; 17.49 - Vector<TrapData> exception_table = new Vector<TrapData>(0); 17.50 - Vector<LineNumData> lin_num_tb = new Vector<LineNumData>(0); 17.51 - Vector<LocVarData> loc_var_tb = new Vector<LocVarData>(0); 17.52 - StackMapTableData[] stackMapTable; 17.53 - StackMapData[] stackMap; 17.54 - int[] exc_index_table=null; 17.55 - Vector<AttrData> attrs=new Vector<AttrData>(0); 17.56 - Vector<AttrData> code_attrs=new Vector<AttrData>(0); 17.57 - int max_stack, max_locals; 17.58 - boolean isSynthetic=false; 17.59 - boolean isDeprecated=false; 17.60 - 17.61 - public MethodData(ClassData cls){ 17.62 - this.cls=cls; 17.63 - } 17.64 - 17.65 - /** 17.66 - * Read method info. 17.67 - */ 17.68 - public void read(DataInputStream in) throws IOException { 17.69 - access = in.readUnsignedShort(); 17.70 - name_index=in.readUnsignedShort(); 17.71 - descriptor_index =in.readUnsignedShort(); 17.72 - int attributes_count = in.readUnsignedShort(); 17.73 - for (int i = 0; i < attributes_count; i++) { 17.74 - int attr_name_index=in.readUnsignedShort(); 17.75 - 17.76 - readAttr: { 17.77 - if (cls.getTag(attr_name_index)==CONSTANT_UTF8) { 17.78 - String attr_name=cls.getString(attr_name_index); 17.79 - if ( attr_name.equals("Code")){ 17.80 - readCode (in); 17.81 - AttrData attr=new AttrData(cls); 17.82 - attr.read(attr_name_index); 17.83 - attrs.addElement(attr); 17.84 - break readAttr; 17.85 - } else if ( attr_name.equals("Exceptions")){ 17.86 - readExceptions(in); 17.87 - AttrData attr=new AttrData(cls); 17.88 - attr.read(attr_name_index); 17.89 - attrs.addElement(attr); 17.90 - break readAttr; 17.91 - } else if (attr_name.equals("Synthetic")){ 17.92 - if (in.readInt()!=0) 17.93 - throw new ClassFormatError("invalid Synthetic attr length"); 17.94 - isSynthetic=true; 17.95 - AttrData attr=new AttrData(cls); 17.96 - attr.read(attr_name_index); 17.97 - attrs.addElement(attr); 17.98 - break readAttr; 17.99 - } else if (attr_name.equals("Deprecated")){ 17.100 - if (in.readInt()!=0) 17.101 - throw new ClassFormatError("invalid Synthetic attr length"); 17.102 - isDeprecated = true; 17.103 - AttrData attr=new AttrData(cls); 17.104 - attr.read(attr_name_index); 17.105 - attrs.addElement(attr); 17.106 - break readAttr; 17.107 - } 17.108 - } 17.109 - AttrData attr=new AttrData(cls); 17.110 - attr.read(attr_name_index, in); 17.111 - attrs.addElement(attr); 17.112 - } 17.113 - } 17.114 - } 17.115 - 17.116 - /** 17.117 - * Read code attribute info. 17.118 - */ 17.119 - public void readCode(DataInputStream in) throws IOException { 17.120 - 17.121 - int attr_length = in.readInt(); 17.122 - max_stack=in.readUnsignedShort(); 17.123 - max_locals=in.readUnsignedShort(); 17.124 - int codelen=in.readInt(); 17.125 - 17.126 - code=new byte[codelen]; 17.127 - int totalread = 0; 17.128 - while(totalread < codelen){ 17.129 - totalread += in.read(code, totalread, codelen-totalread); 17.130 - } 17.131 - // in.read(code, 0, codelen); 17.132 - int clen = 0; 17.133 - readExceptionTable(in); 17.134 - int code_attributes_count = in.readUnsignedShort(); 17.135 - 17.136 - for (int k = 0 ; k < code_attributes_count ; k++) { 17.137 - int table_name_index=in.readUnsignedShort(); 17.138 - int table_name_tag=cls.getTag(table_name_index); 17.139 - AttrData attr=new AttrData(cls); 17.140 - if (table_name_tag==CONSTANT_UTF8) { 17.141 - String table_name_tstr=cls.getString(table_name_index); 17.142 - if (table_name_tstr.equals("LineNumberTable")) { 17.143 - readLineNumTable(in); 17.144 - attr.read(table_name_index); 17.145 - } else if (table_name_tstr.equals("LocalVariableTable")) { 17.146 - readLocVarTable(in); 17.147 - attr.read(table_name_index); 17.148 - } else if (table_name_tstr.equals("StackMapTable")) { 17.149 - readStackMapTable(in); 17.150 - attr.read(table_name_index); 17.151 - } else if (table_name_tstr.equals("StackMap")) { 17.152 - readStackMap(in); 17.153 - attr.read(table_name_index); 17.154 - } else { 17.155 - attr.read(table_name_index, in); 17.156 - } 17.157 - code_attrs.addElement(attr); 17.158 - continue; 17.159 - } 17.160 - 17.161 - attr.read(table_name_index, in); 17.162 - code_attrs.addElement(attr); 17.163 - } 17.164 - } 17.165 - 17.166 - /** 17.167 - * Read exception table info. 17.168 - */ 17.169 - void readExceptionTable (DataInputStream in) throws IOException { 17.170 - int exception_table_len=in.readUnsignedShort(); 17.171 - exception_table=new Vector<TrapData>(exception_table_len); 17.172 - for (int l = 0; l < exception_table_len; l++) { 17.173 - exception_table.addElement(new TrapData(in, l)); 17.174 - } 17.175 - } 17.176 - 17.177 - /** 17.178 - * Read LineNumberTable attribute info. 17.179 - */ 17.180 - void readLineNumTable (DataInputStream in) throws IOException { 17.181 - int attr_len = in.readInt(); // attr_length 17.182 - int lin_num_tb_len = in.readUnsignedShort(); 17.183 - lin_num_tb=new Vector<LineNumData>(lin_num_tb_len); 17.184 - for (int l = 0; l < lin_num_tb_len; l++) { 17.185 - lin_num_tb.addElement(new LineNumData(in)); 17.186 - } 17.187 - } 17.188 - 17.189 - /** 17.190 - * Read LocalVariableTable attribute info. 17.191 - */ 17.192 - void readLocVarTable (DataInputStream in) throws IOException { 17.193 - int attr_len=in.readInt(); // attr_length 17.194 - int loc_var_tb_len = in.readUnsignedShort(); 17.195 - loc_var_tb = new Vector<LocVarData>(loc_var_tb_len); 17.196 - for (int l = 0; l < loc_var_tb_len; l++) { 17.197 - loc_var_tb.addElement(new LocVarData(in)); 17.198 - } 17.199 - } 17.200 - 17.201 - /** 17.202 - * Read Exception attribute info. 17.203 - */ 17.204 - public void readExceptions(DataInputStream in) throws IOException { 17.205 - int attr_len=in.readInt(); // attr_length in prog 17.206 - int num_exceptions = in.readUnsignedShort(); 17.207 - exc_index_table=new int[num_exceptions]; 17.208 - for (int l = 0; l < num_exceptions; l++) { 17.209 - int exc=in.readShort(); 17.210 - exc_index_table[l]=exc; 17.211 - } 17.212 - } 17.213 - 17.214 - /** 17.215 - * Read StackMapTable attribute info. 17.216 - */ 17.217 - void readStackMapTable(DataInputStream in) throws IOException { 17.218 - int attr_len = in.readInt(); //attr_length 17.219 - int stack_map_tb_len = in.readUnsignedShort(); 17.220 - stackMapTable = new StackMapTableData[stack_map_tb_len]; 17.221 - for (int i=0; i<stack_map_tb_len; i++) { 17.222 - stackMapTable[i] = StackMapTableData.getInstance(in, this); 17.223 - } 17.224 - } 17.225 - 17.226 - /** 17.227 - * Read StackMap attribute info. 17.228 - */ 17.229 - void readStackMap(DataInputStream in) throws IOException { 17.230 - int attr_len = in.readInt(); //attr_length 17.231 - int stack_map_len = in.readUnsignedShort(); 17.232 - stackMap = new StackMapData[stack_map_len]; 17.233 - for (int i = 0; i<stack_map_len; i++) { 17.234 - stackMap[i] = new StackMapData(in, this); 17.235 - } 17.236 - } 17.237 - 17.238 - /** 17.239 - * Return access of the method. 17.240 - */ 17.241 - public String[] getAccess(){ 17.242 - 17.243 - Vector<String> v = new Vector<String>(); 17.244 - if ((access & ACC_PUBLIC) !=0) v.addElement("public"); 17.245 - if ((access & ACC_PRIVATE) !=0) v.addElement("private"); 17.246 - if ((access & ACC_PROTECTED) !=0) v.addElement("protected"); 17.247 - if ((access & ACC_STATIC) !=0) v.addElement("static"); 17.248 - if ((access & ACC_FINAL) !=0) v.addElement("final"); 17.249 - if ((access & ACC_SYNCHRONIZED) !=0) v.addElement("synchronized"); 17.250 - if ((access & ACC_NATIVE) !=0) v.addElement("native"); 17.251 - if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract"); 17.252 - if ((access & ACC_STRICT) !=0) v.addElement("strictfp"); 17.253 - 17.254 - String[] accflags = new String[v.size()]; 17.255 - v.copyInto(accflags); 17.256 - return accflags; 17.257 - } 17.258 - 17.259 - /** 17.260 - * Return name of the method. 17.261 - */ 17.262 - public String getName(){ 17.263 - return cls.getStringValue(name_index); 17.264 - } 17.265 - 17.266 - /** 17.267 - * Return internal siganature of the method. 17.268 - */ 17.269 - public String getInternalSig(){ 17.270 - return cls.getStringValue(descriptor_index); 17.271 - } 17.272 - 17.273 - /** 17.274 - * Return java return type signature of method. 17.275 - */ 17.276 - public String getReturnType(){ 17.277 - 17.278 - String rttype = (new TypeSignature(getInternalSig())).getReturnType(); 17.279 - return rttype; 17.280 - } 17.281 - 17.282 - /** 17.283 - * Return java type parameter signature. 17.284 - */ 17.285 - public String getParameters(){ 17.286 - String ptype = (new TypeSignature(getInternalSig())).getParameters(); 17.287 - 17.288 - return ptype; 17.289 - } 17.290 - 17.291 - /** 17.292 - * Return code attribute data of a method. 17.293 - */ 17.294 - public byte[] getCode(){ 17.295 - return code; 17.296 - } 17.297 - 17.298 - /** 17.299 - * Return LineNumberTable size. 17.300 - */ 17.301 - public int getnumlines(){ 17.302 - return lin_num_tb.size(); 17.303 - } 17.304 - 17.305 - /** 17.306 - * Return LineNumberTable 17.307 - */ 17.308 - public Vector<?> getlin_num_tb(){ 17.309 - return lin_num_tb; 17.310 - } 17.311 - 17.312 - /** 17.313 - * Return LocalVariableTable size. 17.314 - */ 17.315 - public int getloc_var_tbsize(){ 17.316 - return loc_var_tb.size(); 17.317 - } 17.318 - 17.319 - 17.320 - /** 17.321 - * Return LocalVariableTable. 17.322 - */ 17.323 - public Vector<?> getloc_var_tb(){ 17.324 - return loc_var_tb; 17.325 - } 17.326 - 17.327 - /** 17.328 - * Return StackMap. 17.329 - */ 17.330 - public StackMapData[] getStackMap() { 17.331 - return stackMap; 17.332 - } 17.333 - 17.334 - /** 17.335 - * Return StackMapTable. 17.336 - */ 17.337 - public StackMapTableData[] getStackMapTable() { 17.338 - return stackMapTable; 17.339 - } 17.340 - 17.341 - /** 17.342 - * Return number of arguments of that method. 17.343 - */ 17.344 - public int getArgumentlength(){ 17.345 - return new TypeSignature(getInternalSig()).getArgumentlength(); 17.346 - } 17.347 - 17.348 - /** 17.349 - * Return true if method is static 17.350 - */ 17.351 - public boolean isStatic(){ 17.352 - if ((access & ACC_STATIC) !=0) return true; 17.353 - return false; 17.354 - } 17.355 - 17.356 - 17.357 - /** 17.358 - * Return max depth of operand stack. 17.359 - */ 17.360 - public int getMaxStack(){ 17.361 - return max_stack; 17.362 - } 17.363 - 17.364 - 17.365 - /** 17.366 - * Return number of local variables. 17.367 - */ 17.368 - public int getMaxLocals(){ 17.369 - return max_locals; 17.370 - } 17.371 - 17.372 - 17.373 - /** 17.374 - * Return exception index table in Exception attribute. 17.375 - */ 17.376 - public int []get_exc_index_table(){ 17.377 - return exc_index_table; 17.378 - } 17.379 - 17.380 - 17.381 - /** 17.382 - * Return exception table in code attributre. 17.383 - */ 17.384 - public Vector<?> getexception_table(){ 17.385 - return exception_table; 17.386 - } 17.387 - 17.388 - 17.389 - /** 17.390 - * Return method attributes. 17.391 - */ 17.392 - public Vector<?> getAttributes(){ 17.393 - return attrs; 17.394 - } 17.395 - 17.396 - 17.397 - /** 17.398 - * Return code attributes. 17.399 - */ 17.400 - public Vector<?> getCodeAttributes(){ 17.401 - return code_attrs; 17.402 - } 17.403 - 17.404 - 17.405 - /** 17.406 - * Return true if method id synthetic. 17.407 - */ 17.408 - public boolean isSynthetic(){ 17.409 - return isSynthetic; 17.410 - } 17.411 - 17.412 - 17.413 - /** 17.414 - * Return true if method is deprecated. 17.415 - */ 17.416 - public boolean isDeprecated(){ 17.417 - return isDeprecated; 17.418 - } 17.419 -}
18.1 --- a/src/share/classes/sun/tools/javap/RuntimeConstants.java Thu May 28 09:49:56 2009 -0700 18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 18.3 @@ -1,787 +0,0 @@ 18.4 -/* 18.5 - * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved. 18.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.7 - * 18.8 - * This code is free software; you can redistribute it and/or modify it 18.9 - * under the terms of the GNU General Public License version 2 only, as 18.10 - * published by the Free Software Foundation. Sun designates this 18.11 - * particular file as subject to the "Classpath" exception as provided 18.12 - * by Sun in the LICENSE file that accompanied this code. 18.13 - * 18.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 18.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18.17 - * version 2 for more details (a copy is included in the LICENSE file that 18.18 - * accompanied this code). 18.19 - * 18.20 - * You should have received a copy of the GNU General Public License version 18.21 - * 2 along with this work; if not, write to the Free Software Foundation, 18.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18.23 - * 18.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 18.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 18.26 - * have any questions. 18.27 - */ 18.28 - 18.29 - 18.30 -package sun.tools.javap; 18.31 - 18.32 -public interface RuntimeConstants { 18.33 - 18.34 - /* Signature Characters */ 18.35 - public static final char SIGC_VOID = 'V'; 18.36 - public static final String SIG_VOID = "V"; 18.37 - public static final char SIGC_BOOLEAN = 'Z'; 18.38 - public static final String SIG_BOOLEAN = "Z"; 18.39 - public static final char SIGC_BYTE = 'B'; 18.40 - public static final String SIG_BYTE = "B"; 18.41 - public static final char SIGC_CHAR = 'C'; 18.42 - public static final String SIG_CHAR = "C"; 18.43 - public static final char SIGC_SHORT = 'S'; 18.44 - public static final String SIG_SHORT = "S"; 18.45 - public static final char SIGC_INT = 'I'; 18.46 - public static final String SIG_INT = "I"; 18.47 - public static final char SIGC_LONG = 'J'; 18.48 - public static final String SIG_LONG = "J"; 18.49 - public static final char SIGC_FLOAT = 'F'; 18.50 - public static final String SIG_FLOAT = "F"; 18.51 - public static final char SIGC_DOUBLE = 'D'; 18.52 - public static final String SIG_DOUBLE = "D"; 18.53 - public static final char SIGC_ARRAY = '['; 18.54 - public static final String SIG_ARRAY = "["; 18.55 - public static final char SIGC_CLASS = 'L'; 18.56 - public static final String SIG_CLASS = "L"; 18.57 - public static final char SIGC_METHOD = '('; 18.58 - public static final String SIG_METHOD = "("; 18.59 - public static final char SIGC_ENDCLASS = ';'; 18.60 - public static final String SIG_ENDCLASS = ";"; 18.61 - public static final char SIGC_ENDMETHOD = ')'; 18.62 - public static final String SIG_ENDMETHOD = ")"; 18.63 - public static final char SIGC_PACKAGE = '/'; 18.64 - public static final String SIG_PACKAGE = "/"; 18.65 - 18.66 - /* Class File Constants */ 18.67 - public static final int JAVA_MAGIC = 0xcafebabe; 18.68 - public static final int JAVA_VERSION = 45; 18.69 - public static final int JAVA_MINOR_VERSION = 3; 18.70 - 18.71 - /* Constant table */ 18.72 - public static final int CONSTANT_UTF8 = 1; 18.73 - public static final int CONSTANT_UNICODE = 2; 18.74 - public static final int CONSTANT_INTEGER = 3; 18.75 - public static final int CONSTANT_FLOAT = 4; 18.76 - public static final int CONSTANT_LONG = 5; 18.77 - public static final int CONSTANT_DOUBLE = 6; 18.78 - public static final int CONSTANT_CLASS = 7; 18.79 - public static final int CONSTANT_STRING = 8; 18.80 - public static final int CONSTANT_FIELD = 9; 18.81 - public static final int CONSTANT_METHOD = 10; 18.82 - public static final int CONSTANT_INTERFACEMETHOD = 11; 18.83 - public static final int CONSTANT_NAMEANDTYPE = 12; 18.84 - 18.85 - /* Access Flags */ 18.86 - public static final int ACC_PUBLIC = 0x00000001; 18.87 - public static final int ACC_PRIVATE = 0x00000002; 18.88 - public static final int ACC_PROTECTED = 0x00000004; 18.89 - public static final int ACC_STATIC = 0x00000008; 18.90 - public static final int ACC_FINAL = 0x00000010; 18.91 - public static final int ACC_SYNCHRONIZED = 0x00000020; 18.92 - public static final int ACC_SUPER = 0x00000020; 18.93 - public static final int ACC_VOLATILE = 0x00000040; 18.94 - public static final int ACC_TRANSIENT = 0x00000080; 18.95 - public static final int ACC_NATIVE = 0x00000100; 18.96 - public static final int ACC_INTERFACE = 0x00000200; 18.97 - public static final int ACC_ABSTRACT = 0x00000400; 18.98 - public static final int ACC_STRICT = 0x00000800; 18.99 - public static final int ACC_EXPLICIT = 0x00001000; 18.100 - public static final int ACC_SYNTHETIC = 0x00010000; // actually, this is an attribute 18.101 - 18.102 - /* Type codes */ 18.103 - public static final int T_CLASS = 0x00000002; 18.104 - public static final int T_BOOLEAN = 0x00000004; 18.105 - public static final int T_CHAR = 0x00000005; 18.106 - public static final int T_FLOAT = 0x00000006; 18.107 - public static final int T_DOUBLE = 0x00000007; 18.108 - public static final int T_BYTE = 0x00000008; 18.109 - public static final int T_SHORT = 0x00000009; 18.110 - public static final int T_INT = 0x0000000a; 18.111 - public static final int T_LONG = 0x0000000b; 18.112 - 18.113 - /* Type codes for StackMap attribute */ 18.114 - public static final int ITEM_Bogus =0; // an unknown or uninitialized value 18.115 - public static final int ITEM_Integer =1; // a 32-bit integer 18.116 - public static final int ITEM_Float =2; // not used 18.117 - public static final int ITEM_Double =3; // not used 18.118 - public static final int ITEM_Long =4; // a 64-bit integer 18.119 - public static final int ITEM_Null =5; // the type of null 18.120 - public static final int ITEM_InitObject =6; // "this" in constructor 18.121 - public static final int ITEM_Object =7; // followed by 2-byte index of class name 18.122 - public static final int ITEM_NewObject =8; // followed by 2-byte ref to "new" 18.123 - 18.124 - /* Constants used in StackMapTable attribute */ 18.125 - public static final int SAME_FRAME_BOUND = 64; 18.126 - public static final int SAME_LOCALS_1_STACK_ITEM_BOUND = 128; 18.127 - public static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247; 18.128 - public static final int SAME_FRAME_EXTENDED = 251; 18.129 - public static final int FULL_FRAME = 255; 18.130 - 18.131 - /* Opcodes */ 18.132 - public static final int opc_dead = -2; 18.133 - public static final int opc_label = -1; 18.134 - public static final int opc_nop = 0; 18.135 - public static final int opc_aconst_null = 1; 18.136 - public static final int opc_iconst_m1 = 2; 18.137 - public static final int opc_iconst_0 = 3; 18.138 - public static final int opc_iconst_1 = 4; 18.139 - public static final int opc_iconst_2 = 5; 18.140 - public static final int opc_iconst_3 = 6; 18.141 - public static final int opc_iconst_4 = 7; 18.142 - public static final int opc_iconst_5 = 8; 18.143 - public static final int opc_lconst_0 = 9; 18.144 - public static final int opc_lconst_1 = 10; 18.145 - public static final int opc_fconst_0 = 11; 18.146 - public static final int opc_fconst_1 = 12; 18.147 - public static final int opc_fconst_2 = 13; 18.148 - public static final int opc_dconst_0 = 14; 18.149 - public static final int opc_dconst_1 = 15; 18.150 - public static final int opc_bipush = 16; 18.151 - public static final int opc_sipush = 17; 18.152 - public static final int opc_ldc = 18; 18.153 - public static final int opc_ldc_w = 19; 18.154 - public static final int opc_ldc2_w = 20; 18.155 - public static final int opc_iload = 21; 18.156 - public static final int opc_lload = 22; 18.157 - public static final int opc_fload = 23; 18.158 - public static final int opc_dload = 24; 18.159 - public static final int opc_aload = 25; 18.160 - public static final int opc_iload_0 = 26; 18.161 - public static final int opc_iload_1 = 27; 18.162 - public static final int opc_iload_2 = 28; 18.163 - public static final int opc_iload_3 = 29; 18.164 - public static final int opc_lload_0 = 30; 18.165 - public static final int opc_lload_1 = 31; 18.166 - public static final int opc_lload_2 = 32; 18.167 - public static final int opc_lload_3 = 33; 18.168 - public static final int opc_fload_0 = 34; 18.169 - public static final int opc_fload_1 = 35; 18.170 - public static final int opc_fload_2 = 36; 18.171 - public static final int opc_fload_3 = 37; 18.172 - public static final int opc_dload_0 = 38; 18.173 - public static final int opc_dload_1 = 39; 18.174 - public static final int opc_dload_2 = 40; 18.175 - public static final int opc_dload_3 = 41; 18.176 - public static final int opc_aload_0 = 42; 18.177 - public static final int opc_aload_1 = 43; 18.178 - public static final int opc_aload_2 = 44; 18.179 - public static final int opc_aload_3 = 45; 18.180 - public static final int opc_iaload = 46; 18.181 - public static final int opc_laload = 47; 18.182 - public static final int opc_faload = 48; 18.183 - public static final int opc_daload = 49; 18.184 - public static final int opc_aaload = 50; 18.185 - public static final int opc_baload = 51; 18.186 - public static final int opc_caload = 52; 18.187 - public static final int opc_saload = 53; 18.188 - public static final int opc_istore = 54; 18.189 - public static final int opc_lstore = 55; 18.190 - public static final int opc_fstore = 56; 18.191 - public static final int opc_dstore = 57; 18.192 - public static final int opc_astore = 58; 18.193 - public static final int opc_istore_0 = 59; 18.194 - public static final int opc_istore_1 = 60; 18.195 - public static final int opc_istore_2 = 61; 18.196 - public static final int opc_istore_3 = 62; 18.197 - public static final int opc_lstore_0 = 63; 18.198 - public static final int opc_lstore_1 = 64; 18.199 - public static final int opc_lstore_2 = 65; 18.200 - public static final int opc_lstore_3 = 66; 18.201 - public static final int opc_fstore_0 = 67; 18.202 - public static final int opc_fstore_1 = 68; 18.203 - public static final int opc_fstore_2 = 69; 18.204 - public static final int opc_fstore_3 = 70; 18.205 - public static final int opc_dstore_0 = 71; 18.206 - public static final int opc_dstore_1 = 72; 18.207 - public static final int opc_dstore_2 = 73; 18.208 - public static final int opc_dstore_3 = 74; 18.209 - public static final int opc_astore_0 = 75; 18.210 - public static final int opc_astore_1 = 76; 18.211 - public static final int opc_astore_2 = 77; 18.212 - public static final int opc_astore_3 = 78; 18.213 - public static final int opc_iastore = 79; 18.214 - public static final int opc_lastore = 80; 18.215 - public static final int opc_fastore = 81; 18.216 - public static final int opc_dastore = 82; 18.217 - public static final int opc_aastore = 83; 18.218 - public static final int opc_bastore = 84; 18.219 - public static final int opc_castore = 85; 18.220 - public static final int opc_sastore = 86; 18.221 - public static final int opc_pop = 87; 18.222 - public static final int opc_pop2 = 88; 18.223 - public static final int opc_dup = 89; 18.224 - public static final int opc_dup_x1 = 90; 18.225 - public static final int opc_dup_x2 = 91; 18.226 - public static final int opc_dup2 = 92; 18.227 - public static final int opc_dup2_x1 = 93; 18.228 - public static final int opc_dup2_x2 = 94; 18.229 - public static final int opc_swap = 95; 18.230 - public static final int opc_iadd = 96; 18.231 - public static final int opc_ladd = 97; 18.232 - public static final int opc_fadd = 98; 18.233 - public static final int opc_dadd = 99; 18.234 - public static final int opc_isub = 100; 18.235 - public static final int opc_lsub = 101; 18.236 - public static final int opc_fsub = 102; 18.237 - public static final int opc_dsub = 103; 18.238 - public static final int opc_imul = 104; 18.239 - public static final int opc_lmul = 105; 18.240 - public static final int opc_fmul = 106; 18.241 - public static final int opc_dmul = 107; 18.242 - public static final int opc_idiv = 108; 18.243 - public static final int opc_ldiv = 109; 18.244 - public static final int opc_fdiv = 110; 18.245 - public static final int opc_ddiv = 111; 18.246 - public static final int opc_irem = 112; 18.247 - public static final int opc_lrem = 113; 18.248 - public static final int opc_frem = 114; 18.249 - public static final int opc_drem = 115; 18.250 - public static final int opc_ineg = 116; 18.251 - public static final int opc_lneg = 117; 18.252 - public static final int opc_fneg = 118; 18.253 - public static final int opc_dneg = 119; 18.254 - public static final int opc_ishl = 120; 18.255 - public static final int opc_lshl = 121; 18.256 - public static final int opc_ishr = 122; 18.257 - public static final int opc_lshr = 123; 18.258 - public static final int opc_iushr = 124; 18.259 - public static final int opc_lushr = 125; 18.260 - public static final int opc_iand = 126; 18.261 - public static final int opc_land = 127; 18.262 - public static final int opc_ior = 128; 18.263 - public static final int opc_lor = 129; 18.264 - public static final int opc_ixor = 130; 18.265 - public static final int opc_lxor = 131; 18.266 - public static final int opc_iinc = 132; 18.267 - public static final int opc_i2l = 133; 18.268 - public static final int opc_i2f = 134; 18.269 - public static final int opc_i2d = 135; 18.270 - public static final int opc_l2i = 136; 18.271 - public static final int opc_l2f = 137; 18.272 - public static final int opc_l2d = 138; 18.273 - public static final int opc_f2i = 139; 18.274 - public static final int opc_f2l = 140; 18.275 - public static final int opc_f2d = 141; 18.276 - public static final int opc_d2i = 142; 18.277 - public static final int opc_d2l = 143; 18.278 - public static final int opc_d2f = 144; 18.279 - public static final int opc_i2b = 145; 18.280 - public static final int opc_int2byte = 145; 18.281 - public static final int opc_i2c = 146; 18.282 - public static final int opc_int2char = 146; 18.283 - public static final int opc_i2s = 147; 18.284 - public static final int opc_int2short = 147; 18.285 - public static final int opc_lcmp = 148; 18.286 - public static final int opc_fcmpl = 149; 18.287 - public static final int opc_fcmpg = 150; 18.288 - public static final int opc_dcmpl = 151; 18.289 - public static final int opc_dcmpg = 152; 18.290 - public static final int opc_ifeq = 153; 18.291 - public static final int opc_ifne = 154; 18.292 - public static final int opc_iflt = 155; 18.293 - public static final int opc_ifge = 156; 18.294 - public static final int opc_ifgt = 157; 18.295 - public static final int opc_ifle = 158; 18.296 - public static final int opc_if_icmpeq = 159; 18.297 - public static final int opc_if_icmpne = 160; 18.298 - public static final int opc_if_icmplt = 161; 18.299 - public static final int opc_if_icmpge = 162; 18.300 - public static final int opc_if_icmpgt = 163; 18.301 - public static final int opc_if_icmple = 164; 18.302 - public static final int opc_if_acmpeq = 165; 18.303 - public static final int opc_if_acmpne = 166; 18.304 - public static final int opc_goto = 167; 18.305 - public static final int opc_jsr = 168; 18.306 - public static final int opc_ret = 169; 18.307 - public static final int opc_tableswitch = 170; 18.308 - public static final int opc_lookupswitch = 171; 18.309 - public static final int opc_ireturn = 172; 18.310 - public static final int opc_lreturn = 173; 18.311 - public static final int opc_freturn = 174; 18.312 - public static final int opc_dreturn = 175; 18.313 - public static final int opc_areturn = 176; 18.314 - public static final int opc_return = 177; 18.315 - public static final int opc_getstatic = 178; 18.316 - public static final int opc_putstatic = 179; 18.317 - public static final int opc_getfield = 180; 18.318 - public static final int opc_putfield = 181; 18.319 - public static final int opc_invokevirtual = 182; 18.320 - public static final int opc_invokenonvirtual = 183; 18.321 - public static final int opc_invokespecial = 183; 18.322 - public static final int opc_invokestatic = 184; 18.323 - public static final int opc_invokeinterface = 185; 18.324 - public static final int opc_invokedynamic = 186; 18.325 - public static final int opc_new = 187; 18.326 - public static final int opc_newarray = 188; 18.327 - public static final int opc_anewarray = 189; 18.328 - public static final int opc_arraylength = 190; 18.329 - public static final int opc_athrow = 191; 18.330 - public static final int opc_checkcast = 192; 18.331 - public static final int opc_instanceof = 193; 18.332 - public static final int opc_monitorenter = 194; 18.333 - public static final int opc_monitorexit = 195; 18.334 - public static final int opc_wide = 196; 18.335 - public static final int opc_multianewarray = 197; 18.336 - public static final int opc_ifnull = 198; 18.337 - public static final int opc_ifnonnull = 199; 18.338 - public static final int opc_goto_w = 200; 18.339 - public static final int opc_jsr_w = 201; 18.340 - /* Pseudo-instructions */ 18.341 - public static final int opc_bytecode = 203; 18.342 - public static final int opc_try = 204; 18.343 - public static final int opc_endtry = 205; 18.344 - public static final int opc_catch = 206; 18.345 - public static final int opc_var = 207; 18.346 - public static final int opc_endvar = 208; 18.347 - public static final int opc_localsmap = 209; 18.348 - public static final int opc_stackmap = 210; 18.349 - /* PicoJava prefixes */ 18.350 - public static final int opc_nonpriv = 254; 18.351 - public static final int opc_priv = 255; 18.352 - 18.353 - /* Wide instructions */ 18.354 - public static final int opc_iload_w = (opc_wide<<8)|opc_iload; 18.355 - public static final int opc_lload_w = (opc_wide<<8)|opc_lload; 18.356 - public static final int opc_fload_w = (opc_wide<<8)|opc_fload; 18.357 - public static final int opc_dload_w = (opc_wide<<8)|opc_dload; 18.358 - public static final int opc_aload_w = (opc_wide<<8)|opc_aload; 18.359 - public static final int opc_istore_w = (opc_wide<<8)|opc_istore; 18.360 - public static final int opc_lstore_w = (opc_wide<<8)|opc_lstore; 18.361 - public static final int opc_fstore_w = (opc_wide<<8)|opc_fstore; 18.362 - public static final int opc_dstore_w = (opc_wide<<8)|opc_dstore; 18.363 - public static final int opc_astore_w = (opc_wide<<8)|opc_astore; 18.364 - public static final int opc_ret_w = (opc_wide<<8)|opc_ret; 18.365 - public static final int opc_iinc_w = (opc_wide<<8)|opc_iinc; 18.366 - 18.367 - /* Opcode Names */ 18.368 - public static final String opcNamesTab[] = { 18.369 - "nop", 18.370 - "aconst_null", 18.371 - "iconst_m1", 18.372 - "iconst_0", 18.373 - "iconst_1", 18.374 - "iconst_2", 18.375 - "iconst_3", 18.376 - "iconst_4", 18.377 - "iconst_5", 18.378 - "lconst_0", 18.379 - "lconst_1", 18.380 - "fconst_0", 18.381 - "fconst_1", 18.382 - "fconst_2", 18.383 - "dconst_0", 18.384 - "dconst_1", 18.385 - "bipush", 18.386 - "sipush", 18.387 - "ldc", 18.388 - "ldc_w", 18.389 - "ldc2_w", 18.390 - "iload", 18.391 - "lload", 18.392 - "fload", 18.393 - "dload", 18.394 - "aload", 18.395 - "iload_0", 18.396 - "iload_1", 18.397 - "iload_2", 18.398 - "iload_3", 18.399 - "lload_0", 18.400 - "lload_1", 18.401 - "lload_2", 18.402 - "lload_3", 18.403 - "fload_0", 18.404 - "fload_1", 18.405 - "fload_2", 18.406 - "fload_3", 18.407 - "dload_0", 18.408 - "dload_1", 18.409 - "dload_2", 18.410 - "dload_3", 18.411 - "aload_0", 18.412 - "aload_1", 18.413 - "aload_2", 18.414 - "aload_3", 18.415 - "iaload", 18.416 - "laload", 18.417 - "faload", 18.418 - "daload", 18.419 - "aaload", 18.420 - "baload", 18.421 - "caload", 18.422 - "saload", 18.423 - "istore", 18.424 - "lstore", 18.425 - "fstore", 18.426 - "dstore", 18.427 - "astore", 18.428 - "istore_0", 18.429 - "istore_1", 18.430 - "istore_2", 18.431 - "istore_3", 18.432 - "lstore_0", 18.433 - "lstore_1", 18.434 - "lstore_2", 18.435 - "lstore_3", 18.436 - "fstore_0", 18.437 - "fstore_1", 18.438 - "fstore_2", 18.439 - "fstore_3", 18.440 - "dstore_0", 18.441 - "dstore_1", 18.442 - "dstore_2", 18.443 - "dstore_3", 18.444 - "astore_0", 18.445 - "astore_1", 18.446 - "astore_2", 18.447 - "astore_3", 18.448 - "iastore", 18.449 - "lastore", 18.450 - "fastore", 18.451 - "dastore", 18.452 - "aastore", 18.453 - "bastore", 18.454 - "castore", 18.455 - "sastore", 18.456 - "pop", 18.457 - "pop2", 18.458 - "dup", 18.459 - "dup_x1", 18.460 - "dup_x2", 18.461 - "dup2", 18.462 - "dup2_x1", 18.463 - "dup2_x2", 18.464 - "swap", 18.465 - "iadd", 18.466 - "ladd", 18.467 - "fadd", 18.468 - "dadd", 18.469 - "isub", 18.470 - "lsub", 18.471 - "fsub", 18.472 - "dsub", 18.473 - "imul", 18.474 - "lmul", 18.475 - "fmul", 18.476 - "dmul", 18.477 - "idiv", 18.478 - "ldiv", 18.479 - "fdiv", 18.480 - "ddiv", 18.481 - "irem", 18.482 - "lrem", 18.483 - "frem", 18.484 - "drem", 18.485 - "ineg", 18.486 - "lneg", 18.487 - "fneg", 18.488 - "dneg", 18.489 - "ishl", 18.490 - "lshl", 18.491 - "ishr", 18.492 - "lshr", 18.493 - "iushr", 18.494 - "lushr", 18.495 - "iand", 18.496 - "land", 18.497 - "ior", 18.498 - "lor", 18.499 - "ixor", 18.500 - "lxor", 18.501 - "iinc", 18.502 - "i2l", 18.503 - "i2f", 18.504 - "i2d", 18.505 - "l2i", 18.506 - "l2f", 18.507 - "l2d", 18.508 - "f2i", 18.509 - "f2l", 18.510 - "f2d", 18.511 - "d2i", 18.512 - "d2l", 18.513 - "d2f", 18.514 - "i2b", 18.515 - "i2c", 18.516 - "i2s", 18.517 - "lcmp", 18.518 - "fcmpl", 18.519 - "fcmpg", 18.520 - "dcmpl", 18.521 - "dcmpg", 18.522 - "ifeq", 18.523 - "ifne", 18.524 - "iflt", 18.525 - "ifge", 18.526 - "ifgt", 18.527 - "ifle", 18.528 - "if_icmpeq", 18.529 - "if_icmpne", 18.530 - "if_icmplt", 18.531 - "if_icmpge", 18.532 - "if_icmpgt", 18.533 - "if_icmple", 18.534 - "if_acmpeq", 18.535 - "if_acmpne", 18.536 - "goto", 18.537 - "jsr", 18.538 - "ret", 18.539 - "tableswitch", 18.540 - "lookupswitch", 18.541 - "ireturn", 18.542 - "lreturn", 18.543 - "freturn", 18.544 - "dreturn", 18.545 - "areturn", 18.546 - "return", 18.547 - "getstatic", 18.548 - "putstatic", 18.549 - "getfield", 18.550 - "putfield", 18.551 - "invokevirtual", 18.552 - "invokespecial", // was "invokenonvirtual", 18.553 - "invokestatic", 18.554 - "invokeinterface", 18.555 - "invokedynamic", 18.556 - "new", 18.557 - "newarray", 18.558 - "anewarray", 18.559 - "arraylength", 18.560 - "athrow", 18.561 - "checkcast", 18.562 - "instanceof", 18.563 - "monitorenter", 18.564 - "monitorexit", 18.565 - null, // "wide", 18.566 - "multianewarray", 18.567 - "ifnull", 18.568 - "ifnonnull", 18.569 - "goto_w", 18.570 - "jsr_w", 18.571 - "bytecode 202", // "breakpoint", 18.572 - "bytecode", 18.573 - "try", 18.574 - "endtry", 18.575 - "catch", 18.576 - "var", 18.577 - "endvar", 18.578 - "locals_map", 18.579 - "stack_map" 18.580 - }; 18.581 - 18.582 - /* Opcode Lengths */ 18.583 - public static final int opcLengthsTab[] = { 18.584 - 1, 18.585 - 1, 18.586 - 1, 18.587 - 1, 18.588 - 1, 18.589 - 1, 18.590 - 1, 18.591 - 1, 18.592 - 1, 18.593 - 1, 18.594 - 1, 18.595 - 1, 18.596 - 1, 18.597 - 1, 18.598 - 1, 18.599 - 1, 18.600 - 2, 18.601 - 3, 18.602 - 2, 18.603 - 3, 18.604 - 3, 18.605 - 2, 18.606 - 2, 18.607 - 2, 18.608 - 2, 18.609 - 2, 18.610 - 1, 18.611 - 1, 18.612 - 1, 18.613 - 1, 18.614 - 1, 18.615 - 1, 18.616 - 1, 18.617 - 1, 18.618 - 1, 18.619 - 1, 18.620 - 1, 18.621 - 1, 18.622 - 1, 18.623 - 1, 18.624 - 1, 18.625 - 1, 18.626 - 1, 18.627 - 1, 18.628 - 1, 18.629 - 1, 18.630 - 1, 18.631 - 1, 18.632 - 1, 18.633 - 1, 18.634 - 1, 18.635 - 1, 18.636 - 1, 18.637 - 1, 18.638 - 2, 18.639 - 2, 18.640 - 2, 18.641 - 2, 18.642 - 2, 18.643 - 1, 18.644 - 1, 18.645 - 1, 18.646 - 1, 18.647 - 1, 18.648 - 1, 18.649 - 1, 18.650 - 1, 18.651 - 1, 18.652 - 1, 18.653 - 1, 18.654 - 1, 18.655 - 1, 18.656 - 1, 18.657 - 1, 18.658 - 1, 18.659 - 1, 18.660 - 1, 18.661 - 1, 18.662 - 1, 18.663 - 1, 18.664 - 1, 18.665 - 1, 18.666 - 1, 18.667 - 1, 18.668 - 1, 18.669 - 1, 18.670 - 1, 18.671 - 1, 18.672 - 1, 18.673 - 1, 18.674 - 1, 18.675 - 1, 18.676 - 1, 18.677 - 1, 18.678 - 1, 18.679 - 1, 18.680 - 1, 18.681 - 1, 18.682 - 1, 18.683 - 1, 18.684 - 1, 18.685 - 1, 18.686 - 1, 18.687 - 1, 18.688 - 1, 18.689 - 1, 18.690 - 1, 18.691 - 1, 18.692 - 1, 18.693 - 1, 18.694 - 1, 18.695 - 1, 18.696 - 1, 18.697 - 1, 18.698 - 1, 18.699 - 1, 18.700 - 1, 18.701 - 1, 18.702 - 1, 18.703 - 1, 18.704 - 1, 18.705 - 1, 18.706 - 1, 18.707 - 1, 18.708 - 1, 18.709 - 1, 18.710 - 1, 18.711 - 1, 18.712 - 1, 18.713 - 1, 18.714 - 1, 18.715 - 1, 18.716 - 3, 18.717 - 1, 18.718 - 1, 18.719 - 1, 18.720 - 1, 18.721 - 1, 18.722 - 1, 18.723 - 1, 18.724 - 1, 18.725 - 1, 18.726 - 1, 18.727 - 1, 18.728 - 1, 18.729 - 1, 18.730 - 1, 18.731 - 1, 18.732 - 1, 18.733 - 1, 18.734 - 1, 18.735 - 1, 18.736 - 1, 18.737 - 3, 18.738 - 3, 18.739 - 3, 18.740 - 3, 18.741 - 3, 18.742 - 3, 18.743 - 3, 18.744 - 3, 18.745 - 3, 18.746 - 3, 18.747 - 3, 18.748 - 3, 18.749 - 3, 18.750 - 3, 18.751 - 3, 18.752 - 3, 18.753 - 2, 18.754 - 99, 18.755 - 99, 18.756 - 1, 18.757 - 1, 18.758 - 1, 18.759 - 1, 18.760 - 1, 18.761 - 1, 18.762 - 3, 18.763 - 3, 18.764 - 3, 18.765 - 3, 18.766 - 3, 18.767 - 3, 18.768 - 3, 18.769 - 5, 18.770 - 0, 18.771 - 3, 18.772 - 2, 18.773 - 3, 18.774 - 1, 18.775 - 1, 18.776 - 3, 18.777 - 3, 18.778 - 1, 18.779 - 1, 18.780 - 0, // wide 18.781 - 4, 18.782 - 3, 18.783 - 3, 18.784 - 5, 18.785 - 5, 18.786 - 1, 18.787 - 1, 0, 0, 0, 0, 0 // pseudo 18.788 - }; 18.789 - 18.790 -}
19.1 --- a/src/share/classes/sun/tools/javap/StackMapData.java Thu May 28 09:49:56 2009 -0700 19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 19.3 @@ -1,76 +0,0 @@ 19.4 -/* 19.5 - * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. 19.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.7 - * 19.8 - * This code is free software; you can redistribute it and/or modify it 19.9 - * under the terms of the GNU General Public License version 2 only, as 19.10 - * published by the Free Software Foundation. Sun designates this 19.11 - * particular file as subject to the "Classpath" exception as provided 19.12 - * by Sun in the LICENSE file that accompanied this code. 19.13 - * 19.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 19.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19.17 - * version 2 for more details (a copy is included in the LICENSE file that 19.18 - * accompanied this code). 19.19 - * 19.20 - * You should have received a copy of the GNU General Public License version 19.21 - * 2 along with this work; if not, write to the Free Software Foundation, 19.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19.23 - * 19.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 19.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 19.26 - * have any questions. 19.27 - */ 19.28 - 19.29 - 19.30 -package sun.tools.javap; 19.31 - 19.32 -import java.util.*; 19.33 -import java.io.*; 19.34 - 19.35 -import static sun.tools.javap.RuntimeConstants.*; 19.36 - 19.37 -/* represents one entry of StackMap attribute 19.38 - */ 19.39 -class StackMapData { 19.40 - final int offset; 19.41 - final int[] locals; 19.42 - final int[] stack; 19.43 - 19.44 - StackMapData(int offset, int[] locals, int[] stack) { 19.45 - this.offset = offset; 19.46 - this.locals = locals; 19.47 - this.stack = stack; 19.48 - } 19.49 - 19.50 - StackMapData(DataInputStream in, MethodData method) throws IOException { 19.51 - offset = in.readUnsignedShort(); 19.52 - int local_size = in.readUnsignedShort(); 19.53 - locals = readTypeArray(in, local_size, method); 19.54 - int stack_size = in.readUnsignedShort(); 19.55 - stack = readTypeArray(in, stack_size, method); 19.56 - } 19.57 - 19.58 - static final int[] readTypeArray(DataInputStream in, int length, MethodData method) throws IOException { 19.59 - int[] types = new int[length]; 19.60 - for (int i=0; i<length; i++) { 19.61 - types[i] = readType(in, method); 19.62 - } 19.63 - return types; 19.64 - } 19.65 - 19.66 - static final int readType(DataInputStream in, MethodData method) throws IOException { 19.67 - int type = in.readUnsignedByte(); 19.68 - if (type == ITEM_Object || type == ITEM_NewObject) { 19.69 - type = type | (in.readUnsignedShort()<<8); 19.70 - } 19.71 - return type; 19.72 - } 19.73 - 19.74 - void print(JavapPrinter p) { 19.75 - p.out.println(" " + offset + ":"); 19.76 - p.printMap(" locals = [", locals); 19.77 - p.printMap(" stack = [", stack); 19.78 - } 19.79 -}
20.1 --- a/src/share/classes/sun/tools/javap/StackMapTableData.java Thu May 28 09:49:56 2009 -0700 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,168 +0,0 @@ 20.4 -/* 20.5 - * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. 20.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.7 - * 20.8 - * This code is free software; you can redistribute it and/or modify it 20.9 - * under the terms of the GNU General Public License version 2 only, as 20.10 - * published by the Free Software Foundation. Sun designates this 20.11 - * particular file as subject to the "Classpath" exception as provided 20.12 - * by Sun in the LICENSE file that accompanied this code. 20.13 - * 20.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 20.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20.17 - * version 2 for more details (a copy is included in the LICENSE file that 20.18 - * accompanied this code). 20.19 - * 20.20 - * You should have received a copy of the GNU General Public License version 20.21 - * 2 along with this work; if not, write to the Free Software Foundation, 20.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20.23 - * 20.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 20.26 - * have any questions. 20.27 - */ 20.28 - 20.29 - 20.30 -package sun.tools.javap; 20.31 - 20.32 -import java.util.*; 20.33 -import java.io.*; 20.34 - 20.35 -import static sun.tools.javap.RuntimeConstants.*; 20.36 - 20.37 -/* represents one entry of StackMapTable attribute 20.38 - */ 20.39 -class StackMapTableData { 20.40 - final int frameType; 20.41 - int offsetDelta; 20.42 - 20.43 - StackMapTableData(int frameType) { 20.44 - this.frameType = frameType; 20.45 - } 20.46 - 20.47 - void print(JavapPrinter p) { 20.48 - p.out.print(" frame_type = " + frameType); 20.49 - } 20.50 - 20.51 - static class SameFrame extends StackMapTableData { 20.52 - SameFrame(int frameType, int offsetDelta) { 20.53 - super(frameType); 20.54 - this.offsetDelta = offsetDelta; 20.55 - } 20.56 - void print(JavapPrinter p) { 20.57 - super.print(p); 20.58 - if (frameType < SAME_FRAME_BOUND) { 20.59 - p.out.println(" /* same */"); 20.60 - } else { 20.61 - p.out.println(" /* same_frame_extended */"); 20.62 - p.out.println(" offset_delta = " + offsetDelta); 20.63 - } 20.64 - } 20.65 - } 20.66 - 20.67 - static class SameLocals1StackItem extends StackMapTableData { 20.68 - final int[] stack; 20.69 - SameLocals1StackItem(int frameType, int offsetDelta, int[] stack) { 20.70 - super(frameType); 20.71 - this.offsetDelta = offsetDelta; 20.72 - this.stack = stack; 20.73 - } 20.74 - void print(JavapPrinter p) { 20.75 - super.print(p); 20.76 - if (frameType == SAME_LOCALS_1_STACK_ITEM_EXTENDED) { 20.77 - p.out.println(" /* same_locals_1_stack_item_frame_extended */"); 20.78 - p.out.println(" offset_delta = " + offsetDelta); 20.79 - } else { 20.80 - p.out.println(" /* same_locals_1_stack_item */"); 20.81 - } 20.82 - p.printMap(" stack = [", stack); 20.83 - } 20.84 - } 20.85 - 20.86 - static class ChopFrame extends StackMapTableData { 20.87 - ChopFrame(int frameType, int offsetDelta) { 20.88 - super(frameType); 20.89 - this.offsetDelta = offsetDelta; 20.90 - } 20.91 - void print(JavapPrinter p) { 20.92 - super.print(p); 20.93 - p.out.println(" /* chop */"); 20.94 - p.out.println(" offset_delta = " + offsetDelta); 20.95 - } 20.96 - } 20.97 - 20.98 - static class AppendFrame extends StackMapTableData { 20.99 - final int[] locals; 20.100 - AppendFrame(int frameType, int offsetDelta, int[] locals) { 20.101 - super(frameType); 20.102 - this.offsetDelta = offsetDelta; 20.103 - this.locals = locals; 20.104 - } 20.105 - void print(JavapPrinter p) { 20.106 - super.print(p); 20.107 - p.out.println(" /* append */"); 20.108 - p.out.println(" offset_delta = " + offsetDelta); 20.109 - p.printMap(" locals = [", locals); 20.110 - } 20.111 - } 20.112 - 20.113 - static class FullFrame extends StackMapTableData { 20.114 - final int[] locals; 20.115 - final int[] stack; 20.116 - FullFrame(int offsetDelta, int[] locals, int[] stack) { 20.117 - super(FULL_FRAME); 20.118 - this.offsetDelta = offsetDelta; 20.119 - this.locals = locals; 20.120 - this.stack = stack; 20.121 - } 20.122 - void print(JavapPrinter p) { 20.123 - super.print(p); 20.124 - p.out.println(" /* full_frame */"); 20.125 - p.out.println(" offset_delta = " + offsetDelta); 20.126 - p.printMap(" locals = [", locals); 20.127 - p.printMap(" stack = [", stack); 20.128 - } 20.129 - } 20.130 - 20.131 - static StackMapTableData getInstance(DataInputStream in, MethodData method) 20.132 - throws IOException { 20.133 - int frameType = in.readUnsignedByte(); 20.134 - 20.135 - if (frameType < SAME_FRAME_BOUND) { 20.136 - // same_frame 20.137 - return new SameFrame(frameType, frameType); 20.138 - } else if (SAME_FRAME_BOUND <= frameType && frameType < SAME_LOCALS_1_STACK_ITEM_BOUND) { 20.139 - // same_locals_1_stack_item_frame 20.140 - // read additional single stack element 20.141 - return new SameLocals1StackItem(frameType, 20.142 - (frameType - SAME_FRAME_BOUND), 20.143 - StackMapData.readTypeArray(in, 1, method)); 20.144 - } else if (frameType == SAME_LOCALS_1_STACK_ITEM_EXTENDED) { 20.145 - // same_locals_1_stack_item_extended 20.146 - return new SameLocals1StackItem(frameType, 20.147 - in.readUnsignedShort(), 20.148 - StackMapData.readTypeArray(in, 1, method)); 20.149 - } else if (SAME_LOCALS_1_STACK_ITEM_EXTENDED < frameType && frameType < SAME_FRAME_EXTENDED) { 20.150 - // chop_frame or same_frame_extended 20.151 - return new ChopFrame(frameType, in.readUnsignedShort()); 20.152 - } else if (frameType == SAME_FRAME_EXTENDED) { 20.153 - // chop_frame or same_frame_extended 20.154 - return new SameFrame(frameType, in.readUnsignedShort()); 20.155 - } else if (SAME_FRAME_EXTENDED < frameType && frameType < FULL_FRAME) { 20.156 - // append_frame 20.157 - return new AppendFrame(frameType, in.readUnsignedShort(), 20.158 - StackMapData.readTypeArray(in, frameType - SAME_FRAME_EXTENDED, method)); 20.159 - } else if (frameType == FULL_FRAME) { 20.160 - // full_frame 20.161 - int offsetDelta = in.readUnsignedShort(); 20.162 - int locals_size = in.readUnsignedShort(); 20.163 - int[] locals = StackMapData.readTypeArray(in, locals_size, method); 20.164 - int stack_size = in.readUnsignedShort(); 20.165 - int[] stack = StackMapData.readTypeArray(in, stack_size, method); 20.166 - return new FullFrame(offsetDelta, locals, stack); 20.167 - } else { 20.168 - throw new ClassFormatError("unrecognized frame_type in StackMapTable"); 20.169 - } 20.170 - } 20.171 -}
21.1 --- a/src/share/classes/sun/tools/javap/Tables.java Thu May 28 09:49:56 2009 -0700 21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 21.3 @@ -1,375 +0,0 @@ 21.4 -/* 21.5 - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. 21.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.7 - * 21.8 - * This code is free software; you can redistribute it and/or modify it 21.9 - * under the terms of the GNU General Public License version 2 only, as 21.10 - * published by the Free Software Foundation. Sun designates this 21.11 - * particular file as subject to the "Classpath" exception as provided 21.12 - * by Sun in the LICENSE file that accompanied this code. 21.13 - * 21.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 21.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21.17 - * version 2 for more details (a copy is included in the LICENSE file that 21.18 - * accompanied this code). 21.19 - * 21.20 - * You should have received a copy of the GNU General Public License version 21.21 - * 2 along with this work; if not, write to the Free Software Foundation, 21.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21.23 - * 21.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 21.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 21.26 - * have any questions. 21.27 - */ 21.28 - 21.29 - 21.30 -package sun.tools.javap; 21.31 - 21.32 -import java.util.Hashtable; 21.33 -import java.util.Vector; 21.34 - 21.35 - 21.36 -public class Tables implements Constants { 21.37 - /** 21.38 - * Define mnemocodes table. 21.39 - */ 21.40 - static Hashtable<String,Integer> mnemocodes = new Hashtable<String,Integer>(301, 0.5f); 21.41 - static String opcExtNamesTab[]=new String[128]; 21.42 - static String opcPrivExtNamesTab[]=new String[128]; 21.43 - static void defineNonPriv(int opc, String mnem) { 21.44 - mnemocodes.put(opcExtNamesTab[opc]=mnem, opc_nonpriv*256+opc); 21.45 - } 21.46 - static void definePriv(int opc, String mnem) { 21.47 - mnemocodes.put(opcPrivExtNamesTab[opc]="priv_"+mnem, opc_priv*256+opc); 21.48 - } 21.49 - static void defineExt(int opc, String mnem) { 21.50 - defineNonPriv(opc, mnem); 21.51 - definePriv(opc, mnem); 21.52 - } 21.53 - static { int k; 21.54 - for (k=0; k<opc_wide; k++) { 21.55 - mnemocodes.put(opcNamesTab[k], k); 21.56 - } 21.57 - for (k=opc_wide+1; k<opcNamesTab.length; k++) { 21.58 - mnemocodes.put(opcNamesTab[k], k); 21.59 - } 21.60 - mnemocodes.put("invokenonvirtual", opc_invokespecial); 21.61 - 21.62 - mnemocodes.put("iload_w", opc_iload_w); 21.63 - mnemocodes.put("lload_w", opc_lload_w); 21.64 - mnemocodes.put("fload_w", opc_fload_w); 21.65 - mnemocodes.put("dload_w", opc_dload_w); 21.66 - mnemocodes.put("aload_w", opc_aload_w); 21.67 - mnemocodes.put("istore_w", opc_istore_w); 21.68 - mnemocodes.put("lstore_w", opc_lstore_w); 21.69 - mnemocodes.put("fstore_w", opc_fstore_w); 21.70 - mnemocodes.put("dstore_w", opc_dstore_w); 21.71 - mnemocodes.put("astore_w", opc_astore_w); 21.72 - mnemocodes.put("ret_w", opc_ret_w); 21.73 - mnemocodes.put("iinc_w", opc_iinc_w); 21.74 - 21.75 - mnemocodes.put("nonpriv", opc_nonpriv); 21.76 - mnemocodes.put("priv", opc_priv); 21.77 - 21.78 - defineExt(0, "load_ubyte"); 21.79 - defineExt(1, "load_byte"); 21.80 - defineExt(2, "load_char"); 21.81 - defineExt(3, "load_short"); 21.82 - defineExt(4, "load_word"); 21.83 - defineExt(10, "load_char_oe"); 21.84 - defineExt(11, "load_short_oe"); 21.85 - defineExt(12, "load_word_oe"); 21.86 - defineExt(16, "ncload_ubyte"); 21.87 - defineExt(17, "ncload_byte"); 21.88 - defineExt(18, "ncload_char"); 21.89 - defineExt(19, "ncload_short"); 21.90 - defineExt(20, "ncload_word"); 21.91 - defineExt(26, "ncload_char_oe"); 21.92 - defineExt(27, "ncload_short_oe"); 21.93 - defineExt(28, "ncload_word_oe"); 21.94 - defineExt(30, "cache_flush"); 21.95 - defineExt(32, "store_byte"); 21.96 - defineExt(34, "store_short"); 21.97 - defineExt(36, "store_word"); 21.98 - defineExt(42, "store_short_oe"); 21.99 - defineExt(44, "store_word_oe"); 21.100 - defineExt(48, "ncstore_byte"); 21.101 - defineExt(50, "ncstore_short"); 21.102 - defineExt(52, "ncstore_word"); 21.103 - defineExt(58, "ncstore_short_oe"); 21.104 - defineExt(60, "ncstore_word_oe"); 21.105 - defineExt(62, "zero_line"); 21.106 - defineNonPriv(5, "ret_from_sub"); 21.107 - defineNonPriv(63, "enter_sync_method"); 21.108 - definePriv(5, "ret_from_trap"); 21.109 - definePriv(6, "read_dcache_tag"); 21.110 - definePriv(7, "read_dcache_data"); 21.111 - definePriv(14, "read_icache_tag"); 21.112 - definePriv(15, "read_icache_data"); 21.113 - definePriv(22, "powerdown"); 21.114 - definePriv(23, "read_scache_data"); 21.115 - definePriv(31, "cache_index_flush"); 21.116 - definePriv(38, "write_dcache_tag"); 21.117 - definePriv(39, "write_dcache_data"); 21.118 - definePriv(46, "write_icache_tag"); 21.119 - definePriv(47, "write_icache_data"); 21.120 - definePriv(54, "reset"); 21.121 - definePriv(55, "write_scache_data"); 21.122 - for (k=0; k<32; k++) { 21.123 - definePriv(k+64, "read_reg_"+k); 21.124 - } 21.125 - for (k=0; k<32; k++) { 21.126 - definePriv(k+96, "write_reg_"+k); 21.127 - } 21.128 - } 21.129 - 21.130 - public static int opcLength(int opc) throws ArrayIndexOutOfBoundsException { 21.131 - switch (opc>>8) { 21.132 - case 0: 21.133 - return opcLengthsTab[opc]; 21.134 - case opc_wide: 21.135 - switch (opc&0xFF) { 21.136 - case opc_aload: case opc_astore: 21.137 - case opc_fload: case opc_fstore: 21.138 - case opc_iload: case opc_istore: 21.139 - case opc_lload: case opc_lstore: 21.140 - case opc_dload: case opc_dstore: 21.141 - case opc_ret: 21.142 - return 4; 21.143 - case opc_iinc: 21.144 - return 6; 21.145 - default: 21.146 - throw new ArrayIndexOutOfBoundsException(); 21.147 - } 21.148 - case opc_nonpriv: 21.149 - case opc_priv: 21.150 - return 2; 21.151 - default: 21.152 - throw new ArrayIndexOutOfBoundsException(); 21.153 - } 21.154 - } 21.155 - 21.156 - public static String opcName(int opc) { 21.157 - try { 21.158 - switch (opc>>8) { 21.159 - case 0: 21.160 - return opcNamesTab[opc]; 21.161 - case opc_wide: { 21.162 - String mnem=opcNamesTab[opc&0xFF]+"_w"; 21.163 - if (mnemocodes.get(mnem) == null) 21.164 - return null; // non-existent opcode 21.165 - return mnem; 21.166 - } 21.167 - case opc_nonpriv: 21.168 - return opcExtNamesTab[opc&0xFF]; 21.169 - case opc_priv: 21.170 - return opcPrivExtNamesTab[opc&0xFF]; 21.171 - default: 21.172 - return null; 21.173 - } 21.174 - } catch (ArrayIndexOutOfBoundsException e) { 21.175 - switch (opc) { 21.176 - case opc_nonpriv: 21.177 - return "nonpriv"; 21.178 - case opc_priv: 21.179 - return "priv"; 21.180 - default: 21.181 - return null; 21.182 - } 21.183 - } 21.184 - } 21.185 - 21.186 - public static int opcode(String mnem) { 21.187 - Integer Val=mnemocodes.get(mnem); 21.188 - if (Val == null) return -1; 21.189 - return Val.intValue(); 21.190 - } 21.191 - 21.192 - /** 21.193 - * Initialized keyword and token Hashtables 21.194 - */ 21.195 - static Vector<String> keywordNames = new Vector<String>(40); 21.196 - private static void defineKeywordName(String id, int token) { 21.197 - 21.198 - if (token>=keywordNames.size()) { 21.199 - keywordNames.setSize(token+1); 21.200 - } 21.201 - keywordNames.setElementAt(id, token); 21.202 - } 21.203 - public static String keywordName(int token) { 21.204 - if (token==-1) return "EOF"; 21.205 - if (token>=keywordNames.size()) return null; 21.206 - return keywordNames.elementAt(token); 21.207 - } 21.208 - static { 21.209 - defineKeywordName("ident", IDENT); 21.210 - defineKeywordName("STRINGVAL", STRINGVAL); 21.211 - defineKeywordName("intVal", INTVAL); 21.212 - defineKeywordName("longVal", LONGVAL); 21.213 - defineKeywordName("floatVal", FLOATVAL); 21.214 - defineKeywordName("doubleVal", DOUBLEVAL); 21.215 - defineKeywordName("SEMICOLON", SEMICOLON); 21.216 - defineKeywordName("COLON", COLON); 21.217 - defineKeywordName("LBRACE", LBRACE); 21.218 - defineKeywordName("RBRACE", RBRACE); 21.219 - } 21.220 - 21.221 - static Hashtable<String,Integer> keywords = new Hashtable<String,Integer>(40); 21.222 - public static int keyword(String idValue) { 21.223 - Integer val=keywords.get(idValue); 21.224 - if (val == null) return IDENT; 21.225 - return val.intValue(); 21.226 - } 21.227 - 21.228 - private static void defineKeyword(String id, int token) { 21.229 - keywords.put(id, token); 21.230 - defineKeywordName(id, token); 21.231 - } 21.232 - static { 21.233 - // Modifier keywords 21.234 - defineKeyword("private", PRIVATE); 21.235 - defineKeyword("public", PUBLIC); 21.236 - defineKeyword("protected", PROTECTED); 21.237 - defineKeyword("static", STATIC); 21.238 - defineKeyword("transient", TRANSIENT); 21.239 - defineKeyword("synchronized", SYNCHRONIZED); 21.240 - defineKeyword("super", SUPER); 21.241 - defineKeyword("native", NATIVE); 21.242 - defineKeyword("abstract", ABSTRACT); 21.243 - defineKeyword("volatile", VOLATILE); 21.244 - defineKeyword("final", FINAL); 21.245 - defineKeyword("interface",INTERFACE); 21.246 - defineKeyword("synthetic",SYNTHETIC); 21.247 - defineKeyword("strict",STRICT); 21.248 - 21.249 - // Declaration keywords 21.250 - defineKeyword("package",PACKAGE); 21.251 - defineKeyword("class",CLASS); 21.252 - defineKeyword("extends",EXTENDS); 21.253 - defineKeyword("implements",IMPLEMENTS); 21.254 - defineKeyword("const", CONST); 21.255 - defineKeyword("throws",THROWS); 21.256 - defineKeyword("interface",INTERFACE); 21.257 - defineKeyword("Method",METHODREF); 21.258 - defineKeyword("Field",FIELDREF); 21.259 - defineKeyword("stack",STACK); 21.260 - defineKeyword("locals",LOCAL); 21.261 - 21.262 - // used in switchtables 21.263 - defineKeyword("default", DEFAULT); 21.264 - 21.265 - // used in inner class declarations 21.266 - defineKeyword("InnerClass", INNERCLASS); 21.267 - defineKeyword("of", OF); 21.268 - 21.269 - // misc 21.270 - defineKeyword("bits",BITS); 21.271 - defineKeyword("Infinity",INF); 21.272 - defineKeyword("Inf",INF); 21.273 - defineKeyword("NaN",NAN); 21.274 - } 21.275 - 21.276 - /** 21.277 - * Define tag table. 21.278 - */ 21.279 - private static Vector<String> tagNames = new Vector<String>(10); 21.280 - private static Hashtable<String,Integer> Tags = new Hashtable<String,Integer>(10); 21.281 - static { 21.282 - defineTag("Asciz",CONSTANT_UTF8); 21.283 - defineTag("int",CONSTANT_INTEGER); 21.284 - defineTag("float",CONSTANT_FLOAT); 21.285 - defineTag("long",CONSTANT_LONG); 21.286 - defineTag("double",CONSTANT_DOUBLE); 21.287 - defineTag("class",CONSTANT_CLASS); 21.288 - defineTag("String",CONSTANT_STRING); 21.289 - defineTag("Field",CONSTANT_FIELD); 21.290 - defineTag("Method",CONSTANT_METHOD); 21.291 - defineTag("InterfaceMethod",CONSTANT_INTERFACEMETHOD); 21.292 - defineTag("NameAndType",CONSTANT_NAMEANDTYPE); 21.293 - } 21.294 - private static void defineTag(String id, int val) { 21.295 - Tags.put(id, val); 21.296 - if (val>=tagNames.size()) { 21.297 - tagNames.setSize(val+1); 21.298 - } 21.299 - tagNames.setElementAt(id, val); 21.300 - } 21.301 - public static String tagName(int tag) { 21.302 - if (tag>=tagNames.size()) return null; 21.303 - return tagNames.elementAt(tag); 21.304 - } 21.305 - public static int tagValue(String idValue) { 21.306 - Integer Val=Tags.get(idValue); 21.307 - if (Val == null) return 0; 21.308 - return Val.intValue(); 21.309 - } 21.310 - 21.311 - /** 21.312 - * Define type table. These types used in "newarray" instruction only. 21.313 - */ 21.314 - private static Vector<String> typeNames = new Vector<String>(10); 21.315 - private static Hashtable<String,Integer> Types = new Hashtable<String,Integer>(10); 21.316 - static { 21.317 - defineType("int",T_INT); 21.318 - defineType("long",T_LONG); 21.319 - defineType("float",T_FLOAT); 21.320 - defineType("double",T_DOUBLE); 21.321 - defineType("class",T_CLASS); 21.322 - defineType("boolean",T_BOOLEAN); 21.323 - defineType("char",T_CHAR); 21.324 - defineType("byte",T_BYTE); 21.325 - defineType("short",T_SHORT); 21.326 - } 21.327 - private static void defineType(String id, int val) { 21.328 - Types.put(id, val); 21.329 - if (val>=typeNames.size()) { 21.330 - typeNames.setSize(val+1); 21.331 - } 21.332 - typeNames.setElementAt(id, val); 21.333 - } 21.334 - public static int typeValue(String idValue) { 21.335 - Integer Val=Types.get(idValue); 21.336 - if (Val == null) return -1; 21.337 - return Val.intValue(); 21.338 - } 21.339 - public static String typeName(int type) { 21.340 - if (type>=typeNames.size()) return null; 21.341 - return typeNames.elementAt(type); 21.342 - } 21.343 - 21.344 - /** 21.345 - * Define MapTypes table. 21.346 - * These constants used in stackmap tables only. 21.347 - */ 21.348 - private static Vector<String> mapTypeNames = new Vector<String>(10); 21.349 - private static Hashtable<String,Integer> MapTypes = new Hashtable<String,Integer>(10); 21.350 - static { 21.351 - defineMapType("bogus", ITEM_Bogus); 21.352 - defineMapType("int", ITEM_Integer); 21.353 - defineMapType("float", ITEM_Float); 21.354 - defineMapType("double", ITEM_Double); 21.355 - defineMapType("long", ITEM_Long); 21.356 - defineMapType("null", ITEM_Null); 21.357 - defineMapType("this", ITEM_InitObject); 21.358 - defineMapType("CP", ITEM_Object); 21.359 - defineMapType("uninitialized", ITEM_NewObject); 21.360 - } 21.361 - private static void defineMapType(String id, int val) { 21.362 - MapTypes.put(id, val); 21.363 - if (val>=mapTypeNames.size()) { 21.364 - mapTypeNames.setSize(val+1); 21.365 - } 21.366 - mapTypeNames.setElementAt(id, val); 21.367 - } 21.368 - public static int mapTypeValue(String idValue) { 21.369 - Integer Val=MapTypes.get(idValue); 21.370 - if (Val == null) return -1; 21.371 - return Val.intValue(); 21.372 - } 21.373 - public static String mapTypeName(int type) { 21.374 - if (type>=mapTypeNames.size()) return null; 21.375 - return mapTypeNames.elementAt(type); 21.376 - } 21.377 - 21.378 -}
22.1 --- a/src/share/classes/sun/tools/javap/TrapData.java Thu May 28 09:49:56 2009 -0700 22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 22.3 @@ -1,60 +0,0 @@ 22.4 -/* 22.5 - * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved. 22.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.7 - * 22.8 - * This code is free software; you can redistribute it and/or modify it 22.9 - * under the terms of the GNU General Public License version 2 only, as 22.10 - * published by the Free Software Foundation. Sun designates this 22.11 - * particular file as subject to the "Classpath" exception as provided 22.12 - * by Sun in the LICENSE file that accompanied this code. 22.13 - * 22.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 22.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22.17 - * version 2 for more details (a copy is included in the LICENSE file that 22.18 - * accompanied this code). 22.19 - * 22.20 - * You should have received a copy of the GNU General Public License version 22.21 - * 2 along with this work; if not, write to the Free Software Foundation, 22.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22.23 - * 22.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 22.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 22.26 - * have any questions. 22.27 - */ 22.28 - 22.29 - 22.30 -package sun.tools.javap; 22.31 - 22.32 -import java.util.*; 22.33 -import java.io.*; 22.34 - 22.35 -/** 22.36 - * Stores exception table data in code attribute. 22.37 - * 22.38 - * @author Sucheta Dambalkar (Adopted code from jdis) 22.39 - */ 22.40 -class TrapData { 22.41 - short start_pc, end_pc, handler_pc, catch_cpx; 22.42 - int num; 22.43 - 22.44 - 22.45 - /** 22.46 - * Read and store exception table data in code attribute. 22.47 - */ 22.48 - public TrapData(DataInputStream in, int num) throws IOException { 22.49 - this.num=num; 22.50 - start_pc = in.readShort(); 22.51 - end_pc=in.readShort(); 22.52 - handler_pc=in.readShort(); 22.53 - catch_cpx=in.readShort(); 22.54 - } 22.55 - 22.56 - /** 22.57 - * returns recommended identifier 22.58 - */ 22.59 - public String ident() { 22.60 - return "t"+num; 22.61 - } 22.62 - 22.63 -}
23.1 --- a/src/share/classes/sun/tools/javap/TypeSignature.java Thu May 28 09:49:56 2009 -0700 23.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 23.3 @@ -1,295 +0,0 @@ 23.4 -/* 23.5 - * Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved. 23.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.7 - * 23.8 - * This code is free software; you can redistribute it and/or modify it 23.9 - * under the terms of the GNU General Public License version 2 only, as 23.10 - * published by the Free Software Foundation. Sun designates this 23.11 - * particular file as subject to the "Classpath" exception as provided 23.12 - * by Sun in the LICENSE file that accompanied this code. 23.13 - * 23.14 - * This code is distributed in the hope that it will be useful, but WITHOUT 23.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 23.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 23.17 - * version 2 for more details (a copy is included in the LICENSE file that 23.18 - * accompanied this code). 23.19 - * 23.20 - * You should have received a copy of the GNU General Public License version 23.21 - * 2 along with this work; if not, write to the Free Software Foundation, 23.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23.23 - * 23.24 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 23.25 - * CA 95054 USA or visit www.sun.com if you need additional information or 23.26 - * have any questions. 23.27 - */ 23.28 - 23.29 - 23.30 -package sun.tools.javap; 23.31 - 23.32 -import java.util.*; 23.33 -import java.io.*; 23.34 - 23.35 -/** 23.36 - * Returns java type signature. 23.37 - * 23.38 - * @author Sucheta Dambalkar 23.39 - */ 23.40 -public class TypeSignature { 23.41 - 23.42 - String parameters = null; 23.43 - String returntype = null; 23.44 - String fieldtype = null; 23.45 - int argumentlength = 0; 23.46 - 23.47 - public TypeSignature(String JVMSignature){ 23.48 - 23.49 - if(JVMSignature != null){ 23.50 - if(JVMSignature.indexOf("(") == -1){ 23.51 - //This is a field type. 23.52 - this.fieldtype = getFieldTypeSignature(JVMSignature); 23.53 - }else { 23.54 - String parameterdes = null; 23.55 - if((JVMSignature.indexOf(")")-1) > (JVMSignature.indexOf("("))){ 23.56 - //Get parameter signature. 23.57 - parameterdes = 23.58 - JVMSignature.substring(JVMSignature.indexOf("(")+1, 23.59 - JVMSignature.indexOf(")")); 23.60 - this.parameters = getParametersHelper(parameterdes); 23.61 - }else this.parameters = "()"; 23.62 - //Get return type signature. 23.63 - String returndes = JVMSignature.substring(JVMSignature.lastIndexOf(")")+1); 23.64 - this.returntype = getReturnTypeHelper(returndes); 23.65 - } 23.66 - } 23.67 - } 23.68 - 23.69 - /** 23.70 - * Returns java type signature of a field. 23.71 - */ 23.72 - public String getFieldTypeSignature(String fielddes){ 23.73 - if(fielddes.startsWith("L")){ 23.74 - return(getObjectType(fielddes)); 23.75 - }else if(fielddes.startsWith("[")){ 23.76 - return(getArrayType(fielddes)); 23.77 - }else 23.78 - return(getBaseType(fielddes)); 23.79 - } 23.80 - 23.81 - /** 23.82 - * Returns java type signature of a parameter. 23.83 - */ 23.84 - public String getParametersHelper(String parameterdes){ 23.85 - Vector<String> parameters = new Vector<String>(); 23.86 - int startindex = -1; 23.87 - int endindex = -1; 23.88 - String param = ""; 23.89 - 23.90 - while(parameterdes != null){ 23.91 - 23.92 - if(parameterdes.startsWith("L")){ 23.93 - //parameter is a object. 23.94 - startindex = parameterdes.indexOf("L"); 23.95 - endindex = parameterdes.indexOf(";"); 23.96 - if(startindex < parameterdes.length()) { 23.97 - if(endindex == parameterdes.length()-1) { 23.98 - //last parameter 23.99 - param = parameterdes.substring(startindex); 23.100 - parameterdes = null; 23.101 - }else if(endindex+1 < parameterdes.length()){ 23.102 - //rest parameters 23.103 - param = parameterdes.substring(startindex, endindex+1); 23.104 - parameterdes = parameterdes.substring(endindex+1); 23.105 - 23.106 - } 23.107 - parameters.add(getObjectType(param)); 23.108 - } 23.109 - }else if(parameterdes.startsWith("[")){ 23.110 - //parameter is an array. 23.111 - String componentType = ""; 23.112 - int enddim = -1; 23.113 - int st = 0; 23.114 - while(true){ 23.115 - if(st < parameterdes.length()){ 23.116 - if(parameterdes.charAt(st) == '['){ 23.117 - 23.118 - enddim = st; 23.119 - st++; 23.120 - } 23.121 - else break; 23.122 - } 23.123 - else break; 23.124 - } 23.125 - 23.126 - if(enddim+1 < parameterdes.length()){ 23.127 - /* Array dimension.*/ 23.128 - param = parameterdes.substring(0,enddim+1); 23.129 - 23.130 - } 23.131 - 23.132 - int stotherparam = param.lastIndexOf("[")+1; 23.133 - 23.134 - if(stotherparam < parameterdes.length()){ 23.135 - componentType = parameterdes.substring(stotherparam); 23.136 - } 23.137 - 23.138 - if(componentType.startsWith("L")){ 23.139 - //parameter is array of objects. 23.140 - startindex = parameterdes.indexOf("L"); 23.141 - endindex = parameterdes.indexOf(";"); 23.142 - 23.143 - if(endindex == parameterdes.length()-1){ 23.144 - //last parameter 23.145 - param += parameterdes.substring(startindex); 23.146 - parameterdes = null; 23.147 - }else if(endindex+1 < parameterdes.length()){ 23.148 - //rest parameters 23.149 - param += parameterdes.substring(startindex, endindex+1); 23.150 - parameterdes = parameterdes.substring(endindex+1); 23.151 - } 23.152 - }else{ 23.153 - //parameter is array of base type. 23.154 - if(componentType.length() == 1){ 23.155 - //last parameter. 23.156 - param += componentType; 23.157 - parameterdes = null; 23.158 - } 23.159 - else if (componentType.length() > 1) { 23.160 - //rest parameters. 23.161 - param += componentType.substring(0,1); 23.162 - parameterdes = componentType.substring(1); 23.163 - } 23.164 - } 23.165 - parameters.add(getArrayType(param)); 23.166 - 23.167 - 23.168 - }else { 23.169 - 23.170 - //parameter is of base type. 23.171 - if(parameterdes.length() == 1){ 23.172 - //last parameter 23.173 - param = parameterdes; 23.174 - parameterdes = null; 23.175 - } 23.176 - else if (parameterdes.length() > 1) { 23.177 - //rest parameters. 23.178 - param = parameterdes.substring(0,1); 23.179 - parameterdes = parameterdes.substring(1); 23.180 - } 23.181 - parameters.add(getBaseType(param)); 23.182 - } 23.183 - } 23.184 - 23.185 - /* number of arguments of a method.*/ 23.186 - argumentlength = parameters.size(); 23.187 - 23.188 - /* java type signature.*/ 23.189 - String parametersignature = "("; 23.190 - int i; 23.191 - 23.192 - for(i = 0; i < parameters.size(); i++){ 23.193 - parametersignature += parameters.elementAt(i); 23.194 - if(i != parameters.size()-1){ 23.195 - parametersignature += ", "; 23.196 - } 23.197 - } 23.198 - parametersignature += ")"; 23.199 - return parametersignature; 23.200 - } 23.201 - 23.202 - /** 23.203 - * Returns java type signature for a return type. 23.204 - */ 23.205 - public String getReturnTypeHelper(String returndes){ 23.206 - return getFieldTypeSignature(returndes); 23.207 - } 23.208 - 23.209 - /** 23.210 - * Returns java type signature for a base type. 23.211 - */ 23.212 - public String getBaseType(String baseType){ 23.213 - if(baseType != null){ 23.214 - if(baseType.equals("B")) return "byte"; 23.215 - else if(baseType.equals("C")) return "char"; 23.216 - else if(baseType.equals("D")) return "double"; 23.217 - else if(baseType.equals("F")) return "float"; 23.218 - else if(baseType.equals("I")) return "int"; 23.219 - else if(baseType.equals("J")) return "long"; 23.220 - else if(baseType.equals("S")) return "short"; 23.221 - else if(baseType.equals("Z")) return "boolean"; 23.222 - else if(baseType.equals("V")) return "void"; 23.223 - } 23.224 - return null; 23.225 - } 23.226 - 23.227 - /** 23.228 - * Returns java type signature for a object type. 23.229 - */ 23.230 - public String getObjectType(String JVMobjectType) { 23.231 - String objectType = ""; 23.232 - int startindex = JVMobjectType.indexOf("L")+1; 23.233 - int endindex = JVMobjectType.indexOf(";"); 23.234 - if((startindex != -1) && (endindex != -1)){ 23.235 - if((startindex < JVMobjectType.length()) && (endindex < JVMobjectType.length())){ 23.236 - objectType = JVMobjectType.substring(startindex, endindex); 23.237 - } 23.238 - objectType = objectType.replace('/','.'); 23.239 - return objectType; 23.240 - } 23.241 - return null; 23.242 - } 23.243 - 23.244 - /** 23.245 - * Returns java type signature for array type. 23.246 - */ 23.247 - public String getArrayType(String arrayType) { 23.248 - if(arrayType != null){ 23.249 - String dimention = ""; 23.250 - 23.251 - while(arrayType.indexOf("[") != -1){ 23.252 - dimention += "[]"; 23.253 - 23.254 - int startindex = arrayType.indexOf("[")+1; 23.255 - if(startindex <= arrayType.length()){ 23.256 - arrayType = arrayType.substring(startindex); 23.257 - } 23.258 - } 23.259 - 23.260 - String componentType = ""; 23.261 - if(arrayType.startsWith("L")){ 23.262 - componentType = getObjectType(arrayType); 23.263 - }else { 23.264 - componentType = getBaseType(arrayType); 23.265 - } 23.266 - return componentType+dimention; 23.267 - } 23.268 - return null; 23.269 - } 23.270 - 23.271 - /** 23.272 - * Returns java type signature for parameters. 23.273 - */ 23.274 - public String getParameters(){ 23.275 - return parameters; 23.276 - } 23.277 - 23.278 - /** 23.279 - * Returns java type signature for return type. 23.280 - */ 23.281 - public String getReturnType(){ 23.282 - return returntype; 23.283 - } 23.284 - 23.285 - /** 23.286 - * Returns java type signature for field type. 23.287 - */ 23.288 - public String getFieldType(){ 23.289 - return fieldtype; 23.290 - } 23.291 - 23.292 - /** 23.293 - * Return number of arguments of a method. 23.294 - */ 23.295 - public int getArgumentlength(){ 23.296 - return argumentlength; 23.297 - } 23.298 -}
24.1 --- a/test/tools/javap/ExtPath.java Thu May 28 09:49:56 2009 -0700 24.2 +++ b/test/tools/javap/ExtPath.java Fri May 29 16:26:41 2009 -0700 24.3 @@ -30,11 +30,12 @@ 24.4 * @run main/othervm ExtPath com.sun.crypto.provider.SunJCE 24.5 */ 24.6 24.7 -import sun.tools.javap.Main; 24.8 +import com.sun.tools.javap.Main; 24.9 import java.io.*; 24.10 24.11 public class ExtPath { 24.12 public static void main(String[] args) { 24.13 - Main.entry(args); 24.14 + PrintWriter pw = new PrintWriter(System.out, true); 24.15 + Main.run(args, pw); 24.16 } 24.17 }
25.1 --- a/test/tools/javap/ListTest.java Thu May 28 09:49:56 2009 -0700 25.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 25.3 @@ -1,152 +0,0 @@ 25.4 -/* 25.5 - * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 25.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.7 - * 25.8 - * This code is free software; you can redistribute it and/or modify it 25.9 - * under the terms of the GNU General Public License version 2 only, as 25.10 - * published by the Free Software Foundation. 25.11 - * 25.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 25.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25.15 - * version 2 for more details (a copy is included in the LICENSE file that 25.16 - * accompanied this code). 25.17 - * 25.18 - * You should have received a copy of the GNU General Public License version 25.19 - * 2 along with this work; if not, write to the Free Software Foundation, 25.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 25.21 - * 25.22 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 25.23 - * CA 95054 USA or visit www.sun.com if you need additional information or 25.24 - * have any questions. 25.25 - */ 25.26 - 25.27 -import java.io.*; 25.28 -import java.util.*; 25.29 -import javax.tools.*; 25.30 - 25.31 -/* 25.32 - * @test 25.33 - * @bug 6439940 25.34 - * @summary Cleanup javap implementation 25.35 - * @run main/othervm ListTest 25.36 - */ 25.37 -public class ListTest { 25.38 - public static void main(String[] args) throws Exception { 25.39 - new ListTest().run(); 25.40 - } 25.41 - 25.42 - ListTest() { 25.43 - String v = System.getProperty("view.cmd"); 25.44 - // v = "/opt/teamware/7.7/bin/filemerge -r"; 25.45 - if (v != null) { 25.46 - viewResults = true; 25.47 - viewCmd = Arrays.asList(v.split(" +")); 25.48 - } 25.49 - } 25.50 - 25.51 - void run() throws Exception { 25.52 - StandardLocation[] locs = new StandardLocation[] { 25.53 - StandardLocation.PLATFORM_CLASS_PATH, 25.54 - StandardLocation.CLASS_PATH, 25.55 - }; 25.56 - 25.57 - int count = 0; 25.58 - int pass = 0; 25.59 - for (StandardLocation loc: locs) { 25.60 - for (String testClassName: list(loc)) { 25.61 - count++; 25.62 - if (test(testClassName)) 25.63 - pass++; 25.64 - } 25.65 - } 25.66 - 25.67 - if (pass < count) 25.68 - throw new Error(pass + "/" + count + " test cases passed"); 25.69 - } 25.70 - 25.71 - Iterable<String> list(StandardLocation loc) throws IOException { 25.72 - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 25.73 - StandardJavaFileManager sfm = compiler.getStandardFileManager(null, null, null); 25.74 - Set<JavaFileObject.Kind> kinds = Collections.singleton(JavaFileObject.Kind.CLASS); 25.75 - 25.76 - List<String> list = new ArrayList<String>(); 25.77 - for (JavaFileObject fo: sfm.list(loc, testPackage, kinds, true)) { 25.78 - //System.err.println(com.sun.tools.javac.util.Old199.getPath(fo)); 25.79 - list.add(sfm.inferBinaryName(loc, fo)); 25.80 - } 25.81 - return list; 25.82 - } 25.83 - 25.84 - boolean test(String testClassName) throws Exception { 25.85 - String[] args = new String[options.size() + 1]; 25.86 - options.toArray(args); 25.87 - args[args.length - 1] = testClassName; 25.88 - byte[] oldOut = runOldJavap(args); 25.89 - byte[] newOut = runNewJavap(args); 25.90 - boolean ok = equal(oldOut, newOut); 25.91 - System.err.println((ok ? "pass" : "FAIL") + ": " + testClassName); 25.92 - if (!ok && viewResults) 25.93 - view(oldOut, newOut); 25.94 - return ok; 25.95 - } 25.96 - 25.97 - byte[] runOldJavap(String[] args) { 25.98 - //System.err.println("OLD: " + Arrays.asList(args)); 25.99 - PrintStream oldOut = System.out; 25.100 - ByteArrayOutputStream out = new ByteArrayOutputStream(); 25.101 - System.setOut(new PrintStream(out)); 25.102 - try { 25.103 - sun.tools.javap.Main.entry(args); 25.104 - } finally { 25.105 - System.setOut(oldOut); 25.106 - } 25.107 - return out.toByteArray(); 25.108 - } 25.109 - 25.110 - byte[] runNewJavap(String[] args) { 25.111 - String[] nArgs = new String[args.length + 2]; 25.112 - nArgs[0] = "-XDcompat"; 25.113 - nArgs[1] = "-XDignore.symbol.file"; 25.114 - System.arraycopy(args, 0, nArgs, 2, args.length); 25.115 - //System.err.println("NEW: " + Arrays.asList(nArgs)); 25.116 - ByteArrayOutputStream out = new ByteArrayOutputStream(); 25.117 - com.sun.tools.javap.Main.run(nArgs, 25.118 - new PrintWriter(new OutputStreamWriter(out), true)); 25.119 - return out.toByteArray(); 25.120 - } 25.121 - 25.122 - File write(byte[] text, String suffix) throws IOException { 25.123 - File f = new File("ListTest." + suffix); 25.124 - FileOutputStream out = new FileOutputStream(f); 25.125 - out.write(text); 25.126 - out.close(); 25.127 - return f; 25.128 - } 25.129 - 25.130 - boolean equal(byte[] a1, byte[] a2) { 25.131 - return Arrays.equals(a1, a2); 25.132 - } 25.133 - 25.134 - void view(byte[] oldOut, byte[] newOut) throws Exception { 25.135 - File oldFile = write(oldOut, "old"); 25.136 - File newFile = write(newOut, "new"); 25.137 - List<String> cmd = new ArrayList<String>(); 25.138 - cmd.addAll(viewCmd); 25.139 - cmd.add(oldFile.getPath()); 25.140 - cmd.add(newFile.getPath()); 25.141 - Process p = new ProcessBuilder(cmd).redirectErrorStream(true).start(); 25.142 - p.getOutputStream().close(); 25.143 - String line; 25.144 - BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); 25.145 - while ((line = in.readLine()) != null) 25.146 - System.err.println(line); 25.147 - in.close(); 25.148 - p.waitFor(); 25.149 - } 25.150 - 25.151 - String testPackage = "java.lang"; 25.152 - List<String> options = Arrays.asList("-v"); 25.153 - boolean viewResults; 25.154 - List<String> viewCmd; 25.155 -}
26.1 --- a/test/tools/javap/OptionTest.java Thu May 28 09:49:56 2009 -0700 26.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 26.3 @@ -1,143 +0,0 @@ 26.4 -/* 26.5 - * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved. 26.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.7 - * 26.8 - * This code is free software; you can redistribute it and/or modify it 26.9 - * under the terms of the GNU General Public License version 2 only, as 26.10 - * published by the Free Software Foundation. 26.11 - * 26.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 26.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 26.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 26.15 - * version 2 for more details (a copy is included in the LICENSE file that 26.16 - * accompanied this code). 26.17 - * 26.18 - * You should have received a copy of the GNU General Public License version 26.19 - * 2 along with this work; if not, write to the Free Software Foundation, 26.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26.21 - * 26.22 - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 26.23 - * CA 95054 USA or visit www.sun.com if you need additional information or 26.24 - * have any questions. 26.25 - */ 26.26 - 26.27 -import java.io.*; 26.28 -import java.util.*; 26.29 - 26.30 -/* 26.31 - * @test 26.32 - * @bug 6439940 26.33 - * @summary Cleanup javap implementation 26.34 - * @run main/othervm OptionTest 26.35 - */ 26.36 -public class OptionTest { 26.37 - public static void main(String[] args) throws Exception { 26.38 - new OptionTest().run(); 26.39 - } 26.40 - 26.41 - OptionTest() { 26.42 - String v = System.getProperty("view.cmd"); 26.43 - if (v != null) { 26.44 - viewResults = true; 26.45 - viewCmd = Arrays.asList(v.split(" +")); 26.46 - } 26.47 - } 26.48 - 26.49 - 26.50 - void run() throws Exception { 26.51 - int count = 0; 26.52 - int pass = 0; 26.53 - // try combinations of options and compare old javap against new javap 26.54 - for (int i = 0; i < (1<<8); i++) { 26.55 - List<String> options = new ArrayList<String>(); 26.56 - if ((i & 0x01) != 0) 26.57 - options.add("-c"); 26.58 - if ((i & 0x02) != 0) 26.59 - options.add("-l"); 26.60 - if ((i & 0x04) != 0) 26.61 - options.add("-public"); 26.62 - if ((i & 0x08) != 0) 26.63 - options.add("-protected"); 26.64 - if ((i & 0x10) != 0) 26.65 - options.add("-package"); 26.66 - if ((i & 0x20) != 0) 26.67 - options.add("-private"); 26.68 - if ((i & 0x40) != 0) 26.69 - options.add("-s"); 26.70 - if ((i & 0x80) != 0) 26.71 - options.add("-verbose"); 26.72 - count++; 26.73 - if (test(options)) 26.74 - pass++; 26.75 - } 26.76 - 26.77 - if (pass < count) 26.78 - throw new Error(pass + "/" + count + " test cases passed"); 26.79 - } 26.80 - 26.81 - boolean test(List<String> options) throws Exception { 26.82 - String[] args = new String[options.size() + 1]; 26.83 - options.toArray(args); 26.84 - args[args.length - 1] = testClassName; 26.85 - String oldOut = runOldJavap(args); 26.86 - String newOut = runNewJavap(args); 26.87 - boolean ok = oldOut.equals(newOut); 26.88 - System.err.println((ok ? "pass" : "FAIL") + ": " + options); 26.89 - if (!ok && viewResults) 26.90 - view(oldOut, newOut); 26.91 - return ok; 26.92 - } 26.93 - 26.94 - String runOldJavap(String[] args) { 26.95 - //System.err.println("OLD: " + Arrays.asList(args)); 26.96 - PrintStream oldOut = System.out; 26.97 - ByteArrayOutputStream out = new ByteArrayOutputStream(); 26.98 - System.setOut(new PrintStream(out)); 26.99 - try { 26.100 - sun.tools.javap.Main.entry(args); 26.101 - } finally { 26.102 - System.setOut(oldOut); 26.103 - } 26.104 - return out.toString(); 26.105 - } 26.106 - 26.107 - String runNewJavap(String[] args) { 26.108 - String[] nArgs = new String[args.length + 2]; 26.109 - nArgs[0] = "-XDcompat"; 26.110 - nArgs[1] = "-XDignore.symbol.file"; 26.111 - System.arraycopy(args, 0, nArgs, 2, args.length); 26.112 - //System.err.println("NEW: " + Arrays.asList(nArgs)); 26.113 - StringWriter out = new StringWriter(); 26.114 - com.sun.tools.javap.Main.run(nArgs, new PrintWriter(out, true)); 26.115 - return out.toString(); 26.116 - } 26.117 - 26.118 - File write(String text, String suffix) throws IOException { 26.119 - File f = File.createTempFile("OptionTest", suffix); 26.120 - FileWriter out = new FileWriter(f); 26.121 - out.write(text); 26.122 - out.close(); 26.123 - return f; 26.124 - } 26.125 - 26.126 - void view(String oldOut, String newOut) throws Exception { 26.127 - File oldFile = write(oldOut, "old"); 26.128 - File newFile = write(newOut, "new"); 26.129 - List<String> cmd = new ArrayList<String>(); 26.130 - cmd.addAll(viewCmd); 26.131 - cmd.add(oldFile.getPath()); 26.132 - cmd.add(newFile.getPath()); 26.133 - Process p = new ProcessBuilder(cmd).redirectErrorStream(true).start(); 26.134 - p.getOutputStream().close(); 26.135 - String line; 26.136 - BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); 26.137 - while ((line = in.readLine()) != null) 26.138 - System.err.println(line); 26.139 - in.close(); 26.140 - p.waitFor(); 26.141 - } 26.142 - 26.143 - String testClassName = "java.lang.SecurityManager"; 26.144 - boolean viewResults; 26.145 - List<String> viewCmd; 26.146 -}