Moving the bytecode parser into a single class inside the vm module - Nexus does not like modules without javadoc and I certainly don't want to publish javadoc for the former javap
1.1 --- a/pom.xml Sun Mar 03 22:50:02 2013 +0100
1.2 +++ b/pom.xml Mon Mar 04 19:20:40 2013 +0100
1.3 @@ -78,7 +78,7 @@
1.4 <exclude>*</exclude>
1.5 <exclude>.*/**</exclude>
1.6 <exclude>rt/emul/*/src/main/**</exclude>
1.7 - <exclude>rt/javap/**</exclude>
1.8 + <exclude>rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java</exclude>
1.9 <exclude>rt/mojo/src/main/resources/archetype-resources/**</exclude>
1.10 <exclude>rt/vmtest/src/test/resources/**</exclude>
1.11 <exclude>dew/src/main/resources/org/apidesign/bck2brwsr/dew/**</exclude>
2.1 --- a/rt/javap/pom.xml Sun Mar 03 22:50:02 2013 +0100
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,40 +0,0 @@
2.4 -<?xml version="1.0"?>
2.5 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2.6 - <modelVersion>4.0.0</modelVersion>
2.7 - <parent>
2.8 - <groupId>org.apidesign.bck2brwsr</groupId>
2.9 - <artifactId>rt</artifactId>
2.10 - <version>0.4-SNAPSHOT</version>
2.11 - </parent>
2.12 - <groupId>org.apidesign.bck2brwsr</groupId>
2.13 - <artifactId>javap</artifactId>
2.14 - <version>0.4-SNAPSHOT</version>
2.15 - <name>ByteCode Parser</name>
2.16 - <url>http://maven.apache.org</url>
2.17 - <properties>
2.18 - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2.19 - </properties>
2.20 - <build>
2.21 - <plugins>
2.22 - <plugin>
2.23 - <groupId>org.apache.maven.plugins</groupId>
2.24 - <artifactId>maven-compiler-plugin</artifactId>
2.25 - <version>2.5.1</version>
2.26 - <configuration>
2.27 - <compilerArguments>
2.28 - <!--<bootclasspath>non-existing</bootclasspath>-->
2.29 - </compilerArguments>
2.30 - <source>1.6</source>
2.31 - <target>1.6</target>
2.32 - </configuration>
2.33 - </plugin>
2.34 - </plugins>
2.35 - </build>
2.36 - <dependencies>
2.37 - <dependency>
2.38 - <groupId>org.apidesign.bck2brwsr</groupId>
2.39 - <artifactId>emul.mini</artifactId>
2.40 - <version>0.4-SNAPSHOT</version>
2.41 - </dependency>
2.42 - </dependencies>
2.43 -</project>
3.1 --- a/rt/javap/src/main/java/org/apidesign/javap/AnnotationParser.java Sun Mar 03 22:50:02 2013 +0100
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,145 +0,0 @@
3.4 -/*
3.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
3.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3.7 - *
3.8 - * This code is free software; you can redistribute it and/or modify it
3.9 - * under the terms of the GNU General Public License version 2 only, as
3.10 - * published by the Free Software Foundation. Oracle designates this
3.11 - * particular file as subject to the "Classpath" exception as provided
3.12 - * by Oracle in the LICENSE file that accompanied this code.
3.13 - *
3.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
3.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3.17 - * version 2 for more details (a copy is included in the LICENSE file that
3.18 - * accompanied this code).
3.19 - *
3.20 - * You should have received a copy of the GNU General Public License version
3.21 - * 2 along with this work; if not, write to the Free Software Foundation,
3.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3.23 - *
3.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3.25 - * or visit www.oracle.com if you need additional information or have any
3.26 - * questions.
3.27 - */
3.28 -package org.apidesign.javap;
3.29 -
3.30 -import java.io.ByteArrayInputStream;
3.31 -import java.io.DataInputStream;
3.32 -import java.io.IOException;
3.33 -
3.34 -/** An abstract parser for annotation definitions. Analyses the bytes and
3.35 - * performs some callbacks to the overriden parser methods.
3.36 - *
3.37 - * @author Jaroslav Tulach <jtulach@netbeans.org>
3.38 - */
3.39 -public class AnnotationParser {
3.40 - private final boolean textual;
3.41 - private final boolean iterateArray;
3.42 -
3.43 - protected AnnotationParser(boolean textual, boolean iterateArray) {
3.44 - this.textual = textual;
3.45 - this.iterateArray = iterateArray;
3.46 - }
3.47 -
3.48 - protected void visitAnnotationStart(String type, boolean top) throws IOException {
3.49 - }
3.50 -
3.51 - protected void visitAnnotationEnd(String type, boolean top) throws IOException {
3.52 - }
3.53 -
3.54 - protected void visitValueStart(String attrName, char type) throws IOException {
3.55 - }
3.56 -
3.57 - protected void visitValueEnd(String attrName, char type) throws IOException {
3.58 - }
3.59 -
3.60 -
3.61 - protected void visitAttr(
3.62 - String annoType, String attr, String attrType, String value
3.63 - ) throws IOException {
3.64 - }
3.65 -
3.66 - protected void visitEnumAttr(
3.67 - String annoType, String attr, String attrType, String value
3.68 - ) throws IOException {
3.69 - visitAttr(annoType, attr, attrType, value);
3.70 - }
3.71 -
3.72 - /** Initialize the parsing with constant pool from <code>cd</code>.
3.73 - *
3.74 - * @param attr the attribute defining annotations
3.75 - * @param cd constant pool
3.76 - * @throws IOException in case I/O fails
3.77 - */
3.78 - public final void parse(byte[] attr, ClassData cd) throws IOException {
3.79 - ByteArrayInputStream is = new ByteArrayInputStream(attr);
3.80 - DataInputStream dis = new DataInputStream(is);
3.81 - try {
3.82 - read(dis, cd);
3.83 - } finally {
3.84 - is.close();
3.85 - }
3.86 - }
3.87 -
3.88 - private void read(DataInputStream dis, ClassData cd) throws IOException {
3.89 - int cnt = dis.readUnsignedShort();
3.90 - for (int i = 0; i < cnt; i++) {
3.91 - readAnno(dis, cd, true);
3.92 - }
3.93 - }
3.94 -
3.95 - private void readAnno(DataInputStream dis, ClassData cd, boolean top) throws IOException {
3.96 - int type = dis.readUnsignedShort();
3.97 - String typeName = cd.StringValue(type);
3.98 - visitAnnotationStart(typeName, top);
3.99 - int cnt = dis.readUnsignedShort();
3.100 - for (int i = 0; i < cnt; i++) {
3.101 - String attrName = cd.StringValue(dis.readUnsignedShort());
3.102 - readValue(dis, cd, typeName, attrName);
3.103 - }
3.104 - visitAnnotationEnd(typeName, top);
3.105 - if (cnt == 0) {
3.106 - visitAttr(typeName, null, null, null);
3.107 - }
3.108 - }
3.109 -
3.110 - private void readValue(
3.111 - DataInputStream dis, ClassData cd, String typeName, String attrName
3.112 - ) throws IOException {
3.113 - char type = (char)dis.readByte();
3.114 - visitValueStart(attrName, type);
3.115 - if (type == '@') {
3.116 - readAnno(dis, cd, false);
3.117 - } else if ("CFJZsSIDB".indexOf(type) >= 0) { // NOI18N
3.118 - int primitive = dis.readUnsignedShort();
3.119 - String val = cd.stringValue(primitive, textual);
3.120 - String attrType;
3.121 - if (type == 's') {
3.122 - attrType = "Ljava_lang_String_2";
3.123 - if (textual) {
3.124 - val = '"' + val + '"';
3.125 - }
3.126 - } else {
3.127 - attrType = "" + type;
3.128 - }
3.129 - visitAttr(typeName, attrName, attrType, val);
3.130 - } else if (type == 'c') {
3.131 - int cls = dis.readUnsignedShort();
3.132 - } else if (type == '[') {
3.133 - int cnt = dis.readUnsignedShort();
3.134 - for (int i = 0; i < cnt; i++) {
3.135 - readValue(dis, cd, typeName, iterateArray ? attrName : null);
3.136 - }
3.137 - } else if (type == 'e') {
3.138 - int enumT = dis.readUnsignedShort();
3.139 - String attrType = cd.stringValue(enumT, textual);
3.140 - int enumN = dis.readUnsignedShort();
3.141 - String val = cd.stringValue(enumN, textual);
3.142 - visitEnumAttr(typeName, attrName, attrType, val);
3.143 - } else {
3.144 - throw new IOException("Unknown type " + type);
3.145 - }
3.146 - visitValueEnd(attrName, type);
3.147 - }
3.148 -}
4.1 --- a/rt/javap/src/main/java/org/apidesign/javap/AttrData.java Sun Mar 03 22:50:02 2013 +0100
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,77 +0,0 @@
4.4 -/*
4.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
4.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4.7 - *
4.8 - * This code is free software; you can redistribute it and/or modify it
4.9 - * under the terms of the GNU General Public License version 2 only, as
4.10 - * published by the Free Software Foundation. Oracle designates this
4.11 - * particular file as subject to the "Classpath" exception as provided
4.12 - * by Oracle in the LICENSE file that accompanied this code.
4.13 - *
4.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
4.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4.16 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4.17 - * version 2 for more details (a copy is included in the LICENSE file that
4.18 - * accompanied this code).
4.19 - *
4.20 - * You should have received a copy of the GNU General Public License version
4.21 - * 2 along with this work; if not, write to the Free Software Foundation,
4.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4.23 - *
4.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4.25 - * or visit www.oracle.com if you need additional information or have any
4.26 - * questions.
4.27 - */
4.28 -
4.29 -
4.30 -
4.31 -package org.apidesign.javap;
4.32 -
4.33 -import java.io.*;
4.34 -
4.35 -/**
4.36 - * Reads and stores attribute information.
4.37 - *
4.38 - * @author Sucheta Dambalkar (Adopted code from jdis)
4.39 - */
4.40 -class AttrData {
4.41 - ClassData cls;
4.42 - int name_cpx;
4.43 - int datalen;
4.44 - byte data[];
4.45 -
4.46 - public AttrData (ClassData cls) {
4.47 - this.cls=cls;
4.48 - }
4.49 -
4.50 - /**
4.51 - * Reads unknown attribute.
4.52 - */
4.53 - public void read(int name_cpx, DataInputStream in) throws IOException {
4.54 - this.name_cpx=name_cpx;
4.55 - datalen=in.readInt();
4.56 - data=new byte[datalen];
4.57 - in.readFully(data);
4.58 - }
4.59 -
4.60 - /**
4.61 - * Reads just the name of known attribute.
4.62 - */
4.63 - public void read(int name_cpx){
4.64 - this.name_cpx=name_cpx;
4.65 - }
4.66 -
4.67 - /**
4.68 - * Returns attribute name.
4.69 - */
4.70 - public String getAttrName(){
4.71 - return cls.getString(name_cpx);
4.72 - }
4.73 -
4.74 - /**
4.75 - * Returns attribute data.
4.76 - */
4.77 - public byte[] getData(){
4.78 - return data;
4.79 - }
4.80 -}
5.1 --- a/rt/javap/src/main/java/org/apidesign/javap/CPX.java Sun Mar 03 22:50:02 2013 +0100
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,40 +0,0 @@
5.4 -/*
5.5 - * Copyright (c) 2002, Oracle and/or its affiliates. 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. Oracle designates this
5.11 - * particular file as subject to the "Classpath" exception as provided
5.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5.25 - * or visit www.oracle.com if you need additional information or have any
5.26 - * questions.
5.27 - */
5.28 -
5.29 -
5.30 -package org.apidesign.javap;
5.31 -
5.32 -/**
5.33 - * Stores constant pool entry information with one field.
5.34 - *
5.35 - * @author Sucheta Dambalkar (Adopted code from jdis)
5.36 - */
5.37 -class CPX {
5.38 - int cpx;
5.39 -
5.40 - CPX (int cpx) {
5.41 - this.cpx=cpx;
5.42 - }
5.43 -}
6.1 --- a/rt/javap/src/main/java/org/apidesign/javap/CPX2.java Sun Mar 03 22:50:02 2013 +0100
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,41 +0,0 @@
6.4 -/*
6.5 - * Copyright (c) 2002, Oracle and/or its affiliates. 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. Oracle designates this
6.11 - * particular file as subject to the "Classpath" exception as provided
6.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6.25 - * or visit www.oracle.com if you need additional information or have any
6.26 - * questions.
6.27 - */
6.28 -
6.29 -
6.30 -package org.apidesign.javap;
6.31 -
6.32 -/**
6.33 - * Stores constant pool entry information with two fields.
6.34 - *
6.35 - * @author Sucheta Dambalkar (Adopted code from jdis)
6.36 - */
6.37 -class CPX2 {
6.38 - int cpx1,cpx2;
6.39 -
6.40 - CPX2 (int cpx1, int cpx2) {
6.41 - this.cpx1=cpx1;
6.42 - this.cpx2=cpx2;
6.43 - }
6.44 -}
7.1 --- a/rt/javap/src/main/java/org/apidesign/javap/ClassData.java Sun Mar 03 22:50:02 2013 +0100
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,713 +0,0 @@
7.4 -/*
7.5 - * Copyright (c) 2002, 2004, Oracle and/or its affiliates. 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. Oracle designates this
7.11 - * particular file as subject to the "Classpath" exception as provided
7.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
7.25 - * or visit www.oracle.com if you need additional information or have any
7.26 - * questions.
7.27 - */
7.28 -
7.29 -
7.30 -package org.apidesign.javap;
7.31 -
7.32 -import java.io.*;
7.33 -
7.34 -/**
7.35 - * Central data repository of the Java Disassembler.
7.36 - * Stores all the information in java class file.
7.37 - *
7.38 - * @author Sucheta Dambalkar (Adopted code from jdis)
7.39 - */
7.40 -public final class ClassData implements RuntimeConstants {
7.41 -
7.42 - private int magic;
7.43 - private int minor_version;
7.44 - private int major_version;
7.45 - private int cpool_count;
7.46 - private Object cpool[];
7.47 - private int access;
7.48 - private int this_class = 0;;
7.49 - private int super_class;
7.50 - private int interfaces_count;
7.51 - private int[] interfaces = new int[0];;
7.52 - private int fields_count;
7.53 - private FieldData[] fields;
7.54 - private int methods_count;
7.55 - private MethodData[] methods;
7.56 - private InnerClassData[] innerClasses;
7.57 - private int attributes_count;
7.58 - private AttrData[] attrs;
7.59 - private String classname;
7.60 - private String superclassname;
7.61 - private int source_cpx=0;
7.62 - private byte tags[];
7.63 - private Hashtable indexHashAscii = new Hashtable();
7.64 - private String pkgPrefix="";
7.65 - private int pkgPrefixLen=0;
7.66 -
7.67 - /**
7.68 - * Read classfile to disassemble.
7.69 - */
7.70 - public ClassData(InputStream infile) throws IOException {
7.71 - this.read(new DataInputStream(infile));
7.72 - }
7.73 -
7.74 - /**
7.75 - * Reads and stores class file information.
7.76 - */
7.77 - public void read(DataInputStream in) throws IOException {
7.78 - // Read the header
7.79 - magic = in.readInt();
7.80 - if (magic != JAVA_MAGIC) {
7.81 - throw new ClassFormatError("wrong magic: " +
7.82 - toHex(magic) + ", expected " +
7.83 - toHex(JAVA_MAGIC));
7.84 - }
7.85 - minor_version = in.readShort();
7.86 - major_version = in.readShort();
7.87 - if (major_version != JAVA_VERSION) {
7.88 - }
7.89 -
7.90 - // Read the constant pool
7.91 - readCP(in);
7.92 - access = in.readUnsignedShort();
7.93 - this_class = in.readUnsignedShort();
7.94 - super_class = in.readUnsignedShort();
7.95 -
7.96 - //Read interfaces.
7.97 - interfaces_count = in.readUnsignedShort();
7.98 - if(interfaces_count > 0){
7.99 - interfaces = new int[interfaces_count];
7.100 - }
7.101 - for (int i = 0; i < interfaces_count; i++) {
7.102 - interfaces[i]=in.readShort();
7.103 - }
7.104 -
7.105 - // Read the fields
7.106 - readFields(in);
7.107 -
7.108 - // Read the methods
7.109 - readMethods(in);
7.110 -
7.111 - // Read the attributes
7.112 - attributes_count = in.readUnsignedShort();
7.113 - attrs=new AttrData[attributes_count];
7.114 - for (int k = 0; k < attributes_count; k++) {
7.115 - int name_cpx=in.readUnsignedShort();
7.116 - if (getTag(name_cpx)==CONSTANT_UTF8
7.117 - && getString(name_cpx).equals("SourceFile")
7.118 - ){ if (in.readInt()!=2)
7.119 - throw new ClassFormatError("invalid attr length");
7.120 - source_cpx=in.readUnsignedShort();
7.121 - AttrData attr=new AttrData(this);
7.122 - attr.read(name_cpx);
7.123 - attrs[k]=attr;
7.124 -
7.125 - } else if (getTag(name_cpx)==CONSTANT_UTF8
7.126 - && getString(name_cpx).equals("InnerClasses")
7.127 - ){ int length=in.readInt();
7.128 - int num=in.readUnsignedShort();
7.129 - if (2+num*8 != length)
7.130 - throw new ClassFormatError("invalid attr length");
7.131 - innerClasses=new InnerClassData[num];
7.132 - for (int j = 0; j < num; j++) {
7.133 - InnerClassData innerClass=new InnerClassData(this);
7.134 - innerClass.read(in);
7.135 - innerClasses[j]=innerClass;
7.136 - }
7.137 - AttrData attr=new AttrData(this);
7.138 - attr.read(name_cpx);
7.139 - attrs[k]=attr;
7.140 - } else {
7.141 - AttrData attr=new AttrData(this);
7.142 - attr.read(name_cpx, in);
7.143 - attrs[k]=attr;
7.144 - }
7.145 - }
7.146 - in.close();
7.147 - } // end ClassData.read()
7.148 -
7.149 - /**
7.150 - * Reads and stores constant pool info.
7.151 - */
7.152 - void readCP(DataInputStream in) throws IOException {
7.153 - cpool_count = in.readUnsignedShort();
7.154 - tags = new byte[cpool_count];
7.155 - cpool = new Object[cpool_count];
7.156 - for (int i = 1; i < cpool_count; i++) {
7.157 - byte tag = in.readByte();
7.158 -
7.159 - switch(tags[i] = tag) {
7.160 - case CONSTANT_UTF8:
7.161 - String str=in.readUTF();
7.162 - indexHashAscii.put(cpool[i] = str, new Integer(i));
7.163 - break;
7.164 - case CONSTANT_INTEGER:
7.165 - cpool[i] = new Integer(in.readInt());
7.166 - break;
7.167 - case CONSTANT_FLOAT:
7.168 - cpool[i] = new Float(in.readFloat());
7.169 - break;
7.170 - case CONSTANT_LONG:
7.171 - cpool[i++] = new Long(in.readLong());
7.172 - break;
7.173 - case CONSTANT_DOUBLE:
7.174 - cpool[i++] = new Double(in.readDouble());
7.175 - break;
7.176 - case CONSTANT_CLASS:
7.177 - case CONSTANT_STRING:
7.178 - cpool[i] = new CPX(in.readUnsignedShort());
7.179 - break;
7.180 -
7.181 - case CONSTANT_FIELD:
7.182 - case CONSTANT_METHOD:
7.183 - case CONSTANT_INTERFACEMETHOD:
7.184 - case CONSTANT_NAMEANDTYPE:
7.185 - cpool[i] = new CPX2(in.readUnsignedShort(), in.readUnsignedShort());
7.186 - break;
7.187 -
7.188 - case 0:
7.189 - default:
7.190 - throw new ClassFormatError("invalid constant type: " + (int)tags[i]);
7.191 - }
7.192 - }
7.193 - }
7.194 -
7.195 - /**
7.196 - * Reads and strores field info.
7.197 - */
7.198 - protected void readFields(DataInputStream in) throws IOException {
7.199 - int fields_count = in.readUnsignedShort();
7.200 - fields=new FieldData[fields_count];
7.201 - for (int k = 0; k < fields_count; k++) {
7.202 - FieldData field=new FieldData(this);
7.203 - field.read(in);
7.204 - fields[k]=field;
7.205 - }
7.206 - }
7.207 -
7.208 - /**
7.209 - * Reads and strores Method info.
7.210 - */
7.211 - protected void readMethods(DataInputStream in) throws IOException {
7.212 - int methods_count = in.readUnsignedShort();
7.213 - methods=new MethodData[methods_count];
7.214 - for (int k = 0; k < methods_count ; k++) {
7.215 - MethodData method=new MethodData(this);
7.216 - method.read(in);
7.217 - methods[k]=method;
7.218 - }
7.219 - }
7.220 -
7.221 - /**
7.222 - * get a string
7.223 - */
7.224 - public String getString(int n) {
7.225 - if (n == 0) {
7.226 - return null;
7.227 - } else {
7.228 - return (String)cpool[n];
7.229 - }
7.230 - }
7.231 -
7.232 - /**
7.233 - * get the type of constant given an index
7.234 - */
7.235 - public byte getTag(int n) {
7.236 - try{
7.237 - return tags[n];
7.238 - } catch (ArrayIndexOutOfBoundsException e) {
7.239 - return (byte)100;
7.240 - }
7.241 - }
7.242 -
7.243 - static final String hexString="0123456789ABCDEF";
7.244 -
7.245 - public static char hexTable[]=hexString.toCharArray();
7.246 -
7.247 - static String toHex(long val, int width) {
7.248 - StringBuffer s = new StringBuffer();
7.249 - for (int i=width-1; i>=0; i--)
7.250 - s.append(hexTable[((int)(val>>(4*i)))&0xF]);
7.251 - return "0x"+s.toString();
7.252 - }
7.253 -
7.254 - static String toHex(long val) {
7.255 - int width;
7.256 - for (width=16; width>0; width--) {
7.257 - if ((val>>(width-1)*4)!=0) break;
7.258 - }
7.259 - return toHex(val, width);
7.260 - }
7.261 -
7.262 - static String toHex(int val) {
7.263 - int width;
7.264 - for (width=8; width>0; width--) {
7.265 - if ((val>>(width-1)*4)!=0) break;
7.266 - }
7.267 - return toHex(val, width);
7.268 - }
7.269 -
7.270 - /**
7.271 - * Returns the name of this class.
7.272 - */
7.273 - public String getClassName() {
7.274 - String res=null;
7.275 - if (this_class==0) {
7.276 - return res;
7.277 - }
7.278 - int tcpx;
7.279 - try {
7.280 - if (tags[this_class]!=CONSTANT_CLASS) {
7.281 - return res; //"<CP["+cpx+"] is not a Class> ";
7.282 - }
7.283 - tcpx=((CPX)cpool[this_class]).cpx;
7.284 - } catch (ArrayIndexOutOfBoundsException e) {
7.285 - return res; // "#"+cpx+"// invalid constant pool index";
7.286 - } catch (Throwable e) {
7.287 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
7.288 - }
7.289 -
7.290 - try {
7.291 - return (String)(cpool[tcpx]);
7.292 - } catch (ArrayIndexOutOfBoundsException e) {
7.293 - return res; // "class #"+scpx+"// invalid constant pool index";
7.294 - } catch (ClassCastException e) {
7.295 - return res; // "class #"+scpx+"// invalid constant pool reference";
7.296 - } catch (Throwable e) {
7.297 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
7.298 - }
7.299 -
7.300 - }
7.301 -
7.302 - /**
7.303 - * Returns the name of class at perticular index.
7.304 - */
7.305 - public String getClassName(int cpx) {
7.306 - String res="#"+cpx;
7.307 - if (cpx==0) {
7.308 - return res;
7.309 - }
7.310 - int scpx;
7.311 - try {
7.312 - if (tags[cpx]!=CONSTANT_CLASS) {
7.313 - return res; //"<CP["+cpx+"] is not a Class> ";
7.314 - }
7.315 - scpx=((CPX)cpool[cpx]).cpx;
7.316 - } catch (ArrayIndexOutOfBoundsException e) {
7.317 - return res; // "#"+cpx+"// invalid constant pool index";
7.318 - } catch (Throwable e) {
7.319 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
7.320 - }
7.321 - res="#"+scpx;
7.322 - try {
7.323 - return (String)(cpool[scpx]);
7.324 - } catch (ArrayIndexOutOfBoundsException e) {
7.325 - return res; // "class #"+scpx+"// invalid constant pool index";
7.326 - } catch (ClassCastException e) {
7.327 - return res; // "class #"+scpx+"// invalid constant pool reference";
7.328 - } catch (Throwable e) {
7.329 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
7.330 - }
7.331 - }
7.332 -
7.333 - public int getAccessFlags() {
7.334 - return access;
7.335 - }
7.336 -
7.337 - /**
7.338 - * Returns true if it is a class
7.339 - */
7.340 - public boolean isClass() {
7.341 - if((access & ACC_INTERFACE) == 0) return true;
7.342 - return false;
7.343 - }
7.344 -
7.345 - /**
7.346 - * Returns true if it is a interface.
7.347 - */
7.348 - public boolean isInterface(){
7.349 - if((access & ACC_INTERFACE) != 0) return true;
7.350 - return false;
7.351 - }
7.352 -
7.353 - /**
7.354 - * Returns true if this member is public, false otherwise.
7.355 - */
7.356 - public boolean isPublic(){
7.357 - return (access & ACC_PUBLIC) != 0;
7.358 - }
7.359 -
7.360 - /**
7.361 - * Returns the access of this class or interface.
7.362 - */
7.363 - public String[] getAccess(){
7.364 - Vector v = new Vector();
7.365 - if ((access & ACC_PUBLIC) !=0) v.addElement("public");
7.366 - if ((access & ACC_FINAL) !=0) v.addElement("final");
7.367 - if ((access & ACC_ABSTRACT) !=0) v.addElement("abstract");
7.368 - String[] accflags = new String[v.size()];
7.369 - v.copyInto(accflags);
7.370 - return accflags;
7.371 - }
7.372 -
7.373 - /**
7.374 - * Returns list of innerclasses.
7.375 - */
7.376 - public InnerClassData[] getInnerClasses(){
7.377 - return innerClasses;
7.378 - }
7.379 -
7.380 - /**
7.381 - * Returns list of attributes.
7.382 - */
7.383 - final AttrData[] getAttributes(){
7.384 - return attrs;
7.385 - }
7.386 -
7.387 - public byte[] findAnnotationData(boolean classRetention) {
7.388 - String n = classRetention ?
7.389 - "RuntimeInvisibleAnnotations" : // NOI18N
7.390 - "RuntimeVisibleAnnotations"; // NOI18N
7.391 - return findAttr(n, attrs);
7.392 - }
7.393 -
7.394 - /**
7.395 - * Returns true if superbit is set.
7.396 - */
7.397 - public boolean isSuperSet(){
7.398 - if ((access & ACC_SUPER) !=0) return true;
7.399 - return false;
7.400 - }
7.401 -
7.402 - /**
7.403 - * Returns super class name.
7.404 - */
7.405 - public String getSuperClassName(){
7.406 - String res=null;
7.407 - if (super_class==0) {
7.408 - return res;
7.409 - }
7.410 - int scpx;
7.411 - try {
7.412 - if (tags[super_class]!=CONSTANT_CLASS) {
7.413 - return res; //"<CP["+cpx+"] is not a Class> ";
7.414 - }
7.415 - scpx=((CPX)cpool[super_class]).cpx;
7.416 - } catch (ArrayIndexOutOfBoundsException e) {
7.417 - return res; // "#"+cpx+"// invalid constant pool index";
7.418 - } catch (Throwable e) {
7.419 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
7.420 - }
7.421 -
7.422 - try {
7.423 - return (String)(cpool[scpx]);
7.424 - } catch (ArrayIndexOutOfBoundsException e) {
7.425 - return res; // "class #"+scpx+"// invalid constant pool index";
7.426 - } catch (ClassCastException e) {
7.427 - return res; // "class #"+scpx+"// invalid constant pool reference";
7.428 - } catch (Throwable e) {
7.429 - return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
7.430 - }
7.431 - }
7.432 -
7.433 - /**
7.434 - * Returns list of super interfaces.
7.435 - */
7.436 - public String[] getSuperInterfaces(){
7.437 - String interfacenames[] = new String[interfaces.length];
7.438 - int interfacecpx = -1;
7.439 - for(int i = 0; i < interfaces.length; i++){
7.440 - interfacecpx=((CPX)cpool[interfaces[i]]).cpx;
7.441 - interfacenames[i] = (String)(cpool[interfacecpx]);
7.442 - }
7.443 - return interfacenames;
7.444 - }
7.445 -
7.446 - /**
7.447 - * Returns string at prticular constant pool index.
7.448 - */
7.449 - public String getStringValue(int cpoolx) {
7.450 - try {
7.451 - return ((String)cpool[cpoolx]);
7.452 - } catch (ArrayIndexOutOfBoundsException e) {
7.453 - return "//invalid constant pool index:"+cpoolx;
7.454 - } catch (ClassCastException e) {
7.455 - return "//invalid constant pool ref:"+cpoolx;
7.456 - }
7.457 - }
7.458 -
7.459 - /**
7.460 - * Returns list of field info.
7.461 - */
7.462 - public FieldData[] getFields(){
7.463 - return fields;
7.464 - }
7.465 -
7.466 - /**
7.467 - * Returns list of method info.
7.468 - */
7.469 - public MethodData[] getMethods(){
7.470 - return methods;
7.471 - }
7.472 -
7.473 - /**
7.474 - * Returns constant pool entry at that index.
7.475 - */
7.476 - public CPX2 getCpoolEntry(int cpx){
7.477 - return ((CPX2)(cpool[cpx]));
7.478 - }
7.479 -
7.480 - public Object getCpoolEntryobj(int cpx){
7.481 - return (cpool[cpx]);
7.482 - }
7.483 -
7.484 - /**
7.485 - * Returns index of this class.
7.486 - */
7.487 - public int getthis_cpx(){
7.488 - return this_class;
7.489 - }
7.490 -
7.491 - /**
7.492 - * Returns string at that index.
7.493 - */
7.494 - public String StringValue(int cpx) {
7.495 - return stringValue(cpx, false);
7.496 - }
7.497 - public String stringValue(int cpx, boolean textual) {
7.498 - return stringValue(cpx, textual, null);
7.499 - }
7.500 - public String stringValue(int cpx, String[] classRefs) {
7.501 - return stringValue(cpx, true, classRefs);
7.502 - }
7.503 - private String stringValue(int cpx, boolean textual, String[] refs) {
7.504 - if (cpx==0) return "#0";
7.505 - int tag;
7.506 - Object x;
7.507 - String suffix="";
7.508 - try {
7.509 - tag=tags[cpx];
7.510 - x=cpool[cpx];
7.511 - } catch (IndexOutOfBoundsException e) {
7.512 - return "<Incorrect CP index:"+cpx+">";
7.513 - }
7.514 -
7.515 - if (x==null) return "<NULL>";
7.516 - switch (tag) {
7.517 - case CONSTANT_UTF8: {
7.518 - if (!textual) {
7.519 - return (String)x;
7.520 - }
7.521 - StringBuilder sb=new StringBuilder();
7.522 - String s=(String)x;
7.523 - for (int k=0; k<s.length(); k++) {
7.524 - char c=s.charAt(k);
7.525 - switch (c) {
7.526 - case '\\': sb.append('\\').append('\\'); break;
7.527 - case '\t': sb.append('\\').append('t'); break;
7.528 - case '\n': sb.append('\\').append('n'); break;
7.529 - case '\r': sb.append('\\').append('r'); break;
7.530 - case '\"': sb.append('\\').append('\"'); break;
7.531 - default: sb.append(c);
7.532 - }
7.533 - }
7.534 - return sb.toString();
7.535 - }
7.536 - case CONSTANT_DOUBLE: {
7.537 - Double d=(Double)x;
7.538 - String sd=d.toString();
7.539 - if (textual) {
7.540 - return sd;
7.541 - }
7.542 - return sd+"d";
7.543 - }
7.544 - case CONSTANT_FLOAT: {
7.545 - Float f=(Float)x;
7.546 - String sf=(f).toString();
7.547 - if (textual) {
7.548 - return sf;
7.549 - }
7.550 - return sf+"f";
7.551 - }
7.552 - case CONSTANT_LONG: {
7.553 - Long ln = (Long)x;
7.554 - if (textual) {
7.555 - return ln.toString();
7.556 - }
7.557 - return ln.toString()+'l';
7.558 - }
7.559 - case CONSTANT_INTEGER: {
7.560 - Integer in = (Integer)x;
7.561 - return in.toString();
7.562 - }
7.563 - case CONSTANT_CLASS:
7.564 - String jn = getClassName(cpx);
7.565 - if (textual) {
7.566 - if (refs != null) {
7.567 - refs[0] = jn;
7.568 - }
7.569 - return jn;
7.570 - }
7.571 - return javaName(jn);
7.572 - case CONSTANT_STRING:
7.573 - String sv = stringValue(((CPX)x).cpx, textual);
7.574 - if (textual) {
7.575 - return '"' + sv + '"';
7.576 - } else {
7.577 - return sv;
7.578 - }
7.579 - case CONSTANT_FIELD:
7.580 - case CONSTANT_METHOD:
7.581 - case CONSTANT_INTERFACEMETHOD:
7.582 - //return getShortClassName(((CPX2)x).cpx1)+"."+StringValue(((CPX2)x).cpx2);
7.583 - return javaName(getClassName(((CPX2)x).cpx1))+"."+StringValue(((CPX2)x).cpx2);
7.584 -
7.585 - case CONSTANT_NAMEANDTYPE:
7.586 - return getName(((CPX2)x).cpx1)+":"+StringValue(((CPX2)x).cpx2);
7.587 - default:
7.588 - return "UnknownTag"; //TBD
7.589 - }
7.590 - }
7.591 -
7.592 - /**
7.593 - * Returns resolved java type name.
7.594 - */
7.595 - public String javaName(String name) {
7.596 - if( name==null) return "null";
7.597 - int len=name.length();
7.598 - if (len==0) return "\"\"";
7.599 - int cc='/';
7.600 - fullname: { // xxx/yyy/zzz
7.601 - int cp;
7.602 - for (int k=0; k<len; k += Character.charCount(cp)) {
7.603 - cp=name.codePointAt(k);
7.604 - if (cc=='/') {
7.605 - if (!isJavaIdentifierStart(cp)) break fullname;
7.606 - } else if (cp!='/') {
7.607 - if (!isJavaIdentifierPart(cp)) break fullname;
7.608 - }
7.609 - cc=cp;
7.610 - }
7.611 - return name;
7.612 - }
7.613 - return "\""+name+"\"";
7.614 - }
7.615 -
7.616 - public String getName(int cpx) {
7.617 - String res;
7.618 - try {
7.619 - return javaName((String)cpool[cpx]); //.replace('/','.');
7.620 - } catch (ArrayIndexOutOfBoundsException e) {
7.621 - return "<invalid constant pool index:"+cpx+">";
7.622 - } catch (ClassCastException e) {
7.623 - return "<invalid constant pool ref:"+cpx+">";
7.624 - }
7.625 - }
7.626 -
7.627 - /**
7.628 - * Returns unqualified class name.
7.629 - */
7.630 - public String getShortClassName(int cpx) {
7.631 - String classname=javaName(getClassName(cpx));
7.632 - pkgPrefixLen=classname.lastIndexOf("/")+1;
7.633 - if (pkgPrefixLen!=0) {
7.634 - pkgPrefix=classname.substring(0,pkgPrefixLen);
7.635 - if (classname.startsWith(pkgPrefix)) {
7.636 - return classname.substring(pkgPrefixLen);
7.637 - }
7.638 - }
7.639 - return classname;
7.640 - }
7.641 -
7.642 - /**
7.643 - * Returns source file name.
7.644 - */
7.645 - public String getSourceName(){
7.646 - return getName(source_cpx);
7.647 - }
7.648 -
7.649 - /**
7.650 - * Returns package name.
7.651 - */
7.652 - public String getPkgName(){
7.653 - String classname=getClassName(this_class);
7.654 - pkgPrefixLen=classname.lastIndexOf("/")+1;
7.655 - if (pkgPrefixLen!=0) {
7.656 - pkgPrefix=classname.substring(0,pkgPrefixLen);
7.657 - return("package "+pkgPrefix.substring(0,pkgPrefixLen-1)+";\n");
7.658 - }else return null;
7.659 - }
7.660 -
7.661 - /**
7.662 - * Returns total constant pool entry count.
7.663 - */
7.664 - public int getCpoolCount(){
7.665 - return cpool_count;
7.666 - }
7.667 -
7.668 - /**
7.669 - * Returns minor version of class file.
7.670 - */
7.671 - public int getMinor_version(){
7.672 - return minor_version;
7.673 - }
7.674 -
7.675 - /**
7.676 - * Returns major version of class file.
7.677 - */
7.678 - public int getMajor_version(){
7.679 - return major_version;
7.680 - }
7.681 -
7.682 - private boolean isJavaIdentifierStart(int cp) {
7.683 - return ('a' <= cp && cp <= 'z') || ('A' <= cp && cp <= 'Z');
7.684 - }
7.685 -
7.686 - private boolean isJavaIdentifierPart(int cp) {
7.687 - return isJavaIdentifierStart(cp) || ('0' <= cp && cp <= '9');
7.688 - }
7.689 -
7.690 - public String[] getNameAndType(int indx) {
7.691 - return getNameAndType(indx, 0, new String[2]);
7.692 - }
7.693 -
7.694 - private String[] getNameAndType(int indx, int at, String[] arr) {
7.695 - CPX2 c2 = getCpoolEntry(indx);
7.696 - arr[at] = StringValue(c2.cpx1);
7.697 - arr[at + 1] = StringValue(c2.cpx2);
7.698 - return arr;
7.699 - }
7.700 -
7.701 - public String[] getFieldInfoName(int indx) {
7.702 - CPX2 c2 = getCpoolEntry(indx);
7.703 - String[] arr = new String[3];
7.704 - arr[0] = getClassName(c2.cpx1);
7.705 - return getNameAndType(c2.cpx2, 1, arr);
7.706 - }
7.707 -
7.708 - static byte[] findAttr(String n, AttrData[] attrs) {
7.709 - for (AttrData ad : attrs) {
7.710 - if (n.equals(ad.getAttrName())) {
7.711 - return ad.getData();
7.712 - }
7.713 - }
7.714 - return null;
7.715 - }
7.716 -}
8.1 --- a/rt/javap/src/main/java/org/apidesign/javap/Constants.java Sun Mar 03 22:50:02 2013 +0100
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,372 +0,0 @@
8.4 -/*
8.5 - * Copyright (c) 2002, Oracle and/or its affiliates. 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. Oracle designates this
8.11 - * particular file as subject to the "Classpath" exception as provided
8.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8.25 - * or visit www.oracle.com if you need additional information or have any
8.26 - * questions.
8.27 - */
8.28 -
8.29 -
8.30 -
8.31 -package org.apidesign.javap;
8.32 -
8.33 -/**
8.34 - * This interface defines constant that are used
8.35 - * throughout the compiler. It inherits from RuntimeConstants,
8.36 - * which is an autogenerated class that contains contstants
8.37 - * defined in the interpreter.
8.38 - */
8.39 -
8.40 -public
8.41 -interface Constants extends RuntimeConstants {
8.42 -
8.43 - /**
8.44 - * End of input
8.45 - */
8.46 - public static final int EOF = -1;
8.47 -
8.48 - /*
8.49 - * Flags
8.50 - */
8.51 - public static final int F_VERBOSE = 1 << 0;
8.52 - public static final int F_DUMP = 1 << 1;
8.53 - public static final int F_WARNINGS = 1 << 2;
8.54 - public static final int F_DEBUG = 1 << 3;
8.55 - public static final int F_OPTIMIZE = 1 << 4;
8.56 - public static final int F_DEPENDENCIES = 1 << 5;
8.57 -
8.58 - /*
8.59 - * Type codes
8.60 - */
8.61 - public static final int TC_BOOLEAN = 0;
8.62 - public static final int TC_BYTE = 1;
8.63 - public static final int TC_CHAR = 2;
8.64 - public static final int TC_SHORT = 3;
8.65 - public static final int TC_INT = 4;
8.66 - public static final int TC_LONG = 5;
8.67 - public static final int TC_FLOAT = 6;
8.68 - public static final int TC_DOUBLE = 7;
8.69 - public static final int TC_NULL = 8;
8.70 - public static final int TC_ARRAY = 9;
8.71 - public static final int TC_CLASS = 10;
8.72 - public static final int TC_VOID = 11;
8.73 - public static final int TC_METHOD = 12;
8.74 - public static final int TC_ERROR = 13;
8.75 -
8.76 - /*
8.77 - * Type Masks
8.78 - */
8.79 - public static final int TM_NULL = 1 << TC_NULL;
8.80 - public static final int TM_VOID = 1 << TC_VOID;
8.81 - public static final int TM_BOOLEAN = 1 << TC_BOOLEAN;
8.82 - public static final int TM_BYTE = 1 << TC_BYTE;
8.83 - public static final int TM_CHAR = 1 << TC_CHAR;
8.84 - public static final int TM_SHORT = 1 << TC_SHORT;
8.85 - public static final int TM_INT = 1 << TC_INT;
8.86 - public static final int TM_LONG = 1 << TC_LONG;
8.87 - public static final int TM_FLOAT = 1 << TC_FLOAT;
8.88 - public static final int TM_DOUBLE = 1 << TC_DOUBLE;
8.89 - public static final int TM_ARRAY = 1 << TC_ARRAY;
8.90 - public static final int TM_CLASS = 1 << TC_CLASS;
8.91 - public static final int TM_METHOD = 1 << TC_METHOD;
8.92 - public static final int TM_ERROR = 1 << TC_ERROR;
8.93 -
8.94 - public static final int TM_INT32 = TM_BYTE | TM_SHORT | TM_CHAR | TM_INT;
8.95 - public static final int TM_NUM32 = TM_INT32 | TM_FLOAT;
8.96 - public static final int TM_NUM64 = TM_LONG | TM_DOUBLE;
8.97 - public static final int TM_INTEGER = TM_INT32 | TM_LONG;
8.98 - public static final int TM_REAL = TM_FLOAT | TM_DOUBLE;
8.99 - public static final int TM_NUMBER = TM_INTEGER | TM_REAL;
8.100 - public static final int TM_REFERENCE = TM_ARRAY | TM_CLASS | TM_NULL;
8.101 -
8.102 - /*
8.103 - * Class status
8.104 - */
8.105 - public static final int CS_UNDEFINED = 0;
8.106 - public static final int CS_UNDECIDED = 1;
8.107 - public static final int CS_BINARY = 2;
8.108 - public static final int CS_SOURCE = 3;
8.109 - public static final int CS_PARSED = 4;
8.110 - public static final int CS_COMPILED = 5;
8.111 - public static final int CS_NOTFOUND = 6;
8.112 -
8.113 - /*
8.114 - * Attributes
8.115 - */
8.116 - public static final int ATT_ALL = -1;
8.117 - public static final int ATT_CODE = 1;
8.118 -
8.119 - /*
8.120 - * Number of bits used in file offsets
8.121 - */
8.122 - public static final int OFFSETBITS = 19;
8.123 - public static final int MAXFILESIZE = (1 << OFFSETBITS) - 1;
8.124 - public static final int MAXLINENUMBER = (1 << (32 - OFFSETBITS)) - 1;
8.125 -
8.126 - /*
8.127 - * Operators
8.128 - */
8.129 - public final int COMMA = 0;
8.130 - public final int ASSIGN = 1;
8.131 -
8.132 - public final int ASGMUL = 2;
8.133 - public final int ASGDIV = 3;
8.134 - public final int ASGREM = 4;
8.135 - public final int ASGADD = 5;
8.136 - public final int ASGSUB = 6;
8.137 - public final int ASGLSHIFT = 7;
8.138 - public final int ASGRSHIFT = 8;
8.139 - public final int ASGURSHIFT = 9;
8.140 - public final int ASGBITAND = 10;
8.141 - public final int ASGBITOR = 11;
8.142 - public final int ASGBITXOR = 12;
8.143 -
8.144 - public final int COND = 13;
8.145 - public final int OR = 14;
8.146 - public final int AND = 15;
8.147 - public final int BITOR = 16;
8.148 - public final int BITXOR = 17;
8.149 - public final int BITAND = 18;
8.150 - public final int NE = 19;
8.151 - public final int EQ = 20;
8.152 - public final int GE = 21;
8.153 - public final int GT = 22;
8.154 - public final int LE = 23;
8.155 - public final int LT = 24;
8.156 - public final int INSTANCEOF = 25;
8.157 - public final int LSHIFT = 26;
8.158 - public final int RSHIFT = 27;
8.159 - public final int URSHIFT = 28;
8.160 - public final int ADD = 29;
8.161 - public final int SUB = 30;
8.162 - public final int DIV = 31;
8.163 - public final int REM = 32;
8.164 - public final int MUL = 33;
8.165 - public final int CAST = 34; // (x)y
8.166 - public final int POS = 35; // +x
8.167 - public final int NEG = 36; // -x
8.168 - public final int NOT = 37;
8.169 - public final int BITNOT = 38;
8.170 - public final int PREINC = 39; // ++x
8.171 - public final int PREDEC = 40; // --x
8.172 - public final int NEWARRAY = 41;
8.173 - public final int NEWINSTANCE = 42;
8.174 - public final int NEWFROMNAME = 43;
8.175 - public final int POSTINC = 44; // x++
8.176 - public final int POSTDEC = 45; // x--
8.177 - public final int FIELD = 46;
8.178 - public final int METHOD = 47; // x(y)
8.179 - public final int ARRAYACCESS = 48; // x[y]
8.180 - public final int NEW = 49;
8.181 - public final int INC = 50;
8.182 - public final int DEC = 51;
8.183 -
8.184 - public final int CONVERT = 55; // implicit conversion
8.185 - public final int EXPR = 56; // (x)
8.186 - public final int ARRAY = 57; // {x, y, ...}
8.187 - public final int GOTO = 58;
8.188 -
8.189 - /*
8.190 - * Value tokens
8.191 - */
8.192 - public final int IDENT = 60;
8.193 - public final int BOOLEANVAL = 61;
8.194 - public final int BYTEVAL = 62;
8.195 - public final int CHARVAL = 63;
8.196 - public final int SHORTVAL = 64;
8.197 - public final int INTVAL = 65;
8.198 - public final int LONGVAL = 66;
8.199 - public final int FLOATVAL = 67;
8.200 - public final int DOUBLEVAL = 68;
8.201 - public final int STRINGVAL = 69;
8.202 -
8.203 - /*
8.204 - * Type keywords
8.205 - */
8.206 - public final int BYTE = 70;
8.207 - public final int CHAR = 71;
8.208 - public final int SHORT = 72;
8.209 - public final int INT = 73;
8.210 - public final int LONG = 74;
8.211 - public final int FLOAT = 75;
8.212 - public final int DOUBLE = 76;
8.213 - public final int VOID = 77;
8.214 - public final int BOOLEAN = 78;
8.215 -
8.216 - /*
8.217 - * Expression keywords
8.218 - */
8.219 - public final int TRUE = 80;
8.220 - public final int FALSE = 81;
8.221 - public final int THIS = 82;
8.222 - public final int SUPER = 83;
8.223 - public final int NULL = 84;
8.224 -
8.225 - /*
8.226 - * Statement keywords
8.227 - */
8.228 - public final int IF = 90;
8.229 - public final int ELSE = 91;
8.230 - public final int FOR = 92;
8.231 - public final int WHILE = 93;
8.232 - public final int DO = 94;
8.233 - public final int SWITCH = 95;
8.234 - public final int CASE = 96;
8.235 - public final int DEFAULT = 97;
8.236 - public final int BREAK = 98;
8.237 - public final int CONTINUE = 99;
8.238 - public final int RETURN = 100;
8.239 - public final int TRY = 101;
8.240 - public final int CATCH = 102;
8.241 - public final int FINALLY = 103;
8.242 - public final int THROW = 104;
8.243 - public final int STAT = 105;
8.244 - public final int EXPRESSION = 106;
8.245 - public final int DECLARATION = 107;
8.246 - public final int VARDECLARATION = 108;
8.247 -
8.248 - /*
8.249 - * Declaration keywords
8.250 - */
8.251 - public final int IMPORT = 110;
8.252 - public final int CLASS = 111;
8.253 - public final int EXTENDS = 112;
8.254 - public final int IMPLEMENTS = 113;
8.255 - public final int INTERFACE = 114;
8.256 - public final int PACKAGE = 115;
8.257 -
8.258 - /*
8.259 - * Modifier keywords
8.260 - */
8.261 - public final int PRIVATE = 120;
8.262 - public final int PUBLIC = 121;
8.263 - public final int PROTECTED = 122;
8.264 - public final int CONST = 123;
8.265 - public final int STATIC = 124;
8.266 - public final int TRANSIENT = 125;
8.267 - public final int SYNCHRONIZED = 126;
8.268 - public final int NATIVE = 127;
8.269 - public final int FINAL = 128;
8.270 - public final int VOLATILE = 129;
8.271 - public final int ABSTRACT = 130;
8.272 - public final int STRICT = 165;
8.273 -
8.274 - /*
8.275 - * Punctuation
8.276 - */
8.277 - public final int SEMICOLON = 135;
8.278 - public final int COLON = 136;
8.279 - public final int QUESTIONMARK = 137;
8.280 - public final int LBRACE = 138;
8.281 - public final int RBRACE = 139;
8.282 - public final int LPAREN = 140;
8.283 - public final int RPAREN = 141;
8.284 - public final int LSQBRACKET = 142;
8.285 - public final int RSQBRACKET = 143;
8.286 - public final int THROWS = 144;
8.287 -
8.288 - /*
8.289 - * Special tokens
8.290 - */
8.291 - public final int ERROR = 145; // an error
8.292 - public final int COMMENT = 146; // not used anymore.
8.293 - public final int TYPE = 147;
8.294 - public final int LENGTH = 148;
8.295 - public final int INLINERETURN = 149;
8.296 - public final int INLINEMETHOD = 150;
8.297 - public final int INLINENEWINSTANCE = 151;
8.298 -
8.299 - /*
8.300 - * Added for jasm
8.301 - */
8.302 - public final int METHODREF = 152;
8.303 - public final int FIELDREF = 153;
8.304 - public final int STACK = 154;
8.305 - public final int LOCAL = 155;
8.306 - public final int CPINDEX = 156;
8.307 - public final int CPNAME = 157;
8.308 - public final int SIGN = 158;
8.309 - public final int BITS = 159;
8.310 - public final int INF = 160;
8.311 - public final int NAN = 161;
8.312 - public final int INNERCLASS = 162;
8.313 - public final int OF = 163;
8.314 - public final int SYNTHETIC = 164;
8.315 -// last used=165;
8.316 -
8.317 - /*
8.318 - * Operator precedence
8.319 - */
8.320 - public static final int opPrecedence[] = {
8.321 - 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
8.322 - 11, 11, 11, 12, 13, 14, 15, 16, 17, 18,
8.323 - 18, 19, 19, 19, 19, 19, 20, 20, 20, 21,
8.324 - 21, 22, 22, 22, 23, 24, 24, 24, 24, 24,
8.325 - 24, 25, 25, 26, 26, 26, 26, 26, 26
8.326 - };
8.327 -
8.328 - /*
8.329 - * Operator names
8.330 - */
8.331 - public static final String opNames[] = {
8.332 - ",", "=", "*=", "/=", "%=",
8.333 - "+=", "-=", "<<=", ">>=", "<<<=",
8.334 - "&=", "|=", "^=", "?:", "||",
8.335 - "&&", "|", "^", "&", "!=",
8.336 - "==", ">=", ">", "<=", "<",
8.337 - "instanceof", "<<", ">>", "<<<", "+",
8.338 - "-", "/", "%", "*", "cast",
8.339 - "+", "-", "!", "~", "++",
8.340 - "--", "new", "new", "new", "++",
8.341 - "--", "field", "method", "[]", "new",
8.342 - "++", "--", null, null, null,
8.343 -
8.344 - "convert", "expr", "array", "goto", null,
8.345 -
8.346 - "Identifier", "Boolean", "Byte", "Char", "Short",
8.347 - "Integer", "Long", "Float", "Double", "String",
8.348 -
8.349 - "byte", "char", "short", "int", "long",
8.350 - "float", "double", "void", "boolean", null,
8.351 -
8.352 - "true", "false", "this", "super", "null",
8.353 - null, null, null, null, null,
8.354 -
8.355 - "if", "else", "for", "while", "do",
8.356 - "switch", "case", "default", "break", "continue",
8.357 - "return", "try", "catch", "finally", "throw",
8.358 - "stat", "expression", "declaration", "declaration", null,
8.359 -
8.360 - "import", "class", "extends", "implements", "interface",
8.361 - "package", null, null, null, null,
8.362 -
8.363 - "private", "public", "protected", "const", "static",
8.364 - "transient", "synchronized", "native", "final", "volatile",
8.365 - "abstract", null, null, null, null,
8.366 -
8.367 - ";", ":", "?", "{", "}",
8.368 - "(", ")", "[", "]", "throws",
8.369 - "error", "comment", "type", "length", "inline-return",
8.370 - "inline-method", "inline-new",
8.371 - "method", "field", "stack", "locals", "CPINDEX", "CPName", "SIGN",
8.372 - "bits", "INF", "NaN", "InnerClass", "of", "synthetic"
8.373 - };
8.374 -
8.375 -}
9.1 --- a/rt/javap/src/main/java/org/apidesign/javap/FieldData.java Sun Mar 03 22:50:02 2013 +0100
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,168 +0,0 @@
9.4 -/*
9.5 - * Copyright (c) 2002, Oracle and/or its affiliates. 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. Oracle designates this
9.11 - * particular file as subject to the "Classpath" exception as provided
9.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9.25 - * or visit www.oracle.com if you need additional information or have any
9.26 - * questions.
9.27 - */
9.28 -
9.29 -
9.30 -package org.apidesign.javap;
9.31 -
9.32 -import java.io.*;
9.33 -
9.34 -/**
9.35 - * Strores field data informastion.
9.36 - *
9.37 - * @author Sucheta Dambalkar (Adopted code from jdis)
9.38 - */
9.39 -
9.40 -public class FieldData implements RuntimeConstants {
9.41 -
9.42 - ClassData cls;
9.43 - int access;
9.44 - int name_index;
9.45 - int descriptor_index;
9.46 - int attributes_count;
9.47 - int value_cpx=0;
9.48 - boolean isSynthetic=false;
9.49 - boolean isDeprecated=false;
9.50 - Vector attrs;
9.51 -
9.52 - public FieldData(ClassData cls){
9.53 - this.cls=cls;
9.54 - }
9.55 -
9.56 - /**
9.57 - * Read and store field info.
9.58 - */
9.59 - public void read(DataInputStream in) throws IOException {
9.60 - access = in.readUnsignedShort();
9.61 - name_index = in.readUnsignedShort();
9.62 - descriptor_index = in.readUnsignedShort();
9.63 - // Read the attributes
9.64 - int attributes_count = in.readUnsignedShort();
9.65 - attrs=new Vector(attributes_count);
9.66 - for (int i = 0; i < attributes_count; i++) {
9.67 - int attr_name_index=in.readUnsignedShort();
9.68 - if (cls.getTag(attr_name_index)!=CONSTANT_UTF8) continue;
9.69 - String attr_name=cls.getString(attr_name_index);
9.70 - if (attr_name.equals("ConstantValue")){
9.71 - if (in.readInt()!=2)
9.72 - throw new ClassFormatError("invalid ConstantValue attr length");
9.73 - value_cpx=in.readUnsignedShort();
9.74 - AttrData attr=new AttrData(cls);
9.75 - attr.read(attr_name_index);
9.76 - attrs.addElement(attr);
9.77 - } else if (attr_name.equals("Synthetic")){
9.78 - if (in.readInt()!=0)
9.79 - throw new ClassFormatError("invalid Synthetic attr length");
9.80 - isSynthetic=true;
9.81 - AttrData attr=new AttrData(cls);
9.82 - attr.read(attr_name_index);
9.83 - attrs.addElement(attr);
9.84 - } else if (attr_name.equals("Deprecated")){
9.85 - if (in.readInt()!=0)
9.86 - throw new ClassFormatError("invalid Synthetic attr length");
9.87 - isDeprecated = true;
9.88 - AttrData attr=new AttrData(cls);
9.89 - attr.read(attr_name_index);
9.90 - attrs.addElement(attr);
9.91 - } else {
9.92 - AttrData attr=new AttrData(cls);
9.93 - attr.read(attr_name_index, in);
9.94 - attrs.addElement(attr);
9.95 - }
9.96 - }
9.97 -
9.98 - } // end read
9.99 -
9.100 - public boolean isStatic() {
9.101 - return (access & ACC_STATIC) != 0;
9.102 - }
9.103 -
9.104 - /**
9.105 - * Returns access of a field.
9.106 - */
9.107 - public String[] getAccess(){
9.108 - Vector v = new Vector();
9.109 - if ((access & ACC_PUBLIC) !=0) v.addElement("public");
9.110 - if ((access & ACC_PRIVATE) !=0) v.addElement("private");
9.111 - if ((access & ACC_PROTECTED) !=0) v.addElement("protected");
9.112 - if ((access & ACC_STATIC) !=0) v.addElement("static");
9.113 - if ((access & ACC_FINAL) !=0) v.addElement("final");
9.114 - if ((access & ACC_VOLATILE) !=0) v.addElement("volatile");
9.115 - if ((access & ACC_TRANSIENT) !=0) v.addElement("transient");
9.116 - String[] accflags = new String[v.size()];
9.117 - v.copyInto(accflags);
9.118 - return accflags;
9.119 - }
9.120 -
9.121 - /**
9.122 - * Returns name of a field.
9.123 - */
9.124 - public String getName(){
9.125 - return cls.getStringValue(name_index);
9.126 - }
9.127 -
9.128 - /**
9.129 - * Returns internal signature of a field
9.130 - */
9.131 - public String getInternalSig(){
9.132 - return cls.getStringValue(descriptor_index);
9.133 - }
9.134 -
9.135 - /**
9.136 - * Returns true if field is synthetic.
9.137 - */
9.138 - public boolean isSynthetic(){
9.139 - return isSynthetic;
9.140 - }
9.141 -
9.142 - /**
9.143 - * Returns true if field is deprecated.
9.144 - */
9.145 - public boolean isDeprecated(){
9.146 - return isDeprecated;
9.147 - }
9.148 -
9.149 - /**
9.150 - * Returns index of constant value in cpool.
9.151 - */
9.152 - public int getConstantValueIndex(){
9.153 - return (value_cpx);
9.154 - }
9.155 -
9.156 - /**
9.157 - * Returns list of attributes of field.
9.158 - */
9.159 - public Vector getAttributes(){
9.160 - return attrs;
9.161 - }
9.162 -
9.163 - public byte[] findAnnotationData(boolean classRetention) {
9.164 - String n = classRetention ?
9.165 - "RuntimeInvisibleAnnotations" : // NOI18N
9.166 - "RuntimeVisibleAnnotations"; // NOI18N
9.167 - AttrData[] arr = new AttrData[attrs.size()];
9.168 - attrs.copyInto(arr);
9.169 - return ClassData.findAttr(n, arr);
9.170 - }
9.171 -}
10.1 --- a/rt/javap/src/main/java/org/apidesign/javap/Hashtable.java Sun Mar 03 22:50:02 2013 +0100
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,94 +0,0 @@
10.4 -/**
10.5 - * Back 2 Browser Bytecode Translator
10.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
10.7 - *
10.8 - * This program is free software: you can redistribute it and/or modify
10.9 - * it under the terms of the GNU General Public License as published by
10.10 - * the Free Software Foundation, version 2 of the License.
10.11 - *
10.12 - * This program is distributed in the hope that it will be useful,
10.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
10.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10.15 - * GNU General Public License for more details.
10.16 - *
10.17 - * You should have received a copy of the GNU General Public License
10.18 - * along with this program. Look for COPYING file in the top folder.
10.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
10.20 - */
10.21 -package org.apidesign.javap;
10.22 -
10.23 -/** A JavaScript optimized replacement for Hashtable.
10.24 - *
10.25 - * @author Jaroslav Tulach <jtulach@netbeans.org>
10.26 - */
10.27 -final class Hashtable {
10.28 - private Object[] keys;
10.29 - private Object[] values;
10.30 -
10.31 - Hashtable(int i) {
10.32 - this();
10.33 - }
10.34 -
10.35 - Hashtable(int i, double d) {
10.36 - this();
10.37 - }
10.38 -
10.39 - Hashtable() {
10.40 - }
10.41 -
10.42 - synchronized void put(Object key, Object val) {
10.43 - int[] where = { -1, -1 };
10.44 - Object found = get(key, where);
10.45 - if (where[0] != -1) {
10.46 - // key exists
10.47 - values[where[0]] = val;
10.48 - } else {
10.49 - if (where[1] != -1) {
10.50 - // null found
10.51 - keys[where[1]] = key;
10.52 - values[where[1]] = val;
10.53 - } else {
10.54 - if (keys == null) {
10.55 - keys = new Object[11];
10.56 - values = new Object[11];
10.57 - keys[0] = key;
10.58 - values[0] = val;
10.59 - } else {
10.60 - Object[] newKeys = new Object[keys.length * 2];
10.61 - Object[] newValues = new Object[values.length * 2];
10.62 - for (int i = 0; i < keys.length; i++) {
10.63 - newKeys[i] = keys[i];
10.64 - newValues[i] = values[i];
10.65 - }
10.66 - newKeys[keys.length] = key;
10.67 - newValues[keys.length] = val;
10.68 - keys = newKeys;
10.69 - values = newValues;
10.70 - }
10.71 - }
10.72 - }
10.73 - }
10.74 -
10.75 - Object get(Object key) {
10.76 - return get(key, null);
10.77 - }
10.78 - private synchronized Object get(Object key, int[] foundAndNull) {
10.79 - if (keys == null) {
10.80 - return null;
10.81 - }
10.82 - for (int i = 0; i < keys.length; i++) {
10.83 - if (keys[i] == null) {
10.84 - if (foundAndNull != null) {
10.85 - foundAndNull[1] = i;
10.86 - }
10.87 - } else if (keys[i].equals(key)) {
10.88 - if (foundAndNull != null) {
10.89 - foundAndNull[0] = i;
10.90 - }
10.91 - return values[i];
10.92 - }
10.93 - }
10.94 - return null;
10.95 - }
10.96 -
10.97 -}
11.1 --- a/rt/javap/src/main/java/org/apidesign/javap/InnerClassData.java Sun Mar 03 22:50:02 2013 +0100
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,75 +0,0 @@
11.4 -/*
11.5 - * Copyright (c) 2002, Oracle and/or its affiliates. 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. Oracle designates this
11.11 - * particular file as subject to the "Classpath" exception as provided
11.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11.25 - * or visit www.oracle.com if you need additional information or have any
11.26 - * questions.
11.27 - */
11.28 -
11.29 -
11.30 -package org.apidesign.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 v = new Vector();
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/rt/javap/src/main/java/org/apidesign/javap/LineNumData.java Sun Mar 03 22:50:02 2013 +0100
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,50 +0,0 @@
12.4 -/*
12.5 - * Copyright (c) 2002, Oracle and/or its affiliates. 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. Oracle designates this
12.11 - * particular file as subject to the "Classpath" exception as provided
12.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
12.25 - * or visit www.oracle.com if you need additional information or have any
12.26 - * questions.
12.27 - */
12.28 -
12.29 -
12.30 -package org.apidesign.javap;
12.31 -
12.32 -import java.util.*;
12.33 -import java.io.*;
12.34 -
12.35 -/**
12.36 - * Strores LineNumberTable data information.
12.37 - *
12.38 - * @author Sucheta Dambalkar (Adopted code from jdis)
12.39 - */
12.40 -class LineNumData {
12.41 - short start_pc, line_number;
12.42 -
12.43 - public LineNumData() {}
12.44 -
12.45 - /**
12.46 - * Read LineNumberTable attribute.
12.47 - */
12.48 - public LineNumData(DataInputStream in) throws IOException {
12.49 - start_pc = in.readShort();
12.50 - line_number=in.readShort();
12.51 -
12.52 - }
12.53 -}
13.1 --- a/rt/javap/src/main/java/org/apidesign/javap/LocVarData.java Sun Mar 03 22:50:02 2013 +0100
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,54 +0,0 @@
13.4 -/*
13.5 - * Copyright (c) 2002, Oracle and/or its affiliates. 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. Oracle designates this
13.11 - * particular file as subject to the "Classpath" exception as provided
13.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
13.25 - * or visit www.oracle.com if you need additional information or have any
13.26 - * questions.
13.27 - */
13.28 -
13.29 -
13.30 -package org.apidesign.javap;
13.31 -
13.32 -import java.util.*;
13.33 -import java.io.*;
13.34 -
13.35 -/**
13.36 - * Strores LocalVariableTable data information.
13.37 - *
13.38 - * @author Sucheta Dambalkar (Adopted code from jdis)
13.39 - */
13.40 -class LocVarData {
13.41 - short start_pc, length, name_cpx, sig_cpx, slot;
13.42 -
13.43 - public LocVarData() {
13.44 - }
13.45 -
13.46 - /**
13.47 - * Read LocalVariableTable attribute.
13.48 - */
13.49 - public LocVarData(DataInputStream in) throws IOException {
13.50 - start_pc = in.readShort();
13.51 - length=in.readShort();
13.52 - name_cpx=in.readShort();
13.53 - sig_cpx=in.readShort();
13.54 - slot=in.readShort();
13.55 -
13.56 - }
13.57 -}
14.1 --- a/rt/javap/src/main/java/org/apidesign/javap/MethodData.java Sun Mar 03 22:50:02 2013 +0100
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,394 +0,0 @@
14.4 -/*
14.5 - * Copyright (c) 2002, 2005, Oracle and/or its affiliates. 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. Oracle designates this
14.11 - * particular file as subject to the "Classpath" exception as provided
14.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
14.25 - * or visit www.oracle.com if you need additional information or have any
14.26 - * questions.
14.27 - */
14.28 -
14.29 -package org.apidesign.javap;
14.30 -
14.31 -
14.32 -import java.io.DataInputStream;
14.33 -import java.io.IOException;
14.34 -import static org.apidesign.javap.RuntimeConstants.*;
14.35 -
14.36 -/**
14.37 - * Strores method data informastion.
14.38 - *
14.39 - * @author Sucheta Dambalkar (Adopted code from jdis)
14.40 - */
14.41 -public class MethodData {
14.42 -
14.43 - ClassData cls;
14.44 - int access;
14.45 - int name_index;
14.46 - int descriptor_index;
14.47 - int attributes_count;
14.48 - byte[] code;
14.49 - Vector exception_table = new Vector(0);
14.50 - Vector lin_num_tb = new Vector(0);
14.51 - Vector loc_var_tb = new Vector(0);
14.52 - StackMapTableData[] stackMapTable;
14.53 - StackMapData[] stackMap;
14.54 - int[] exc_index_table=null;
14.55 - Vector attrs=new Vector(0);
14.56 - Vector code_attrs=new Vector(0);
14.57 - int max_stack, max_locals;
14.58 - boolean isSynthetic=false;
14.59 - boolean isDeprecated=false;
14.60 -
14.61 - public MethodData(ClassData cls){
14.62 - this.cls=cls;
14.63 - }
14.64 -
14.65 - /**
14.66 - * Read method info.
14.67 - */
14.68 - public void read(DataInputStream in) throws IOException {
14.69 - access = in.readUnsignedShort();
14.70 - name_index=in.readUnsignedShort();
14.71 - descriptor_index =in.readUnsignedShort();
14.72 - int attributes_count = in.readUnsignedShort();
14.73 - for (int i = 0; i < attributes_count; i++) {
14.74 - int attr_name_index=in.readUnsignedShort();
14.75 -
14.76 - readAttr: {
14.77 - if (cls.getTag(attr_name_index)==CONSTANT_UTF8) {
14.78 - String attr_name=cls.getString(attr_name_index);
14.79 - if ( attr_name.equals("Code")){
14.80 - readCode (in);
14.81 - AttrData attr=new AttrData(cls);
14.82 - attr.read(attr_name_index);
14.83 - attrs.addElement(attr);
14.84 - break readAttr;
14.85 - } else if ( attr_name.equals("Exceptions")){
14.86 - readExceptions(in);
14.87 - AttrData attr=new AttrData(cls);
14.88 - attr.read(attr_name_index);
14.89 - attrs.addElement(attr);
14.90 - break readAttr;
14.91 - } else if (attr_name.equals("Synthetic")){
14.92 - if (in.readInt()!=0)
14.93 - throw new ClassFormatError("invalid Synthetic attr length");
14.94 - isSynthetic=true;
14.95 - AttrData attr=new AttrData(cls);
14.96 - attr.read(attr_name_index);
14.97 - attrs.addElement(attr);
14.98 - break readAttr;
14.99 - } else if (attr_name.equals("Deprecated")){
14.100 - if (in.readInt()!=0)
14.101 - throw new ClassFormatError("invalid Synthetic attr length");
14.102 - isDeprecated = true;
14.103 - AttrData attr=new AttrData(cls);
14.104 - attr.read(attr_name_index);
14.105 - attrs.addElement(attr);
14.106 - break readAttr;
14.107 - }
14.108 - }
14.109 - AttrData attr=new AttrData(cls);
14.110 - attr.read(attr_name_index, in);
14.111 - attrs.addElement(attr);
14.112 - }
14.113 - }
14.114 - }
14.115 -
14.116 - /**
14.117 - * Read code attribute info.
14.118 - */
14.119 - public void readCode(DataInputStream in) throws IOException {
14.120 -
14.121 - int attr_length = in.readInt();
14.122 - max_stack=in.readUnsignedShort();
14.123 - max_locals=in.readUnsignedShort();
14.124 - int codelen=in.readInt();
14.125 -
14.126 - code=new byte[codelen];
14.127 - int totalread = 0;
14.128 - while(totalread < codelen){
14.129 - totalread += in.read(code, totalread, codelen-totalread);
14.130 - }
14.131 - // in.read(code, 0, codelen);
14.132 - int clen = 0;
14.133 - readExceptionTable(in);
14.134 - int code_attributes_count = in.readUnsignedShort();
14.135 -
14.136 - for (int k = 0 ; k < code_attributes_count ; k++) {
14.137 - int table_name_index=in.readUnsignedShort();
14.138 - int table_name_tag=cls.getTag(table_name_index);
14.139 - AttrData attr=new AttrData(cls);
14.140 - if (table_name_tag==CONSTANT_UTF8) {
14.141 - String table_name_tstr=cls.getString(table_name_index);
14.142 - if (table_name_tstr.equals("LineNumberTable")) {
14.143 - readLineNumTable(in);
14.144 - attr.read(table_name_index);
14.145 - } else if (table_name_tstr.equals("LocalVariableTable")) {
14.146 - readLocVarTable(in);
14.147 - attr.read(table_name_index);
14.148 - } else if (table_name_tstr.equals("StackMapTable")) {
14.149 - readStackMapTable(in);
14.150 - attr.read(table_name_index);
14.151 - } else if (table_name_tstr.equals("StackMap")) {
14.152 - readStackMap(in);
14.153 - attr.read(table_name_index);
14.154 - } else {
14.155 - attr.read(table_name_index, in);
14.156 - }
14.157 - code_attrs.addElement(attr);
14.158 - continue;
14.159 - }
14.160 -
14.161 - attr.read(table_name_index, in);
14.162 - code_attrs.addElement(attr);
14.163 - }
14.164 - }
14.165 -
14.166 - /**
14.167 - * Read exception table info.
14.168 - */
14.169 - void readExceptionTable (DataInputStream in) throws IOException {
14.170 - int exception_table_len=in.readUnsignedShort();
14.171 - exception_table=new Vector(exception_table_len);
14.172 - for (int l = 0; l < exception_table_len; l++) {
14.173 - exception_table.addElement(new TrapData(in, l));
14.174 - }
14.175 - }
14.176 -
14.177 - /**
14.178 - * Read LineNumberTable attribute info.
14.179 - */
14.180 - void readLineNumTable (DataInputStream in) throws IOException {
14.181 - int attr_len = in.readInt(); // attr_length
14.182 - int lin_num_tb_len = in.readUnsignedShort();
14.183 - lin_num_tb=new Vector(lin_num_tb_len);
14.184 - for (int l = 0; l < lin_num_tb_len; l++) {
14.185 - lin_num_tb.addElement(new LineNumData(in));
14.186 - }
14.187 - }
14.188 -
14.189 - /**
14.190 - * Read LocalVariableTable attribute info.
14.191 - */
14.192 - void readLocVarTable (DataInputStream in) throws IOException {
14.193 - int attr_len=in.readInt(); // attr_length
14.194 - int loc_var_tb_len = in.readUnsignedShort();
14.195 - loc_var_tb = new Vector(loc_var_tb_len);
14.196 - for (int l = 0; l < loc_var_tb_len; l++) {
14.197 - loc_var_tb.addElement(new LocVarData(in));
14.198 - }
14.199 - }
14.200 -
14.201 - /**
14.202 - * Read Exception attribute info.
14.203 - */
14.204 - public void readExceptions(DataInputStream in) throws IOException {
14.205 - int attr_len=in.readInt(); // attr_length in prog
14.206 - int num_exceptions = in.readUnsignedShort();
14.207 - exc_index_table=new int[num_exceptions];
14.208 - for (int l = 0; l < num_exceptions; l++) {
14.209 - int exc=in.readShort();
14.210 - exc_index_table[l]=exc;
14.211 - }
14.212 - }
14.213 -
14.214 - /**
14.215 - * Read StackMapTable attribute info.
14.216 - */
14.217 - void readStackMapTable(DataInputStream in) throws IOException {
14.218 - int attr_len = in.readInt(); //attr_length
14.219 - int stack_map_tb_len = in.readUnsignedShort();
14.220 - stackMapTable = new StackMapTableData[stack_map_tb_len];
14.221 - for (int i=0; i<stack_map_tb_len; i++) {
14.222 - stackMapTable[i] = StackMapTableData.getInstance(in, this);
14.223 - }
14.224 - }
14.225 -
14.226 - /**
14.227 - * Read StackMap attribute info.
14.228 - */
14.229 - void readStackMap(DataInputStream in) throws IOException {
14.230 - int attr_len = in.readInt(); //attr_length
14.231 - int stack_map_len = in.readUnsignedShort();
14.232 - stackMap = new StackMapData[stack_map_len];
14.233 - for (int i = 0; i<stack_map_len; i++) {
14.234 - stackMap[i] = new StackMapData(in, this);
14.235 - }
14.236 - }
14.237 -
14.238 - /**
14.239 - * Return access of the method.
14.240 - */
14.241 - public int getAccess(){
14.242 - return access;
14.243 - }
14.244 -
14.245 - /**
14.246 - * Return name of the method.
14.247 - */
14.248 - public String getName(){
14.249 - return cls.getStringValue(name_index);
14.250 - }
14.251 -
14.252 - /**
14.253 - * Return internal siganature of the method.
14.254 - */
14.255 - public String getInternalSig(){
14.256 - return cls.getStringValue(descriptor_index);
14.257 - }
14.258 -
14.259 - /**
14.260 - * Return code attribute data of a method.
14.261 - */
14.262 - public byte[] getCode(){
14.263 - return code;
14.264 - }
14.265 -
14.266 - /**
14.267 - * Return LineNumberTable size.
14.268 - */
14.269 - public int getnumlines(){
14.270 - return lin_num_tb.size();
14.271 - }
14.272 -
14.273 - /**
14.274 - * Return LineNumberTable
14.275 - */
14.276 - public Vector getlin_num_tb(){
14.277 - return lin_num_tb;
14.278 - }
14.279 -
14.280 - /**
14.281 - * Return LocalVariableTable size.
14.282 - */
14.283 - public int getloc_var_tbsize(){
14.284 - return loc_var_tb.size();
14.285 - }
14.286 -
14.287 -
14.288 - /**
14.289 - * Return LocalVariableTable.
14.290 - */
14.291 - public Vector getloc_var_tb(){
14.292 - return loc_var_tb;
14.293 - }
14.294 -
14.295 - /**
14.296 - * Return StackMap.
14.297 - */
14.298 - public StackMapData[] getStackMap() {
14.299 - return stackMap;
14.300 - }
14.301 -
14.302 - /**
14.303 - * Return StackMapTable.
14.304 - */
14.305 - public StackMapTableData[] getStackMapTable() {
14.306 - return stackMapTable;
14.307 - }
14.308 -
14.309 - public StackMapIterator createStackMapIterator() {
14.310 - return new StackMapIterator(this);
14.311 - }
14.312 -
14.313 - /**
14.314 - * Return true if method is static
14.315 - */
14.316 - public boolean isStatic(){
14.317 - if ((access & ACC_STATIC) !=0) return true;
14.318 - return false;
14.319 - }
14.320 -
14.321 -
14.322 - /**
14.323 - * Return max depth of operand stack.
14.324 - */
14.325 - public int getMaxStack(){
14.326 - return max_stack;
14.327 - }
14.328 -
14.329 -
14.330 - /**
14.331 - * Return number of local variables.
14.332 - */
14.333 - public int getMaxLocals(){
14.334 - return max_locals;
14.335 - }
14.336 -
14.337 -
14.338 - /**
14.339 - * Return exception index table in Exception attribute.
14.340 - */
14.341 - public int []get_exc_index_table(){
14.342 - return exc_index_table;
14.343 - }
14.344 -
14.345 -
14.346 - /**
14.347 - * Return exception table in code attributre.
14.348 - */
14.349 - public TrapDataIterator getTrapDataIterator(){
14.350 - return new TrapDataIterator(exception_table);
14.351 - }
14.352 -
14.353 -
14.354 - /**
14.355 - * Return method attributes.
14.356 - */
14.357 - public Vector getAttributes(){
14.358 - return attrs;
14.359 - }
14.360 -
14.361 -
14.362 - /**
14.363 - * Return code attributes.
14.364 - */
14.365 - public Vector getCodeAttributes(){
14.366 - return code_attrs;
14.367 - }
14.368 -
14.369 -
14.370 - /**
14.371 - * Return true if method id synthetic.
14.372 - */
14.373 - public boolean isSynthetic(){
14.374 - return isSynthetic;
14.375 - }
14.376 -
14.377 -
14.378 - /**
14.379 - * Return true if method is deprecated.
14.380 - */
14.381 - public boolean isDeprecated(){
14.382 - return isDeprecated;
14.383 - }
14.384 -
14.385 - public byte[] findAnnotationData(boolean classRetention) {
14.386 - String n = classRetention ?
14.387 - "RuntimeInvisibleAnnotations" : // NOI18N
14.388 - "RuntimeVisibleAnnotations"; // NOI18N
14.389 - AttrData[] arr = new AttrData[attrs.size()];
14.390 - attrs.copyInto(arr);
14.391 - return ClassData.findAttr(n, arr);
14.392 - }
14.393 -
14.394 - public boolean isConstructor() {
14.395 - return "<init>".equals(getName());
14.396 - }
14.397 -}
15.1 --- a/rt/javap/src/main/java/org/apidesign/javap/RuntimeConstants.java Sun Mar 03 22:50:02 2013 +0100
15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
15.3 @@ -1,787 +0,0 @@
15.4 -/*
15.5 - * Copyright (c) 2002, 2005, Oracle and/or its affiliates. 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. Oracle designates this
15.11 - * particular file as subject to the "Classpath" exception as provided
15.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
15.25 - * or visit www.oracle.com if you need additional information or have any
15.26 - * questions.
15.27 - */
15.28 -
15.29 -
15.30 -package org.apidesign.javap;
15.31 -
15.32 -public interface RuntimeConstants {
15.33 -
15.34 - /* Signature Characters */
15.35 - public static final char SIGC_VOID = 'V';
15.36 - public static final String SIG_VOID = "V";
15.37 - public static final char SIGC_BOOLEAN = 'Z';
15.38 - public static final String SIG_BOOLEAN = "Z";
15.39 - public static final char SIGC_BYTE = 'B';
15.40 - public static final String SIG_BYTE = "B";
15.41 - public static final char SIGC_CHAR = 'C';
15.42 - public static final String SIG_CHAR = "C";
15.43 - public static final char SIGC_SHORT = 'S';
15.44 - public static final String SIG_SHORT = "S";
15.45 - public static final char SIGC_INT = 'I';
15.46 - public static final String SIG_INT = "I";
15.47 - public static final char SIGC_LONG = 'J';
15.48 - public static final String SIG_LONG = "J";
15.49 - public static final char SIGC_FLOAT = 'F';
15.50 - public static final String SIG_FLOAT = "F";
15.51 - public static final char SIGC_DOUBLE = 'D';
15.52 - public static final String SIG_DOUBLE = "D";
15.53 - public static final char SIGC_ARRAY = '[';
15.54 - public static final String SIG_ARRAY = "[";
15.55 - public static final char SIGC_CLASS = 'L';
15.56 - public static final String SIG_CLASS = "L";
15.57 - public static final char SIGC_METHOD = '(';
15.58 - public static final String SIG_METHOD = "(";
15.59 - public static final char SIGC_ENDCLASS = ';';
15.60 - public static final String SIG_ENDCLASS = ";";
15.61 - public static final char SIGC_ENDMETHOD = ')';
15.62 - public static final String SIG_ENDMETHOD = ")";
15.63 - public static final char SIGC_PACKAGE = '/';
15.64 - public static final String SIG_PACKAGE = "/";
15.65 -
15.66 - /* Class File Constants */
15.67 - public static final int JAVA_MAGIC = 0xcafebabe;
15.68 - public static final int JAVA_VERSION = 45;
15.69 - public static final int JAVA_MINOR_VERSION = 3;
15.70 -
15.71 - /* Constant table */
15.72 - public static final int CONSTANT_UTF8 = 1;
15.73 - public static final int CONSTANT_UNICODE = 2;
15.74 - public static final int CONSTANT_INTEGER = 3;
15.75 - public static final int CONSTANT_FLOAT = 4;
15.76 - public static final int CONSTANT_LONG = 5;
15.77 - public static final int CONSTANT_DOUBLE = 6;
15.78 - public static final int CONSTANT_CLASS = 7;
15.79 - public static final int CONSTANT_STRING = 8;
15.80 - public static final int CONSTANT_FIELD = 9;
15.81 - public static final int CONSTANT_METHOD = 10;
15.82 - public static final int CONSTANT_INTERFACEMETHOD = 11;
15.83 - public static final int CONSTANT_NAMEANDTYPE = 12;
15.84 -
15.85 - /* Access Flags */
15.86 - public static final int ACC_PUBLIC = 0x00000001;
15.87 - public static final int ACC_PRIVATE = 0x00000002;
15.88 - public static final int ACC_PROTECTED = 0x00000004;
15.89 - public static final int ACC_STATIC = 0x00000008;
15.90 - public static final int ACC_FINAL = 0x00000010;
15.91 - public static final int ACC_SYNCHRONIZED = 0x00000020;
15.92 - public static final int ACC_SUPER = 0x00000020;
15.93 - public static final int ACC_VOLATILE = 0x00000040;
15.94 - public static final int ACC_TRANSIENT = 0x00000080;
15.95 - public static final int ACC_NATIVE = 0x00000100;
15.96 - public static final int ACC_INTERFACE = 0x00000200;
15.97 - public static final int ACC_ABSTRACT = 0x00000400;
15.98 - public static final int ACC_STRICT = 0x00000800;
15.99 - public static final int ACC_EXPLICIT = 0x00001000;
15.100 - public static final int ACC_SYNTHETIC = 0x00010000; // actually, this is an attribute
15.101 -
15.102 - /* Type codes */
15.103 - public static final int T_CLASS = 0x00000002;
15.104 - public static final int T_BOOLEAN = 0x00000004;
15.105 - public static final int T_CHAR = 0x00000005;
15.106 - public static final int T_FLOAT = 0x00000006;
15.107 - public static final int T_DOUBLE = 0x00000007;
15.108 - public static final int T_BYTE = 0x00000008;
15.109 - public static final int T_SHORT = 0x00000009;
15.110 - public static final int T_INT = 0x0000000a;
15.111 - public static final int T_LONG = 0x0000000b;
15.112 -
15.113 - /* Type codes for StackMap attribute */
15.114 - public static final int ITEM_Bogus =0; // an unknown or uninitialized value
15.115 - public static final int ITEM_Integer =1; // a 32-bit integer
15.116 - public static final int ITEM_Float =2; // not used
15.117 - public static final int ITEM_Double =3; // not used
15.118 - public static final int ITEM_Long =4; // a 64-bit integer
15.119 - public static final int ITEM_Null =5; // the type of null
15.120 - public static final int ITEM_InitObject =6; // "this" in constructor
15.121 - public static final int ITEM_Object =7; // followed by 2-byte index of class name
15.122 - public static final int ITEM_NewObject =8; // followed by 2-byte ref to "new"
15.123 -
15.124 - /* Constants used in StackMapTable attribute */
15.125 - public static final int SAME_FRAME_BOUND = 64;
15.126 - public static final int SAME_LOCALS_1_STACK_ITEM_BOUND = 128;
15.127 - public static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247;
15.128 - public static final int SAME_FRAME_EXTENDED = 251;
15.129 - public static final int FULL_FRAME = 255;
15.130 -
15.131 - /* Opcodes */
15.132 - public static final int opc_dead = -2;
15.133 - public static final int opc_label = -1;
15.134 - public static final int opc_nop = 0;
15.135 - public static final int opc_aconst_null = 1;
15.136 - public static final int opc_iconst_m1 = 2;
15.137 - public static final int opc_iconst_0 = 3;
15.138 - public static final int opc_iconst_1 = 4;
15.139 - public static final int opc_iconst_2 = 5;
15.140 - public static final int opc_iconst_3 = 6;
15.141 - public static final int opc_iconst_4 = 7;
15.142 - public static final int opc_iconst_5 = 8;
15.143 - public static final int opc_lconst_0 = 9;
15.144 - public static final int opc_lconst_1 = 10;
15.145 - public static final int opc_fconst_0 = 11;
15.146 - public static final int opc_fconst_1 = 12;
15.147 - public static final int opc_fconst_2 = 13;
15.148 - public static final int opc_dconst_0 = 14;
15.149 - public static final int opc_dconst_1 = 15;
15.150 - public static final int opc_bipush = 16;
15.151 - public static final int opc_sipush = 17;
15.152 - public static final int opc_ldc = 18;
15.153 - public static final int opc_ldc_w = 19;
15.154 - public static final int opc_ldc2_w = 20;
15.155 - public static final int opc_iload = 21;
15.156 - public static final int opc_lload = 22;
15.157 - public static final int opc_fload = 23;
15.158 - public static final int opc_dload = 24;
15.159 - public static final int opc_aload = 25;
15.160 - public static final int opc_iload_0 = 26;
15.161 - public static final int opc_iload_1 = 27;
15.162 - public static final int opc_iload_2 = 28;
15.163 - public static final int opc_iload_3 = 29;
15.164 - public static final int opc_lload_0 = 30;
15.165 - public static final int opc_lload_1 = 31;
15.166 - public static final int opc_lload_2 = 32;
15.167 - public static final int opc_lload_3 = 33;
15.168 - public static final int opc_fload_0 = 34;
15.169 - public static final int opc_fload_1 = 35;
15.170 - public static final int opc_fload_2 = 36;
15.171 - public static final int opc_fload_3 = 37;
15.172 - public static final int opc_dload_0 = 38;
15.173 - public static final int opc_dload_1 = 39;
15.174 - public static final int opc_dload_2 = 40;
15.175 - public static final int opc_dload_3 = 41;
15.176 - public static final int opc_aload_0 = 42;
15.177 - public static final int opc_aload_1 = 43;
15.178 - public static final int opc_aload_2 = 44;
15.179 - public static final int opc_aload_3 = 45;
15.180 - public static final int opc_iaload = 46;
15.181 - public static final int opc_laload = 47;
15.182 - public static final int opc_faload = 48;
15.183 - public static final int opc_daload = 49;
15.184 - public static final int opc_aaload = 50;
15.185 - public static final int opc_baload = 51;
15.186 - public static final int opc_caload = 52;
15.187 - public static final int opc_saload = 53;
15.188 - public static final int opc_istore = 54;
15.189 - public static final int opc_lstore = 55;
15.190 - public static final int opc_fstore = 56;
15.191 - public static final int opc_dstore = 57;
15.192 - public static final int opc_astore = 58;
15.193 - public static final int opc_istore_0 = 59;
15.194 - public static final int opc_istore_1 = 60;
15.195 - public static final int opc_istore_2 = 61;
15.196 - public static final int opc_istore_3 = 62;
15.197 - public static final int opc_lstore_0 = 63;
15.198 - public static final int opc_lstore_1 = 64;
15.199 - public static final int opc_lstore_2 = 65;
15.200 - public static final int opc_lstore_3 = 66;
15.201 - public static final int opc_fstore_0 = 67;
15.202 - public static final int opc_fstore_1 = 68;
15.203 - public static final int opc_fstore_2 = 69;
15.204 - public static final int opc_fstore_3 = 70;
15.205 - public static final int opc_dstore_0 = 71;
15.206 - public static final int opc_dstore_1 = 72;
15.207 - public static final int opc_dstore_2 = 73;
15.208 - public static final int opc_dstore_3 = 74;
15.209 - public static final int opc_astore_0 = 75;
15.210 - public static final int opc_astore_1 = 76;
15.211 - public static final int opc_astore_2 = 77;
15.212 - public static final int opc_astore_3 = 78;
15.213 - public static final int opc_iastore = 79;
15.214 - public static final int opc_lastore = 80;
15.215 - public static final int opc_fastore = 81;
15.216 - public static final int opc_dastore = 82;
15.217 - public static final int opc_aastore = 83;
15.218 - public static final int opc_bastore = 84;
15.219 - public static final int opc_castore = 85;
15.220 - public static final int opc_sastore = 86;
15.221 - public static final int opc_pop = 87;
15.222 - public static final int opc_pop2 = 88;
15.223 - public static final int opc_dup = 89;
15.224 - public static final int opc_dup_x1 = 90;
15.225 - public static final int opc_dup_x2 = 91;
15.226 - public static final int opc_dup2 = 92;
15.227 - public static final int opc_dup2_x1 = 93;
15.228 - public static final int opc_dup2_x2 = 94;
15.229 - public static final int opc_swap = 95;
15.230 - public static final int opc_iadd = 96;
15.231 - public static final int opc_ladd = 97;
15.232 - public static final int opc_fadd = 98;
15.233 - public static final int opc_dadd = 99;
15.234 - public static final int opc_isub = 100;
15.235 - public static final int opc_lsub = 101;
15.236 - public static final int opc_fsub = 102;
15.237 - public static final int opc_dsub = 103;
15.238 - public static final int opc_imul = 104;
15.239 - public static final int opc_lmul = 105;
15.240 - public static final int opc_fmul = 106;
15.241 - public static final int opc_dmul = 107;
15.242 - public static final int opc_idiv = 108;
15.243 - public static final int opc_ldiv = 109;
15.244 - public static final int opc_fdiv = 110;
15.245 - public static final int opc_ddiv = 111;
15.246 - public static final int opc_irem = 112;
15.247 - public static final int opc_lrem = 113;
15.248 - public static final int opc_frem = 114;
15.249 - public static final int opc_drem = 115;
15.250 - public static final int opc_ineg = 116;
15.251 - public static final int opc_lneg = 117;
15.252 - public static final int opc_fneg = 118;
15.253 - public static final int opc_dneg = 119;
15.254 - public static final int opc_ishl = 120;
15.255 - public static final int opc_lshl = 121;
15.256 - public static final int opc_ishr = 122;
15.257 - public static final int opc_lshr = 123;
15.258 - public static final int opc_iushr = 124;
15.259 - public static final int opc_lushr = 125;
15.260 - public static final int opc_iand = 126;
15.261 - public static final int opc_land = 127;
15.262 - public static final int opc_ior = 128;
15.263 - public static final int opc_lor = 129;
15.264 - public static final int opc_ixor = 130;
15.265 - public static final int opc_lxor = 131;
15.266 - public static final int opc_iinc = 132;
15.267 - public static final int opc_i2l = 133;
15.268 - public static final int opc_i2f = 134;
15.269 - public static final int opc_i2d = 135;
15.270 - public static final int opc_l2i = 136;
15.271 - public static final int opc_l2f = 137;
15.272 - public static final int opc_l2d = 138;
15.273 - public static final int opc_f2i = 139;
15.274 - public static final int opc_f2l = 140;
15.275 - public static final int opc_f2d = 141;
15.276 - public static final int opc_d2i = 142;
15.277 - public static final int opc_d2l = 143;
15.278 - public static final int opc_d2f = 144;
15.279 - public static final int opc_i2b = 145;
15.280 - public static final int opc_int2byte = 145;
15.281 - public static final int opc_i2c = 146;
15.282 - public static final int opc_int2char = 146;
15.283 - public static final int opc_i2s = 147;
15.284 - public static final int opc_int2short = 147;
15.285 - public static final int opc_lcmp = 148;
15.286 - public static final int opc_fcmpl = 149;
15.287 - public static final int opc_fcmpg = 150;
15.288 - public static final int opc_dcmpl = 151;
15.289 - public static final int opc_dcmpg = 152;
15.290 - public static final int opc_ifeq = 153;
15.291 - public static final int opc_ifne = 154;
15.292 - public static final int opc_iflt = 155;
15.293 - public static final int opc_ifge = 156;
15.294 - public static final int opc_ifgt = 157;
15.295 - public static final int opc_ifle = 158;
15.296 - public static final int opc_if_icmpeq = 159;
15.297 - public static final int opc_if_icmpne = 160;
15.298 - public static final int opc_if_icmplt = 161;
15.299 - public static final int opc_if_icmpge = 162;
15.300 - public static final int opc_if_icmpgt = 163;
15.301 - public static final int opc_if_icmple = 164;
15.302 - public static final int opc_if_acmpeq = 165;
15.303 - public static final int opc_if_acmpne = 166;
15.304 - public static final int opc_goto = 167;
15.305 - public static final int opc_jsr = 168;
15.306 - public static final int opc_ret = 169;
15.307 - public static final int opc_tableswitch = 170;
15.308 - public static final int opc_lookupswitch = 171;
15.309 - public static final int opc_ireturn = 172;
15.310 - public static final int opc_lreturn = 173;
15.311 - public static final int opc_freturn = 174;
15.312 - public static final int opc_dreturn = 175;
15.313 - public static final int opc_areturn = 176;
15.314 - public static final int opc_return = 177;
15.315 - public static final int opc_getstatic = 178;
15.316 - public static final int opc_putstatic = 179;
15.317 - public static final int opc_getfield = 180;
15.318 - public static final int opc_putfield = 181;
15.319 - public static final int opc_invokevirtual = 182;
15.320 - public static final int opc_invokenonvirtual = 183;
15.321 - public static final int opc_invokespecial = 183;
15.322 - public static final int opc_invokestatic = 184;
15.323 - public static final int opc_invokeinterface = 185;
15.324 -// public static final int opc_xxxunusedxxx = 186;
15.325 - public static final int opc_new = 187;
15.326 - public static final int opc_newarray = 188;
15.327 - public static final int opc_anewarray = 189;
15.328 - public static final int opc_arraylength = 190;
15.329 - public static final int opc_athrow = 191;
15.330 - public static final int opc_checkcast = 192;
15.331 - public static final int opc_instanceof = 193;
15.332 - public static final int opc_monitorenter = 194;
15.333 - public static final int opc_monitorexit = 195;
15.334 - public static final int opc_wide = 196;
15.335 - public static final int opc_multianewarray = 197;
15.336 - public static final int opc_ifnull = 198;
15.337 - public static final int opc_ifnonnull = 199;
15.338 - public static final int opc_goto_w = 200;
15.339 - public static final int opc_jsr_w = 201;
15.340 - /* Pseudo-instructions */
15.341 - public static final int opc_bytecode = 203;
15.342 - public static final int opc_try = 204;
15.343 - public static final int opc_endtry = 205;
15.344 - public static final int opc_catch = 206;
15.345 - public static final int opc_var = 207;
15.346 - public static final int opc_endvar = 208;
15.347 - public static final int opc_localsmap = 209;
15.348 - public static final int opc_stackmap = 210;
15.349 - /* PicoJava prefixes */
15.350 - public static final int opc_nonpriv = 254;
15.351 - public static final int opc_priv = 255;
15.352 -
15.353 - /* Wide instructions */
15.354 - public static final int opc_iload_w = (opc_wide<<8)|opc_iload;
15.355 - public static final int opc_lload_w = (opc_wide<<8)|opc_lload;
15.356 - public static final int opc_fload_w = (opc_wide<<8)|opc_fload;
15.357 - public static final int opc_dload_w = (opc_wide<<8)|opc_dload;
15.358 - public static final int opc_aload_w = (opc_wide<<8)|opc_aload;
15.359 - public static final int opc_istore_w = (opc_wide<<8)|opc_istore;
15.360 - public static final int opc_lstore_w = (opc_wide<<8)|opc_lstore;
15.361 - public static final int opc_fstore_w = (opc_wide<<8)|opc_fstore;
15.362 - public static final int opc_dstore_w = (opc_wide<<8)|opc_dstore;
15.363 - public static final int opc_astore_w = (opc_wide<<8)|opc_astore;
15.364 - public static final int opc_ret_w = (opc_wide<<8)|opc_ret;
15.365 - public static final int opc_iinc_w = (opc_wide<<8)|opc_iinc;
15.366 -
15.367 - /* Opcode Names */
15.368 - public static final String opcNamesTab[] = {
15.369 - "nop",
15.370 - "aconst_null",
15.371 - "iconst_m1",
15.372 - "iconst_0",
15.373 - "iconst_1",
15.374 - "iconst_2",
15.375 - "iconst_3",
15.376 - "iconst_4",
15.377 - "iconst_5",
15.378 - "lconst_0",
15.379 - "lconst_1",
15.380 - "fconst_0",
15.381 - "fconst_1",
15.382 - "fconst_2",
15.383 - "dconst_0",
15.384 - "dconst_1",
15.385 - "bipush",
15.386 - "sipush",
15.387 - "ldc",
15.388 - "ldc_w",
15.389 - "ldc2_w",
15.390 - "iload",
15.391 - "lload",
15.392 - "fload",
15.393 - "dload",
15.394 - "aload",
15.395 - "iload_0",
15.396 - "iload_1",
15.397 - "iload_2",
15.398 - "iload_3",
15.399 - "lload_0",
15.400 - "lload_1",
15.401 - "lload_2",
15.402 - "lload_3",
15.403 - "fload_0",
15.404 - "fload_1",
15.405 - "fload_2",
15.406 - "fload_3",
15.407 - "dload_0",
15.408 - "dload_1",
15.409 - "dload_2",
15.410 - "dload_3",
15.411 - "aload_0",
15.412 - "aload_1",
15.413 - "aload_2",
15.414 - "aload_3",
15.415 - "iaload",
15.416 - "laload",
15.417 - "faload",
15.418 - "daload",
15.419 - "aaload",
15.420 - "baload",
15.421 - "caload",
15.422 - "saload",
15.423 - "istore",
15.424 - "lstore",
15.425 - "fstore",
15.426 - "dstore",
15.427 - "astore",
15.428 - "istore_0",
15.429 - "istore_1",
15.430 - "istore_2",
15.431 - "istore_3",
15.432 - "lstore_0",
15.433 - "lstore_1",
15.434 - "lstore_2",
15.435 - "lstore_3",
15.436 - "fstore_0",
15.437 - "fstore_1",
15.438 - "fstore_2",
15.439 - "fstore_3",
15.440 - "dstore_0",
15.441 - "dstore_1",
15.442 - "dstore_2",
15.443 - "dstore_3",
15.444 - "astore_0",
15.445 - "astore_1",
15.446 - "astore_2",
15.447 - "astore_3",
15.448 - "iastore",
15.449 - "lastore",
15.450 - "fastore",
15.451 - "dastore",
15.452 - "aastore",
15.453 - "bastore",
15.454 - "castore",
15.455 - "sastore",
15.456 - "pop",
15.457 - "pop2",
15.458 - "dup",
15.459 - "dup_x1",
15.460 - "dup_x2",
15.461 - "dup2",
15.462 - "dup2_x1",
15.463 - "dup2_x2",
15.464 - "swap",
15.465 - "iadd",
15.466 - "ladd",
15.467 - "fadd",
15.468 - "dadd",
15.469 - "isub",
15.470 - "lsub",
15.471 - "fsub",
15.472 - "dsub",
15.473 - "imul",
15.474 - "lmul",
15.475 - "fmul",
15.476 - "dmul",
15.477 - "idiv",
15.478 - "ldiv",
15.479 - "fdiv",
15.480 - "ddiv",
15.481 - "irem",
15.482 - "lrem",
15.483 - "frem",
15.484 - "drem",
15.485 - "ineg",
15.486 - "lneg",
15.487 - "fneg",
15.488 - "dneg",
15.489 - "ishl",
15.490 - "lshl",
15.491 - "ishr",
15.492 - "lshr",
15.493 - "iushr",
15.494 - "lushr",
15.495 - "iand",
15.496 - "land",
15.497 - "ior",
15.498 - "lor",
15.499 - "ixor",
15.500 - "lxor",
15.501 - "iinc",
15.502 - "i2l",
15.503 - "i2f",
15.504 - "i2d",
15.505 - "l2i",
15.506 - "l2f",
15.507 - "l2d",
15.508 - "f2i",
15.509 - "f2l",
15.510 - "f2d",
15.511 - "d2i",
15.512 - "d2l",
15.513 - "d2f",
15.514 - "i2b",
15.515 - "i2c",
15.516 - "i2s",
15.517 - "lcmp",
15.518 - "fcmpl",
15.519 - "fcmpg",
15.520 - "dcmpl",
15.521 - "dcmpg",
15.522 - "ifeq",
15.523 - "ifne",
15.524 - "iflt",
15.525 - "ifge",
15.526 - "ifgt",
15.527 - "ifle",
15.528 - "if_icmpeq",
15.529 - "if_icmpne",
15.530 - "if_icmplt",
15.531 - "if_icmpge",
15.532 - "if_icmpgt",
15.533 - "if_icmple",
15.534 - "if_acmpeq",
15.535 - "if_acmpne",
15.536 - "goto",
15.537 - "jsr",
15.538 - "ret",
15.539 - "tableswitch",
15.540 - "lookupswitch",
15.541 - "ireturn",
15.542 - "lreturn",
15.543 - "freturn",
15.544 - "dreturn",
15.545 - "areturn",
15.546 - "return",
15.547 - "getstatic",
15.548 - "putstatic",
15.549 - "getfield",
15.550 - "putfield",
15.551 - "invokevirtual",
15.552 - "invokespecial", // was "invokenonvirtual",
15.553 - "invokestatic",
15.554 - "invokeinterface",
15.555 - "bytecode 186", //"xxxunusedxxx",
15.556 - "new",
15.557 - "newarray",
15.558 - "anewarray",
15.559 - "arraylength",
15.560 - "athrow",
15.561 - "checkcast",
15.562 - "instanceof",
15.563 - "monitorenter",
15.564 - "monitorexit",
15.565 - null, // "wide",
15.566 - "multianewarray",
15.567 - "ifnull",
15.568 - "ifnonnull",
15.569 - "goto_w",
15.570 - "jsr_w",
15.571 - "bytecode 202", // "breakpoint",
15.572 - "bytecode",
15.573 - "try",
15.574 - "endtry",
15.575 - "catch",
15.576 - "var",
15.577 - "endvar",
15.578 - "locals_map",
15.579 - "stack_map"
15.580 - };
15.581 -
15.582 - /* Opcode Lengths */
15.583 - public static final int opcLengthsTab[] = {
15.584 - 1,
15.585 - 1,
15.586 - 1,
15.587 - 1,
15.588 - 1,
15.589 - 1,
15.590 - 1,
15.591 - 1,
15.592 - 1,
15.593 - 1,
15.594 - 1,
15.595 - 1,
15.596 - 1,
15.597 - 1,
15.598 - 1,
15.599 - 1,
15.600 - 2,
15.601 - 3,
15.602 - 2,
15.603 - 3,
15.604 - 3,
15.605 - 2,
15.606 - 2,
15.607 - 2,
15.608 - 2,
15.609 - 2,
15.610 - 1,
15.611 - 1,
15.612 - 1,
15.613 - 1,
15.614 - 1,
15.615 - 1,
15.616 - 1,
15.617 - 1,
15.618 - 1,
15.619 - 1,
15.620 - 1,
15.621 - 1,
15.622 - 1,
15.623 - 1,
15.624 - 1,
15.625 - 1,
15.626 - 1,
15.627 - 1,
15.628 - 1,
15.629 - 1,
15.630 - 1,
15.631 - 1,
15.632 - 1,
15.633 - 1,
15.634 - 1,
15.635 - 1,
15.636 - 1,
15.637 - 1,
15.638 - 2,
15.639 - 2,
15.640 - 2,
15.641 - 2,
15.642 - 2,
15.643 - 1,
15.644 - 1,
15.645 - 1,
15.646 - 1,
15.647 - 1,
15.648 - 1,
15.649 - 1,
15.650 - 1,
15.651 - 1,
15.652 - 1,
15.653 - 1,
15.654 - 1,
15.655 - 1,
15.656 - 1,
15.657 - 1,
15.658 - 1,
15.659 - 1,
15.660 - 1,
15.661 - 1,
15.662 - 1,
15.663 - 1,
15.664 - 1,
15.665 - 1,
15.666 - 1,
15.667 - 1,
15.668 - 1,
15.669 - 1,
15.670 - 1,
15.671 - 1,
15.672 - 1,
15.673 - 1,
15.674 - 1,
15.675 - 1,
15.676 - 1,
15.677 - 1,
15.678 - 1,
15.679 - 1,
15.680 - 1,
15.681 - 1,
15.682 - 1,
15.683 - 1,
15.684 - 1,
15.685 - 1,
15.686 - 1,
15.687 - 1,
15.688 - 1,
15.689 - 1,
15.690 - 1,
15.691 - 1,
15.692 - 1,
15.693 - 1,
15.694 - 1,
15.695 - 1,
15.696 - 1,
15.697 - 1,
15.698 - 1,
15.699 - 1,
15.700 - 1,
15.701 - 1,
15.702 - 1,
15.703 - 1,
15.704 - 1,
15.705 - 1,
15.706 - 1,
15.707 - 1,
15.708 - 1,
15.709 - 1,
15.710 - 1,
15.711 - 1,
15.712 - 1,
15.713 - 1,
15.714 - 1,
15.715 - 1,
15.716 - 3,
15.717 - 1,
15.718 - 1,
15.719 - 1,
15.720 - 1,
15.721 - 1,
15.722 - 1,
15.723 - 1,
15.724 - 1,
15.725 - 1,
15.726 - 1,
15.727 - 1,
15.728 - 1,
15.729 - 1,
15.730 - 1,
15.731 - 1,
15.732 - 1,
15.733 - 1,
15.734 - 1,
15.735 - 1,
15.736 - 1,
15.737 - 3,
15.738 - 3,
15.739 - 3,
15.740 - 3,
15.741 - 3,
15.742 - 3,
15.743 - 3,
15.744 - 3,
15.745 - 3,
15.746 - 3,
15.747 - 3,
15.748 - 3,
15.749 - 3,
15.750 - 3,
15.751 - 3,
15.752 - 3,
15.753 - 2,
15.754 - 99,
15.755 - 99,
15.756 - 1,
15.757 - 1,
15.758 - 1,
15.759 - 1,
15.760 - 1,
15.761 - 1,
15.762 - 3,
15.763 - 3,
15.764 - 3,
15.765 - 3,
15.766 - 3,
15.767 - 3,
15.768 - 3,
15.769 - 5,
15.770 - 0,
15.771 - 3,
15.772 - 2,
15.773 - 3,
15.774 - 1,
15.775 - 1,
15.776 - 3,
15.777 - 3,
15.778 - 1,
15.779 - 1,
15.780 - 0, // wide
15.781 - 4,
15.782 - 3,
15.783 - 3,
15.784 - 5,
15.785 - 5,
15.786 - 1,
15.787 - 1, 0, 0, 0, 0, 0 // pseudo
15.788 - };
15.789 -
15.790 -}
16.1 --- a/rt/javap/src/main/java/org/apidesign/javap/StackMapData.java Sun Mar 03 22:50:02 2013 +0100
16.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
16.3 @@ -1,71 +0,0 @@
16.4 -/*
16.5 - * Copyright (c) 2005, Oracle and/or its affiliates. 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. Oracle designates this
16.11 - * particular file as subject to the "Classpath" exception as provided
16.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
16.25 - * or visit www.oracle.com if you need additional information or have any
16.26 - * questions.
16.27 - */
16.28 -
16.29 -
16.30 -package org.apidesign.javap;
16.31 -
16.32 -import java.util.*;
16.33 -import java.io.*;
16.34 -
16.35 -import static org.apidesign.javap.RuntimeConstants.*;
16.36 -
16.37 -/* represents one entry of StackMap attribute
16.38 - */
16.39 -class StackMapData {
16.40 - final int offset;
16.41 - final int[] locals;
16.42 - final int[] stack;
16.43 -
16.44 - StackMapData(int offset, int[] locals, int[] stack) {
16.45 - this.offset = offset;
16.46 - this.locals = locals;
16.47 - this.stack = stack;
16.48 - }
16.49 -
16.50 - StackMapData(DataInputStream in, MethodData method) throws IOException {
16.51 - offset = in.readUnsignedShort();
16.52 - int local_size = in.readUnsignedShort();
16.53 - locals = readTypeArray(in, local_size, method);
16.54 - int stack_size = in.readUnsignedShort();
16.55 - stack = readTypeArray(in, stack_size, method);
16.56 - }
16.57 -
16.58 - static final int[] readTypeArray(DataInputStream in, int length, MethodData method) throws IOException {
16.59 - int[] types = new int[length];
16.60 - for (int i=0; i<length; i++) {
16.61 - types[i] = readType(in, method);
16.62 - }
16.63 - return types;
16.64 - }
16.65 -
16.66 - static final int readType(DataInputStream in, MethodData method) throws IOException {
16.67 - int type = in.readUnsignedByte();
16.68 - if (type == ITEM_Object || type == ITEM_NewObject) {
16.69 - type = type | (in.readUnsignedShort()<<8);
16.70 - }
16.71 - return type;
16.72 - }
16.73 -
16.74 -}
17.1 --- a/rt/javap/src/main/java/org/apidesign/javap/StackMapIterator.java Sun Mar 03 22:50:02 2013 +0100
17.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
17.3 @@ -1,179 +0,0 @@
17.4 -/*
17.5 - * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this
17.11 - * particular file as subject to the "Classpath" exception as provided
17.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
17.25 - * or visit www.oracle.com if you need additional information or have any
17.26 - * questions.
17.27 - */
17.28 -
17.29 -package org.apidesign.javap;
17.30 -
17.31 -import static org.apidesign.javap.RuntimeConstants.ITEM_Integer;
17.32 -import static org.apidesign.javap.RuntimeConstants.ITEM_Float;
17.33 -import static org.apidesign.javap.RuntimeConstants.ITEM_Double;
17.34 -import static org.apidesign.javap.RuntimeConstants.ITEM_Long;
17.35 -import static org.apidesign.javap.RuntimeConstants.ITEM_Object;
17.36 -
17.37 -public final class StackMapIterator {
17.38 - private final StackMapTableData[] stackMapTable;
17.39 - private final TypeArray argTypes;
17.40 - private final TypeArray localTypes;
17.41 - private final TypeArray stackTypes;
17.42 -
17.43 - private int nextFrameIndex;
17.44 - private int lastFrameByteCodeOffset;
17.45 -
17.46 - private int byteCodeOffset;
17.47 -
17.48 - StackMapIterator(final MethodData methodData) {
17.49 - this(methodData.getStackMapTable(),
17.50 - methodData.getInternalSig(),
17.51 - methodData.isStatic());
17.52 - }
17.53 -
17.54 - StackMapIterator(final StackMapTableData[] stackMapTable,
17.55 - final String methodSignature,
17.56 - final boolean isStaticMethod) {
17.57 - this.stackMapTable = (stackMapTable != null)
17.58 - ? stackMapTable
17.59 - : new StackMapTableData[0];
17.60 -
17.61 - argTypes = getArgTypes(methodSignature, isStaticMethod);
17.62 - localTypes = new TypeArray();
17.63 - stackTypes = new TypeArray();
17.64 -
17.65 - localTypes.addAll(argTypes);
17.66 -
17.67 - lastFrameByteCodeOffset = -1;
17.68 - advanceBy(0);
17.69 - }
17.70 -
17.71 - public String getFrameAsString() {
17.72 - return (nextFrameIndex == 0)
17.73 - ? StackMapTableData.toString("INITIAL", 0, null, null)
17.74 - : stackMapTable[nextFrameIndex - 1].toString();
17.75 - }
17.76 -
17.77 - public int getFrameIndex() {
17.78 - return nextFrameIndex;
17.79 - }
17.80 -
17.81 - public TypeArray getFrameStack() {
17.82 - return stackTypes;
17.83 - }
17.84 -
17.85 - public TypeArray getFrameLocals() {
17.86 - return localTypes;
17.87 - }
17.88 -
17.89 - public TypeArray getArguments() {
17.90 - return argTypes;
17.91 - }
17.92 -
17.93 - public void advanceBy(final int numByteCodes) {
17.94 - if (numByteCodes < 0) {
17.95 - throw new IllegalStateException("Forward only iterator");
17.96 - }
17.97 -
17.98 - byteCodeOffset += numByteCodes;
17.99 - while ((nextFrameIndex < stackMapTable.length)
17.100 - && ((byteCodeOffset - lastFrameByteCodeOffset)
17.101 - >= (stackMapTable[nextFrameIndex].offsetDelta
17.102 - + 1))) {
17.103 - final StackMapTableData nextFrame = stackMapTable[nextFrameIndex];
17.104 -
17.105 - lastFrameByteCodeOffset += nextFrame.offsetDelta + 1;
17.106 - nextFrame.applyTo(localTypes, stackTypes);
17.107 -
17.108 - ++nextFrameIndex;
17.109 - }
17.110 - }
17.111 -
17.112 - public void advanceTo(final int nextByteCodeOffset) {
17.113 - advanceBy(nextByteCodeOffset - byteCodeOffset);
17.114 - }
17.115 -
17.116 - private static TypeArray getArgTypes(final String methodSignature,
17.117 - final boolean isStaticMethod) {
17.118 - final TypeArray argTypes = new TypeArray();
17.119 -
17.120 - if (!isStaticMethod) {
17.121 - argTypes.add(ITEM_Object);
17.122 - }
17.123 -
17.124 - if (methodSignature.charAt(0) != '(') {
17.125 - throw new IllegalArgumentException("Invalid method signature");
17.126 - }
17.127 -
17.128 - final int length = methodSignature.length();
17.129 - boolean skipType = false;
17.130 - int argType;
17.131 - for (int i = 1; i < length; ++i) {
17.132 - switch (methodSignature.charAt(i)) {
17.133 - case 'B':
17.134 - case 'C':
17.135 - case 'S':
17.136 - case 'Z':
17.137 - case 'I':
17.138 - argType = ITEM_Integer;
17.139 - break;
17.140 - case 'J':
17.141 - argType = ITEM_Long;
17.142 - break;
17.143 - case 'F':
17.144 - argType = ITEM_Float;
17.145 - break;
17.146 - case 'D':
17.147 - argType = ITEM_Double;
17.148 - break;
17.149 - case 'L': {
17.150 - i = methodSignature.indexOf(';', i + 1);
17.151 - if (i == -1) {
17.152 - throw new IllegalArgumentException(
17.153 - "Invalid method signature");
17.154 - }
17.155 - argType = ITEM_Object;
17.156 - break;
17.157 - }
17.158 - case ')':
17.159 - // not interested in the return value type
17.160 - return argTypes;
17.161 - case '[':
17.162 - if (!skipType) {
17.163 - argTypes.add(ITEM_Object);
17.164 - skipType = true;
17.165 - }
17.166 - continue;
17.167 -
17.168 - default:
17.169 - throw new IllegalArgumentException(
17.170 - "Invalid method signature");
17.171 - }
17.172 -
17.173 - if (!skipType) {
17.174 - argTypes.add(argType);
17.175 - } else {
17.176 - skipType = false;
17.177 - }
17.178 - }
17.179 -
17.180 - return argTypes;
17.181 - }
17.182 -}
18.1 --- a/rt/javap/src/main/java/org/apidesign/javap/StackMapTableData.java Sun Mar 03 22:50:02 2013 +0100
18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
18.3 @@ -1,223 +0,0 @@
18.4 -/*
18.5 - * Copyright (c) 2005, Oracle and/or its affiliates. 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. Oracle designates this
18.11 - * particular file as subject to the "Classpath" exception as provided
18.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
18.25 - * or visit www.oracle.com if you need additional information or have any
18.26 - * questions.
18.27 - */
18.28 -
18.29 -
18.30 -package org.apidesign.javap;
18.31 -
18.32 -import java.io.*;
18.33 -
18.34 -import static org.apidesign.javap.RuntimeConstants.*;
18.35 -
18.36 -/* represents one entry of StackMapTable attribute
18.37 - */
18.38 -abstract class StackMapTableData {
18.39 - final int frameType;
18.40 - int offsetDelta;
18.41 -
18.42 - StackMapTableData(int frameType) {
18.43 - this.frameType = frameType;
18.44 - }
18.45 -
18.46 - abstract void applyTo(TypeArray localTypes, TypeArray stackTypes);
18.47 -
18.48 - protected static String toString(
18.49 - final String frameType,
18.50 - final int offset,
18.51 - final int[] localTypes,
18.52 - final int[] stackTypes) {
18.53 - final StringBuilder sb = new StringBuilder(frameType);
18.54 -
18.55 - sb.append("(off: +").append(offset);
18.56 - if (localTypes != null) {
18.57 - sb.append(", locals: ");
18.58 - appendTypes(sb, localTypes);
18.59 - }
18.60 - if (stackTypes != null) {
18.61 - sb.append(", stack: ");
18.62 - appendTypes(sb, stackTypes);
18.63 - }
18.64 - sb.append(')');
18.65 -
18.66 - return sb.toString();
18.67 - }
18.68 -
18.69 - private static void appendTypes(final StringBuilder sb, final int[] types) {
18.70 - sb.append('[');
18.71 - if (types.length > 0) {
18.72 - sb.append(TypeArray.typeString(types[0]));
18.73 - for (int i = 1; i < types.length; ++i) {
18.74 - sb.append(", ");
18.75 - sb.append(TypeArray.typeString(types[i]));
18.76 - }
18.77 - }
18.78 - sb.append(']');
18.79 - }
18.80 -
18.81 - static class SameFrame extends StackMapTableData {
18.82 - SameFrame(int frameType, int offsetDelta) {
18.83 - super(frameType);
18.84 - this.offsetDelta = offsetDelta;
18.85 - }
18.86 -
18.87 - @Override
18.88 - void applyTo(TypeArray localTypes, TypeArray stackTypes) {
18.89 - stackTypes.clear();
18.90 - }
18.91 -
18.92 - @Override
18.93 - public String toString() {
18.94 - return toString("SAME" + ((frameType == SAME_FRAME_EXTENDED)
18.95 - ? "_FRAME_EXTENDED" : ""),
18.96 - offsetDelta,
18.97 - null, null);
18.98 - }
18.99 - }
18.100 -
18.101 - static class SameLocals1StackItem extends StackMapTableData {
18.102 - final int[] stack;
18.103 - SameLocals1StackItem(int frameType, int offsetDelta, int[] stack) {
18.104 - super(frameType);
18.105 - this.offsetDelta = offsetDelta;
18.106 - this.stack = stack;
18.107 - }
18.108 -
18.109 - @Override
18.110 - void applyTo(TypeArray localTypes, TypeArray stackTypes) {
18.111 - stackTypes.setAll(stack);
18.112 - }
18.113 -
18.114 - @Override
18.115 - public String toString() {
18.116 - return toString(
18.117 - "SAME_LOCALS_1_STACK_ITEM"
18.118 - + ((frameType == SAME_LOCALS_1_STACK_ITEM_EXTENDED)
18.119 - ? "_EXTENDED" : ""),
18.120 - offsetDelta,
18.121 - null, stack);
18.122 - }
18.123 - }
18.124 -
18.125 - static class ChopFrame extends StackMapTableData {
18.126 - ChopFrame(int frameType, int offsetDelta) {
18.127 - super(frameType);
18.128 - this.offsetDelta = offsetDelta;
18.129 - }
18.130 -
18.131 - @Override
18.132 - void applyTo(TypeArray localTypes, TypeArray stackTypes) {
18.133 - localTypes.setSize(localTypes.getSize()
18.134 - - (SAME_FRAME_EXTENDED - frameType));
18.135 - stackTypes.clear();
18.136 - }
18.137 -
18.138 - @Override
18.139 - public String toString() {
18.140 - return toString("CHOP", offsetDelta, null, null);
18.141 - }
18.142 - }
18.143 -
18.144 - static class AppendFrame extends StackMapTableData {
18.145 - final int[] locals;
18.146 - AppendFrame(int frameType, int offsetDelta, int[] locals) {
18.147 - super(frameType);
18.148 - this.offsetDelta = offsetDelta;
18.149 - this.locals = locals;
18.150 - }
18.151 -
18.152 - @Override
18.153 - void applyTo(TypeArray localTypes, TypeArray stackTypes) {
18.154 - localTypes.addAll(locals);
18.155 - stackTypes.clear();
18.156 - }
18.157 -
18.158 - @Override
18.159 - public String toString() {
18.160 - return toString("APPEND", offsetDelta, locals, null);
18.161 - }
18.162 - }
18.163 -
18.164 - static class FullFrame extends StackMapTableData {
18.165 - final int[] locals;
18.166 - final int[] stack;
18.167 - FullFrame(int offsetDelta, int[] locals, int[] stack) {
18.168 - super(FULL_FRAME);
18.169 - this.offsetDelta = offsetDelta;
18.170 - this.locals = locals;
18.171 - this.stack = stack;
18.172 - }
18.173 -
18.174 - @Override
18.175 - void applyTo(TypeArray localTypes, TypeArray stackTypes) {
18.176 - localTypes.setAll(locals);
18.177 - stackTypes.setAll(stack);
18.178 - }
18.179 -
18.180 - @Override
18.181 - public String toString() {
18.182 - return toString("FULL", offsetDelta, locals, stack);
18.183 - }
18.184 - }
18.185 -
18.186 - static StackMapTableData getInstance(DataInputStream in, MethodData method)
18.187 - throws IOException {
18.188 - int frameType = in.readUnsignedByte();
18.189 -
18.190 - if (frameType < SAME_FRAME_BOUND) {
18.191 - // same_frame
18.192 - return new SameFrame(frameType, frameType);
18.193 - } else if (SAME_FRAME_BOUND <= frameType && frameType < SAME_LOCALS_1_STACK_ITEM_BOUND) {
18.194 - // same_locals_1_stack_item_frame
18.195 - // read additional single stack element
18.196 - return new SameLocals1StackItem(frameType,
18.197 - (frameType - SAME_FRAME_BOUND),
18.198 - StackMapData.readTypeArray(in, 1, method));
18.199 - } else if (frameType == SAME_LOCALS_1_STACK_ITEM_EXTENDED) {
18.200 - // same_locals_1_stack_item_extended
18.201 - return new SameLocals1StackItem(frameType,
18.202 - in.readUnsignedShort(),
18.203 - StackMapData.readTypeArray(in, 1, method));
18.204 - } else if (SAME_LOCALS_1_STACK_ITEM_EXTENDED < frameType && frameType < SAME_FRAME_EXTENDED) {
18.205 - // chop_frame or same_frame_extended
18.206 - return new ChopFrame(frameType, in.readUnsignedShort());
18.207 - } else if (frameType == SAME_FRAME_EXTENDED) {
18.208 - // chop_frame or same_frame_extended
18.209 - return new SameFrame(frameType, in.readUnsignedShort());
18.210 - } else if (SAME_FRAME_EXTENDED < frameType && frameType < FULL_FRAME) {
18.211 - // append_frame
18.212 - return new AppendFrame(frameType, in.readUnsignedShort(),
18.213 - StackMapData.readTypeArray(in, frameType - SAME_FRAME_EXTENDED, method));
18.214 - } else if (frameType == FULL_FRAME) {
18.215 - // full_frame
18.216 - int offsetDelta = in.readUnsignedShort();
18.217 - int locals_size = in.readUnsignedShort();
18.218 - int[] locals = StackMapData.readTypeArray(in, locals_size, method);
18.219 - int stack_size = in.readUnsignedShort();
18.220 - int[] stack = StackMapData.readTypeArray(in, stack_size, method);
18.221 - return new FullFrame(offsetDelta, locals, stack);
18.222 - } else {
18.223 - throw new ClassFormatError("unrecognized frame_type in StackMapTable");
18.224 - }
18.225 - }
18.226 -}
19.1 --- a/rt/javap/src/main/java/org/apidesign/javap/TrapData.java Sun Mar 03 22:50:02 2013 +0100
19.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
19.3 @@ -1,62 +0,0 @@
19.4 -/*
19.5 - * Copyright (c) 2002, Oracle and/or its affiliates. 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. Oracle designates this
19.11 - * particular file as subject to the "Classpath" exception as provided
19.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19.25 - * or visit www.oracle.com if you need additional information or have any
19.26 - * questions.
19.27 - */
19.28 -
19.29 -
19.30 -package org.apidesign.javap;
19.31 -
19.32 -import java.io.*;
19.33 -
19.34 -/**
19.35 - * Stores exception table data in code attribute.
19.36 - *
19.37 - * @author Sucheta Dambalkar (Adopted code from jdis)
19.38 - */
19.39 -public final class TrapData {
19.40 - public final short start_pc;
19.41 - public final short end_pc;
19.42 - public final short handler_pc;
19.43 - public final short catch_cpx;
19.44 - final int num;
19.45 -
19.46 -
19.47 - /**
19.48 - * Read and store exception table data in code attribute.
19.49 - */
19.50 - TrapData(DataInputStream in, int num) throws IOException {
19.51 - this.num=num;
19.52 - start_pc = in.readShort();
19.53 - end_pc=in.readShort();
19.54 - handler_pc=in.readShort();
19.55 - catch_cpx=in.readShort();
19.56 - }
19.57 -
19.58 - /**
19.59 - * returns recommended identifier
19.60 - */
19.61 - public String ident() {
19.62 - return "t"+num;
19.63 - }
19.64 -
19.65 -}
20.1 --- a/rt/javap/src/main/java/org/apidesign/javap/TrapDataIterator.java Sun Mar 03 22:50:02 2013 +0100
20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
20.3 @@ -1,114 +0,0 @@
20.4 -/**
20.5 - * Back 2 Browser Bytecode Translator
20.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
20.7 - *
20.8 - * This program is free software: you can redistribute it and/or modify
20.9 - * it under the terms of the GNU General Public License as published by
20.10 - * the Free Software Foundation, version 2 of the License.
20.11 - *
20.12 - * This program is distributed in the hope that it will be useful,
20.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
20.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20.15 - * GNU General Public License for more details.
20.16 - *
20.17 - * You should have received a copy of the GNU General Public License
20.18 - * along with this program. Look for COPYING file in the top folder.
20.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
20.20 - */
20.21 -package org.apidesign.javap;
20.22 -
20.23 -/**
20.24 - *
20.25 - * @author Jaroslav Tulach <jtulach@netbeans.org>
20.26 - */
20.27 -public final class TrapDataIterator {
20.28 - private final Hashtable exStart = new Hashtable();
20.29 - private final Hashtable exStop = new Hashtable();
20.30 - private TrapData[] current = new TrapData[10];
20.31 - private int currentCount;
20.32 -
20.33 - TrapDataIterator(Vector exceptionTable) {
20.34 - for (int i=0 ; i < exceptionTable.size(); i++) {
20.35 - final TrapData td = (TrapData)exceptionTable.elementAt(i);
20.36 - put(exStart, td.start_pc, td);
20.37 - put(exStop, td.end_pc, td);
20.38 - }
20.39 - }
20.40 -
20.41 - private static void put(Hashtable h, short key, TrapData td) {
20.42 - Short s = Short.valueOf((short)key);
20.43 - Vector v = (Vector) h.get(s);
20.44 - if (v == null) {
20.45 - v = new Vector(1);
20.46 - h.put(s, v);
20.47 - }
20.48 - v.add(td);
20.49 - }
20.50 -
20.51 - private boolean processAll(Hashtable h, Short key, boolean add) {
20.52 - boolean change = false;
20.53 - Vector v = (Vector)h.get(key);
20.54 - if (v != null) {
20.55 - int s = v.size();
20.56 - for (int i = 0; i < s; i++) {
20.57 - TrapData td = (TrapData)v.elementAt(i);
20.58 - if (add) {
20.59 - add(td);
20.60 - change = true;
20.61 - } else {
20.62 - remove(td);
20.63 - change = true;
20.64 - }
20.65 - }
20.66 - }
20.67 - return change;
20.68 - }
20.69 -
20.70 - public boolean advanceTo(int i) {
20.71 - Short s = Short.valueOf((short)i);
20.72 - boolean ch1 = processAll(exStart, s, true);
20.73 - boolean ch2 = processAll(exStop, s, false);
20.74 - return ch1 || ch2;
20.75 - }
20.76 -
20.77 - public boolean useTry() {
20.78 - return currentCount > 0;
20.79 - }
20.80 -
20.81 - public TrapData[] current() {
20.82 - TrapData[] copy = new TrapData[currentCount];
20.83 - for (int i = 0; i < currentCount; i++) {
20.84 - copy[i] = current[i];
20.85 - }
20.86 - return copy;
20.87 - }
20.88 -
20.89 - private void add(TrapData e) {
20.90 - if (currentCount == current.length) {
20.91 - TrapData[] data = new TrapData[currentCount * 2];
20.92 - for (int i = 0; i < currentCount; i++) {
20.93 - data[i] = current[i];
20.94 - }
20.95 - current = data;
20.96 - }
20.97 - current[currentCount++] = e;
20.98 - }
20.99 -
20.100 - private void remove(TrapData e) {
20.101 - if (currentCount == 0) {
20.102 - return;
20.103 - }
20.104 - int from = 0;
20.105 - while (from < currentCount) {
20.106 - if (e == current[from++]) {
20.107 - break;
20.108 - }
20.109 - }
20.110 - while (from < currentCount) {
20.111 - current[from - 1] = current[from];
20.112 - current[from] = null;
20.113 - from++;
20.114 - }
20.115 - currentCount--;
20.116 - }
20.117 -}
21.1 --- a/rt/javap/src/main/java/org/apidesign/javap/TypeArray.java Sun Mar 03 22:50:02 2013 +0100
21.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
21.3 @@ -1,186 +0,0 @@
21.4 -/*
21.5 - * Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this
21.11 - * particular file as subject to the "Classpath" exception as provided
21.12 - * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21.25 - * or visit www.oracle.com if you need additional information or have any
21.26 - * questions.
21.27 - */
21.28 -
21.29 -package org.apidesign.javap;
21.30 -
21.31 -import static org.apidesign.javap.RuntimeConstants.ITEM_Bogus;
21.32 -import static org.apidesign.javap.RuntimeConstants.ITEM_Integer;
21.33 -import static org.apidesign.javap.RuntimeConstants.ITEM_Float;
21.34 -import static org.apidesign.javap.RuntimeConstants.ITEM_Double;
21.35 -import static org.apidesign.javap.RuntimeConstants.ITEM_Long;
21.36 -import static org.apidesign.javap.RuntimeConstants.ITEM_Null;
21.37 -import static org.apidesign.javap.RuntimeConstants.ITEM_InitObject;
21.38 -import static org.apidesign.javap.RuntimeConstants.ITEM_Object;
21.39 -import static org.apidesign.javap.RuntimeConstants.ITEM_NewObject;
21.40 -
21.41 -public final class TypeArray {
21.42 - private static final int CAPACITY_INCREMENT = 16;
21.43 -
21.44 - private int[] types;
21.45 - private int size;
21.46 -
21.47 - public TypeArray() {
21.48 - }
21.49 -
21.50 - public TypeArray(final TypeArray initialTypes) {
21.51 - setAll(initialTypes);
21.52 - }
21.53 -
21.54 - public void add(final int newType) {
21.55 - ensureCapacity(size + 1);
21.56 - types[size++] = newType;
21.57 - }
21.58 -
21.59 - public void addAll(final TypeArray newTypes) {
21.60 - addAll(newTypes.types, 0, newTypes.size);
21.61 - }
21.62 -
21.63 - public void addAll(final int[] newTypes) {
21.64 - addAll(newTypes, 0, newTypes.length);
21.65 - }
21.66 -
21.67 - public void addAll(final int[] newTypes,
21.68 - final int offset,
21.69 - final int count) {
21.70 - if (count > 0) {
21.71 - ensureCapacity(size + count);
21.72 - arraycopy(newTypes, offset, types, size, count);
21.73 - size += count;
21.74 - }
21.75 - }
21.76 -
21.77 - public void set(final int index, final int newType) {
21.78 - types[index] = newType;
21.79 - }
21.80 -
21.81 - public void setAll(final TypeArray newTypes) {
21.82 - setAll(newTypes.types, 0, newTypes.size);
21.83 - }
21.84 -
21.85 - public void setAll(final int[] newTypes) {
21.86 - setAll(newTypes, 0, newTypes.length);
21.87 - }
21.88 -
21.89 - public void setAll(final int[] newTypes,
21.90 - final int offset,
21.91 - final int count) {
21.92 - if (count > 0) {
21.93 - ensureCapacity(count);
21.94 - arraycopy(newTypes, offset, types, 0, count);
21.95 - size = count;
21.96 - } else {
21.97 - clear();
21.98 - }
21.99 - }
21.100 -
21.101 - public void setSize(final int newSize) {
21.102 - if (size != newSize) {
21.103 - ensureCapacity(newSize);
21.104 -
21.105 - for (int i = size; i < newSize; ++i) {
21.106 - types[i] = 0;
21.107 - }
21.108 - size = newSize;
21.109 - }
21.110 - }
21.111 -
21.112 - public void clear() {
21.113 - size = 0;
21.114 - }
21.115 -
21.116 - public int getSize() {
21.117 - return size;
21.118 - }
21.119 -
21.120 - public int get(final int index) {
21.121 - return types[index];
21.122 - }
21.123 -
21.124 - public static String typeString(final int type) {
21.125 - switch (type & 0xff) {
21.126 - case ITEM_Bogus:
21.127 - return "_top_";
21.128 - case ITEM_Integer:
21.129 - return "_int_";
21.130 - case ITEM_Float:
21.131 - return "_float_";
21.132 - case ITEM_Double:
21.133 - return "_double_";
21.134 - case ITEM_Long:
21.135 - return "_long_";
21.136 - case ITEM_Null:
21.137 - return "_null_";
21.138 - case ITEM_InitObject: // UninitializedThis
21.139 - return "_init_";
21.140 - case ITEM_Object:
21.141 - return "_object_";
21.142 - case ITEM_NewObject: // Uninitialized
21.143 - return "_new_";
21.144 - default:
21.145 - throw new IllegalArgumentException("Unknown type");
21.146 - }
21.147 - }
21.148 -
21.149 - @Override
21.150 - public String toString() {
21.151 - final StringBuilder sb = new StringBuilder("[");
21.152 - if (size > 0) {
21.153 - sb.append(typeString(types[0]));
21.154 - for (int i = 1; i < size; ++i) {
21.155 - sb.append(", ");
21.156 - sb.append(typeString(types[i]));
21.157 - }
21.158 - }
21.159 -
21.160 - return sb.append(']').toString();
21.161 - }
21.162 -
21.163 - private void ensureCapacity(final int minCapacity) {
21.164 - if ((minCapacity == 0)
21.165 - || (types != null) && (minCapacity <= types.length)) {
21.166 - return;
21.167 - }
21.168 -
21.169 - final int newCapacity =
21.170 - ((minCapacity + CAPACITY_INCREMENT - 1) / CAPACITY_INCREMENT)
21.171 - * CAPACITY_INCREMENT;
21.172 - final int[] newTypes = new int[newCapacity];
21.173 -
21.174 - if (size > 0) {
21.175 - arraycopy(types, 0, newTypes, 0, size);
21.176 - }
21.177 -
21.178 - types = newTypes;
21.179 - }
21.180 -
21.181 - // no System.arraycopy
21.182 - private void arraycopy(final int[] src, final int srcPos,
21.183 - final int[] dest, final int destPos,
21.184 - final int length) {
21.185 - for (int i = 0; i < length; ++i) {
21.186 - dest[destPos + i] = src[srcPos + i];
21.187 - }
21.188 - }
21.189 -}
22.1 --- a/rt/javap/src/main/java/org/apidesign/javap/Vector.java Sun Mar 03 22:50:02 2013 +0100
22.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
22.3 @@ -1,89 +0,0 @@
22.4 -/**
22.5 - * Back 2 Browser Bytecode Translator
22.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
22.7 - *
22.8 - * This program is free software: you can redistribute it and/or modify
22.9 - * it under the terms of the GNU General Public License as published by
22.10 - * the Free Software Foundation, version 2 of the License.
22.11 - *
22.12 - * This program is distributed in the hope that it will be useful,
22.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
22.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22.15 - * GNU General Public License for more details.
22.16 - *
22.17 - * You should have received a copy of the GNU General Public License
22.18 - * along with this program. Look for COPYING file in the top folder.
22.19 - * If not, see http://opensource.org/licenses/GPL-2.0.
22.20 - */
22.21 -package org.apidesign.javap;
22.22 -
22.23 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
22.24 -import org.apidesign.bck2brwsr.core.JavaScriptPrototype;
22.25 -
22.26 -/** A JavaScript ready replacement for java.util.Vector
22.27 - *
22.28 - * @author Jaroslav Tulach <jtulach@netbeans.org>
22.29 - */
22.30 -@JavaScriptPrototype(prototype = "new Array" )
22.31 -final class Vector {
22.32 - private Object[] arr;
22.33 -
22.34 - Vector() {
22.35 - }
22.36 -
22.37 - Vector(int i) {
22.38 - }
22.39 -
22.40 - void add(Object objectType) {
22.41 - addElement(objectType);
22.42 - }
22.43 - @JavaScriptBody(args = { "obj" }, body =
22.44 - "this.push(obj);"
22.45 - )
22.46 - void addElement(Object obj) {
22.47 - final int s = size();
22.48 - setSize(s + 1);
22.49 - setElementAt(obj, s);
22.50 - }
22.51 -
22.52 - @JavaScriptBody(args = { }, body =
22.53 - "return this.length;"
22.54 - )
22.55 - int size() {
22.56 - return arr == null ? 0 : arr.length;
22.57 - }
22.58 -
22.59 - @JavaScriptBody(args = { "newArr" }, body =
22.60 - "for (var i = 0; i < this.length; i++) {\n"
22.61 - + " newArr[i] = this[i];\n"
22.62 - + "}\n")
22.63 - void copyInto(Object[] newArr) {
22.64 - if (arr == null) {
22.65 - return;
22.66 - }
22.67 - int min = Math.min(newArr.length, arr.length);
22.68 - for (int i = 0; i < min; i++) {
22.69 - newArr[i] = arr[i];
22.70 - }
22.71 - }
22.72 -
22.73 - @JavaScriptBody(args = { "index" }, body =
22.74 - "return this[index];"
22.75 - )
22.76 - Object elementAt(int index) {
22.77 - return arr[index];
22.78 - }
22.79 -
22.80 - private void setSize(int len) {
22.81 - Object[] newArr = new Object[len];
22.82 - copyInto(newArr);
22.83 - arr = newArr;
22.84 - }
22.85 -
22.86 - @JavaScriptBody(args = { "val", "index" }, body =
22.87 - "this[index] = val;"
22.88 - )
22.89 - void setElementAt(Object val, int index) {
22.90 - arr[index] = val;
22.91 - }
22.92 -}
23.1 --- a/rt/pom.xml Sun Mar 03 22:50:02 2013 +0100
23.2 +++ b/rt/pom.xml Mon Mar 04 19:20:40 2013 +0100
23.3 @@ -14,10 +14,9 @@
23.4 <modules>
23.5 <module>core</module>
23.6 <module>emul</module>
23.7 - <module>javap</module>
23.8 <module>launcher</module>
23.9 <module>mojo</module>
23.10 <module>vm</module>
23.11 <module>vmtest</module>
23.12 </modules>
23.13 -</project>
23.14 \ No newline at end of file
23.15 +</project>
24.1 --- a/rt/vm/pom.xml Sun Mar 03 22:50:02 2013 +0100
24.2 +++ b/rt/vm/pom.xml Mon Mar 04 19:20:40 2013 +0100
24.3 @@ -139,11 +139,5 @@
24.4 <version>${project.version}</version>
24.5 <scope>compile</scope>
24.6 </dependency>
24.7 - <dependency>
24.8 - <groupId>${project.groupId}</groupId>
24.9 - <artifactId>javap</artifactId>
24.10 - <version>${project.version}</version>
24.11 - <scope>compile</scope>
24.12 - </dependency>
24.13 </dependencies>
24.14 </project>
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeParser.java Mon Mar 04 19:20:40 2013 +0100
25.3 @@ -0,0 +1,3461 @@
25.4 +/*
25.5 + * Copyright (c) 2002, 2004, Oracle and/or its affiliates. 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. Oracle designates this
25.11 + * particular file as subject to the "Classpath" exception as provided
25.12 + * by Oracle in the LICENSE file that accompanied this code.
25.13 + *
25.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
25.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25.17 + * version 2 for more details (a copy is included in the LICENSE file that
25.18 + * accompanied this code).
25.19 + *
25.20 + * You should have received a copy of the GNU General Public License version
25.21 + * 2 along with this work; if not, write to the Free Software Foundation,
25.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25.23 + *
25.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
25.25 + * or visit www.oracle.com if you need additional information or have any
25.26 + * questions.
25.27 + */
25.28 +package org.apidesign.vm4brwsr;
25.29 +
25.30 +import java.io.ByteArrayInputStream;
25.31 +import java.io.DataInputStream;
25.32 +import java.io.IOException;
25.33 +import java.io.InputStream;
25.34 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
25.35 +import org.apidesign.bck2brwsr.core.JavaScriptPrototype;
25.36 +
25.37 +/** This is a byte code parser heavily based on original code of JavaP utility.
25.38 + * As such I decided to keep the original Oracle's GPLv2 header.
25.39 + *
25.40 + * @author Jaroslav Tulach <jtulach@netbeans.org>
25.41 + */
25.42 +final class ByteCodeParser {
25.43 + private ByteCodeParser() {
25.44 + }
25.45 + /* Signature Characters */
25.46 + public static final char SIGC_VOID = 'V';
25.47 + public static final String SIG_VOID = "V";
25.48 + public static final char SIGC_BOOLEAN = 'Z';
25.49 + public static final String SIG_BOOLEAN = "Z";
25.50 + public static final char SIGC_BYTE = 'B';
25.51 + public static final String SIG_BYTE = "B";
25.52 + public static final char SIGC_CHAR = 'C';
25.53 + public static final String SIG_CHAR = "C";
25.54 + public static final char SIGC_SHORT = 'S';
25.55 + public static final String SIG_SHORT = "S";
25.56 + public static final char SIGC_INT = 'I';
25.57 + public static final String SIG_INT = "I";
25.58 + public static final char SIGC_LONG = 'J';
25.59 + public static final String SIG_LONG = "J";
25.60 + public static final char SIGC_FLOAT = 'F';
25.61 + public static final String SIG_FLOAT = "F";
25.62 + public static final char SIGC_DOUBLE = 'D';
25.63 + public static final String SIG_DOUBLE = "D";
25.64 + public static final char SIGC_ARRAY = '[';
25.65 + public static final String SIG_ARRAY = "[";
25.66 + public static final char SIGC_CLASS = 'L';
25.67 + public static final String SIG_CLASS = "L";
25.68 + public static final char SIGC_METHOD = '(';
25.69 + public static final String SIG_METHOD = "(";
25.70 + public static final char SIGC_ENDCLASS = ';';
25.71 + public static final String SIG_ENDCLASS = ";";
25.72 + public static final char SIGC_ENDMETHOD = ')';
25.73 + public static final String SIG_ENDMETHOD = ")";
25.74 + public static final char SIGC_PACKAGE = '/';
25.75 + public static final String SIG_PACKAGE = "/";
25.76 +
25.77 + /* Class File Constants */
25.78 + public static final int JAVA_MAGIC = 0xcafebabe;
25.79 + public static final int JAVA_VERSION = 45;
25.80 + public static final int JAVA_MINOR_VERSION = 3;
25.81 +
25.82 + /* Constant table */
25.83 + public static final int CONSTANT_UTF8 = 1;
25.84 + public static final int CONSTANT_UNICODE = 2;
25.85 + public static final int CONSTANT_INTEGER = 3;
25.86 + public static final int CONSTANT_FLOAT = 4;
25.87 + public static final int CONSTANT_LONG = 5;
25.88 + public static final int CONSTANT_DOUBLE = 6;
25.89 + public static final int CONSTANT_CLASS = 7;
25.90 + public static final int CONSTANT_STRING = 8;
25.91 + public static final int CONSTANT_FIELD = 9;
25.92 + public static final int CONSTANT_METHOD = 10;
25.93 + public static final int CONSTANT_INTERFACEMETHOD = 11;
25.94 + public static final int CONSTANT_NAMEANDTYPE = 12;
25.95 +
25.96 + /* Access Flags */
25.97 + public static final int ACC_PUBLIC = 0x00000001;
25.98 + public static final int ACC_PRIVATE = 0x00000002;
25.99 + public static final int ACC_PROTECTED = 0x00000004;
25.100 + public static final int ACC_STATIC = 0x00000008;
25.101 + public static final int ACC_FINAL = 0x00000010;
25.102 + public static final int ACC_SYNCHRONIZED = 0x00000020;
25.103 + public static final int ACC_SUPER = 0x00000020;
25.104 + public static final int ACC_VOLATILE = 0x00000040;
25.105 + public static final int ACC_TRANSIENT = 0x00000080;
25.106 + public static final int ACC_NATIVE = 0x00000100;
25.107 + public static final int ACC_INTERFACE = 0x00000200;
25.108 + public static final int ACC_ABSTRACT = 0x00000400;
25.109 + public static final int ACC_STRICT = 0x00000800;
25.110 + public static final int ACC_EXPLICIT = 0x00001000;
25.111 + public static final int ACC_SYNTHETIC = 0x00010000; // actually, this is an attribute
25.112 +
25.113 + /* Type codes */
25.114 + public static final int T_CLASS = 0x00000002;
25.115 + public static final int T_BOOLEAN = 0x00000004;
25.116 + public static final int T_CHAR = 0x00000005;
25.117 + public static final int T_FLOAT = 0x00000006;
25.118 + public static final int T_DOUBLE = 0x00000007;
25.119 + public static final int T_BYTE = 0x00000008;
25.120 + public static final int T_SHORT = 0x00000009;
25.121 + public static final int T_INT = 0x0000000a;
25.122 + public static final int T_LONG = 0x0000000b;
25.123 +
25.124 + /* Type codes for StackMap attribute */
25.125 + public static final int ITEM_Bogus =0; // an unknown or uninitialized value
25.126 + public static final int ITEM_Integer =1; // a 32-bit integer
25.127 + public static final int ITEM_Float =2; // not used
25.128 + public static final int ITEM_Double =3; // not used
25.129 + public static final int ITEM_Long =4; // a 64-bit integer
25.130 + public static final int ITEM_Null =5; // the type of null
25.131 + public static final int ITEM_InitObject =6; // "this" in constructor
25.132 + public static final int ITEM_Object =7; // followed by 2-byte index of class name
25.133 + public static final int ITEM_NewObject =8; // followed by 2-byte ref to "new"
25.134 +
25.135 + /* Constants used in StackMapTable attribute */
25.136 + public static final int SAME_FRAME_BOUND = 64;
25.137 + public static final int SAME_LOCALS_1_STACK_ITEM_BOUND = 128;
25.138 + public static final int SAME_LOCALS_1_STACK_ITEM_EXTENDED = 247;
25.139 + public static final int SAME_FRAME_EXTENDED = 251;
25.140 + public static final int FULL_FRAME = 255;
25.141 +
25.142 + /* Opcodes */
25.143 + public static final int opc_dead = -2;
25.144 + public static final int opc_label = -1;
25.145 + public static final int opc_nop = 0;
25.146 + public static final int opc_aconst_null = 1;
25.147 + public static final int opc_iconst_m1 = 2;
25.148 + public static final int opc_iconst_0 = 3;
25.149 + public static final int opc_iconst_1 = 4;
25.150 + public static final int opc_iconst_2 = 5;
25.151 + public static final int opc_iconst_3 = 6;
25.152 + public static final int opc_iconst_4 = 7;
25.153 + public static final int opc_iconst_5 = 8;
25.154 + public static final int opc_lconst_0 = 9;
25.155 + public static final int opc_lconst_1 = 10;
25.156 + public static final int opc_fconst_0 = 11;
25.157 + public static final int opc_fconst_1 = 12;
25.158 + public static final int opc_fconst_2 = 13;
25.159 + public static final int opc_dconst_0 = 14;
25.160 + public static final int opc_dconst_1 = 15;
25.161 + public static final int opc_bipush = 16;
25.162 + public static final int opc_sipush = 17;
25.163 + public static final int opc_ldc = 18;
25.164 + public static final int opc_ldc_w = 19;
25.165 + public static final int opc_ldc2_w = 20;
25.166 + public static final int opc_iload = 21;
25.167 + public static final int opc_lload = 22;
25.168 + public static final int opc_fload = 23;
25.169 + public static final int opc_dload = 24;
25.170 + public static final int opc_aload = 25;
25.171 + public static final int opc_iload_0 = 26;
25.172 + public static final int opc_iload_1 = 27;
25.173 + public static final int opc_iload_2 = 28;
25.174 + public static final int opc_iload_3 = 29;
25.175 + public static final int opc_lload_0 = 30;
25.176 + public static final int opc_lload_1 = 31;
25.177 + public static final int opc_lload_2 = 32;
25.178 + public static final int opc_lload_3 = 33;
25.179 + public static final int opc_fload_0 = 34;
25.180 + public static final int opc_fload_1 = 35;
25.181 + public static final int opc_fload_2 = 36;
25.182 + public static final int opc_fload_3 = 37;
25.183 + public static final int opc_dload_0 = 38;
25.184 + public static final int opc_dload_1 = 39;
25.185 + public static final int opc_dload_2 = 40;
25.186 + public static final int opc_dload_3 = 41;
25.187 + public static final int opc_aload_0 = 42;
25.188 + public static final int opc_aload_1 = 43;
25.189 + public static final int opc_aload_2 = 44;
25.190 + public static final int opc_aload_3 = 45;
25.191 + public static final int opc_iaload = 46;
25.192 + public static final int opc_laload = 47;
25.193 + public static final int opc_faload = 48;
25.194 + public static final int opc_daload = 49;
25.195 + public static final int opc_aaload = 50;
25.196 + public static final int opc_baload = 51;
25.197 + public static final int opc_caload = 52;
25.198 + public static final int opc_saload = 53;
25.199 + public static final int opc_istore = 54;
25.200 + public static final int opc_lstore = 55;
25.201 + public static final int opc_fstore = 56;
25.202 + public static final int opc_dstore = 57;
25.203 + public static final int opc_astore = 58;
25.204 + public static final int opc_istore_0 = 59;
25.205 + public static final int opc_istore_1 = 60;
25.206 + public static final int opc_istore_2 = 61;
25.207 + public static final int opc_istore_3 = 62;
25.208 + public static final int opc_lstore_0 = 63;
25.209 + public static final int opc_lstore_1 = 64;
25.210 + public static final int opc_lstore_2 = 65;
25.211 + public static final int opc_lstore_3 = 66;
25.212 + public static final int opc_fstore_0 = 67;
25.213 + public static final int opc_fstore_1 = 68;
25.214 + public static final int opc_fstore_2 = 69;
25.215 + public static final int opc_fstore_3 = 70;
25.216 + public static final int opc_dstore_0 = 71;
25.217 + public static final int opc_dstore_1 = 72;
25.218 + public static final int opc_dstore_2 = 73;
25.219 + public static final int opc_dstore_3 = 74;
25.220 + public static final int opc_astore_0 = 75;
25.221 + public static final int opc_astore_1 = 76;
25.222 + public static final int opc_astore_2 = 77;
25.223 + public static final int opc_astore_3 = 78;
25.224 + public static final int opc_iastore = 79;
25.225 + public static final int opc_lastore = 80;
25.226 + public static final int opc_fastore = 81;
25.227 + public static final int opc_dastore = 82;
25.228 + public static final int opc_aastore = 83;
25.229 + public static final int opc_bastore = 84;
25.230 + public static final int opc_castore = 85;
25.231 + public static final int opc_sastore = 86;
25.232 + public static final int opc_pop = 87;
25.233 + public static final int opc_pop2 = 88;
25.234 + public static final int opc_dup = 89;
25.235 + public static final int opc_dup_x1 = 90;
25.236 + public static final int opc_dup_x2 = 91;
25.237 + public static final int opc_dup2 = 92;
25.238 + public static final int opc_dup2_x1 = 93;
25.239 + public static final int opc_dup2_x2 = 94;
25.240 + public static final int opc_swap = 95;
25.241 + public static final int opc_iadd = 96;
25.242 + public static final int opc_ladd = 97;
25.243 + public static final int opc_fadd = 98;
25.244 + public static final int opc_dadd = 99;
25.245 + public static final int opc_isub = 100;
25.246 + public static final int opc_lsub = 101;
25.247 + public static final int opc_fsub = 102;
25.248 + public static final int opc_dsub = 103;
25.249 + public static final int opc_imul = 104;
25.250 + public static final int opc_lmul = 105;
25.251 + public static final int opc_fmul = 106;
25.252 + public static final int opc_dmul = 107;
25.253 + public static final int opc_idiv = 108;
25.254 + public static final int opc_ldiv = 109;
25.255 + public static final int opc_fdiv = 110;
25.256 + public static final int opc_ddiv = 111;
25.257 + public static final int opc_irem = 112;
25.258 + public static final int opc_lrem = 113;
25.259 + public static final int opc_frem = 114;
25.260 + public static final int opc_drem = 115;
25.261 + public static final int opc_ineg = 116;
25.262 + public static final int opc_lneg = 117;
25.263 + public static final int opc_fneg = 118;
25.264 + public static final int opc_dneg = 119;
25.265 + public static final int opc_ishl = 120;
25.266 + public static final int opc_lshl = 121;
25.267 + public static final int opc_ishr = 122;
25.268 + public static final int opc_lshr = 123;
25.269 + public static final int opc_iushr = 124;
25.270 + public static final int opc_lushr = 125;
25.271 + public static final int opc_iand = 126;
25.272 + public static final int opc_land = 127;
25.273 + public static final int opc_ior = 128;
25.274 + public static final int opc_lor = 129;
25.275 + public static final int opc_ixor = 130;
25.276 + public static final int opc_lxor = 131;
25.277 + public static final int opc_iinc = 132;
25.278 + public static final int opc_i2l = 133;
25.279 + public static final int opc_i2f = 134;
25.280 + public static final int opc_i2d = 135;
25.281 + public static final int opc_l2i = 136;
25.282 + public static final int opc_l2f = 137;
25.283 + public static final int opc_l2d = 138;
25.284 + public static final int opc_f2i = 139;
25.285 + public static final int opc_f2l = 140;
25.286 + public static final int opc_f2d = 141;
25.287 + public static final int opc_d2i = 142;
25.288 + public static final int opc_d2l = 143;
25.289 + public static final int opc_d2f = 144;
25.290 + public static final int opc_i2b = 145;
25.291 + public static final int opc_int2byte = 145;
25.292 + public static final int opc_i2c = 146;
25.293 + public static final int opc_int2char = 146;
25.294 + public static final int opc_i2s = 147;
25.295 + public static final int opc_int2short = 147;
25.296 + public static final int opc_lcmp = 148;
25.297 + public static final int opc_fcmpl = 149;
25.298 + public static final int opc_fcmpg = 150;
25.299 + public static final int opc_dcmpl = 151;
25.300 + public static final int opc_dcmpg = 152;
25.301 + public static final int opc_ifeq = 153;
25.302 + public static final int opc_ifne = 154;
25.303 + public static final int opc_iflt = 155;
25.304 + public static final int opc_ifge = 156;
25.305 + public static final int opc_ifgt = 157;
25.306 + public static final int opc_ifle = 158;
25.307 + public static final int opc_if_icmpeq = 159;
25.308 + public static final int opc_if_icmpne = 160;
25.309 + public static final int opc_if_icmplt = 161;
25.310 + public static final int opc_if_icmpge = 162;
25.311 + public static final int opc_if_icmpgt = 163;
25.312 + public static final int opc_if_icmple = 164;
25.313 + public static final int opc_if_acmpeq = 165;
25.314 + public static final int opc_if_acmpne = 166;
25.315 + public static final int opc_goto = 167;
25.316 + public static final int opc_jsr = 168;
25.317 + public static final int opc_ret = 169;
25.318 + public static final int opc_tableswitch = 170;
25.319 + public static final int opc_lookupswitch = 171;
25.320 + public static final int opc_ireturn = 172;
25.321 + public static final int opc_lreturn = 173;
25.322 + public static final int opc_freturn = 174;
25.323 + public static final int opc_dreturn = 175;
25.324 + public static final int opc_areturn = 176;
25.325 + public static final int opc_return = 177;
25.326 + public static final int opc_getstatic = 178;
25.327 + public static final int opc_putstatic = 179;
25.328 + public static final int opc_getfield = 180;
25.329 + public static final int opc_putfield = 181;
25.330 + public static final int opc_invokevirtual = 182;
25.331 + public static final int opc_invokenonvirtual = 183;
25.332 + public static final int opc_invokespecial = 183;
25.333 + public static final int opc_invokestatic = 184;
25.334 + public static final int opc_invokeinterface = 185;
25.335 +// public static final int opc_xxxunusedxxx = 186;
25.336 + public static final int opc_new = 187;
25.337 + public static final int opc_newarray = 188;
25.338 + public static final int opc_anewarray = 189;
25.339 + public static final int opc_arraylength = 190;
25.340 + public static final int opc_athrow = 191;
25.341 + public static final int opc_checkcast = 192;
25.342 + public static final int opc_instanceof = 193;
25.343 + public static final int opc_monitorenter = 194;
25.344 + public static final int opc_monitorexit = 195;
25.345 + public static final int opc_wide = 196;
25.346 + public static final int opc_multianewarray = 197;
25.347 + public static final int opc_ifnull = 198;
25.348 + public static final int opc_ifnonnull = 199;
25.349 + public static final int opc_goto_w = 200;
25.350 + public static final int opc_jsr_w = 201;
25.351 + /* Pseudo-instructions */
25.352 + public static final int opc_bytecode = 203;
25.353 + public static final int opc_try = 204;
25.354 + public static final int opc_endtry = 205;
25.355 + public static final int opc_catch = 206;
25.356 + public static final int opc_var = 207;
25.357 + public static final int opc_endvar = 208;
25.358 + public static final int opc_localsmap = 209;
25.359 + public static final int opc_stackmap = 210;
25.360 + /* PicoJava prefixes */
25.361 + public static final int opc_nonpriv = 254;
25.362 + public static final int opc_priv = 255;
25.363 +
25.364 + /* Wide instructions */
25.365 + public static final int opc_iload_w = (opc_wide<<8)|opc_iload;
25.366 + public static final int opc_lload_w = (opc_wide<<8)|opc_lload;
25.367 + public static final int opc_fload_w = (opc_wide<<8)|opc_fload;
25.368 + public static final int opc_dload_w = (opc_wide<<8)|opc_dload;
25.369 + public static final int opc_aload_w = (opc_wide<<8)|opc_aload;
25.370 + public static final int opc_istore_w = (opc_wide<<8)|opc_istore;
25.371 + public static final int opc_lstore_w = (opc_wide<<8)|opc_lstore;
25.372 + public static final int opc_fstore_w = (opc_wide<<8)|opc_fstore;
25.373 + public static final int opc_dstore_w = (opc_wide<<8)|opc_dstore;
25.374 + public static final int opc_astore_w = (opc_wide<<8)|opc_astore;
25.375 + public static final int opc_ret_w = (opc_wide<<8)|opc_ret;
25.376 + public static final int opc_iinc_w = (opc_wide<<8)|opc_iinc;
25.377 +
25.378 + /* Opcode Names */
25.379 + public static final String opcNamesTab[] = {
25.380 + "nop",
25.381 + "aconst_null",
25.382 + "iconst_m1",
25.383 + "iconst_0",
25.384 + "iconst_1",
25.385 + "iconst_2",
25.386 + "iconst_3",
25.387 + "iconst_4",
25.388 + "iconst_5",
25.389 + "lconst_0",
25.390 + "lconst_1",
25.391 + "fconst_0",
25.392 + "fconst_1",
25.393 + "fconst_2",
25.394 + "dconst_0",
25.395 + "dconst_1",
25.396 + "bipush",
25.397 + "sipush",
25.398 + "ldc",
25.399 + "ldc_w",
25.400 + "ldc2_w",
25.401 + "iload",
25.402 + "lload",
25.403 + "fload",
25.404 + "dload",
25.405 + "aload",
25.406 + "iload_0",
25.407 + "iload_1",
25.408 + "iload_2",
25.409 + "iload_3",
25.410 + "lload_0",
25.411 + "lload_1",
25.412 + "lload_2",
25.413 + "lload_3",
25.414 + "fload_0",
25.415 + "fload_1",
25.416 + "fload_2",
25.417 + "fload_3",
25.418 + "dload_0",
25.419 + "dload_1",
25.420 + "dload_2",
25.421 + "dload_3",
25.422 + "aload_0",
25.423 + "aload_1",
25.424 + "aload_2",
25.425 + "aload_3",
25.426 + "iaload",
25.427 + "laload",
25.428 + "faload",
25.429 + "daload",
25.430 + "aaload",
25.431 + "baload",
25.432 + "caload",
25.433 + "saload",
25.434 + "istore",
25.435 + "lstore",
25.436 + "fstore",
25.437 + "dstore",
25.438 + "astore",
25.439 + "istore_0",
25.440 + "istore_1",
25.441 + "istore_2",
25.442 + "istore_3",
25.443 + "lstore_0",
25.444 + "lstore_1",
25.445 + "lstore_2",
25.446 + "lstore_3",
25.447 + "fstore_0",
25.448 + "fstore_1",
25.449 + "fstore_2",
25.450 + "fstore_3",
25.451 + "dstore_0",
25.452 + "dstore_1",
25.453 + "dstore_2",
25.454 + "dstore_3",
25.455 + "astore_0",
25.456 + "astore_1",
25.457 + "astore_2",
25.458 + "astore_3",
25.459 + "iastore",
25.460 + "lastore",
25.461 + "fastore",
25.462 + "dastore",
25.463 + "aastore",
25.464 + "bastore",
25.465 + "castore",
25.466 + "sastore",
25.467 + "pop",
25.468 + "pop2",
25.469 + "dup",
25.470 + "dup_x1",
25.471 + "dup_x2",
25.472 + "dup2",
25.473 + "dup2_x1",
25.474 + "dup2_x2",
25.475 + "swap",
25.476 + "iadd",
25.477 + "ladd",
25.478 + "fadd",
25.479 + "dadd",
25.480 + "isub",
25.481 + "lsub",
25.482 + "fsub",
25.483 + "dsub",
25.484 + "imul",
25.485 + "lmul",
25.486 + "fmul",
25.487 + "dmul",
25.488 + "idiv",
25.489 + "ldiv",
25.490 + "fdiv",
25.491 + "ddiv",
25.492 + "irem",
25.493 + "lrem",
25.494 + "frem",
25.495 + "drem",
25.496 + "ineg",
25.497 + "lneg",
25.498 + "fneg",
25.499 + "dneg",
25.500 + "ishl",
25.501 + "lshl",
25.502 + "ishr",
25.503 + "lshr",
25.504 + "iushr",
25.505 + "lushr",
25.506 + "iand",
25.507 + "land",
25.508 + "ior",
25.509 + "lor",
25.510 + "ixor",
25.511 + "lxor",
25.512 + "iinc",
25.513 + "i2l",
25.514 + "i2f",
25.515 + "i2d",
25.516 + "l2i",
25.517 + "l2f",
25.518 + "l2d",
25.519 + "f2i",
25.520 + "f2l",
25.521 + "f2d",
25.522 + "d2i",
25.523 + "d2l",
25.524 + "d2f",
25.525 + "i2b",
25.526 + "i2c",
25.527 + "i2s",
25.528 + "lcmp",
25.529 + "fcmpl",
25.530 + "fcmpg",
25.531 + "dcmpl",
25.532 + "dcmpg",
25.533 + "ifeq",
25.534 + "ifne",
25.535 + "iflt",
25.536 + "ifge",
25.537 + "ifgt",
25.538 + "ifle",
25.539 + "if_icmpeq",
25.540 + "if_icmpne",
25.541 + "if_icmplt",
25.542 + "if_icmpge",
25.543 + "if_icmpgt",
25.544 + "if_icmple",
25.545 + "if_acmpeq",
25.546 + "if_acmpne",
25.547 + "goto",
25.548 + "jsr",
25.549 + "ret",
25.550 + "tableswitch",
25.551 + "lookupswitch",
25.552 + "ireturn",
25.553 + "lreturn",
25.554 + "freturn",
25.555 + "dreturn",
25.556 + "areturn",
25.557 + "return",
25.558 + "getstatic",
25.559 + "putstatic",
25.560 + "getfield",
25.561 + "putfield",
25.562 + "invokevirtual",
25.563 + "invokespecial", // was "invokenonvirtual",
25.564 + "invokestatic",
25.565 + "invokeinterface",
25.566 + "bytecode 186", //"xxxunusedxxx",
25.567 + "new",
25.568 + "newarray",
25.569 + "anewarray",
25.570 + "arraylength",
25.571 + "athrow",
25.572 + "checkcast",
25.573 + "instanceof",
25.574 + "monitorenter",
25.575 + "monitorexit",
25.576 + null, // "wide",
25.577 + "multianewarray",
25.578 + "ifnull",
25.579 + "ifnonnull",
25.580 + "goto_w",
25.581 + "jsr_w",
25.582 + "bytecode 202", // "breakpoint",
25.583 + "bytecode",
25.584 + "try",
25.585 + "endtry",
25.586 + "catch",
25.587 + "var",
25.588 + "endvar",
25.589 + "locals_map",
25.590 + "stack_map"
25.591 + };
25.592 +
25.593 + /* Opcode Lengths */
25.594 + public static final int opcLengthsTab[] = {
25.595 + 1,
25.596 + 1,
25.597 + 1,
25.598 + 1,
25.599 + 1,
25.600 + 1,
25.601 + 1,
25.602 + 1,
25.603 + 1,
25.604 + 1,
25.605 + 1,
25.606 + 1,
25.607 + 1,
25.608 + 1,
25.609 + 1,
25.610 + 1,
25.611 + 2,
25.612 + 3,
25.613 + 2,
25.614 + 3,
25.615 + 3,
25.616 + 2,
25.617 + 2,
25.618 + 2,
25.619 + 2,
25.620 + 2,
25.621 + 1,
25.622 + 1,
25.623 + 1,
25.624 + 1,
25.625 + 1,
25.626 + 1,
25.627 + 1,
25.628 + 1,
25.629 + 1,
25.630 + 1,
25.631 + 1,
25.632 + 1,
25.633 + 1,
25.634 + 1,
25.635 + 1,
25.636 + 1,
25.637 + 1,
25.638 + 1,
25.639 + 1,
25.640 + 1,
25.641 + 1,
25.642 + 1,
25.643 + 1,
25.644 + 1,
25.645 + 1,
25.646 + 1,
25.647 + 1,
25.648 + 1,
25.649 + 2,
25.650 + 2,
25.651 + 2,
25.652 + 2,
25.653 + 2,
25.654 + 1,
25.655 + 1,
25.656 + 1,
25.657 + 1,
25.658 + 1,
25.659 + 1,
25.660 + 1,
25.661 + 1,
25.662 + 1,
25.663 + 1,
25.664 + 1,
25.665 + 1,
25.666 + 1,
25.667 + 1,
25.668 + 1,
25.669 + 1,
25.670 + 1,
25.671 + 1,
25.672 + 1,
25.673 + 1,
25.674 + 1,
25.675 + 1,
25.676 + 1,
25.677 + 1,
25.678 + 1,
25.679 + 1,
25.680 + 1,
25.681 + 1,
25.682 + 1,
25.683 + 1,
25.684 + 1,
25.685 + 1,
25.686 + 1,
25.687 + 1,
25.688 + 1,
25.689 + 1,
25.690 + 1,
25.691 + 1,
25.692 + 1,
25.693 + 1,
25.694 + 1,
25.695 + 1,
25.696 + 1,
25.697 + 1,
25.698 + 1,
25.699 + 1,
25.700 + 1,
25.701 + 1,
25.702 + 1,
25.703 + 1,
25.704 + 1,
25.705 + 1,
25.706 + 1,
25.707 + 1,
25.708 + 1,
25.709 + 1,
25.710 + 1,
25.711 + 1,
25.712 + 1,
25.713 + 1,
25.714 + 1,
25.715 + 1,
25.716 + 1,
25.717 + 1,
25.718 + 1,
25.719 + 1,
25.720 + 1,
25.721 + 1,
25.722 + 1,
25.723 + 1,
25.724 + 1,
25.725 + 1,
25.726 + 1,
25.727 + 3,
25.728 + 1,
25.729 + 1,
25.730 + 1,
25.731 + 1,
25.732 + 1,
25.733 + 1,
25.734 + 1,
25.735 + 1,
25.736 + 1,
25.737 + 1,
25.738 + 1,
25.739 + 1,
25.740 + 1,
25.741 + 1,
25.742 + 1,
25.743 + 1,
25.744 + 1,
25.745 + 1,
25.746 + 1,
25.747 + 1,
25.748 + 3,
25.749 + 3,
25.750 + 3,
25.751 + 3,
25.752 + 3,
25.753 + 3,
25.754 + 3,
25.755 + 3,
25.756 + 3,
25.757 + 3,
25.758 + 3,
25.759 + 3,
25.760 + 3,
25.761 + 3,
25.762 + 3,
25.763 + 3,
25.764 + 2,
25.765 + 99,
25.766 + 99,
25.767 + 1,
25.768 + 1,
25.769 + 1,
25.770 + 1,
25.771 + 1,
25.772 + 1,
25.773 + 3,
25.774 + 3,
25.775 + 3,
25.776 + 3,
25.777 + 3,
25.778 + 3,
25.779 + 3,
25.780 + 5,
25.781 + 0,
25.782 + 3,
25.783 + 2,
25.784 + 3,
25.785 + 1,
25.786 + 1,
25.787 + 3,
25.788 + 3,
25.789 + 1,
25.790 + 1,
25.791 + 0, // wide
25.792 + 4,
25.793 + 3,
25.794 + 3,
25.795 + 5,
25.796 + 5,
25.797 + 1,
25.798 + 1, 0, 0, 0, 0, 0 // pseudo
25.799 + };
25.800 +
25.801 + /**
25.802 + * End of input
25.803 + */
25.804 + public static final int EOF = -1;
25.805 +
25.806 + /*
25.807 + * Flags
25.808 + */
25.809 + public static final int F_VERBOSE = 1 << 0;
25.810 + public static final int F_DUMP = 1 << 1;
25.811 + public static final int F_WARNINGS = 1 << 2;
25.812 + public static final int F_DEBUG = 1 << 3;
25.813 + public static final int F_OPTIMIZE = 1 << 4;
25.814 + public static final int F_DEPENDENCIES = 1 << 5;
25.815 +
25.816 + /*
25.817 + * Type codes
25.818 + */
25.819 + public static final int TC_BOOLEAN = 0;
25.820 + public static final int TC_BYTE = 1;
25.821 + public static final int TC_CHAR = 2;
25.822 + public static final int TC_SHORT = 3;
25.823 + public static final int TC_INT = 4;
25.824 + public static final int TC_LONG = 5;
25.825 + public static final int TC_FLOAT = 6;
25.826 + public static final int TC_DOUBLE = 7;
25.827 + public static final int TC_NULL = 8;
25.828 + public static final int TC_ARRAY = 9;
25.829 + public static final int TC_CLASS = 10;
25.830 + public static final int TC_VOID = 11;
25.831 + public static final int TC_METHOD = 12;
25.832 + public static final int TC_ERROR = 13;
25.833 +
25.834 + /*
25.835 + * Type Masks
25.836 + */
25.837 + public static final int TM_NULL = 1 << TC_NULL;
25.838 + public static final int TM_VOID = 1 << TC_VOID;
25.839 + public static final int TM_BOOLEAN = 1 << TC_BOOLEAN;
25.840 + public static final int TM_BYTE = 1 << TC_BYTE;
25.841 + public static final int TM_CHAR = 1 << TC_CHAR;
25.842 + public static final int TM_SHORT = 1 << TC_SHORT;
25.843 + public static final int TM_INT = 1 << TC_INT;
25.844 + public static final int TM_LONG = 1 << TC_LONG;
25.845 + public static final int TM_FLOAT = 1 << TC_FLOAT;
25.846 + public static final int TM_DOUBLE = 1 << TC_DOUBLE;
25.847 + public static final int TM_ARRAY = 1 << TC_ARRAY;
25.848 + public static final int TM_CLASS = 1 << TC_CLASS;
25.849 + public static final int TM_METHOD = 1 << TC_METHOD;
25.850 + public static final int TM_ERROR = 1 << TC_ERROR;
25.851 +
25.852 + public static final int TM_INT32 = TM_BYTE | TM_SHORT | TM_CHAR | TM_INT;
25.853 + public static final int TM_NUM32 = TM_INT32 | TM_FLOAT;
25.854 + public static final int TM_NUM64 = TM_LONG | TM_DOUBLE;
25.855 + public static final int TM_INTEGER = TM_INT32 | TM_LONG;
25.856 + public static final int TM_REAL = TM_FLOAT | TM_DOUBLE;
25.857 + public static final int TM_NUMBER = TM_INTEGER | TM_REAL;
25.858 + public static final int TM_REFERENCE = TM_ARRAY | TM_CLASS | TM_NULL;
25.859 +
25.860 + /*
25.861 + * Class status
25.862 + */
25.863 + public static final int CS_UNDEFINED = 0;
25.864 + public static final int CS_UNDECIDED = 1;
25.865 + public static final int CS_BINARY = 2;
25.866 + public static final int CS_SOURCE = 3;
25.867 + public static final int CS_PARSED = 4;
25.868 + public static final int CS_COMPILED = 5;
25.869 + public static final int CS_NOTFOUND = 6;
25.870 +
25.871 + /*
25.872 + * Attributes
25.873 + */
25.874 + public static final int ATT_ALL = -1;
25.875 + public static final int ATT_CODE = 1;
25.876 +
25.877 + /*
25.878 + * Number of bits used in file offsets
25.879 + */
25.880 + public static final int OFFSETBITS = 19;
25.881 + public static final int MAXFILESIZE = (1 << OFFSETBITS) - 1;
25.882 + public static final int MAXLINENUMBER = (1 << (32 - OFFSETBITS)) - 1;
25.883 +
25.884 + /*
25.885 + * Operators
25.886 + */
25.887 + public final int COMMA = 0;
25.888 + public final int ASSIGN = 1;
25.889 +
25.890 + public final int ASGMUL = 2;
25.891 + public final int ASGDIV = 3;
25.892 + public final int ASGREM = 4;
25.893 + public final int ASGADD = 5;
25.894 + public final int ASGSUB = 6;
25.895 + public final int ASGLSHIFT = 7;
25.896 + public final int ASGRSHIFT = 8;
25.897 + public final int ASGURSHIFT = 9;
25.898 + public final int ASGBITAND = 10;
25.899 + public final int ASGBITOR = 11;
25.900 + public final int ASGBITXOR = 12;
25.901 +
25.902 + public final int COND = 13;
25.903 + public final int OR = 14;
25.904 + public final int AND = 15;
25.905 + public final int BITOR = 16;
25.906 + public final int BITXOR = 17;
25.907 + public final int BITAND = 18;
25.908 + public final int NE = 19;
25.909 + public final int EQ = 20;
25.910 + public final int GE = 21;
25.911 + public final int GT = 22;
25.912 + public final int LE = 23;
25.913 + public final int LT = 24;
25.914 + public final int INSTANCEOF = 25;
25.915 + public final int LSHIFT = 26;
25.916 + public final int RSHIFT = 27;
25.917 + public final int URSHIFT = 28;
25.918 + public final int ADD = 29;
25.919 + public final int SUB = 30;
25.920 + public final int DIV = 31;
25.921 + public final int REM = 32;
25.922 + public final int MUL = 33;
25.923 + public final int CAST = 34; // (x)y
25.924 + public final int POS = 35; // +x
25.925 + public final int NEG = 36; // -x
25.926 + public final int NOT = 37;
25.927 + public final int BITNOT = 38;
25.928 + public final int PREINC = 39; // ++x
25.929 + public final int PREDEC = 40; // --x
25.930 + public final int NEWARRAY = 41;
25.931 + public final int NEWINSTANCE = 42;
25.932 + public final int NEWFROMNAME = 43;
25.933 + public final int POSTINC = 44; // x++
25.934 + public final int POSTDEC = 45; // x--
25.935 + public final int FIELD = 46;
25.936 + public final int METHOD = 47; // x(y)
25.937 + public final int ARRAYACCESS = 48; // x[y]
25.938 + public final int NEW = 49;
25.939 + public final int INC = 50;
25.940 + public final int DEC = 51;
25.941 +
25.942 + public final int CONVERT = 55; // implicit conversion
25.943 + public final int EXPR = 56; // (x)
25.944 + public final int ARRAY = 57; // {x, y, ...}
25.945 + public final int GOTO = 58;
25.946 +
25.947 + /*
25.948 + * Value tokens
25.949 + */
25.950 + public final int IDENT = 60;
25.951 + public final int BOOLEANVAL = 61;
25.952 + public final int BYTEVAL = 62;
25.953 + public final int CHARVAL = 63;
25.954 + public final int SHORTVAL = 64;
25.955 + public final int INTVAL = 65;
25.956 + public final int LONGVAL = 66;
25.957 + public final int FLOATVAL = 67;
25.958 + public final int DOUBLEVAL = 68;
25.959 + public final int STRINGVAL = 69;
25.960 +
25.961 + /*
25.962 + * Type keywords
25.963 + */
25.964 + public final int BYTE = 70;
25.965 + public final int CHAR = 71;
25.966 + public final int SHORT = 72;
25.967 + public final int INT = 73;
25.968 + public final int LONG = 74;
25.969 + public final int FLOAT = 75;
25.970 + public final int DOUBLE = 76;
25.971 + public final int VOID = 77;
25.972 + public final int BOOLEAN = 78;
25.973 +
25.974 + /*
25.975 + * Expression keywords
25.976 + */
25.977 + public final int TRUE = 80;
25.978 + public final int FALSE = 81;
25.979 + public final int THIS = 82;
25.980 + public final int SUPER = 83;
25.981 + public final int NULL = 84;
25.982 +
25.983 + /*
25.984 + * Statement keywords
25.985 + */
25.986 + public final int IF = 90;
25.987 + public final int ELSE = 91;
25.988 + public final int FOR = 92;
25.989 + public final int WHILE = 93;
25.990 + public final int DO = 94;
25.991 + public final int SWITCH = 95;
25.992 + public final int CASE = 96;
25.993 + public final int DEFAULT = 97;
25.994 + public final int BREAK = 98;
25.995 + public final int CONTINUE = 99;
25.996 + public final int RETURN = 100;
25.997 + public final int TRY = 101;
25.998 + public final int CATCH = 102;
25.999 + public final int FINALLY = 103;
25.1000 + public final int THROW = 104;
25.1001 + public final int STAT = 105;
25.1002 + public final int EXPRESSION = 106;
25.1003 + public final int DECLARATION = 107;
25.1004 + public final int VARDECLARATION = 108;
25.1005 +
25.1006 + /*
25.1007 + * Declaration keywords
25.1008 + */
25.1009 + public final int IMPORT = 110;
25.1010 + public final int CLASS = 111;
25.1011 + public final int EXTENDS = 112;
25.1012 + public final int IMPLEMENTS = 113;
25.1013 + public final int INTERFACE = 114;
25.1014 + public final int PACKAGE = 115;
25.1015 +
25.1016 + /*
25.1017 + * Modifier keywords
25.1018 + */
25.1019 + public final int PRIVATE = 120;
25.1020 + public final int PUBLIC = 121;
25.1021 + public final int PROTECTED = 122;
25.1022 + public final int CONST = 123;
25.1023 + public final int STATIC = 124;
25.1024 + public final int TRANSIENT = 125;
25.1025 + public final int SYNCHRONIZED = 126;
25.1026 + public final int NATIVE = 127;
25.1027 + public final int FINAL = 128;
25.1028 + public final int VOLATILE = 129;
25.1029 + public final int ABSTRACT = 130;
25.1030 + public final int STRICT = 165;
25.1031 +
25.1032 + /*
25.1033 + * Punctuation
25.1034 + */
25.1035 + public final int SEMICOLON = 135;
25.1036 + public final int COLON = 136;
25.1037 + public final int QUESTIONMARK = 137;
25.1038 + public final int LBRACE = 138;
25.1039 + public final int RBRACE = 139;
25.1040 + public final int LPAREN = 140;
25.1041 + public final int RPAREN = 141;
25.1042 + public final int LSQBRACKET = 142;
25.1043 + public final int RSQBRACKET = 143;
25.1044 + public final int THROWS = 144;
25.1045 +
25.1046 + /*
25.1047 + * Special tokens
25.1048 + */
25.1049 + public final int ERROR = 145; // an error
25.1050 + public final int COMMENT = 146; // not used anymore.
25.1051 + public final int TYPE = 147;
25.1052 + public final int LENGTH = 148;
25.1053 + public final int INLINERETURN = 149;
25.1054 + public final int INLINEMETHOD = 150;
25.1055 + public final int INLINENEWINSTANCE = 151;
25.1056 +
25.1057 + /*
25.1058 + * Added for jasm
25.1059 + */
25.1060 + public final int METHODREF = 152;
25.1061 + public final int FIELDREF = 153;
25.1062 + public final int STACK = 154;
25.1063 + public final int LOCAL = 155;
25.1064 + public final int CPINDEX = 156;
25.1065 + public final int CPNAME = 157;
25.1066 + public final int SIGN = 158;
25.1067 + public final int BITS = 159;
25.1068 + public final int INF = 160;
25.1069 + public final int NAN = 161;
25.1070 + public final int INNERCLASS = 162;
25.1071 + public final int OF = 163;
25.1072 + public final int SYNTHETIC = 164;
25.1073 +// last used=165;
25.1074 +
25.1075 + /*
25.1076 + * Operator precedence
25.1077 + */
25.1078 + public static final int opPrecedence[] = {
25.1079 + 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
25.1080 + 11, 11, 11, 12, 13, 14, 15, 16, 17, 18,
25.1081 + 18, 19, 19, 19, 19, 19, 20, 20, 20, 21,
25.1082 + 21, 22, 22, 22, 23, 24, 24, 24, 24, 24,
25.1083 + 24, 25, 25, 26, 26, 26, 26, 26, 26
25.1084 + };
25.1085 +
25.1086 + /*
25.1087 + * Operator names
25.1088 + */
25.1089 + public static final String opNames[] = {
25.1090 + ",", "=", "*=", "/=", "%=",
25.1091 + "+=", "-=", "<<=", ">>=", "<<<=",
25.1092 + "&=", "|=", "^=", "?:", "||",
25.1093 + "&&", "|", "^", "&", "!=",
25.1094 + "==", ">=", ">", "<=", "<",
25.1095 + "instanceof", "<<", ">>", "<<<", "+",
25.1096 + "-", "/", "%", "*", "cast",
25.1097 + "+", "-", "!", "~", "++",
25.1098 + "--", "new", "new", "new", "++",
25.1099 + "--", "field", "method", "[]", "new",
25.1100 + "++", "--", null, null, null,
25.1101 +
25.1102 + "convert", "expr", "array", "goto", null,
25.1103 +
25.1104 + "Identifier", "Boolean", "Byte", "Char", "Short",
25.1105 + "Integer", "Long", "Float", "Double", "String",
25.1106 +
25.1107 + "byte", "char", "short", "int", "long",
25.1108 + "float", "double", "void", "boolean", null,
25.1109 +
25.1110 + "true", "false", "this", "super", "null",
25.1111 + null, null, null, null, null,
25.1112 +
25.1113 + "if", "else", "for", "while", "do",
25.1114 + "switch", "case", "default", "break", "continue",
25.1115 + "return", "try", "catch", "finally", "throw",
25.1116 + "stat", "expression", "declaration", "declaration", null,
25.1117 +
25.1118 + "import", "class", "extends", "implements", "interface",
25.1119 + "package", null, null, null, null,
25.1120 +
25.1121 + "private", "public", "protected", "const", "static",
25.1122 + "transient", "synchronized", "native", "final", "volatile",
25.1123 + "abstract", null, null, null, null,
25.1124 +
25.1125 + ";", ":", "?", "{", "}",
25.1126 + "(", ")", "[", "]", "throws",
25.1127 + "error", "comment", "type", "length", "inline-return",
25.1128 + "inline-method", "inline-new",
25.1129 + "method", "field", "stack", "locals", "CPINDEX", "CPName", "SIGN",
25.1130 + "bits", "INF", "NaN", "InnerClass", "of", "synthetic"
25.1131 + };
25.1132 +
25.1133 + static class AnnotationParser {
25.1134 +
25.1135 + private final boolean textual;
25.1136 + private final boolean iterateArray;
25.1137 +
25.1138 + protected AnnotationParser(boolean textual, boolean iterateArray) {
25.1139 + this.textual = textual;
25.1140 + this.iterateArray = iterateArray;
25.1141 + }
25.1142 +
25.1143 + protected void visitAnnotationStart(String type, boolean top) throws IOException {
25.1144 + }
25.1145 +
25.1146 + protected void visitAnnotationEnd(String type, boolean top) throws IOException {
25.1147 + }
25.1148 +
25.1149 + protected void visitValueStart(String attrName, char type) throws IOException {
25.1150 + }
25.1151 +
25.1152 + protected void visitValueEnd(String attrName, char type) throws IOException {
25.1153 + }
25.1154 +
25.1155 + protected void visitAttr(
25.1156 + String annoType, String attr, String attrType, String value) throws IOException {
25.1157 + }
25.1158 +
25.1159 + protected void visitEnumAttr(
25.1160 + String annoType, String attr, String attrType, String value) throws IOException {
25.1161 + visitAttr(annoType, attr, attrType, value);
25.1162 + }
25.1163 +
25.1164 + /**
25.1165 + * Initialize the parsing with constant pool from
25.1166 + * <code>cd</code>.
25.1167 + *
25.1168 + * @param attr the attribute defining annotations
25.1169 + * @param cd constant pool
25.1170 + * @throws IOException in case I/O fails
25.1171 + */
25.1172 + public final void parse(byte[] attr, ClassData cd) throws IOException {
25.1173 + ByteArrayInputStream is = new ByteArrayInputStream(attr);
25.1174 + DataInputStream dis = new DataInputStream(is);
25.1175 + try {
25.1176 + read(dis, cd);
25.1177 + } finally {
25.1178 + is.close();
25.1179 + }
25.1180 + }
25.1181 +
25.1182 + private void read(DataInputStream dis, ClassData cd) throws IOException {
25.1183 + int cnt = dis.readUnsignedShort();
25.1184 + for (int i = 0; i < cnt; i++) {
25.1185 + readAnno(dis, cd, true);
25.1186 + }
25.1187 + }
25.1188 +
25.1189 + private void readAnno(DataInputStream dis, ClassData cd, boolean top) throws IOException {
25.1190 + int type = dis.readUnsignedShort();
25.1191 + String typeName = cd.StringValue(type);
25.1192 + visitAnnotationStart(typeName, top);
25.1193 + int cnt = dis.readUnsignedShort();
25.1194 + for (int i = 0; i < cnt; i++) {
25.1195 + String attrName = cd.StringValue(dis.readUnsignedShort());
25.1196 + readValue(dis, cd, typeName, attrName);
25.1197 + }
25.1198 + visitAnnotationEnd(typeName, top);
25.1199 + if (cnt == 0) {
25.1200 + visitAttr(typeName, null, null, null);
25.1201 + }
25.1202 + }
25.1203 +
25.1204 + private void readValue(
25.1205 + DataInputStream dis, ClassData cd, String typeName, String attrName) throws IOException {
25.1206 + char type = (char) dis.readByte();
25.1207 + visitValueStart(attrName, type);
25.1208 + if (type == '@') {
25.1209 + readAnno(dis, cd, false);
25.1210 + } else if ("CFJZsSIDB".indexOf(type) >= 0) { // NOI18N
25.1211 + int primitive = dis.readUnsignedShort();
25.1212 + String val = cd.stringValue(primitive, textual);
25.1213 + String attrType;
25.1214 + if (type == 's') {
25.1215 + attrType = "Ljava_lang_String_2";
25.1216 + if (textual) {
25.1217 + val = '"' + val + '"';
25.1218 + }
25.1219 + } else {
25.1220 + attrType = "" + type;
25.1221 + }
25.1222 + visitAttr(typeName, attrName, attrType, val);
25.1223 + } else if (type == 'c') {
25.1224 + int cls = dis.readUnsignedShort();
25.1225 + } else if (type == '[') {
25.1226 + int cnt = dis.readUnsignedShort();
25.1227 + for (int i = 0; i < cnt; i++) {
25.1228 + readValue(dis, cd, typeName, iterateArray ? attrName : null);
25.1229 + }
25.1230 + } else if (type == 'e') {
25.1231 + int enumT = dis.readUnsignedShort();
25.1232 + String attrType = cd.stringValue(enumT, textual);
25.1233 + int enumN = dis.readUnsignedShort();
25.1234 + String val = cd.stringValue(enumN, textual);
25.1235 + visitEnumAttr(typeName, attrName, attrType, val);
25.1236 + } else {
25.1237 + throw new IOException("Unknown type " + type);
25.1238 + }
25.1239 + visitValueEnd(attrName, type);
25.1240 + }
25.1241 + }
25.1242 +
25.1243 + /**
25.1244 + * Reads and stores attribute information.
25.1245 + *
25.1246 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.1247 + */
25.1248 + private static class AttrData {
25.1249 +
25.1250 + ClassData cls;
25.1251 + int name_cpx;
25.1252 + int datalen;
25.1253 + byte data[];
25.1254 +
25.1255 + public AttrData(ClassData cls) {
25.1256 + this.cls = cls;
25.1257 + }
25.1258 +
25.1259 + /**
25.1260 + * Reads unknown attribute.
25.1261 + */
25.1262 + public void read(int name_cpx, DataInputStream in) throws IOException {
25.1263 + this.name_cpx = name_cpx;
25.1264 + datalen = in.readInt();
25.1265 + data = new byte[datalen];
25.1266 + in.readFully(data);
25.1267 + }
25.1268 +
25.1269 + /**
25.1270 + * Reads just the name of known attribute.
25.1271 + */
25.1272 + public void read(int name_cpx) {
25.1273 + this.name_cpx = name_cpx;
25.1274 + }
25.1275 +
25.1276 + /**
25.1277 + * Returns attribute name.
25.1278 + */
25.1279 + public String getAttrName() {
25.1280 + return cls.getString(name_cpx);
25.1281 + }
25.1282 +
25.1283 + /**
25.1284 + * Returns attribute data.
25.1285 + */
25.1286 + public byte[] getData() {
25.1287 + return data;
25.1288 + }
25.1289 + }
25.1290 +
25.1291 + /**
25.1292 + * Stores constant pool entry information with one field.
25.1293 + *
25.1294 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.1295 + */
25.1296 + private static class CPX {
25.1297 +
25.1298 + int cpx;
25.1299 +
25.1300 + CPX(int cpx) {
25.1301 + this.cpx = cpx;
25.1302 + }
25.1303 + }
25.1304 +
25.1305 + /**
25.1306 + * Stores constant pool entry information with two fields.
25.1307 + *
25.1308 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.1309 + */
25.1310 + private static class CPX2 {
25.1311 +
25.1312 + int cpx1, cpx2;
25.1313 +
25.1314 + CPX2(int cpx1, int cpx2) {
25.1315 + this.cpx1 = cpx1;
25.1316 + this.cpx2 = cpx2;
25.1317 + }
25.1318 + }
25.1319 +
25.1320 + /**
25.1321 + * Central data repository of the Java Disassembler. Stores all the
25.1322 + * information in java class file.
25.1323 + *
25.1324 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.1325 + */
25.1326 + static final class ClassData {
25.1327 +
25.1328 + private int magic;
25.1329 + private int minor_version;
25.1330 + private int major_version;
25.1331 + private int cpool_count;
25.1332 + private Object cpool[];
25.1333 + private int access;
25.1334 + private int this_class = 0;
25.1335 + private int super_class;
25.1336 + private int interfaces_count;
25.1337 + private int[] interfaces = new int[0];
25.1338 + private int fields_count;
25.1339 + private FieldData[] fields;
25.1340 + private int methods_count;
25.1341 + private MethodData[] methods;
25.1342 + private InnerClassData[] innerClasses;
25.1343 + private int attributes_count;
25.1344 + private AttrData[] attrs;
25.1345 + private String classname;
25.1346 + private String superclassname;
25.1347 + private int source_cpx = 0;
25.1348 + private byte tags[];
25.1349 + private Hashtable indexHashAscii = new Hashtable();
25.1350 + private String pkgPrefix = "";
25.1351 + private int pkgPrefixLen = 0;
25.1352 +
25.1353 + /**
25.1354 + * Read classfile to disassemble.
25.1355 + */
25.1356 + public ClassData(InputStream infile) throws IOException {
25.1357 + this.read(new DataInputStream(infile));
25.1358 + }
25.1359 +
25.1360 + /**
25.1361 + * Reads and stores class file information.
25.1362 + */
25.1363 + public void read(DataInputStream in) throws IOException {
25.1364 + // Read the header
25.1365 + magic = in.readInt();
25.1366 + if (magic != JAVA_MAGIC) {
25.1367 + throw new ClassFormatError("wrong magic: "
25.1368 + + toHex(magic) + ", expected "
25.1369 + + toHex(JAVA_MAGIC));
25.1370 + }
25.1371 + minor_version = in.readShort();
25.1372 + major_version = in.readShort();
25.1373 + if (major_version != JAVA_VERSION) {
25.1374 + }
25.1375 +
25.1376 + // Read the constant pool
25.1377 + readCP(in);
25.1378 + access = in.readUnsignedShort();
25.1379 + this_class = in.readUnsignedShort();
25.1380 + super_class = in.readUnsignedShort();
25.1381 +
25.1382 + //Read interfaces.
25.1383 + interfaces_count = in.readUnsignedShort();
25.1384 + if (interfaces_count > 0) {
25.1385 + interfaces = new int[interfaces_count];
25.1386 + }
25.1387 + for (int i = 0; i < interfaces_count; i++) {
25.1388 + interfaces[i] = in.readShort();
25.1389 + }
25.1390 +
25.1391 + // Read the fields
25.1392 + readFields(in);
25.1393 +
25.1394 + // Read the methods
25.1395 + readMethods(in);
25.1396 +
25.1397 + // Read the attributes
25.1398 + attributes_count = in.readUnsignedShort();
25.1399 + attrs = new AttrData[attributes_count];
25.1400 + for (int k = 0; k < attributes_count; k++) {
25.1401 + int name_cpx = in.readUnsignedShort();
25.1402 + if (getTag(name_cpx) == CONSTANT_UTF8
25.1403 + && getString(name_cpx).equals("SourceFile")) {
25.1404 + if (in.readInt() != 2) {
25.1405 + throw new ClassFormatError("invalid attr length");
25.1406 + }
25.1407 + source_cpx = in.readUnsignedShort();
25.1408 + AttrData attr = new AttrData(this);
25.1409 + attr.read(name_cpx);
25.1410 + attrs[k] = attr;
25.1411 +
25.1412 + } else if (getTag(name_cpx) == CONSTANT_UTF8
25.1413 + && getString(name_cpx).equals("InnerClasses")) {
25.1414 + int length = in.readInt();
25.1415 + int num = in.readUnsignedShort();
25.1416 + if (2 + num * 8 != length) {
25.1417 + throw new ClassFormatError("invalid attr length");
25.1418 + }
25.1419 + innerClasses = new InnerClassData[num];
25.1420 + for (int j = 0; j < num; j++) {
25.1421 + InnerClassData innerClass = new InnerClassData(this);
25.1422 + innerClass.read(in);
25.1423 + innerClasses[j] = innerClass;
25.1424 + }
25.1425 + AttrData attr = new AttrData(this);
25.1426 + attr.read(name_cpx);
25.1427 + attrs[k] = attr;
25.1428 + } else {
25.1429 + AttrData attr = new AttrData(this);
25.1430 + attr.read(name_cpx, in);
25.1431 + attrs[k] = attr;
25.1432 + }
25.1433 + }
25.1434 + in.close();
25.1435 + } // end ClassData.read()
25.1436 +
25.1437 + /**
25.1438 + * Reads and stores constant pool info.
25.1439 + */
25.1440 + void readCP(DataInputStream in) throws IOException {
25.1441 + cpool_count = in.readUnsignedShort();
25.1442 + tags = new byte[cpool_count];
25.1443 + cpool = new Object[cpool_count];
25.1444 + for (int i = 1; i < cpool_count; i++) {
25.1445 + byte tag = in.readByte();
25.1446 +
25.1447 + switch (tags[i] = tag) {
25.1448 + case CONSTANT_UTF8:
25.1449 + String str = in.readUTF();
25.1450 + indexHashAscii.put(cpool[i] = str, new Integer(i));
25.1451 + break;
25.1452 + case CONSTANT_INTEGER:
25.1453 + cpool[i] = new Integer(in.readInt());
25.1454 + break;
25.1455 + case CONSTANT_FLOAT:
25.1456 + cpool[i] = new Float(in.readFloat());
25.1457 + break;
25.1458 + case CONSTANT_LONG:
25.1459 + cpool[i++] = new Long(in.readLong());
25.1460 + break;
25.1461 + case CONSTANT_DOUBLE:
25.1462 + cpool[i++] = new Double(in.readDouble());
25.1463 + break;
25.1464 + case CONSTANT_CLASS:
25.1465 + case CONSTANT_STRING:
25.1466 + cpool[i] = new CPX(in.readUnsignedShort());
25.1467 + break;
25.1468 +
25.1469 + case CONSTANT_FIELD:
25.1470 + case CONSTANT_METHOD:
25.1471 + case CONSTANT_INTERFACEMETHOD:
25.1472 + case CONSTANT_NAMEANDTYPE:
25.1473 + cpool[i] = new CPX2(in.readUnsignedShort(), in.readUnsignedShort());
25.1474 + break;
25.1475 +
25.1476 + case 0:
25.1477 + default:
25.1478 + throw new ClassFormatError("invalid constant type: " + (int) tags[i]);
25.1479 + }
25.1480 + }
25.1481 + }
25.1482 +
25.1483 + /**
25.1484 + * Reads and strores field info.
25.1485 + */
25.1486 + protected void readFields(DataInputStream in) throws IOException {
25.1487 + int fields_count = in.readUnsignedShort();
25.1488 + fields = new FieldData[fields_count];
25.1489 + for (int k = 0; k < fields_count; k++) {
25.1490 + FieldData field = new FieldData(this);
25.1491 + field.read(in);
25.1492 + fields[k] = field;
25.1493 + }
25.1494 + }
25.1495 +
25.1496 + /**
25.1497 + * Reads and strores Method info.
25.1498 + */
25.1499 + protected void readMethods(DataInputStream in) throws IOException {
25.1500 + int methods_count = in.readUnsignedShort();
25.1501 + methods = new MethodData[methods_count];
25.1502 + for (int k = 0; k < methods_count; k++) {
25.1503 + MethodData method = new MethodData(this);
25.1504 + method.read(in);
25.1505 + methods[k] = method;
25.1506 + }
25.1507 + }
25.1508 +
25.1509 + /**
25.1510 + * get a string
25.1511 + */
25.1512 + public String getString(int n) {
25.1513 + if (n == 0) {
25.1514 + return null;
25.1515 + } else {
25.1516 + return (String) cpool[n];
25.1517 + }
25.1518 + }
25.1519 +
25.1520 + /**
25.1521 + * get the type of constant given an index
25.1522 + */
25.1523 + public byte getTag(int n) {
25.1524 + try {
25.1525 + return tags[n];
25.1526 + } catch (ArrayIndexOutOfBoundsException e) {
25.1527 + return (byte) 100;
25.1528 + }
25.1529 + }
25.1530 + static final String hexString = "0123456789ABCDEF";
25.1531 + public static char hexTable[] = hexString.toCharArray();
25.1532 +
25.1533 + static String toHex(long val, int width) {
25.1534 + StringBuffer s = new StringBuffer();
25.1535 + for (int i = width - 1; i >= 0; i--) {
25.1536 + s.append(hexTable[((int) (val >> (4 * i))) & 0xF]);
25.1537 + }
25.1538 + return "0x" + s.toString();
25.1539 + }
25.1540 +
25.1541 + static String toHex(long val) {
25.1542 + int width;
25.1543 + for (width = 16; width > 0; width--) {
25.1544 + if ((val >> (width - 1) * 4) != 0) {
25.1545 + break;
25.1546 + }
25.1547 + }
25.1548 + return toHex(val, width);
25.1549 + }
25.1550 +
25.1551 + static String toHex(int val) {
25.1552 + int width;
25.1553 + for (width = 8; width > 0; width--) {
25.1554 + if ((val >> (width - 1) * 4) != 0) {
25.1555 + break;
25.1556 + }
25.1557 + }
25.1558 + return toHex(val, width);
25.1559 + }
25.1560 +
25.1561 + /**
25.1562 + * Returns the name of this class.
25.1563 + */
25.1564 + public String getClassName() {
25.1565 + String res = null;
25.1566 + if (this_class == 0) {
25.1567 + return res;
25.1568 + }
25.1569 + int tcpx;
25.1570 + try {
25.1571 + if (tags[this_class] != CONSTANT_CLASS) {
25.1572 + return res; //"<CP["+cpx+"] is not a Class> ";
25.1573 + }
25.1574 + tcpx = ((CPX) cpool[this_class]).cpx;
25.1575 + } catch (ArrayIndexOutOfBoundsException e) {
25.1576 + return res; // "#"+cpx+"// invalid constant pool index";
25.1577 + } catch (Throwable e) {
25.1578 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
25.1579 + }
25.1580 +
25.1581 + try {
25.1582 + return (String) (cpool[tcpx]);
25.1583 + } catch (ArrayIndexOutOfBoundsException e) {
25.1584 + return res; // "class #"+scpx+"// invalid constant pool index";
25.1585 + } catch (ClassCastException e) {
25.1586 + return res; // "class #"+scpx+"// invalid constant pool reference";
25.1587 + } catch (Throwable e) {
25.1588 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
25.1589 + }
25.1590 +
25.1591 + }
25.1592 +
25.1593 + /**
25.1594 + * Returns the name of class at perticular index.
25.1595 + */
25.1596 + public String getClassName(int cpx) {
25.1597 + String res = "#" + cpx;
25.1598 + if (cpx == 0) {
25.1599 + return res;
25.1600 + }
25.1601 + int scpx;
25.1602 + try {
25.1603 + if (tags[cpx] != CONSTANT_CLASS) {
25.1604 + return res; //"<CP["+cpx+"] is not a Class> ";
25.1605 + }
25.1606 + scpx = ((CPX) cpool[cpx]).cpx;
25.1607 + } catch (ArrayIndexOutOfBoundsException e) {
25.1608 + return res; // "#"+cpx+"// invalid constant pool index";
25.1609 + } catch (Throwable e) {
25.1610 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
25.1611 + }
25.1612 + res = "#" + scpx;
25.1613 + try {
25.1614 + return (String) (cpool[scpx]);
25.1615 + } catch (ArrayIndexOutOfBoundsException e) {
25.1616 + return res; // "class #"+scpx+"// invalid constant pool index";
25.1617 + } catch (ClassCastException e) {
25.1618 + return res; // "class #"+scpx+"// invalid constant pool reference";
25.1619 + } catch (Throwable e) {
25.1620 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
25.1621 + }
25.1622 + }
25.1623 +
25.1624 + public int getAccessFlags() {
25.1625 + return access;
25.1626 + }
25.1627 +
25.1628 + /**
25.1629 + * Returns true if it is a class
25.1630 + */
25.1631 + public boolean isClass() {
25.1632 + if ((access & ACC_INTERFACE) == 0) {
25.1633 + return true;
25.1634 + }
25.1635 + return false;
25.1636 + }
25.1637 +
25.1638 + /**
25.1639 + * Returns true if it is a interface.
25.1640 + */
25.1641 + public boolean isInterface() {
25.1642 + if ((access & ACC_INTERFACE) != 0) {
25.1643 + return true;
25.1644 + }
25.1645 + return false;
25.1646 + }
25.1647 +
25.1648 + /**
25.1649 + * Returns true if this member is public, false otherwise.
25.1650 + */
25.1651 + public boolean isPublic() {
25.1652 + return (access & ACC_PUBLIC) != 0;
25.1653 + }
25.1654 +
25.1655 + /**
25.1656 + * Returns the access of this class or interface.
25.1657 + */
25.1658 + public String[] getAccess() {
25.1659 + Vector v = new Vector();
25.1660 + if ((access & ACC_PUBLIC) != 0) {
25.1661 + v.addElement("public");
25.1662 + }
25.1663 + if ((access & ACC_FINAL) != 0) {
25.1664 + v.addElement("final");
25.1665 + }
25.1666 + if ((access & ACC_ABSTRACT) != 0) {
25.1667 + v.addElement("abstract");
25.1668 + }
25.1669 + String[] accflags = new String[v.size()];
25.1670 + v.copyInto(accflags);
25.1671 + return accflags;
25.1672 + }
25.1673 +
25.1674 + /**
25.1675 + * Returns list of innerclasses.
25.1676 + */
25.1677 + public InnerClassData[] getInnerClasses() {
25.1678 + return innerClasses;
25.1679 + }
25.1680 +
25.1681 + /**
25.1682 + * Returns list of attributes.
25.1683 + */
25.1684 + final AttrData[] getAttributes() {
25.1685 + return attrs;
25.1686 + }
25.1687 +
25.1688 + public byte[] findAnnotationData(boolean classRetention) {
25.1689 + String n = classRetention
25.1690 + ? "RuntimeInvisibleAnnotations" : // NOI18N
25.1691 + "RuntimeVisibleAnnotations"; // NOI18N
25.1692 + return findAttr(n, attrs);
25.1693 + }
25.1694 +
25.1695 + /**
25.1696 + * Returns true if superbit is set.
25.1697 + */
25.1698 + public boolean isSuperSet() {
25.1699 + if ((access & ACC_SUPER) != 0) {
25.1700 + return true;
25.1701 + }
25.1702 + return false;
25.1703 + }
25.1704 +
25.1705 + /**
25.1706 + * Returns super class name.
25.1707 + */
25.1708 + public String getSuperClassName() {
25.1709 + String res = null;
25.1710 + if (super_class == 0) {
25.1711 + return res;
25.1712 + }
25.1713 + int scpx;
25.1714 + try {
25.1715 + if (tags[super_class] != CONSTANT_CLASS) {
25.1716 + return res; //"<CP["+cpx+"] is not a Class> ";
25.1717 + }
25.1718 + scpx = ((CPX) cpool[super_class]).cpx;
25.1719 + } catch (ArrayIndexOutOfBoundsException e) {
25.1720 + return res; // "#"+cpx+"// invalid constant pool index";
25.1721 + } catch (Throwable e) {
25.1722 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
25.1723 + }
25.1724 +
25.1725 + try {
25.1726 + return (String) (cpool[scpx]);
25.1727 + } catch (ArrayIndexOutOfBoundsException e) {
25.1728 + return res; // "class #"+scpx+"// invalid constant pool index";
25.1729 + } catch (ClassCastException e) {
25.1730 + return res; // "class #"+scpx+"// invalid constant pool reference";
25.1731 + } catch (Throwable e) {
25.1732 + return res; // "#"+cpx+"// ERROR IN DISASSEMBLER";
25.1733 + }
25.1734 + }
25.1735 +
25.1736 + /**
25.1737 + * Returns list of super interfaces.
25.1738 + */
25.1739 + public String[] getSuperInterfaces() {
25.1740 + String interfacenames[] = new String[interfaces.length];
25.1741 + int interfacecpx = -1;
25.1742 + for (int i = 0; i < interfaces.length; i++) {
25.1743 + interfacecpx = ((CPX) cpool[interfaces[i]]).cpx;
25.1744 + interfacenames[i] = (String) (cpool[interfacecpx]);
25.1745 + }
25.1746 + return interfacenames;
25.1747 + }
25.1748 +
25.1749 + /**
25.1750 + * Returns string at prticular constant pool index.
25.1751 + */
25.1752 + public String getStringValue(int cpoolx) {
25.1753 + try {
25.1754 + return ((String) cpool[cpoolx]);
25.1755 + } catch (ArrayIndexOutOfBoundsException e) {
25.1756 + return "//invalid constant pool index:" + cpoolx;
25.1757 + } catch (ClassCastException e) {
25.1758 + return "//invalid constant pool ref:" + cpoolx;
25.1759 + }
25.1760 + }
25.1761 +
25.1762 + /**
25.1763 + * Returns list of field info.
25.1764 + */
25.1765 + public FieldData[] getFields() {
25.1766 + return fields;
25.1767 + }
25.1768 +
25.1769 + /**
25.1770 + * Returns list of method info.
25.1771 + */
25.1772 + public MethodData[] getMethods() {
25.1773 + return methods;
25.1774 + }
25.1775 +
25.1776 + /**
25.1777 + * Returns constant pool entry at that index.
25.1778 + */
25.1779 + public CPX2 getCpoolEntry(int cpx) {
25.1780 + return ((CPX2) (cpool[cpx]));
25.1781 + }
25.1782 +
25.1783 + public Object getCpoolEntryobj(int cpx) {
25.1784 + return (cpool[cpx]);
25.1785 + }
25.1786 +
25.1787 + /**
25.1788 + * Returns index of this class.
25.1789 + */
25.1790 + public int getthis_cpx() {
25.1791 + return this_class;
25.1792 + }
25.1793 +
25.1794 + /**
25.1795 + * Returns string at that index.
25.1796 + */
25.1797 + public String StringValue(int cpx) {
25.1798 + return stringValue(cpx, false);
25.1799 + }
25.1800 +
25.1801 + public String stringValue(int cpx, boolean textual) {
25.1802 + return stringValue(cpx, textual, null);
25.1803 + }
25.1804 +
25.1805 + public String stringValue(int cpx, String[] classRefs) {
25.1806 + return stringValue(cpx, true, classRefs);
25.1807 + }
25.1808 +
25.1809 + private String stringValue(int cpx, boolean textual, String[] refs) {
25.1810 + if (cpx == 0) {
25.1811 + return "#0";
25.1812 + }
25.1813 + int tag;
25.1814 + Object x;
25.1815 + String suffix = "";
25.1816 + try {
25.1817 + tag = tags[cpx];
25.1818 + x = cpool[cpx];
25.1819 + } catch (IndexOutOfBoundsException e) {
25.1820 + return "<Incorrect CP index:" + cpx + ">";
25.1821 + }
25.1822 +
25.1823 + if (x == null) {
25.1824 + return "<NULL>";
25.1825 + }
25.1826 + switch (tag) {
25.1827 + case CONSTANT_UTF8: {
25.1828 + if (!textual) {
25.1829 + return (String) x;
25.1830 + }
25.1831 + StringBuilder sb = new StringBuilder();
25.1832 + String s = (String) x;
25.1833 + for (int k = 0; k < s.length(); k++) {
25.1834 + char c = s.charAt(k);
25.1835 + switch (c) {
25.1836 + case '\\':
25.1837 + sb.append('\\').append('\\');
25.1838 + break;
25.1839 + case '\t':
25.1840 + sb.append('\\').append('t');
25.1841 + break;
25.1842 + case '\n':
25.1843 + sb.append('\\').append('n');
25.1844 + break;
25.1845 + case '\r':
25.1846 + sb.append('\\').append('r');
25.1847 + break;
25.1848 + case '\"':
25.1849 + sb.append('\\').append('\"');
25.1850 + break;
25.1851 + default:
25.1852 + sb.append(c);
25.1853 + }
25.1854 + }
25.1855 + return sb.toString();
25.1856 + }
25.1857 + case CONSTANT_DOUBLE: {
25.1858 + Double d = (Double) x;
25.1859 + String sd = d.toString();
25.1860 + if (textual) {
25.1861 + return sd;
25.1862 + }
25.1863 + return sd + "d";
25.1864 + }
25.1865 + case CONSTANT_FLOAT: {
25.1866 + Float f = (Float) x;
25.1867 + String sf = (f).toString();
25.1868 + if (textual) {
25.1869 + return sf;
25.1870 + }
25.1871 + return sf + "f";
25.1872 + }
25.1873 + case CONSTANT_LONG: {
25.1874 + Long ln = (Long) x;
25.1875 + if (textual) {
25.1876 + return ln.toString();
25.1877 + }
25.1878 + return ln.toString() + 'l';
25.1879 + }
25.1880 + case CONSTANT_INTEGER: {
25.1881 + Integer in = (Integer) x;
25.1882 + return in.toString();
25.1883 + }
25.1884 + case CONSTANT_CLASS:
25.1885 + String jn = getClassName(cpx);
25.1886 + if (textual) {
25.1887 + if (refs != null) {
25.1888 + refs[0] = jn;
25.1889 + }
25.1890 + return jn;
25.1891 + }
25.1892 + return javaName(jn);
25.1893 + case CONSTANT_STRING:
25.1894 + String sv = stringValue(((CPX) x).cpx, textual);
25.1895 + if (textual) {
25.1896 + return '"' + sv + '"';
25.1897 + } else {
25.1898 + return sv;
25.1899 + }
25.1900 + case CONSTANT_FIELD:
25.1901 + case CONSTANT_METHOD:
25.1902 + case CONSTANT_INTERFACEMETHOD:
25.1903 + //return getShortClassName(((CPX2)x).cpx1)+"."+StringValue(((CPX2)x).cpx2);
25.1904 + return javaName(getClassName(((CPX2) x).cpx1)) + "." + StringValue(((CPX2) x).cpx2);
25.1905 +
25.1906 + case CONSTANT_NAMEANDTYPE:
25.1907 + return getName(((CPX2) x).cpx1) + ":" + StringValue(((CPX2) x).cpx2);
25.1908 + default:
25.1909 + return "UnknownTag"; //TBD
25.1910 + }
25.1911 + }
25.1912 +
25.1913 + /**
25.1914 + * Returns resolved java type name.
25.1915 + */
25.1916 + public String javaName(String name) {
25.1917 + if (name == null) {
25.1918 + return "null";
25.1919 + }
25.1920 + int len = name.length();
25.1921 + if (len == 0) {
25.1922 + return "\"\"";
25.1923 + }
25.1924 + int cc = '/';
25.1925 + fullname:
25.1926 + { // xxx/yyy/zzz
25.1927 + int cp;
25.1928 + for (int k = 0; k < len; k += Character.charCount(cp)) {
25.1929 + cp = name.codePointAt(k);
25.1930 + if (cc == '/') {
25.1931 + if (!isJavaIdentifierStart(cp)) {
25.1932 + break fullname;
25.1933 + }
25.1934 + } else if (cp != '/') {
25.1935 + if (!isJavaIdentifierPart(cp)) {
25.1936 + break fullname;
25.1937 + }
25.1938 + }
25.1939 + cc = cp;
25.1940 + }
25.1941 + return name;
25.1942 + }
25.1943 + return "\"" + name + "\"";
25.1944 + }
25.1945 +
25.1946 + public String getName(int cpx) {
25.1947 + String res;
25.1948 + try {
25.1949 + return javaName((String) cpool[cpx]); //.replace('/','.');
25.1950 + } catch (ArrayIndexOutOfBoundsException e) {
25.1951 + return "<invalid constant pool index:" + cpx + ">";
25.1952 + } catch (ClassCastException e) {
25.1953 + return "<invalid constant pool ref:" + cpx + ">";
25.1954 + }
25.1955 + }
25.1956 +
25.1957 + /**
25.1958 + * Returns unqualified class name.
25.1959 + */
25.1960 + public String getShortClassName(int cpx) {
25.1961 + String classname = javaName(getClassName(cpx));
25.1962 + pkgPrefixLen = classname.lastIndexOf("/") + 1;
25.1963 + if (pkgPrefixLen != 0) {
25.1964 + pkgPrefix = classname.substring(0, pkgPrefixLen);
25.1965 + if (classname.startsWith(pkgPrefix)) {
25.1966 + return classname.substring(pkgPrefixLen);
25.1967 + }
25.1968 + }
25.1969 + return classname;
25.1970 + }
25.1971 +
25.1972 + /**
25.1973 + * Returns source file name.
25.1974 + */
25.1975 + public String getSourceName() {
25.1976 + return getName(source_cpx);
25.1977 + }
25.1978 +
25.1979 + /**
25.1980 + * Returns package name.
25.1981 + */
25.1982 + public String getPkgName() {
25.1983 + String classname = getClassName(this_class);
25.1984 + pkgPrefixLen = classname.lastIndexOf("/") + 1;
25.1985 + if (pkgPrefixLen != 0) {
25.1986 + pkgPrefix = classname.substring(0, pkgPrefixLen);
25.1987 + return ("package " + pkgPrefix.substring(0, pkgPrefixLen - 1) + ";\n");
25.1988 + } else {
25.1989 + return null;
25.1990 + }
25.1991 + }
25.1992 +
25.1993 + /**
25.1994 + * Returns total constant pool entry count.
25.1995 + */
25.1996 + public int getCpoolCount() {
25.1997 + return cpool_count;
25.1998 + }
25.1999 +
25.2000 + /**
25.2001 + * Returns minor version of class file.
25.2002 + */
25.2003 + public int getMinor_version() {
25.2004 + return minor_version;
25.2005 + }
25.2006 +
25.2007 + /**
25.2008 + * Returns major version of class file.
25.2009 + */
25.2010 + public int getMajor_version() {
25.2011 + return major_version;
25.2012 + }
25.2013 +
25.2014 + private boolean isJavaIdentifierStart(int cp) {
25.2015 + return ('a' <= cp && cp <= 'z') || ('A' <= cp && cp <= 'Z');
25.2016 + }
25.2017 +
25.2018 + private boolean isJavaIdentifierPart(int cp) {
25.2019 + return isJavaIdentifierStart(cp) || ('0' <= cp && cp <= '9');
25.2020 + }
25.2021 +
25.2022 + public String[] getNameAndType(int indx) {
25.2023 + return getNameAndType(indx, 0, new String[2]);
25.2024 + }
25.2025 +
25.2026 + private String[] getNameAndType(int indx, int at, String[] arr) {
25.2027 + CPX2 c2 = getCpoolEntry(indx);
25.2028 + arr[at] = StringValue(c2.cpx1);
25.2029 + arr[at + 1] = StringValue(c2.cpx2);
25.2030 + return arr;
25.2031 + }
25.2032 +
25.2033 + public String[] getFieldInfoName(int indx) {
25.2034 + CPX2 c2 = getCpoolEntry(indx);
25.2035 + String[] arr = new String[3];
25.2036 + arr[0] = getClassName(c2.cpx1);
25.2037 + return getNameAndType(c2.cpx2, 1, arr);
25.2038 + }
25.2039 +
25.2040 + static byte[] findAttr(String n, AttrData[] attrs) {
25.2041 + for (AttrData ad : attrs) {
25.2042 + if (n.equals(ad.getAttrName())) {
25.2043 + return ad.getData();
25.2044 + }
25.2045 + }
25.2046 + return null;
25.2047 + }
25.2048 + }
25.2049 +
25.2050 + /**
25.2051 + * Strores field data informastion.
25.2052 + *
25.2053 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.2054 + */
25.2055 + static class FieldData {
25.2056 +
25.2057 + ClassData cls;
25.2058 + int access;
25.2059 + int name_index;
25.2060 + int descriptor_index;
25.2061 + int attributes_count;
25.2062 + int value_cpx = 0;
25.2063 + boolean isSynthetic = false;
25.2064 + boolean isDeprecated = false;
25.2065 + Vector attrs;
25.2066 +
25.2067 + public FieldData(ClassData cls) {
25.2068 + this.cls = cls;
25.2069 + }
25.2070 +
25.2071 + /**
25.2072 + * Read and store field info.
25.2073 + */
25.2074 + public void read(DataInputStream in) throws IOException {
25.2075 + access = in.readUnsignedShort();
25.2076 + name_index = in.readUnsignedShort();
25.2077 + descriptor_index = in.readUnsignedShort();
25.2078 + // Read the attributes
25.2079 + int attributes_count = in.readUnsignedShort();
25.2080 + attrs = new Vector(attributes_count);
25.2081 + for (int i = 0; i < attributes_count; i++) {
25.2082 + int attr_name_index = in.readUnsignedShort();
25.2083 + if (cls.getTag(attr_name_index) != CONSTANT_UTF8) {
25.2084 + continue;
25.2085 + }
25.2086 + String attr_name = cls.getString(attr_name_index);
25.2087 + if (attr_name.equals("ConstantValue")) {
25.2088 + if (in.readInt() != 2) {
25.2089 + throw new ClassFormatError("invalid ConstantValue attr length");
25.2090 + }
25.2091 + value_cpx = in.readUnsignedShort();
25.2092 + AttrData attr = new AttrData(cls);
25.2093 + attr.read(attr_name_index);
25.2094 + attrs.addElement(attr);
25.2095 + } else if (attr_name.equals("Synthetic")) {
25.2096 + if (in.readInt() != 0) {
25.2097 + throw new ClassFormatError("invalid Synthetic attr length");
25.2098 + }
25.2099 + isSynthetic = true;
25.2100 + AttrData attr = new AttrData(cls);
25.2101 + attr.read(attr_name_index);
25.2102 + attrs.addElement(attr);
25.2103 + } else if (attr_name.equals("Deprecated")) {
25.2104 + if (in.readInt() != 0) {
25.2105 + throw new ClassFormatError("invalid Synthetic attr length");
25.2106 + }
25.2107 + isDeprecated = true;
25.2108 + AttrData attr = new AttrData(cls);
25.2109 + attr.read(attr_name_index);
25.2110 + attrs.addElement(attr);
25.2111 + } else {
25.2112 + AttrData attr = new AttrData(cls);
25.2113 + attr.read(attr_name_index, in);
25.2114 + attrs.addElement(attr);
25.2115 + }
25.2116 + }
25.2117 +
25.2118 + } // end read
25.2119 +
25.2120 + public boolean isStatic() {
25.2121 + return (access & ACC_STATIC) != 0;
25.2122 + }
25.2123 +
25.2124 + /**
25.2125 + * Returns access of a field.
25.2126 + */
25.2127 + public String[] getAccess() {
25.2128 + Vector v = new Vector();
25.2129 + if ((access & ACC_PUBLIC) != 0) {
25.2130 + v.addElement("public");
25.2131 + }
25.2132 + if ((access & ACC_PRIVATE) != 0) {
25.2133 + v.addElement("private");
25.2134 + }
25.2135 + if ((access & ACC_PROTECTED) != 0) {
25.2136 + v.addElement("protected");
25.2137 + }
25.2138 + if ((access & ACC_STATIC) != 0) {
25.2139 + v.addElement("static");
25.2140 + }
25.2141 + if ((access & ACC_FINAL) != 0) {
25.2142 + v.addElement("final");
25.2143 + }
25.2144 + if ((access & ACC_VOLATILE) != 0) {
25.2145 + v.addElement("volatile");
25.2146 + }
25.2147 + if ((access & ACC_TRANSIENT) != 0) {
25.2148 + v.addElement("transient");
25.2149 + }
25.2150 + String[] accflags = new String[v.size()];
25.2151 + v.copyInto(accflags);
25.2152 + return accflags;
25.2153 + }
25.2154 +
25.2155 + /**
25.2156 + * Returns name of a field.
25.2157 + */
25.2158 + public String getName() {
25.2159 + return cls.getStringValue(name_index);
25.2160 + }
25.2161 +
25.2162 + /**
25.2163 + * Returns internal signature of a field
25.2164 + */
25.2165 + public String getInternalSig() {
25.2166 + return cls.getStringValue(descriptor_index);
25.2167 + }
25.2168 +
25.2169 + /**
25.2170 + * Returns true if field is synthetic.
25.2171 + */
25.2172 + public boolean isSynthetic() {
25.2173 + return isSynthetic;
25.2174 + }
25.2175 +
25.2176 + /**
25.2177 + * Returns true if field is deprecated.
25.2178 + */
25.2179 + public boolean isDeprecated() {
25.2180 + return isDeprecated;
25.2181 + }
25.2182 +
25.2183 + /**
25.2184 + * Returns index of constant value in cpool.
25.2185 + */
25.2186 + public int getConstantValueIndex() {
25.2187 + return (value_cpx);
25.2188 + }
25.2189 +
25.2190 + /**
25.2191 + * Returns list of attributes of field.
25.2192 + */
25.2193 + public Vector getAttributes() {
25.2194 + return attrs;
25.2195 + }
25.2196 +
25.2197 + public byte[] findAnnotationData(boolean classRetention) {
25.2198 + String n = classRetention
25.2199 + ? "RuntimeInvisibleAnnotations" : // NOI18N
25.2200 + "RuntimeVisibleAnnotations"; // NOI18N
25.2201 + AttrData[] arr = new AttrData[attrs.size()];
25.2202 + attrs.copyInto(arr);
25.2203 + return ClassData.findAttr(n, arr);
25.2204 + }
25.2205 + }
25.2206 +
25.2207 + /**
25.2208 + * A JavaScript optimized replacement for Hashtable.
25.2209 + *
25.2210 + * @author Jaroslav Tulach <jtulach@netbeans.org>
25.2211 + */
25.2212 + private static final class Hashtable {
25.2213 +
25.2214 + private Object[] keys;
25.2215 + private Object[] values;
25.2216 +
25.2217 + Hashtable(int i) {
25.2218 + this();
25.2219 + }
25.2220 +
25.2221 + Hashtable(int i, double d) {
25.2222 + this();
25.2223 + }
25.2224 +
25.2225 + Hashtable() {
25.2226 + }
25.2227 +
25.2228 + synchronized void put(Object key, Object val) {
25.2229 + int[] where = {-1, -1};
25.2230 + Object found = get(key, where);
25.2231 + if (where[0] != -1) {
25.2232 + // key exists
25.2233 + values[where[0]] = val;
25.2234 + } else {
25.2235 + if (where[1] != -1) {
25.2236 + // null found
25.2237 + keys[where[1]] = key;
25.2238 + values[where[1]] = val;
25.2239 + } else {
25.2240 + if (keys == null) {
25.2241 + keys = new Object[11];
25.2242 + values = new Object[11];
25.2243 + keys[0] = key;
25.2244 + values[0] = val;
25.2245 + } else {
25.2246 + Object[] newKeys = new Object[keys.length * 2];
25.2247 + Object[] newValues = new Object[values.length * 2];
25.2248 + for (int i = 0; i < keys.length; i++) {
25.2249 + newKeys[i] = keys[i];
25.2250 + newValues[i] = values[i];
25.2251 + }
25.2252 + newKeys[keys.length] = key;
25.2253 + newValues[keys.length] = val;
25.2254 + keys = newKeys;
25.2255 + values = newValues;
25.2256 + }
25.2257 + }
25.2258 + }
25.2259 + }
25.2260 +
25.2261 + Object get(Object key) {
25.2262 + return get(key, null);
25.2263 + }
25.2264 +
25.2265 + private synchronized Object get(Object key, int[] foundAndNull) {
25.2266 + if (keys == null) {
25.2267 + return null;
25.2268 + }
25.2269 + for (int i = 0; i < keys.length; i++) {
25.2270 + if (keys[i] == null) {
25.2271 + if (foundAndNull != null) {
25.2272 + foundAndNull[1] = i;
25.2273 + }
25.2274 + } else if (keys[i].equals(key)) {
25.2275 + if (foundAndNull != null) {
25.2276 + foundAndNull[0] = i;
25.2277 + }
25.2278 + return values[i];
25.2279 + }
25.2280 + }
25.2281 + return null;
25.2282 + }
25.2283 + }
25.2284 +
25.2285 + /**
25.2286 + * Strores InnerClass data informastion.
25.2287 + *
25.2288 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.2289 + */
25.2290 + private static class InnerClassData {
25.2291 +
25.2292 + ClassData cls;
25.2293 + int inner_class_info_index, outer_class_info_index, inner_name_index, access;
25.2294 +
25.2295 + public InnerClassData(ClassData cls) {
25.2296 + this.cls = cls;
25.2297 +
25.2298 + }
25.2299 +
25.2300 + /**
25.2301 + * Read Innerclass attribute data.
25.2302 + */
25.2303 + public void read(DataInputStream in) throws IOException {
25.2304 + inner_class_info_index = in.readUnsignedShort();
25.2305 + outer_class_info_index = in.readUnsignedShort();
25.2306 + inner_name_index = in.readUnsignedShort();
25.2307 + access = in.readUnsignedShort();
25.2308 + } // end read
25.2309 +
25.2310 + /**
25.2311 + * Returns the access of this class or interface.
25.2312 + */
25.2313 + public String[] getAccess() {
25.2314 + Vector v = new Vector();
25.2315 + if ((access & ACC_PUBLIC) != 0) {
25.2316 + v.addElement("public");
25.2317 + }
25.2318 + if ((access & ACC_FINAL) != 0) {
25.2319 + v.addElement("final");
25.2320 + }
25.2321 + if ((access & ACC_ABSTRACT) != 0) {
25.2322 + v.addElement("abstract");
25.2323 + }
25.2324 + String[] accflags = new String[v.size()];
25.2325 + v.copyInto(accflags);
25.2326 + return accflags;
25.2327 + }
25.2328 + } // end InnerClassData
25.2329 +
25.2330 + /**
25.2331 + * Strores LineNumberTable data information.
25.2332 + *
25.2333 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.2334 + */
25.2335 + private static class LineNumData {
25.2336 +
25.2337 + short start_pc, line_number;
25.2338 +
25.2339 + public LineNumData() {
25.2340 + }
25.2341 +
25.2342 + /**
25.2343 + * Read LineNumberTable attribute.
25.2344 + */
25.2345 + public LineNumData(DataInputStream in) throws IOException {
25.2346 + start_pc = in.readShort();
25.2347 + line_number = in.readShort();
25.2348 +
25.2349 + }
25.2350 + }
25.2351 +
25.2352 + /**
25.2353 + * Strores LocalVariableTable data information.
25.2354 + *
25.2355 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.2356 + */
25.2357 + private static class LocVarData {
25.2358 +
25.2359 + short start_pc, length, name_cpx, sig_cpx, slot;
25.2360 +
25.2361 + public LocVarData() {
25.2362 + }
25.2363 +
25.2364 + /**
25.2365 + * Read LocalVariableTable attribute.
25.2366 + */
25.2367 + public LocVarData(DataInputStream in) throws IOException {
25.2368 + start_pc = in.readShort();
25.2369 + length = in.readShort();
25.2370 + name_cpx = in.readShort();
25.2371 + sig_cpx = in.readShort();
25.2372 + slot = in.readShort();
25.2373 +
25.2374 + }
25.2375 + }
25.2376 + /**
25.2377 + * Strores method data informastion.
25.2378 + *
25.2379 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.2380 + */
25.2381 + static class MethodData {
25.2382 +
25.2383 + ClassData cls;
25.2384 + int access;
25.2385 + int name_index;
25.2386 + int descriptor_index;
25.2387 + int attributes_count;
25.2388 + byte[] code;
25.2389 + Vector exception_table = new Vector(0);
25.2390 + Vector lin_num_tb = new Vector(0);
25.2391 + Vector loc_var_tb = new Vector(0);
25.2392 + StackMapTableData[] stackMapTable;
25.2393 + StackMapData[] stackMap;
25.2394 + int[] exc_index_table = null;
25.2395 + Vector attrs = new Vector(0);
25.2396 + Vector code_attrs = new Vector(0);
25.2397 + int max_stack, max_locals;
25.2398 + boolean isSynthetic = false;
25.2399 + boolean isDeprecated = false;
25.2400 +
25.2401 + public MethodData(ClassData cls) {
25.2402 + this.cls = cls;
25.2403 + }
25.2404 +
25.2405 + /**
25.2406 + * Read method info.
25.2407 + */
25.2408 + public void read(DataInputStream in) throws IOException {
25.2409 + access = in.readUnsignedShort();
25.2410 + name_index = in.readUnsignedShort();
25.2411 + descriptor_index = in.readUnsignedShort();
25.2412 + int attributes_count = in.readUnsignedShort();
25.2413 + for (int i = 0; i < attributes_count; i++) {
25.2414 + int attr_name_index = in.readUnsignedShort();
25.2415 +
25.2416 + readAttr:
25.2417 + {
25.2418 + if (cls.getTag(attr_name_index) == CONSTANT_UTF8) {
25.2419 + String attr_name = cls.getString(attr_name_index);
25.2420 + if (attr_name.equals("Code")) {
25.2421 + readCode(in);
25.2422 + AttrData attr = new AttrData(cls);
25.2423 + attr.read(attr_name_index);
25.2424 + attrs.addElement(attr);
25.2425 + break readAttr;
25.2426 + } else if (attr_name.equals("Exceptions")) {
25.2427 + readExceptions(in);
25.2428 + AttrData attr = new AttrData(cls);
25.2429 + attr.read(attr_name_index);
25.2430 + attrs.addElement(attr);
25.2431 + break readAttr;
25.2432 + } else if (attr_name.equals("Synthetic")) {
25.2433 + if (in.readInt() != 0) {
25.2434 + throw new ClassFormatError("invalid Synthetic attr length");
25.2435 + }
25.2436 + isSynthetic = true;
25.2437 + AttrData attr = new AttrData(cls);
25.2438 + attr.read(attr_name_index);
25.2439 + attrs.addElement(attr);
25.2440 + break readAttr;
25.2441 + } else if (attr_name.equals("Deprecated")) {
25.2442 + if (in.readInt() != 0) {
25.2443 + throw new ClassFormatError("invalid Synthetic attr length");
25.2444 + }
25.2445 + isDeprecated = true;
25.2446 + AttrData attr = new AttrData(cls);
25.2447 + attr.read(attr_name_index);
25.2448 + attrs.addElement(attr);
25.2449 + break readAttr;
25.2450 + }
25.2451 + }
25.2452 + AttrData attr = new AttrData(cls);
25.2453 + attr.read(attr_name_index, in);
25.2454 + attrs.addElement(attr);
25.2455 + }
25.2456 + }
25.2457 + }
25.2458 +
25.2459 + /**
25.2460 + * Read code attribute info.
25.2461 + */
25.2462 + public void readCode(DataInputStream in) throws IOException {
25.2463 +
25.2464 + int attr_length = in.readInt();
25.2465 + max_stack = in.readUnsignedShort();
25.2466 + max_locals = in.readUnsignedShort();
25.2467 + int codelen = in.readInt();
25.2468 +
25.2469 + code = new byte[codelen];
25.2470 + int totalread = 0;
25.2471 + while (totalread < codelen) {
25.2472 + totalread += in.read(code, totalread, codelen - totalread);
25.2473 + }
25.2474 + // in.read(code, 0, codelen);
25.2475 + int clen = 0;
25.2476 + readExceptionTable(in);
25.2477 + int code_attributes_count = in.readUnsignedShort();
25.2478 +
25.2479 + for (int k = 0; k < code_attributes_count; k++) {
25.2480 + int table_name_index = in.readUnsignedShort();
25.2481 + int table_name_tag = cls.getTag(table_name_index);
25.2482 + AttrData attr = new AttrData(cls);
25.2483 + if (table_name_tag == CONSTANT_UTF8) {
25.2484 + String table_name_tstr = cls.getString(table_name_index);
25.2485 + if (table_name_tstr.equals("LineNumberTable")) {
25.2486 + readLineNumTable(in);
25.2487 + attr.read(table_name_index);
25.2488 + } else if (table_name_tstr.equals("LocalVariableTable")) {
25.2489 + readLocVarTable(in);
25.2490 + attr.read(table_name_index);
25.2491 + } else if (table_name_tstr.equals("StackMapTable")) {
25.2492 + readStackMapTable(in);
25.2493 + attr.read(table_name_index);
25.2494 + } else if (table_name_tstr.equals("StackMap")) {
25.2495 + readStackMap(in);
25.2496 + attr.read(table_name_index);
25.2497 + } else {
25.2498 + attr.read(table_name_index, in);
25.2499 + }
25.2500 + code_attrs.addElement(attr);
25.2501 + continue;
25.2502 + }
25.2503 +
25.2504 + attr.read(table_name_index, in);
25.2505 + code_attrs.addElement(attr);
25.2506 + }
25.2507 + }
25.2508 +
25.2509 + /**
25.2510 + * Read exception table info.
25.2511 + */
25.2512 + void readExceptionTable(DataInputStream in) throws IOException {
25.2513 + int exception_table_len = in.readUnsignedShort();
25.2514 + exception_table = new Vector(exception_table_len);
25.2515 + for (int l = 0; l < exception_table_len; l++) {
25.2516 + exception_table.addElement(new TrapData(in, l));
25.2517 + }
25.2518 + }
25.2519 +
25.2520 + /**
25.2521 + * Read LineNumberTable attribute info.
25.2522 + */
25.2523 + void readLineNumTable(DataInputStream in) throws IOException {
25.2524 + int attr_len = in.readInt(); // attr_length
25.2525 + int lin_num_tb_len = in.readUnsignedShort();
25.2526 + lin_num_tb = new Vector(lin_num_tb_len);
25.2527 + for (int l = 0; l < lin_num_tb_len; l++) {
25.2528 + lin_num_tb.addElement(new LineNumData(in));
25.2529 + }
25.2530 + }
25.2531 +
25.2532 + /**
25.2533 + * Read LocalVariableTable attribute info.
25.2534 + */
25.2535 + void readLocVarTable(DataInputStream in) throws IOException {
25.2536 + int attr_len = in.readInt(); // attr_length
25.2537 + int loc_var_tb_len = in.readUnsignedShort();
25.2538 + loc_var_tb = new Vector(loc_var_tb_len);
25.2539 + for (int l = 0; l < loc_var_tb_len; l++) {
25.2540 + loc_var_tb.addElement(new LocVarData(in));
25.2541 + }
25.2542 + }
25.2543 +
25.2544 + /**
25.2545 + * Read Exception attribute info.
25.2546 + */
25.2547 + public void readExceptions(DataInputStream in) throws IOException {
25.2548 + int attr_len = in.readInt(); // attr_length in prog
25.2549 + int num_exceptions = in.readUnsignedShort();
25.2550 + exc_index_table = new int[num_exceptions];
25.2551 + for (int l = 0; l < num_exceptions; l++) {
25.2552 + int exc = in.readShort();
25.2553 + exc_index_table[l] = exc;
25.2554 + }
25.2555 + }
25.2556 +
25.2557 + /**
25.2558 + * Read StackMapTable attribute info.
25.2559 + */
25.2560 + void readStackMapTable(DataInputStream in) throws IOException {
25.2561 + int attr_len = in.readInt(); //attr_length
25.2562 + int stack_map_tb_len = in.readUnsignedShort();
25.2563 + stackMapTable = new StackMapTableData[stack_map_tb_len];
25.2564 + for (int i = 0; i < stack_map_tb_len; i++) {
25.2565 + stackMapTable[i] = StackMapTableData.getInstance(in, this);
25.2566 + }
25.2567 + }
25.2568 +
25.2569 + /**
25.2570 + * Read StackMap attribute info.
25.2571 + */
25.2572 + void readStackMap(DataInputStream in) throws IOException {
25.2573 + int attr_len = in.readInt(); //attr_length
25.2574 + int stack_map_len = in.readUnsignedShort();
25.2575 + stackMap = new StackMapData[stack_map_len];
25.2576 + for (int i = 0; i < stack_map_len; i++) {
25.2577 + stackMap[i] = new StackMapData(in, this);
25.2578 + }
25.2579 + }
25.2580 +
25.2581 + /**
25.2582 + * Return access of the method.
25.2583 + */
25.2584 + public int getAccess() {
25.2585 + return access;
25.2586 + }
25.2587 +
25.2588 + /**
25.2589 + * Return name of the method.
25.2590 + */
25.2591 + public String getName() {
25.2592 + return cls.getStringValue(name_index);
25.2593 + }
25.2594 +
25.2595 + /**
25.2596 + * Return internal siganature of the method.
25.2597 + */
25.2598 + public String getInternalSig() {
25.2599 + return cls.getStringValue(descriptor_index);
25.2600 + }
25.2601 +
25.2602 + /**
25.2603 + * Return code attribute data of a method.
25.2604 + */
25.2605 + public byte[] getCode() {
25.2606 + return code;
25.2607 + }
25.2608 +
25.2609 + /**
25.2610 + * Return LineNumberTable size.
25.2611 + */
25.2612 + public int getnumlines() {
25.2613 + return lin_num_tb.size();
25.2614 + }
25.2615 +
25.2616 + /**
25.2617 + * Return LineNumberTable
25.2618 + */
25.2619 + public Vector getlin_num_tb() {
25.2620 + return lin_num_tb;
25.2621 + }
25.2622 +
25.2623 + /**
25.2624 + * Return LocalVariableTable size.
25.2625 + */
25.2626 + public int getloc_var_tbsize() {
25.2627 + return loc_var_tb.size();
25.2628 + }
25.2629 +
25.2630 + /**
25.2631 + * Return LocalVariableTable.
25.2632 + */
25.2633 + public Vector getloc_var_tb() {
25.2634 + return loc_var_tb;
25.2635 + }
25.2636 +
25.2637 + /**
25.2638 + * Return StackMap.
25.2639 + */
25.2640 + public StackMapData[] getStackMap() {
25.2641 + return stackMap;
25.2642 + }
25.2643 +
25.2644 + /**
25.2645 + * Return StackMapTable.
25.2646 + */
25.2647 + public StackMapTableData[] getStackMapTable() {
25.2648 + return stackMapTable;
25.2649 + }
25.2650 +
25.2651 + public StackMapIterator createStackMapIterator() {
25.2652 + return new StackMapIterator(this);
25.2653 + }
25.2654 +
25.2655 + /**
25.2656 + * Return true if method is static
25.2657 + */
25.2658 + public boolean isStatic() {
25.2659 + if ((access & ACC_STATIC) != 0) {
25.2660 + return true;
25.2661 + }
25.2662 + return false;
25.2663 + }
25.2664 +
25.2665 + /**
25.2666 + * Return max depth of operand stack.
25.2667 + */
25.2668 + public int getMaxStack() {
25.2669 + return max_stack;
25.2670 + }
25.2671 +
25.2672 + /**
25.2673 + * Return number of local variables.
25.2674 + */
25.2675 + public int getMaxLocals() {
25.2676 + return max_locals;
25.2677 + }
25.2678 +
25.2679 + /**
25.2680 + * Return exception index table in Exception attribute.
25.2681 + */
25.2682 + public int[] get_exc_index_table() {
25.2683 + return exc_index_table;
25.2684 + }
25.2685 +
25.2686 + /**
25.2687 + * Return exception table in code attributre.
25.2688 + */
25.2689 + public TrapDataIterator getTrapDataIterator() {
25.2690 + return new TrapDataIterator(exception_table);
25.2691 + }
25.2692 +
25.2693 + /**
25.2694 + * Return method attributes.
25.2695 + */
25.2696 + public Vector getAttributes() {
25.2697 + return attrs;
25.2698 + }
25.2699 +
25.2700 + /**
25.2701 + * Return code attributes.
25.2702 + */
25.2703 + public Vector getCodeAttributes() {
25.2704 + return code_attrs;
25.2705 + }
25.2706 +
25.2707 + /**
25.2708 + * Return true if method id synthetic.
25.2709 + */
25.2710 + public boolean isSynthetic() {
25.2711 + return isSynthetic;
25.2712 + }
25.2713 +
25.2714 + /**
25.2715 + * Return true if method is deprecated.
25.2716 + */
25.2717 + public boolean isDeprecated() {
25.2718 + return isDeprecated;
25.2719 + }
25.2720 +
25.2721 + public byte[] findAnnotationData(boolean classRetention) {
25.2722 + String n = classRetention
25.2723 + ? "RuntimeInvisibleAnnotations" : // NOI18N
25.2724 + "RuntimeVisibleAnnotations"; // NOI18N
25.2725 + AttrData[] arr = new AttrData[attrs.size()];
25.2726 + attrs.copyInto(arr);
25.2727 + return ClassData.findAttr(n, arr);
25.2728 + }
25.2729 +
25.2730 + public boolean isConstructor() {
25.2731 + return "<init>".equals(getName());
25.2732 + }
25.2733 + }
25.2734 +
25.2735 + /* represents one entry of StackMap attribute
25.2736 + */
25.2737 + private static class StackMapData {
25.2738 +
25.2739 + final int offset;
25.2740 + final int[] locals;
25.2741 + final int[] stack;
25.2742 +
25.2743 + StackMapData(int offset, int[] locals, int[] stack) {
25.2744 + this.offset = offset;
25.2745 + this.locals = locals;
25.2746 + this.stack = stack;
25.2747 + }
25.2748 +
25.2749 + StackMapData(DataInputStream in, MethodData method) throws IOException {
25.2750 + offset = in.readUnsignedShort();
25.2751 + int local_size = in.readUnsignedShort();
25.2752 + locals = readTypeArray(in, local_size, method);
25.2753 + int stack_size = in.readUnsignedShort();
25.2754 + stack = readTypeArray(in, stack_size, method);
25.2755 + }
25.2756 +
25.2757 + static final int[] readTypeArray(DataInputStream in, int length, MethodData method) throws IOException {
25.2758 + int[] types = new int[length];
25.2759 + for (int i = 0; i < length; i++) {
25.2760 + types[i] = readType(in, method);
25.2761 + }
25.2762 + return types;
25.2763 + }
25.2764 +
25.2765 + static final int readType(DataInputStream in, MethodData method) throws IOException {
25.2766 + int type = in.readUnsignedByte();
25.2767 + if (type == ITEM_Object || type == ITEM_NewObject) {
25.2768 + type = type | (in.readUnsignedShort() << 8);
25.2769 + }
25.2770 + return type;
25.2771 + }
25.2772 + }
25.2773 +
25.2774 + static final class StackMapIterator {
25.2775 +
25.2776 + private final StackMapTableData[] stackMapTable;
25.2777 + private final TypeArray argTypes;
25.2778 + private final TypeArray localTypes;
25.2779 + private final TypeArray stackTypes;
25.2780 + private int nextFrameIndex;
25.2781 + private int lastFrameByteCodeOffset;
25.2782 + private int byteCodeOffset;
25.2783 +
25.2784 + StackMapIterator(final MethodData methodData) {
25.2785 + this(methodData.getStackMapTable(),
25.2786 + methodData.getInternalSig(),
25.2787 + methodData.isStatic());
25.2788 + }
25.2789 +
25.2790 + StackMapIterator(final StackMapTableData[] stackMapTable,
25.2791 + final String methodSignature,
25.2792 + final boolean isStaticMethod) {
25.2793 + this.stackMapTable = (stackMapTable != null)
25.2794 + ? stackMapTable
25.2795 + : new StackMapTableData[0];
25.2796 +
25.2797 + argTypes = getArgTypes(methodSignature, isStaticMethod);
25.2798 + localTypes = new TypeArray();
25.2799 + stackTypes = new TypeArray();
25.2800 +
25.2801 + localTypes.addAll(argTypes);
25.2802 +
25.2803 + lastFrameByteCodeOffset = -1;
25.2804 + advanceBy(0);
25.2805 + }
25.2806 +
25.2807 + public String getFrameAsString() {
25.2808 + return (nextFrameIndex == 0)
25.2809 + ? StackMapTableData.toString("INITIAL", 0, null, null)
25.2810 + : stackMapTable[nextFrameIndex - 1].toString();
25.2811 + }
25.2812 +
25.2813 + public int getFrameIndex() {
25.2814 + return nextFrameIndex;
25.2815 + }
25.2816 +
25.2817 + public TypeArray getFrameStack() {
25.2818 + return stackTypes;
25.2819 + }
25.2820 +
25.2821 + public TypeArray getFrameLocals() {
25.2822 + return localTypes;
25.2823 + }
25.2824 +
25.2825 + public TypeArray getArguments() {
25.2826 + return argTypes;
25.2827 + }
25.2828 +
25.2829 + public void advanceBy(final int numByteCodes) {
25.2830 + if (numByteCodes < 0) {
25.2831 + throw new IllegalStateException("Forward only iterator");
25.2832 + }
25.2833 +
25.2834 + byteCodeOffset += numByteCodes;
25.2835 + while ((nextFrameIndex < stackMapTable.length)
25.2836 + && ((byteCodeOffset - lastFrameByteCodeOffset)
25.2837 + >= (stackMapTable[nextFrameIndex].offsetDelta
25.2838 + + 1))) {
25.2839 + final StackMapTableData nextFrame = stackMapTable[nextFrameIndex];
25.2840 +
25.2841 + lastFrameByteCodeOffset += nextFrame.offsetDelta + 1;
25.2842 + nextFrame.applyTo(localTypes, stackTypes);
25.2843 +
25.2844 + ++nextFrameIndex;
25.2845 + }
25.2846 + }
25.2847 +
25.2848 + public void advanceTo(final int nextByteCodeOffset) {
25.2849 + advanceBy(nextByteCodeOffset - byteCodeOffset);
25.2850 + }
25.2851 +
25.2852 + private static TypeArray getArgTypes(final String methodSignature,
25.2853 + final boolean isStaticMethod) {
25.2854 + final TypeArray argTypes = new TypeArray();
25.2855 +
25.2856 + if (!isStaticMethod) {
25.2857 + argTypes.add(ITEM_Object);
25.2858 + }
25.2859 +
25.2860 + if (methodSignature.charAt(0) != '(') {
25.2861 + throw new IllegalArgumentException("Invalid method signature");
25.2862 + }
25.2863 +
25.2864 + final int length = methodSignature.length();
25.2865 + boolean skipType = false;
25.2866 + int argType;
25.2867 + for (int i = 1; i < length; ++i) {
25.2868 + switch (methodSignature.charAt(i)) {
25.2869 + case 'B':
25.2870 + case 'C':
25.2871 + case 'S':
25.2872 + case 'Z':
25.2873 + case 'I':
25.2874 + argType = ITEM_Integer;
25.2875 + break;
25.2876 + case 'J':
25.2877 + argType = ITEM_Long;
25.2878 + break;
25.2879 + case 'F':
25.2880 + argType = ITEM_Float;
25.2881 + break;
25.2882 + case 'D':
25.2883 + argType = ITEM_Double;
25.2884 + break;
25.2885 + case 'L': {
25.2886 + i = methodSignature.indexOf(';', i + 1);
25.2887 + if (i == -1) {
25.2888 + throw new IllegalArgumentException(
25.2889 + "Invalid method signature");
25.2890 + }
25.2891 + argType = ITEM_Object;
25.2892 + break;
25.2893 + }
25.2894 + case ')':
25.2895 + // not interested in the return value type
25.2896 + return argTypes;
25.2897 + case '[':
25.2898 + if (!skipType) {
25.2899 + argTypes.add(ITEM_Object);
25.2900 + skipType = true;
25.2901 + }
25.2902 + continue;
25.2903 +
25.2904 + default:
25.2905 + throw new IllegalArgumentException(
25.2906 + "Invalid method signature");
25.2907 + }
25.2908 +
25.2909 + if (!skipType) {
25.2910 + argTypes.add(argType);
25.2911 + } else {
25.2912 + skipType = false;
25.2913 + }
25.2914 + }
25.2915 +
25.2916 + return argTypes;
25.2917 + }
25.2918 + }
25.2919 + /* represents one entry of StackMapTable attribute
25.2920 + */
25.2921 +
25.2922 + private static abstract class StackMapTableData {
25.2923 +
25.2924 + final int frameType;
25.2925 + int offsetDelta;
25.2926 +
25.2927 + StackMapTableData(int frameType) {
25.2928 + this.frameType = frameType;
25.2929 + }
25.2930 +
25.2931 + abstract void applyTo(TypeArray localTypes, TypeArray stackTypes);
25.2932 +
25.2933 + protected static String toString(
25.2934 + final String frameType,
25.2935 + final int offset,
25.2936 + final int[] localTypes,
25.2937 + final int[] stackTypes) {
25.2938 + final StringBuilder sb = new StringBuilder(frameType);
25.2939 +
25.2940 + sb.append("(off: +").append(offset);
25.2941 + if (localTypes != null) {
25.2942 + sb.append(", locals: ");
25.2943 + appendTypes(sb, localTypes);
25.2944 + }
25.2945 + if (stackTypes != null) {
25.2946 + sb.append(", stack: ");
25.2947 + appendTypes(sb, stackTypes);
25.2948 + }
25.2949 + sb.append(')');
25.2950 +
25.2951 + return sb.toString();
25.2952 + }
25.2953 +
25.2954 + private static void appendTypes(final StringBuilder sb, final int[] types) {
25.2955 + sb.append('[');
25.2956 + if (types.length > 0) {
25.2957 + sb.append(TypeArray.typeString(types[0]));
25.2958 + for (int i = 1; i < types.length; ++i) {
25.2959 + sb.append(", ");
25.2960 + sb.append(TypeArray.typeString(types[i]));
25.2961 + }
25.2962 + }
25.2963 + sb.append(']');
25.2964 + }
25.2965 +
25.2966 + private static class SameFrame extends StackMapTableData {
25.2967 +
25.2968 + SameFrame(int frameType, int offsetDelta) {
25.2969 + super(frameType);
25.2970 + this.offsetDelta = offsetDelta;
25.2971 + }
25.2972 +
25.2973 + @Override
25.2974 + void applyTo(TypeArray localTypes, TypeArray stackTypes) {
25.2975 + stackTypes.clear();
25.2976 + }
25.2977 +
25.2978 + @Override
25.2979 + public String toString() {
25.2980 + return toString("SAME" + ((frameType == SAME_FRAME_EXTENDED)
25.2981 + ? "_FRAME_EXTENDED" : ""),
25.2982 + offsetDelta,
25.2983 + null, null);
25.2984 + }
25.2985 + }
25.2986 +
25.2987 + private static class SameLocals1StackItem extends StackMapTableData {
25.2988 +
25.2989 + final int[] stack;
25.2990 +
25.2991 + SameLocals1StackItem(int frameType, int offsetDelta, int[] stack) {
25.2992 + super(frameType);
25.2993 + this.offsetDelta = offsetDelta;
25.2994 + this.stack = stack;
25.2995 + }
25.2996 +
25.2997 + @Override
25.2998 + void applyTo(TypeArray localTypes, TypeArray stackTypes) {
25.2999 + stackTypes.setAll(stack);
25.3000 + }
25.3001 +
25.3002 + @Override
25.3003 + public String toString() {
25.3004 + return toString(
25.3005 + "SAME_LOCALS_1_STACK_ITEM"
25.3006 + + ((frameType == SAME_LOCALS_1_STACK_ITEM_EXTENDED)
25.3007 + ? "_EXTENDED" : ""),
25.3008 + offsetDelta,
25.3009 + null, stack);
25.3010 + }
25.3011 + }
25.3012 +
25.3013 + private static class ChopFrame extends StackMapTableData {
25.3014 +
25.3015 + ChopFrame(int frameType, int offsetDelta) {
25.3016 + super(frameType);
25.3017 + this.offsetDelta = offsetDelta;
25.3018 + }
25.3019 +
25.3020 + @Override
25.3021 + void applyTo(TypeArray localTypes, TypeArray stackTypes) {
25.3022 + localTypes.setSize(localTypes.getSize()
25.3023 + - (SAME_FRAME_EXTENDED - frameType));
25.3024 + stackTypes.clear();
25.3025 + }
25.3026 +
25.3027 + @Override
25.3028 + public String toString() {
25.3029 + return toString("CHOP", offsetDelta, null, null);
25.3030 + }
25.3031 + }
25.3032 +
25.3033 + private static class AppendFrame extends StackMapTableData {
25.3034 +
25.3035 + final int[] locals;
25.3036 +
25.3037 + AppendFrame(int frameType, int offsetDelta, int[] locals) {
25.3038 + super(frameType);
25.3039 + this.offsetDelta = offsetDelta;
25.3040 + this.locals = locals;
25.3041 + }
25.3042 +
25.3043 + @Override
25.3044 + void applyTo(TypeArray localTypes, TypeArray stackTypes) {
25.3045 + localTypes.addAll(locals);
25.3046 + stackTypes.clear();
25.3047 + }
25.3048 +
25.3049 + @Override
25.3050 + public String toString() {
25.3051 + return toString("APPEND", offsetDelta, locals, null);
25.3052 + }
25.3053 + }
25.3054 +
25.3055 + private static class FullFrame extends StackMapTableData {
25.3056 +
25.3057 + final int[] locals;
25.3058 + final int[] stack;
25.3059 +
25.3060 + FullFrame(int offsetDelta, int[] locals, int[] stack) {
25.3061 + super(FULL_FRAME);
25.3062 + this.offsetDelta = offsetDelta;
25.3063 + this.locals = locals;
25.3064 + this.stack = stack;
25.3065 + }
25.3066 +
25.3067 + @Override
25.3068 + void applyTo(TypeArray localTypes, TypeArray stackTypes) {
25.3069 + localTypes.setAll(locals);
25.3070 + stackTypes.setAll(stack);
25.3071 + }
25.3072 +
25.3073 + @Override
25.3074 + public String toString() {
25.3075 + return toString("FULL", offsetDelta, locals, stack);
25.3076 + }
25.3077 + }
25.3078 +
25.3079 + static StackMapTableData getInstance(DataInputStream in, MethodData method)
25.3080 + throws IOException {
25.3081 + int frameType = in.readUnsignedByte();
25.3082 +
25.3083 + if (frameType < SAME_FRAME_BOUND) {
25.3084 + // same_frame
25.3085 + return new SameFrame(frameType, frameType);
25.3086 + } else if (SAME_FRAME_BOUND <= frameType && frameType < SAME_LOCALS_1_STACK_ITEM_BOUND) {
25.3087 + // same_locals_1_stack_item_frame
25.3088 + // read additional single stack element
25.3089 + return new SameLocals1StackItem(frameType,
25.3090 + (frameType - SAME_FRAME_BOUND),
25.3091 + StackMapData.readTypeArray(in, 1, method));
25.3092 + } else if (frameType == SAME_LOCALS_1_STACK_ITEM_EXTENDED) {
25.3093 + // same_locals_1_stack_item_extended
25.3094 + return new SameLocals1StackItem(frameType,
25.3095 + in.readUnsignedShort(),
25.3096 + StackMapData.readTypeArray(in, 1, method));
25.3097 + } else if (SAME_LOCALS_1_STACK_ITEM_EXTENDED < frameType && frameType < SAME_FRAME_EXTENDED) {
25.3098 + // chop_frame or same_frame_extended
25.3099 + return new ChopFrame(frameType, in.readUnsignedShort());
25.3100 + } else if (frameType == SAME_FRAME_EXTENDED) {
25.3101 + // chop_frame or same_frame_extended
25.3102 + return new SameFrame(frameType, in.readUnsignedShort());
25.3103 + } else if (SAME_FRAME_EXTENDED < frameType && frameType < FULL_FRAME) {
25.3104 + // append_frame
25.3105 + return new AppendFrame(frameType, in.readUnsignedShort(),
25.3106 + StackMapData.readTypeArray(in, frameType - SAME_FRAME_EXTENDED, method));
25.3107 + } else if (frameType == FULL_FRAME) {
25.3108 + // full_frame
25.3109 + int offsetDelta = in.readUnsignedShort();
25.3110 + int locals_size = in.readUnsignedShort();
25.3111 + int[] locals = StackMapData.readTypeArray(in, locals_size, method);
25.3112 + int stack_size = in.readUnsignedShort();
25.3113 + int[] stack = StackMapData.readTypeArray(in, stack_size, method);
25.3114 + return new FullFrame(offsetDelta, locals, stack);
25.3115 + } else {
25.3116 + throw new ClassFormatError("unrecognized frame_type in StackMapTable");
25.3117 + }
25.3118 + }
25.3119 + }
25.3120 +
25.3121 + /**
25.3122 + * Stores exception table data in code attribute.
25.3123 + *
25.3124 + * @author Sucheta Dambalkar (Adopted code from jdis)
25.3125 + */
25.3126 + static final class TrapData {
25.3127 +
25.3128 + public final short start_pc;
25.3129 + public final short end_pc;
25.3130 + public final short handler_pc;
25.3131 + public final short catch_cpx;
25.3132 + final int num;
25.3133 +
25.3134 + /**
25.3135 + * Read and store exception table data in code attribute.
25.3136 + */
25.3137 + TrapData(DataInputStream in, int num) throws IOException {
25.3138 + this.num = num;
25.3139 + start_pc = in.readShort();
25.3140 + end_pc = in.readShort();
25.3141 + handler_pc = in.readShort();
25.3142 + catch_cpx = in.readShort();
25.3143 + }
25.3144 +
25.3145 + /**
25.3146 + * returns recommended identifier
25.3147 + */
25.3148 + public String ident() {
25.3149 + return "t" + num;
25.3150 + }
25.3151 + }
25.3152 + /**
25.3153 + *
25.3154 + * @author Jaroslav Tulach <jtulach@netbeans.org>
25.3155 + */
25.3156 + static final class TrapDataIterator {
25.3157 +
25.3158 + private final Hashtable exStart = new Hashtable();
25.3159 + private final Hashtable exStop = new Hashtable();
25.3160 + private TrapData[] current = new TrapData[10];
25.3161 + private int currentCount;
25.3162 +
25.3163 + TrapDataIterator(Vector exceptionTable) {
25.3164 + for (int i = 0; i < exceptionTable.size(); i++) {
25.3165 + final TrapData td = (TrapData) exceptionTable.elementAt(i);
25.3166 + put(exStart, td.start_pc, td);
25.3167 + put(exStop, td.end_pc, td);
25.3168 + }
25.3169 + }
25.3170 +
25.3171 + private static void put(Hashtable h, short key, TrapData td) {
25.3172 + Short s = Short.valueOf((short) key);
25.3173 + Vector v = (Vector) h.get(s);
25.3174 + if (v == null) {
25.3175 + v = new Vector(1);
25.3176 + h.put(s, v);
25.3177 + }
25.3178 + v.add(td);
25.3179 + }
25.3180 +
25.3181 + private boolean processAll(Hashtable h, Short key, boolean add) {
25.3182 + boolean change = false;
25.3183 + Vector v = (Vector) h.get(key);
25.3184 + if (v != null) {
25.3185 + int s = v.size();
25.3186 + for (int i = 0; i < s; i++) {
25.3187 + TrapData td = (TrapData) v.elementAt(i);
25.3188 + if (add) {
25.3189 + add(td);
25.3190 + change = true;
25.3191 + } else {
25.3192 + remove(td);
25.3193 + change = true;
25.3194 + }
25.3195 + }
25.3196 + }
25.3197 + return change;
25.3198 + }
25.3199 +
25.3200 + public boolean advanceTo(int i) {
25.3201 + Short s = Short.valueOf((short) i);
25.3202 + boolean ch1 = processAll(exStart, s, true);
25.3203 + boolean ch2 = processAll(exStop, s, false);
25.3204 + return ch1 || ch2;
25.3205 + }
25.3206 +
25.3207 + public boolean useTry() {
25.3208 + return currentCount > 0;
25.3209 + }
25.3210 +
25.3211 + public TrapData[] current() {
25.3212 + TrapData[] copy = new TrapData[currentCount];
25.3213 + for (int i = 0; i < currentCount; i++) {
25.3214 + copy[i] = current[i];
25.3215 + }
25.3216 + return copy;
25.3217 + }
25.3218 +
25.3219 + private void add(TrapData e) {
25.3220 + if (currentCount == current.length) {
25.3221 + TrapData[] data = new TrapData[currentCount * 2];
25.3222 + for (int i = 0; i < currentCount; i++) {
25.3223 + data[i] = current[i];
25.3224 + }
25.3225 + current = data;
25.3226 + }
25.3227 + current[currentCount++] = e;
25.3228 + }
25.3229 +
25.3230 + private void remove(TrapData e) {
25.3231 + if (currentCount == 0) {
25.3232 + return;
25.3233 + }
25.3234 + int from = 0;
25.3235 + while (from < currentCount) {
25.3236 + if (e == current[from++]) {
25.3237 + break;
25.3238 + }
25.3239 + }
25.3240 + while (from < currentCount) {
25.3241 + current[from - 1] = current[from];
25.3242 + current[from] = null;
25.3243 + from++;
25.3244 + }
25.3245 + currentCount--;
25.3246 + }
25.3247 + }
25.3248 + static final class TypeArray {
25.3249 +
25.3250 + private static final int CAPACITY_INCREMENT = 16;
25.3251 + private int[] types;
25.3252 + private int size;
25.3253 +
25.3254 + public TypeArray() {
25.3255 + }
25.3256 +
25.3257 + public TypeArray(final TypeArray initialTypes) {
25.3258 + setAll(initialTypes);
25.3259 + }
25.3260 +
25.3261 + public void add(final int newType) {
25.3262 + ensureCapacity(size + 1);
25.3263 + types[size++] = newType;
25.3264 + }
25.3265 +
25.3266 + public void addAll(final TypeArray newTypes) {
25.3267 + addAll(newTypes.types, 0, newTypes.size);
25.3268 + }
25.3269 +
25.3270 + public void addAll(final int[] newTypes) {
25.3271 + addAll(newTypes, 0, newTypes.length);
25.3272 + }
25.3273 +
25.3274 + public void addAll(final int[] newTypes,
25.3275 + final int offset,
25.3276 + final int count) {
25.3277 + if (count > 0) {
25.3278 + ensureCapacity(size + count);
25.3279 + arraycopy(newTypes, offset, types, size, count);
25.3280 + size += count;
25.3281 + }
25.3282 + }
25.3283 +
25.3284 + public void set(final int index, final int newType) {
25.3285 + types[index] = newType;
25.3286 + }
25.3287 +
25.3288 + public void setAll(final TypeArray newTypes) {
25.3289 + setAll(newTypes.types, 0, newTypes.size);
25.3290 + }
25.3291 +
25.3292 + public void setAll(final int[] newTypes) {
25.3293 + setAll(newTypes, 0, newTypes.length);
25.3294 + }
25.3295 +
25.3296 + public void setAll(final int[] newTypes,
25.3297 + final int offset,
25.3298 + final int count) {
25.3299 + if (count > 0) {
25.3300 + ensureCapacity(count);
25.3301 + arraycopy(newTypes, offset, types, 0, count);
25.3302 + size = count;
25.3303 + } else {
25.3304 + clear();
25.3305 + }
25.3306 + }
25.3307 +
25.3308 + public void setSize(final int newSize) {
25.3309 + if (size != newSize) {
25.3310 + ensureCapacity(newSize);
25.3311 +
25.3312 + for (int i = size; i < newSize; ++i) {
25.3313 + types[i] = 0;
25.3314 + }
25.3315 + size = newSize;
25.3316 + }
25.3317 + }
25.3318 +
25.3319 + public void clear() {
25.3320 + size = 0;
25.3321 + }
25.3322 +
25.3323 + public int getSize() {
25.3324 + return size;
25.3325 + }
25.3326 +
25.3327 + public int get(final int index) {
25.3328 + return types[index];
25.3329 + }
25.3330 +
25.3331 + public static String typeString(final int type) {
25.3332 + switch (type & 0xff) {
25.3333 + case ITEM_Bogus:
25.3334 + return "_top_";
25.3335 + case ITEM_Integer:
25.3336 + return "_int_";
25.3337 + case ITEM_Float:
25.3338 + return "_float_";
25.3339 + case ITEM_Double:
25.3340 + return "_double_";
25.3341 + case ITEM_Long:
25.3342 + return "_long_";
25.3343 + case ITEM_Null:
25.3344 + return "_null_";
25.3345 + case ITEM_InitObject: // UninitializedThis
25.3346 + return "_init_";
25.3347 + case ITEM_Object:
25.3348 + return "_object_";
25.3349 + case ITEM_NewObject: // Uninitialized
25.3350 + return "_new_";
25.3351 + default:
25.3352 + throw new IllegalArgumentException("Unknown type");
25.3353 + }
25.3354 + }
25.3355 +
25.3356 + @Override
25.3357 + public String toString() {
25.3358 + final StringBuilder sb = new StringBuilder("[");
25.3359 + if (size > 0) {
25.3360 + sb.append(typeString(types[0]));
25.3361 + for (int i = 1; i < size; ++i) {
25.3362 + sb.append(", ");
25.3363 + sb.append(typeString(types[i]));
25.3364 + }
25.3365 + }
25.3366 +
25.3367 + return sb.append(']').toString();
25.3368 + }
25.3369 +
25.3370 + private void ensureCapacity(final int minCapacity) {
25.3371 + if ((minCapacity == 0)
25.3372 + || (types != null) && (minCapacity <= types.length)) {
25.3373 + return;
25.3374 + }
25.3375 +
25.3376 + final int newCapacity =
25.3377 + ((minCapacity + CAPACITY_INCREMENT - 1) / CAPACITY_INCREMENT)
25.3378 + * CAPACITY_INCREMENT;
25.3379 + final int[] newTypes = new int[newCapacity];
25.3380 +
25.3381 + if (size > 0) {
25.3382 + arraycopy(types, 0, newTypes, 0, size);
25.3383 + }
25.3384 +
25.3385 + types = newTypes;
25.3386 + }
25.3387 +
25.3388 + // no System.arraycopy
25.3389 + private void arraycopy(final int[] src, final int srcPos,
25.3390 + final int[] dest, final int destPos,
25.3391 + final int length) {
25.3392 + for (int i = 0; i < length; ++i) {
25.3393 + dest[destPos + i] = src[srcPos + i];
25.3394 + }
25.3395 + }
25.3396 + }
25.3397 + /**
25.3398 + * A JavaScript ready replacement for java.util.Vector
25.3399 + *
25.3400 + * @author Jaroslav Tulach <jtulach@netbeans.org>
25.3401 + */
25.3402 + @JavaScriptPrototype(prototype = "new Array")
25.3403 + private static final class Vector {
25.3404 +
25.3405 + private Object[] arr;
25.3406 +
25.3407 + Vector() {
25.3408 + }
25.3409 +
25.3410 + Vector(int i) {
25.3411 + }
25.3412 +
25.3413 + void add(Object objectType) {
25.3414 + addElement(objectType);
25.3415 + }
25.3416 +
25.3417 + @JavaScriptBody(args = {"obj"}, body =
25.3418 + "this.push(obj);")
25.3419 + void addElement(Object obj) {
25.3420 + final int s = size();
25.3421 + setSize(s + 1);
25.3422 + setElementAt(obj, s);
25.3423 + }
25.3424 +
25.3425 + @JavaScriptBody(args = {}, body =
25.3426 + "return this.length;")
25.3427 + int size() {
25.3428 + return arr == null ? 0 : arr.length;
25.3429 + }
25.3430 +
25.3431 + @JavaScriptBody(args = {"newArr"}, body =
25.3432 + "for (var i = 0; i < this.length; i++) {\n"
25.3433 + + " newArr[i] = this[i];\n"
25.3434 + + "}\n")
25.3435 + void copyInto(Object[] newArr) {
25.3436 + if (arr == null) {
25.3437 + return;
25.3438 + }
25.3439 + int min = Math.min(newArr.length, arr.length);
25.3440 + for (int i = 0; i < min; i++) {
25.3441 + newArr[i] = arr[i];
25.3442 + }
25.3443 + }
25.3444 +
25.3445 + @JavaScriptBody(args = {"index"}, body =
25.3446 + "return this[index];")
25.3447 + Object elementAt(int index) {
25.3448 + return arr[index];
25.3449 + }
25.3450 +
25.3451 + private void setSize(int len) {
25.3452 + Object[] newArr = new Object[len];
25.3453 + copyInto(newArr);
25.3454 + arr = newArr;
25.3455 + }
25.3456 +
25.3457 + @JavaScriptBody(args = {"val", "index"}, body =
25.3458 + "this[index] = val;")
25.3459 + void setElementAt(Object val, int index) {
25.3460 + arr[index] = val;
25.3461 + }
25.3462 + }
25.3463 +
25.3464 +}
26.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Sun Mar 03 22:50:02 2013 +0100
26.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ByteCodeToJavaScript.java Mon Mar 04 19:20:40 2013 +0100
26.3 @@ -19,15 +19,7 @@
26.4
26.5 import java.io.IOException;
26.6 import java.io.InputStream;
26.7 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
26.8 -import org.apidesign.javap.AnnotationParser;
26.9 -import org.apidesign.javap.ClassData;
26.10 -import org.apidesign.javap.FieldData;
26.11 -import org.apidesign.javap.MethodData;
26.12 -import org.apidesign.javap.StackMapIterator;
26.13 -import static org.apidesign.javap.RuntimeConstants.*;
26.14 -import org.apidesign.javap.TrapData;
26.15 -import org.apidesign.javap.TrapDataIterator;
26.16 +import static org.apidesign.vm4brwsr.ByteCodeParser.*;
26.17
26.18 /** Translator of the code inside class files to JavaScript.
26.19 *
27.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/LocalsMapper.java Sun Mar 03 22:50:02 2013 +0100
27.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/LocalsMapper.java Mon Mar 04 19:20:40 2013 +0100
27.3 @@ -18,8 +18,7 @@
27.4 package org.apidesign.vm4brwsr;
27.5
27.6 import java.io.IOException;
27.7 -import org.apidesign.javap.RuntimeConstants;
27.8 -import org.apidesign.javap.TypeArray;
27.9 +import org.apidesign.vm4brwsr.ByteCodeParser.TypeArray;
27.10
27.11 final class LocalsMapper {
27.12 private final TypeArray argTypeRecords;
27.13 @@ -113,7 +112,7 @@
27.14 final int srcSize = stackMapTypes.getSize();
27.15 for (int i = 0, dstIndex = 0; i < srcSize; ++i) {
27.16 final int smType = stackMapTypes.get(i);
27.17 - if (smType == RuntimeConstants.ITEM_Bogus) {
27.18 + if (smType == ByteCodeParser.ITEM_Bogus) {
27.19 ++dstIndex;
27.20 continue;
27.21 }
28.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/StackMapper.java Sun Mar 03 22:50:02 2013 +0100
28.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/StackMapper.java Mon Mar 04 19:20:40 2013 +0100
28.3 @@ -17,7 +17,7 @@
28.4 */
28.5 package org.apidesign.vm4brwsr;
28.6
28.7 -import org.apidesign.javap.TypeArray;
28.8 +import org.apidesign.vm4brwsr.ByteCodeParser.TypeArray;
28.9
28.10 final class StackMapper {
28.11 private final TypeArray stackTypeIndexPairs;
29.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VarType.java Sun Mar 03 22:50:02 2013 +0100
29.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VarType.java Mon Mar 04 19:20:40 2013 +0100
29.3 @@ -17,8 +17,6 @@
29.4 */
29.5 package org.apidesign.vm4brwsr;
29.6
29.7 -import org.apidesign.javap.RuntimeConstants;
29.8 -
29.9 final class VarType {
29.10 public static final int INTEGER = 0;
29.11 public static final int LONG = 1;
29.12 @@ -37,21 +35,21 @@
29.13
29.14 public static int fromStackMapType(final int smType) {
29.15 switch (smType & 0xff) {
29.16 - case RuntimeConstants.ITEM_Integer:
29.17 + case ByteCodeParser.ITEM_Integer:
29.18 return VarType.INTEGER;
29.19 - case RuntimeConstants.ITEM_Float:
29.20 + case ByteCodeParser.ITEM_Float:
29.21 return VarType.FLOAT;
29.22 - case RuntimeConstants.ITEM_Double:
29.23 + case ByteCodeParser.ITEM_Double:
29.24 return VarType.DOUBLE;
29.25 - case RuntimeConstants.ITEM_Long:
29.26 + case ByteCodeParser.ITEM_Long:
29.27 return VarType.LONG;
29.28 - case RuntimeConstants.ITEM_Null:
29.29 - case RuntimeConstants.ITEM_InitObject:
29.30 - case RuntimeConstants.ITEM_Object:
29.31 - case RuntimeConstants.ITEM_NewObject:
29.32 + case ByteCodeParser.ITEM_Null:
29.33 + case ByteCodeParser.ITEM_InitObject:
29.34 + case ByteCodeParser.ITEM_Object:
29.35 + case ByteCodeParser.ITEM_NewObject:
29.36 return VarType.REFERENCE;
29.37
29.38 - case RuntimeConstants.ITEM_Bogus:
29.39 + case ByteCodeParser.ITEM_Bogus:
29.40 /* unclear how to handle for now */
29.41 default:
29.42 throw new IllegalStateException("Unhandled stack map type");
29.43 @@ -60,25 +58,25 @@
29.44
29.45 public static int fromConstantType(final byte constantTag) {
29.46 switch (constantTag) {
29.47 - case RuntimeConstants.CONSTANT_INTEGER:
29.48 + case ByteCodeParser.CONSTANT_INTEGER:
29.49 return VarType.INTEGER;
29.50 - case RuntimeConstants.CONSTANT_FLOAT:
29.51 + case ByteCodeParser.CONSTANT_FLOAT:
29.52 return VarType.FLOAT;
29.53 - case RuntimeConstants.CONSTANT_LONG:
29.54 + case ByteCodeParser.CONSTANT_LONG:
29.55 return VarType.LONG;
29.56 - case RuntimeConstants.CONSTANT_DOUBLE:
29.57 + case ByteCodeParser.CONSTANT_DOUBLE:
29.58 return VarType.DOUBLE;
29.59
29.60 - case RuntimeConstants.CONSTANT_CLASS:
29.61 - case RuntimeConstants.CONSTANT_UTF8:
29.62 - case RuntimeConstants.CONSTANT_UNICODE:
29.63 - case RuntimeConstants.CONSTANT_STRING:
29.64 + case ByteCodeParser.CONSTANT_CLASS:
29.65 + case ByteCodeParser.CONSTANT_UTF8:
29.66 + case ByteCodeParser.CONSTANT_UNICODE:
29.67 + case ByteCodeParser.CONSTANT_STRING:
29.68 return VarType.REFERENCE;
29.69
29.70 - case RuntimeConstants.CONSTANT_FIELD:
29.71 - case RuntimeConstants.CONSTANT_METHOD:
29.72 - case RuntimeConstants.CONSTANT_INTERFACEMETHOD:
29.73 - case RuntimeConstants.CONSTANT_NAMEANDTYPE:
29.74 + case ByteCodeParser.CONSTANT_FIELD:
29.75 + case ByteCodeParser.CONSTANT_METHOD:
29.76 + case ByteCodeParser.CONSTANT_INTERFACEMETHOD:
29.77 + case ByteCodeParser.CONSTANT_NAMEANDTYPE:
29.78 /* unclear how to handle for now */
29.79 default:
29.80 throw new IllegalStateException("Unhandled constant tag");