src/java.xml/share/classes/com/sun/org/apache/bcel/internal/util/AttributeHTML.java
author joehw
Wed, 26 Jun 2019 05:49:59 +0000
changeset 55496 8e0ae3830fca
parent 47216 71c04702a3d5
permissions -rw-r--r--
8224157: BCEL: update to version 6.3.1 Reviewed-by: dfuchs, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
44797
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     5
/*
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     8
 * this work for additional information regarding copyright ownership.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    11
 * the License.  You may obtain a copy of the License at
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    12
 *
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    14
 *
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    18
 * See the License for the specific language governing permissions and
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    19
 * limitations under the License.
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    20
 */
8b3b3b911b8a 8162572: Update License Header for all JAXP sources
joehw
parents: 25868
diff changeset
    21
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
package com.sun.org.apache.bcel.internal.util;
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    24
import java.io.FileOutputStream;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    25
import java.io.IOException;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    26
import java.io.PrintWriter;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    28
import com.sun.org.apache.bcel.internal.Const;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    29
import com.sun.org.apache.bcel.internal.classfile.Attribute;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    30
import com.sun.org.apache.bcel.internal.classfile.Code;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    31
import com.sun.org.apache.bcel.internal.classfile.CodeException;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    32
import com.sun.org.apache.bcel.internal.classfile.ConstantPool;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    33
import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    34
import com.sun.org.apache.bcel.internal.classfile.ConstantValue;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    35
import com.sun.org.apache.bcel.internal.classfile.ExceptionTable;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    36
import com.sun.org.apache.bcel.internal.classfile.InnerClass;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    37
import com.sun.org.apache.bcel.internal.classfile.InnerClasses;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    38
import com.sun.org.apache.bcel.internal.classfile.LineNumber;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    39
import com.sun.org.apache.bcel.internal.classfile.LineNumberTable;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    40
import com.sun.org.apache.bcel.internal.classfile.LocalVariable;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    41
import com.sun.org.apache.bcel.internal.classfile.LocalVariableTable;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    42
import com.sun.org.apache.bcel.internal.classfile.SourceFile;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    43
import com.sun.org.apache.bcel.internal.classfile.Utility;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * Convert found attributes into HTML file.
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 *
55496
8e0ae3830fca 8224157: BCEL: update to version 6.3.1
joehw
parents: 47216
diff changeset
    48
 * @version $Id$
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    49
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 */
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    51
final class AttributeHTML {
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    52
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    53
    private final String class_name; // name of current class
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    54
    private final PrintWriter file; // file to write to
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    55
    private int attr_count = 0;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    56
    private final ConstantHTML constant_html;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    57
    private final ConstantPool constant_pool;
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    60
    AttributeHTML(final String dir, final String class_name, final ConstantPool constant_pool,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    61
            final ConstantHTML constant_html) throws IOException {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    62
        this.class_name = class_name;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    63
        this.constant_pool = constant_pool;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    64
        this.constant_html = constant_html;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    65
        file = new PrintWriter(new FileOutputStream(dir + class_name + "_attributes.html"));
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    66
        file.println("<HTML><BODY BGCOLOR=\"#C0C0C0\"><TABLE BORDER=0>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    67
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    70
    private String codeLink( final int link, final int method_number ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    71
        return "<A HREF=\"" + class_name + "_code.html#code" + method_number + "@" + link
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    72
                + "\" TARGET=Code>" + link + "</A>";
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    73
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    76
    final void close() {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    77
        file.println("</TABLE></BODY></HTML>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    78
        file.close();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    79
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    82
    final void writeAttribute( final Attribute attribute, final String anchor ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    83
        writeAttribute(attribute, anchor, 0);
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
46174
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    86
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    87
    final void writeAttribute( final Attribute attribute, final String anchor, final int method_number ) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    88
        final byte tag = attribute.getTag();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    89
        int index;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    90
        if (tag == Const.ATTR_UNKNOWN) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    91
            return;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    92
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    93
        attr_count++; // Increment number of attributes found so far
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    94
        if (attr_count % 2 == 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    95
            file.print("<TR BGCOLOR=\"#C0C0C0\"><TD>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    96
        } else {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    97
            file.print("<TR BGCOLOR=\"#A0A0A0\"><TD>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    98
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
    99
        file.println("<H4><A NAME=\"" + anchor + "\">" + attr_count + " " + Const.getAttributeName(tag)
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   100
                + "</A></H4>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   101
        /* Handle different attributes
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   102
         */
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   103
        switch (tag) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   104
            case Const.ATTR_CODE:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   105
                final Code c = (Code) attribute;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   106
                // Some directly printable values
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   107
                file.print("<UL><LI>Maximum stack size = " + c.getMaxStack()
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   108
                        + "</LI>\n<LI>Number of local variables = " + c.getMaxLocals()
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   109
                        + "</LI>\n<LI><A HREF=\"" + class_name + "_code.html#method"
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   110
                        + method_number + "\" TARGET=Code>Byte code</A></LI></UL>\n");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   111
                // Get handled exceptions and list them
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   112
                final CodeException[] ce = c.getExceptionTable();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   113
                final int len = ce.length;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   114
                if (len > 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   115
                    file.print("<P><B>Exceptions handled</B><UL>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   116
                    for (final CodeException cex : ce) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   117
                        final int catch_type = cex.getCatchType(); // Index in constant pool
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   118
                        file.print("<LI>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   119
                        if (catch_type != 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   120
                            file.print(constant_html.referenceConstant(catch_type)); // Create Link to _cp.html
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   121
                        } else {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   122
                            file.print("Any Exception");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   123
                        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   124
                        file.print("<BR>(Ranging from lines "
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   125
                                + codeLink(cex.getStartPC(), method_number) + " to "
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   126
                                + codeLink(cex.getEndPC(), method_number) + ", handled at line "
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   127
                                + codeLink(cex.getHandlerPC(), method_number) + ")</LI>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   128
                    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   129
                    file.print("</UL>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   130
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   131
                break;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   132
            case Const.ATTR_CONSTANT_VALUE:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   133
                index = ((ConstantValue) attribute).getConstantValueIndex();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   134
                // Reference _cp.html
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   135
                file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   136
                        + "\" TARGET=\"ConstantPool\">Constant value index(" + index
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   137
                        + ")</A></UL>\n");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   138
                break;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   139
            case Const.ATTR_SOURCE_FILE:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   140
                index = ((SourceFile) attribute).getSourceFileIndex();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   141
                // Reference _cp.html
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   142
                file.print("<UL><LI><A HREF=\"" + class_name + "_cp.html#cp" + index
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   143
                        + "\" TARGET=\"ConstantPool\">Source file index(" + index + ")</A></UL>\n");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   144
                break;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   145
            case Const.ATTR_EXCEPTIONS:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   146
                // List thrown exceptions
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   147
                final int[] indices = ((ExceptionTable) attribute).getExceptionIndexTable();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   148
                file.print("<UL>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   149
                for (final int indice : indices) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   150
                    file.print("<LI><A HREF=\"" + class_name + "_cp.html#cp" + indice
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   151
                            + "\" TARGET=\"ConstantPool\">Exception class index(" + indice
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   152
                            + ")</A>\n");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   153
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   154
                file.print("</UL>\n");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   155
                break;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   156
            case Const.ATTR_LINE_NUMBER_TABLE:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   157
                final LineNumber[] line_numbers = ((LineNumberTable) attribute).getLineNumberTable();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   158
                // List line number pairs
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   159
                file.print("<P>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   160
                for (int i = 0; i < line_numbers.length; i++) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   161
                    file.print("(" + line_numbers[i].getStartPC() + ",&nbsp;"
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   162
                            + line_numbers[i].getLineNumber() + ")");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   163
                    if (i < line_numbers.length - 1) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   164
                        file.print(", "); // breakable
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   165
                    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   166
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   167
                break;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   168
            case Const.ATTR_LOCAL_VARIABLE_TABLE:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   169
                final LocalVariable[] vars = ((LocalVariableTable) attribute).getLocalVariableTable();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   170
                // List name, range and type
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   171
                file.print("<UL>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   172
                for (final LocalVariable var : vars) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   173
                    index = var.getSignatureIndex();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   174
                    String signature = ((ConstantUtf8) constant_pool.getConstant(index,
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   175
                            Const.CONSTANT_Utf8)).getBytes();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   176
                    signature = Utility.signatureToString(signature, false);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   177
                    final int start = var.getStartPC();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   178
                    final int end = start + var.getLength();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   179
                    file.println("<LI>" + Class2HTML.referenceType(signature) + "&nbsp;<B>"
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   180
                            + var.getName() + "</B> in slot %" + var.getIndex()
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   181
                            + "<BR>Valid from lines " + "<A HREF=\"" + class_name
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   182
                            + "_code.html#code" + method_number + "@" + start + "\" TARGET=Code>"
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   183
                            + start + "</A> to " + "<A HREF=\"" + class_name + "_code.html#code"
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   184
                            + method_number + "@" + end + "\" TARGET=Code>" + end + "</A></LI>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   185
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   186
                file.print("</UL>\n");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   187
                break;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   188
            case Const.ATTR_INNER_CLASSES:
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   189
                final InnerClass[] classes = ((InnerClasses) attribute).getInnerClasses();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   190
                // List inner classes
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   191
                file.print("<UL>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   192
                for (final InnerClass classe : classes) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   193
                    String name;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   194
                    String access;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   195
                    index = classe.getInnerNameIndex();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   196
                    if (index > 0) {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   197
                        name = ((ConstantUtf8) constant_pool.getConstant(index, Const.CONSTANT_Utf8))
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   198
                                .getBytes();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   199
                    } else {
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   200
                        name = "&lt;anonymous&gt;";
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   201
                    }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   202
                    access = Utility.accessToString(classe.getInnerAccessFlags());
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   203
                    file.print("<LI><FONT COLOR=\"#FF0000\">" + access + "</FONT> "
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   204
                            + constant_html.referenceConstant(classe.getInnerClassIndex())
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   205
                            + " in&nbsp;class "
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   206
                            + constant_html.referenceConstant(classe.getOuterClassIndex())
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   207
                            + " named " + name + "</LI>\n");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   208
                }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   209
                file.print("</UL>\n");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   210
                break;
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   211
            default: // Such as Unknown attribute or Deprecated
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   212
                file.print("<P>" + attribute);
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   213
        }
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   214
        file.println("</TD></TR>");
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   215
        file.flush();
5611d2529b49 8163121: BCEL: update to the latest 6.0 release
joehw
parents: 44797
diff changeset
   216
    }
6
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
}