/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* See JVMS, section 4.5.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
public class ConstantPool {
super(index);
}
// i18n
return "invalid index #" + index;
}
}
super(index);
this.expected_tag = expected_tag;
}
// i18n?
return "unexpected entry at #" + index + " -- expected tag " + expected_tag + ", found " + found_tag;
}
public final int expected_tag;
public final int found_tag;
}
super(index);
}
// i18n?
}
public final int tag;
}
super(-1);
}
// i18n?
return "value not found: " + value;
}
}
public static enum RefKind {
public final int tag;
}
switch(tag) {
case 1:
return REF_getField;
case 2:
return REF_getStatic;
case 3:
return REF_putField;
case 4:
return REF_putStatic;
case 5:
return REF_invokeVirtual;
case 6:
return REF_invokeStatic;
case 7:
return REF_invokeSpecial;
case 8:
return REF_newInvokeSpecial;
case 9:
return REF_invokeInterface;
default:
return null;
}
}
}
for (int i = 1; i < count; i++) {
switch (tag) {
case CONSTANT_Class:
break;
case CONSTANT_Double:
i++;
break;
case CONSTANT_Fieldref:
break;
case CONSTANT_Float:
break;
case CONSTANT_Integer:
break;
break;
case CONSTANT_InvokeDynamic:
break;
case CONSTANT_Long:
i++;
break;
case CONSTANT_MethodHandle:
break;
case CONSTANT_MethodType:
break;
case CONSTANT_Methodref:
break;
case CONSTANT_NameAndType:
break;
case CONSTANT_String:
break;
case CONSTANT_Utf8:
break;
default:
throw new InvalidEntry(i, tag);
}
}
}
}
public int size() {
}
public int byteLength() {
int length = 2;
for (int i = 1; i < size(); ) {
}
return length;
}
throw new InvalidIndex(index);
// this occurs for indices referencing the "second half" of an
// 8 byte constant, such as CONSTANT_Double or CONSTANT_Long
throw new InvalidIndex(index);
}
}
return info;
}
}
}
public CONSTANT_NameAndType_info getNameAndTypeInfo(int index) throws InvalidIndex, UnexpectedEntry {
}
}
if (info instanceof CONSTANT_Utf8_info &&
return i;
}
throw new EntryNotFound(value);
}
public boolean hasNext() {
}
case CONSTANT_Double:
case CONSTANT_Long:
next += 2;
break;
default:
next += 1;
}
return current;
}
public void remove() {
throw new UnsupportedOperationException();
}
private int next = 1;
};
}
};
}
public interface Visitor<R,P> {
}
public static abstract class CPInfo {
CPInfo() {
}
}
public abstract int getTag();
/** The number of slots in the constant pool used by this entry.
* 2 for CONSTANT_Double and CONSTANT_Long; 1 for everything else. */
public int size() {
return 1;
}
public abstract int byteLength();
}
super(cp);
}
super(cp);
this.class_index = class_index;
}
public int getTag() {
return tag;
}
public int byteLength() {
return 5;
}
}
}
}
public final int tag;
public final int class_index;
public final int name_and_type_index;
}
super(cp);
}
super(cp);
this.name_index = name_index;
}
public int getTag() {
return CONSTANT_Class;
}
public int byteLength() {
return 3;
}
/**
* Get the raw value of the class referenced by this constant pool entry.
* This will either be the name of the class, in internal form, or a
* descriptor for an array class.
* @return the raw value of the class
*/
}
/**
* If this constant pool entry identifies either a class or interface type,
* or a possibly multi-dimensional array of a class of interface type,
* return the name of the class or interface in internal form. Otherwise,
* (i.e. if this is a possibly multi-dimensional array of a primitive type),
* return null.
* @return the base class or interface name
*/
if (index == -1)
return null;
} else
return name;
}
int count = 0;
count++;
return count;
}
}
}
public final int name_index;
}
}
}
public int getTag() {
return CONSTANT_Double;
}
public int byteLength() {
return 9;
}
public int size() {
return 2;
}
}
}
public final double value;
}
}
}
return "CONSTANT_Fieldref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
}
}
}
}
}
public int getTag() {
return CONSTANT_Float;
}
public int byteLength() {
return 5;
}
}
}
public final float value;
}
}
}
public int getTag() {
return CONSTANT_Integer;
}
public int byteLength() {
return 5;
}
}
}
public final int value;
}
}
public CONSTANT_InterfaceMethodref_info(ConstantPool cp, int class_index, int name_and_type_index) {
}
return "CONSTANT_InterfaceMethodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
}
}
}
super(cp);
}
public CONSTANT_InvokeDynamic_info(ConstantPool cp, int bootstrap_method_index, int name_and_type_index) {
super(cp);
}
public int getTag() {
return CONSTANT_InvokeDynamic;
}
public int byteLength() {
return 5;
}
return "CONSTANT_InvokeDynamic_info[bootstrap_method_index: " + bootstrap_method_attr_index + ", name_and_type_index: " + name_and_type_index + "]";
}
}
}
public final int bootstrap_method_attr_index;
public final int name_and_type_index;
}
}
}
public int getTag() {
return CONSTANT_Long;
}
public int size() {
return 2;
}
public int byteLength() {
return 9;
}
}
}
public final long value;
}
super(cp);
}
super(cp);
this.reference_kind = ref_kind;
this.reference_index = member_index;
}
public int getTag() {
return CONSTANT_MethodHandle;
}
public int byteLength() {
return 4;
}
return "CONSTANT_MethodHandle_info[ref_kind: " + reference_kind + ", member_index: " + reference_index + "]";
}
}
int expected = CONSTANT_Methodref;
// allow these tag types also:
switch (actual) {
case CONSTANT_Fieldref:
}
}
public final int reference_index;
}
super(cp);
}
super(cp);
this.descriptor_index = signature_index;
}
public int getTag() {
return CONSTANT_MethodType;
}
public int byteLength() {
return 3;
}
}
}
}
public final int descriptor_index;
}
}
}
return "CONSTANT_Methodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]";
}
}
}
super(cp);
}
super(cp);
this.name_index = name_index;
this.type_index = type_index;
}
public int getTag() {
return CONSTANT_NameAndType;
}
public int byteLength() {
return 5;
}
}
}
}
}
public final int name_index;
public final int type_index;
}
super(cp);
}
super(cp);
this.string_index = string_index;
}
public int getTag() {
return CONSTANT_String;
}
public int byteLength() {
return 3;
}
}
}
}
public final int string_index;
}
}
}
public int getTag() {
return CONSTANT_Utf8;
}
public int byteLength() {
class SizeOutputStream extends OutputStream {
public void write(int b) {
size++;
}
int size;
}
}
else
}
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c < 32 || c >= 127)
return false;
}
return true;
}
}
}
}