langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java
author jjg
Fri, 19 Jun 2009 11:40:47 -0700
changeset 3141 79c119fae7fb
parent 735 372aa565a221
child 3149 0cd06d598d6f
permissions -rw-r--r--
6852856: javap changes to facilitate subclassing javap for variants Reviewed-by: mcimadamore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     1
/*
735
372aa565a221 6719955: Update copyright year
xdono
parents: 733
diff changeset
     2
 * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     4
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    10
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    15
 * accompanied this code).
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    16
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    20
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    23
 * have any questions.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    24
 */
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    25
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    26
package com.sun.tools.javap;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    27
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    28
import java.util.Formatter;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    29
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    30
import com.sun.tools.classfile.AccessFlags;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    31
import com.sun.tools.classfile.AnnotationDefault_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    32
import com.sun.tools.classfile.Attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    33
import com.sun.tools.classfile.Attributes;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    34
import com.sun.tools.classfile.CharacterRangeTable_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    35
import com.sun.tools.classfile.Code_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    36
import com.sun.tools.classfile.CompilationID_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    37
import com.sun.tools.classfile.ConstantPool;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    38
import com.sun.tools.classfile.ConstantPoolException;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    39
import com.sun.tools.classfile.ConstantValue_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    40
import com.sun.tools.classfile.DefaultAttribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    41
import com.sun.tools.classfile.Deprecated_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    42
import com.sun.tools.classfile.EnclosingMethod_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    43
import com.sun.tools.classfile.Exceptions_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    44
import com.sun.tools.classfile.Field;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    45
import com.sun.tools.classfile.InnerClasses_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    46
import com.sun.tools.classfile.LineNumberTable_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    47
import com.sun.tools.classfile.LocalVariableTable_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    48
import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    49
import com.sun.tools.classfile.ModuleExportTable_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    50
import com.sun.tools.classfile.ModuleMemberTable_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    51
import com.sun.tools.classfile.Module_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    52
import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    53
import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    54
import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    55
import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    56
import com.sun.tools.classfile.Signature_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    57
import com.sun.tools.classfile.SourceDebugExtension_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    58
import com.sun.tools.classfile.SourceFile_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    59
import com.sun.tools.classfile.SourceID_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    60
import com.sun.tools.classfile.StackMapTable_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    61
import com.sun.tools.classfile.StackMap_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    62
import com.sun.tools.classfile.Synthetic_attribute;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    63
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    64
import static com.sun.tools.classfile.AccessFlags.*;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    65
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    66
/*
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    67
 *  A writer for writing Attributes as text.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    68
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    69
 *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    70
 *  you write code that depends on this, you do so at your own risk.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    71
 *  This code and its internal interfaces are subject to change or
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    72
 *  deletion without notice.</b>
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    73
 */
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    74
public class AttributeWriter extends BasicWriter
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    75
        implements Attribute.Visitor<Void,Void>
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    76
{
3141
79c119fae7fb 6852856: javap changes to facilitate subclassing javap for variants
jjg
parents: 735
diff changeset
    77
    public static AttributeWriter instance(Context context) {
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    78
        AttributeWriter instance = context.get(AttributeWriter.class);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    79
        if (instance == null)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    80
            instance = new AttributeWriter(context);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    81
        return instance;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    82
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    83
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    84
    protected AttributeWriter(Context context) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    85
        super(context);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    86
        context.put(AttributeWriter.class, this);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    87
        annotationWriter = AnnotationWriter.instance(context);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    88
        codeWriter = CodeWriter.instance(context);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    89
        constantWriter = ConstantWriter.instance(context);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    90
        options = Options.instance(context);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    91
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    92
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    93
    public void write(Object owner, Attribute attr, ConstantPool constant_pool) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    94
        if (attr != null) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    95
            // null checks
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    96
            owner.getClass();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    97
            constant_pool.getClass();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    98
            this.constant_pool = constant_pool;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    99
            this.owner = owner;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   100
            attr.accept(this, null);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   101
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   102
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   103
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   104
    public void write(Object owner, Attributes attrs, ConstantPool constant_pool) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   105
        if (attrs != null) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   106
            // null checks
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   107
            owner.getClass();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   108
            constant_pool.getClass();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   109
            this.constant_pool = constant_pool;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   110
            this.owner = owner;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   111
            for (Attribute attr: attrs)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   112
                attr.accept(this, null);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   113
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   114
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   115
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   116
    public Void visitDefault(DefaultAttribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   117
        byte[] data = attr.info;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   118
        int i = 0;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   119
        int j = 0;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   120
        print("  ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   121
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   122
            print(attr.getName(constant_pool));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   123
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   124
            report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   125
            print("attribute name = #" + attr.attribute_name_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   126
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   127
        print(": ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   128
        println("length = 0x" + toHex(attr.info.length));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   129
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   130
        print("   ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   131
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   132
        while (i < data.length) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   133
            print(toHex(data[i], 2));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   134
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   135
            j++;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   136
            if (j == 16) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   137
                println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   138
                print("   ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   139
                j = 0;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   140
            } else {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   141
                print(" ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   142
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   143
            i++;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   144
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   145
        println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   146
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   147
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   148
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   149
    public Void visitAnnotationDefault(AnnotationDefault_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   150
        println("  AnnotationDefault: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   151
        print("    default_value: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   152
        annotationWriter.write(attr.default_value);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   153
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   154
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   155
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   156
    public Void visitCharacterRangeTable(CharacterRangeTable_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   157
        print("  CharacterRangeTable: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   158
        for (int i = 0; i < attr.character_range_table.length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   159
            CharacterRangeTable_attribute.Entry e = attr.character_range_table[i];
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   160
            print("    " + e.start_pc + ", " +
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   161
                    e.end_pc + ", " +
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   162
                    Integer.toHexString(e.character_range_start) + ", " +
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   163
                    Integer.toHexString(e.character_range_end) + ", " +
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   164
                    Integer.toHexString(e.flags) +
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   165
                    "\t// ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   166
            print(e.start_pc + ", " +
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   167
                    e.end_pc + ", " +
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   168
                    (e.character_range_start >> 10) + ":" + (e.character_range_start & 0x3ff) + ", " +
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   169
                    (e.character_range_end >> 10) + ":" + (e.character_range_end & 0x3ff));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   170
            if ((e.flags & CharacterRangeTable_attribute.CRT_STATEMENT) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   171
                print(", statement");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   172
            if ((e.flags & CharacterRangeTable_attribute.CRT_BLOCK) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   173
                print(", block");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   174
            if ((e.flags & CharacterRangeTable_attribute.CRT_ASSIGNMENT) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   175
                print(", assignment");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   176
            if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_CONTROLLER) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   177
                print(", flow-controller");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   178
            if ((e.flags & CharacterRangeTable_attribute.CRT_FLOW_TARGET) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   179
                print(", flow-target");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   180
            if ((e.flags & CharacterRangeTable_attribute.CRT_INVOKE) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   181
                print(", invoke");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   182
            if ((e.flags & CharacterRangeTable_attribute.CRT_CREATE) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   183
                print(", create");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   184
            if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_TRUE) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   185
                print(", branch-true");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   186
            if ((e.flags & CharacterRangeTable_attribute.CRT_BRANCH_FALSE) != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   187
                print(", branch-false");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   188
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   189
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   190
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   191
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   192
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   193
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   194
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   195
    public Void visitCode(Code_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   196
        codeWriter.write(attr, constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   197
        println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   198
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   199
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   200
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   201
    public Void visitCompilationID(CompilationID_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   202
        constantWriter.write(attr.compilationID_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   203
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   204
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   205
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   206
    public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   207
        if (options.compat) // BUG 6622216 javap names some attributes incorrectly
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   208
            print("  Constant value: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   209
        else
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   210
            print("  ConstantValue: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   211
        constantWriter.write(attr.constantvalue_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   212
        if (!options.compat) // BUG 6622232 javap gets whitespace confused
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   213
            println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   214
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   215
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   216
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   217
    public Void visitDeprecated(Deprecated_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   218
        if (!(options.compat && owner instanceof Field)) // BUG 6622232 javap gets whitespace confused
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   219
            print("  ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   220
        println("Deprecated: true");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   221
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   222
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   223
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   224
    public Void visitEnclosingMethod(EnclosingMethod_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   225
        print("  EnclosingMethod: #" + attr.class_index + ".#" + attr.method_index
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   226
                + "\t// " + getJavaClassName(attr));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   227
        if (attr.method_index != 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   228
            print("." + getMethodName(attr));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   229
        println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   230
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   231
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   232
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   233
    private String getJavaClassName(EnclosingMethod_attribute a) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   234
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   235
            return getJavaName(a.getClassName(constant_pool));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   236
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   237
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   238
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   239
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   240
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   241
    private String getMethodName(EnclosingMethod_attribute a) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   242
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   243
            return a.getMethodName(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   244
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   245
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   246
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   247
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   248
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   249
    public Void visitExceptions(Exceptions_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   250
        println("  Exceptions: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   251
        print("   throws ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   252
        for (int i = 0; i < attr.number_of_exceptions; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   253
            if (i > 0)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   254
                print(", ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   255
            print(getJavaException(attr, i));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   256
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   257
        if (!options.compat) // BUG 6622232 javap gets whitespace confused
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   258
            println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   259
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   260
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   261
733
b76c4357c649 6715767: javap on java.lang.ClassLoader crashes
jjg
parents: 727
diff changeset
   262
    private String getJavaException(Exceptions_attribute attr, int index) {
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   263
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   264
            return getJavaName(attr.getException(index, constant_pool));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   265
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   266
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   267
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   268
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   269
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   270
    public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   271
        boolean first = true;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   272
        if (options.compat) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   273
            writeInnerClassHeader();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   274
            first = false;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   275
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   276
        for (int i = 0 ; i < attr.classes.length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   277
            InnerClasses_attribute.Info info = attr.classes[i];
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   278
            //access
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   279
            AccessFlags access_flags = info.inner_class_access_flags;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   280
            if (options.compat) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   281
                // BUG 6622215: javap ignores certain relevant access flags
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   282
                access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   283
                // BUG 6622232: javap gets whitespace confused
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   284
                print("   ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   285
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   286
            if (options.checkAccess(access_flags)) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   287
                if (first) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   288
                    writeInnerClassHeader();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   289
                    first = false;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   290
                }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   291
                if (!options.compat) // BUG 6622232: javap gets whitespace confused
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   292
                    print("   ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   293
                for (String name: access_flags.getInnerClassModifiers())
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   294
                    print(name + " ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   295
                if (info.inner_name_index!=0) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   296
                    print("#" + info.inner_name_index + "= ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   297
                }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   298
                print("#" + info.inner_class_info_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   299
                if (info.outer_class_info_index != 0) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   300
                    print(" of #" + info.outer_class_info_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   301
                }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   302
                print("; //");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   303
                if (info.inner_name_index != 0) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   304
                    print(getInnerName(constant_pool, info) + "=");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   305
                }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   306
                constantWriter.write(info.inner_class_info_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   307
                if (info.outer_class_info_index != 0) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   308
                    print(" of ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   309
                    constantWriter.write(info.outer_class_info_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   310
                }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   311
                println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   312
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   313
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   314
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   315
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   316
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   317
    String getInnerName(ConstantPool constant_pool, InnerClasses_attribute.Info info) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   318
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   319
            return info.getInnerName(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   320
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   321
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   322
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   323
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   324
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   325
    private void writeInnerClassHeader() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   326
        print("  ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   327
        if (options.compat) // BUG 6622216: javap names some attributes incorrectly
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   328
            print("InnerClass");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   329
        else
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   330
            print("InnerClasses");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   331
        println(": ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   332
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   333
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   334
    public Void visitLineNumberTable(LineNumberTable_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   335
        println("  LineNumberTable: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   336
        for (LineNumberTable_attribute.Entry entry: attr.line_number_table) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   337
            println("   line " + entry.line_number + ": " + entry.start_pc);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   338
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   339
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   340
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   341
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   342
    public Void visitLocalVariableTable(LocalVariableTable_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   343
        println("  LocalVariableTable: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   344
        println("   Start  Length  Slot  Name   Signature");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   345
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   346
        for (LocalVariableTable_attribute.Entry entry : attr.local_variable_table) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   347
            Formatter formatter = new Formatter();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   348
            println(formatter.format("%8d %7d %5d %5s   %s",
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   349
                    entry.start_pc, entry.length, entry.index,
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   350
                    constantWriter.stringValue(entry.name_index),
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   351
                    constantWriter.stringValue(entry.descriptor_index)));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   352
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   353
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   354
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   355
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   356
    public Void visitLocalVariableTypeTable(LocalVariableTypeTable_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   357
        println("  LocalVariableTypeTable: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   358
        println("   Start  Length  Slot  Name   Signature");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   359
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   360
        for (LocalVariableTypeTable_attribute.Entry entry : attr.local_variable_table) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   361
            Formatter formatter = new Formatter();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   362
            println(formatter.format("%8d %7d %5d %5s   %s",
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   363
                    entry.start_pc, entry.length, entry.index,
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   364
                    constantWriter.stringValue(entry.name_index),
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   365
                    constantWriter.stringValue(entry.signature_index)));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   366
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   367
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   368
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   369
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   370
    public Void visitModule(Module_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   371
        println("  Module: #" + attr.module_name + "\t// " + getModuleName(attr));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   372
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   373
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   374
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   375
    String getModuleName(Module_attribute attr) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   376
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   377
            return attr.getModuleName(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   378
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   379
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   380
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   381
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   382
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   383
    public Void visitModuleExportTable(ModuleExportTable_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   384
        println("  ModuleExportTable:");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   385
        println("    Types: (" + attr.export_type_table.length + ")");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   386
        for (int i = 0; i < attr.export_type_table.length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   387
            println("      #" + attr.export_type_table[i] + "\t// " + getExportTypeName(attr, i));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   388
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   389
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   390
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   391
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   392
    String getExportTypeName(ModuleExportTable_attribute attr, int index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   393
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   394
            return attr.getExportTypeName(index, constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   395
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   396
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   397
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   398
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   399
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   400
    public Void visitModuleMemberTable(ModuleMemberTable_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   401
        println("  ModuleMemberTable:");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   402
        println("    Packages: (" + attr.package_member_table.length + ")");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   403
        for (int i = 0; i < attr.package_member_table.length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   404
            println("      #" + attr.package_member_table[i] + "\t// " + getPackageMemberName(attr, i));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   405
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   406
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   407
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   408
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   409
    String getPackageMemberName(ModuleMemberTable_attribute attr, int index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   410
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   411
            return attr.getPackageMemberName(index, constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   412
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   413
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   414
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   415
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   416
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   417
    public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   418
        println("  RuntimeVisibleAnnotations: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   419
        for (int i = 0; i < attr.annotations.length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   420
            print("    " + i + ": ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   421
            annotationWriter.write(attr.annotations[i]);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   422
            println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   423
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   424
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   425
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   426
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   427
    public Void visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   428
        println("  RuntimeInvisibleAnnotations: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   429
        for (int i = 0; i < attr.annotations.length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   430
            print("    " + i + ": ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   431
            annotationWriter.write(attr.annotations[i]);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   432
            println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   433
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   434
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   435
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   436
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   437
    public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   438
        println("  RuntimeVisibleParameterAnnotations: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   439
        for (int param = 0; param < attr.parameter_annotations.length; param++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   440
            println("    parameter " + param + ": ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   441
            for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   442
                print("    " + i + ": ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   443
                annotationWriter.write(attr.parameter_annotations[param][i]);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   444
                println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   445
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   446
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   447
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   448
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   449
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   450
    public Void visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   451
        println("  RuntimeInvisibleParameterAnnotations: ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   452
        for (int param = 0; param < attr.parameter_annotations.length; param++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   453
            println("    " + param + ": ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   454
            for (int i = 0; i < attr.parameter_annotations[param].length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   455
                print("    " + i + ": ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   456
                annotationWriter.write(attr.parameter_annotations[param][i]);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   457
                println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   458
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   459
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   460
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   461
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   462
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   463
    public Void visitSignature(Signature_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   464
        println("  Signature: #" + attr.signature_index + "\t// " + getSignature(attr));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   465
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   466
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   467
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   468
    String getSignature(Signature_attribute info) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   469
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   470
            return info.getSignature(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   471
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   472
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   473
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   474
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   475
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   476
    public Void visitSourceDebugExtension(SourceDebugExtension_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   477
        println("  SourceDebugExtension: " + attr.getValue());
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   478
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   479
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   480
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   481
    public Void visitSourceFile(SourceFile_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   482
        println("  SourceFile: \"" + getSourceFile(attr) + "\"");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   483
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   484
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   485
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   486
    private String getSourceFile(SourceFile_attribute attr) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   487
        try {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   488
            return attr.getSourceFile(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   489
        } catch (ConstantPoolException e) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   490
            return report(e);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   491
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   492
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   493
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   494
    public Void visitSourceID(SourceID_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   495
        constantWriter.write(attr.sourceID_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   496
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   497
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   498
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   499
    public Void visitStackMap(StackMap_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   500
        println("  StackMap: number_of_entries = " + attr.number_of_entries);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   501
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   502
        StackMapTableWriter w = new StackMapTableWriter();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   503
        for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   504
            w.write(entry);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   505
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   506
        println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   507
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   508
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   509
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   510
    public Void visitStackMapTable(StackMapTable_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   511
        println("  StackMapTable: number_of_entries = " + attr.number_of_entries);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   512
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   513
        StackMapTableWriter w = new StackMapTableWriter();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   514
        for (StackMapTable_attribute.stack_map_frame entry : attr.entries) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   515
            w.write(entry);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   516
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   517
        println();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   518
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   519
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   520
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   521
    class StackMapTableWriter // also handles CLDC StackMap attributes
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   522
            implements StackMapTable_attribute.stack_map_frame.Visitor<Void,Void> {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   523
        public void write(StackMapTable_attribute.stack_map_frame frame) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   524
            frame.accept(this, null);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   525
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   526
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   527
        public Void visit_same_frame(StackMapTable_attribute.same_frame frame, Void p) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   528
            printHeader(frame);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   529
            println(" /* same */");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   530
            return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   531
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   532
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   533
        public Void visit_same_locals_1_stack_item_frame(StackMapTable_attribute.same_locals_1_stack_item_frame frame, Void p) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   534
            printHeader(frame);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   535
            println(" /* same_locals_1_stack_item */");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   536
            printMap("stack", frame.stack);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   537
            return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   538
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   539
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   540
        public Void visit_same_locals_1_stack_item_frame_extended(StackMapTable_attribute.same_locals_1_stack_item_frame_extended frame, Void p) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   541
            printHeader(frame);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   542
            println(" /* same_locals_1_stack_item_frame_extended */");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   543
            println("     offset_delta = " + frame.offset_delta);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   544
            printMap("stack", frame.stack);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   545
            return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   546
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   547
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   548
        public Void visit_chop_frame(StackMapTable_attribute.chop_frame frame, Void p) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   549
            printHeader(frame);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   550
            println(" /* chop */");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   551
            println("     offset_delta = " + frame.offset_delta);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   552
            return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   553
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   554
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   555
        public Void visit_same_frame_extended(StackMapTable_attribute.same_frame_extended frame, Void p) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   556
            printHeader(frame);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   557
            println(" /* same_frame_extended */");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   558
            println("     offset_delta = " + frame.offset_delta);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   559
            return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   560
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   561
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   562
        public Void visit_append_frame(StackMapTable_attribute.append_frame frame, Void p) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   563
            printHeader(frame);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   564
            println(" /* append */");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   565
            println("     offset_delta = " + frame.offset_delta);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   566
            printMap("locals", frame.locals);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   567
            return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   568
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   569
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   570
        public Void visit_full_frame(StackMapTable_attribute.full_frame frame, Void p) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   571
            printHeader(frame);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   572
            if (frame instanceof StackMap_attribute.stack_map_frame) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   573
                println("     offset = " + frame.offset_delta);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   574
            } else {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   575
                println(" /* full_frame */");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   576
                println("     offset_delta = " + frame.offset_delta);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   577
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   578
            printMap("locals", frame.locals);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   579
            printMap("stack", frame.stack);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   580
            return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   581
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   582
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   583
        void printHeader(StackMapTable_attribute.stack_map_frame frame) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   584
            print("   frame_type = " + frame.frame_type);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   585
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   586
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   587
        void printMap(String name, StackMapTable_attribute.verification_type_info[] map) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   588
            print("     " + name + " = [");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   589
            for (int i = 0; i < map.length; i++) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   590
                StackMapTable_attribute.verification_type_info info = map[i];
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   591
                int tag = info.tag;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   592
                switch (tag) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   593
                    case StackMapTable_attribute.verification_type_info.ITEM_Object:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   594
                        print(" ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   595
                        constantWriter.write(((StackMapTable_attribute.Object_variable_info) info).cpool_index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   596
                        break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   597
                    case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   598
                        print(" " + mapTypeName(tag));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   599
                        print(" " + ((StackMapTable_attribute.Uninitialized_variable_info) info).offset);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   600
                        break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   601
                    default:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   602
                        print(" " + mapTypeName(tag));
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   603
                }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   604
                print(i == (map.length - 1) ? " " : ",");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   605
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   606
            println("]");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   607
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   608
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   609
        String mapTypeName(int tag) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   610
            switch (tag) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   611
            case StackMapTable_attribute.verification_type_info.ITEM_Top:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   612
                return "top";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   613
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   614
            case StackMapTable_attribute.verification_type_info.ITEM_Integer:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   615
                return "int";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   616
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   617
            case StackMapTable_attribute.verification_type_info.ITEM_Float:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   618
                return "float";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   619
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   620
            case StackMapTable_attribute.verification_type_info.ITEM_Long:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   621
                return "long";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   622
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   623
            case StackMapTable_attribute.verification_type_info.ITEM_Double:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   624
                return "double";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   625
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   626
            case StackMapTable_attribute.verification_type_info.ITEM_Null:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   627
                return "null";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   628
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   629
            case StackMapTable_attribute.verification_type_info.ITEM_UninitializedThis:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   630
                return "this";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   631
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   632
            case StackMapTable_attribute.verification_type_info.ITEM_Object:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   633
                return "CP";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   634
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   635
            case StackMapTable_attribute.verification_type_info.ITEM_Uninitialized:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   636
                return "uninitialized";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   637
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   638
            default:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   639
                report("unrecognized verification_type_info tag: " + tag);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   640
                return "[tag:" + tag + "]";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   641
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   642
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   643
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   644
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   645
    public Void visitSynthetic(Synthetic_attribute attr, Void ignore) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   646
        println("Synthetic: true");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   647
        return null;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   648
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   649
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   650
    static String getJavaName(String name) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   651
        return name.replace('/', '.');
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   652
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   653
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   654
    String toHex(byte b, int w) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   655
        if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   656
            return toHex((int) b, w);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   657
        else
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   658
            return toHex(b & 0xff, w);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   659
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   660
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   661
    static String toHex(int i) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   662
        return Integer.toString(i, 16).toUpperCase();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   663
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   664
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   665
    static String toHex(int i, int w) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   666
        String s = Integer.toHexString(i).toUpperCase();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   667
        while (s.length() < w)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   668
            s = "0" + s;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   669
        return s.toUpperCase();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   670
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   671
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   672
    private AnnotationWriter annotationWriter;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   673
    private CodeWriter codeWriter;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   674
    private ConstantWriter constantWriter;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   675
    private Options options;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   676
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   677
    private ConstantPool constant_pool;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   678
    private Object owner;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   679
}