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 package java.lang;
26
27 import jdk.internal.reflect.MethodAccessor;
28 import java.lang.StackWalker.Option;
29 import java.lang.StackWalker.StackFrame;
30
31 import java.lang.annotation.Native;
32 import java.lang.reflect.Method;
33 import java.util.HashSet;
34 import java.util.NoSuchElementException;
35 import java.util.Objects;
36 import java.util.Set;
37 import java.util.Spliterator;
38 import java.util.function.Consumer;
39 import java.util.function.Function;
40 import java.util.stream.Stream;
41 import java.util.stream.StreamSupport;
42 import sun.security.action.GetPropertyAction;
43
44 import static java.lang.StackStreamFactory.WalkerState.*;
45
46 /**
47 * StackStreamFactory class provides static factory methods
963 Set<Class<?>> classes = new HashSet<>();
964 classes.add(StackWalker.class);
965 classes.add(StackStreamFactory.class);
966 classes.add(AbstractStackWalker.class);
967 return classes;
968 }
969
970 private static boolean filterStackWalkImpl(Class<?> c) {
971 return stackWalkImplClasses.contains(c) ||
972 c.getName().startsWith("java.util.stream.");
973 }
974
975 // MethodHandle frames are not hidden and CallerClassFinder has
976 // to filter them out
977 private static boolean isMethodHandleFrame(Class<?> c) {
978 return c.getName().startsWith("java.lang.invoke.");
979 }
980
981 private static boolean isReflectionFrame(Class<?> c) {
982 if (c.getName().startsWith("jdk.internal.reflect") &&
983 !MethodAccessor.class.isAssignableFrom(c)) {
984 throw new InternalError("Not jdk.internal.reflect.MethodAccessor: " + c.toString());
985 }
986 // ## should filter all @Hidden frames?
987 return c == Method.class ||
988 MethodAccessor.class.isAssignableFrom(c) ||
989 c.getName().startsWith("java.lang.invoke.LambdaForm");
990 }
991
992 }
|
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 package java.lang;
26
27 import jdk.internal.reflect.MethodAccessor;
28 import jdk.internal.reflect.ConstructorAccessor;
29 import java.lang.StackWalker.Option;
30 import java.lang.StackWalker.StackFrame;
31
32 import java.lang.annotation.Native;
33 import java.lang.reflect.Method;
34 import java.util.HashSet;
35 import java.util.NoSuchElementException;
36 import java.util.Objects;
37 import java.util.Set;
38 import java.util.Spliterator;
39 import java.util.function.Consumer;
40 import java.util.function.Function;
41 import java.util.stream.Stream;
42 import java.util.stream.StreamSupport;
43 import sun.security.action.GetPropertyAction;
44
45 import static java.lang.StackStreamFactory.WalkerState.*;
46
47 /**
48 * StackStreamFactory class provides static factory methods
964 Set<Class<?>> classes = new HashSet<>();
965 classes.add(StackWalker.class);
966 classes.add(StackStreamFactory.class);
967 classes.add(AbstractStackWalker.class);
968 return classes;
969 }
970
971 private static boolean filterStackWalkImpl(Class<?> c) {
972 return stackWalkImplClasses.contains(c) ||
973 c.getName().startsWith("java.util.stream.");
974 }
975
976 // MethodHandle frames are not hidden and CallerClassFinder has
977 // to filter them out
978 private static boolean isMethodHandleFrame(Class<?> c) {
979 return c.getName().startsWith("java.lang.invoke.");
980 }
981
982 private static boolean isReflectionFrame(Class<?> c) {
983 if (c.getName().startsWith("jdk.internal.reflect") &&
984 !MethodAccessor.class.isAssignableFrom(c) &&
985 !ConstructorAccessor.class.isAssignableFrom(c)) {
986 throw new InternalError("Not jdk.internal.reflect.MethodAccessor"
987 + " or jdk.internal.reflect.ConstructorAccessor: "
988 + c.toString());
989 }
990 // ## should filter all @Hidden frames?
991 return c == Method.class ||
992 MethodAccessor.class.isAssignableFrom(c) ||
993 c.getName().startsWith("java.lang.invoke.LambdaForm");
994 }
995
996 }
|