Lines 1-9
Link Here
|
1 |
/* |
1 |
/* |
2 |
* InnerClass.java |
|
|
3 |
* |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
5 |
* |
3 |
* |
6 |
* Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. |
4 |
* Copyright 2013 Oracle and/or its affiliates. All rights reserved. |
7 |
* |
5 |
* |
8 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
6 |
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. |
9 |
* Other names may be trademarks of their respective owners. |
7 |
* Other names may be trademarks of their respective owners. |
Lines 29-35
Link Here
|
29 |
* Contributor(s): |
27 |
* Contributor(s): |
30 |
* |
28 |
* |
31 |
* The Original Software is NetBeans. The Initial Developer of the Original |
29 |
* The Original Software is NetBeans. The Initial Developer of the Original |
32 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
30 |
* Software is Sun Microsystems, Inc. Portions Copyright 2013 Sun |
33 |
* Microsystems, Inc. All Rights Reserved. |
31 |
* Microsystems, Inc. All Rights Reserved. |
34 |
* |
32 |
* |
35 |
* If you wish your version of this file to be governed by only the CDDL |
33 |
* If you wish your version of this file to be governed by only the CDDL |
Lines 57-143
Link Here
|
57 |
* An InnerClass attribute of a classfile. |
55 |
* An InnerClass attribute of a classfile. |
58 |
* |
56 |
* |
59 |
* @author Thomas Ball |
57 |
* @author Thomas Ball |
|
|
58 |
* @since 1.40 |
60 |
*/ |
59 |
*/ |
61 |
public final class InnerClass { |
60 |
public final class BootstrapMethod { |
62 |
|
61 |
|
63 |
ClassName name; |
62 |
int methodRef; |
64 |
ClassName outerClassName; |
63 |
int[] arguments; |
65 |
String simpleName; |
|
|
66 |
int access; |
67 |
|
64 |
|
68 |
static InnerClass[] loadInnerClasses(DataInputStream in, ConstantPool pool) |
65 |
static BootstrapMethod[] loadBootstrapMethod(DataInputStream in, ConstantPool pool) |
69 |
throws IOException { |
66 |
throws IOException { |
70 |
int n = in.readUnsignedShort(); |
67 |
int n = in.readUnsignedShort(); |
71 |
InnerClass[] innerClasses = new InnerClass[n]; |
68 |
BootstrapMethod[] innerClasses = new BootstrapMethod[n]; |
72 |
for (int i = 0; i < n; i++) |
69 |
for (int i = 0; i < n; i++) |
73 |
innerClasses[i] = new InnerClass(in, pool); |
70 |
innerClasses[i] = new BootstrapMethod(in, pool); |
74 |
return innerClasses; |
71 |
return innerClasses; |
75 |
} |
72 |
} |
76 |
|
73 |
|
77 |
InnerClass(DataInputStream in, ConstantPool pool) |
74 |
BootstrapMethod(DataInputStream in, ConstantPool pool) throws IOException { |
78 |
throws IOException { |
75 |
this.methodRef = in.readUnsignedShort(); |
79 |
loadInnerClass(in, pool); |
76 |
int args = in.readUnsignedShort(); |
|
|
77 |
arguments = new int[args]; |
78 |
for (int i = 0; i < args; i++) { |
79 |
arguments[i] = in.readUnsignedShort(); |
80 |
} |
80 |
} |
81 |
} |
81 |
|
82 |
|
82 |
private void loadInnerClass(DataInputStream in, ConstantPool pool) |
83 |
public int getMethodRef() { |
83 |
throws IOException { |
84 |
return methodRef; |
84 |
int index = in.readUnsignedShort(); |
|
|
85 |
name = (index > 0) ? pool.getClass(index).getClassName() : null; |
86 |
index = in.readUnsignedShort(); |
87 |
outerClassName = (index > 0) ? pool.getClass(index).getClassName() : null; |
88 |
index = in.readUnsignedShort(); |
89 |
if (index > 0) { |
90 |
CPUTF8Info entry = (CPUTF8Info)pool.get(index); |
91 |
simpleName = entry.getName(); |
92 |
} |
93 |
access = in.readUnsignedShort(); |
94 |
} |
85 |
} |
95 |
|
86 |
|
96 |
/** Returns the name of this class, including its package (if any). |
87 |
public int[] getArguments() { |
97 |
* If the compiler didn't define this value, the string |
88 |
return arguments.clone(); |
98 |
* "<not defined>" is returned. |
|
|
99 |
* @return the name of this class. |
100 |
*/ |
101 |
public final ClassName getName() { |
102 |
return name; |
103 |
} |
104 |
|
105 |
/** Returns the name of the enclosing outer class, including |
106 |
* its package (if any). |
107 |
* @return the name of this class, or null if not available. |
108 |
*/ |
109 |
public final ClassName getOuterClassName() { |
110 |
return outerClassName; |
111 |
} |
112 |
|
113 |
/** |
114 |
* Returns the original simple name as given in the source code. |
115 |
* If this is an anonymous class, null is returned instead. |
116 |
* @return the simple name of this class, or null if anonymous. |
117 |
*/ |
118 |
public final String getSimpleName() { |
119 |
return simpleName; |
120 |
} |
121 |
|
122 |
/** |
123 |
* Returns the access flags of this class. |
124 |
*/ |
125 |
public final int getAccess() { |
126 |
return access; |
127 |
} |
89 |
} |
128 |
|
90 |
|
129 |
@Override |
91 |
@Override |
130 |
public String toString() { |
92 |
public String toString() { |
131 |
StringBuffer sb = new StringBuffer(); |
93 |
StringBuilder sb = new StringBuilder(); |
132 |
sb.append("innerclass="); |
94 |
sb.append("bootstrapmethod="); |
133 |
sb.append(name); |
95 |
sb.append(methodRef); |
134 |
if (simpleName != null) { |
96 |
sb.append("("); |
135 |
sb.append(" ("); |
97 |
for (int i = 0; i < arguments.length; i++) { |
136 |
sb.append(simpleName); |
98 |
if (i > 0) sb.append(", "); |
137 |
sb.append(')'); |
99 |
sb.append(arguments[i]); |
138 |
} |
100 |
} |
139 |
sb.append(", outerclass="); |
101 |
sb.append(")"); |
140 |
sb.append(outerClassName); |
|
|
141 |
return sb.toString(); |
102 |
return sb.toString(); |
142 |
} |
103 |
} |
143 |
} |
104 |
} |