< prev index next >

src/jdk.jdeps/share/classes/com/sun/tools/javap/AttributeWriter.java

Print this page

        

*** 23,32 **** --- 23,34 ---- * questions. */ package com.sun.tools.javap; + import java.util.Collection; + 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;
*** 38,47 **** --- 40,51 ---- import com.sun.tools.classfile.ConstantPool.CONSTANT_Class_info; 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.Descriptor; + import com.sun.tools.classfile.Descriptor.InvalidDescriptor; 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.InnerClasses_attribute.Info; import com.sun.tools.classfile.LineNumberTable_attribute;
*** 54,83 **** --- 58,95 ---- import com.sun.tools.classfile.ModulePackages_attribute; import com.sun.tools.classfile.ModuleResolution_attribute; import com.sun.tools.classfile.ModuleTarget_attribute; import com.sun.tools.classfile.NestHost_attribute; import com.sun.tools.classfile.NestMembers_attribute; + import com.sun.tools.classfile.Record_attribute; import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute; import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute; import com.sun.tools.classfile.RuntimeParameterAnnotations_attribute; import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute; import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute; import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute; + import com.sun.tools.classfile.PermittedSubtypes_attribute; + import com.sun.tools.classfile.Signature; 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 com.sun.tools.classfile.Type; import static com.sun.tools.classfile.AccessFlags.*; import com.sun.tools.javac.util.Assert; import com.sun.tools.javac.util.StringUtils; + import java.util.stream.Collectors; + import java.util.stream.IntStream; + import java.util.stream.Stream; + /* * 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.
*** 712,721 **** --- 724,772 ---- } return null; } @Override + public Void visitRecord(Record_attribute attr, Void p) { + println("Record:"); + indent(+1); + for (int i = 0; i < attr.num_params; i++) { + println("#" + attr.accessors[i]); + } + indent(-1); + return null; + } + + void writeList(String prefix, Collection<?> items, String suffix) { + print(prefix); + String sep = ""; + for (Object item: items) { + print(sep); + print(item); + sep = ", "; + } + print(suffix); + } + + String getJavaFieldType(Descriptor d) { + try { + return getJavaName(d.getFieldType(constant_pool)); + } catch (ConstantPoolException e) { + return report(e); + } catch (InvalidDescriptor e) { + return report(e); + } + } + + void writeModifiers(Collection<String> items) { + for (Object item: items) { + print(item); + print(" "); + } + } + + @Override public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) { println("RuntimeVisibleAnnotations:"); indent(+1); for (int i = 0; i < attr.annotations.length; i++) { print(i + ": ");
*** 792,801 **** --- 843,868 ---- visitParameterAnnotations("RuntimeInvisibleParameterAnnotations:", (RuntimeParameterAnnotations_attribute) attr); return null; } @Override + public Void visitPermittedSubtypes(PermittedSubtypes_attribute attr, Void ignore) { + println("PermittedSubtypes:"); + indent(+1); + try { + CONSTANT_Class_info[] subtypes = attr.getSubtypes(constant_pool); + for (int i = 0; i < subtypes.length; i++) { + println(constantWriter.stringValue(subtypes[i])); + } + indent(-1); + } catch (ConstantPoolException ex) { + throw new AssertionError(ex); + } + return null; + } + + @Override public Void visitSignature(Signature_attribute attr, Void ignore) { print("Signature: #" + attr.signature_index); tab(); println("// " + getSignature(attr)); return null;
< prev index next >