file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
LocalVariableTypeTable_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/LocalVariableTypeTable_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.14. * * <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 LocalVariableTypeTable_attribute extends Attribute { LocalVariableTypeTable_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); local_variable_table_length = cr.readUnsignedShort(); local_variable_table = new Entry[local_variable_table_length]; for (int i = 0; i < local_variable_table_length; i++) local_variable_table[i] = new Entry(cr); } public LocalVariableTypeTable_attribute(ConstantPool constant_pool, Entry[] local_variable_table) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.LocalVariableTypeTable), local_variable_table); } public LocalVariableTypeTable_attribute(int name_index, Entry[] local_variable_table) { super(name_index, 2 + local_variable_table.length * Entry.length()); this.local_variable_table_length = local_variable_table.length; this.local_variable_table = local_variable_table; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitLocalVariableTypeTable(this, data); } public final int local_variable_table_length; public final Entry[] local_variable_table; public static class Entry { Entry(ClassReader cr) throws IOException { start_pc = cr.readUnsignedShort(); length = cr.readUnsignedShort(); name_index = cr.readUnsignedShort(); signature_index = cr.readUnsignedShort(); index = cr.readUnsignedShort(); } public static int length() { return 10; } public final int start_pc; public final int length; public final int name_index; public final int signature_index; public final int index; } }
3,372
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java
/* * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import static com.sun.tools.classfile.Annotation.*; import static com.sun.tools.classfile.ConstantPool.*; import static com.sun.tools.classfile.StackMapTable_attribute.*; import static com.sun.tools.classfile.StackMapTable_attribute.verification_type_info.*; /** * Write a ClassFile data structure to a file or stream. * * <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 ClassWriter { public ClassWriter() { attributeWriter = new AttributeWriter(); constantPoolWriter = new ConstantPoolWriter(); out = new ClassOutputStream(); } /** * Write a ClassFile data structure to a file. */ public void write(ClassFile classFile, File f) throws IOException { FileOutputStream f_out = new FileOutputStream(f); try { write(classFile, f_out); } finally { f_out.close(); } } /** * Write a ClassFile data structure to a stream. */ public void write(ClassFile classFile, OutputStream s) throws IOException { this.classFile = classFile; out.reset(); write(); out.writeTo(s); } protected void write() throws IOException { writeHeader(); writeConstantPool(); writeAccessFlags(classFile.access_flags); writeClassInfo(); writeFields(); writeMethods(); writeAttributes(classFile.attributes); } protected void writeHeader() { out.writeInt(classFile.magic); out.writeShort(classFile.minor_version); out.writeShort(classFile.major_version); } protected void writeAccessFlags(AccessFlags flags) { out.writeShort(flags.flags); } protected void writeAttributes(Attributes attributes) { int size = attributes.size(); out.writeShort(size); for (Attribute attr: attributes) attributeWriter.write(attr, out); } protected void writeClassInfo() { out.writeShort(classFile.this_class); out.writeShort(classFile.super_class); int[] interfaces = classFile.interfaces; out.writeShort(interfaces.length); for (int i: interfaces) out.writeShort(i); } protected void writeDescriptor(Descriptor d) { out.writeShort(d.index); } protected void writeConstantPool() { ConstantPool pool = classFile.constant_pool; int size = pool.size(); out.writeShort(size); for (CPInfo cpInfo: pool.entries()) constantPoolWriter.write(cpInfo, out); } protected void writeFields() throws IOException { Field[] fields = classFile.fields; out.writeShort(fields.length); for (Field f: fields) writeField(f); } protected void writeField(Field f) throws IOException { writeAccessFlags(f.access_flags); out.writeShort(f.name_index); writeDescriptor(f.descriptor); writeAttributes(f.attributes); } protected void writeMethods() throws IOException { Method[] methods = classFile.methods; out.writeShort(methods.length); for (Method m: methods) { writeMethod(m); } } protected void writeMethod(Method m) throws IOException { writeAccessFlags(m.access_flags); out.writeShort(m.name_index); writeDescriptor(m.descriptor); writeAttributes(m.attributes); } protected ClassFile classFile; protected ClassOutputStream out; protected AttributeWriter attributeWriter; protected ConstantPoolWriter constantPoolWriter; /** * Subtype of ByteArrayOutputStream with the convenience methods of * a DataOutputStream. Since ByteArrayOutputStream does not throw * IOException, there are no exceptions from the additional * convenience methods either, */ protected static class ClassOutputStream extends ByteArrayOutputStream { public ClassOutputStream() { d = new DataOutputStream(this); } public void writeByte(int value) { try { d.writeByte(value); } catch (IOException ignore) { } } public void writeShort(int value) { try { d.writeShort(value); } catch (IOException ignore) { } } public void writeInt(int value) { try { d.writeInt(value); } catch (IOException ignore) { } } public void writeLong(long value) { try { d.writeLong(value); } catch (IOException ignore) { } } public void writeFloat(float value) { try { d.writeFloat(value); } catch (IOException ignore) { } } public void writeDouble(double value) { try { d.writeDouble(value); } catch (IOException ignore) { } } public void writeUTF(String value) { try { d.writeUTF(value); } catch (IOException ignore) { } } public void writeTo(ClassOutputStream s) { try { super.writeTo(s); } catch (IOException ignore) { } } private DataOutputStream d; } /** * Writer for the entries in the constant pool. */ protected static class ConstantPoolWriter implements ConstantPool.Visitor<Integer,ClassOutputStream> { protected int write(CPInfo info, ClassOutputStream out) { out.writeByte(info.getTag()); return info.accept(this, out); } public Integer visitClass(CONSTANT_Class_info info, ClassOutputStream out) { out.writeShort(info.name_index); return 1; } public Integer visitDouble(CONSTANT_Double_info info, ClassOutputStream out) { out.writeDouble(info.value); return 2; } public Integer visitFieldref(CONSTANT_Fieldref_info info, ClassOutputStream out) { writeRef(info, out); return 1; } public Integer visitFloat(CONSTANT_Float_info info, ClassOutputStream out) { out.writeFloat(info.value); return 1; } public Integer visitInteger(CONSTANT_Integer_info info, ClassOutputStream out) { out.writeInt(info.value); return 1; } public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, ClassOutputStream out) { writeRef(info, out); return 1; } public Integer visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, ClassOutputStream out) { out.writeShort(info.bootstrap_method_attr_index); out.writeShort(info.name_and_type_index); return 1; } public Integer visitLong(CONSTANT_Long_info info, ClassOutputStream out) { out.writeLong(info.value); return 2; } public Integer visitNameAndType(CONSTANT_NameAndType_info info, ClassOutputStream out) { out.writeShort(info.name_index); out.writeShort(info.type_index); return 1; } public Integer visitMethodHandle(CONSTANT_MethodHandle_info info, ClassOutputStream out) { out.writeByte(info.reference_kind.tag); out.writeShort(info.reference_index); return 1; } public Integer visitMethodType(CONSTANT_MethodType_info info, ClassOutputStream out) { out.writeShort(info.descriptor_index); return 1; } public Integer visitMethodref(CONSTANT_Methodref_info info, ClassOutputStream out) { return writeRef(info, out); } public Integer visitString(CONSTANT_String_info info, ClassOutputStream out) { out.writeShort(info.string_index); return 1; } public Integer visitUtf8(CONSTANT_Utf8_info info, ClassOutputStream out) { out.writeUTF(info.value); return 1; } protected Integer writeRef(CPRefInfo info, ClassOutputStream out) { out.writeShort(info.class_index); out.writeShort(info.name_and_type_index); return 1; } } /** * Writer for the different types of attribute. */ protected static class AttributeWriter implements Attribute.Visitor<Void,ClassOutputStream> { public void write(Attributes attributes, ClassOutputStream out) { int size = attributes.size(); out.writeShort(size); for (Attribute a: attributes) write(a, out); } // Note: due to the use of shared resources, this method is not reentrant. public void write(Attribute attr, ClassOutputStream out) { out.writeShort(attr.attribute_name_index); sharedOut.reset(); attr.accept(this, sharedOut); out.writeInt(sharedOut.size()); sharedOut.writeTo(out); } protected ClassOutputStream sharedOut = new ClassOutputStream(); protected AnnotationWriter annotationWriter = new AnnotationWriter(); public Void visitDefault(DefaultAttribute attr, ClassOutputStream out) { out.write(attr.info, 0, attr.info.length); return null; } public Void visitAnnotationDefault(AnnotationDefault_attribute attr, ClassOutputStream out) { annotationWriter.write(attr.default_value, out); return null; } public Void visitBootstrapMethods(BootstrapMethods_attribute attr, ClassOutputStream out) { out.writeShort(attr.bootstrap_method_specifiers.length); for (BootstrapMethods_attribute.BootstrapMethodSpecifier bsm : attr.bootstrap_method_specifiers) { out.writeShort(bsm.bootstrap_method_ref); int bsm_args_count = bsm.bootstrap_arguments.length; out.writeShort(bsm_args_count); for (int i : bsm.bootstrap_arguments) { out.writeShort(i); } } return null; } public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, ClassOutputStream out) { out.writeShort(attr.character_range_table.length); for (CharacterRangeTable_attribute.Entry e: attr.character_range_table) writeCharacterRangeTableEntry(e, out); return null; } protected void writeCharacterRangeTableEntry(CharacterRangeTable_attribute.Entry entry, ClassOutputStream out) { out.writeShort(entry.start_pc); out.writeShort(entry.end_pc); out.writeInt(entry.character_range_start); out.writeInt(entry.character_range_end); out.writeShort(entry.flags); } public Void visitCode(Code_attribute attr, ClassOutputStream out) { out.writeShort(attr.max_stack); out.writeShort(attr.max_locals); out.writeInt(attr.code.length); out.write(attr.code, 0, attr.code.length); out.writeShort(attr.exception_table.length); for (Code_attribute.Exception_data e: attr.exception_table) writeExceptionTableEntry(e, out); new AttributeWriter().write(attr.attributes, out); return null; } protected void writeExceptionTableEntry(Code_attribute.Exception_data exception_data, ClassOutputStream out) { out.writeShort(exception_data.start_pc); out.writeShort(exception_data.end_pc); out.writeShort(exception_data.handler_pc); out.writeShort(exception_data.catch_type); } public Void visitCompilationID(CompilationID_attribute attr, ClassOutputStream out) { out.writeShort(attr.compilationID_index); return null; } public Void visitConstantValue(ConstantValue_attribute attr, ClassOutputStream out) { out.writeShort(attr.constantvalue_index); return null; } public Void visitDeprecated(Deprecated_attribute attr, ClassOutputStream out) { return null; } public Void visitEnclosingMethod(EnclosingMethod_attribute attr, ClassOutputStream out) { out.writeShort(attr.class_index); out.writeShort(attr.method_index); return null; } public Void visitExceptions(Exceptions_attribute attr, ClassOutputStream out) { out.writeShort(attr.exception_index_table.length); for (int i: attr.exception_index_table) out.writeShort(i); return null; } public Void visitInnerClasses(InnerClasses_attribute attr, ClassOutputStream out) { out.writeShort(attr.classes.length); for (InnerClasses_attribute.Info info: attr.classes) writeInnerClassesInfo(info, out); return null; } protected void writeInnerClassesInfo(InnerClasses_attribute.Info info, ClassOutputStream out) { out.writeShort(info.inner_class_info_index); out.writeShort(info.outer_class_info_index); out.writeShort(info.inner_name_index); writeAccessFlags(info.inner_class_access_flags, out); } public Void visitLineNumberTable(LineNumberTable_attribute attr, ClassOutputStream out) { out.writeShort(attr.line_number_table.length); for (LineNumberTable_attribute.Entry e: attr.line_number_table) writeLineNumberTableEntry(e, out); return null; } protected void writeLineNumberTableEntry(LineNumberTable_attribute.Entry entry, ClassOutputStream out) { out.writeShort(entry.start_pc); out.writeShort(entry.line_number); } public Void visitLocalVariableTable(LocalVariableTable_attribute attr, ClassOutputStream out) { out.writeShort(attr.local_variable_table.length); for (LocalVariableTable_attribute.Entry e: attr.local_variable_table) writeLocalVariableTableEntry(e, out); return null; } protected void writeLocalVariableTableEntry(LocalVariableTable_attribute.Entry entry, ClassOutputStream out) { out.writeShort(entry.start_pc); out.writeShort(entry.length); out.writeShort(entry.name_index); out.writeShort(entry.descriptor_index); out.writeShort(entry.index); } public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, ClassOutputStream out) { out.writeShort(attr.local_variable_table.length); for (LocalVariableTypeTable_attribute.Entry e: attr.local_variable_table) writeLocalVariableTypeTableEntry(e, out); return null; } protected void writeLocalVariableTypeTableEntry(LocalVariableTypeTable_attribute.Entry entry, ClassOutputStream out) { out.writeShort(entry.start_pc); out.writeShort(entry.length); out.writeShort(entry.name_index); out.writeShort(entry.signature_index); out.writeShort(entry.index); } public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, ClassOutputStream out) { annotationWriter.write(attr.annotations, out); return null; } public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, ClassOutputStream out) { annotationWriter.write(attr.annotations, out); return null; } public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, ClassOutputStream out) { out.writeByte(attr.parameter_annotations.length); for (Annotation[] annos: attr.parameter_annotations) annotationWriter.write(annos, out); return null; } public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, ClassOutputStream out) { out.writeByte(attr.parameter_annotations.length); for (Annotation[] annos: attr.parameter_annotations) annotationWriter.write(annos, out); return null; } public Void visitSignature(Signature_attribute attr, ClassOutputStream out) { out.writeShort(attr.signature_index); return null; } public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, ClassOutputStream out) { out.write(attr.debug_extension, 0, attr.debug_extension.length); return null; } public Void visitSourceFile(SourceFile_attribute attr, ClassOutputStream out) { out.writeShort(attr.sourcefile_index); return null; } public Void visitSourceID(SourceID_attribute attr, ClassOutputStream out) { out.writeShort(attr.sourceID_index); return null; } public Void visitStackMap(StackMap_attribute attr, ClassOutputStream out) { if (stackMapWriter == null) stackMapWriter = new StackMapTableWriter(); out.writeShort(attr.entries.length); for (stack_map_frame f: attr.entries) stackMapWriter.write(f, out); return null; } public Void visitStackMapTable(StackMapTable_attribute attr, ClassOutputStream out) { if (stackMapWriter == null) stackMapWriter = new StackMapTableWriter(); out.writeShort(attr.entries.length); for (stack_map_frame f: attr.entries) stackMapWriter.write(f, out); return null; } public Void visitSynthetic(Synthetic_attribute attr, ClassOutputStream out) { return null; } protected void writeAccessFlags(AccessFlags flags, ClassOutputStream p) { sharedOut.writeShort(flags.flags); } protected StackMapTableWriter stackMapWriter; } /** * Writer for the frames of StackMap and StackMapTable attributes. */ protected static class StackMapTableWriter implements stack_map_frame.Visitor<Void,ClassOutputStream> { public void write(stack_map_frame frame, ClassOutputStream out) { out.write(frame.frame_type); frame.accept(this, out); } public Void visit_same_frame(same_frame frame, ClassOutputStream p) { return null; } public Void visit_same_locals_1_stack_item_frame(same_locals_1_stack_item_frame frame, ClassOutputStream out) { writeVerificationTypeInfo(frame.stack[0], out); return null; } public Void visit_same_locals_1_stack_item_frame_extended(same_locals_1_stack_item_frame_extended frame, ClassOutputStream out) { out.writeShort(frame.offset_delta); writeVerificationTypeInfo(frame.stack[0], out); return null; } public Void visit_chop_frame(chop_frame frame, ClassOutputStream out) { out.writeShort(frame.offset_delta); return null; } public Void visit_same_frame_extended(same_frame_extended frame, ClassOutputStream out) { out.writeShort(frame.offset_delta); return null; } public Void visit_append_frame(append_frame frame, ClassOutputStream out) { out.writeShort(frame.offset_delta); for (verification_type_info l: frame.locals) writeVerificationTypeInfo(l, out); return null; } public Void visit_full_frame(full_frame frame, ClassOutputStream out) { out.writeShort(frame.offset_delta); out.writeShort(frame.locals.length); for (verification_type_info l: frame.locals) writeVerificationTypeInfo(l, out); out.writeShort(frame.stack.length); for (verification_type_info s: frame.stack) writeVerificationTypeInfo(s, out); return null; } protected void writeVerificationTypeInfo(verification_type_info info, ClassOutputStream out) { out.write(info.tag); switch (info.tag) { case ITEM_Top: case ITEM_Integer: case ITEM_Float: case ITEM_Long: case ITEM_Double: case ITEM_Null: case ITEM_UninitializedThis: break; case ITEM_Object: Object_variable_info o = (Object_variable_info) info; out.writeShort(o.cpool_index); break; case ITEM_Uninitialized: Uninitialized_variable_info u = (Uninitialized_variable_info) info; out.writeShort(u.offset); break; default: throw new Error(); } } } /** * Writer for annotations and the values they contain. */ protected static class AnnotationWriter implements Annotation.element_value.Visitor<Void,ClassOutputStream> { public void write(Annotation[] annos, ClassOutputStream out) { out.writeShort(annos.length); for (Annotation anno: annos) write(anno, out); } public void write(Annotation anno, ClassOutputStream out) { out.writeShort(anno.type_index); out.writeShort(anno.element_value_pairs.length); for (element_value_pair p: anno.element_value_pairs) write(p, out); } public void write(element_value_pair pair, ClassOutputStream out) { out.writeShort(pair.element_name_index); write(pair.value, out); } public void write(element_value ev, ClassOutputStream out) { out.writeByte(ev.tag); ev.accept(this, out); } public Void visitPrimitive(Primitive_element_value ev, ClassOutputStream out) { out.writeShort(ev.const_value_index); return null; } public Void visitEnum(Enum_element_value ev, ClassOutputStream out) { out.writeShort(ev.type_name_index); out.writeShort(ev.const_name_index); return null; } public Void visitClass(Class_element_value ev, ClassOutputStream out) { out.writeShort(ev.class_info_index); return null; } public Void visitAnnotation(Annotation_element_value ev, ClassOutputStream out) { write(ev.annotation_value, out); return null; } public Void visitArray(Array_element_value ev, ClassOutputStream out) { out.writeShort(ev.num_values); for (element_value v: ev.values) write(v, out); return null; } } }
25,006
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassTranslator.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/ClassTranslator.java
/* * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_Double_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_Fieldref_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_Float_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_Integer_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_InterfaceMethodref_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_InvokeDynamic_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_Long_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_MethodHandle_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_MethodType_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_Methodref_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_NameAndType_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_String_info; import com.sun.tools.classfile.ConstantPool.CONSTANT_Utf8_info; import com.sun.tools.classfile.ConstantPool.CPInfo; import java.util.Map; /** * Rewrites a class file using a map of translations. * * <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 ClassTranslator implements ConstantPool.Visitor<ConstantPool.CPInfo,Map<Object,Object>> { /** * Create a new ClassFile from {@code cf}, such that for all entries * {@code k&nbsp;-\&gt;&nbsp;v} in {@code translations}, * each occurrence of {@code k} in {@code cf} will be replaced by {@code v}. * in * @param cf the class file to be processed * @param translations the set of translations to be applied * @return a copy of {@code} with the values in {@code translations} substituted */ public ClassFile translate(ClassFile cf, Map<Object,Object> translations) { ClassFile cf2 = (ClassFile) translations.get(cf); if (cf2 == null) { ConstantPool constant_pool2 = translate(cf.constant_pool, translations); Field[] fields2 = translate(cf.fields, cf.constant_pool, translations); Method[] methods2 = translateMethods(cf.methods, cf.constant_pool, translations); Attributes attributes2 = translateAttributes(cf.attributes, cf.constant_pool, translations); if (constant_pool2 == cf.constant_pool && fields2 == cf.fields && methods2 == cf.methods && attributes2 == cf.attributes) cf2 = cf; else cf2 = new ClassFile( cf.magic, cf.minor_version, cf.major_version, constant_pool2, cf.access_flags, cf.this_class, cf.super_class, cf.interfaces, fields2, methods2, attributes2); translations.put(cf, cf2); } return cf2; } ConstantPool translate(ConstantPool cp, Map<Object,Object> translations) { ConstantPool cp2 = (ConstantPool) translations.get(cp); if (cp2 == null) { ConstantPool.CPInfo[] pool2 = new ConstantPool.CPInfo[cp.size()]; boolean eq = true; for (int i = 0; i < cp.size(); ) { ConstantPool.CPInfo cpInfo; try { cpInfo = cp.get(i); } catch (ConstantPool.InvalidIndex e) { throw new IllegalStateException(e); } ConstantPool.CPInfo cpInfo2 = translate(cpInfo, translations); eq &= (cpInfo == cpInfo2); pool2[i] = cpInfo2; if (cpInfo.getTag() != cpInfo2.getTag()) throw new IllegalStateException(); i += cpInfo.size(); } if (eq) cp2 = cp; else cp2 = new ConstantPool(pool2); translations.put(cp, cp2); } return cp2; } ConstantPool.CPInfo translate(ConstantPool.CPInfo cpInfo, Map<Object,Object> translations) { ConstantPool.CPInfo cpInfo2 = (ConstantPool.CPInfo) translations.get(cpInfo); if (cpInfo2 == null) { cpInfo2 = cpInfo.accept(this, translations); translations.put(cpInfo, cpInfo2); } return cpInfo2; } Field[] translate(Field[] fields, ConstantPool constant_pool, Map<Object,Object> translations) { Field[] fields2 = (Field[]) translations.get(fields); if (fields2 == null) { fields2 = new Field[fields.length]; for (int i = 0; i < fields.length; i++) fields2[i] = translate(fields[i], constant_pool, translations); if (equal(fields, fields2)) fields2 = fields; translations.put(fields, fields2); } return fields2; } Field translate(Field field, ConstantPool constant_pool, Map<Object,Object> translations) { Field field2 = (Field) translations.get(field); if (field2 == null) { Attributes attributes2 = translateAttributes(field.attributes, constant_pool, translations); if (attributes2 == field.attributes) field2 = field; else field2 = new Field( field.access_flags, field.name_index, field.descriptor, attributes2); translations.put(field, field2); } return field2; } Method[] translateMethods(Method[] methods, ConstantPool constant_pool, Map<Object,Object> translations) { Method[] methods2 = (Method[]) translations.get(methods); if (methods2 == null) { methods2 = new Method[methods.length]; for (int i = 0; i < methods.length; i++) methods2[i] = translate(methods[i], constant_pool, translations); if (equal(methods, methods2)) methods2 = methods; translations.put(methods, methods2); } return methods2; } Method translate(Method method, ConstantPool constant_pool, Map<Object,Object> translations) { Method method2 = (Method) translations.get(method); if (method2 == null) { Attributes attributes2 = translateAttributes(method.attributes, constant_pool, translations); if (attributes2 == method.attributes) method2 = method; else method2 = new Method( method.access_flags, method.name_index, method.descriptor, attributes2); translations.put(method, method2); } return method2; } Attributes translateAttributes(Attributes attributes, ConstantPool constant_pool, Map<Object,Object> translations) { Attributes attributes2 = (Attributes) translations.get(attributes); if (attributes2 == null) { Attribute[] attrArray2 = new Attribute[attributes.size()]; ConstantPool constant_pool2 = translate(constant_pool, translations); boolean attrsEqual = true; for (int i = 0; i < attributes.size(); i++) { Attribute attr = attributes.get(i); Attribute attr2 = translate(attr, translations); if (attr2 != attr) attrsEqual = false; attrArray2[i] = attr2; } if ((constant_pool2 == constant_pool) && attrsEqual) attributes2 = attributes; else attributes2 = new Attributes(constant_pool2, attrArray2); translations.put(attributes, attributes2); } return attributes2; } Attribute translate(Attribute attribute, Map<Object,Object> translations) { Attribute attribute2 = (Attribute) translations.get(attribute); if (attribute2 == null) { attribute2 = attribute; // don't support translation within attributes yet // (what about Code attribute) translations.put(attribute, attribute2); } return attribute2; } private static <T> boolean equal(T[] a1, T[] a2) { if (a1 == null || a2 == null) return (a1 == a2); if (a1.length != a2.length) return false; for (int i = 0; i < a1.length; i++) { if (a1[i] != a2[i]) return false; } return true; } public CPInfo visitClass(CONSTANT_Class_info info, Map<Object, Object> translations) { CONSTANT_Class_info info2 = (CONSTANT_Class_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) info2 = info; else info2 = new CONSTANT_Class_info(cp2, info.name_index); translations.put(info, info2); } return info; } public CPInfo visitDouble(CONSTANT_Double_info info, Map<Object, Object> translations) { CONSTANT_Double_info info2 = (CONSTANT_Double_info) translations.get(info); if (info2 == null) { info2 = info; translations.put(info, info2); } return info; } public CPInfo visitFieldref(CONSTANT_Fieldref_info info, Map<Object, Object> translations) { CONSTANT_Fieldref_info info2 = (CONSTANT_Fieldref_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) info2 = info; else info2 = new CONSTANT_Fieldref_info(cp2, info.class_index, info.name_and_type_index); translations.put(info, info2); } return info; } public CPInfo visitFloat(CONSTANT_Float_info info, Map<Object, Object> translations) { CONSTANT_Float_info info2 = (CONSTANT_Float_info) translations.get(info); if (info2 == null) { info2 = info; translations.put(info, info2); } return info; } public CPInfo visitInteger(CONSTANT_Integer_info info, Map<Object, Object> translations) { CONSTANT_Integer_info info2 = (CONSTANT_Integer_info) translations.get(info); if (info2 == null) { info2 = info; translations.put(info, info2); } return info; } public CPInfo visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Map<Object, Object> translations) { CONSTANT_InterfaceMethodref_info info2 = (CONSTANT_InterfaceMethodref_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) info2 = info; else info2 = new CONSTANT_InterfaceMethodref_info(cp2, info.class_index, info.name_and_type_index); translations.put(info, info2); } return info; } public CPInfo visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Map<Object, Object> translations) { CONSTANT_InvokeDynamic_info info2 = (CONSTANT_InvokeDynamic_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) { info2 = info; } else { info2 = new CONSTANT_InvokeDynamic_info(cp2, info.bootstrap_method_attr_index, info.name_and_type_index); } translations.put(info, info2); } return info; } public CPInfo visitLong(CONSTANT_Long_info info, Map<Object, Object> translations) { CONSTANT_Long_info info2 = (CONSTANT_Long_info) translations.get(info); if (info2 == null) { info2 = info; translations.put(info, info2); } return info; } public CPInfo visitNameAndType(CONSTANT_NameAndType_info info, Map<Object, Object> translations) { CONSTANT_NameAndType_info info2 = (CONSTANT_NameAndType_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) info2 = info; else info2 = new CONSTANT_NameAndType_info(cp2, info.name_index, info.type_index); translations.put(info, info2); } return info; } public CPInfo visitMethodref(CONSTANT_Methodref_info info, Map<Object, Object> translations) { CONSTANT_Methodref_info info2 = (CONSTANT_Methodref_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) info2 = info; else info2 = new CONSTANT_Methodref_info(cp2, info.class_index, info.name_and_type_index); translations.put(info, info2); } return info; } public CPInfo visitMethodHandle(CONSTANT_MethodHandle_info info, Map<Object, Object> translations) { CONSTANT_MethodHandle_info info2 = (CONSTANT_MethodHandle_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) { info2 = info; } else { info2 = new CONSTANT_MethodHandle_info(cp2, info.reference_kind, info.reference_index); } translations.put(info, info2); } return info; } public CPInfo visitMethodType(CONSTANT_MethodType_info info, Map<Object, Object> translations) { CONSTANT_MethodType_info info2 = (CONSTANT_MethodType_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) { info2 = info; } else { info2 = new CONSTANT_MethodType_info(cp2, info.descriptor_index); } translations.put(info, info2); } return info; } public CPInfo visitString(CONSTANT_String_info info, Map<Object, Object> translations) { CONSTANT_String_info info2 = (CONSTANT_String_info) translations.get(info); if (info2 == null) { ConstantPool cp2 = translate(info.cp, translations); if (cp2 == info.cp) info2 = info; else info2 = new CONSTANT_String_info(cp2, info.string_index); translations.put(info, info2); } return info; } public CPInfo visitUtf8(CONSTANT_Utf8_info info, Map<Object, Object> translations) { CONSTANT_Utf8_info info2 = (CONSTANT_Utf8_info) translations.get(info); if (info2 == null) { info2 = info; translations.put(info, info2); } return info; } }
16,687
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassReader.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/ClassReader.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; /** * <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 ClassReader { ClassReader(ClassFile classFile, InputStream in, Attribute.Factory attributeFactory) throws IOException { // null checks classFile.getClass(); attributeFactory.getClass(); this.classFile = classFile; this.in = new DataInputStream(new BufferedInputStream(in)); this.attributeFactory = attributeFactory; } ClassFile getClassFile() { return classFile; } ConstantPool getConstantPool() { return classFile.constant_pool; } public Attribute readAttribute() throws IOException { int name_index = readUnsignedShort(); int length = readInt(); byte[] data = new byte[length]; readFully(data); DataInputStream prev = in; in = new DataInputStream(new ByteArrayInputStream(data)); try { return attributeFactory.createAttribute(this, name_index, data); } finally { in = prev; } } public void readFully(byte[] b) throws IOException { in.readFully(b); } public int readUnsignedByte() throws IOException { return in.readUnsignedByte(); } public int readUnsignedShort() throws IOException { return in.readUnsignedShort(); } public int readInt() throws IOException { return in.readInt(); } public long readLong() throws IOException { return in.readLong(); } public float readFloat() throws IOException { return in.readFloat(); } public double readDouble() throws IOException { return in.readDouble(); } public String readUTF() throws IOException { return in.readUTF(); } private DataInputStream in; private ClassFile classFile; private Attribute.Factory attributeFactory; }
3,467
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Signature.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Signature.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.util.ArrayList; import java.util.List; import com.sun.tools.classfile.Type.*; /** * See JVMS 4.4.4. * * <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 Signature extends Descriptor { public Signature(int index) { super(index); } public Type getType(ConstantPool constant_pool) throws ConstantPoolException { if (type == null) type = parse(getValue(constant_pool)); return type; } @Override public int getParameterCount(ConstantPool constant_pool) throws ConstantPoolException { MethodType m = (MethodType) getType(constant_pool); return m.paramTypes.size(); } @Override public String getParameterTypes(ConstantPool constant_pool) throws ConstantPoolException { MethodType m = (MethodType) getType(constant_pool); StringBuilder sb = new StringBuilder(); sb.append("("); String sep = ""; for (Type paramType: m.paramTypes) { sb.append(sep); sb.append(paramType); sep = ", "; } sb.append(")"); return sb.toString(); } @Override public String getReturnType(ConstantPool constant_pool) throws ConstantPoolException { MethodType m = (MethodType) getType(constant_pool); return m.returnType.toString(); } @Override public String getFieldType(ConstantPool constant_pool) throws ConstantPoolException { return getType(constant_pool).toString(); } private Type parse(String sig) { this.sig = sig; sigp = 0; List<TypeParamType> typeParamTypes = null; if (sig.charAt(sigp) == '<') typeParamTypes = parseTypeParamTypes(); if (sig.charAt(sigp) == '(') { List<Type> paramTypes = parseTypeSignatures(')'); Type returnType = parseTypeSignature(); List<Type> throwsTypes = null; while (sigp < sig.length() && sig.charAt(sigp) == '^') { sigp++; if (throwsTypes == null) throwsTypes = new ArrayList<Type>(); throwsTypes.add(parseTypeSignature()); } return new MethodType(typeParamTypes, paramTypes, returnType, throwsTypes); } else { Type t = parseTypeSignature(); if (typeParamTypes == null && sigp == sig.length()) return t; Type superclass = t; List<Type> superinterfaces = null; while (sigp < sig.length()) { if (superinterfaces == null) superinterfaces = new ArrayList<Type>(); superinterfaces.add(parseTypeSignature()); } return new ClassSigType(typeParamTypes, superclass, superinterfaces); } } private Type parseTypeSignature() { switch (sig.charAt(sigp)) { case 'B': sigp++; return new SimpleType("byte"); case 'C': sigp++; return new SimpleType("char"); case 'D': sigp++; return new SimpleType("double"); case 'F': sigp++; return new SimpleType("float"); case 'I': sigp++; return new SimpleType("int"); case 'J': sigp++; return new SimpleType("long"); case 'L': return parseClassTypeSignature(); case 'S': sigp++; return new SimpleType("short"); case 'T': return parseTypeVariableSignature(); case 'V': sigp++; return new SimpleType("void"); case 'Z': sigp++; return new SimpleType("boolean"); case '[': sigp++; return new ArrayType(parseTypeSignature()); case '*': sigp++; return new WildcardType(); case '+': sigp++; return new WildcardType(WildcardType.Kind.EXTENDS, parseTypeSignature()); case '-': sigp++; return new WildcardType(WildcardType.Kind.SUPER, parseTypeSignature()); default: throw new IllegalStateException(debugInfo()); } } private List<Type> parseTypeSignatures(char term) { sigp++; List<Type> types = new ArrayList<Type>(); while (sig.charAt(sigp) != term) types.add(parseTypeSignature()); sigp++; return types; } private Type parseClassTypeSignature() { assert sig.charAt(sigp) == 'L'; sigp++; return parseClassTypeSignatureRest(); } private Type parseClassTypeSignatureRest() { StringBuilder sb = new StringBuilder(); List<Type> argTypes = null; ClassType t = null; char sigch ; do { switch (sigch = sig.charAt(sigp)) { case '<': argTypes = parseTypeSignatures('>'); break; case '.': case ';': sigp++; t = new ClassType(t, sb.toString(), argTypes); sb.setLength(0); argTypes = null; break; default: sigp++; sb.append(sigch); break; } } while (sigch != ';'); return t; } private List<TypeParamType> parseTypeParamTypes() { assert sig.charAt(sigp) == '<'; sigp++; List<TypeParamType> types = new ArrayList<TypeParamType>(); while (sig.charAt(sigp) != '>') types.add(parseTypeParamType()); sigp++; return types; } private TypeParamType parseTypeParamType() { int sep = sig.indexOf(":", sigp); String name = sig.substring(sigp, sep); Type classBound = null; List<Type> interfaceBounds = null; sigp = sep + 1; if (sig.charAt(sigp) != ':') classBound = parseTypeSignature(); while (sig.charAt(sigp) == ':') { sigp++; if (interfaceBounds == null) interfaceBounds = new ArrayList<Type>(); interfaceBounds.add(parseTypeSignature()); } return new TypeParamType(name, classBound, interfaceBounds); } private Type parseTypeVariableSignature() { sigp++; int sep = sig.indexOf(';', sigp); Type t = new SimpleType(sig.substring(sigp, sep)); sigp = sep + 1; return t; } private String debugInfo() { return sig.substring(0, sigp) + "!" + sig.charAt(sigp) + "!" + sig.substring(sigp+1); } private String sig; private int sigp; private Type type; }
8,453
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SourceDebugExtension_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/SourceDebugExtension_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; /** * See JVMS, section 4.8.15. * * <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 SourceDebugExtension_attribute extends Attribute { SourceDebugExtension_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); debug_extension = new byte[attribute_length]; cr.readFully(debug_extension); } public SourceDebugExtension_attribute(ConstantPool constant_pool, byte[] debug_extension) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.SourceDebugExtension), debug_extension); } public SourceDebugExtension_attribute(int name_index, byte[] debug_extension) { super(name_index, debug_extension.length); this.debug_extension = debug_extension; } public String getValue() { DataInputStream d = new DataInputStream(new ByteArrayInputStream(debug_extension)); try { return d.readUTF(); } catch (IOException e) { return null; } } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitSourceDebugExtension(this, data); } public final byte[] debug_extension; }
2,749
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RuntimeVisibleAnnotations_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/RuntimeVisibleAnnotations_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.16. * * <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 RuntimeVisibleAnnotations_attribute extends RuntimeAnnotations_attribute { RuntimeVisibleAnnotations_attribute(ClassReader cr, int name_index, int length) throws IOException, Annotation.InvalidAnnotation { super(cr, name_index, length); } public RuntimeVisibleAnnotations_attribute(ConstantPool cp, Annotation[] annotations) throws ConstantPoolException { this(cp.getUTF8Index(Attribute.RuntimeVisibleAnnotations), annotations); } public RuntimeVisibleAnnotations_attribute(int name_index, Annotation[] annotations) { super(name_index, annotations); } public <R, P> R accept(Visitor<R, P> visitor, P p) { return visitor.visitRuntimeVisibleAnnotations(this, p); } }
2,307
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Deprecated_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Deprecated_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.15. * * <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 Deprecated_attribute extends Attribute { Deprecated_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); } public Deprecated_attribute(ConstantPool constant_pool) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.Deprecated)); } public Deprecated_attribute(int name_index) { super(name_index, 0); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitDeprecated(this, data); } }
2,105
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DefaultAttribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/DefaultAttribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; /* * <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 DefaultAttribute extends Attribute { DefaultAttribute(ClassReader cr, int name_index, byte[] data) { super(name_index, data.length); info = data; } public DefaultAttribute(ConstantPool constant_pool, int name_index, byte[] info) { super(name_index, info.length); this.info = info; } public <R, P> R accept(Visitor<R, P> visitor, P p) { return visitor.visitDefault(this, p); } public final byte[] info; }
1,964
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Attributes.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Attributes.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /* * <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 Attributes implements Iterable<Attribute> { Attributes(ClassReader cr) throws IOException { map = new HashMap<String,Attribute>(); int attrs_count = cr.readUnsignedShort(); attrs = new Attribute[attrs_count]; for (int i = 0; i < attrs_count; i++) { Attribute attr = Attribute.read(cr); attrs[i] = attr; try { map.put(attr.getName(cr.getConstantPool()), attr); } catch (ConstantPoolException e) { // don't enter invalid names in map } } } public Attributes(ConstantPool constant_pool, Attribute[] attrs) { this.attrs = attrs; map = new HashMap<String,Attribute>(); for (int i = 0; i < attrs.length; i++) { Attribute attr = attrs[i]; try { map.put(attr.getName(constant_pool), attr); } catch (ConstantPoolException e) { // don't enter invalid names in map } } } public Iterator<Attribute> iterator() { return Arrays.asList(attrs).iterator(); } public Attribute get(int index) { return attrs[index]; } public Attribute get(String name) { return map.get(name); } public int getIndex(ConstantPool constant_pool, String name) { for (int i = 0; i < attrs.length; i++) { Attribute attr = attrs[i]; try { if (attr != null && attr.getName(constant_pool).equals(name)) return i; } catch (ConstantPoolException e) { // ignore invalid entries } } return -1; } public int size() { return attrs.length; } public int byteLength() { int length = 2; for (Attribute a: attrs) length += a.byteLength(); return length; } public final Attribute[] attrs; public final Map<String, Attribute> map; }
3,609
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstantPool.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java
/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.Iterator; /** * 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 { public static class InvalidIndex extends ConstantPoolException { private static final long serialVersionUID = -4350294289300939730L; InvalidIndex(int index) { super(index); } @Override public String getMessage() { // i18n return "invalid index #" + index; } } public static class UnexpectedEntry extends ConstantPoolException { private static final long serialVersionUID = 6986335935377933211L; UnexpectedEntry(int index, int expected_tag, int found_tag) { super(index); this.expected_tag = expected_tag; this.found_tag = found_tag; } @Override public String getMessage() { // i18n? return "unexpected entry at #" + index + " -- expected tag " + expected_tag + ", found " + found_tag; } public final int expected_tag; public final int found_tag; } public static class InvalidEntry extends ConstantPoolException { private static final long serialVersionUID = 1000087545585204447L; InvalidEntry(int index, int tag) { super(index); this.tag = tag; } @Override public String getMessage() { // i18n? return "unexpected tag at #" + index + ": " + tag; } public final int tag; } public static class EntryNotFound extends ConstantPoolException { private static final long serialVersionUID = 2885537606468581850L; EntryNotFound(Object value) { super(-1); this.value = value; } @Override public String getMessage() { // i18n? return "value not found: " + value; } public final Object value; } public static final int CONSTANT_Utf8 = 1; public static final int CONSTANT_Integer = 3; public static final int CONSTANT_Float = 4; public static final int CONSTANT_Long = 5; public static final int CONSTANT_Double = 6; public static final int CONSTANT_Class = 7; public static final int CONSTANT_String = 8; public static final int CONSTANT_Fieldref = 9; public static final int CONSTANT_Methodref = 10; public static final int CONSTANT_InterfaceMethodref = 11; public static final int CONSTANT_NameAndType = 12; public static final int CONSTANT_MethodHandle = 15; public static final int CONSTANT_MethodType = 16; public static final int CONSTANT_InvokeDynamic = 18; public static enum RefKind { REF_getField(1, "getfield"), REF_getStatic(2, "getstatic"), REF_putField(3, "putfield"), REF_putStatic(4, "putstatic"), REF_invokeVirtual(5, "invokevirtual"), REF_invokeStatic(6, "invokestatic"), REF_invokeSpecial(7, "invokespecial"), REF_newInvokeSpecial(8, "newinvokespecial"), REF_invokeInterface(9, "invokeinterface"); public final int tag; public final String name; RefKind(int tag, String name) { this.tag = tag; this.name = name; } static RefKind getRefkind(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; } } } ConstantPool(ClassReader cr) throws IOException, InvalidEntry { int count = cr.readUnsignedShort(); pool = new CPInfo[count]; for (int i = 1; i < count; i++) { int tag = cr.readUnsignedByte(); switch (tag) { case CONSTANT_Class: pool[i] = new CONSTANT_Class_info(this, cr); break; case CONSTANT_Double: pool[i] = new CONSTANT_Double_info(cr); i++; break; case CONSTANT_Fieldref: pool[i] = new CONSTANT_Fieldref_info(this, cr); break; case CONSTANT_Float: pool[i] = new CONSTANT_Float_info(cr); break; case CONSTANT_Integer: pool[i] = new CONSTANT_Integer_info(cr); break; case CONSTANT_InterfaceMethodref: pool[i] = new CONSTANT_InterfaceMethodref_info(this, cr); break; case CONSTANT_InvokeDynamic: pool[i] = new CONSTANT_InvokeDynamic_info(this, cr); break; case CONSTANT_Long: pool[i] = new CONSTANT_Long_info(cr); i++; break; case CONSTANT_MethodHandle: pool[i] = new CONSTANT_MethodHandle_info(this, cr); break; case CONSTANT_MethodType: pool[i] = new CONSTANT_MethodType_info(this, cr); break; case CONSTANT_Methodref: pool[i] = new CONSTANT_Methodref_info(this, cr); break; case CONSTANT_NameAndType: pool[i] = new CONSTANT_NameAndType_info(this, cr); break; case CONSTANT_String: pool[i] = new CONSTANT_String_info(this, cr); break; case CONSTANT_Utf8: pool[i] = new CONSTANT_Utf8_info(cr); break; default: throw new InvalidEntry(i, tag); } } } public ConstantPool(CPInfo[] pool) { this.pool = pool; } public int size() { return pool.length; } public int byteLength() { int length = 2; for (int i = 1; i < size(); ) { CPInfo cpInfo = pool[i]; length += cpInfo.byteLength(); i += cpInfo.size(); } return length; } public CPInfo get(int index) throws InvalidIndex { if (index <= 0 || index >= pool.length) throw new InvalidIndex(index); CPInfo info = pool[index]; if (info == null) { // 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 pool[index]; } private CPInfo get(int index, int expected_type) throws InvalidIndex, UnexpectedEntry { CPInfo info = get(index); if (info.getTag() != expected_type) throw new UnexpectedEntry(index, expected_type, info.getTag()); return info; } public CONSTANT_Utf8_info getUTF8Info(int index) throws InvalidIndex, UnexpectedEntry { return ((CONSTANT_Utf8_info) get(index, CONSTANT_Utf8)); } public CONSTANT_Class_info getClassInfo(int index) throws InvalidIndex, UnexpectedEntry { return ((CONSTANT_Class_info) get(index, CONSTANT_Class)); } public CONSTANT_NameAndType_info getNameAndTypeInfo(int index) throws InvalidIndex, UnexpectedEntry { return ((CONSTANT_NameAndType_info) get(index, CONSTANT_NameAndType)); } public String getUTF8Value(int index) throws InvalidIndex, UnexpectedEntry { return getUTF8Info(index).value; } public int getUTF8Index(String value) throws EntryNotFound { for (int i = 1; i < pool.length; i++) { CPInfo info = pool[i]; if (info instanceof CONSTANT_Utf8_info && ((CONSTANT_Utf8_info) info).value.equals(value)) return i; } throw new EntryNotFound(value); } public Iterable<CPInfo> entries() { return new Iterable<CPInfo>() { public Iterator<CPInfo> iterator() { return new Iterator<CPInfo>() { public boolean hasNext() { return next < pool.length; } public CPInfo next() { current = pool[next]; switch (current.getTag()) { case CONSTANT_Double: case CONSTANT_Long: next += 2; break; default: next += 1; } return current; } public void remove() { throw new UnsupportedOperationException(); } private CPInfo current; private int next = 1; }; } }; } private CPInfo[] pool; public interface Visitor<R,P> { R visitClass(CONSTANT_Class_info info, P p); R visitDouble(CONSTANT_Double_info info, P p); R visitFieldref(CONSTANT_Fieldref_info info, P p); R visitFloat(CONSTANT_Float_info info, P p); R visitInteger(CONSTANT_Integer_info info, P p); R visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, P p); R visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, P p); R visitLong(CONSTANT_Long_info info, P p); R visitNameAndType(CONSTANT_NameAndType_info info, P p); R visitMethodref(CONSTANT_Methodref_info info, P p); R visitMethodHandle(CONSTANT_MethodHandle_info info, P p); R visitMethodType(CONSTANT_MethodType_info info, P p); R visitString(CONSTANT_String_info info, P p); R visitUtf8(CONSTANT_Utf8_info info, P p); } public static abstract class CPInfo { CPInfo() { this.cp = null; } CPInfo(ConstantPool cp) { this.cp = cp; } 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(); public abstract <R,D> R accept(Visitor<R,D> visitor, D data); protected final ConstantPool cp; } public static abstract class CPRefInfo extends CPInfo { protected CPRefInfo(ConstantPool cp, ClassReader cr, int tag) throws IOException { super(cp); this.tag = tag; class_index = cr.readUnsignedShort(); name_and_type_index = cr.readUnsignedShort(); } protected CPRefInfo(ConstantPool cp, int tag, int class_index, int name_and_type_index) { super(cp); this.tag = tag; this.class_index = class_index; this.name_and_type_index = name_and_type_index; } public int getTag() { return tag; } public int byteLength() { return 5; } public CONSTANT_Class_info getClassInfo() throws ConstantPoolException { return cp.getClassInfo(class_index); } public String getClassName() throws ConstantPoolException { return cp.getClassInfo(class_index).getName(); } public CONSTANT_NameAndType_info getNameAndTypeInfo() throws ConstantPoolException { return cp.getNameAndTypeInfo(name_and_type_index); } public final int tag; public final int class_index; public final int name_and_type_index; } public static class CONSTANT_Class_info extends CPInfo { CONSTANT_Class_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp); name_index = cr.readUnsignedShort(); } public CONSTANT_Class_info(ConstantPool cp, int name_index) { 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 */ public String getName() throws ConstantPoolException { return cp.getUTF8Value(name_index); } /** * 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 */ public String getBaseName() throws ConstantPoolException { String name = getName(); if (name.startsWith("[")) { int index = name.indexOf("[L"); if (index == -1) return null; return name.substring(index + 2, name.length() - 1); } else return name; } public int getDimensionCount() throws ConstantPoolException { String name = getName(); int count = 0; while (name.charAt(count) == '[') count++; return count; } @Override public String toString() { return "CONSTANT_Class_info[name_index: " + name_index + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitClass(this, data); } public final int name_index; } public static class CONSTANT_Double_info extends CPInfo { CONSTANT_Double_info(ClassReader cr) throws IOException { value = cr.readDouble(); } public CONSTANT_Double_info(double value) { this.value = value; } public int getTag() { return CONSTANT_Double; } public int byteLength() { return 9; } @Override public int size() { return 2; } @Override public String toString() { return "CONSTANT_Double_info[value: " + value + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitDouble(this, data); } public final double value; } public static class CONSTANT_Fieldref_info extends CPRefInfo { CONSTANT_Fieldref_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp, cr, CONSTANT_Fieldref); } public CONSTANT_Fieldref_info(ConstantPool cp, int class_index, int name_and_type_index) { super(cp, CONSTANT_Fieldref, class_index, name_and_type_index); } @Override public String toString() { return "CONSTANT_Fieldref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitFieldref(this, data); } } public static class CONSTANT_Float_info extends CPInfo { CONSTANT_Float_info(ClassReader cr) throws IOException { value = cr.readFloat(); } public CONSTANT_Float_info(float value) { this.value = value; } public int getTag() { return CONSTANT_Float; } public int byteLength() { return 5; } @Override public String toString() { return "CONSTANT_Float_info[value: " + value + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitFloat(this, data); } public final float value; } public static class CONSTANT_Integer_info extends CPInfo { CONSTANT_Integer_info(ClassReader cr) throws IOException { value = cr.readInt(); } public CONSTANT_Integer_info(int value) { this.value = value; } public int getTag() { return CONSTANT_Integer; } public int byteLength() { return 5; } @Override public String toString() { return "CONSTANT_Integer_info[value: " + value + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitInteger(this, data); } public final int value; } public static class CONSTANT_InterfaceMethodref_info extends CPRefInfo { CONSTANT_InterfaceMethodref_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp, cr, CONSTANT_InterfaceMethodref); } public CONSTANT_InterfaceMethodref_info(ConstantPool cp, int class_index, int name_and_type_index) { super(cp, CONSTANT_InterfaceMethodref, class_index, name_and_type_index); } @Override public String toString() { return "CONSTANT_InterfaceMethodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitInterfaceMethodref(this, data); } } public static class CONSTANT_InvokeDynamic_info extends CPInfo { CONSTANT_InvokeDynamic_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp); bootstrap_method_attr_index = cr.readUnsignedShort(); name_and_type_index = cr.readUnsignedShort(); } public CONSTANT_InvokeDynamic_info(ConstantPool cp, int bootstrap_method_index, int name_and_type_index) { super(cp); this.bootstrap_method_attr_index = bootstrap_method_index; this.name_and_type_index = name_and_type_index; } public int getTag() { return CONSTANT_InvokeDynamic; } public int byteLength() { return 5; } @Override public String toString() { return "CONSTANT_InvokeDynamic_info[bootstrap_method_index: " + bootstrap_method_attr_index + ", name_and_type_index: " + name_and_type_index + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitInvokeDynamic(this, data); } public CONSTANT_NameAndType_info getNameAndTypeInfo() throws ConstantPoolException { return cp.getNameAndTypeInfo(name_and_type_index); } public final int bootstrap_method_attr_index; public final int name_and_type_index; } public static class CONSTANT_Long_info extends CPInfo { CONSTANT_Long_info(ClassReader cr) throws IOException { value = cr.readLong(); } public CONSTANT_Long_info(long value) { this.value = value; } public int getTag() { return CONSTANT_Long; } @Override public int size() { return 2; } public int byteLength() { return 9; } @Override public String toString() { return "CONSTANT_Long_info[value: " + value + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitLong(this, data); } public final long value; } public static class CONSTANT_MethodHandle_info extends CPInfo { CONSTANT_MethodHandle_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp); reference_kind = RefKind.getRefkind(cr.readUnsignedByte()); reference_index = cr.readUnsignedShort(); } public CONSTANT_MethodHandle_info(ConstantPool cp, RefKind ref_kind, int member_index) { super(cp); this.reference_kind = ref_kind; this.reference_index = member_index; } public int getTag() { return CONSTANT_MethodHandle; } public int byteLength() { return 4; } @Override public String toString() { return "CONSTANT_MethodHandle_info[ref_kind: " + reference_kind + ", member_index: " + reference_index + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitMethodHandle(this, data); } public CPRefInfo getCPRefInfo() throws ConstantPoolException { int expected = CONSTANT_Methodref; int actual = cp.get(reference_index).getTag(); // allow these tag types also: switch (actual) { case CONSTANT_Fieldref: case CONSTANT_InterfaceMethodref: expected = actual; } return (CPRefInfo) cp.get(reference_index, expected); } public final RefKind reference_kind; public final int reference_index; } public static class CONSTANT_MethodType_info extends CPInfo { CONSTANT_MethodType_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp); descriptor_index = cr.readUnsignedShort(); } public CONSTANT_MethodType_info(ConstantPool cp, int signature_index) { super(cp); this.descriptor_index = signature_index; } public int getTag() { return CONSTANT_MethodType; } public int byteLength() { return 3; } @Override public String toString() { return "CONSTANT_MethodType_info[signature_index: " + descriptor_index + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitMethodType(this, data); } public String getType() throws ConstantPoolException { return cp.getUTF8Value(descriptor_index); } public final int descriptor_index; } public static class CONSTANT_Methodref_info extends CPRefInfo { CONSTANT_Methodref_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp, cr, CONSTANT_Methodref); } public CONSTANT_Methodref_info(ConstantPool cp, int class_index, int name_and_type_index) { super(cp, CONSTANT_Methodref, class_index, name_and_type_index); } @Override public String toString() { return "CONSTANT_Methodref_info[class_index: " + class_index + ", name_and_type_index: " + name_and_type_index + "]"; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitMethodref(this, data); } } public static class CONSTANT_NameAndType_info extends CPInfo { CONSTANT_NameAndType_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp); name_index = cr.readUnsignedShort(); type_index = cr.readUnsignedShort(); } public CONSTANT_NameAndType_info(ConstantPool cp, int name_index, int type_index) { super(cp); this.name_index = name_index; this.type_index = type_index; } public int getTag() { return CONSTANT_NameAndType; } public int byteLength() { return 5; } public String getName() throws ConstantPoolException { return cp.getUTF8Value(name_index); } public String getType() throws ConstantPoolException { return cp.getUTF8Value(type_index); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitNameAndType(this, data); } @Override public String toString() { return "CONSTANT_NameAndType_info[name_index: " + name_index + ", type_index: " + type_index + "]"; } public final int name_index; public final int type_index; } public static class CONSTANT_String_info extends CPInfo { CONSTANT_String_info(ConstantPool cp, ClassReader cr) throws IOException { super(cp); string_index = cr.readUnsignedShort(); } public CONSTANT_String_info(ConstantPool cp, int string_index) { super(cp); this.string_index = string_index; } public int getTag() { return CONSTANT_String; } public int byteLength() { return 3; } public String getString() throws ConstantPoolException { return cp.getUTF8Value(string_index); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitString(this, data); } @Override public String toString() { return "CONSTANT_String_info[class_index: " + string_index + "]"; } public final int string_index; } public static class CONSTANT_Utf8_info extends CPInfo { CONSTANT_Utf8_info(ClassReader cr) throws IOException { value = cr.readUTF(); } public CONSTANT_Utf8_info(String value) { this.value = value; } public int getTag() { return CONSTANT_Utf8; } public int byteLength() { class SizeOutputStream extends OutputStream { @Override public void write(int b) { size++; } int size; } SizeOutputStream sizeOut = new SizeOutputStream(); DataOutputStream out = new DataOutputStream(sizeOut); try { out.writeUTF(value); } catch (IOException ignore) { } return 1 + sizeOut.size; } @Override public String toString() { if (value.length() < 32 && isPrintableAscii(value)) return "CONSTANT_Utf8_info[value: \"" + value + "\"]"; else return "CONSTANT_Utf8_info[value: (" + value.length() + " chars)]"; } static boolean isPrintableAscii(String s) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c < 32 || c >= 127) return false; } return true; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitUtf8(this, data); } public final String value; } }
28,955
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Annotation.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Annotation.java
/* * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.16. * * <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 Annotation { static class InvalidAnnotation extends AttributeException { private static final long serialVersionUID = -4620480740735772708L; InvalidAnnotation(String msg) { super(msg); } } Annotation(ClassReader cr) throws IOException, InvalidAnnotation { type_index = cr.readUnsignedShort(); num_element_value_pairs = cr.readUnsignedShort(); element_value_pairs = new element_value_pair[num_element_value_pairs]; for (int i = 0; i < element_value_pairs.length; i++) element_value_pairs[i] = new element_value_pair(cr); } public Annotation(ConstantPool constant_pool, int type_index, element_value_pair[] element_value_pairs) { this.type_index = type_index; num_element_value_pairs = element_value_pairs.length; this.element_value_pairs = element_value_pairs; } public int length() { int n = 2 /*type_index*/ + 2 /*num_element_value_pairs*/; for (element_value_pair pair: element_value_pairs) n += pair.length(); return n; } public final int type_index; public final int num_element_value_pairs; public final element_value_pair element_value_pairs[]; /** * See JVMS, section 4.8.16.1. */ public static abstract class element_value { public static element_value read(ClassReader cr) throws IOException, InvalidAnnotation { int tag = cr.readUnsignedByte(); switch (tag) { case 'B': case 'C': case 'D': case 'F': case 'I': case 'J': case 'S': case 'Z': case 's': return new Primitive_element_value(cr, tag); case 'e': return new Enum_element_value(cr, tag); case 'c': return new Class_element_value(cr, tag); case '@': return new Annotation_element_value(cr, tag); case '[': return new Array_element_value(cr, tag); default: throw new InvalidAnnotation("unrecognized tag: " + tag); } } protected element_value(int tag) { this.tag = tag; } public abstract int length(); public abstract <R,P> R accept(Visitor<R,P> visitor, P p); public interface Visitor<R,P> { R visitPrimitive(Primitive_element_value ev, P p); R visitEnum(Enum_element_value ev, P p); R visitClass(Class_element_value ev, P p); R visitAnnotation(Annotation_element_value ev, P p); R visitArray(Array_element_value ev, P p); } public final int tag; } public static class Primitive_element_value extends element_value { Primitive_element_value(ClassReader cr, int tag) throws IOException { super(tag); const_value_index = cr.readUnsignedShort(); } @Override public int length() { return 2; } public <R,P> R accept(Visitor<R,P> visitor, P p) { return visitor.visitPrimitive(this, p); } public final int const_value_index; } public static class Enum_element_value extends element_value { Enum_element_value(ClassReader cr, int tag) throws IOException { super(tag); type_name_index = cr.readUnsignedShort(); const_name_index = cr.readUnsignedShort(); } @Override public int length() { return 4; } public <R,P> R accept(Visitor<R,P> visitor, P p) { return visitor.visitEnum(this, p); } public final int type_name_index; public final int const_name_index; } public static class Class_element_value extends element_value { Class_element_value(ClassReader cr, int tag) throws IOException { super(tag); class_info_index = cr.readUnsignedShort(); } @Override public int length() { return 2; } public <R,P> R accept(Visitor<R,P> visitor, P p) { return visitor.visitClass(this, p); } public final int class_info_index; } public static class Annotation_element_value extends element_value { Annotation_element_value(ClassReader cr, int tag) throws IOException, InvalidAnnotation { super(tag); annotation_value = new Annotation(cr); } @Override public int length() { return annotation_value.length(); } public <R,P> R accept(Visitor<R,P> visitor, P p) { return visitor.visitAnnotation(this, p); } public final Annotation annotation_value; } public static class Array_element_value extends element_value { Array_element_value(ClassReader cr, int tag) throws IOException, InvalidAnnotation { super(tag); num_values = cr.readUnsignedShort(); values = new element_value[num_values]; for (int i = 0; i < values.length; i++) values[i] = element_value.read(cr); } @Override public int length() { int n = 2; for (int i = 0; i < values.length; i++) n += values[i].length(); return n; } public <R,P> R accept(Visitor<R,P> visitor, P p) { return visitor.visitArray(this, p); } public final int num_values; public final element_value[] values; } public static class element_value_pair { element_value_pair(ClassReader cr) throws IOException, InvalidAnnotation { element_name_index = cr.readUnsignedShort(); value = element_value.read(cr); } public int length() { return 2 + value.length(); } public final int element_name_index; public final element_value value; } }
7,732
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Instruction.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Instruction.java
/* * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; /** * See JVMS, chapter 6. * * <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> * * @see Code_attribute#getInstructions */ public class Instruction { /** The kind of an instruction, as determined by the position, size and * types of its operands. */ public static enum Kind { /** Opcode is not followed by any operands. */ NO_OPERANDS(1), /** Opcode is followed by a byte indicating a type. */ ATYPE(2), /** Opcode is followed by a 2-byte branch offset. */ BRANCH(3), /** Opcode is followed by a 4-byte branch offset. */ BRANCH_W(5), /** Opcode is followed by a signed byte value. */ BYTE(2), /** Opcode is followed by a 1-byte index into the constant pool. */ CPREF(2), /** Opcode is followed by a 2-byte index into the constant pool. */ CPREF_W(3), /** Opcode is followed by a 2-byte index into the constant pool, * an unsigned byte value. */ CPREF_W_UBYTE(4), /** Opcode is followed by a 2-byte index into the constant pool., * an unsigned byte value, and a zero byte. */ CPREF_W_UBYTE_ZERO(5), /** Opcode is followed by variable number of operands, depending * on the instruction.*/ DYNAMIC(-1), /** Opcode is followed by a 1-byte reference to a local variable. */ LOCAL(2), /** Opcode is followed by a 1-byte reference to a local variable, * and a signed byte value. */ LOCAL_BYTE(3), /** Opcode is followed by a signed short value. */ SHORT(3), /** Wide opcode is not followed by any operands. */ WIDE_NO_OPERANDS(2), /** Wide opcode is followed by a 2-byte index into the constant pool. */ WIDE_CPREF_W(4), /** Wide opcode is followed by a 2-byte index into the constant pool, * and a signed short value. */ WIDE_CPREF_W_SHORT(6), /** Opcode was not recognized. */ UNKNOWN(1); Kind(int length) { this.length = length; } /** The length, in bytes, of this kind of instruction, or -1 is the * length depends on the specific instruction. */ public final int length; }; /** A utility visitor to help decode the operands of an instruction. * @see Instruction#accept */ public interface KindVisitor<R,P> { /** See {@link Kind#NO_OPERANDS}, {@link Kind#WIDE_NO_OPERANDS}. */ R visitNoOperands(Instruction instr, P p); /** See {@link Kind#ATYPE}. */ R visitArrayType(Instruction instr, TypeKind kind, P p); /** See {@link Kind#BRANCH}, {@link Kind#BRANCH_W}. */ R visitBranch(Instruction instr, int offset, P p); /** See {@link Kind#CPREF}, {@link Kind#CPREF_W}, {@link Kind#WIDE_CPREF_W}. */ R visitConstantPoolRef(Instruction instr, int index, P p); /** See {@link Kind#CPREF_W_UBYTE}, {@link Kind#CPREF_W_UBYTE_ZERO}, {@link Kind#WIDE_CPREF_W_SHORT}. */ R visitConstantPoolRefAndValue(Instruction instr, int index, int value, P p); /** See {@link Kind#LOCAL}. */ R visitLocal(Instruction instr, int index, P p); /** See {@link Kind#LOCAL_UBYTE}. */ R visitLocalAndValue(Instruction instr, int index, int value, P p); /** See {@link Kind#DYNAMIC}. */ R visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, P p); /** See {@link Kind#DYNAMIC}. */ R visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, P p); /** See {@link Kind#BYTE}, {@link Kind#SHORT}. */ R visitValue(Instruction instr, int value, P p); /** Instruction is unrecognized. */ R visitUnknown(Instruction instr, P p); } /** The kind of primitive array type to create. * See JVMS chapter 6, newarray. */ public static enum TypeKind { T_BOOLEAN(4, "boolean"), T_CHAR(5, "char"), T_FLOAT(6, "float"), T_DOUBLE(7, "double"), T_BYTE(8, "byte"), T_SHORT(9, "short"), T_INT (10, "int"), T_LONG (11, "long"); TypeKind(int value, String name) { this.value = value; this.name = name; } public static TypeKind get(int value) { switch (value) { case 4: return T_BOOLEAN; case 5: return T_CHAR; case 6: return T_FLOAT; case 7: return T_DOUBLE; case 8: return T_BYTE; case 9: return T_SHORT; case 10: return T_INT; case 11: return T_LONG; default: return null; } } public final int value; public final String name; } /** An instruction is defined by its position in a bytecode array. */ public Instruction(byte[] bytes, int pc) { this.bytes = bytes; this.pc = pc; } /** Get the position of the instruction within the bytecode array. */ public int getPC() { return pc; } /** Get a byte value, relative to the start of this instruction. */ public int getByte(int offset) { return bytes[pc + offset]; } /** Get an unsigned byte value, relative to the start of this instruction. */ public int getUnsignedByte(int offset) { return getByte(offset) & 0xff; } /** Get a 2-byte value, relative to the start of this instruction. */ public int getShort(int offset) { return (getByte(offset) << 8) | getUnsignedByte(offset + 1); } /** Get a unsigned 2-byte value, relative to the start of this instruction. */ public int getUnsignedShort(int offset) { return getShort(offset) & 0xFFFF; } /** Get a 4-byte value, relative to the start of this instruction. */ public int getInt(int offset) { return (getShort(offset) << 16) | (getUnsignedShort(offset + 2)); } /** Get the Opcode for this instruction, or null if the instruction is * unrecognized. */ public Opcode getOpcode() { int b = getUnsignedByte(0); switch (b) { case Opcode.NONPRIV: case Opcode.PRIV: case Opcode.WIDE: return Opcode.get(b, getUnsignedByte(1)); } return Opcode.get(b); } /** Get the mnemonic for this instruction, or a default string if the * instruction is unrecognized. */ public String getMnemonic() { Opcode opcode = getOpcode(); if (opcode == null) return "bytecode " + getUnsignedByte(0); else return opcode.toString().toLowerCase(); } /** Get the length, in bytes, of this instruction, including the opcode * and all its operands. */ public int length() { Opcode opcode = getOpcode(); if (opcode == null) return 1; switch (opcode) { case TABLESWITCH: { int pad = align(pc + 1) - pc; int low = getInt(pad + 4); int high = getInt(pad + 8); return pad + 12 + 4 * (high - low + 1); } case LOOKUPSWITCH: { int pad = align(pc + 1) - pc; int npairs = getInt(pad + 4); return pad + 8 + 8 * npairs; } default: return opcode.kind.length; } } /** Get the {@link Kind} of this instruction. */ public Kind getKind() { Opcode opcode = getOpcode(); return (opcode != null ? opcode.kind : Kind.UNKNOWN); } /** Invoke a method on the visitor according to the kind of this * instruction, passing in the decoded operands for the instruction. */ public <R,P> R accept(KindVisitor<R,P> visitor, P p) { switch (getKind()) { case NO_OPERANDS: return visitor.visitNoOperands(this, p); case ATYPE: return visitor.visitArrayType( this, TypeKind.get(getUnsignedByte(1)), p); case BRANCH: return visitor.visitBranch(this, getShort(1), p); case BRANCH_W: return visitor.visitBranch(this, getInt(1), p); case BYTE: return visitor.visitValue(this, getByte(1), p); case CPREF: return visitor.visitConstantPoolRef(this, getUnsignedByte(1), p); case CPREF_W: return visitor.visitConstantPoolRef(this, getUnsignedShort(1), p); case CPREF_W_UBYTE: case CPREF_W_UBYTE_ZERO: return visitor.visitConstantPoolRefAndValue( this, getUnsignedShort(1), getUnsignedByte(3), p); case DYNAMIC: { switch (getOpcode()) { case TABLESWITCH: { int pad = align(pc + 1) - pc; int default_ = getInt(pad); int low = getInt(pad + 4); int high = getInt(pad + 8); int[] values = new int[high - low + 1]; for (int i = 0; i < values.length; i++) values[i] = getInt(pad + 12 + 4 * i); return visitor.visitTableSwitch( this, default_, low, high, values, p); } case LOOKUPSWITCH: { int pad = align(pc + 1) - pc; int default_ = getInt(pad); int npairs = getInt(pad + 4); int[] matches = new int[npairs]; int[] offsets = new int[npairs]; for (int i = 0; i < npairs; i++) { matches[i] = getInt(pad + 8 + i * 8); offsets[i] = getInt(pad + 12 + i * 8); } return visitor.visitLookupSwitch( this, default_, npairs, matches, offsets, p); } default: throw new IllegalStateException(); } } case LOCAL: return visitor.visitLocal(this, getUnsignedByte(1), p); case LOCAL_BYTE: return visitor.visitLocalAndValue( this, getUnsignedByte(1), getByte(2), p); case SHORT: return visitor.visitValue(this, getShort(1), p); case WIDE_NO_OPERANDS: return visitor.visitNoOperands(this, p); case WIDE_CPREF_W: return visitor.visitConstantPoolRef(this, getUnsignedShort(2), p); case WIDE_CPREF_W_SHORT: return visitor.visitConstantPoolRefAndValue( this, getUnsignedShort(2), getUnsignedByte(4), p); case UNKNOWN: return visitor.visitUnknown(this, p); default: throw new IllegalStateException(); } } private static int align(int n) { return (n + 3) & ~3; } private byte[] bytes; private int pc; }
12,759
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RuntimeInvisibleAnnotations_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleAnnotations_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.17. * * <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 RuntimeInvisibleAnnotations_attribute extends RuntimeAnnotations_attribute { RuntimeInvisibleAnnotations_attribute(ClassReader cr, int name_index, int length) throws IOException, AttributeException { super(cr, name_index, length); } public RuntimeInvisibleAnnotations_attribute(ConstantPool cp, Annotation[] annotations) throws ConstantPoolException { this(cp.getUTF8Index(Attribute.RuntimeInvisibleAnnotations), annotations); } public RuntimeInvisibleAnnotations_attribute(int name_index, Annotation[] annotations) { super(name_index, annotations); } public <R, P> R accept(Visitor<R, P> visitor, P p) { return visitor.visitRuntimeInvisibleAnnotations(this, p); } }
2,309
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SourceFile_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/SourceFile_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.10. * * <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 SourceFile_attribute extends Attribute { SourceFile_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); sourcefile_index = cr.readUnsignedShort(); } public SourceFile_attribute(ConstantPool constant_pool, int sourcefile_index) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.SourceFile), sourcefile_index); } public SourceFile_attribute(int name_index, int sourcefile_index) { super(name_index, 2); this.sourcefile_index = sourcefile_index; } public String getSourceFile(ConstantPool constant_pool) throws ConstantPoolException { return constant_pool.getUTF8Value(sourcefile_index); } public <R, P> R accept(Visitor<R, P> visitor, P p) { return visitor.visitSourceFile(this, p); } public final int sourcefile_index; }
2,461
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Dependency.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Dependency.java
/* * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; /** * A directed relationship between two {@link Dependency.Location Location}s. * Subtypes of {@code Dependency} may provide additional detail about the dependency. * * @see Dependency.Finder * @see Dependency.Filter * @see Dependencies */ public interface Dependency { /** * A filter used to select dependencies of interest, and to discard others. */ public interface Filter { /** * Return true if the dependency is of interest. * @param dependency the dependency to be considered * @return true if and only if the dependency is of interest. */ boolean accepts(Dependency dependency); } /** * An interface for finding the immediate dependencies of a given class file. */ public interface Finder { /** * Find the immediate dependencies of a given class file. * @param classfile the class file to be examined * @return the dependencies located in the given class file. */ public Iterable<? extends Dependency> findDependencies(ClassFile classfile); } /** * A location somewhere within a class. Subtypes of {@code Location} * may be used to provide additional detail about the location. */ public interface Location { /** * Get the name of the class containing the location. * This name will be used to locate the class file for transitive * dependency analysis. * @return the name of the class containing the location. */ String getClassName(); } /** * Get the location that has the dependency. * @return the location that has the dependency. */ Location getOrigin(); /** * Get the location that is being depended upon. * @return the location that is being depended upon. */ Location getTarget(); }
3,138
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SourceID_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/SourceID_attribute.java
/* * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * <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 SourceID_attribute extends Attribute { SourceID_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); sourceID_index = cr.readUnsignedShort(); } public SourceID_attribute(ConstantPool constant_pool, int sourceID_index) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.SourceID), sourceID_index); } public SourceID_attribute(int name_index, int sourceID_index) { super(name_index, 2); this.sourceID_index = sourceID_index; } String getSourceID(ConstantPool constant_pool) throws ConstantPoolException { return constant_pool.getUTF8Value(sourceID_index); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitSourceID(this, data); } public final int sourceID_index; }
2,392
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AccessFlags.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/AccessFlags.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; import java.util.LinkedHashSet; import java.util.Set; /** * See JVMS, sections 4.2, 4.6, 4.7. * * <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 AccessFlags { public static final int ACC_PUBLIC = 0x0001; // class, inner, field, method public static final int ACC_PRIVATE = 0x0002; // inner, field, method public static final int ACC_PROTECTED = 0x0004; // inner, field, method public static final int ACC_STATIC = 0x0008; // inner, field, method public static final int ACC_FINAL = 0x0010; // class, inner, field, method public static final int ACC_SUPER = 0x0020; // class public static final int ACC_SYNCHRONIZED = 0x0020; // method public static final int ACC_VOLATILE = 0x0040; // field public static final int ACC_BRIDGE = 0x0040; // method public static final int ACC_TRANSIENT = 0x0080; // field public static final int ACC_VARARGS = 0x0080; // method public static final int ACC_NATIVE = 0x0100; // method public static final int ACC_INTERFACE = 0x0200; // class, inner public static final int ACC_ABSTRACT = 0x0400; // class, inner, method public static final int ACC_STRICT = 0x0800; // method public static final int ACC_SYNTHETIC = 0x1000; // class, inner, field, method public static final int ACC_ANNOTATION = 0x2000; // class, inner public static final int ACC_ENUM = 0x4000; // class, inner, field public static final int ACC_MODULE = 0x8000; // class, inner, field, method public static enum Kind { Class, InnerClass, Field, Method}; AccessFlags(ClassReader cr) throws IOException { this(cr.readUnsignedShort()); } public AccessFlags(int flags) { this.flags = flags; } public AccessFlags ignore(int mask) { return new AccessFlags(flags & ~mask); } public boolean is(int mask) { return (flags & mask) != 0; } public int byteLength() { return 2; } private static final int[] classModifiers = { ACC_PUBLIC, ACC_FINAL, ACC_ABSTRACT, ACC_MODULE }; private static final int[] classFlags = { ACC_PUBLIC, ACC_FINAL, ACC_SUPER, ACC_INTERFACE, ACC_ABSTRACT, ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM, ACC_MODULE }; public Set<String> getClassModifiers() { int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags); return getModifiers(f, classModifiers, Kind.Class); } public Set<String> getClassFlags() { return getFlags(classFlags, Kind.Class); } private static final int[] innerClassModifiers = { ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_ABSTRACT, ACC_MODULE }; private static final int[] innerClassFlags = { ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SUPER, ACC_INTERFACE, ACC_ABSTRACT, ACC_SYNTHETIC, ACC_ANNOTATION, ACC_ENUM, ACC_MODULE }; public Set<String> getInnerClassModifiers() { int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags); return getModifiers(f, innerClassModifiers, Kind.InnerClass); } public Set<String> getInnerClassFlags() { return getFlags(innerClassFlags, Kind.InnerClass); } private static final int[] fieldModifiers = { ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT, ACC_MODULE }; private static final int[] fieldFlags = { ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT, ACC_SYNTHETIC, ACC_ENUM, ACC_MODULE }; public Set<String> getFieldModifiers() { return getModifiers(fieldModifiers, Kind.Field); } public Set<String> getFieldFlags() { return getFlags(fieldFlags, Kind.Field); } private static final int[] methodModifiers = { ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT, ACC_MODULE }; private static final int[] methodFlags = { ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_BRIDGE, ACC_VARARGS, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT, ACC_SYNTHETIC, ACC_MODULE }; public Set<String> getMethodModifiers() { return getModifiers(methodModifiers, Kind.Method); } public Set<String> getMethodFlags() { return getFlags(methodFlags, Kind.Method); } private Set<String> getModifiers(int[] modifierFlags, Kind t) { return getModifiers(flags, modifierFlags, t); } private static Set<String> getModifiers(int flags, int[] modifierFlags, Kind t) { Set<String> s = new LinkedHashSet<String>(); for (int m: modifierFlags) { if ((flags & m) != 0) s.add(flagToModifier(m, t)); } return s; } private Set<String> getFlags(int[] expectedFlags, Kind t) { Set<String> s = new LinkedHashSet<String>(); int f = flags; for (int e: expectedFlags) { if ((f & e) != 0) { s.add(flagToName(e, t)); f = f & ~e; } } while (f != 0) { int bit = Integer.highestOneBit(f); s.add("0x" + Integer.toHexString(bit)); f = f & ~bit; } return s; } private static String flagToModifier(int flag, Kind t) { switch (flag) { case ACC_PUBLIC: return "public"; case ACC_PRIVATE: return "private"; case ACC_PROTECTED: return "protected"; case ACC_STATIC: return "static"; case ACC_FINAL: return "final"; case ACC_SYNCHRONIZED: return "synchronized"; case 0x80: return (t == Kind.Field ? "transient" : null); case ACC_VOLATILE: return "volatile"; case ACC_NATIVE: return "native"; case ACC_ABSTRACT: return "abstract"; case ACC_STRICT: return "strictfp"; case ACC_MODULE: return "module"; default: return null; } } private static String flagToName(int flag, Kind t) { switch (flag) { case ACC_PUBLIC: return "ACC_PUBLIC"; case ACC_PRIVATE: return "ACC_PRIVATE"; case ACC_PROTECTED: return "ACC_PROTECTED"; case ACC_STATIC: return "ACC_STATIC"; case ACC_FINAL: return "ACC_FINAL"; case 0x20: return (t == Kind.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED"); case 0x40: return (t == Kind.Field ? "ACC_VOLATILE" : "ACC_BRIDGE"); case 0x80: return (t == Kind.Field ? "ACC_TRANSIENT" : "ACC_VARARGS"); case ACC_NATIVE: return "ACC_NATIVE"; case ACC_INTERFACE: return "ACC_INTERFACE"; case ACC_ABSTRACT: return "ACC_ABSTRACT"; case ACC_STRICT: return "ACC_STRICT"; case ACC_SYNTHETIC: return "ACC_SYNTHETIC"; case ACC_ANNOTATION: return "ACC_ANNOTATION"; case ACC_ENUM: return "ACC_ENUM"; case ACC_MODULE: return "ACC_MODULE"; default: return null; } } public final int flags; }
9,296
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
BootstrapMethods_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/BootstrapMethods_attribute.java
/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS <TBD> * http://cr.openjdk.java.net/~jrose/pres/indy-javadoc-mlvm/ * * <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 BootstrapMethods_attribute extends Attribute { public final BootstrapMethodSpecifier[] bootstrap_method_specifiers; BootstrapMethods_attribute(ClassReader cr, int name_index, int length) throws IOException, AttributeException { super(name_index, length); int bootstrap_method_count = cr.readUnsignedShort(); bootstrap_method_specifiers = new BootstrapMethodSpecifier[bootstrap_method_count]; for (int i = 0; i < bootstrap_method_specifiers.length; i++) bootstrap_method_specifiers[i] = new BootstrapMethodSpecifier(cr); } public BootstrapMethods_attribute(int name_index, BootstrapMethodSpecifier[] bootstrap_method_specifiers) { super(name_index, length(bootstrap_method_specifiers)); this.bootstrap_method_specifiers = bootstrap_method_specifiers; } public static int length(BootstrapMethodSpecifier[] bootstrap_method_specifiers) { int n = 2; for (BootstrapMethodSpecifier b : bootstrap_method_specifiers) n += b.length(); return n; } @Override public <R, P> R accept(Visitor<R, P> visitor, P p) { return visitor.visitBootstrapMethods(this, p); } public static class BootstrapMethodSpecifier { public int bootstrap_method_ref; public int[] bootstrap_arguments; public BootstrapMethodSpecifier(int bootstrap_method_ref, int[] bootstrap_arguments) { this.bootstrap_method_ref = bootstrap_method_ref; this.bootstrap_arguments = bootstrap_arguments; } BootstrapMethodSpecifier(ClassReader cr) throws IOException { bootstrap_method_ref = cr.readUnsignedShort(); int method_count = cr.readUnsignedShort(); bootstrap_arguments = new int[method_count]; for (int i = 0; i < bootstrap_arguments.length; i++) { bootstrap_arguments[i] = cr.readUnsignedShort(); } } int length() { // u2 (method_ref) + u2 (argc) + u2 * argc return 2 + 2 + (bootstrap_arguments.length * 2); } } }
3,724
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CompilationID_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/CompilationID_attribute.java
/* * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * <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 CompilationID_attribute extends Attribute { CompilationID_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); compilationID_index = cr.readUnsignedShort(); } public CompilationID_attribute(ConstantPool constant_pool, int compilationID_index) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.CompilationID), compilationID_index); } public CompilationID_attribute(int name_index, int compilationID_index) { super(name_index, 2); this.compilationID_index = compilationID_index; } String getCompilationID(ConstantPool constant_pool) throws ConstantPoolException { return constant_pool.getUTF8Value(compilationID_index); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitCompilationID(this, data); } public final int compilationID_index; }
2,479
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
StackMapTable_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/StackMapTable_attribute.java
/* * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.4. * * <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 StackMapTable_attribute extends Attribute { static class InvalidStackMap extends AttributeException { private static final long serialVersionUID = -5659038410855089780L; InvalidStackMap(String msg) { super(msg); } } StackMapTable_attribute(ClassReader cr, int name_index, int length) throws IOException, InvalidStackMap { super(name_index, length); number_of_entries = cr.readUnsignedShort(); entries = new stack_map_frame[number_of_entries]; for (int i = 0; i < number_of_entries; i++) entries[i] = stack_map_frame.read(cr); } public StackMapTable_attribute(ConstantPool constant_pool, stack_map_frame[] entries) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.StackMapTable), entries); } public StackMapTable_attribute(int name_index, stack_map_frame[] entries) { super(name_index, length(entries)); this.number_of_entries = entries.length; this.entries = entries; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitStackMapTable(this, data); } static int length(stack_map_frame[] entries) { int n = 2; for (stack_map_frame entry: entries) n += entry.length(); return n; } public final int number_of_entries; public final stack_map_frame entries[]; public static abstract class stack_map_frame { static stack_map_frame read(ClassReader cr) throws IOException, InvalidStackMap { int frame_type = cr.readUnsignedByte(); if (frame_type <= 63) return new same_frame(frame_type); else if (frame_type <= 127) return new same_locals_1_stack_item_frame(frame_type, cr); else if (frame_type <= 246) throw new Error("unknown frame_type " + frame_type); else if (frame_type == 247) return new same_locals_1_stack_item_frame_extended(frame_type, cr); else if (frame_type <= 250) return new chop_frame(frame_type, cr); else if (frame_type == 251) return new same_frame_extended(frame_type, cr); else if (frame_type <= 254) return new append_frame(frame_type, cr); else return new full_frame(frame_type, cr); } protected stack_map_frame(int frame_type) { this.frame_type = frame_type; } public int length() { return 1; } public abstract int getOffsetDelta(); public abstract <R,D> R accept(Visitor<R,D> visitor, D data); public final int frame_type; public static interface Visitor<R,P> { R visit_same_frame(same_frame frame, P p); R visit_same_locals_1_stack_item_frame(same_locals_1_stack_item_frame frame, P p); R visit_same_locals_1_stack_item_frame_extended(same_locals_1_stack_item_frame_extended frame, P p); R visit_chop_frame(chop_frame frame, P p); R visit_same_frame_extended(same_frame_extended frame, P p); R visit_append_frame(append_frame frame, P p); R visit_full_frame(full_frame frame, P p); } } public static class same_frame extends stack_map_frame { same_frame(int frame_type) { super(frame_type); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visit_same_frame(this, data); } public int getOffsetDelta() { return frame_type; } } public static class same_locals_1_stack_item_frame extends stack_map_frame { same_locals_1_stack_item_frame(int frame_type, ClassReader cr) throws IOException, InvalidStackMap { super(frame_type); stack = new verification_type_info[1]; stack[0] = verification_type_info.read(cr); } @Override public int length() { return super.length() + stack[0].length(); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visit_same_locals_1_stack_item_frame(this, data); } public int getOffsetDelta() { return frame_type - 64; } public final verification_type_info[] stack; } public static class same_locals_1_stack_item_frame_extended extends stack_map_frame { same_locals_1_stack_item_frame_extended(int frame_type, ClassReader cr) throws IOException, InvalidStackMap { super(frame_type); offset_delta = cr.readUnsignedShort(); stack = new verification_type_info[1]; stack[0] = verification_type_info.read(cr); } @Override public int length() { return super.length() + 2 + stack[0].length(); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visit_same_locals_1_stack_item_frame_extended(this, data); } public int getOffsetDelta() { return offset_delta; } public final int offset_delta; public final verification_type_info[] stack; } public static class chop_frame extends stack_map_frame { chop_frame(int frame_type, ClassReader cr) throws IOException { super(frame_type); offset_delta = cr.readUnsignedShort(); } @Override public int length() { return super.length() + 2; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visit_chop_frame(this, data); } public int getOffsetDelta() { return offset_delta; } public final int offset_delta; } public static class same_frame_extended extends stack_map_frame { same_frame_extended(int frame_type, ClassReader cr) throws IOException { super(frame_type); offset_delta = cr.readUnsignedShort(); } @Override public int length() { return super.length() + 2; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visit_same_frame_extended(this, data); } public int getOffsetDelta() { return offset_delta; } public final int offset_delta; } public static class append_frame extends stack_map_frame { append_frame(int frame_type, ClassReader cr) throws IOException, InvalidStackMap { super(frame_type); offset_delta = cr.readUnsignedShort(); locals = new verification_type_info[frame_type - 251]; for (int i = 0; i < locals.length; i++) locals[i] = verification_type_info.read(cr); } @Override public int length() { int n = super.length() + 2; for (verification_type_info local: locals) n += local.length(); return n; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visit_append_frame(this, data); } public int getOffsetDelta() { return offset_delta; } public final int offset_delta; public final verification_type_info[] locals; } public static class full_frame extends stack_map_frame { full_frame(int frame_type, ClassReader cr) throws IOException, InvalidStackMap { super(frame_type); offset_delta = cr.readUnsignedShort(); number_of_locals = cr.readUnsignedShort(); locals = new verification_type_info[number_of_locals]; for (int i = 0; i < locals.length; i++) locals[i] = verification_type_info.read(cr); number_of_stack_items = cr.readUnsignedShort(); stack = new verification_type_info[number_of_stack_items]; for (int i = 0; i < stack.length; i++) stack[i] = verification_type_info.read(cr); } @Override public int length() { int n = super.length() + 2; for (verification_type_info local: locals) n += local.length(); n += 2; for (verification_type_info item: stack) n += item.length(); return n; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visit_full_frame(this, data); } public int getOffsetDelta() { return offset_delta; } public final int offset_delta; public final int number_of_locals; public final verification_type_info[] locals; public final int number_of_stack_items; public final verification_type_info[] stack; } public static class verification_type_info { public static final int ITEM_Top = 0; public static final int ITEM_Integer = 1; public static final int ITEM_Float = 2; public static final int ITEM_Long = 4; public static final int ITEM_Double = 3; public static final int ITEM_Null = 5; public static final int ITEM_UninitializedThis = 6; public static final int ITEM_Object = 7; public static final int ITEM_Uninitialized = 8; static verification_type_info read(ClassReader cr) throws IOException, InvalidStackMap { int tag = cr.readUnsignedByte(); switch (tag) { case ITEM_Top: case ITEM_Integer: case ITEM_Float: case ITEM_Long: case ITEM_Double: case ITEM_Null: case ITEM_UninitializedThis: return new verification_type_info(tag); case ITEM_Object: return new Object_variable_info(cr); case ITEM_Uninitialized: return new Uninitialized_variable_info(cr); default: throw new InvalidStackMap("unrecognized verification_type_info tag"); } } protected verification_type_info(int tag) { this.tag = tag; } public int length() { return 1; } public final int tag; } public static class Object_variable_info extends verification_type_info { Object_variable_info(ClassReader cr) throws IOException { super(ITEM_Object); cpool_index = cr.readUnsignedShort(); } @Override public int length() { return super.length() + 2; } public final int cpool_index; } public static class Uninitialized_variable_info extends verification_type_info { Uninitialized_variable_info(ClassReader cr) throws IOException { super(ITEM_Uninitialized); offset = cr.readUnsignedShort(); } @Override public int length() { return super.length() + 2; } public final int offset; } }
12,837
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Code_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Code_attribute.java
/* * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; import java.util.Iterator; import java.util.NoSuchElementException; /** * See JVMS, section 4.8.3. * * <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 Code_attribute extends Attribute { public class InvalidIndex extends AttributeException { private static final long serialVersionUID = -8904527774589382802L; InvalidIndex(int index) { this.index = index; } @Override public String getMessage() { // i18n return "invalid index " + index + " in Code attribute"; } public final int index; } Code_attribute(ClassReader cr, int name_index, int length) throws IOException, ConstantPoolException { super(name_index, length); max_stack = cr.readUnsignedShort(); max_locals = cr.readUnsignedShort(); code_length = cr.readInt(); code = new byte[code_length]; cr.readFully(code); exception_table_langth = cr.readUnsignedShort(); exception_table = new Exception_data[exception_table_langth]; for (int i = 0; i < exception_table_langth; i++) exception_table[i] = new Exception_data(cr); attributes = new Attributes(cr); } public int getByte(int offset) throws InvalidIndex { if (offset < 0 || offset >= code.length) throw new InvalidIndex(offset); return code[offset]; } public int getUnsignedByte(int offset) throws InvalidIndex { if (offset < 0 || offset >= code.length) throw new InvalidIndex(offset); return code[offset] & 0xff; } public int getShort(int offset) throws InvalidIndex { if (offset < 0 || offset + 1 >= code.length) throw new InvalidIndex(offset); return (code[offset] << 8) | (code[offset + 1] & 0xFF); } public int getUnsignedShort(int offset) throws InvalidIndex { if (offset < 0 || offset + 1 >= code.length) throw new InvalidIndex(offset); return ((code[offset] << 8) | (code[offset + 1] & 0xFF)) & 0xFFFF; } public int getInt(int offset) throws InvalidIndex { if (offset < 0 || offset + 3 >= code.length) throw new InvalidIndex(offset); return (getShort(offset) << 16) | (getShort(offset + 2) & 0xFFFF); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitCode(this, data); } public Iterable<Instruction> getInstructions() { return new Iterable<Instruction>() { public Iterator<Instruction> iterator() { return new Iterator<Instruction>() { public boolean hasNext() { return (next != null); } public Instruction next() { if (next == null) throw new NoSuchElementException(); current = next; pc += current.length(); next = (pc < code.length ? new Instruction(code, pc) : null); return current; } public void remove() { throw new UnsupportedOperationException("Not supported."); } Instruction current = null; int pc = 0; Instruction next = new Instruction(code, pc); }; } }; } public final int max_stack; public final int max_locals; public final int code_length; public final byte[] code; public final int exception_table_langth; public final Exception_data[] exception_table; public final Attributes attributes; public class Exception_data { Exception_data(ClassReader cr) throws IOException { start_pc = cr.readUnsignedShort(); end_pc = cr.readUnsignedShort(); handler_pc = cr.readUnsignedShort(); catch_type = cr.readUnsignedShort(); } public final int start_pc; public final int end_pc; public final int handler_pc; public final int catch_type; } }
5,672
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InnerClasses_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/InnerClasses_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; import com.sun.tools.classfile.ConstantPool.*; /** * See JVMS, section 4.8.6. * * <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 InnerClasses_attribute extends Attribute { InnerClasses_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); number_of_classes = cr.readUnsignedShort(); classes = new Info[number_of_classes]; for (int i = 0; i < number_of_classes; i++) classes[i] = new Info(cr); } public InnerClasses_attribute(ConstantPool constant_pool, Info[] classes) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.InnerClasses), classes); } public InnerClasses_attribute(int name_index, Info[] classes) { super(name_index, 2 + Info.length() * classes.length); this.number_of_classes = classes.length; this.classes = classes; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitInnerClasses(this, data); } public final int number_of_classes; public final Info[] classes; public static class Info { Info(ClassReader cr) throws IOException { inner_class_info_index = cr.readUnsignedShort(); outer_class_info_index = cr.readUnsignedShort(); inner_name_index = cr.readUnsignedShort(); inner_class_access_flags = new AccessFlags(cr.readUnsignedShort()); } public CONSTANT_Class_info getInnerClassInfo(ConstantPool constant_pool) throws ConstantPoolException { if (inner_class_info_index == 0) return null; return constant_pool.getClassInfo(inner_class_info_index); } public CONSTANT_Class_info getOuterClassInfo(ConstantPool constant_pool) throws ConstantPoolException { if (outer_class_info_index == 0) return null; return constant_pool.getClassInfo(outer_class_info_index); } public String getInnerName(ConstantPool constant_pool) throws ConstantPoolException { if (inner_name_index == 0) return null; return constant_pool.getUTF8Value(inner_name_index); } public static int length() { return 8; } public final int inner_class_info_index; public final int outer_class_info_index; public final int inner_name_index; public final AccessFlags inner_class_access_flags; } }
3,983
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RuntimeAnnotations_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/RuntimeAnnotations_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.16 and 4.8.17. * * <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 abstract class RuntimeAnnotations_attribute extends Attribute { protected RuntimeAnnotations_attribute(ClassReader cr, int name_index, int length) throws IOException, Annotation.InvalidAnnotation { super(name_index, length); int num_annotations = cr.readUnsignedShort(); annotations = new Annotation[num_annotations]; for (int i = 0; i < annotations.length; i++) annotations[i] = new Annotation(cr); } protected RuntimeAnnotations_attribute(int name_index, Annotation[] annotations) { super(name_index, length(annotations)); this.annotations = annotations; } private static int length(Annotation[] annos) { int n = 2; for (Annotation anno: annos) n += anno.length(); return n; } public final Annotation[] annotations; }
2,415
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Type.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Type.java
/* * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; /* * Family of classes used to represent the parsed form of a {@link Descriptor} * or {@link Signature}. * * <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 abstract class Type { protected Type() { } public boolean isObject() { return false; } public abstract <R,D> R accept(Visitor<R,D> visitor, D data); protected static void append(StringBuilder sb, String prefix, List<? extends Type> types, String suffix) { sb.append(prefix); String sep = ""; for (Type t: types) { sb.append(sep); sb.append(t); sep = ", "; } sb.append(suffix); } protected static void appendIfNotEmpty(StringBuilder sb, String prefix, List<? extends Type> types, String suffix) { if (types != null && types.size() > 0) append(sb, prefix, types, suffix); } public interface Visitor<R,P> { R visitSimpleType(SimpleType type, P p); R visitArrayType(ArrayType type, P p); R visitMethodType(MethodType type, P p); R visitClassSigType(ClassSigType type, P p); R visitClassType(ClassType type, P p); R visitTypeParamType(TypeParamType type, P p); R visitWildcardType(WildcardType type, P p); } /** * Represents a type signature with a simple name. The name may be that of a * primitive type, such "{@code int}, {@code float}, etc * or that of a type argument, such as {@code T}, {@code K}, {@code V}, etc. * * See: * JVMS 4.3.2 * BaseType: * {@code B}, {@code C}, {@code D}, {@code F}, {@code I}, * {@code J}, {@code S}, {@code Z}; * VoidDescriptor: * {@code V}; * JVMS 4.3.4 * TypeVariableSignature: * {@code T} Identifier {@code ;} */ public static class SimpleType extends Type { public SimpleType(String name) { this.name = name; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitSimpleType(this, data); } public boolean isPrimitiveType() { return primitiveTypes.contains(name); } // where private static final Set<String> primitiveTypes = new HashSet<String>(Arrays.asList( "boolean", "byte", "char", "double", "float", "int", "long", "short", "void")); @Override public String toString() { return name; } public final String name; } /** * Represents an array type signature. * * See: * JVMS 4.3.4 * ArrayTypeSignature: * {@code [} TypeSignature {@code ]} */ public static class ArrayType extends Type { public ArrayType(Type elemType) { this.elemType = elemType; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitArrayType(this, data); } @Override public String toString() { return elemType + "[]"; } public final Type elemType; } /** * Represents a method type signature. * * See; * JVMS 4.3.4 * MethodTypeSignature: * FormalTypeParameters_opt {@code (} TypeSignature* {@code)} ReturnType * ThrowsSignature* */ public static class MethodType extends Type { public MethodType(List<? extends Type> paramTypes, Type resultType) { this(null, paramTypes, resultType, null); } public MethodType(List<? extends TypeParamType> typeParamTypes, List<? extends Type> paramTypes, Type returnType, List<? extends Type> throwsTypes) { this.typeParamTypes = typeParamTypes; this.paramTypes = paramTypes; this.returnType = returnType; this.throwsTypes = throwsTypes; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitMethodType(this, data); } @Override public String toString() { StringBuilder sb = new StringBuilder(); appendIfNotEmpty(sb, "<", typeParamTypes, "> "); sb.append(returnType); append(sb, " (", paramTypes, ")"); appendIfNotEmpty(sb, " throws ", throwsTypes, ""); return sb.toString(); } public final List<? extends TypeParamType> typeParamTypes; public final List<? extends Type> paramTypes; public final Type returnType; public final List<? extends Type> throwsTypes; } /** * Represents a class signature. These describe the signature of * a class that has type arguments. * * See: * JVMS 4.3.4 * ClassSignature: * FormalTypeParameters_opt SuperclassSignature SuperinterfaceSignature* */ public static class ClassSigType extends Type { public ClassSigType(List<TypeParamType> typeParamTypes, Type superclassType, List<Type> superinterfaceTypes) { this.typeParamTypes = typeParamTypes; this.superclassType = superclassType; this.superinterfaceTypes = superinterfaceTypes; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitClassSigType(this, data); } @Override public String toString() { StringBuilder sb = new StringBuilder(); appendIfNotEmpty(sb, "<", typeParamTypes, ">"); if (superclassType != null) { sb.append(" extends "); sb.append(superclassType); } appendIfNotEmpty(sb, " implements ", superinterfaceTypes, ""); return sb.toString(); } public final List<TypeParamType> typeParamTypes; public final Type superclassType; public final List<Type> superinterfaceTypes; } /** * Represents a class type signature. This is used to represent a * reference to a class, such as in a field, parameter, return type, etc. * * See: * JVMS 4.3.4 * ClassTypeSignature: * {@code L} PackageSpecifier_opt SimpleClassTypeSignature * ClassTypeSignatureSuffix* {@code ;} * PackageSpecifier: * Identifier {@code /} PackageSpecifier* * SimpleClassTypeSignature: * Identifier TypeArguments_opt } * ClassTypeSignatureSuffix: * {@code .} SimpleClassTypeSignature */ public static class ClassType extends Type { public ClassType(ClassType outerType, String name, List<Type> typeArgs) { this.outerType = outerType; this.name = name; this.typeArgs = typeArgs; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitClassType(this, data); } public String getBinaryName() { if (outerType == null) return name; else return (outerType.getBinaryName() + "$" + name); } @Override public String toString() { StringBuilder sb = new StringBuilder(); if (outerType != null) { sb.append(outerType); sb.append("."); } sb.append(name); appendIfNotEmpty(sb, "<", typeArgs, ">"); return sb.toString(); } @Override public boolean isObject() { return (outerType == null) && name.equals("java/lang/Object") && (typeArgs == null || typeArgs.isEmpty()); } public final ClassType outerType; public final String name; public final List<Type> typeArgs; } /** * Represents a FormalTypeParameter. These are used to declare the type * parameters for generic classes and methods. * * See: * JVMS 4.3.4 * FormalTypeParameters: * {@code <} FormalTypeParameter+ {@code >} * FormalTypeParameter: * Identifier ClassBound InterfaceBound* * ClassBound: * {@code :} FieldTypeSignature_opt * InterfaceBound: * {@code :} FieldTypeSignature */ public static class TypeParamType extends Type { public TypeParamType(String name, Type classBound, List<Type> interfaceBounds) { this.name = name; this.classBound = classBound; this.interfaceBounds = interfaceBounds; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitTypeParamType(this, data); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(name); String sep = " extends "; if (classBound != null) { sb.append(sep); sb.append(classBound); sep = " & "; } if (interfaceBounds != null) { for (Type bound: interfaceBounds) { sb.append(sep); sb.append(bound); sep = " & "; } } return sb.toString(); } public final String name; public final Type classBound; public final List<Type> interfaceBounds; } /** * Represents a wildcard type argument. A type argument that is not a * wildcard type argument will be represented by a ClassType, ArrayType, etc. * * See: * JVMS 4.3.4 * TypeArgument: * WildcardIndicator_opt FieldTypeSignature * {@code *} * WildcardIndicator: * {@code +} * {@code -} */ public static class WildcardType extends Type { public enum Kind { UNBOUNDED, EXTENDS, SUPER }; public WildcardType() { this(Kind.UNBOUNDED, null); } public WildcardType(Kind kind, Type boundType) { this.kind = kind; this.boundType = boundType; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitWildcardType(this, data); } @Override public String toString() { switch (kind) { case UNBOUNDED: return "?"; case EXTENDS: return "? extends " + boundType; case SUPER: return "? super " + boundType; default: throw new AssertionError(); } } public final Kind kind; public final Type boundType; } }
12,450
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AttributeException.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/AttributeException.java
/* * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; /* * <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 AttributeException extends Exception { private static final long serialVersionUID = -4231486387714867770L; AttributeException() { } AttributeException(String msg) { super(msg); } }
1,695
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Opcode.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Opcode.java
/* * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import static com.sun.tools.classfile.Instruction.Kind.*; import static com.sun.tools.classfile.Opcode.Set.*; /** * See JVMS, chapter 6. * * <p>In addition to providing all the standard opcodes defined in JVMS, * this class also provides legacy support for the PicoJava extensions. * * <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 enum Opcode { NOP(0x0), ACONST_NULL(0x1), ICONST_M1(0x2), ICONST_0(0x3), ICONST_1(0x4), ICONST_2(0x5), ICONST_3(0x6), ICONST_4(0x7), ICONST_5(0x8), LCONST_0(0x9), LCONST_1(0xa), FCONST_0(0xb), FCONST_1(0xc), FCONST_2(0xd), DCONST_0(0xe), DCONST_1(0xf), BIPUSH(0x10, BYTE), SIPUSH(0x11, SHORT), LDC(0x12, CPREF), LDC_W(0x13, CPREF_W), LDC2_W(0x14, CPREF_W), ILOAD(0x15, LOCAL), LLOAD(0x16, LOCAL), FLOAD(0x17, LOCAL), DLOAD(0x18, LOCAL), ALOAD(0x19, LOCAL), ILOAD_0(0x1a), ILOAD_1(0x1b), ILOAD_2(0x1c), ILOAD_3(0x1d), LLOAD_0(0x1e), LLOAD_1(0x1f), LLOAD_2(0x20), LLOAD_3(0x21), FLOAD_0(0x22), FLOAD_1(0x23), FLOAD_2(0x24), FLOAD_3(0x25), DLOAD_0(0x26), DLOAD_1(0x27), DLOAD_2(0x28), DLOAD_3(0x29), ALOAD_0(0x2a), ALOAD_1(0x2b), ALOAD_2(0x2c), ALOAD_3(0x2d), IALOAD(0x2e), LALOAD(0x2f), FALOAD(0x30), DALOAD(0x31), AALOAD(0x32), BALOAD(0x33), CALOAD(0x34), SALOAD(0x35), ISTORE(0x36, LOCAL), LSTORE(0x37, LOCAL), FSTORE(0x38, LOCAL), DSTORE(0x39, LOCAL), ASTORE(0x3a, LOCAL), ISTORE_0(0x3b), ISTORE_1(0x3c), ISTORE_2(0x3d), ISTORE_3(0x3e), LSTORE_0(0x3f), LSTORE_1(0x40), LSTORE_2(0x41), LSTORE_3(0x42), FSTORE_0(0x43), FSTORE_1(0x44), FSTORE_2(0x45), FSTORE_3(0x46), DSTORE_0(0x47), DSTORE_1(0x48), DSTORE_2(0x49), DSTORE_3(0x4a), ASTORE_0(0x4b), ASTORE_1(0x4c), ASTORE_2(0x4d), ASTORE_3(0x4e), IASTORE(0x4f), LASTORE(0x50), FASTORE(0x51), DASTORE(0x52), AASTORE(0x53), BASTORE(0x54), CASTORE(0x55), SASTORE(0x56), POP(0x57), POP2(0x58), DUP(0x59), DUP_X1(0x5a), DUP_X2(0x5b), DUP2(0x5c), DUP2_X1(0x5d), DUP2_X2(0x5e), SWAP(0x5f), IADD(0x60), LADD(0x61), FADD(0x62), DADD(0x63), ISUB(0x64), LSUB(0x65), FSUB(0x66), DSUB(0x67), IMUL(0x68), LMUL(0x69), FMUL(0x6a), DMUL(0x6b), IDIV(0x6c), LDIV(0x6d), FDIV(0x6e), DDIV(0x6f), IREM(0x70), LREM(0x71), FREM(0x72), DREM(0x73), INEG(0x74), LNEG(0x75), FNEG(0x76), DNEG(0x77), ISHL(0x78), LSHL(0x79), ISHR(0x7a), LSHR(0x7b), IUSHR(0x7c), LUSHR(0x7d), IAND(0x7e), LAND(0x7f), IOR(0x80), LOR(0x81), IXOR(0x82), LXOR(0x83), IINC(0x84, LOCAL_BYTE), I2L(0x85), I2F(0x86), I2D(0x87), L2I(0x88), L2F(0x89), L2D(0x8a), F2I(0x8b), F2L(0x8c), F2D(0x8d), D2I(0x8e), D2L(0x8f), D2F(0x90), I2B(0x91), I2C(0x92), I2S(0x93), LCMP(0x94), FCMPL(0x95), FCMPG(0x96), DCMPL(0x97), DCMPG(0x98), IFEQ(0x99, BRANCH), IFNE(0x9a, BRANCH), IFLT(0x9b, BRANCH), IFGE(0x9c, BRANCH), IFGT(0x9d, BRANCH), IFLE(0x9e, BRANCH), IF_ICMPEQ(0x9f, BRANCH), IF_ICMPNE(0xa0, BRANCH), IF_ICMPLT(0xa1, BRANCH), IF_ICMPGE(0xa2, BRANCH), IF_ICMPGT(0xa3, BRANCH), IF_ICMPLE(0xa4, BRANCH), IF_ACMPEQ(0xa5, BRANCH), IF_ACMPNE(0xa6, BRANCH), GOTO(0xa7, BRANCH), JSR(0xa8, BRANCH), RET(0xa9, LOCAL), TABLESWITCH(0xaa, DYNAMIC), LOOKUPSWITCH(0xab, DYNAMIC), IRETURN(0xac), LRETURN(0xad), FRETURN(0xae), DRETURN(0xaf), ARETURN(0xb0), RETURN(0xb1), GETSTATIC(0xb2, CPREF_W), PUTSTATIC(0xb3, CPREF_W), GETFIELD(0xb4, CPREF_W), PUTFIELD(0xb5, CPREF_W), INVOKEVIRTUAL(0xb6, CPREF_W), INVOKESPECIAL(0xb7, CPREF_W), INVOKESTATIC(0xb8, CPREF_W), INVOKEINTERFACE(0xb9, CPREF_W_UBYTE_ZERO), INVOKEDYNAMIC(0xba, CPREF_W_UBYTE_ZERO), NEW(0xbb, CPREF_W), NEWARRAY(0xbc, ATYPE), ANEWARRAY(0xbd, CPREF_W), ARRAYLENGTH(0xbe), ATHROW(0xbf), CHECKCAST(0xc0, CPREF_W), INSTANCEOF(0xc1, CPREF_W), MONITORENTER(0xc2), MONITOREXIT(0xc3), // wide 0xc4 MULTIANEWARRAY(0xc5, CPREF_W_UBYTE), IFNULL(0xc6, BRANCH), IFNONNULL(0xc7, BRANCH), GOTO_W(0xc8, BRANCH_W), JSR_W(0xc9, BRANCH_W), // impdep 0xfe: PicoJava nonpriv // impdep 0xff: Picojava priv // wide opcodes ILOAD_W(0xc415, WIDE_CPREF_W), LLOAD_W(0xc416, WIDE_CPREF_W), FLOAD_W(0xc417, WIDE_CPREF_W), DLOAD_W(0xc418, WIDE_CPREF_W), ALOAD_W(0xc419, WIDE_CPREF_W), ISTORE_W(0xc436, WIDE_CPREF_W), LSTORE_W(0xc437, WIDE_CPREF_W), FSTORE_W(0xc438, WIDE_CPREF_W), DSTORE_W(0xc439, WIDE_CPREF_W), ASTORE_W(0xc43a, WIDE_CPREF_W), IINC_W(0xc484, WIDE_CPREF_W_SHORT), RET_W(0xc4a9, WIDE_CPREF_W), // PicoJava nonpriv instructions LOAD_UBYTE(PICOJAVA, 0xfe00), LOAD_BYTE(PICOJAVA, 0xfe01), LOAD_CHAR(PICOJAVA, 0xfe02), LOAD_SHORT(PICOJAVA, 0xfe03), LOAD_WORD(PICOJAVA, 0xfe04), RET_FROM_SUB(PICOJAVA, 0xfe05), LOAD_CHAR_OE(PICOJAVA, 0xfe0a), LOAD_SHORT_OE(PICOJAVA, 0xfe0b), LOAD_WORD_OE(PICOJAVA, 0xfe0c), NCLOAD_UBYTE(PICOJAVA, 0xfe10), NCLOAD_BYTE(PICOJAVA, 0xfe11), NCLOAD_CHAR(PICOJAVA, 0xfe12), NCLOAD_SHORT(PICOJAVA, 0xfe13), NCLOAD_WORD(PICOJAVA, 0xfe14), NCLOAD_CHAR_OE(PICOJAVA, 0xfe1a), NCLOAD_SHORT_OE(PICOJAVA, 0xfe1b), NCLOAD_WORD_OE(PICOJAVA, 0xfe1c), CACHE_FLUSH(PICOJAVA, 0xfe1e), STORE_BYTE(PICOJAVA, 0xfe20), STORE_SHORT(PICOJAVA, 0xfe22), STORE_WORD(PICOJAVA, 0xfe24), STORE_SHORT_OE(PICOJAVA, 0xfe2a), STORE_WORD_OE(PICOJAVA, 0xfe2c), NCSTORE_BYTE(PICOJAVA, 0xfe30), NCSTORE_SHORT(PICOJAVA, 0xfe32), NCSTORE_WORD(PICOJAVA, 0xfe34), NCSTORE_SHORT_OE(PICOJAVA, 0xfe3a), NCSTORE_WORD_OE(PICOJAVA, 0xfe3c), ZERO_LINE(PICOJAVA, 0xfe3e), ENTER_SYNC_METHOD(PICOJAVA, 0xfe3f), // PicoJava priv instructions PRIV_LOAD_UBYTE(PICOJAVA, 0xff00), PRIV_LOAD_BYTE(PICOJAVA, 0xff01), PRIV_LOAD_CHAR(PICOJAVA, 0xff02), PRIV_LOAD_SHORT(PICOJAVA, 0xff03), PRIV_LOAD_WORD(PICOJAVA, 0xff04), PRIV_RET_FROM_TRAP(PICOJAVA, 0xff05), PRIV_READ_DCACHE_TAG(PICOJAVA, 0xff06), PRIV_READ_DCACHE_DATA(PICOJAVA, 0xff07), PRIV_LOAD_CHAR_OE(PICOJAVA, 0xff0a), PRIV_LOAD_SHORT_OE(PICOJAVA, 0xff0b), PRIV_LOAD_WORD_OE(PICOJAVA, 0xff0c), PRIV_READ_ICACHE_TAG(PICOJAVA, 0xff0e), PRIV_READ_ICACHE_DATA(PICOJAVA, 0xff0f), PRIV_NCLOAD_UBYTE(PICOJAVA, 0xff10), PRIV_NCLOAD_BYTE(PICOJAVA, 0xff11), PRIV_NCLOAD_CHAR(PICOJAVA, 0xff12), PRIV_NCLOAD_SHORT(PICOJAVA, 0xff13), PRIV_NCLOAD_WORD(PICOJAVA, 0xff14), PRIV_POWERDOWN(PICOJAVA, 0xff16), PRIV_READ_SCACHE_DATA(PICOJAVA, 0xff17), PRIV_NCLOAD_CHAR_OE(PICOJAVA, 0xff1a), PRIV_NCLOAD_SHORT_OE(PICOJAVA, 0xff1b), PRIV_NCLOAD_WORD_OE(PICOJAVA, 0xff1c), PRIV_CACHE_FLUSH(PICOJAVA, 0xff1e), PRIV_CACHE_INDEX_FLUSH(PICOJAVA, 0xff1f), PRIV_STORE_BYTE(PICOJAVA, 0xff20), PRIV_STORE_SHORT(PICOJAVA, 0xff22), PRIV_STORE_WORD(PICOJAVA, 0xff24), PRIV_WRITE_DCACHE_TAG(PICOJAVA, 0xff26), PRIV_WRITE_DCACHE_DATA(PICOJAVA, 0xff27), PRIV_STORE_SHORT_OE(PICOJAVA, 0xff2a), PRIV_STORE_WORD_OE(PICOJAVA, 0xff2c), PRIV_WRITE_ICACHE_TAG(PICOJAVA, 0xff2e), PRIV_WRITE_ICACHE_DATA(PICOJAVA, 0xff2f), PRIV_NCSTORE_BYTE(PICOJAVA, 0xff30), PRIV_NCSTORE_SHORT(PICOJAVA, 0xff32), PRIV_NCSTORE_WORD(PICOJAVA, 0xff34), PRIV_RESET(PICOJAVA, 0xff36), PRIV_WRITE_SCACHE_DATA(PICOJAVA, 0xff37), PRIV_NCSTORE_SHORT_OE(PICOJAVA, 0xff3a), PRIV_NCSTORE_WORD_OE(PICOJAVA, 0xff3c), PRIV_ZERO_LINE(PICOJAVA, 0xff3e), PRIV_READ_REG_0(PICOJAVA, 0xff40), PRIV_READ_REG_1(PICOJAVA, 0xff41), PRIV_READ_REG_2(PICOJAVA, 0xff42), PRIV_READ_REG_3(PICOJAVA, 0xff43), PRIV_READ_REG_4(PICOJAVA, 0xff44), PRIV_READ_REG_5(PICOJAVA, 0xff45), PRIV_READ_REG_6(PICOJAVA, 0xff46), PRIV_READ_REG_7(PICOJAVA, 0xff47), PRIV_READ_REG_8(PICOJAVA, 0xff48), PRIV_READ_REG_9(PICOJAVA, 0xff49), PRIV_READ_REG_10(PICOJAVA, 0xff4a), PRIV_READ_REG_11(PICOJAVA, 0xff4b), PRIV_READ_REG_12(PICOJAVA, 0xff4c), PRIV_READ_REG_13(PICOJAVA, 0xff4d), PRIV_READ_REG_14(PICOJAVA, 0xff4e), PRIV_READ_REG_15(PICOJAVA, 0xff4f), PRIV_READ_REG_16(PICOJAVA, 0xff50), PRIV_READ_REG_17(PICOJAVA, 0xff51), PRIV_READ_REG_18(PICOJAVA, 0xff52), PRIV_READ_REG_19(PICOJAVA, 0xff53), PRIV_READ_REG_20(PICOJAVA, 0xff54), PRIV_READ_REG_21(PICOJAVA, 0xff55), PRIV_READ_REG_22(PICOJAVA, 0xff56), PRIV_READ_REG_23(PICOJAVA, 0xff57), PRIV_READ_REG_24(PICOJAVA, 0xff58), PRIV_READ_REG_25(PICOJAVA, 0xff59), PRIV_READ_REG_26(PICOJAVA, 0xff5a), PRIV_READ_REG_27(PICOJAVA, 0xff5b), PRIV_READ_REG_28(PICOJAVA, 0xff5c), PRIV_READ_REG_29(PICOJAVA, 0xff5d), PRIV_READ_REG_30(PICOJAVA, 0xff5e), PRIV_READ_REG_31(PICOJAVA, 0xff5f), PRIV_WRITE_REG_0(PICOJAVA, 0xff60), PRIV_WRITE_REG_1(PICOJAVA, 0xff61), PRIV_WRITE_REG_2(PICOJAVA, 0xff62), PRIV_WRITE_REG_3(PICOJAVA, 0xff63), PRIV_WRITE_REG_4(PICOJAVA, 0xff64), PRIV_WRITE_REG_5(PICOJAVA, 0xff65), PRIV_WRITE_REG_6(PICOJAVA, 0xff66), PRIV_WRITE_REG_7(PICOJAVA, 0xff67), PRIV_WRITE_REG_8(PICOJAVA, 0xff68), PRIV_WRITE_REG_9(PICOJAVA, 0xff69), PRIV_WRITE_REG_10(PICOJAVA, 0xff6a), PRIV_WRITE_REG_11(PICOJAVA, 0xff6b), PRIV_WRITE_REG_12(PICOJAVA, 0xff6c), PRIV_WRITE_REG_13(PICOJAVA, 0xff6d), PRIV_WRITE_REG_14(PICOJAVA, 0xff6e), PRIV_WRITE_REG_15(PICOJAVA, 0xff6f), PRIV_WRITE_REG_16(PICOJAVA, 0xff70), PRIV_WRITE_REG_17(PICOJAVA, 0xff71), PRIV_WRITE_REG_18(PICOJAVA, 0xff72), PRIV_WRITE_REG_19(PICOJAVA, 0xff73), PRIV_WRITE_REG_20(PICOJAVA, 0xff74), PRIV_WRITE_REG_21(PICOJAVA, 0xff75), PRIV_WRITE_REG_22(PICOJAVA, 0xff76), PRIV_WRITE_REG_23(PICOJAVA, 0xff77), PRIV_WRITE_REG_24(PICOJAVA, 0xff78), PRIV_WRITE_REG_25(PICOJAVA, 0xff79), PRIV_WRITE_REG_26(PICOJAVA, 0xff7a), PRIV_WRITE_REG_27(PICOJAVA, 0xff7b), PRIV_WRITE_REG_28(PICOJAVA, 0xff7c), PRIV_WRITE_REG_29(PICOJAVA, 0xff7d), PRIV_WRITE_REG_30(PICOJAVA, 0xff7e), PRIV_WRITE_REG_31(PICOJAVA, 0xff7f); Opcode(int opcode) { this(STANDARD, opcode, NO_OPERANDS); } Opcode(int opcode, Instruction.Kind kind) { this(STANDARD, opcode, kind); } Opcode(Set set, int opcode) { this(set, opcode, (set == STANDARD ? NO_OPERANDS : WIDE_NO_OPERANDS)); } Opcode(Set set, int opcode, Instruction.Kind kind) { this.set = set; this.opcode = opcode; this.kind = kind; } public final Set set; public final int opcode; public final Instruction.Kind kind; /** Get the Opcode for a simple standard 1-byte opcode. */ public static Opcode get(int opcode) { return stdOpcodes[opcode]; } /** Get the Opcode for 1- or 2-byte opcode. */ public static Opcode get(int opcodePrefix, int opcode) { Opcode[] block = getOpcodeBlock(opcodePrefix); return (block == null ? null : block[opcode]); } private static Opcode[] getOpcodeBlock(int opcodePrefix) { switch (opcodePrefix) { case 0: return stdOpcodes; case WIDE: return wideOpcodes; case NONPRIV: return nonPrivOpcodes; case PRIV: return privOpcodes; default: return null; } } private static Opcode[] stdOpcodes = new Opcode[256]; private static Opcode[] wideOpcodes = new Opcode[256]; private static Opcode[] nonPrivOpcodes = new Opcode[256]; private static Opcode[] privOpcodes = new Opcode[256]; static { for (Opcode o: values()) getOpcodeBlock(o.opcode >> 8)[o.opcode & 0xff] = o; } /** The byte prefix for the wide instructions. */ public static final int WIDE = 0xc4; /** The byte prefix for the PicoJava nonpriv instructions. */ public static final int NONPRIV = 0xfe; /** The byte prefix for the PicoJava priv instructions. */ public static final int PRIV = 0xff; public enum Set { /** Standard opcodes. */ STANDARD, /** Legacy support for PicoJava opcodes. */ PICOJAVA }; }
14,042
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LocalVariableTable_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/LocalVariableTable_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.13. * * <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 LocalVariableTable_attribute extends Attribute { LocalVariableTable_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); local_variable_table_length = cr.readUnsignedShort(); local_variable_table = new Entry[local_variable_table_length]; for (int i = 0; i < local_variable_table_length; i++) local_variable_table[i] = new Entry(cr); } public LocalVariableTable_attribute(ConstantPool constant_pool, Entry[] local_variable_table) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.LocalVariableTable), local_variable_table); } public LocalVariableTable_attribute(int name_index, Entry[] local_variable_table) { super(name_index, 2 + local_variable_table.length * Entry.length()); this.local_variable_table_length = local_variable_table.length; this.local_variable_table = local_variable_table; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitLocalVariableTable(this, data); } public final int local_variable_table_length; public final Entry[] local_variable_table; public static class Entry { Entry(ClassReader cr) throws IOException { start_pc = cr.readUnsignedShort(); length = cr.readUnsignedShort(); name_index = cr.readUnsignedShort(); descriptor_index = cr.readUnsignedShort(); index = cr.readUnsignedShort(); } public static int length() { return 10; } public final int start_pc; public final int length; public final int name_index; public final int descriptor_index; public final int index; } }
3,350
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Method.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Method.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /* * <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 Method { Method(ClassReader cr) throws IOException { access_flags = new AccessFlags(cr); name_index = cr.readUnsignedShort(); descriptor = new Descriptor(cr); attributes = new Attributes(cr); } public Method(AccessFlags access_flags, int name_index, Descriptor descriptor, Attributes attributes) { this.access_flags = access_flags; this.name_index = name_index; this.descriptor = descriptor; this.attributes = attributes; } public int byteLength() { return 6 + attributes.byteLength(); } public String getName(ConstantPool constant_pool) throws ConstantPoolException { return constant_pool.getUTF8Value(name_index); } public final AccessFlags access_flags; public final int name_index; public final Descriptor descriptor; public final Attributes attributes; }
2,434
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RuntimeVisibleParameterAnnotations_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/RuntimeVisibleParameterAnnotations_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.18. * * <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 RuntimeVisibleParameterAnnotations_attribute extends RuntimeParameterAnnotations_attribute { RuntimeVisibleParameterAnnotations_attribute(ClassReader cr, int name_index, int length) throws IOException, Annotation.InvalidAnnotation { super(cr, name_index, length); } public RuntimeVisibleParameterAnnotations_attribute(ConstantPool cp, Annotation[][] parameter_annotations) throws ConstantPoolException { this(cp.getUTF8Index(Attribute.RuntimeVisibleParameterAnnotations), parameter_annotations); } public RuntimeVisibleParameterAnnotations_attribute(int name_index, Annotation[][] parameter_annotations) { super(name_index, parameter_annotations); } public <R, P> R accept(Visitor<R, P> visitor, P p) { return visitor.visitRuntimeVisibleParameterAnnotations(this, p); } }
2,414
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CharacterRangeTable_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/CharacterRangeTable_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * <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 CharacterRangeTable_attribute extends Attribute { public static final int CRT_STATEMENT = 0x0001; public static final int CRT_BLOCK = 0x0002; public static final int CRT_ASSIGNMENT = 0x0004; public static final int CRT_FLOW_CONTROLLER = 0x0008; public static final int CRT_FLOW_TARGET = 0x0010; public static final int CRT_INVOKE = 0x0020; public static final int CRT_CREATE = 0x0040; public static final int CRT_BRANCH_TRUE = 0x0080; public static final int CRT_BRANCH_FALSE = 0x0100; CharacterRangeTable_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); int character_range_table_length = cr.readUnsignedShort(); character_range_table = new Entry[character_range_table_length]; for (int i = 0; i < character_range_table_length; i++) character_range_table[i] = new Entry(cr); } public CharacterRangeTable_attribute(ConstantPool constant_pool, Entry[] character_range_table) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.CharacterRangeTable), character_range_table); } public CharacterRangeTable_attribute(int name_index, Entry[] character_range_table) { super(name_index, 2 + character_range_table.length * Entry.length()); this.character_range_table = character_range_table; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitCharacterRangeTable(this, data); } public final Entry[] character_range_table; public static class Entry { Entry(ClassReader cr) throws IOException { start_pc = cr.readUnsignedShort(); end_pc = cr.readUnsignedShort(); character_range_start = cr.readInt(); character_range_end = cr.readInt(); flags = cr.readUnsignedShort(); } public static int length() { return 14; } public final int start_pc; public final int end_pc; public final int character_range_start; public final int character_range_end; public final int flags; }; }
3,751
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Synthetic_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/Synthetic_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.8. * * <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 Synthetic_attribute extends Attribute { Synthetic_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); } public Synthetic_attribute(ConstantPool constant_pool) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.Synthetic)); } public Synthetic_attribute(int name_index) { super(name_index, 0); } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitSynthetic(this, data); } }
2,098
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassFile.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/ClassFile.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import static com.sun.tools.classfile.AccessFlags.*; /** * See JVMS, section 4.2. * * <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 ClassFile { public static ClassFile read(File file) throws IOException, ConstantPoolException { return read(file, new Attribute.Factory()); } public static ClassFile read(File file, Attribute.Factory attributeFactory) throws IOException, ConstantPoolException { FileInputStream in = new FileInputStream(file); try { return new ClassFile(in, attributeFactory); } finally { try { in.close(); } catch (IOException e) { // ignore } } } public static ClassFile read(InputStream in) throws IOException, ConstantPoolException { return new ClassFile(in, new Attribute.Factory()); } public static ClassFile read(InputStream in, Attribute.Factory attributeFactory) throws IOException, ConstantPoolException { return new ClassFile(in, attributeFactory); } ClassFile(InputStream in, Attribute.Factory attributeFactory) throws IOException, ConstantPoolException { ClassReader cr = new ClassReader(this, in, attributeFactory); magic = cr.readInt(); minor_version = cr.readUnsignedShort(); major_version = cr.readUnsignedShort(); constant_pool = new ConstantPool(cr); access_flags = new AccessFlags(cr); this_class = cr.readUnsignedShort(); super_class = cr.readUnsignedShort(); int interfaces_count = cr.readUnsignedShort(); interfaces = new int[interfaces_count]; for (int i = 0; i < interfaces_count; i++) interfaces[i] = cr.readUnsignedShort(); int fields_count = cr.readUnsignedShort(); fields = new Field[fields_count]; for (int i = 0; i < fields_count; i++) fields[i] = new Field(cr); int methods_count = cr.readUnsignedShort(); methods = new Method[methods_count]; for (int i = 0; i < methods_count; i++) methods[i] = new Method(cr); attributes = new Attributes(cr); } public ClassFile(int magic, int minor_version, int major_version, ConstantPool constant_pool, AccessFlags access_flags, int this_class, int super_class, int[] interfaces, Field[] fields, Method[] methods, Attributes attributes) { this.magic = magic; this.minor_version = minor_version; this.major_version = major_version; this.constant_pool = constant_pool; this.access_flags = access_flags; this.this_class = this_class; this.super_class = super_class; this.interfaces = interfaces; this.fields = fields; this.methods = methods; this.attributes = attributes; } public String getName() throws ConstantPoolException { return constant_pool.getClassInfo(this_class).getName(); } public String getSuperclassName() throws ConstantPoolException { return constant_pool.getClassInfo(super_class).getName(); } public String getInterfaceName(int i) throws ConstantPoolException { return constant_pool.getClassInfo(interfaces[i]).getName(); } public Attribute getAttribute(String name) { return attributes.get(name); } public boolean isClass() { return !isInterface(); } public boolean isInterface() { return access_flags.is(ACC_INTERFACE); } public int byteLength() { return 4 + // magic 2 + // minor 2 + // major constant_pool.byteLength() + 2 + // access flags 2 + // this_class 2 + // super_class byteLength(interfaces) + byteLength(fields) + byteLength(methods) + attributes.byteLength(); } private int byteLength(int[] indices) { return 2 + 2 * indices.length; } private int byteLength(Field[] fields) { int length = 2; for (Field f: fields) length += f.byteLength(); return length; } private int byteLength(Method[] methods) { int length = 2; for (Method m: methods) length += m.byteLength(); return length; } public final int magic; public final int minor_version; public final int major_version; public final ConstantPool constant_pool; public final AccessFlags access_flags; public final int this_class; public final int super_class; public final int[] interfaces; public final Field[] fields; public final Method[] methods; public final Attributes attributes; }
6,408
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstantValue_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/ConstantValue_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.2. * * <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 ConstantValue_attribute extends Attribute { ConstantValue_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); constantvalue_index = cr.readUnsignedShort(); } public ConstantValue_attribute(ConstantPool constant_pool, int constantvalue_index) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.ConstantValue), constantvalue_index); } public ConstantValue_attribute(int name_index, int constantvalue_index) { super(name_index, 2); this.constantvalue_index = constantvalue_index; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitConstantValue(this, data); } public final int constantvalue_index; }
2,346
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LineNumberTable_attribute.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/LineNumberTable_attribute.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; import java.io.IOException; /** * See JVMS, section 4.8.12. * * <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 LineNumberTable_attribute extends Attribute { LineNumberTable_attribute(ClassReader cr, int name_index, int length) throws IOException { super(name_index, length); line_number_table_length = cr.readUnsignedShort(); line_number_table = new Entry[line_number_table_length]; for (int i = 0; i < line_number_table_length; i++) line_number_table[i] = new Entry(cr); } public LineNumberTable_attribute(ConstantPool constant_pool, Entry[] line_number_table) throws ConstantPoolException { this(constant_pool.getUTF8Index(Attribute.LineNumberTable), line_number_table); } public LineNumberTable_attribute(int name_index, Entry[] line_number_table) { super(name_index, 2 + line_number_table.length * Entry.length()); this.line_number_table_length = line_number_table.length; this.line_number_table = line_number_table; } public <R, D> R accept(Visitor<R, D> visitor, D data) { return visitor.visitLineNumberTable(this, data); } public final int line_number_table_length; public final Entry[] line_number_table; public static class Entry { Entry(ClassReader cr) throws IOException { start_pc = cr.readUnsignedShort(); line_number = cr.readUnsignedShort(); } public static int length() { return 4; } public final int start_pc; public final int line_number; } }
3,036
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstantPoolException.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/classfile/ConstantPoolException.java
/* * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.classfile; /* * <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 ConstantPoolException extends Exception { private static final long serialVersionUID = -2324397349644754565L; ConstantPoolException(int index) { this.index = index; } public final int index; }
1,708
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
JavapTask.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/JavapTask.java
/* * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.io.EOFException; import java.io.FileNotFoundException; import java.io.FilterInputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.StringWriter; import java.io.Writer; import java.net.URI; import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; import javax.lang.model.element.Modifier; import javax.lang.model.element.NestingKind; import javax.tools.Diagnostic; import javax.tools.DiagnosticListener; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; import com.sun.tools.classfile.*; import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; /** * "Main" class for javap, normally accessed from the command line * via Main, or from JSR199 via DisassemblerTool. * * <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 JavapTask implements DisassemblerTool.DisassemblerTask, Messages { public class BadArgs extends Exception { static final long serialVersionUID = 8765093759964640721L; BadArgs(String key, Object... args) { super(JavapTask.this.getMessage(key, args)); this.key = key; this.args = args; } BadArgs showUsage(boolean b) { showUsage = b; return this; } final String key; final Object[] args; boolean showUsage; } static abstract class Option { Option(boolean hasArg, String... aliases) { this.hasArg = hasArg; this.aliases = aliases; } boolean matches(String opt) { for (String a: aliases) { if (a.equals(opt)) return true; } return false; } boolean ignoreRest() { return false; } abstract void process(JavapTask task, String opt, String arg) throws BadArgs; final boolean hasArg; final String[] aliases; } static Option[] recognizedOptions = { new Option(false, "-help", "--help", "-?") { void process(JavapTask task, String opt, String arg) { task.options.help = true; } }, new Option(false, "-version") { void process(JavapTask task, String opt, String arg) { task.options.version = true; } }, new Option(false, "-fullversion") { void process(JavapTask task, String opt, String arg) { task.options.fullVersion = true; } }, new Option(false, "-v", "-verbose", "-all") { void process(JavapTask task, String opt, String arg) { task.options.verbose = true; task.options.showFlags = true; task.options.showAllAttrs = true; } }, new Option(false, "-l") { void process(JavapTask task, String opt, String arg) { task.options.showLineAndLocalVariableTables = true; } }, new Option(false, "-public") { void process(JavapTask task, String opt, String arg) { task.options.accessOptions.add(opt); task.options.showAccess = AccessFlags.ACC_PUBLIC; } }, new Option(false, "-protected") { void process(JavapTask task, String opt, String arg) { task.options.accessOptions.add(opt); task.options.showAccess = AccessFlags.ACC_PROTECTED; } }, new Option(false, "-package") { void process(JavapTask task, String opt, String arg) { task.options.accessOptions.add(opt); task.options.showAccess = 0; } }, new Option(false, "-p", "-private") { void process(JavapTask task, String opt, String arg) { if (!task.options.accessOptions.contains("-p") && !task.options.accessOptions.contains("-private")) { task.options.accessOptions.add(opt); } task.options.showAccess = AccessFlags.ACC_PRIVATE; } }, new Option(false, "-c") { void process(JavapTask task, String opt, String arg) { task.options.showDisassembled = true; } }, new Option(false, "-s") { void process(JavapTask task, String opt, String arg) { task.options.showInternalSignatures = true; } }, // new Option(false, "-all") { // void process(JavapTask task, String opt, String arg) { // task.options.showAllAttrs = true; // } // }, new Option(false, "-h") { void process(JavapTask task, String opt, String arg) throws BadArgs { throw task.new BadArgs("err.h.not.supported"); } }, new Option(false, "-verify", "-verify-verbose") { void process(JavapTask task, String opt, String arg) throws BadArgs { throw task.new BadArgs("err.verify.not.supported"); } }, new Option(false, "-sysinfo") { void process(JavapTask task, String opt, String arg) { task.options.sysInfo = true; } }, new Option(false, "-Xold") { void process(JavapTask task, String opt, String arg) throws BadArgs { task.log.println(task.getMessage("warn.Xold.not.supported")); } }, new Option(false, "-Xnew") { void process(JavapTask task, String opt, String arg) throws BadArgs { // ignore: this _is_ the new version } }, new Option(false, "-XDcompat") { void process(JavapTask task, String opt, String arg) { task.options.compat = true; } }, new Option(false, "-XDdetails") { void process(JavapTask task, String opt, String arg) { task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class); } }, new Option(false, "-XDdetails:") { @Override boolean matches(String opt) { int sep = opt.indexOf(":"); return sep != -1 && super.matches(opt.substring(0, sep + 1)); } void process(JavapTask task, String opt, String arg) throws BadArgs { int sep = opt.indexOf(":"); for (String v: opt.substring(sep + 1).split("[,: ]+")) { if (!handleArg(task, v)) throw task.new BadArgs("err.invalid.arg.for.option", v); } } boolean handleArg(JavapTask task, String arg) { if (arg.length() == 0) return true; if (arg.equals("all")) { task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class); return true; } boolean on = true; if (arg.startsWith("-")) { on = false; arg = arg.substring(1); } for (InstructionDetailWriter.Kind k: InstructionDetailWriter.Kind.values()) { if (arg.equalsIgnoreCase(k.option)) { if (on) task.options.details.add(k); else task.options.details.remove(k); return true; } } return false; } }, new Option(false, "-constants") { void process(JavapTask task, String opt, String arg) { task.options.showConstants = true; } }, new Option(false, "-XDinner") { void process(JavapTask task, String opt, String arg) { task.options.showInnerClasses = true; } }, new Option(false, "-XDindent:") { @Override boolean matches(String opt) { int sep = opt.indexOf(":"); return sep != -1 && super.matches(opt.substring(0, sep + 1)); } void process(JavapTask task, String opt, String arg) throws BadArgs { int sep = opt.indexOf(":"); try { task.options.indentWidth = Integer.valueOf(opt.substring(sep + 1)); } catch (NumberFormatException e) { } } }, new Option(false, "-XDtab:") { @Override boolean matches(String opt) { int sep = opt.indexOf(":"); return sep != -1 && super.matches(opt.substring(0, sep + 1)); } void process(JavapTask task, String opt, String arg) throws BadArgs { int sep = opt.indexOf(":"); try { task.options.tabColumn = Integer.valueOf(opt.substring(sep + 1)); } catch (NumberFormatException e) { } } } }; public JavapTask() { context = new Context(); context.put(Messages.class, this); options = Options.instance(context); attributeFactory = new Attribute.Factory(); } public JavapTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener) { this(); this.log = getPrintWriterForWriter(out); this.fileManager = fileManager; this.diagnosticListener = diagnosticListener; } public JavapTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes) { this(out, fileManager, diagnosticListener); this.classes = new ArrayList<String>(); for (String classname: classes) { classname.getClass(); // null-check this.classes.add(classname); } try { handleOptions(options, false); } catch (BadArgs e) { throw new IllegalArgumentException(e.getMessage()); } } public void setLocale(Locale locale) { if (locale == null) locale = Locale.getDefault(); task_locale = locale; } public void setLog(PrintWriter log) { this.log = log; } public void setLog(OutputStream s) { setLog(getPrintWriterForStream(s)); } private static PrintWriter getPrintWriterForStream(OutputStream s) { return new PrintWriter(s, true); } private static PrintWriter getPrintWriterForWriter(Writer w) { if (w == null) return getPrintWriterForStream(null); else if (w instanceof PrintWriter) return (PrintWriter) w; else return new PrintWriter(w, true); } public void setDiagnosticListener(DiagnosticListener<? super JavaFileObject> dl) { diagnosticListener = dl; } public void setDiagnosticListener(OutputStream s) { setDiagnosticListener(getDiagnosticListenerForStream(s)); } private DiagnosticListener<JavaFileObject> getDiagnosticListenerForStream(OutputStream s) { return getDiagnosticListenerForWriter(getPrintWriterForStream(s)); } private DiagnosticListener<JavaFileObject> getDiagnosticListenerForWriter(Writer w) { final PrintWriter pw = getPrintWriterForWriter(w); return new DiagnosticListener<JavaFileObject> () { public void report(Diagnostic<? extends JavaFileObject> diagnostic) { switch (diagnostic.getKind()) { case ERROR: pw.print(getMessage("err.prefix")); break; case WARNING: pw.print(getMessage("warn.prefix")); break; case NOTE: pw.print(getMessage("note.prefix")); break; } pw.print(" "); pw.println(diagnostic.getMessage(null)); } }; } /** Result codes. */ static final int EXIT_OK = 0, // Compilation completed with no errors. EXIT_ERROR = 1, // Completed but reported errors. EXIT_CMDERR = 2, // Bad command-line arguments EXIT_SYSERR = 3, // System error or resource exhaustion. EXIT_ABNORMAL = 4; // Compiler terminated abnormally int run(String[] args) { try { handleOptions(args); // the following gives consistent behavior with javac if (classes == null || classes.size() == 0) { if (options.help || options.version || options.fullVersion) return EXIT_OK; else return EXIT_CMDERR; } try { boolean ok = run(); return ok ? EXIT_OK : EXIT_ERROR; } finally { if (defaultFileManager != null) { try { defaultFileManager.close(); defaultFileManager = null; } catch (IOException e) { throw new InternalError(e); } } } } catch (BadArgs e) { reportError(e.key, e.args); if (e.showUsage) { log.println(getMessage("main.usage.summary", progname)); } return EXIT_CMDERR; } catch (InternalError e) { Object[] e_args; if (e.getCause() == null) e_args = e.args; else { e_args = new Object[e.args.length + 1]; e_args[0] = e.getCause(); System.arraycopy(e.args, 0, e_args, 1, e.args.length); } reportError("err.internal.error", e_args); return EXIT_ABNORMAL; } finally { log.flush(); } } public void handleOptions(String[] args) throws BadArgs { handleOptions(Arrays.asList(args), true); } private void handleOptions(Iterable<String> args, boolean allowClasses) throws BadArgs { if (log == null) { log = getPrintWriterForStream(System.out); if (diagnosticListener == null) diagnosticListener = getDiagnosticListenerForStream(System.err); } else { if (diagnosticListener == null) diagnosticListener = getDiagnosticListenerForWriter(log); } if (fileManager == null) fileManager = getDefaultFileManager(diagnosticListener, log); Iterator<String> iter = args.iterator(); boolean noArgs = !iter.hasNext(); while (iter.hasNext()) { String arg = iter.next(); if (arg.startsWith("-")) handleOption(arg, iter); else if (allowClasses) { if (classes == null) classes = new ArrayList<String>(); classes.add(arg); while (iter.hasNext()) classes.add(iter.next()); } else throw new BadArgs("err.unknown.option", arg).showUsage(true); } if (!options.compat && options.accessOptions.size() > 1) { StringBuilder sb = new StringBuilder(); for (String opt: options.accessOptions) { if (sb.length() > 0) sb.append(" "); sb.append(opt); } throw new BadArgs("err.incompatible.options", sb); } if ((classes == null || classes.size() == 0) && !(noArgs || options.help || options.version || options.fullVersion)) { throw new BadArgs("err.no.classes.specified"); } if (noArgs || options.help) showHelp(); if (options.version || options.fullVersion) showVersion(options.fullVersion); } private void handleOption(String name, Iterator<String> rest) throws BadArgs { for (Option o: recognizedOptions) { if (o.matches(name)) { if (o.hasArg) { if (rest.hasNext()) o.process(this, name, rest.next()); else throw new BadArgs("err.missing.arg", name).showUsage(true); } else o.process(this, name, null); if (o.ignoreRest()) { while (rest.hasNext()) rest.next(); } return; } } if (fileManager.handleOption(name, rest)) return; throw new BadArgs("err.unknown.option", name).showUsage(true); } public Boolean call() { return run(); } public boolean run() { if (classes == null || classes.size() == 0) return false; context.put(PrintWriter.class, log); ClassWriter classWriter = ClassWriter.instance(context); SourceWriter sourceWriter = SourceWriter.instance(context); sourceWriter.setFileManager(fileManager); attributeFactory.setCompat(options.compat); boolean ok = true; for (String className: classes) { JavaFileObject fo; try { writeClass(classWriter, className); } catch (ConstantPoolException e) { reportError("err.bad.constant.pool", className, e.getLocalizedMessage()); ok = false; } catch (EOFException e) { reportError("err.end.of.file", className); ok = false; } catch (FileNotFoundException e) { reportError("err.file.not.found", e.getLocalizedMessage()); ok = false; } catch (IOException e) { //e.printStackTrace(); Object msg = e.getLocalizedMessage(); if (msg == null) msg = e; reportError("err.ioerror", className, msg); ok = false; } catch (Throwable t) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.close(); reportError("err.crash", t.toString(), sw.toString()); ok = false; } } return ok; } protected boolean writeClass(ClassWriter classWriter, String className) throws IOException, ConstantPoolException { JavaFileObject fo = open(className); if (fo == null) { reportError("err.class.not.found", className); return false; } ClassFileInfo cfInfo = read(fo); if (!className.endsWith(".class")) { String cfName = cfInfo.cf.getName(); if (!cfName.replaceAll("[/$]", ".").equals(className.replaceAll("[/$]", "."))) reportWarning("warn.unexpected.class", className, cfName.replace('/', '.')); } write(cfInfo); if (options.showInnerClasses) { ClassFile cf = cfInfo.cf; Attribute a = cf.getAttribute(Attribute.InnerClasses); if (a instanceof InnerClasses_attribute) { InnerClasses_attribute inners = (InnerClasses_attribute) a; try { boolean ok = true; for (int i = 0; i < inners.classes.length; i++) { int outerIndex = inners.classes[i].outer_class_info_index; ConstantPool.CONSTANT_Class_info outerClassInfo = cf.constant_pool.getClassInfo(outerIndex); String outerClassName = outerClassInfo.getName(); if (outerClassName.equals(cf.getName())) { int innerIndex = inners.classes[i].inner_class_info_index; ConstantPool.CONSTANT_Class_info innerClassInfo = cf.constant_pool.getClassInfo(innerIndex); String innerClassName = innerClassInfo.getName(); classWriter.println("// inner class " + innerClassName.replaceAll("[/$]", ".")); classWriter.println(); ok = ok & writeClass(classWriter, innerClassName); } } return ok; } catch (ConstantPoolException e) { reportError("err.bad.innerclasses.attribute", className); return false; } } else if (a != null) { reportError("err.bad.innerclasses.attribute", className); return false; } } return true; } protected JavaFileObject open(String className) throws IOException { // for compatibility, first see if it is a class name JavaFileObject fo = getClassFileObject(className); if (fo != null) return fo; // see if it is an inner class, by replacing dots to $, starting from the right String cn = className; int lastDot; while ((lastDot = cn.lastIndexOf(".")) != -1) { cn = cn.substring(0, lastDot) + "$" + cn.substring(lastDot + 1); fo = getClassFileObject(cn); if (fo != null) return fo; } if (!className.endsWith(".class")) return null; if (fileManager instanceof StandardJavaFileManager) { StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager; fo = sfm.getJavaFileObjects(className).iterator().next(); if (fo != null && fo.getLastModified() != 0) { return fo; } } // see if it is a URL, and if so, wrap it in just enough of a JavaFileObject // to suit javap's needs if (className.matches("^[A-Za-z]+:.*")) { try { final URI uri = new URI(className); final URL url = uri.toURL(); final URLConnection conn = url.openConnection(); return new JavaFileObject() { public Kind getKind() { return JavaFileObject.Kind.CLASS; } public boolean isNameCompatible(String simpleName, Kind kind) { throw new UnsupportedOperationException(); } public NestingKind getNestingKind() { throw new UnsupportedOperationException(); } public Modifier getAccessLevel() { throw new UnsupportedOperationException(); } public URI toUri() { return uri; } public String getName() { return url.toString(); } public InputStream openInputStream() throws IOException { return conn.getInputStream(); } public OutputStream openOutputStream() throws IOException { throw new UnsupportedOperationException(); } public Reader openReader(boolean ignoreEncodingErrors) throws IOException { throw new UnsupportedOperationException(); } public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { throw new UnsupportedOperationException(); } public Writer openWriter() throws IOException { throw new UnsupportedOperationException(); } public long getLastModified() { return conn.getLastModified(); } public boolean delete() { throw new UnsupportedOperationException(); } }; } catch (URISyntaxException ignore) { } catch (IOException ignore) { } } return null; } public static class ClassFileInfo { ClassFileInfo(JavaFileObject fo, ClassFile cf, byte[] digest, int size) { this.fo = fo; this.cf = cf; this.digest = digest; this.size = size; } public final JavaFileObject fo; public final ClassFile cf; public final byte[] digest; public final int size; } public ClassFileInfo read(JavaFileObject fo) throws IOException, ConstantPoolException { InputStream in = fo.openInputStream(); try { SizeInputStream sizeIn = null; MessageDigest md = null; if (options.sysInfo || options.verbose) { try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException ignore) { } in = new DigestInputStream(in, md); in = sizeIn = new SizeInputStream(in); } ClassFile cf = ClassFile.read(in, attributeFactory); byte[] digest = (md == null) ? null : md.digest(); int size = (sizeIn == null) ? -1 : sizeIn.size(); return new ClassFileInfo(fo, cf, digest, size); } finally { in.close(); } } public void write(ClassFileInfo info) { ClassWriter classWriter = ClassWriter.instance(context); if (options.sysInfo || options.verbose) { classWriter.setFile(info.fo.toUri()); classWriter.setLastModified(info.fo.getLastModified()); classWriter.setDigest("MD5", info.digest); classWriter.setFileSize(info.size); } classWriter.write(info.cf); } protected void setClassFile(ClassFile classFile) { ClassWriter classWriter = ClassWriter.instance(context); classWriter.setClassFile(classFile); } protected void setMethod(Method enclosingMethod) { ClassWriter classWriter = ClassWriter.instance(context); classWriter.setMethod(enclosingMethod); } protected void write(Attribute value) { AttributeWriter attrWriter = AttributeWriter.instance(context); ClassWriter classWriter = ClassWriter.instance(context); ClassFile cf = classWriter.getClassFile(); attrWriter.write(cf, value, cf.constant_pool); } protected void write(Attributes attrs) { AttributeWriter attrWriter = AttributeWriter.instance(context); ClassWriter classWriter = ClassWriter.instance(context); ClassFile cf = classWriter.getClassFile(); attrWriter.write(cf, attrs, cf.constant_pool); } protected void write(ConstantPool constant_pool) { ConstantWriter constantWriter = ConstantWriter.instance(context); constantWriter.writeConstantPool(constant_pool); } protected void write(ConstantPool constant_pool, int value) { ConstantWriter constantWriter = ConstantWriter.instance(context); constantWriter.write(value); } protected void write(ConstantPool.CPInfo value) { ConstantWriter constantWriter = ConstantWriter.instance(context); constantWriter.println(value); } protected void write(Field value) { ClassWriter classWriter = ClassWriter.instance(context); classWriter.writeField(value); } protected void write(Method value) { ClassWriter classWriter = ClassWriter.instance(context); classWriter.writeMethod(value); } private JavaFileManager getDefaultFileManager(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) { if (defaultFileManager == null) defaultFileManager = JavapFileManager.create(dl, log); return defaultFileManager; } private JavaFileObject getClassFileObject(String className) throws IOException { JavaFileObject fo; fo = fileManager.getJavaFileForInput(StandardLocation.PLATFORM_CLASS_PATH, className, JavaFileObject.Kind.CLASS); if (fo == null) fo = fileManager.getJavaFileForInput(StandardLocation.CLASS_PATH, className, JavaFileObject.Kind.CLASS); return fo; } private void showHelp() { log.println(getMessage("main.usage", progname)); for (Option o: recognizedOptions) { String name = o.aliases[0].substring(1); // there must always be at least one name if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify")) continue; log.println(getMessage("main.opt." + name)); } String[] fmOptions = { "-classpath", "-bootclasspath" }; for (String o: fmOptions) { if (fileManager.isSupportedOption(o) == -1) continue; String name = o.substring(1); log.println(getMessage("main.opt." + name)); } } private void showVersion(boolean full) { log.println(version(full ? "full" : "release")); } private static final String versionRBName = "com.sun.tools.javap.resources.version"; private static ResourceBundle versionRB; private String version(String key) { // key=version: mm.nn.oo[-milestone] // key=full: mm.mm.oo[-milestone]-build if (versionRB == null) { try { versionRB = ResourceBundle.getBundle(versionRBName); } catch (MissingResourceException e) { return getMessage("version.resource.missing", System.getProperty("java.version")); } } try { return versionRB.getString(key); } catch (MissingResourceException e) { return getMessage("version.unknown", System.getProperty("java.version")); } } private void reportError(String key, Object... args) { diagnosticListener.report(createDiagnostic(Diagnostic.Kind.ERROR, key, args)); } private void reportNote(String key, Object... args) { diagnosticListener.report(createDiagnostic(Diagnostic.Kind.NOTE, key, args)); } private void reportWarning(String key, Object... args) { diagnosticListener.report(createDiagnostic(Diagnostic.Kind.WARNING, key, args)); } private Diagnostic<JavaFileObject> createDiagnostic( final Diagnostic.Kind kind, final String key, final Object... args) { return new Diagnostic<JavaFileObject>() { public Kind getKind() { return kind; } public JavaFileObject getSource() { return null; } public long getPosition() { return Diagnostic.NOPOS; } public long getStartPosition() { return Diagnostic.NOPOS; } public long getEndPosition() { return Diagnostic.NOPOS; } public long getLineNumber() { return Diagnostic.NOPOS; } public long getColumnNumber() { return Diagnostic.NOPOS; } public String getCode() { return key; } public String getMessage(Locale locale) { return JavapTask.this.getMessage(locale, key, args); } @Override public String toString() { return getClass().getName() + "[key=" + key + ",args=" + Arrays.asList(args) + "]"; } }; } public String getMessage(String key, Object... args) { return getMessage(task_locale, key, args); } public String getMessage(Locale locale, String key, Object... args) { if (bundles == null) { // could make this a HashMap<Locale,SoftReference<ResourceBundle>> // and for efficiency, keep a hard reference to the bundle for the task // locale bundles = new HashMap<Locale, ResourceBundle>(); } if (locale == null) locale = Locale.getDefault(); ResourceBundle b = bundles.get(locale); if (b == null) { try { b = ResourceBundle.getBundle("com.sun.tools.javap.resources.javap", locale); bundles.put(locale, b); } catch (MissingResourceException e) { throw new InternalError("Cannot find javap resource bundle for locale " + locale); } } try { return MessageFormat.format(b.getString(key), args); } catch (MissingResourceException e) { throw new InternalError(e, key); } } protected Context context; JavaFileManager fileManager; JavaFileManager defaultFileManager; PrintWriter log; DiagnosticListener<? super JavaFileObject> diagnosticListener; List<String> classes; Options options; //ResourceBundle bundle; Locale task_locale; Map<Locale, ResourceBundle> bundles; protected Attribute.Factory attributeFactory; private static final String progname = "javap"; private static class SizeInputStream extends FilterInputStream { SizeInputStream(InputStream in) { super(in); } int size() { return size; } @Override public int read(byte[] buf, int offset, int length) throws IOException { int n = super.read(buf, offset, length); if (n > 0) size += n; return n; } @Override public int read() throws IOException { int b = super.read(); size += 1; return b; } private int size; } }
36,474
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Options.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/Options.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.util.EnumSet; import java.util.HashSet; import java.util.Set; import com.sun.tools.classfile.AccessFlags; /* * Provides access to javap's options, set via the command line * or JSR 199 API. * <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 Options { public static Options instance(Context context) { Options instance = context.get(Options.class); if (instance == null) instance = new Options(context); return instance; } protected Options(Context context) { context.put(Options.class, this); } /** * Checks access of class, field or method. */ public boolean checkAccess(AccessFlags flags){ boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC); boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED); boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE); boolean isPackage = !(isPublic || isProtected || isPrivate); if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage)) return false; else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage)) return false; else if ((showAccess == 0) && (isPrivate)) return false; else return true; } public boolean help; public boolean verbose; public boolean version; public boolean fullVersion; public boolean showFlags; public boolean showLineAndLocalVariableTables; public int showAccess; public Set<String> accessOptions = new HashSet<String>(); public Set<InstructionDetailWriter.Kind> details = EnumSet.noneOf(InstructionDetailWriter.Kind.class); public boolean showDisassembled; public boolean showInternalSignatures; public boolean showAllAttrs; public boolean showConstants; public boolean sysInfo; public boolean showInnerClasses; public int indentWidth = 2; // #spaces per indentWidth level public int tabColumn = 40; // column number for comments public boolean compat; // bug-for-bug compatibility mode with old javap }
3,564
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InstructionDetailWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/InstructionDetailWriter.java
/* * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import com.sun.tools.classfile.Instruction; /* * Write additional details for an instruction. * * <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 abstract class InstructionDetailWriter extends BasicWriter { public enum Kind { LOCAL_VARS("localVariables"), LOCAL_VAR_TYPES("localVariableTypes"), SOURCE("source"), STACKMAPS("stackMaps"), TRY_BLOCKS("tryBlocks"); Kind(String option) { this.option = option; } final String option; } InstructionDetailWriter(Context context) { super(context); } abstract void writeDetails(Instruction instr); void flush() { } }
2,099
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Messages.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/Messages.java
/* * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.util.Locale; /** * Access to javap messages. * * <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 interface Messages { String getMessage(String key, Object... args); String getMessage(Locale locale, String key, Object... args); }
1,680
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LocalVariableTableWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/LocalVariableTableWriter.java
/* * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Descriptor; import com.sun.tools.classfile.Descriptor.InvalidDescriptor; import com.sun.tools.classfile.Instruction; import com.sun.tools.classfile.LocalVariableTable_attribute; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; /** * Annotate instructions with details about local variables. * * <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 LocalVariableTableWriter extends InstructionDetailWriter { public enum NoteKind { START("start") { public boolean match(LocalVariableTable_attribute.Entry entry, int pc) { return (pc == entry.start_pc); } }, END("end") { public boolean match(LocalVariableTable_attribute.Entry entry, int pc) { return (pc == entry.start_pc + entry.length); } }; NoteKind(String text) { this.text = text; } public abstract boolean match(LocalVariableTable_attribute.Entry entry, int pc); public final String text; }; static LocalVariableTableWriter instance(Context context) { LocalVariableTableWriter instance = context.get(LocalVariableTableWriter.class); if (instance == null) instance = new LocalVariableTableWriter(context); return instance; } protected LocalVariableTableWriter(Context context) { super(context); context.put(LocalVariableTableWriter.class, this); classWriter = ClassWriter.instance(context); } public void reset(Code_attribute attr) { codeAttr = attr; pcMap = new HashMap<Integer, List<LocalVariableTable_attribute.Entry>>(); LocalVariableTable_attribute lvt = (LocalVariableTable_attribute) (attr.attributes.get(Attribute.LocalVariableTable)); if (lvt == null) return; for (int i = 0; i < lvt.local_variable_table.length; i++) { LocalVariableTable_attribute.Entry entry = lvt.local_variable_table[i]; put(entry.start_pc, entry); put(entry.start_pc + entry.length, entry); } } public void writeDetails(Instruction instr) { int pc = instr.getPC(); writeLocalVariables(pc, NoteKind.END); writeLocalVariables(pc, NoteKind.START); } @Override public void flush() { int pc = codeAttr.code_length; writeLocalVariables(pc, NoteKind.END); } public void writeLocalVariables(int pc, NoteKind kind) { ConstantPool constant_pool = classWriter.getClassFile().constant_pool; String indent = space(2); // get from Options? List<LocalVariableTable_attribute.Entry> entries = pcMap.get(pc); if (entries != null) { for (ListIterator<LocalVariableTable_attribute.Entry> iter = entries.listIterator(kind == NoteKind.END ? entries.size() : 0); kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext() ; ) { LocalVariableTable_attribute.Entry entry = kind == NoteKind.END ? iter.previous() : iter.next(); if (kind.match(entry, pc)) { print(indent); print(kind.text); print(" local "); print(entry.index); print(" // "); Descriptor d = new Descriptor(entry.descriptor_index); try { print(d.getFieldType(constant_pool)); } catch (InvalidDescriptor e) { print(report(e)); } catch (ConstantPoolException e) { print(report(e)); } print(" "); try { print(constant_pool.getUTF8Value(entry.name_index)); } catch (ConstantPoolException e) { print(report(e)); } println(); } } } } private void put(int pc, LocalVariableTable_attribute.Entry entry) { List<LocalVariableTable_attribute.Entry> list = pcMap.get(pc); if (list == null) { list = new ArrayList<LocalVariableTable_attribute.Entry>(); pcMap.put(pc, list); } if (!list.contains(entry)) list.add(entry); } private ClassWriter classWriter; private Code_attribute codeAttr; private Map<Integer, List<LocalVariableTable_attribute.Entry>> pcMap; }
6,269
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
BasicWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/BasicWriter.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.io.PrintWriter; import com.sun.tools.classfile.AttributeException; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.DescriptorException; /* * A writer similar to a PrintWriter but which does not hide exceptions. * The standard print calls are line-buffered; report calls write messages directly. * * <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 BasicWriter { protected BasicWriter(Context context) { lineWriter = LineWriter.instance(context); out = context.get(PrintWriter.class); messages = context.get(Messages.class); if (messages == null) throw new AssertionError(); } protected void print(String s) { lineWriter.print(s); } protected void print(Object o) { lineWriter.print(o == null ? null : o.toString()); } protected void println() { lineWriter.println(); } protected void println(String s) { lineWriter.print(s); lineWriter.println(); } protected void println(Object o) { lineWriter.print(o == null ? null : o.toString()); lineWriter.println(); } protected void indent(int delta) { lineWriter.indent(delta); } protected void tab() { lineWriter.tab(); } protected void setPendingNewline(boolean b) { lineWriter.pendingNewline = b; } protected String report(AttributeException e) { out.println("Error: " + e.getMessage()); // i18n? return "???"; } protected String report(ConstantPoolException e) { out.println("Error: " + e.getMessage()); // i18n? return "???"; } protected String report(DescriptorException e) { out.println("Error: " + e.getMessage()); // i18n? return "???"; } protected String report(String msg) { out.println("Error: " + msg); // i18n? return "???"; } protected String space(int w) { if (w < spaces.length && spaces[w] != null) return spaces[w]; StringBuilder sb = new StringBuilder(); for (int i = 0; i < w; i++) sb.append(" "); String s = sb.toString(); if (w < spaces.length) spaces[w] = s; return s; } private String[] spaces = new String[80]; private LineWriter lineWriter; private PrintWriter out; protected Messages messages; private static class LineWriter { static LineWriter instance(Context context) { LineWriter instance = context.get(LineWriter.class); if (instance == null) instance = new LineWriter(context); return instance; } protected LineWriter(Context context) { context.put(LineWriter.class, this); Options options = Options.instance(context); indentWidth = options.indentWidth; tabColumn = options.tabColumn; out = context.get(PrintWriter.class); buffer = new StringBuilder(); } protected void print(String s) { if (pendingNewline) { println(); pendingNewline = false; } if (s == null) s = "null"; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '\n': println(); break; default: if (buffer.length() == 0) indent(); buffer.append(c); } } } protected void println() { out.println(buffer); buffer.setLength(0); } protected void indent(int delta) { indentCount += delta; } protected void tab() { if (buffer.length() == 0) indent(); space(indentCount * indentWidth + tabColumn - buffer.length()); } private void indent() { space(indentCount * indentWidth); } private void space(int n) { for (int i = 0; i < n; i++) buffer.append(' '); } private PrintWriter out; private StringBuilder buffer; private int indentCount; private int indentWidth; private int tabColumn; private boolean pendingNewline; } }
5,940
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TryBlockWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/TryBlockWriter.java
/* * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.Code_attribute.Exception_data; import com.sun.tools.classfile.Instruction; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; /** * Annotate instructions with details about try blocks. * * <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 TryBlockWriter extends InstructionDetailWriter { public enum NoteKind { START("try") { public boolean match(Exception_data entry, int pc) { return (pc == entry.start_pc); } }, END("end try") { public boolean match(Exception_data entry, int pc) { return (pc == entry.end_pc); } }, HANDLER("catch") { public boolean match(Exception_data entry, int pc) { return (pc == entry.handler_pc); } }; NoteKind(String text) { this.text = text; } public abstract boolean match(Exception_data entry, int pc); public final String text; }; static TryBlockWriter instance(Context context) { TryBlockWriter instance = context.get(TryBlockWriter.class); if (instance == null) instance = new TryBlockWriter(context); return instance; } protected TryBlockWriter(Context context) { super(context); context.put(TryBlockWriter.class, this); constantWriter = ConstantWriter.instance(context); } public void reset(Code_attribute attr) { indexMap = new HashMap<Exception_data, Integer>(); pcMap = new HashMap<Integer, List<Exception_data>>(); for (int i = 0; i < attr.exception_table.length; i++) { Exception_data entry = attr.exception_table[i]; indexMap.put(entry, i); put(entry.start_pc, entry); put(entry.end_pc, entry); put(entry.handler_pc, entry); } } public void writeDetails(Instruction instr) { writeTrys(instr, NoteKind.END); writeTrys(instr, NoteKind.START); writeTrys(instr, NoteKind.HANDLER); } public void writeTrys(Instruction instr, NoteKind kind) { String indent = space(2); // get from Options? int pc = instr.getPC(); List<Exception_data> entries = pcMap.get(pc); if (entries != null) { for (ListIterator<Exception_data> iter = entries.listIterator(kind == NoteKind.END ? entries.size() : 0); kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext() ; ) { Exception_data entry = kind == NoteKind.END ? iter.previous() : iter.next(); if (kind.match(entry, pc)) { print(indent); print(kind.text); print("["); print(indexMap.get(entry)); print("] "); if (entry.catch_type == 0) print("finally"); else { print("#" + entry.catch_type); print(" // "); constantWriter.write(entry.catch_type); } println(); } } } } private void put(int pc, Exception_data entry) { List<Exception_data> list = pcMap.get(pc); if (list == null) { list = new ArrayList<Exception_data>(); pcMap.put(pc, list); } if (!list.contains(entry)) list.add(entry); } private Map<Integer, List<Exception_data>> pcMap; private Map<Exception_data, Integer> indexMap; private ConstantWriter constantWriter; }
5,267
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java
/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.net.URI; import java.text.DateFormat; import java.util.Collection; import java.util.Date; import java.util.List; import com.sun.tools.classfile.AccessFlags; import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.Attributes; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.ConstantValue_attribute; import com.sun.tools.classfile.Descriptor; import com.sun.tools.classfile.DescriptorException; import com.sun.tools.classfile.Exceptions_attribute; import com.sun.tools.classfile.Field; import com.sun.tools.classfile.Method; import com.sun.tools.classfile.Signature; import com.sun.tools.classfile.Signature_attribute; import com.sun.tools.classfile.SourceFile_attribute; import com.sun.tools.classfile.Type; import com.sun.tools.classfile.Type.ArrayType; import com.sun.tools.classfile.Type.ClassSigType; import com.sun.tools.classfile.Type.ClassType; import com.sun.tools.classfile.Type.MethodType; import com.sun.tools.classfile.Type.SimpleType; import com.sun.tools.classfile.Type.TypeParamType; import com.sun.tools.classfile.Type.WildcardType; import static com.sun.tools.classfile.AccessFlags.*; /* * The main javap class to write the contents of a class file as text. * * <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 ClassWriter extends BasicWriter { static ClassWriter instance(Context context) { ClassWriter instance = context.get(ClassWriter.class); if (instance == null) instance = new ClassWriter(context); return instance; } protected ClassWriter(Context context) { super(context); context.put(ClassWriter.class, this); options = Options.instance(context); attrWriter = AttributeWriter.instance(context); codeWriter = CodeWriter.instance(context); constantWriter = ConstantWriter.instance(context); } void setDigest(String name, byte[] digest) { this.digestName = name; this.digest = digest; } void setFile(URI uri) { this.uri = uri; } void setFileSize(int size) { this.size = size; } void setLastModified(long lastModified) { this.lastModified = lastModified; } protected ClassFile getClassFile() { return classFile; } protected void setClassFile(ClassFile cf) { classFile = cf; constant_pool = classFile.constant_pool; } protected Method getMethod() { return method; } protected void setMethod(Method m) { method = m; } public void write(ClassFile cf) { setClassFile(cf); if ((options.sysInfo || options.verbose) && !options.compat) { if (uri != null) { if (uri.getScheme().equals("file")) println("Classfile " + uri.getPath()); else println("Classfile " + uri); } indent(+1); if (lastModified != -1) { Date lm = new Date(lastModified); DateFormat df = DateFormat.getDateInstance(); if (size > 0) { println("Last modified " + df.format(lm) + "; size " + size + " bytes"); } else { println("Last modified " + df.format(lm)); } } else if (size > 0) { println("Size " + size + " bytes"); } if (digestName != null && digest != null) { StringBuilder sb = new StringBuilder(); for (byte b: digest) sb.append(String.format("%02x", b)); println(digestName + " checksum " + sb); } } Attribute sfa = cf.getAttribute(Attribute.SourceFile); if (sfa instanceof SourceFile_attribute) { println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\""); } if ((options.sysInfo || options.verbose) && !options.compat) { indent(-1); } String name = getJavaName(classFile); AccessFlags flags = cf.access_flags; writeModifiers(flags.getClassModifiers()); if (classFile.isClass()) print("class "); else if (classFile.isInterface()) print("interface "); print(name); Signature_attribute sigAttr = getSignature(cf.attributes); if (sigAttr == null) { // use info from class file header if (classFile.isClass() && classFile.super_class != 0 ) { String sn = getJavaSuperclassName(cf); if (!sn.equals("java.lang.Object")) { print(" extends "); print(sn); } } for (int i = 0; i < classFile.interfaces.length; i++) { print(i == 0 ? (classFile.isClass() ? " implements " : " extends ") : ","); print(getJavaInterfaceName(classFile, i)); } } else { try { Type t = sigAttr.getParsedSignature().getType(constant_pool); JavaTypePrinter p = new JavaTypePrinter(classFile.isInterface()); // The signature parser cannot disambiguate between a // FieldType and a ClassSignatureType that only contains a superclass type. if (t instanceof Type.ClassSigType) { print(p.print(t)); } else if (options.verbose || !t.isObject()) { print(" extends "); print(p.print(t)); } } catch (ConstantPoolException e) { print(report(e)); } } if (options.verbose) { println(); indent(+1); attrWriter.write(cf, cf.attributes, constant_pool); println("minor version: " + cf.minor_version); println("major version: " + cf.major_version); if (!options.compat) writeList("flags: ", flags.getClassFlags(), NEWLINE); indent(-1); constantWriter.writeConstantPool(); } else { print(" "); } println("{"); indent(+1); writeFields(); writeMethods(); indent(-1); println("}"); } // where class JavaTypePrinter implements Type.Visitor<StringBuilder,StringBuilder> { boolean isInterface; JavaTypePrinter(boolean isInterface) { this.isInterface = isInterface; } String print(Type t) { return t.accept(this, new StringBuilder()).toString(); } public StringBuilder visitSimpleType(SimpleType type, StringBuilder sb) { sb.append(getJavaName(type.name)); return sb; } public StringBuilder visitArrayType(ArrayType type, StringBuilder sb) { append(sb, type.elemType); sb.append("[]"); return sb; } public StringBuilder visitMethodType(MethodType type, StringBuilder sb) { appendIfNotEmpty(sb, "<", type.typeParamTypes, "> "); append(sb, type.returnType); append(sb, " (", type.paramTypes, ")"); appendIfNotEmpty(sb, " throws ", type.throwsTypes, ""); return sb; } public StringBuilder visitClassSigType(ClassSigType type, StringBuilder sb) { appendIfNotEmpty(sb, "<", type.typeParamTypes, ">"); if (isInterface) { appendIfNotEmpty(sb, " extends ", type.superinterfaceTypes, ""); } else { if (type.superclassType != null && (options.verbose || !type.superclassType.isObject())) { sb.append(" extends "); append(sb, type.superclassType); } appendIfNotEmpty(sb, " implements ", type.superinterfaceTypes, ""); } return sb; } public StringBuilder visitClassType(ClassType type, StringBuilder sb) { if (type.outerType != null) { append(sb, type.outerType); sb.append("."); } sb.append(getJavaName(type.name)); appendIfNotEmpty(sb, "<", type.typeArgs, ">"); return sb; } public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) { sb.append(type.name); String sep = " extends "; if (type.classBound != null && (options.verbose || !type.classBound.isObject())) { sb.append(sep); append(sb, type.classBound); sep = " & "; } if (type.interfaceBounds != null) { for (Type bound: type.interfaceBounds) { sb.append(sep); append(sb, bound); sep = " & "; } } return sb; } public StringBuilder visitWildcardType(WildcardType type, StringBuilder sb) { switch (type.kind) { case UNBOUNDED: sb.append("?"); break; case EXTENDS: sb.append("? extends "); append(sb, type.boundType); break; case SUPER: sb.append("? super "); append(sb, type.boundType); break; default: throw new AssertionError(); } return sb; } private void append(StringBuilder sb, Type t) { t.accept(this, sb); } private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) { sb.append(prefix); String sep = ""; for (Type t: list) { sb.append(sep); append(sb, t); sep = ", "; } sb.append(suffix); } private void appendIfNotEmpty(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) { if (!isEmpty(list)) append(sb, prefix, list, suffix); } private boolean isEmpty(List<? extends Type> list) { return (list == null || list.isEmpty()); } } protected void writeFields() { for (Field f: classFile.fields) { writeField(f); } } protected void writeField(Field f) { if (!options.checkAccess(f.access_flags)) return; AccessFlags flags = f.access_flags; writeModifiers(flags.getFieldModifiers()); Signature_attribute sigAttr = getSignature(f.attributes); if (sigAttr == null) print(getJavaFieldType(f.descriptor)); else { try { Type t = sigAttr.getParsedSignature().getType(constant_pool); print(getJavaName(t.toString())); } catch (ConstantPoolException e) { // report error? // fall back on non-generic descriptor print(getJavaFieldType(f.descriptor)); } } print(" "); print(getFieldName(f)); if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents Attribute a = f.attributes.get(Attribute.ConstantValue); if (a instanceof ConstantValue_attribute) { print(" = "); ConstantValue_attribute cv = (ConstantValue_attribute) a; print(getConstantValue(f.descriptor, cv.constantvalue_index)); } } print(";"); println(); indent(+1); if (options.showInternalSignatures) println("Signature: " + getValue(f.descriptor)); if (options.verbose && !options.compat) writeList("flags: ", flags.getFieldFlags(), NEWLINE); if (options.showAllAttrs) { for (Attribute attr: f.attributes) attrWriter.write(f, attr, constant_pool); println(); } indent(-1); if (options.showDisassembled || options.showLineAndLocalVariableTables) println(); } protected void writeMethods() { for (Method m: classFile.methods) writeMethod(m); setPendingNewline(false); } protected void writeMethod(Method m) { if (!options.checkAccess(m.access_flags)) return; method = m; AccessFlags flags = m.access_flags; Descriptor d; Type.MethodType methodType; List<? extends Type> methodExceptions; Signature_attribute sigAttr = getSignature(m.attributes); if (sigAttr == null) { d = m.descriptor; methodType = null; methodExceptions = null; } else { Signature methodSig = sigAttr.getParsedSignature(); d = methodSig; try { methodType = (Type.MethodType) methodSig.getType(constant_pool); methodExceptions = methodType.throwsTypes; if (methodExceptions != null && methodExceptions.isEmpty()) methodExceptions = null; } catch (ConstantPoolException e) { // report error? // fall back on standard descriptor methodType = null; methodExceptions = null; } } writeModifiers(flags.getMethodModifiers()); if (methodType != null) { writeListIfNotEmpty("<", methodType.typeParamTypes, "> "); } if (getName(m).equals("<init>")) { print(getJavaName(classFile)); print(getJavaParameterTypes(d, flags)); } else if (getName(m).equals("<clinit>")) { print("{}"); } else { print(getJavaReturnType(d)); print(" "); print(getName(m)); print(getJavaParameterTypes(d, flags)); } Attribute e_attr = m.attributes.get(Attribute.Exceptions); if (e_attr != null) { // if there are generic exceptions, there must be erased exceptions if (e_attr instanceof Exceptions_attribute) { Exceptions_attribute exceptions = (Exceptions_attribute) e_attr; print(" throws "); if (methodExceptions != null) { // use generic list if available writeList("", methodExceptions, ""); } else { for (int i = 0; i < exceptions.number_of_exceptions; i++) { if (i > 0) print(", "); print(getJavaException(exceptions, i)); } } } else { report("Unexpected or invalid value for Exceptions attribute"); } } println(";"); indent(+1); if (options.showInternalSignatures) { println("Signature: " + getValue(m.descriptor)); } if (options.verbose && !options.compat) { writeList("flags: ", flags.getMethodFlags(), NEWLINE); } Code_attribute code = null; Attribute c_attr = m.attributes.get(Attribute.Code); if (c_attr != null) { if (c_attr instanceof Code_attribute) code = (Code_attribute) c_attr; else report("Unexpected or invalid value for Code attribute"); } if (options.showDisassembled && !options.showAllAttrs) { if (code != null) { println("Code:"); codeWriter.writeInstrs(code); codeWriter.writeExceptionTable(code); } } if (options.showLineAndLocalVariableTables) { if (code != null) { attrWriter.write(code, code.attributes.get(Attribute.LineNumberTable), constant_pool); attrWriter.write(code, code.attributes.get(Attribute.LocalVariableTable), constant_pool); } } if (options.showAllAttrs) { Attribute[] attrs = m.attributes.attrs; for (Attribute attr: attrs) attrWriter.write(m, attr, constant_pool); } indent(-1); // set pendingNewline to write a newline before the next method (if any) // if a separator is desired setPendingNewline( options.showDisassembled || options.showAllAttrs || options.showInternalSignatures || options.showLineAndLocalVariableTables || options.verbose); } void writeModifiers(Collection<String> items) { for (Object item: items) { print(item); print(" "); } } void writeList(String prefix, Collection<?> items, String suffix) { print(prefix); String sep = ""; for (Object item: items) { print(sep); print(item); sep = ", "; } print(suffix); } void writeListIfNotEmpty(String prefix, List<?> items, String suffix) { if (items != null && items.size() > 0) writeList(prefix, items, suffix); } Signature_attribute getSignature(Attributes attributes) { if (options.compat) // javap does not recognize recent attributes return null; return (Signature_attribute) attributes.get(Attribute.Signature); } String adjustVarargs(AccessFlags flags, String params) { if (flags.is(ACC_VARARGS) && !options.compat) { int i = params.lastIndexOf("[]"); if (i > 0) return params.substring(0, i) + "..." + params.substring(i+2); } return params; } String getJavaName(ClassFile cf) { try { return getJavaName(cf.getName()); } catch (ConstantPoolException e) { return report(e); } } String getJavaSuperclassName(ClassFile cf) { try { return getJavaName(cf.getSuperclassName()); } catch (ConstantPoolException e) { return report(e); } } String getJavaInterfaceName(ClassFile cf, int index) { try { return getJavaName(cf.getInterfaceName(index)); } catch (ConstantPoolException e) { return report(e); } } String getJavaFieldType(Descriptor d) { try { return getJavaName(d.getFieldType(constant_pool)); } catch (ConstantPoolException e) { return report(e); } catch (DescriptorException e) { return report(e); } } String getJavaReturnType(Descriptor d) { try { return getJavaName(d.getReturnType(constant_pool)); } catch (ConstantPoolException e) { return report(e); } catch (DescriptorException e) { return report(e); } } String getJavaParameterTypes(Descriptor d, AccessFlags flags) { try { return getJavaName(adjustVarargs(flags, d.getParameterTypes(constant_pool))); } catch (ConstantPoolException e) { return report(e); } catch (DescriptorException e) { return report(e); } } String getJavaException(Exceptions_attribute attr, int index) { try { return getJavaName(attr.getException(index, constant_pool)); } catch (ConstantPoolException e) { return report(e); } } String getValue(Descriptor d) { try { return d.getValue(constant_pool); } catch (ConstantPoolException e) { return report(e); } } String getFieldName(Field f) { try { return f.getName(constant_pool); } catch (ConstantPoolException e) { return report(e); } } String getName(Method m) { try { return m.getName(constant_pool); } catch (ConstantPoolException e) { return report(e); } } static String getJavaName(String name) { return name.replace('/', '.'); } String getSourceFile(SourceFile_attribute attr) { try { return attr.getSourceFile(constant_pool); } catch (ConstantPoolException e) { return report(e); } } /** * Get the value of an entry in the constant pool as a Java constant. * Characters and booleans are represented by CONSTANT_Intgere entries. * Character and string values are processed to escape characters outside * the basic printable ASCII set. * @param d the descriptor, giving the expected type of the constant * @param index the index of the value in the constant pool * @return a printable string containing the value of the constant. */ String getConstantValue(Descriptor d, int index) { try { ConstantPool.CPInfo cpInfo = constant_pool.get(index); switch (cpInfo.getTag()) { case ConstantPool.CONSTANT_Integer: { ConstantPool.CONSTANT_Integer_info info = (ConstantPool.CONSTANT_Integer_info) cpInfo; String t = d.getValue(constant_pool); if (t.equals("C")) { // character return getConstantCharValue((char) info.value); } else if (t.equals("Z")) { // boolean return String.valueOf(info.value == 1); } else { // other: assume integer return String.valueOf(info.value); } } case ConstantPool.CONSTANT_String: { ConstantPool.CONSTANT_String_info info = (ConstantPool.CONSTANT_String_info) cpInfo; return getConstantStringValue(info.getString()); } default: return constantWriter.stringValue(cpInfo); } } catch (ConstantPoolException e) { return "#" + index; } } private String getConstantCharValue(char c) { StringBuilder sb = new StringBuilder(); sb.append('\''); sb.append(esc(c, '\'')); sb.append('\''); return sb.toString(); } private String getConstantStringValue(String s) { StringBuilder sb = new StringBuilder(); sb.append("\""); for (int i = 0; i < s.length(); i++) { sb.append(esc(s.charAt(i), '"')); } sb.append("\""); return sb.toString(); } private String esc(char c, char quote) { if (32 <= c && c <= 126 && c != quote) return String.valueOf(c); else switch (c) { case '\b': return "\\b"; case '\n': return "\\n"; case '\t': return "\\t"; case '\f': return "\\f"; case '\r': return "\\r"; case '\\': return "\\\\"; case '\'': return "\\'"; case '\"': return "\\\""; default: return String.format("\\u%04x", (int) c); } } private Options options; private AttributeWriter attrWriter; private CodeWriter codeWriter; private ConstantWriter constantWriter; private ClassFile classFile; private URI uri; private long lastModified; private String digestName; private byte[] digest; private int size; private ConstantPool constant_pool; private Method method; private static final String NEWLINE = System.getProperty("line.separator", "\n"); }
25,939
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InternalError.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/InternalError.java
/* * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; /** * <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 InternalError extends Error { private static final long serialVersionUID = 8114054446416187030L; InternalError(Throwable t, Object... args) { super("Internal error", t); this.args = args; } InternalError(Object... args) { super("Internal error"); this.args = args; } public final Object[] args; }
1,841
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Main.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/Main.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.io.PrintWriter; /** * Main entry point. * * <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 Main { /** * Main entry point for the launcher. * Note: This method calls System.exit. * @param args command line arguments */ public static void main(String[] args) { JavapTask t = new JavapTask(); int rc = t.run(args); System.exit(rc); } /** * Entry point that does <i>not</i> call System.exit. * @param args command line arguments * @param out output stream * @return an exit code. 0 means success, non-zero means an error occurred. */ public static int run(String[] args, PrintWriter out) { JavapTask t = new JavapTask(); t.setLog(out); return t.run(args); } }
2,223
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/AnnotationWriter.java
/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import com.sun.tools.classfile.Annotation; import com.sun.tools.classfile.Annotation.Annotation_element_value; import com.sun.tools.classfile.Annotation.Array_element_value; import com.sun.tools.classfile.Annotation.Class_element_value; import com.sun.tools.classfile.Annotation.Enum_element_value; import com.sun.tools.classfile.Annotation.Primitive_element_value; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Descriptor; import com.sun.tools.classfile.Descriptor.InvalidDescriptor; /** * A writer for writing annotations as text. * * <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 AnnotationWriter extends BasicWriter { static AnnotationWriter instance(Context context) { AnnotationWriter instance = context.get(AnnotationWriter.class); if (instance == null) instance = new AnnotationWriter(context); return instance; } protected AnnotationWriter(Context context) { super(context); classWriter = ClassWriter.instance(context); constantWriter = ConstantWriter.instance(context); } public void write(Annotation annot) { write(annot, false); } public void write(Annotation annot, boolean resolveIndices) { writeDescriptor(annot.type_index, resolveIndices); boolean showParens = annot.num_element_value_pairs > 0 || !resolveIndices; if (showParens) print("("); for (int i = 0; i < annot.num_element_value_pairs; i++) { if (i > 0) print(","); write(annot.element_value_pairs[i], resolveIndices); } if (showParens) print(")"); } public void write(Annotation.element_value_pair pair) { write(pair, false); } public void write(Annotation.element_value_pair pair, boolean resolveIndices) { writeIndex(pair.element_name_index, resolveIndices); print("="); write(pair.value, resolveIndices); } public void write(Annotation.element_value value) { write(value, false); } public void write(Annotation.element_value value, boolean resolveIndices) { ev_writer.write(value, resolveIndices); } private void writeDescriptor(int index, boolean resolveIndices) { if (resolveIndices) { try { ConstantPool constant_pool = classWriter.getClassFile().constant_pool; Descriptor d = new Descriptor(index); print(d.getFieldType(constant_pool)); return; } catch (ConstantPoolException ignore) { } catch (InvalidDescriptor ignore) { } } print("#" + index); } private void writeIndex(int index, boolean resolveIndices) { if (resolveIndices) { print(constantWriter.stringValue(index)); } else print("#" + index); } element_value_Writer ev_writer = new element_value_Writer(); class element_value_Writer implements Annotation.element_value.Visitor<Void,Boolean> { public void write(Annotation.element_value value, boolean resolveIndices) { value.accept(this, resolveIndices); } public Void visitPrimitive(Primitive_element_value ev, Boolean resolveIndices) { if (resolveIndices) writeIndex(ev.const_value_index, resolveIndices); else print(((char) ev.tag) + "#" + ev.const_value_index); return null; } public Void visitEnum(Enum_element_value ev, Boolean resolveIndices) { if (resolveIndices) { writeIndex(ev.type_name_index, resolveIndices); print("."); writeIndex(ev.const_name_index, resolveIndices); } else print(((char) ev.tag) + "#" + ev.type_name_index + ".#" + ev.const_name_index); return null; } public Void visitClass(Class_element_value ev, Boolean resolveIndices) { if (resolveIndices) { writeIndex(ev.class_info_index, resolveIndices); print(".class"); } else print(((char) ev.tag) + "#" + ev.class_info_index); return null; } public Void visitAnnotation(Annotation_element_value ev, Boolean resolveIndices) { print((char) ev.tag); AnnotationWriter.this.write(ev.annotation_value, resolveIndices); return null; } public Void visitArray(Array_element_value ev, Boolean resolveIndices) { print("["); for (int i = 0; i < ev.num_values; i++) { if (i > 0) print(","); write(ev.values[i], resolveIndices); } print("]"); return null; } } private ClassWriter classWriter; private ConstantWriter constantWriter; }
6,441
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstantWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java
/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import static com.sun.tools.classfile.ConstantPool.*; /* * Write a constant pool entry. * * <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 ConstantWriter extends BasicWriter { public static ConstantWriter instance(Context context) { ConstantWriter instance = context.get(ConstantWriter.class); if (instance == null) instance = new ConstantWriter(context); return instance; } protected ConstantWriter(Context context) { super(context); context.put(ConstantWriter.class, this); classWriter = ClassWriter.instance(context); options = Options.instance(context); } protected void writeConstantPool() { ConstantPool constant_pool = classWriter.getClassFile().constant_pool; writeConstantPool(constant_pool); } protected void writeConstantPool(ConstantPool constant_pool) { ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() { public Integer visitClass(CONSTANT_Class_info info, Void p) { print("#" + info.name_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitDouble(CONSTANT_Double_info info, Void p) { println(stringValue(info)); return 2; } public Integer visitFieldref(CONSTANT_Fieldref_info info, Void p) { print("#" + info.class_index + ".#" + info.name_and_type_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitFloat(CONSTANT_Float_info info, Void p) { println(stringValue(info)); return 1; } public Integer visitInteger(CONSTANT_Integer_info info, Void p) { println(stringValue(info)); return 1; } public Integer visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) { print("#" + info.class_index + ".#" + info.name_and_type_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) { print("#" + info.bootstrap_method_attr_index + ":#" + info.name_and_type_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitLong(CONSTANT_Long_info info, Void p) { println(stringValue(info)); return 2; } public Integer visitNameAndType(CONSTANT_NameAndType_info info, Void p) { print("#" + info.name_index + ":#" + info.type_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitMethodref(CONSTANT_Methodref_info info, Void p) { print("#" + info.class_index + ".#" + info.name_and_type_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) { print("#" + info.reference_kind.tag + ":#" + info.reference_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitMethodType(CONSTANT_MethodType_info info, Void p) { print("#" + info.descriptor_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitString(CONSTANT_String_info info, Void p) { print("#" + info.string_index); tab(); println("// " + stringValue(info)); return 1; } public Integer visitUtf8(CONSTANT_Utf8_info info, Void p) { println(stringValue(info)); return 1; } }; println("Constant pool:"); indent(+1); int width = String.valueOf(constant_pool.size()).length() + 1; int cpx = 1; while (cpx < constant_pool.size()) { print(String.format("%" + width + "s", ("#" + cpx))); try { CPInfo cpInfo = constant_pool.get(cpx); print(String.format(" = %-18s ", cpTagName(cpInfo))); cpx += cpInfo.accept(v, null); } catch (ConstantPool.InvalidIndex ex) { // should not happen } } indent(-1); } protected void write(int cpx) { ClassFile classFile = classWriter.getClassFile(); if (cpx == 0) { print("#0"); return; } CPInfo cpInfo; try { cpInfo = classFile.constant_pool.get(cpx); } catch (ConstantPoolException e) { print("#" + cpx); return; } int tag = cpInfo.getTag(); switch (tag) { case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref: case CONSTANT_Fieldref: // simplify references within this class CPRefInfo ref = (CPRefInfo) cpInfo; try { if (ref.class_index == classFile.this_class) cpInfo = classFile.constant_pool.get(ref.name_and_type_index); } catch (ConstantPool.InvalidIndex e) { // ignore, for now } } print(tagName(tag) + " " + stringValue(cpInfo)); } String cpTagName(CPInfo cpInfo) { String n = cpInfo.getClass().getSimpleName(); return n.replace("CONSTANT_", "").replace("_info", ""); } String tagName(int tag) { switch (tag) { case CONSTANT_Utf8: return "Utf8"; case CONSTANT_Integer: return "int"; case CONSTANT_Float: return "float"; case CONSTANT_Long: return "long"; case CONSTANT_Double: return "double"; case CONSTANT_Class: return "class"; case CONSTANT_String: return "String"; case CONSTANT_Fieldref: return "Field"; case CONSTANT_MethodHandle: return "MethodHandle"; case CONSTANT_MethodType: return "MethodType"; case CONSTANT_Methodref: return "Method"; case CONSTANT_InterfaceMethodref: return "InterfaceMethod"; case CONSTANT_InvokeDynamic: return "InvokeDynamic"; case CONSTANT_NameAndType: return "NameAndType"; default: return "(unknown tag " + tag + ")"; } } String stringValue(int constant_pool_index) { ClassFile classFile = classWriter.getClassFile(); try { return stringValue(classFile.constant_pool.get(constant_pool_index)); } catch (ConstantPool.InvalidIndex e) { return report(e); } } String stringValue(CPInfo cpInfo) { return stringValueVisitor.visit(cpInfo); } StringValueVisitor stringValueVisitor = new StringValueVisitor(); private class StringValueVisitor implements ConstantPool.Visitor<String, Void> { public String visit(CPInfo info) { return info.accept(this, null); } public String visitClass(CONSTANT_Class_info info, Void p) { return getCheckedName(info); } String getCheckedName(CONSTANT_Class_info info) { try { return checkName(info.getName()); } catch (ConstantPoolException e) { return report(e); } } public String visitDouble(CONSTANT_Double_info info, Void p) { return info.value + "d"; } public String visitFieldref(CONSTANT_Fieldref_info info, Void p) { return visitRef(info, p); } public String visitFloat(CONSTANT_Float_info info, Void p) { return info.value + "f"; } public String visitInteger(CONSTANT_Integer_info info, Void p) { return String.valueOf(info.value); } public String visitInterfaceMethodref(CONSTANT_InterfaceMethodref_info info, Void p) { return visitRef(info, p); } public String visitInvokeDynamic(CONSTANT_InvokeDynamic_info info, Void p) { try { String callee = stringValue(info.getNameAndTypeInfo()); return "#" + info.bootstrap_method_attr_index + ":" + callee; } catch (ConstantPoolException e) { return report(e); } } public String visitLong(CONSTANT_Long_info info, Void p) { return info.value + "l"; } public String visitNameAndType(CONSTANT_NameAndType_info info, Void p) { return getCheckedName(info) + ":" + getType(info); } String getCheckedName(CONSTANT_NameAndType_info info) { try { return checkName(info.getName()); } catch (ConstantPoolException e) { return report(e); } } String getType(CONSTANT_NameAndType_info info) { try { return info.getType(); } catch (ConstantPoolException e) { return report(e); } } public String visitMethodHandle(CONSTANT_MethodHandle_info info, Void p) { try { return info.reference_kind.name + " " + stringValue(info.getCPRefInfo()); } catch (ConstantPoolException e) { return report(e); } } public String visitMethodType(CONSTANT_MethodType_info info, Void p) { try { return info.getType(); } catch (ConstantPoolException e) { return report(e); } } public String visitMethodref(CONSTANT_Methodref_info info, Void p) { return visitRef(info, p); } public String visitString(CONSTANT_String_info info, Void p) { try { ClassFile classFile = classWriter.getClassFile(); int string_index = info.string_index; return stringValue(classFile.constant_pool.getUTF8Info(string_index)); } catch (ConstantPoolException e) { return report(e); } } public String visitUtf8(CONSTANT_Utf8_info info, Void p) { String s = info.value; StringBuilder sb = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); switch (c) { case '\t': sb.append('\\').append('t'); break; case '\n': sb.append('\\').append('n'); break; case '\r': sb.append('\\').append('r'); break; case '\"': sb.append('\\').append('\"'); break; default: sb.append(c); } } return sb.toString(); } String visitRef(CPRefInfo info, Void p) { String cn = getCheckedClassName(info); String nat; try { nat = stringValue(info.getNameAndTypeInfo()); } catch (ConstantPoolException e) { nat = report(e); } return cn + "." + nat; } String getCheckedClassName(CPRefInfo info) { try { return checkName(info.getClassName()); } catch (ConstantPoolException e) { return report(e); } } } /* If name is a valid binary name, return it; otherwise quote it. */ private static String checkName(String name) { if (name == null) return "null"; int len = name.length(); if (len == 0) return "\"\""; int cc = '/'; int cp; for (int k = 0; k < len; k += Character.charCount(cp)) { cp = name.codePointAt(k); if ((cc == '/' && !Character.isJavaIdentifierStart(cp)) || (cp != '/' && !Character.isJavaIdentifierPart(cp))) { return "\"" + addEscapes(name) + "\""; } cc = cp; } return name; } /* If name requires escapes, put them in, so it can be a string body. */ private static String addEscapes(String name) { String esc = "\\\"\n\t"; String rep = "\\\"nt"; StringBuilder buf = null; int nextk = 0; int len = name.length(); for (int k = 0; k < len; k++) { char cp = name.charAt(k); int n = esc.indexOf(cp); if (n >= 0) { if (buf == null) buf = new StringBuilder(len * 2); if (nextk < k) buf.append(name, nextk, k); buf.append('\\'); buf.append(rep.charAt(n)); nextk = k+1; } } if (buf == null) return name; if (nextk < len) buf.append(name, nextk, len); return buf.toString(); } private ClassWriter classWriter; private Options options; }
15,601
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DisassemblerTool.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/DisassemblerTool.java
/* * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; //javax.tools; import java.io.Writer; import java.nio.charset.Charset; import java.util.Locale; import java.util.concurrent.Callable; import javax.tools.DiagnosticListener; import javax.tools.JavaFileManager; import javax.tools.JavaFileObject; import javax.tools.OptionChecker; import javax.tools.StandardJavaFileManager; import javax.tools.Tool; /** * This class is intended to be put in javax.tools. * * @see DiagnosticListener * @see Diagnostic * @see JavaFileManager * @since 1.7 * * <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 interface DisassemblerTool extends Tool, OptionChecker { /** * Creates a future for a disassembly task with the given * components and arguments. The task might not have * completed as described in the DissemblerTask interface. * * <p>If a file manager is provided, it must be able to handle all * locations defined in {@link StandardLocation}. * * @param out a Writer for additional output from the compiler; * use {@code System.err} if {@code null} * @param fileManager a file manager; if {@code null} use the * compiler's standard filemanager * @param diagnosticListener a diagnostic listener; if {@code * null} use the compiler's default method for reporting * diagnostics * @param options compiler options, {@code null} means no options * @param classes class names (for annotation processing), {@code * null} means no class names * @param compilationUnits the compilation units to compile, {@code * null} means no compilation units * @return an object representing the compilation * @throws RuntimeException if an unrecoverable error * occurred in a user supplied component. The * {@linkplain Throwable#getCause() cause} will be the error in * user code. * @throws IllegalArgumentException if any of the given * compilation units are of other kind than * {@linkplain JavaFileObject.Kind#SOURCE source} */ DisassemblerTask getTask(Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes); /** * Gets a new instance of the standard file manager implementation * for this tool. The file manager will use the given diagnostic * listener for producing any non-fatal diagnostics. Fatal errors * will be signalled with the appropriate exceptions. * * <p>The standard file manager will be automatically reopened if * it is accessed after calls to {@code flush} or {@code close}. * The standard file manager must be usable with other tools. * * @param diagnosticListener a diagnostic listener for non-fatal * diagnostics; if {@code null} use the compiler's default method * for reporting diagnostics * @param locale the locale to apply when formatting diagnostics; * {@code null} means the {@linkplain Locale#getDefault() default locale}. * @param charset the character set used for decoding bytes; if * {@code null} use the platform default * @return the standard file manager */ StandardJavaFileManager getStandardFileManager( DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset); /** * Interface representing a future for a disassembly task. The * task has not yet started. To start the task, call * the {@linkplain #call call} method. * * <p>Before calling the call method, additional aspects of the * task can be configured, for example, by calling the * {@linkplain #setLocale setLocale} method. */ interface DisassemblerTask extends Callable<Boolean> { /** * Set the locale to be applied when formatting diagnostics and * other localized data. * * @param locale the locale to apply; {@code null} means apply no * locale * @throws IllegalStateException if the task has started */ void setLocale(Locale locale); /** * Performs this compilation task. The compilation may only * be performed once. Subsequent calls to this method throw * IllegalStateException. * * @return true if and only all the files compiled without errors; * false otherwise * * @throws RuntimeException if an unrecoverable error occurred * in a user-supplied component. The * {@linkplain Throwable#getCause() cause} will be the error * in user code. * @throws IllegalStateException if called more than once */ Boolean call(); } }
6,274
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
StackMapWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/StackMapWriter.java
/* * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import com.sun.tools.classfile.AccessFlags; import java.util.HashMap; import java.util.Map; import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Descriptor; import com.sun.tools.classfile.Descriptor.InvalidDescriptor; import com.sun.tools.classfile.Instruction; import com.sun.tools.classfile.Method; import com.sun.tools.classfile.StackMapTable_attribute; import com.sun.tools.classfile.StackMapTable_attribute.*; import static com.sun.tools.classfile.StackMapTable_attribute.verification_type_info.*; /** * Annotate instructions with stack map. * * <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 StackMapWriter extends InstructionDetailWriter { static StackMapWriter instance(Context context) { StackMapWriter instance = context.get(StackMapWriter.class); if (instance == null) instance = new StackMapWriter(context); return instance; } protected StackMapWriter(Context context) { super(context); context.put(StackMapWriter.class, this); classWriter = ClassWriter.instance(context); } public void reset(Code_attribute attr) { setStackMap((StackMapTable_attribute) attr.attributes.get(Attribute.StackMapTable)); } void setStackMap(StackMapTable_attribute attr) { if (attr == null) { map = null; return; } Method m = classWriter.getMethod(); Descriptor d = m.descriptor; String[] args; try { ConstantPool cp = classWriter.getClassFile().constant_pool; String argString = d.getParameterTypes(cp); args = argString.substring(1, argString.length() - 1).split("[, ]+"); } catch (ConstantPoolException e) { return; } catch (InvalidDescriptor e) { return; } boolean isStatic = m.access_flags.is(AccessFlags.ACC_STATIC); verification_type_info[] initialLocals = new verification_type_info[(isStatic ? 0 : 1) + args.length]; if (!isStatic) initialLocals[0] = new CustomVerificationTypeInfo("this"); for (int i = 0; i < args.length; i++) { initialLocals[(isStatic ? 0 : 1) + i] = new CustomVerificationTypeInfo(args[i].replace(".", "/")); } map = new HashMap<Integer, StackMap>(); StackMapBuilder builder = new StackMapBuilder(); // using -1 as the pc for the initial frame effectively compensates for // the difference in behavior for the first stack map frame (where the // pc offset is just offset_delta) compared to subsequent frames (where // the pc offset is always offset_delta+1). int pc = -1; map.put(pc, new StackMap(initialLocals, empty)); for (int i = 0; i < attr.entries.length; i++) pc = attr.entries[i].accept(builder, pc); } public void writeInitialDetails() { writeDetails(-1); } public void writeDetails(Instruction instr) { writeDetails(instr.getPC()); } private void writeDetails(int pc) { if (map == null) return; StackMap m = map.get(pc); if (m != null) { print("StackMap locals: ", m.locals); print("StackMap stack: ", m.stack); } } void print(String label, verification_type_info[] entries) { print(label); for (int i = 0; i < entries.length; i++) { print(" "); print(entries[i]); } println(); } void print(verification_type_info entry) { if (entry == null) { print("ERROR"); return; } switch (entry.tag) { case -1: print(((CustomVerificationTypeInfo) entry).text); break; case ITEM_Top: print("top"); break; case ITEM_Integer: print("int"); break; case ITEM_Float: print("float"); break; case ITEM_Long: print("long"); break; case ITEM_Double: print("double"); break; case ITEM_Null: print("null"); break; case ITEM_UninitializedThis: print("uninit_this"); break; case ITEM_Object: try { ConstantPool cp = classWriter.getClassFile().constant_pool; ConstantPool.CONSTANT_Class_info class_info = cp.getClassInfo(((Object_variable_info) entry).cpool_index); print(cp.getUTF8Value(class_info.name_index)); } catch (ConstantPoolException e) { print("??"); } break; case ITEM_Uninitialized: print(((Uninitialized_variable_info) entry).offset); break; } } private Map<Integer, StackMap> map; private ClassWriter classWriter; class StackMapBuilder implements StackMapTable_attribute.stack_map_frame.Visitor<Integer, Integer> { public Integer visit_same_frame(same_frame frame, Integer pc) { int new_pc = pc + frame.getOffsetDelta() + 1; StackMap m = map.get(pc); assert (m != null); map.put(new_pc, m); return new_pc; } public Integer visit_same_locals_1_stack_item_frame(same_locals_1_stack_item_frame frame, Integer pc) { int new_pc = pc + frame.getOffsetDelta() + 1; StackMap prev = map.get(pc); assert (prev != null); StackMap m = new StackMap(prev.locals, frame.stack); map.put(new_pc, m); return new_pc; } public Integer visit_same_locals_1_stack_item_frame_extended(same_locals_1_stack_item_frame_extended frame, Integer pc) { int new_pc = pc + frame.getOffsetDelta() + 1; StackMap prev = map.get(pc); assert (prev != null); StackMap m = new StackMap(prev.locals, frame.stack); map.put(new_pc, m); return new_pc; } public Integer visit_chop_frame(chop_frame frame, Integer pc) { int new_pc = pc + frame.getOffsetDelta() + 1; StackMap prev = map.get(pc); assert (prev != null); int k = 251 - frame.frame_type; verification_type_info[] new_locals = new verification_type_info[prev.locals.length - k]; System.arraycopy(prev.locals, 0, new_locals, 0, new_locals.length); StackMap m = new StackMap(new_locals, empty); map.put(new_pc, m); return new_pc; } public Integer visit_same_frame_extended(same_frame_extended frame, Integer pc) { int new_pc = pc + frame.getOffsetDelta(); StackMap m = map.get(pc); assert (m != null); map.put(new_pc, m); return new_pc; } public Integer visit_append_frame(append_frame frame, Integer pc) { int new_pc = pc + frame.getOffsetDelta() + 1; StackMap prev = map.get(pc); assert (prev != null); verification_type_info[] new_locals = new verification_type_info[prev.locals.length + frame.locals.length]; System.arraycopy(prev.locals, 0, new_locals, 0, prev.locals.length); System.arraycopy(frame.locals, 0, new_locals, prev.locals.length, frame.locals.length); StackMap m = new StackMap(new_locals, empty); map.put(new_pc, m); return new_pc; } public Integer visit_full_frame(full_frame frame, Integer pc) { int new_pc = pc + frame.getOffsetDelta() + 1; StackMap m = new StackMap(frame.locals, frame.stack); map.put(new_pc, m); return new_pc; } } class StackMap { StackMap(verification_type_info[] locals, verification_type_info[] stack) { this.locals = locals; this.stack = stack; } private final verification_type_info[] locals; private final verification_type_info[] stack; } class CustomVerificationTypeInfo extends verification_type_info { public CustomVerificationTypeInfo(String text) { super(-1); this.text = text; } private String text; } private final verification_type_info[] empty = { }; }
10,187
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AttributeWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java
/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.util.Formatter; import com.sun.tools.classfile.AccessFlags; import com.sun.tools.classfile.AnnotationDefault_attribute; import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.Attributes; import com.sun.tools.classfile.BootstrapMethods_attribute; import com.sun.tools.classfile.CharacterRangeTable_attribute; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.CompilationID_attribute; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.ConstantValue_attribute; import com.sun.tools.classfile.DefaultAttribute; import com.sun.tools.classfile.Deprecated_attribute; import com.sun.tools.classfile.EnclosingMethod_attribute; import com.sun.tools.classfile.Exceptions_attribute; import com.sun.tools.classfile.InnerClasses_attribute; import com.sun.tools.classfile.LineNumberTable_attribute; import com.sun.tools.classfile.LocalVariableTable_attribute; import com.sun.tools.classfile.LocalVariableTypeTable_attribute; import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute; import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute; import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute; import com.sun.tools.classfile.Signature_attribute; import com.sun.tools.classfile.SourceDebugExtension_attribute; import com.sun.tools.classfile.SourceFile_attribute; import com.sun.tools.classfile.SourceID_attribute; import com.sun.tools.classfile.StackMapTable_attribute; import com.sun.tools.classfile.StackMap_attribute; import com.sun.tools.classfile.Synthetic_attribute; import static com.sun.tools.classfile.AccessFlags.*; /* * A writer for writing Attributes as text. * * <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 AttributeWriter extends BasicWriter implements Attribute.Visitor<Void,Void> { public static AttributeWriter instance(Context context) { AttributeWriter instance = context.get(AttributeWriter.class); if (instance == null) instance = new AttributeWriter(context); return instance; } protected AttributeWriter(Context context) { super(context); context.put(AttributeWriter.class, this); annotationWriter = AnnotationWriter.instance(context); codeWriter = CodeWriter.instance(context); constantWriter = ConstantWriter.instance(context); options = Options.instance(context); } public void write(Object owner, Attribute attr, ConstantPool constant_pool) { if (attr != null) { // null checks owner.getClass(); constant_pool.getClass(); this.constant_pool = constant_pool; this.owner = owner; attr.accept(this, null); } } public void write(Object owner, Attributes attrs, ConstantPool constant_pool) { if (attrs != null) { // null checks owner.getClass(); constant_pool.getClass(); this.constant_pool = constant_pool; this.owner = owner; for (Attribute attr: attrs) attr.accept(this, null); } } public Void visitDefault(DefaultAttribute attr, Void ignore) { byte[] data = attr.info; int i = 0; int j = 0; print(" "); try { print(attr.getName(constant_pool)); } catch (ConstantPoolException e) { report(e); print("attribute name = #" + attr.attribute_name_index); } print(": "); println("length = 0x" + toHex(attr.info.length)); print(" "); while (i < data.length) { print(toHex(data[i], 2)); j++; if (j == 16) { println(); print(" "); j = 0; } else { print(" "); } i++; } println(); return null; } public Void visitAnnotationDefault(AnnotationDefault_attribute attr, Void ignore) { println("AnnotationDefault:"); indent(+1); print("default_value: "); annotationWriter.write(attr.default_value); indent(-1); return null; } public Void visitBootstrapMethods(BootstrapMethods_attribute attr, Void p) { println(Attribute.BootstrapMethods + ":"); for (int i = 0; i < attr.bootstrap_method_specifiers.length ; i++) { BootstrapMethods_attribute.BootstrapMethodSpecifier bsm = attr.bootstrap_method_specifiers[i]; indent(+1); print(i + ": #" + bsm.bootstrap_method_ref + " "); println(constantWriter.stringValue(bsm.bootstrap_method_ref)); indent(+1); println("Method arguments:"); indent(+1); for (int j = 0; j < bsm.bootstrap_arguments.length; j++) { print("#" + bsm.bootstrap_arguments[j] + " "); println(constantWriter.stringValue(bsm.bootstrap_arguments[j])); } indent(-3); } return null; } public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, Void ignore) { println("CharacterRangeTable:"); indent(+1); for (int i = 0; i < attr.character_range_table.length; i++) { CharacterRangeTable_attribute.Entry e = attr.character_range_table[i]; print(String.format(" %2d, %2d, %6x, %6x, %4x", e.start_pc, e.end_pc, e.character_range_start, e.character_range_end, e.flags)); tab(); print(String.format("// %2d, %2d, %4d:%02d, %4d:%02d", e.start_pc, e.end_pc, (e.character_range_start >> 10), (e.character_range_start & 0x3ff), (e.character_range_end >> 10), (e.character_range_end & 0x3ff))); if ((e.flags & CharacterRangeTable_attribute.CRT_STATEMENT) != 0) print(", statement"); if ((e.flags & CharacterRangeTable_attribute.CRT_BLOCK) != 0) print(", block"); if ((e.flags & CharacterRangeTable_attribute.CRT_ASSIGNMENT) != 0) print(", assignment"); if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_CONTROLLER) != 0) print(", flow-controller"); if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_TARGET) != 0) print(", flow-target"); if ((e.flags & CharacterRangeTable_attribute.CRT_INVOKE) != 0) print(", invoke"); if ((e.flags & CharacterRangeTable_attribute.CRT_CREATE) != 0) print(", create"); if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_TRUE) != 0) print(", branch-true"); if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_FALSE) != 0) print(", branch-false"); println(); } indent(-1); return null; } public Void visitCode(Code_attribute attr, Void ignore) { codeWriter.write(attr, constant_pool); return null; } public Void visitCompilationID(CompilationID_attribute attr, Void ignore) { constantWriter.write(attr.compilationID_index); return null; } public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) { if (options.compat) // BUG 6622216 javap names some attributes incorrectly print("Constant value: "); else print("ConstantValue: "); constantWriter.write(attr.constantvalue_index); println(); return null; } public Void visitDeprecated(Deprecated_attribute attr, Void ignore) { println("Deprecated: true"); return null; } public Void visitEnclosingMethod(EnclosingMethod_attribute attr, Void ignore) { print("EnclosingMethod: #" + attr.class_index + ".#" + attr.method_index); tab(); print("// " + getJavaClassName(attr)); if (attr.method_index != 0) print("." + getMethodName(attr)); println(); return null; } private String getJavaClassName(EnclosingMethod_attribute a) { try { return getJavaName(a.getClassName(constant_pool)); } catch (ConstantPoolException e) { return report(e); } } private String getMethodName(EnclosingMethod_attribute a) { try { return a.getMethodName(constant_pool); } catch (ConstantPoolException e) { return report(e); } } public Void visitExceptions(Exceptions_attribute attr, Void ignore) { println("Exceptions:"); indent(+1); print("throws "); for (int i = 0; i < attr.number_of_exceptions; i++) { if (i > 0) print(", "); print(getJavaException(attr, i)); } println(); indent(-1); return null; } private String getJavaException(Exceptions_attribute attr, int index) { try { return getJavaName(attr.getException(index, constant_pool)); } catch (ConstantPoolException e) { return report(e); } } public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) { boolean first = true; if (options.compat) { writeInnerClassHeader(); first = false; } for (int i = 0 ; i < attr.classes.length; i++) { InnerClasses_attribute.Info info = attr.classes[i]; //access AccessFlags access_flags = info.inner_class_access_flags; if (options.compat) { // BUG 6622215: javap ignores certain relevant access flags access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM); // BUG 6622232: javap gets whitespace confused print(" "); } if (options.checkAccess(access_flags)) { if (first) { writeInnerClassHeader(); first = false; } print(" "); for (String name: access_flags.getInnerClassModifiers()) print(name + " "); if (info.inner_name_index!=0) { print("#" + info.inner_name_index + "= "); } print("#" + info.inner_class_info_index); if (info.outer_class_info_index != 0) { print(" of #" + info.outer_class_info_index); } print("; //"); if (info.inner_name_index != 0) { print(getInnerName(constant_pool, info) + "="); } constantWriter.write(info.inner_class_info_index); if (info.outer_class_info_index != 0) { print(" of "); constantWriter.write(info.outer_class_info_index); } println(); } } if (!first) indent(-1); return null; } String getInnerName(ConstantPool constant_pool, InnerClasses_attribute.Info info) { try { return info.getInnerName(constant_pool); } catch (ConstantPoolException e) { return report(e); } } private void writeInnerClassHeader() { if (options.compat) // BUG 6622216: javap names some attributes incorrectly print("InnerClass"); else print("InnerClasses"); println(":"); indent(+1); } public Void visitLineNumberTable(LineNumberTable_attribute attr, Void ignore) { println("LineNumberTable:"); indent(+1); for (LineNumberTable_attribute.Entry entry: attr.line_number_table) { println("line " + entry.line_number + ": " + entry.start_pc); } indent(-1); return null; } public Void visitLocalVariableTable(LocalVariableTable_attribute attr, Void ignore) { println("LocalVariableTable:"); indent(+1); println("Start Length Slot Name Signature"); for (LocalVariableTable_attribute.Entry entry : attr.local_variable_table) { Formatter formatter = new Formatter(); println(formatter.format("%8d %7d %5d %5s %s", entry.start_pc, entry.length, entry.index, constantWriter.stringValue(entry.name_index), constantWriter.stringValue(entry.descriptor_index))); } indent(-1); return null; } public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, Void ignore) { println("LocalVariableTypeTable:"); indent(+1); println("Start Length Slot Name Signature"); for (LocalVariableTypeTable_attribute.Entry entry : attr.local_variable_table) { println(String.format("%5d %7d %5d %5s %s", entry.start_pc, entry.length, entry.index, constantWriter.stringValue(entry.name_index), constantWriter.stringValue(entry.signature_index))); } indent(-1); return null; } public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) { println("RuntimeVisibleAnnotations:"); indent(+1); for (int i = 0; i < attr.annotations.length; i++) { print(i + ": "); annotationWriter.write(attr.annotations[i]); println(); } indent(-1); return null; } public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, Void ignore) { println("RuntimeInvisibleAnnotations:"); indent(+1); for (int i = 0; i < attr.annotations.length; i++) { print(i + ": "); annotationWriter.write(attr.annotations[i]); println(); } indent(-1); return null; } public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) { println("RuntimeVisibleParameterAnnotations:"); indent(+1); for (int param = 0; param < attr.parameter_annotations.length; param++) { println("parameter " + param + ": "); indent(+1); for (int i = 0; i < attr.parameter_annotations[param].length; i++) { print(i + ": "); annotationWriter.write(attr.parameter_annotations[param][i]); println(); } indent(-1); } indent(-1); return null; } public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, Void ignore) { println("RuntimeInvisibleParameterAnnotations:"); indent(+1); for (int param = 0; param < attr.parameter_annotations.length; param++) { println(param + ": "); indent(+1); for (int i = 0; i < attr.parameter_annotations[param].length; i++) { print(i + ": "); annotationWriter.write(attr.parameter_annotations[param][i]); println(); } indent(-1); } indent(-1); return null; } public Void visitSignature(Signature_attribute attr, Void ignore) { print("Signature: #" + attr.signature_index); tab(); println("// " + getSignature(attr)); return null; } String getSignature(Signature_attribute info) { try { return info.getSignature(constant_pool); } catch (ConstantPoolException e) { return report(e); } } public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) { println("SourceDebugExtension: " + attr.getValue()); return null; } public Void visitSourceFile(SourceFile_attribute attr, Void ignore) { println("SourceFile: \"" + getSourceFile(attr) + "\""); return null; } private String getSourceFile(SourceFile_attribute attr) { try { return attr.getSourceFile(constant_pool); } catch (ConstantPoolException e) { return report(e); } } public Void visitSourceID(SourceID_attribute attr, Void ignore) { constantWriter.write(attr.sourceID_index); return null; } public Void visitStackMap(StackMap_attribute attr, Void ignore) { println("StackMap: number_of_entries = " + attr.number_of_entries); indent(+1); StackMapTableWriter w = new StackMapTableWriter(); for (StackMapTable_attribute.stack_map_frame entry : attr.entries) { w.write(entry); } println(); indent(-1); return null; } public Void visitStackMapTable(StackMapTable_attribute attr, Void ignore) { println("StackMapTable: number_of_entries = " + attr.number_of_entries); indent(+1); StackMapTableWriter w = new StackMapTableWriter(); for (StackMapTable_attribute.stack_map_frame entry : attr.entries) { w.write(entry); } println(); indent(-1); return null; } class StackMapTableWriter // also handles CLDC StackMap attributes implements StackMapTable_attribute.stack_map_frame.Visitor<Void,Void> { public void write(StackMapTable_attribute.stack_map_frame frame) { frame.accept(this, null); } public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) { printHeader(frame); println(" /* same */"); return null; } public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) { printHeader(frame); println(" /* same_locals_1_stack_item */"); indent(+1); printMap("stack", frame.stack); indent(-1); return null; } public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) { printHeader(frame); println(" /* same_locals_1_stack_item_frame_extended */"); indent(+1); println("offset_delta = " + frame.offset_delta); printMap("stack", frame.stack); indent(-1); return null; } public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) { printHeader(frame); println(" /* chop */"); indent(+1); println("offset_delta = " + frame.offset_delta); indent(-1); return null; } public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) { printHeader(frame); println(" /* same_frame_extended */"); indent(+1); println("offset_delta = " + frame.offset_delta); indent(-1); return null; } public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) { printHeader(frame); println(" /* append */"); println(" offset_delta = " + frame.offset_delta); printMap("locals", frame.locals); return null; } public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) { printHeader(frame); if (frame instanceof StackMap_attribute.stack_map_frame) { indent(+1); println(" offset = " + frame.offset_delta); } else { println(" /* full_frame */"); indent(+1); println("offset_delta = " + frame.offset_delta); } printMap("locals", frame.locals); printMap("stack", frame.stack); indent(-1); return null; } void printHeader(StackMapTable_attribute.stack_map_frame frame) { print(" frame_type = " + frame.frame_type); } void printMap(String name, StackMapTable_attribute.verification_type_info[] map) { print(name + " = ["); for (int i = 0; i < map.length; i++) { StackMapTable_attribute.verification_type_info info = map[i]; int tag = info.tag; switch (tag) { case StackMapTable_attribute.verification_type_info.ITEM_Object: print(" "); constantWriter.write(((StackMapTable_attribute.Object_variable_info) info).cpool_index); break; case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized: print(" " + mapTypeName(tag)); print(" " + ((StackMapTable_attribute.Uninitialized_variable_info) info).offset); break; default: print(" " + mapTypeName(tag)); } print(i == (map.length - 1) ? " " : ","); } println("]"); } String mapTypeName(int tag) { switch (tag) { case StackMapTable_attribute.verification_type_info.ITEM_Top: return "top"; case StackMapTable_attribute.verification_type_info.ITEM_Integer: return "int"; case StackMapTable_attribute.verification_type_info.ITEM_Float: return "float"; case StackMapTable_attribute.verification_type_info.ITEM_Long: return "long"; case StackMapTable_attribute.verification_type_info.ITEM_Double: return "double"; case StackMapTable_attribute.verification_type_info.ITEM_Null: return "null"; case StackMapTable_attribute.verification_type_info.ITEM_UninitializedThis: return "this"; case StackMapTable_attribute.verification_type_info.ITEM_Object: return "CP"; case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized: return "uninitialized"; default: report("unrecognized verification_type_info tag: " + tag); return "[tag:" + tag + "]"; } } } public Void visitSynthetic(Synthetic_attribute attr, Void ignore) { println("Synthetic: true"); return null; } static String getJavaName(String name) { return name.replace('/', '.'); } String toHex(byte b, int w) { if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex return toHex((int) b, w); else return toHex(b & 0xff, w); } static String toHex(int i) { return Integer.toString(i, 16).toUpperCase(); } static String toHex(int i, int w) { String s = Integer.toHexString(i).toUpperCase(); while (s.length() < w) s = "0" + s; return s.toUpperCase(); } private AnnotationWriter annotationWriter; private CodeWriter codeWriter; private ConstantWriter constantWriter; private Options options; private ConstantPool constant_pool; private Object owner; }
25,297
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
JavapFileManager.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/JavapFileManager.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.io.PrintWriter; import java.nio.charset.Charset; import javax.tools.DiagnosticListener; import javax.tools.JavaFileObject; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.util.Context; /** * javap's implementation of JavaFileManager. * * <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 JavapFileManager extends JavacFileManager { private JavapFileManager(Context context, Charset charset) { super(context, true, charset); setIgnoreSymbolFile(true); } public static JavapFileManager create(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) { Context javac_context = new Context(); if (dl != null) javac_context.put(DiagnosticListener.class, dl); javac_context.put(com.sun.tools.javac.util.Log.outKey, log); return new JavapFileManager(javac_context, null); } void setIgnoreSymbolFile(boolean b) { ignoreSymbolFile = b; } }
2,416
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
SourceWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/SourceWriter.java
/* * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; import java.util.TreeMap; import java.util.TreeSet; import javax.tools.JavaFileManager; import javax.tools.JavaFileManager.Location; import javax.tools.JavaFileObject; import javax.tools.StandardLocation; import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Instruction; import com.sun.tools.classfile.LineNumberTable_attribute; import com.sun.tools.classfile.SourceFile_attribute; /** * Annotate instructions with source code. * * <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 SourceWriter extends InstructionDetailWriter { static SourceWriter instance(Context context) { SourceWriter instance = context.get(SourceWriter.class); if (instance == null) instance = new SourceWriter(context); return instance; } protected SourceWriter(Context context) { super(context); context.put(SourceWriter.class, this); } void setFileManager(JavaFileManager fileManager) { this.fileManager = fileManager; } public void reset(ClassFile cf, Code_attribute attr) { setSource(cf); setLineMap(attr); } public void writeDetails(Instruction instr) { String indent = space(40); // could get from Options? Set<Integer> lines = lineMap.get(instr.getPC()); if (lines != null) { for (int line: lines) { print(indent); print(String.format(" %4d ", line)); if (line < sourceLines.length) print(sourceLines[line]); println(); int nextLine = nextLine(line); for (int i = line + 1; i < nextLine; i++) { print(indent); print(String.format("(%4d)", i)); if (i < sourceLines.length) print(sourceLines[i]); println(); } } } } public boolean hasSource() { return (sourceLines.length > 0); } private void setLineMap(Code_attribute attr) { SortedMap<Integer, SortedSet<Integer>> map = new TreeMap<Integer, SortedSet<Integer>>(); SortedSet<Integer> allLines = new TreeSet<Integer>(); for (Attribute a: attr.attributes) { if (a instanceof LineNumberTable_attribute) { LineNumberTable_attribute t = (LineNumberTable_attribute) a; for (LineNumberTable_attribute.Entry e: t.line_number_table) { int start_pc = e.start_pc; int line = e.line_number; SortedSet<Integer> pcLines = map.get(start_pc); if (pcLines == null) { pcLines = new TreeSet<Integer>(); map.put(start_pc, pcLines); } pcLines.add(line); allLines.add(line); } } } lineMap = map; lineList = new ArrayList<Integer>(allLines); } private void setSource(ClassFile cf) { if (cf != classFile) { classFile = cf; sourceLines = splitLines(readSource(cf)); } } private String readSource(ClassFile cf) { if (fileManager == null) return null; Location location; if (fileManager.hasLocation((StandardLocation.SOURCE_PATH))) location = StandardLocation.SOURCE_PATH; else location = StandardLocation.CLASS_PATH; // Guess the source file for a class from the package name for this // class and the base of the source file. This avoids having to read // additional classes to determine the outmost class from any // InnerClasses and EnclosingMethod attributes. try { String className = cf.getName(); SourceFile_attribute sf = (SourceFile_attribute) cf.attributes.get(Attribute.SourceFile); if (sf == null) { report(messages.getMessage("err.no.SourceFile.attribute")); return null; } String sourceFile = sf.getSourceFile(cf.constant_pool); String fileBase = sourceFile.endsWith(".java") ? sourceFile.substring(0, sourceFile.length() - 5) : sourceFile; int sep = className.lastIndexOf("/"); String pkgName = (sep == -1 ? "" : className.substring(0, sep+1)); String topClassName = (pkgName + fileBase).replace('/', '.'); JavaFileObject fo = fileManager.getJavaFileForInput(location, topClassName, JavaFileObject.Kind.SOURCE); if (fo == null) { report(messages.getMessage("err.source.file.not.found")); return null; } return fo.getCharContent(true).toString(); } catch (ConstantPoolException e) { report(e); return null; } catch (IOException e) { report(e.getLocalizedMessage()); return null; } } private static String[] splitLines(String text) { if (text == null) return new String[0]; List<String> lines = new ArrayList<String>(); lines.add(""); // dummy line 0 try { BufferedReader r = new BufferedReader(new StringReader(text)); String line; while ((line = r.readLine()) != null) lines.add(line); } catch (IOException ignore) { } return lines.toArray(new String[lines.size()]); } private int nextLine(int line) { int i = lineList.indexOf(line); if (i == -1 || i == lineList.size() - 1) return - 1; return lineList.get(i + 1); } private JavaFileManager fileManager; private ClassFile classFile; private SortedMap<Integer, SortedSet<Integer>> lineMap; private List<Integer> lineList; private String[] sourceLines; }
7,850
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Context.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/Context.java
/* * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.util.HashMap; import java.util.Map; /* * Class from which to put/get shared resources. * * <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 Context { public Context() { map = new HashMap<Class<?>, Object>(); } @SuppressWarnings("unchecked") public <T> T get(Class<T> key) { return (T) map.get(key); } @SuppressWarnings("unchecked") public <T> T put(Class<T> key, T value) { return (T) map.put(key, value); } Map<Class<?>, Object> map; }
1,946
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
CodeWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/CodeWriter.java
/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import java.util.ArrayList; import java.util.List; import com.sun.tools.classfile.AccessFlags; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.DescriptorException; import com.sun.tools.classfile.Instruction; import com.sun.tools.classfile.Instruction.TypeKind; import com.sun.tools.classfile.Method; /* * Write the contents of a Code attribute. * * <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> */ class CodeWriter extends BasicWriter { static CodeWriter instance(Context context) { CodeWriter instance = context.get(CodeWriter.class); if (instance == null) instance = new CodeWriter(context); return instance; } protected CodeWriter(Context context) { super(context); context.put(CodeWriter.class, this); attrWriter = AttributeWriter.instance(context); classWriter = ClassWriter.instance(context); constantWriter = ConstantWriter.instance(context); sourceWriter = SourceWriter.instance(context); tryBlockWriter = TryBlockWriter.instance(context); stackMapWriter = StackMapWriter.instance(context); localVariableTableWriter = LocalVariableTableWriter.instance(context); localVariableTypeTableWriter = LocalVariableTypeTableWriter.instance(context); options = Options.instance(context); } void write(Code_attribute attr, ConstantPool constant_pool) { println("Code:"); indent(+1); writeVerboseHeader(attr, constant_pool); writeInstrs(attr); writeExceptionTable(attr); attrWriter.write(attr, attr.attributes, constant_pool); indent(-1); } public void writeVerboseHeader(Code_attribute attr, ConstantPool constant_pool) { Method method = classWriter.getMethod(); String argCount; try { int n = method.descriptor.getParameterCount(constant_pool); if (!method.access_flags.is(AccessFlags.ACC_STATIC)) ++n; // for 'this' argCount = Integer.toString(n); } catch (ConstantPoolException e) { argCount = report(e); } catch (DescriptorException e) { argCount = report(e); } println("stack=" + attr.max_stack + ", locals=" + attr.max_locals + ", args_size=" + argCount); } public void writeInstrs(Code_attribute attr) { List<InstructionDetailWriter> detailWriters = getDetailWriters(attr); for (Instruction instr: attr.getInstructions()) { try { for (InstructionDetailWriter w: detailWriters) w.writeDetails(instr); writeInstr(instr); } catch (ArrayIndexOutOfBoundsException e) { println(report("error at or after byte " + instr.getPC())); break; } } for (InstructionDetailWriter w: detailWriters) w.flush(); } public void writeInstr(Instruction instr) { print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic())); // compute the number of indentations for the body of multi-line instructions // This is 6 (the width of "%4d: "), divided by the width of each indentation level, // and rounded up to the next integer. int indentWidth = options.indentWidth; int indent = (6 + indentWidth - 1) / indentWidth; instr.accept(instructionPrinter, indent); println(); } // where Instruction.KindVisitor<Void,Integer> instructionPrinter = new Instruction.KindVisitor<Void,Integer>() { public Void visitNoOperands(Instruction instr, Integer indent) { return null; } public Void visitArrayType(Instruction instr, TypeKind kind, Integer indent) { print(" " + kind.name); return null; } public Void visitBranch(Instruction instr, int offset, Integer indent) { print((instr.getPC() + offset)); return null; } public Void visitConstantPoolRef(Instruction instr, int index, Integer indent) { print("#" + index); tab(); print("// "); printConstant(index); return null; } public Void visitConstantPoolRefAndValue(Instruction instr, int index, int value, Integer indent) { print("#" + index + ", " + value); tab(); print("// "); printConstant(index); return null; } public Void visitLocal(Instruction instr, int index, Integer indent) { print(index); return null; } public Void visitLocalAndValue(Instruction instr, int index, int value, Integer indent) { print(index + ", " + value); return null; } public Void visitLookupSwitch(Instruction instr, int default_, int npairs, int[] matches, int[] offsets, Integer indent) { int pc = instr.getPC(); print("{ // " + npairs); indent(indent); for (int i = 0; i < npairs; i++) { print(String.format("%n%12d: %d", matches[i], (pc + offsets[i]))); } print("\n default: " + (pc + default_) + "\n}"); indent(-indent); return null; } public Void visitTableSwitch(Instruction instr, int default_, int low, int high, int[] offsets, Integer indent) { int pc = instr.getPC(); print("{ // " + low + " to " + high); indent(indent); for (int i = 0; i < offsets.length; i++) { print(String.format("%n%12d: %d", (low + i), (pc + offsets[i]))); } print("\n default: " + (pc + default_) + "\n}"); indent(-indent); return null; } public Void visitValue(Instruction instr, int value, Integer indent) { print(value); return null; } public Void visitUnknown(Instruction instr, Integer indent) { return null; } }; public void writeExceptionTable(Code_attribute attr) { if (attr.exception_table_langth > 0) { println("Exception table:"); indent(+1); println(" from to target type"); for (int i = 0; i < attr.exception_table.length; i++) { Code_attribute.Exception_data handler = attr.exception_table[i]; print(String.format(" %5d %5d %5d", handler.start_pc, handler.end_pc, handler.handler_pc)); print(" "); int catch_type = handler.catch_type; if (catch_type == 0) { println("any"); } else { print("Class "); println(constantWriter.stringValue(catch_type)); } } indent(-1); } } private void printConstant(int index) { constantWriter.write(index); } private List<InstructionDetailWriter> getDetailWriters(Code_attribute attr) { List<InstructionDetailWriter> detailWriters = new ArrayList<InstructionDetailWriter>(); if (options.details.contains(InstructionDetailWriter.Kind.SOURCE)) { sourceWriter.reset(classWriter.getClassFile(), attr); if (sourceWriter.hasSource()) detailWriters.add(sourceWriter); else println("(Source code not available)"); } if (options.details.contains(InstructionDetailWriter.Kind.LOCAL_VARS)) { localVariableTableWriter.reset(attr); detailWriters.add(localVariableTableWriter); } if (options.details.contains(InstructionDetailWriter.Kind.LOCAL_VAR_TYPES)) { localVariableTypeTableWriter.reset(attr); detailWriters.add(localVariableTypeTableWriter); } if (options.details.contains(InstructionDetailWriter.Kind.STACKMAPS)) { stackMapWriter.reset(attr); stackMapWriter.writeInitialDetails(); detailWriters.add(stackMapWriter); } if (options.details.contains(InstructionDetailWriter.Kind.TRY_BLOCKS)) { tryBlockWriter.reset(attr); detailWriters.add(tryBlockWriter); } return detailWriters; } private AttributeWriter attrWriter; private ClassWriter classWriter; private ConstantWriter constantWriter; private LocalVariableTableWriter localVariableTableWriter; private LocalVariableTypeTableWriter localVariableTypeTableWriter; private SourceWriter sourceWriter; private StackMapWriter stackMapWriter; private TryBlockWriter tryBlockWriter; private Options options; }
10,471
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
LocalVariableTypeTableWriter.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/tools/javap/LocalVariableTypeTableWriter.java
/* * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.tools.javap; import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Descriptor; import com.sun.tools.classfile.Descriptor.InvalidDescriptor; import com.sun.tools.classfile.Instruction; import com.sun.tools.classfile.LocalVariableTypeTable_attribute; import com.sun.tools.classfile.Signature; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; /** * Annotate instructions with details about local variables. * * <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 LocalVariableTypeTableWriter extends InstructionDetailWriter { public enum NoteKind { START("start") { public boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc) { return (pc == entry.start_pc); } }, END("end") { public boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc) { return (pc == entry.start_pc + entry.length); } }; NoteKind(String text) { this.text = text; } public abstract boolean match(LocalVariableTypeTable_attribute.Entry entry, int pc); public final String text; }; static LocalVariableTypeTableWriter instance(Context context) { LocalVariableTypeTableWriter instance = context.get(LocalVariableTypeTableWriter.class); if (instance == null) instance = new LocalVariableTypeTableWriter(context); return instance; } protected LocalVariableTypeTableWriter(Context context) { super(context); context.put(LocalVariableTypeTableWriter.class, this); classWriter = ClassWriter.instance(context); } public void reset(Code_attribute attr) { codeAttr = attr; pcMap = new HashMap<Integer, List<LocalVariableTypeTable_attribute.Entry>>(); LocalVariableTypeTable_attribute lvt = (LocalVariableTypeTable_attribute) (attr.attributes.get(Attribute.LocalVariableTypeTable)); if (lvt == null) return; for (int i = 0; i < lvt.local_variable_table.length; i++) { LocalVariableTypeTable_attribute.Entry entry = lvt.local_variable_table[i]; put(entry.start_pc, entry); put(entry.start_pc + entry.length, entry); } } public void writeDetails(Instruction instr) { int pc = instr.getPC(); writeLocalVariables(pc, NoteKind.END); writeLocalVariables(pc, NoteKind.START); } @Override public void flush() { int pc = codeAttr.code_length; writeLocalVariables(pc, NoteKind.END); } public void writeLocalVariables(int pc, NoteKind kind) { ConstantPool constant_pool = classWriter.getClassFile().constant_pool; String indent = space(2); // get from Options? List<LocalVariableTypeTable_attribute.Entry> entries = pcMap.get(pc); if (entries != null) { for (ListIterator<LocalVariableTypeTable_attribute.Entry> iter = entries.listIterator(kind == NoteKind.END ? entries.size() : 0); kind == NoteKind.END ? iter.hasPrevious() : iter.hasNext() ; ) { LocalVariableTypeTable_attribute.Entry entry = kind == NoteKind.END ? iter.previous() : iter.next(); if (kind.match(entry, pc)) { print(indent); print(kind.text); print(" generic local "); print(entry.index); print(" // "); Descriptor d = new Signature(entry.signature_index); try { print(d.getFieldType(constant_pool).toString().replace("/", ".")); } catch (InvalidDescriptor e) { print(report(e)); } catch (ConstantPoolException e) { print(report(e)); } print(" "); try { print(constant_pool.getUTF8Value(entry.name_index)); } catch (ConstantPoolException e) { print(report(e)); } println(); } } } } private void put(int pc, LocalVariableTypeTable_attribute.Entry entry) { List<LocalVariableTypeTable_attribute.Entry> list = pcMap.get(pc); if (list == null) { list = new ArrayList<LocalVariableTypeTable_attribute.Entry>(); pcMap.put(pc, list); } if (!list.contains(entry)) list.add(entry); } private ClassWriter classWriter; private Code_attribute codeAttr; private Map<Integer, List<LocalVariableTypeTable_attribute.Entry>> pcMap; }
6,438
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ExecutableDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.util.Collection; import com.sun.mirror.type.ReferenceType; /** * Represents a method or constructor of a class or interface. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.element.ExecutableElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface ExecutableDeclaration extends MemberDeclaration { /** * Returns <tt>true</tt> if this method or constructor accepts a variable * number of arguments. * * @return <tt>true</tt> if this method or constructor accepts a variable * number of arguments */ boolean isVarArgs(); /** * Returns the formal type parameters of this method or constructor. * They are returned in declaration order. * * @return the formal type parameters of this method or constructor, * or an empty collection if there are none */ Collection<TypeParameterDeclaration> getFormalTypeParameters(); /** * Returns the formal parameters of this method or constructor. * They are returned in declaration order. * * @return the formal parameters of this method or constructor, * or an empty collection if there are none */ Collection<ParameterDeclaration> getParameters(); /** * Returns the exceptions and other throwables listed in this * method or constructor's <tt>throws</tt> clause. * * @return the exceptions and other throwables listed in the * <tt>throws</tt> clause, or an empty collection if there are none */ Collection<ReferenceType> getThrownTypes(); }
3,041
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationTypeDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.util.Collection; /** * Represents the declaration of an annotation type. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.TypeElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationTypeDeclaration extends InterfaceDeclaration { /** * Returns the annotation type elements of this annotation type. * These are the methods that are directly declared in the type's * declaration. * * @return the annotation type elements of this annotation type, * or an empty collection if there are none */ Collection<AnnotationTypeElementDeclaration> getMethods(); }
2,132
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
package-info.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/package-info.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ /** * Interfaces used to model program element declarations. A * declaration is represented by the appropriate subinterface of * {@link com.sun.mirror.declaration.Declaration}, and an annotation * is represented as an {@link * com.sun.mirror.declaration.AnnotationMirror}. * * <p>The {@code apt} tool and its associated API have been superseded * by the standardized annotation processing API. The replacement for * the functionality in this package is {@link * javax.lang.model.element}. * * @since 1.5 */ package com.sun.mirror.declaration;
1,766
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ConstructorDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; /** * Represents a constructor of a class or interface. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.ExecutableElement}. * * @author Joe Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface ConstructorDeclaration extends ExecutableDeclaration { }
1,736
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationTypeElementDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; /** * Represents an element of an annotation type. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.ExecutableElement}. * * @author Joe Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationTypeElementDeclaration extends MethodDeclaration { /** * Returns the default value of this element. * * @return the default value of this element, or null if this element * has no default. */ AnnotationValue getDefaultValue(); /** * {@inheritDoc} */ AnnotationTypeDeclaration getDeclaringType(); }
2,035
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ParameterDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import com.sun.mirror.type.TypeMirror; /** * Represents a formal parameter of a method or constructor. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.VariableElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface ParameterDeclaration extends Declaration { /** * Returns the type of this parameter. * * @return the type of this parameter */ TypeMirror getType(); }
1,912
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
FieldDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import com.sun.mirror.type.TypeMirror; /** * Represents a field of a type declaration. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.VariableElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface FieldDeclaration extends MemberDeclaration { /** * Returns the type of this field. * * @return the type of this field */ TypeMirror getType(); /** * Returns the value of this field if this field is a compile-time * constant. Returns <tt>null</tt> otherwise. * The value will be of a primitive type or <tt>String</tt>. * If the value is of a primitive type, it is wrapped in the * appropriate wrapper class (such as {@link Integer}). * * @return the value of this field if this field is a compile-time * constant, or <tt>null</tt> otherwise */ Object getConstantValue(); /** * Returns the text of a <i>constant expression</i> representing the * value of this field if this field is a compile-time constant. * Returns <tt>null</tt> otherwise. * The value will be of a primitive type or <tt>String</tt>. * The text returned is in a form suitable for representing the value * in source code. * * @return the text of a constant expression if this field is a * compile-time constant, or <tt>null</tt> otherwise */ String getConstantExpression(); }
2,910
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MemberDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; /** * Represents a declaration that may be a member or constructor of a declared * type. This includes fields, constructors, methods, and (since they * may be nested) declared types themselves. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.element.Element}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface MemberDeclaration extends Declaration { /** * Returns the type declaration within which this member or constructor * is declared. * If this is the declaration of a top-level type (a non-nested class * or interface), returns null. * * @return the type declaration within which this member or constructor * is declared, or null if there is none */ TypeDeclaration getDeclaringType(); }
2,237
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeParameterDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.util.Collection; import com.sun.mirror.type.*; /** * Represents a formal type parameter of a generic type, method, * or constructor declaration. * A type parameter declares a {@link TypeVariable}. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.element.TypeParameterElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface TypeParameterDeclaration extends Declaration { /** * Returns the bounds of this type parameter. * These are the types given by the <i>extends</i> clause. * If there is no explicit <i>extends</i> clause, then * <tt>java.lang.Object</tt> is considered to be the sole bound. * * @return the bounds of this type parameter */ Collection<ReferenceType> getBounds(); /** * Returns the type, method, or constructor declaration within which * this type parameter is declared. * * @return the declaration within which this type parameter is declared */ Declaration getOwner(); }
2,481
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.util.Collection; /** * Represents the declaration of an enum type. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.TypeElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface EnumDeclaration extends ClassDeclaration { /** * Returns the enum constants defined for this enum. * * @return the enum constants defined for this enum, * or an empty collection if there are none */ Collection<EnumConstantDeclaration> getEnumConstants(); }
1,995
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Declaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/Declaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.lang.annotation.Annotation; import java.util.Collection; import com.sun.mirror.type.*; import com.sun.mirror.util.*; /** * Represents the declaration of a program element such as a package, * class, or method. Each declaration represents a static, language-level * construct (and not, for example, a runtime construct of the virtual * machine), and typically corresponds one-to-one with a particular * fragment of source code. * * <p> Declarations should be compared using the {@link #equals(Object)} * method. There is no guarantee that any particular declaration will * always be represented by the same object. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.element.Element}. * * @author Joseph D. Darcy * @author Scott Seligman * * @see Declarations * @see TypeMirror * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface Declaration { /** * Tests whether an object represents the same declaration as this. * * @param obj the object to be compared with this declaration * @return <tt>true</tt> if the specified object represents the same * declaration as this */ boolean equals(Object obj); /** * Returns the text of the documentation ("javadoc") comment of * this declaration. * * @return the documentation comment of this declaration, or <tt>null</tt> * if there is none */ String getDocComment(); /** * Returns the annotations that are directly present on this declaration. * * @return the annotations directly present on this declaration; * an empty collection if there are none */ Collection<AnnotationMirror> getAnnotationMirrors(); /** * Returns the annotation of this declaration having the specified * type. The annotation may be either inherited or directly * present on this declaration. * * <p> The annotation returned by this method could contain an element * whose value is of type <tt>Class</tt>. * This value cannot be returned directly: information necessary to * locate and load a class (such as the class loader to use) is * not available, and the class might not be loadable at all. * Attempting to read a <tt>Class</tt> object by invoking the relevant * method on the returned annotation * will result in a {@link MirroredTypeException}, * from which the corresponding {@link TypeMirror} may be extracted. * Similarly, attempting to read a <tt>Class[]</tt>-valued element * will result in a {@link MirroredTypesException}. * * <blockquote> * <i>Note:</i> This method is unlike * others in this and related interfaces. It operates on run-time * reflective information -- representations of annotation types * currently loaded into the VM -- rather than on the mirrored * representations defined by and used throughout these * interfaces. It is intended for callers that are written to * operate on a known, fixed set of annotation types. * </blockquote> * * @param <A> the annotation type * @param annotationType the <tt>Class</tt> object corresponding to * the annotation type * @return the annotation of this declaration having the specified type * * @see #getAnnotationMirrors() */ <A extends Annotation> A getAnnotation(Class<A> annotationType); /** * Returns the modifiers of this declaration, excluding annotations. * Implicit modifiers, such as the <tt>public</tt> and <tt>static</tt> * modifiers of interface members, are included. * * @return the modifiers of this declaration in undefined order; * an empty collection if there are none */ Collection<Modifier> getModifiers(); /** * Returns the simple (unqualified) name of this declaration. * The name of a generic type does not include any reference * to its formal type parameters. * For example, the simple name of the interface declaration * {@code java.util.Set<E>} is <tt>"Set"</tt>. * If this declaration represents the empty package, an empty * string is returned. * If it represents a constructor, the simple name of its * declaring class is returned. * * @return the simple name of this declaration */ String getSimpleName(); /** * Returns the source position of the beginning of this declaration. * Returns <tt>null</tt> if the position is unknown or not applicable. * * <p> This source position is intended for use in providing * diagnostics, and indicates only approximately where a declaration * begins. * * @return the source position of the beginning of this declaration, * or null if the position is unknown or not applicable */ SourcePosition getPosition(); /** * Applies a visitor to this declaration. * * @param v the visitor operating on this declaration */ void accept(DeclarationVisitor v); }
6,511
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationMirror.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.util.Map; import com.sun.mirror.type.AnnotationType; import com.sun.mirror.util.SourcePosition; /** * Represents an annotation. An annotation associates a value with * each element of an annotation type. * * <p> Annotations should not be compared using reference-equality * ("<tt>==</tt>"). There is no guarantee that any particular * annotation will always be represented by the same object. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.element.AnnotationMirror}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationMirror { /** * Returns the annotation type of this annotation. * * @return the annotation type of this annotation */ AnnotationType getAnnotationType(); /** * Returns the source position of the beginning of this annotation. * Returns null if the position is unknown or not applicable. * * <p>This source position is intended for use in providing diagnostics, * and indicates only approximately where an annotation begins. * * @return the source position of the beginning of this annotation or * null if the position is unknown or not applicable */ SourcePosition getPosition(); /** * Returns this annotation's elements and their values. * This is returned in the form of a map that associates elements * with their corresponding values. * Only those elements and values explicitly present in the * annotation are included, not those that are implicitly assuming * their default values. * The order of the map matches the order in which the * elements appear in the annotation's source. * * @return this annotation's elements and their values, * or an empty map if there are none */ Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues(); }
3,351
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationValue.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/AnnotationValue.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import com.sun.mirror.util.SourcePosition; /** * Represents a value of an annotation type element. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.element.AnnotationValue}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationValue { /** * Returns the value. * The result has one of the following types: * <ul><li> a wrapper class (such as {@link Integer}) for a primitive type * <li> {@code String} * <li> {@code TypeMirror} * <li> {@code EnumConstantDeclaration} * <li> {@code AnnotationMirror} * <li> {@code Collection<AnnotationValue>} * (representing the elements, in order, if the value is an array) * </ul> * * @return the value */ Object getValue(); /** * Returns the source position of the beginning of this annotation value. * Returns null if the position is unknown or not applicable. * * <p>This source position is intended for use in providing diagnostics, * and indicates only approximately where an annotation value begins. * * @return the source position of the beginning of this annotation value or * null if the position is unknown or not applicable */ SourcePosition getPosition(); /** * Returns a string representation of this value. * This is returned in a form suitable for representing this value * in the source code of an annotation. * * @return a string representation of this value */ String toString(); }
3,028
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.util.Collection; import com.sun.mirror.type.*; /** * Represents the declaration of a class or interface. * Provides access to information about the type and its members. * Note that an {@linkplain EnumDeclaration enum} is a kind of class, * and an {@linkplain AnnotationTypeDeclaration annotation type} is * a kind of interface. * * <p> <a name="DECL_VS_TYPE"></a> * While a <tt>TypeDeclaration</tt> represents the <i>declaration</i> * of a class or interface, a {@link DeclaredType} represents a class * or interface <i>type</i>, the latter being a use * (or <i>invocation</i>) of the former. * The distinction is most apparent with generic types, * for which a single declaration can define a whole * family of types. For example, the declaration of * {@code java.util.Set} corresponds to the parameterized types * {@code java.util.Set<String>} and {@code java.util.Set<Number>} * (and many others), and to the raw type {@code java.util.Set}. * * <p> {@link com.sun.mirror.util.DeclarationFilter} * provides a simple way to select just the items of interest * when a method returns a collection of declarations. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.TypeElement}. * * @author Joseph D. Darcy * @author Scott Seligman * * @see DeclaredType * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface TypeDeclaration extends MemberDeclaration { /** * Returns the package within which this type is declared. * * @return the package within which this type is declared */ PackageDeclaration getPackage(); /** * Returns the fully qualified name of this class or interface * declaration. More precisely, it returns the <i>canonical</i> * name. * The name of a generic type does not include any reference * to its formal type parameters. * For example, the the fully qualified name of the interface declaration * {@code java.util.Set<E>} is <tt>"java.util.Set"</tt>. * * @return the fully qualified name of this class or interface declaration */ String getQualifiedName(); /** * Returns the formal type parameters of this class or interface. * * @return the formal type parameters, or an empty collection * if there are none */ Collection<TypeParameterDeclaration> getFormalTypeParameters(); /** * Returns the interface types directly implemented by this class * or extended by this interface. * * @return the interface types directly implemented by this class * or extended by this interface, or an empty collection if there are none * * @see com.sun.mirror.util.DeclarationFilter */ Collection<InterfaceType> getSuperinterfaces(); /** * Returns the fields that are directly declared by this class or * interface. Includes enum constants. * * @return the fields that are directly declared, * or an empty collection if there are none * * @see com.sun.mirror.util.DeclarationFilter */ Collection<FieldDeclaration> getFields(); /** * Returns the methods that are directly declared by this class or * interface. Includes annotation type elements. Excludes * implicitly declared methods of an interface, such as * <tt>toString</tt>, that correspond to the methods of * <tt>java.lang.Object</tt>. * * @return the methods that are directly declared, * or an empty collection if there are none * * @see com.sun.mirror.util.DeclarationFilter */ Collection<? extends MethodDeclaration> getMethods(); /** * Returns the declarations of the nested classes and interfaces * that are directly declared by this class or interface. * * @return the declarations of the nested classes and interfaces, * or an empty collection if there are none * * @see com.sun.mirror.util.DeclarationFilter */ Collection<TypeDeclaration> getNestedTypes(); }
5,451
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MethodDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import com.sun.mirror.type.TypeMirror; import com.sun.mirror.type.VoidType; /** * Represents a method of a class or interface. * Note that an * {@linkplain AnnotationTypeElementDeclaration annotation type element} * is a kind of method. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.ExecutableElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface MethodDeclaration extends ExecutableDeclaration { /** * Returns the formal return type of this method. * Returns {@link VoidType} if this method does not return a value. * * @return the formal return type of this method */ TypeMirror getReturnType(); }
2,158
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumConstantDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; /** * Represents an enum constant declaration. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.VariableElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface EnumConstantDeclaration extends FieldDeclaration { /** * {@inheritDoc} */ EnumDeclaration getDeclaringType(); }
1,804
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
InterfaceDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import com.sun.mirror.type.InterfaceType; /** * Represents the declaration of an interface. * Provides access to information about the interface and its members. * Note that an {@linkplain AnnotationTypeDeclaration annotation type} is * a kind of interface. * * <p> While an <tt>InterfaceDeclaration</tt> represents the * <i>declaration</i> of an interface, an {@link InterfaceType} * represents an interface <i>type</i>. * See {@link TypeDeclaration} for more on this distinction. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.TypeElement}. * * @author Joseph D. Darcy * @author Scott Seligman * * @see InterfaceType * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface InterfaceDeclaration extends TypeDeclaration { }
2,189
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PackageDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.util.Collection; /** * Represents the declaration of a package. Provides access to information * about the package and its members. * * <p> {@link com.sun.mirror.util.DeclarationFilter} * provides a simple way to select just the items of interest * when a method returns a collection of declarations. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.element.PackageElement}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface PackageDeclaration extends Declaration { /** * Returns the fully qualified name of this package. * This is also known as the package's <i>canonical</i> name. * * @return the fully qualified name of this package, or the * empty string if this is the unnamed package */ String getQualifiedName(); /** * Returns the declarations of the top-level classes in this package. * Interfaces are not included, but enum types are. * * @return the declarations of the top-level classes in this package * * @see com.sun.mirror.util.DeclarationFilter */ Collection<ClassDeclaration> getClasses(); /** * Returns the declarations of the top-level enum types in this package. * * @return the declarations of the top-level enum types in this package * * @see com.sun.mirror.util.DeclarationFilter */ Collection<EnumDeclaration> getEnums(); /** * Returns the declarations of the top-level interfaces in this package. * Annotation types are included. * * @return the declarations of the top-level interfaces in this package * * @see com.sun.mirror.util.DeclarationFilter */ Collection<InterfaceDeclaration> getInterfaces(); /** * Returns the declarations of the top-level annotation types in this * package. * * @return the declarations of the top-level annotation types in this * package * * @see com.sun.mirror.util.DeclarationFilter */ Collection<AnnotationTypeDeclaration> getAnnotationTypes(); }
3,530
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassDeclaration.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; import java.util.Collection; import com.sun.mirror.type.ClassType; /** * Represents the declaration of a class. * For the declaration of an interface, see {@link InterfaceDeclaration}. * Provides access to information about the class, its members, and * its constructors. * Note that an {@linkplain EnumDeclaration enum} is a kind of class. * * <p> While a <tt>ClassDeclaration</tt> represents the <i>declaration</i> * of a class, a {@link ClassType} represents a class <i>type</i>. * See {@link TypeDeclaration} for more on this distinction. * * <p> {@link com.sun.mirror.util.DeclarationFilter} * provides a simple way to select just the items of interest * when a method returns a collection of declarations. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.element.TypeElement}. * * @author Joseph D. Darcy * @author Scott Seligman * * @see ClassType * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface ClassDeclaration extends TypeDeclaration { /** * Returns the class type directly extended by this class. * The only class with no superclass is <tt>java.lang.Object</tt>, * for which this method returns null. * * @return the class type directly extended by this class, or null * if there is none */ ClassType getSuperclass(); /** * Returns the constructors of this class. * This includes the default constructor if this class has * no constructors explicitly declared. * * @return the constructors of this class * * @see com.sun.mirror.util.DeclarationFilter */ Collection<ConstructorDeclaration> getConstructors(); /** * {@inheritDoc} */ Collection<MethodDeclaration> getMethods(); }
3,168
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Modifier.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/declaration/Modifier.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.declaration; /** * Represents a modifier on the declaration of a program element such * as a class, method, or field. * * <p> Not all modifiers are applicable to all kinds of declarations. * When two or more modifiers appear in the source code of a declaration, * then it is customary, though not required, that they appear in the same * order as the constants listed in the detail section below. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this enum is {@link javax.lang.model.element.Modifier}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public enum Modifier { // See JLS2 sections 8.1.1, 8.3.1, 8.4.3, 8.8.3, and 9.1.1. // java.lang.reflect.Modifier includes INTERFACE, but that's a VMism. /** The modifier <tt>public</tt> */ PUBLIC, /** The modifier <tt>protected</tt> */ PROTECTED, /** The modifier <tt>private</tt> */ PRIVATE, /** The modifier <tt>abstract</tt> */ ABSTRACT, /** The modifier <tt>static</tt> */ STATIC, /** The modifier <tt>final</tt> */ FINAL, /** The modifier <tt>transient</tt> */ TRANSIENT, /** The modifier <tt>volatile</tt> */ VOLATILE, /** The modifier <tt>synchronized</tt> */ SYNCHRONIZED, /** The modifier <tt>native</tt> */ NATIVE, /** The modifier <tt>strictfp</tt> */ STRICTFP; private String lowercase = null; // modifier name in lowercase /** * Returns this modifier's name in lowercase. */ public String toString() { if (lowercase == null) { lowercase = name().toLowerCase(java.util.Locale.US); } return lowercase; } }
3,081
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationProcessorFactory.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; import java.util.Collection; import java.util.Set; import com.sun.mirror.declaration.AnnotationTypeDeclaration; /** * A factory for creating annotation processors. * Each factory is responsible for creating processors for one or more * annotation types. * The factory is said to <i>support</i> these types. * * <p> Each implementation of an <tt>AnnotationProcessorFactory</tt> * must provide a public no-argument constructor to be used by tools to * instantiate the factory. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.annotation.processing.Processor}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationProcessorFactory { /** * Returns the options recognized by this factory or by any of the * processors it may create. * Only {@linkplain AnnotationProcessorEnvironment#getOptions() * processor-specific} options are included, each of which begins * with <tt>"-A"</tt>. For example, if this factory recognizes * options such as <tt>-Adebug -Aloglevel=3</tt>, it will * return the strings <tt>"-Adebug"</tt> and <tt>"-Aloglevel"</tt>. * * <p> A tool might use this information to determine if any * options provided by a user are unrecognized by any processor, * in which case it may wish to report an error. * * @return the options recognized by this factory or by any of the * processors it may create, or an empty collection if none */ Collection<String> supportedOptions(); /** * Returns the names of the annotation types supported by this factory. * An element of the result may be the canonical (fully qualified) name * of a supported annotation type. Alternately it may be of the form * <tt>"<i>name</i>.*"</tt> * representing the set of all annotation types * with canonical names beginning with <tt>"<i>name</i>."</tt> * Finally, <tt>"*"</tt> by itself represents the set of all * annotation types. * * @return the names of the annotation types supported by this factory */ Collection<String> supportedAnnotationTypes(); /** * Returns an annotation processor for a set of annotation * types. The set will be empty if the factory supports * &quot;<tt>*</tt>&quot; and the specified type declarations have * no annotations. Note that the set of annotation types may be * empty for other reasons, such as giving the factory an * opportunity to register a listener. An * <tt>AnnotationProcessorFactory</tt> must gracefully handle an * empty set of annotations; an appropriate response to an empty * set will often be returning {@link AnnotationProcessors#NO_OP}. * * @param atds type declarations of the annotation types to be processed * @param env environment to use during processing * @return an annotation processor for the given annotation types, * or <tt>null</tt> if the types are not supported or the * processor cannot be created */ AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env); }
4,655
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
package-info.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/package-info.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ /** * Classes used to communicate information between {@linkplain * com.sun.mirror.apt.AnnotationProcessor annotation processors} and * an annotation processing tool. * * <p>The {@code apt} tool and its associated API have been superseded * by the standardized annotation processing API. The replacement for * the functionality in this package is {@link * javax.annotation.processing}. * * @since 1.5 */ package com.sun.mirror.apt;
1,652
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RoundCompleteListener.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; /** * Listener for the completion of a round of annotation processing. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. This interface has no * direct analog in the standardized API because the different round * model renders it unnecessary. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface RoundCompleteListener extends AnnotationProcessorListener { /** * Invoked after all processors for a round have run to completion. * * @param event An event for round completion */ void roundComplete(RoundCompleteEvent event); }
1,943
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Filer.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/Filer.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; import java.io.*; /** * This interface supports the creation of new files by an * annotation processor. * Files created in this way will be known to the annotation processing * tool implementing this interface, better enabling the tool to manage them. * Four kinds of files are distinguished: * source files, class files, other text files, and other binary files. * The latter two are collectively referred to as <i>auxiliary</i> files. * * <p> There are two distinguished locations (subtrees within the * file system) where newly created files are placed: * one for new source files, and one for new class files. * (These might be specified on a tool's command line, for example, * using flags such as <tt>-s</tt> and <tt>-d</tt>.) * Auxiliary files may be created in either location. * * <p> During each run of an annotation processing tool, a file * with a given pathname may be created only once. If that file already * exists before the first attempt to create it, the old contents will * be deleted. Any subsequent attempt to create the same file during * a run will fail. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.annotation.processing.Filer}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface Filer { /** * Creates a new source file and returns a writer for it. * The file's name and path (relative to the root of all newly created * source files) is based on the type to be declared in that file. * If more than one type is being declared, the name of the principal * top-level type (the public one, for example) should be used. * * <p> The {@linkplain java.nio.charset.Charset charset} used to * encode the file is determined by the implementation. * An annotation processing tool may have an <tt>-encoding</tt> * flag or the like for specifying this. It will typically use * the platform's default encoding if none is specified. * * @param name canonical (fully qualified) name of the principal type * being declared in this file * @return a writer for the new file * @throws IOException if the file cannot be created */ PrintWriter createSourceFile(String name) throws IOException; /** * Creates a new class file, and returns a stream for writing to it. * The file's name and path (relative to the root of all newly created * class files) is based on the name of the type being written. * * @param name canonical (fully qualified) name of the type being written * @return a stream for writing to the new file * @throws IOException if the file cannot be created */ OutputStream createClassFile(String name) throws IOException; /** * Creates a new text file, and returns a writer for it. * The file is located along with either the * newly created source or newly created binary files. It may be * named relative to some package (as are source and binary files), * and from there by an arbitrary pathname. In a loose sense, the * pathname of the new file will be the concatenation of * <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>. * * <p> A {@linkplain java.nio.charset.Charset charset} for * encoding the file may be provided. If none is given, the * charset used to encode source files * (see {@link #createSourceFile(String)}) will be used. * * @param loc location of the new file * @param pkg package relative to which the file should be named, * or the empty string if none * @param relPath final pathname components of the file * @param charsetName the name of the charset to use, or null if none * is being explicitly specified * @return a writer for the new file * @throws IOException if the file cannot be created */ PrintWriter createTextFile(Location loc, String pkg, File relPath, String charsetName) throws IOException; /** * Creates a new binary file, and returns a stream for writing to it. * The file is located along with either the * newly created source or newly created binary files. It may be * named relative to some package (as are source and binary files), * and from there by an arbitrary pathname. In a loose sense, the * pathname of the new file will be the concatenation of * <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>. * * @param loc location of the new file * @param pkg package relative to which the file should be named, * or the empty string if none * @param relPath final pathname components of the file * @return a stream for writing to the new file * @throws IOException if the file cannot be created */ OutputStream createBinaryFile(Location loc, String pkg, File relPath) throws IOException; /** * Locations (subtrees within the file system) where new files are created. * * @deprecated All components of this API have been superseded by * the standardized annotation processing API. The replacement * for the functionality of this enum is {@link * javax.tools.StandardLocation}. */ @Deprecated enum Location { /** The location of new source files. */ SOURCE_TREE, /** The location of new class files. */ CLASS_TREE } }
7,016
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationProcessorListener.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; /** * Superinterface for all annotation processor event listeners. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. This interface has no * direct analog in the standardized API because the different round * model renders it unnecessary. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationProcessorListener extends java.util.EventListener {}
1,745
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
Messager.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/Messager.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; import com.sun.mirror.util.SourcePosition; /** * A <tt>Messager</tt> provides the way for * an annotation processor to report error messages, warnings, and * other notices. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.annotation.processing.Messager}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface Messager { /** * Prints an error message. * Equivalent to <tt>printError(null, msg)</tt>. * @param msg the message, or an empty string if none */ void printError(String msg); /** * Prints an error message. * @param pos the position where the error occured, or null if it is * unknown or not applicable * @param msg the message, or an empty string if none */ void printError(SourcePosition pos, String msg); /** * Prints a warning message. * Equivalent to <tt>printWarning(null, msg)</tt>. * @param msg the message, or an empty string if none */ void printWarning(String msg); /** * Prints a warning message. * @param pos the position where the warning occured, or null if it is * unknown or not applicable * @param msg the message, or an empty string if none */ void printWarning(SourcePosition pos, String msg); /** * Prints a notice. * Equivalent to <tt>printNotice(null, msg)</tt>. * @param msg the message, or an empty string if none */ void printNotice(String msg); /** * Prints a notice. * @param pos the position where the noticed occured, or null if it is * unknown or not applicable * @param msg the message, or an empty string if none */ void printNotice(SourcePosition pos, String msg); }
3,227
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationProcessors.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; import com.sun.mirror.apt.*; import java.util.*; /** * Utilities to create specialized annotation processors. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. There is no direct analog * of the functionality of this class in the standardized API. * * @since 1.5 * @author Joseph D. Darcy * @author Scott Seligman */ @Deprecated @SuppressWarnings("deprecation") public class AnnotationProcessors { static class NoOpAP implements AnnotationProcessor { NoOpAP() {} public void process(){} } /** * Combines multiple annotation processors into a simple composite * processor. * The composite processor functions by invoking each of its component * processors in sequence. */ static class CompositeAnnotationProcessor implements AnnotationProcessor { private List<AnnotationProcessor> aps = new LinkedList<AnnotationProcessor>(); /** * Constructs a new composite annotation processor. * @param aps the component annotation processors */ public CompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) { this.aps.addAll(aps); } /** * Constructs a new composite annotation processor. * @param aps the component annotation processors */ public CompositeAnnotationProcessor(AnnotationProcessor... aps) { for(AnnotationProcessor ap: aps) this.aps.add(ap); } /** * Invokes the <tt>process</tt> method of each component processor, * in the order in which the processors were passed to the constructor. */ public void process() { for(AnnotationProcessor ap: aps) ap.process(); } } /** * An annotation processor that does nothing and has no state. * May be used multiple times. * * @since 1.5 */ public final static AnnotationProcessor NO_OP = new NoOpAP(); /** * Constructs a new composite annotation processor. A composite * annotation processor combines multiple annotation processors * into one and functions by invoking each of its component * processors' process methods in sequence. * * @param aps The processors to create a composite of * @since 1.5 */ public static AnnotationProcessor getCompositeAnnotationProcessor(AnnotationProcessor... aps) { return new CompositeAnnotationProcessor(aps); } /** * Constructs a new composite annotation processor. A composite * annotation processor combines multiple annotation processors * into one and functions by invoking each of its component * processors' process methods in the sequence the processors are * returned by the collection's iterator. * * @param aps A collection of processors to create a composite of * @since 1.5 */ public static AnnotationProcessor getCompositeAnnotationProcessor(Collection<AnnotationProcessor> aps) { return new CompositeAnnotationProcessor(aps); } }
4,420
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RoundCompleteEvent.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; /** * Event for the completion of a round of annotation processing. * * <p>While this class extends the serializable <tt>EventObject</tt>, it * cannot meaningfully be serialized because all of the annotation * processing tool's internal state would potentially be needed. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. This class has no direct * analog in the standardized API because the different round model * renders it unnecessary. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public abstract class RoundCompleteEvent extends java.util.EventObject { private RoundState rs; /** * The current <tt>AnnotationProcessorEnvironment</tt> is regarded * as the source of events. * * @param source The source of events * @param rs The state of the round */ protected RoundCompleteEvent(AnnotationProcessorEnvironment source, RoundState rs) { super(source); this.rs = rs; } /** * Return round state. */ public RoundState getRoundState() { return rs; } /** * Return source. */ public AnnotationProcessorEnvironment getSource() { return (AnnotationProcessorEnvironment)super.getSource(); } }
2,634
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
RoundState.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/RoundState.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; /** * Represents the status of a completed round of annotation processing. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.annotation.processing.RoundEnvironment}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface RoundState { /** * Returns <tt>true</tt> if this was the last round of annotation * processing; returns <tt>false</tt> if there will be a subsequent round. */ boolean finalRound(); /** * Returns <tt>true</tt> if an error was raised in this round of processing; * returns <tt>false</tt> otherwise. */ boolean errorRaised(); /** * Returns <tt>true</tt> if new source files were created in this round of * processing; returns <tt>false</tt> otherwise. */ boolean sourceFilesCreated(); /** * Returns <tt>true</tt> if new class files were created in this round of * processing; returns <tt>false</tt> otherwise. */ boolean classFilesCreated(); }
2,421
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationProcessorEnvironment.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; import java.util.Collection; import java.util.Map; import com.sun.mirror.declaration.*; import com.sun.mirror.util.*; /** * The environment encapsulating the state needed by an annotation processor. * An annotation processing tool makes this environment available * to all annotation processors. * * <p> When an annotation processing tool is invoked, it is given a * set of type declarations on which to operate. These * are refered to as the <i>specified</i> types. * The type declarations said to be <i>included</i> in this invocation * consist of the specified types and any types nested within them. * * <p> {@link DeclarationFilter} * provides a simple way to select just the items of interest * when a method returns a collection of declarations. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.annotation.processing.ProcessingEnvironment}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationProcessorEnvironment { /** * Returns the options passed to the annotation processing tool. * Options are returned in the form of a map from option name * (such as <tt>"-encoding"</tt>) to option value. * For an option with no value (such as <tt>"-help"</tt>), the * corresponding value in the map is <tt>null</tt>. * * <p> Options beginning with <tt>"-A"</tt> are <i>processor-specific.</i> * Such options are unrecognized by the tool, but intended to be used by * some annotation processor. * * @return the options passed to the tool */ Map<String,String> getOptions(); /** * Returns the messager used to report errors, warnings, and other * notices. * * @return the messager */ Messager getMessager(); /** * Returns the filer used to create new source, class, or auxiliary * files. * * @return the filer */ Filer getFiler(); /** * Returns the declarations of the types specified when the * annotation processing tool was invoked. * * @return the types specified when the tool was invoked, or an * empty collection if there were none */ Collection<TypeDeclaration> getSpecifiedTypeDeclarations(); /** * Returns the declaration of a package given its fully qualified name. * * @param name fully qualified package name, or "" for the unnamed package * @return the declaration of the named package, or null if it cannot * be found */ PackageDeclaration getPackage(String name); /** * Returns the declaration of a type given its fully qualified name. * * @param name fully qualified type name * @return the declaration of the named type, or null if it cannot be * found */ TypeDeclaration getTypeDeclaration(String name); /** * A convenience method that returns the declarations of the types * {@linkplain AnnotationProcessorEnvironment <i>included</i>} * in this invocation of the annotation processing tool. * * @return the declarations of the types included in this invocation * of the tool, or an empty collection if there are none */ Collection<TypeDeclaration> getTypeDeclarations(); /** * Returns the declarations annotated with the given annotation type. * Only declarations of the types * {@linkplain AnnotationProcessorEnvironment <i>included</i>} * in this invocation of the annotation processing tool, or * declarations of members, parameters, or type parameters * declared within those, are returned. * * @param a annotation type being requested * @return the declarations annotated with the given annotation type, * or an empty collection if there are none */ Collection<Declaration> getDeclarationsAnnotatedWith( AnnotationTypeDeclaration a); /** * Returns an implementation of some utility methods for * operating on declarations. * * @return declaration utilities */ Declarations getDeclarationUtils(); /** * Returns an implementation of some utility methods for * operating on types. * * @return type utilities */ Types getTypeUtils(); /** * Add a listener. If the listener is currently registered to listen, * adding it again will have no effect. * * @param listener The listener to add. * @throws NullPointerException if the listener is null */ void addListener(AnnotationProcessorListener listener); /** * Remove a listener. If the listener is not currently listening, * the method call does nothing. * * @param listener The listener to remove. * @throws NullPointerException if the listener is null */ void removeListener(AnnotationProcessorListener listener); }
6,340
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationProcessor.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.apt; import java.io.IOException; import java.util.Collection; /** * An annotation processor, used to examine and process the * annotations of program elements. An annotation processor may, * for example, create new source files and XML documents to be used * in conjunction with the original code. * * <p> An annotation processor is constructed by a * {@linkplain AnnotationProcessorFactory factory}, which provides it with an * {@linkplain AnnotationProcessorEnvironment environment} that * encapsulates the state it needs. * Messages regarding warnings and errors encountered during processing * should be directed to the environment's {@link Messager}, * and new files may be created using the environment's {@link Filer}. * * <p> Each annotation processor is created to process annotations * of a particular annotation type or set of annotation types. * It may use its environment to find the program elements with * annotations of those types. It may freely examine any other program * elements in the course of its processing. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.annotation.processing.Processor}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationProcessor { /** * Process all program elements supported by this annotation processor. */ void process(); }
2,790
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeVariable.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/TypeVariable.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import com.sun.mirror.declaration.*; /** * Represents a type variable. * A type variable is declared by a * {@linkplain TypeParameterDeclaration type parameter} of a * type, method, or constructor. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.type.TypeVariable}. * * @author Joe Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface TypeVariable extends ReferenceType { /** * Returns the type parameter that declared this type variable. * * @return the type parameter that declared this type variable */ TypeParameterDeclaration getDeclaration(); }
2,044
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
package-info.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/package-info.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ /** * Interfaces used to model types. A type is represented by the * appropriate subinterface of {@link com.sun.mirror.type.TypeMirror}. * * <p>The {@code apt} tool and its associated API have been * superseded by the standardized annotation processing API. The * replacement for the functionality in this package is {@link * javax.lang.model.type}. * * @since 1.5 */ package com.sun.mirror.type;
1,617
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
DeclaredType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/DeclaredType.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import java.util.Collection; import com.sun.mirror.declaration.TypeDeclaration; /** * Represents a declared type, either a class type or an interface type. * This includes parameterized types such as {@code java.util.Set<String>} * as well as raw types. * * <p> While a <tt>TypeDeclaration</tt> represents the <i>declaration</i> * of a class or interface, a <tt>DeclaredType</tt> represents a class * or interface <i>type</i>, the latter being a use of the former. * See {@link TypeDeclaration} for more on this distinction. * * <p> A <tt>DeclaredType</tt> may represent a type * for which details (declaration, supertypes, <i>etc.</i>) are unknown. * This may be the result of a processing error, such as a missing class file, * and is indicated by {@link #getDeclaration()} returning <tt>null</tt>. * Other method invocations on such an unknown type will not, in general, * return meaningful results. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.type.DeclaredType}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface DeclaredType extends ReferenceType { /** * Returns the declaration of this type. * * <p> Returns null if this type's declaration is unknown. This may * be the result of a processing error, such as a missing class file. * * @return the declaration of this type, or null if unknown */ TypeDeclaration getDeclaration(); /** * Returns the type that contains this type as a member. * Returns <tt>null</tt> if this is a top-level type. * * <p> For example, the containing type of {@code O.I<S>} * is the type {@code O}, and the containing type of * {@code O<T>.I<S>} is the type {@code O<T>}. * * @return the type that contains this type, * or <tt>null</tt> if this is a top-level type */ DeclaredType getContainingType(); /** * Returns (in order) the actual type arguments of this type. * For a generic type nested within another generic type * (such as {@code Outer<String>.Inner<Number>}), only the type * arguments of the innermost type are included. * * @return the actual type arguments of this type, or an empty collection * if there are none */ Collection<TypeMirror> getActualTypeArguments(); /** * Returns the interface types that are direct supertypes of this type. * These are the interface types implemented or extended * by this type's declaration, with any type arguments * substituted in. * * <p> For example, the interface type extended by * {@code java.util.Set<String>} is {@code java.util.Collection<String>}. * * @return the interface types that are direct supertypes of this type, * or an empty collection if there are none */ Collection<InterfaceType> getSuperinterfaces(); }
4,344
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
TypeMirror.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/TypeMirror.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import com.sun.mirror.declaration.Declaration; import com.sun.mirror.util.Types; import com.sun.mirror.util.TypeVisitor; /** * Represents a type in the Java programming language. * Types include primitive types, class and interface types, array * types, and type variables. Wildcard type arguments, and the * pseudo-type representing the type of <tt>void</tt>, are represented * by type mirrors as well. * * <p> Types may be compared using the utility methods in * {@link Types}. * There is no guarantee that any particular type will * always be represented by the same object. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.type.TypeMirror}. * * @author Joseph D. Darcy * @author Scott Seligman * * @see Declaration * @see Types * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface TypeMirror { /** * Returns a string representation of this type. * Any names embedded in the expression are qualified. * * @return a string representation of this type */ String toString(); /** * Tests whether two types represent the same type. * * @param obj the object to be compared with this type * @return <tt>true</tt> if the specified object represents the same * type as this. */ boolean equals(Object obj); /** * Applies a visitor to this type. * * @param v the visitor operating on this type */ void accept(TypeVisitor v); }
2,873
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MirroredTypesException.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/MirroredTypesException.java
/* * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import java.lang.annotation.Annotation; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import com.sun.mirror.declaration.Declaration; /** * Thrown when an application attempts to access a sequence of {@link Class} * objects each corresponding to a {@link TypeMirror}. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this exception is {@link * javax.lang.model.type.MirroredTypesException}. * * @see MirroredTypeException * @see Declaration#getAnnotation(Class) */ @Deprecated @SuppressWarnings("deprecation") public class MirroredTypesException extends RuntimeException { private static final long serialVersionUID = 1; private transient Collection<TypeMirror> types; // cannot be serialized private Collection<String> names; // types' qualified "names" /** * Constructs a new MirroredTypesException for the specified types. * * @param types an ordered collection of the types being accessed */ public MirroredTypesException(Collection<TypeMirror> types) { super("Attempt to access Class objects for TypeMirrors " + types); this.types = types; names = new ArrayList<String>(); for (TypeMirror t : types) { names.add(t.toString()); } } /** * Returns the type mirrors corresponding to the types being accessed. * The type mirrors may be unavailable if this exception has been * serialized and then read back in. * * @return the type mirrors in order, or <tt>null</tt> if unavailable */ public Collection<TypeMirror> getTypeMirrors() { return (types != null) ? Collections.unmodifiableCollection(types) : null; } /** * Returns the fully qualified names of the types being accessed. * More precisely, returns the canonical names of each class, * interface, array, or primitive, and <tt>"void"</tt> for * the pseudo-type representing the type of <tt>void</tt>. * * @return the fully qualified names, in order, of the types being * accessed */ public Collection<String> getQualifiedNames() { return Collections.unmodifiableCollection(names); } }
3,615
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
VoidType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/VoidType.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import com.sun.mirror.declaration.MethodDeclaration; /** * A pseudo-type representing the type of <tt>void</tt>. * * @author Joseph D. Darcy * @author Scott Seligman * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.type.NoType}. * * @see MethodDeclaration#getReturnType() * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface VoidType extends TypeMirror { }
1,800
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
WildcardType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/WildcardType.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import java.util.Collection; /** * Represents a wildcard type argument. * Examples include: <pre><tt> * ? * ? extends Number * ? super T * </tt></pre> * * <p> A wildcard may have its upper bound explicitly set by an * <tt>extends</tt> clause, its lower bound explicitly set by a * <tt>super</tt> clause, or neither (but not both). * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.type.WildcardType}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface WildcardType extends TypeMirror { /** * Returns the upper bounds of this wildcard. * If no upper bound is explicitly declared, then * an empty collection is returned. * * @return the upper bounds of this wildcard */ Collection<ReferenceType> getUpperBounds(); /** * Returns the lower bounds of this wildcard. * If no lower bound is explicitly declared, then * an empty collection is returned. * * @return the lower bounds of this wildcard */ Collection<ReferenceType> getLowerBounds(); }
2,519
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ClassType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/ClassType.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import com.sun.mirror.declaration.*; /** * Represents a class type. * Interface types are represented separately by {@link InterfaceType}. * Note that an {@linkplain EnumType enum} is a kind of class. * * <p> While a {@link ClassDeclaration} represents the <i>declaration</i> * of a class, a <tt>ClassType</tt> represents a class <i>type</i>. * See {@link TypeDeclaration} for more on this distinction. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.type.DeclaredType}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface ClassType extends DeclaredType { /** * {@inheritDoc} */ ClassDeclaration getDeclaration(); /** * Returns the class type that is a direct supertype of this one. * This is the superclass of this type's declaring class, with any * type arguments substituted in. * The only class with no superclass is <tt>java.lang.Object</tt>, * for which this method returns <tt>null</tt>. * * <p> For example, the class type extended by * {@code java.util.TreeSet<String>} is * {@code java.util.AbstractSet<String>}. * * @return the class type that is a direct supertype of this one, * or <tt>null</tt> if there is none */ ClassType getSuperclass(); }
2,753
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
MirroredTypeException.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/MirroredTypeException.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import java.lang.annotation.Annotation; import com.sun.mirror.declaration.Declaration; /** * Thrown when an application attempts to access the {@link Class} object * corresponding to a {@link TypeMirror}. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this exception is {@link * javax.lang.model.type.MirroredTypeException}. * * @see MirroredTypesException * @see Declaration#getAnnotation(Class) */ @Deprecated @SuppressWarnings("deprecation") public class MirroredTypeException extends RuntimeException { private static final long serialVersionUID = 1; private transient TypeMirror type; // cannot be serialized private String name; // type's qualified "name" /** * Constructs a new MirroredTypeException for the specified type. * * @param type the type being accessed */ public MirroredTypeException(TypeMirror type) { super("Attempt to access Class object for TypeMirror " + type); this.type = type; name = type.toString(); } /** * Returns the type mirror corresponding to the type being accessed. * The type mirror may be unavailable if this exception has been * serialized and then read back in. * * @return the type mirror, or <tt>null</tt> if unavailable */ public TypeMirror getTypeMirror() { return type; } /** * Returns the fully qualified name of the type being accessed. * More precisely, returns the canonical name of a class, * interface, array, or primitive, and returns <tt>"void"</tt> for * the pseudo-type representing the type of <tt>void</tt>. * * @return the fully qualified name of the type being accessed */ public String getQualifiedName() { return name; } }
3,158
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
EnumType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/EnumType.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import com.sun.mirror.declaration.EnumDeclaration; /** * Represents an enum type. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.type.DeclaredType}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface EnumType extends ClassType { /** * {@inheritDoc} */ EnumDeclaration getDeclaration(); }
1,805
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
PrimitiveType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/PrimitiveType.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; /** * Represents a primitive type. These include * <tt>boolean</tt>, <tt>byte</tt>, <tt>short</tt>, <tt>int</tt>, * <tt>long</tt>, <tt>char</tt>, <tt>float</tt>, and <tt>double</tt>. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.type.PrimitiveType}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface PrimitiveType extends TypeMirror { /** * Returns the kind of primitive type that this object represents. * * @return the kind of primitive type that this object represents */ Kind getKind(); /** * An enumeration of the different kinds of primitive types. * * @deprecated All components of this API have been superseded by * the standardized annotation processing API. The replacement * for the functionality of this enum is {@link * javax.lang.model.type.TypeKind}. */ @Deprecated enum Kind { /** The primitive type <tt>boolean</tt> */ BOOLEAN, /** The primitive type <tt>byte</tt> */ BYTE, /** The primitive type <tt>short</tt> */ SHORT, /** The primitive type <tt>int</tt> */ INT, /** The primitive type <tt>long</tt> */ LONG, /** The primitive type <tt>char</tt> */ CHAR, /** The primitive type <tt>float</tt> */ FLOAT, /** The primitive type <tt>double</tt> */ DOUBLE } }
2,869
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
AnnotationType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/AnnotationType.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; import com.sun.mirror.declaration.AnnotationTypeDeclaration; /** * Represents an annotation type. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is included in {@link * javax.lang.model.type.DeclaredType}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface AnnotationType extends InterfaceType { /** * {@inheritDoc} */ AnnotationTypeDeclaration getDeclaration(); }
1,841
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z
ReferenceType.java
/FileExtraction/Java_unseen/openjdk-mirror_jdk7u-langtools/src/share/classes/com/sun/mirror/type/ReferenceType.java
/* * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * 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. */ package com.sun.mirror.type; /** * Represents a reference type. * These include class and interface types, array types, and type variables. * * @deprecated All components of this API have been superseded by the * standardized annotation processing API. The replacement for the * functionality of this interface is {@link * javax.lang.model.type.ReferenceType}. * * @author Joseph D. Darcy * @author Scott Seligman * @since 1.5 */ @Deprecated @SuppressWarnings("deprecation") public interface ReferenceType extends TypeMirror { }
1,752
Java
.java
openjdk-mirror/jdk7u-langtools
9
3
0
2012-05-07T19:45:34Z
2012-05-08T17:47:06Z