/com.oracle.max.tests/src/jtt/reflect/Reflection_getCallerClass01.java

https://github.com/chaoyangnz/maxine · Java · 57 lines · 24 code · 7 blank · 26 comment · 0 complexity · 555a944180a210bfcc3b8837956a60d6 MD5 · raw file

  1. /*
  2. * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
  3. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4. *
  5. * This code is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 only, as
  7. * published by the Free Software Foundation.
  8. *
  9. * This code is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * version 2 for more details (a copy is included in the LICENSE file that
  13. * accompanied this code).
  14. *
  15. * You should have received a copy of the GNU General Public License version
  16. * 2 along with this work; if not, write to the Free Software Foundation,
  17. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20. * or visit www.oracle.com if you need additional information or have any
  21. * questions.
  22. */
  23. package jtt.reflect;
  24. import sun.reflect.*;
  25. /*
  26. * @Harness: java
  27. * @Runs: 0 = "sun.reflect.Reflection"; 1 = "jtt.reflect.Reflection_getCallerClass01$Caller1"; 2 = "jtt.reflect.Reflection_getCallerClass01$Caller2"
  28. */
  29. public final class Reflection_getCallerClass01 {
  30. private Reflection_getCallerClass01() {
  31. }
  32. public static final class Caller1 {
  33. private Caller1() {
  34. }
  35. @SuppressWarnings("deprecation")
  36. static String caller1(int depth) {
  37. return Reflection.getCallerClass(depth).getName();
  38. }
  39. }
  40. public static final class Caller2 {
  41. private Caller2() {
  42. }
  43. static String caller2(int depth) {
  44. return Caller1.caller1(depth);
  45. }
  46. }
  47. public static String test(int depth) {
  48. return Caller2.caller2(depth);
  49. }
  50. }