/src/test/jdk/jdk/internal/reflect/Reflection/GetCallerClassTest.sh

https://github.com/corretto/corretto-11 · Shell · 70 lines · 34 code · 7 blank · 29 comment · 7 complexity · eef5b6002449524188fc04cfbfb3e5ff MD5 · raw file

  1. #
  2. # Copyright (c) 2013, 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. # @test
  24. # @bug 8010117
  25. # @summary Test if the VM enforces Reflection.getCallerClass
  26. # be called by methods annotated with CallerSensitive
  27. #
  28. # @run shell GetCallerClassTest.sh
  29. if [ "${TESTSRC}" = "" ]
  30. then
  31. echo "TESTSRC not set. Test cannot execute. Failed."
  32. exit 1
  33. fi
  34. echo "TESTSRC=${TESTSRC}"
  35. if [ "${TESTJAVA}" = "" ]
  36. then
  37. echo "TESTJAVA not set. Test cannot execute. Failed."
  38. exit 1
  39. fi
  40. echo "TESTJAVA=${TESTJAVA}"
  41. if [ "${COMPILEJAVA}" = "" ]
  42. then
  43. COMPILEJAVA="${TESTJAVA}"
  44. fi
  45. echo "COMPILEJAVA=${COMPILEJAVA}"
  46. if [ "${TESTCLASSES}" = "" ]
  47. then
  48. echo "TESTCLASSES not set. Test cannot execute. Failed."
  49. exit 1
  50. fi
  51. BCP=${TESTCLASSES}/bcp
  52. rm -rf ${BCP}
  53. mkdir ${BCP}
  54. EXTRAOPTS="--add-exports java.base/jdk.internal.reflect=ALL-UNNAMED"
  55. # Compile GetCallerClass in bootclasspath
  56. ${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
  57. -XDignore.symbol.file \
  58. -d ${BCP} ${TESTSRC}/GetCallerClass.java || exit 1
  59. ${COMPILEJAVA}/bin/javac ${TESTTOOLVMOPTS} ${EXTRAOPTS} \
  60. -XDignore.symbol.file -cp ${BCP} \
  61. -d ${TESTCLASSES} ${TESTSRC}/GetCallerClassTest.java || exit 2
  62. ${TESTJAVA}/bin/java ${TESTVMOPTS} ${EXTRAOPTS} -Xbootclasspath/a:${BCP} \
  63. -cp ${TESTCLASSES} GetCallerClassTest || exit 3