8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.lang.invoke; 27 28 import sun.invoke.util.BytecodeDescriptor; 29 import sun.invoke.util.VerifyAccess; 30 31 import java.lang.reflect.Constructor; 32 import java.lang.reflect.Field; 33 import java.lang.reflect.Method; 34 import java.lang.reflect.Member; 35 import java.lang.reflect.Modifier; 36 import java.lang.reflect.Module; 37 import java.util.ArrayList; 38 import java.util.Arrays; 39 import java.util.Collections; 40 import java.util.Iterator; 41 import java.util.List; 42 import static java.lang.invoke.MethodHandleNatives.Constants.*; 43 import static java.lang.invoke.MethodHandleStatics.*; 44 import java.util.Objects; 45 46 /** 47 * A {@code MemberName} is a compact symbolic datum which fully characterizes 1126 /** Return a list of all nested types defined by the given class. 1127 * Super types are searched (for inherited members) if {@code searchSupers} is true. 1128 * Access checking is performed on behalf of the given {@code lookupClass}. 1129 * Inaccessible members are not added to the last. 1130 */ 1131 public List<MemberName> getNestedTypes(Class<?> defc, boolean searchSupers, 1132 Class<?> lookupClass) { 1133 int matchFlags = IS_TYPE | (searchSupers ? SEARCH_ALL_SUPERS : 0); 1134 return getMembers(defc, null, null, matchFlags, lookupClass); 1135 } 1136 private static MemberName[] newMemberBuffer(int length) { 1137 MemberName[] buf = new MemberName[length]; 1138 // fill the buffer with dummy structs for the JVM to fill in 1139 for (int i = 0; i < length; i++) 1140 buf[i] = new MemberName(); 1141 return buf; 1142 } 1143 } 1144 1145 static { 1146 // Allow privileged classes outside of java.lang 1147 jdk.internal.misc.SharedSecrets.setJavaLangInvokeAccess(new jdk.internal.misc.JavaLangInvokeAccess() { 1148 public Object newMemberName() { 1149 return new MemberName(); 1150 } 1151 public String getName(Object mname) { 1152 MemberName memberName = (MemberName)mname; 1153 return memberName.getName(); 1154 } 1155 }); 1156 } 1157 } | 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.lang.invoke; 27 28 import jdk.internal.misc.JavaLangInvokeAccess; 29 import jdk.internal.misc.SharedSecrets; 30 import sun.invoke.util.BytecodeDescriptor; 31 import sun.invoke.util.VerifyAccess; 32 33 import java.lang.reflect.Constructor; 34 import java.lang.reflect.Field; 35 import java.lang.reflect.Method; 36 import java.lang.reflect.Member; 37 import java.lang.reflect.Modifier; 38 import java.lang.reflect.Module; 39 import java.util.ArrayList; 40 import java.util.Arrays; 41 import java.util.Collections; 42 import java.util.Iterator; 43 import java.util.List; 44 import static java.lang.invoke.MethodHandleNatives.Constants.*; 45 import static java.lang.invoke.MethodHandleStatics.*; 46 import java.util.Objects; 47 48 /** 49 * A {@code MemberName} is a compact symbolic datum which fully characterizes 1128 /** Return a list of all nested types defined by the given class. 1129 * Super types are searched (for inherited members) if {@code searchSupers} is true. 1130 * Access checking is performed on behalf of the given {@code lookupClass}. 1131 * Inaccessible members are not added to the last. 1132 */ 1133 public List<MemberName> getNestedTypes(Class<?> defc, boolean searchSupers, 1134 Class<?> lookupClass) { 1135 int matchFlags = IS_TYPE | (searchSupers ? SEARCH_ALL_SUPERS : 0); 1136 return getMembers(defc, null, null, matchFlags, lookupClass); 1137 } 1138 private static MemberName[] newMemberBuffer(int length) { 1139 MemberName[] buf = new MemberName[length]; 1140 // fill the buffer with dummy structs for the JVM to fill in 1141 for (int i = 0; i < length; i++) 1142 buf[i] = new MemberName(); 1143 return buf; 1144 } 1145 } 1146 1147 static { 1148 // StackFrameInfo stores Member and this provides the shared secrets 1149 // for stack walker to access MemberName information. 1150 SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() { 1151 @Override 1152 public Object newMemberName() { 1153 return new MemberName(); 1154 } 1155 1156 @Override 1157 public String getName(Object mname) { 1158 MemberName memberName = (MemberName)mname; 1159 return memberName.getName(); 1160 } 1161 1162 @Override 1163 public boolean isNative(Object mname) { 1164 MemberName memberName = (MemberName)mname; 1165 return memberName.isNative(); 1166 } 1167 }); 1168 } 1169 } |