langtools/src/share/classes/com/sun/tools/classfile/MethodParameters_attribute.java
author poonam
Tue, 26 Feb 2013 08:58:20 -0800
changeset 15808 c75f11af1033
parent 15031 c4fad55a5681
child 16305 ee7f13d9d434
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15031
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     1
/*
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     4
 *
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    10
 *
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    15
 * accompanied this code).
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    16
 *
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    20
 *
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    23
 * questions.
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    24
 */
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    25
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    26
package com.sun.tools.classfile;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    27
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    28
import java.io.IOException;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    29
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    30
/**
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    31
 * See JVMS, section 4.8.13.
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    32
 *
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    33
 *  <p><b>This is NOT part of any supported API.
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    34
 *  If you write code that depends on this, you do so at your own risk.
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    35
 *  This code and its internal interfaces are subject to change or
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    36
 *  deletion without notice.</b>
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    37
 */
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    38
public class MethodParameters_attribute extends Attribute {
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    39
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    40
    public final int method_parameter_table_length;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    41
    public final Entry[] method_parameter_table;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    42
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    43
    MethodParameters_attribute(ClassReader cr,
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    44
                              int name_index,
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    45
                              int length)
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    46
        throws IOException {
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    47
        super(name_index, length);
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    48
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    49
        method_parameter_table_length = cr.readUnsignedByte();
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    50
        method_parameter_table = new Entry[method_parameter_table_length];
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    51
        for (int i = 0; i < method_parameter_table_length; i++)
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    52
            method_parameter_table[i] = new Entry(cr);
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    53
    }
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    54
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    55
    public MethodParameters_attribute(ConstantPool constant_pool,
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    56
                                      Entry[] method_parameter_table)
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    57
        throws ConstantPoolException {
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    58
        this(constant_pool.getUTF8Index(Attribute.MethodParameters),
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    59
             method_parameter_table);
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    60
    }
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    61
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    62
    public MethodParameters_attribute(int name_index,
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    63
                                      Entry[] method_parameter_table) {
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    64
        super(name_index, 1 + method_parameter_table.length * Entry.length());
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    65
        this.method_parameter_table_length = method_parameter_table.length;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    66
        this.method_parameter_table = method_parameter_table;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    67
    }
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    68
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    69
    public <R, D> R accept(Visitor<R, D> visitor, D data) {
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    70
        return visitor.visitMethodParameters(this, data);
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    71
    }
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    72
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    73
    public static class Entry {
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    74
        Entry(ClassReader cr) throws IOException {
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    75
            name_index = cr.readUnsignedShort();
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    76
            flags = cr.readInt();
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    77
        }
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    78
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    79
        public static int length() {
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    80
            return 6;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    81
        }
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    82
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    83
        public final int name_index;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    84
        public final int flags;
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    85
    }
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    86
c4fad55a5681 8004727: Add compiler support for parameter reflection
jjg
parents:
diff changeset
    87
}