langtools/src/share/classes/com/sun/tools/classfile/Descriptor.java
author xdono
Mon, 09 Mar 2009 13:29:06 -0700
changeset 2212 1d3dc0e0ba0c
parent 1870 57a1138dffc8
child 5520 86e4b9a9da40
permissions -rw-r--r--
6814575: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 03/09 Reviewed-by: katleman, tbell, ohair
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
/*
2212
1d3dc0e0ba0c 6814575: Update copyright year
xdono
parents: 1870
diff changeset
     2
 * Copyright 2007-2009 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
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    27
package com.sun.tools.classfile;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    28
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    29
import java.io.IOException;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    30
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    31
/**
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    32
 * See JVMS3, section 4.4.
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    33
 *
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    34
 *  <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
    35
 *  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
    36
 *  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
    37
 *  deletion without notice.</b>
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    38
 */
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    39
public class Descriptor {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    40
    public class InvalidDescriptor extends DescriptorException {
1870
57a1138dffc8 6795903: fix latent build warnings in langtools repository
jjg
parents: 735
diff changeset
    41
        private static final long serialVersionUID = 1L;
727
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    42
        InvalidDescriptor(String desc) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    43
            this.desc = desc;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    44
            this.index = -1;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    45
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    46
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    47
        InvalidDescriptor(String desc, int index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    48
            this.desc = desc;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    49
            this.index = index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    50
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    51
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    52
        @Override
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    53
        public String getMessage() {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    54
            // i18n
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    55
            if (index == -1)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    56
                return "invalid descriptor \"" + desc + "\"";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    57
            else
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    58
                return "descriptor is invalid at offset " + index + " in \"" + desc + "\"";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    59
        }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    60
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    61
        public final String desc;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    62
        public final int index;
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
    }
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
    public Descriptor(ClassReader cr) throws IOException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    67
        this(cr.readUnsignedShort());
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
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    70
    public Descriptor(int index) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    71
        this.index = index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    72
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
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    75
    public String getValue(ConstantPool constant_pool) throws ConstantPoolException {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    76
        return constant_pool.getUTF8Value(index);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    77
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    78
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    79
    public int getParameterCount(ConstantPool constant_pool)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    80
            throws ConstantPoolException, InvalidDescriptor {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    81
        String desc = getValue(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    82
        int end = desc.indexOf(")");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    83
        if (end == -1)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    84
            throw new InvalidDescriptor(desc);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    85
        parse(desc, 0, end + 1);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    86
        return count;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    87
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    88
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    89
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    90
    public String getParameterTypes(ConstantPool constant_pool)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    91
            throws ConstantPoolException, InvalidDescriptor {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    92
        String desc = getValue(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    93
        int end = desc.indexOf(")");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    94
        if (end == -1)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    95
            throw new InvalidDescriptor(desc);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    96
        return parse(desc, 0, end + 1);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    97
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    98
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
    99
    public String getReturnType(ConstantPool constant_pool)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   100
            throws ConstantPoolException, InvalidDescriptor {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   101
        String desc = getValue(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   102
        int end = desc.indexOf(")");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   103
        if (end == -1)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   104
            throw new InvalidDescriptor(desc);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   105
        return parse(desc, end + 1, desc.length());
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   106
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   107
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   108
    public String getFieldType(ConstantPool constant_pool)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   109
            throws ConstantPoolException, InvalidDescriptor {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   110
        String desc = getValue(constant_pool);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   111
        return parse(desc, 0, desc.length());
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   112
    }
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
    private String parse(String desc, int start, int end)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   115
            throws InvalidDescriptor {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   116
        int p = start;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   117
        StringBuffer sb = new StringBuffer();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   118
        int dims = 0;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   119
        count = 0;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   120
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   121
        while (p < end) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   122
            String type;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   123
            char ch;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   124
            switch (ch = desc.charAt(p++)) {
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   125
                case '(':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   126
                    sb.append('(');
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   127
                    continue;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   128
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   129
                case ')':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   130
                    sb.append(')');
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   131
                    continue;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   132
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   133
                case '[':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   134
                    dims++;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   135
                    continue;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   136
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   137
                case 'B':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   138
                    type = "byte";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   139
                    break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   140
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   141
                case 'C':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   142
                    type = "char";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   143
                    break;
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
                case 'D':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   146
                    type = "double";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   147
                    break;
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
                case 'F':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   150
                    type = "float";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   151
                    break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   152
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   153
                case 'I':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   154
                    type = "int";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   155
                    break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   156
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   157
                case 'J':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   158
                    type = "long";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   159
                    break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   160
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   161
                case 'L':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   162
                    int sep = desc.indexOf(';', p);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   163
                    if (sep == -1)
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   164
                        throw new InvalidDescriptor(desc, p - 1);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   165
                    type = desc.substring(p, sep).replace('/', '.');
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   166
                    p = sep + 1;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   167
                    break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   168
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   169
                case 'S':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   170
                    type = "short";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   171
                    break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   172
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   173
                case 'Z':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   174
                    type = "boolean";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   175
                    break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   176
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   177
                case 'V':
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   178
                    type = "void";
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   179
                    break;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   180
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   181
                default:
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   182
                    throw new InvalidDescriptor(desc, p - 1);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   183
            }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   184
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   185
            if (sb.length() > 1 && sb.charAt(0) == '(')
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   186
                sb.append(", ");
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   187
            sb.append(type);
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   188
            for ( ; dims > 0; dims-- )
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   189
                sb.append("[]");
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
            count++;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   192
        }
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
        return sb.toString();
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   195
    }
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   196
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   197
    public final int index;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   198
    private int count;
cb50c1ae7bab 4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff changeset
   199
}