Lines 3-9
Link Here
|
3 |
* |
3 |
* |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
5 |
* |
5 |
* |
6 |
* Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. |
6 |
* Copyright 1997-2013 Oracle and/or its affiliates. All rights reserved. |
7 |
* |
7 |
* |
8 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
8 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
9 |
* Other names may be trademarks of their respective owners. |
9 |
* Other names may be trademarks of their respective owners. |
Lines 29-35
Link Here
|
29 |
* Contributor(s): |
29 |
* Contributor(s): |
30 |
* |
30 |
* |
31 |
* The Original Software is NetBeans. The Initial Developer of the Original |
31 |
* The Original Software is NetBeans. The Initial Developer of the Original |
32 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
32 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2013 Sun |
33 |
* Microsystems, Inc. All Rights Reserved. |
33 |
* Microsystems, Inc. All Rights Reserved. |
34 |
* |
34 |
* |
35 |
* If you wish your version of this file to be governed by only the CDDL |
35 |
* If you wish your version of this file to be governed by only the CDDL |
Lines 52-100
Link Here
|
52 |
|
52 |
|
53 |
|
53 |
|
54 |
/** |
54 |
/** |
55 |
* A class representing the CONSTANT_NameAndType constant pool type. |
55 |
* A class representing the CONSTANT_MethodHandle constant pool type. |
56 |
* |
56 |
* |
57 |
* @author Thomas Ball |
57 |
* @author Thomas Ball |
|
|
58 |
* @since 1.40 |
58 |
*/ |
59 |
*/ |
59 |
public class CPNameAndTypeInfo extends CPEntry { |
60 |
public class CPMethodHandleInfo extends CPEntry { |
60 |
int iName; |
61 |
ReferenceKind referenceKind; |
61 |
int iDesc; |
62 |
int iReference; |
62 |
|
63 |
|
63 |
CPNameAndTypeInfo(ConstantPool pool,int iName,int iDesc) { |
64 |
CPMethodHandleInfo(ConstantPool pool, int referenceKind,int iReference) { |
64 |
super(pool); |
65 |
super(pool); |
65 |
this.iName = iName; |
66 |
this.referenceKind = ReferenceKind.from(referenceKind); |
66 |
this.iDesc = iDesc; |
67 |
this.iReference = iReference; |
67 |
} |
|
|
68 |
|
69 |
protected CPNameAndTypeInfo(ConstantPool pool) { |
70 |
super(pool); |
71 |
iName = CPName.INVALID_INDEX; |
72 |
iDesc = CPName.INVALID_INDEX; |
73 |
} |
74 |
|
75 |
public final String getName() { |
76 |
return ((CPName)pool.cpEntries[iName]).getName(); |
77 |
} |
78 |
|
79 |
void setNameIndex(int index) { |
80 |
iName = index; |
81 |
} |
82 |
|
83 |
public final String getDescriptor() { |
84 |
return ((CPName)pool.cpEntries[iDesc]).getName(); |
85 |
} |
86 |
|
87 |
void setDescriptorIndex(int index) { |
88 |
iDesc = index; |
89 |
} |
68 |
} |
90 |
|
69 |
|
91 |
public int getTag() { |
70 |
public int getTag() { |
92 |
return ConstantPool.CONSTANT_NameAndType; |
71 |
return ConstantPool.CONSTANT_MethodHandle; |
93 |
} |
72 |
} |
94 |
|
73 |
|
95 |
@Override |
74 |
@Override |
96 |
public String toString() { |
75 |
public String toString() { |
97 |
return getClass().getName() + ": name=" + getName() + //NOI18N |
76 |
return getClass().getName() + ": kind=" + referenceKind + //NOI18N |
98 |
", descriptor=" + getDescriptor(); //NOI18N |
77 |
", index=" + iReference; //NOI18N |
|
|
78 |
} |
79 |
|
80 |
public enum ReferenceKind { |
81 |
getField(1), |
82 |
getStatic(2), |
83 |
putField(3), |
84 |
putStatic(4), |
85 |
invokeVirtual(5), |
86 |
invokeStatic(6), |
87 |
invokeSpecial(7), |
88 |
newInvokeSpecial(8), |
89 |
invokeInterface(9); |
90 |
|
91 |
private final int kindInt; |
92 |
|
93 |
private ReferenceKind(int kindInt) { |
94 |
this.kindInt = kindInt; |
95 |
} |
96 |
|
97 |
static ReferenceKind from(int referenceKind) { |
98 |
for (ReferenceKind k : values()) { |
99 |
if (k.kindInt == referenceKind) return k; |
100 |
} |
101 |
|
102 |
throw new IllegalStateException("Unknown ref kind: " + referenceKind); |
103 |
} |
99 |
} |
104 |
} |
100 |
} |
105 |
} |