/patches/security/20130618/8006611-improve_scripting.patch

https://bitbucket.org/Ringdingcoder/icedtea6 · Patch · 78 lines · 74 code · 4 blank · 0 comment · 0 complexity · c277c3de0f7d8985cd256ec58077cc04 MD5 · raw file

  1. # HG changeset patch
  2. # User sundar
  3. # Date 1365156565 -19800
  4. # Node ID 1d5eff0bd9b504b7191279bfc6a417f6a2e2251f
  5. # Parent 5c9fbf7443a24076a6545cb043102cb2527f62ca
  6. 8006611: Improve scripting
  7. Reviewed-by: mchung, jdn
  8. diff --git a/src/share/classes/javax/script/ScriptEngineManager.java b/src/share/classes/javax/script/ScriptEngineManager.java
  9. --- openjdk/jdk/src/share/classes/javax/script/ScriptEngineManager.java
  10. +++ openjdk/jdk/src/share/classes/javax/script/ScriptEngineManager.java
  11. @@ -30,8 +30,6 @@
  12. import java.security.*;
  13. import sun.misc.Service;
  14. import sun.misc.ServiceConfigurationError;
  15. -import sun.reflect.Reflection;
  16. -import sun.security.util.SecurityConstants;
  17. /**
  18. * The <code>ScriptEngineManager</code> implements a discovery and instantiation
  19. @@ -64,13 +62,7 @@
  20. */
  21. public ScriptEngineManager() {
  22. ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader();
  23. - if (canCallerAccessLoader(ctxtLoader)) {
  24. - if (DEBUG) System.out.println("using " + ctxtLoader);
  25. - init(ctxtLoader);
  26. - } else {
  27. - if (DEBUG) System.out.println("using bootstrap loader");
  28. - init(null);
  29. - }
  30. + init(ctxtLoader);
  31. }
  32. /**
  33. @@ -418,42 +410,4 @@
  34. /** Global bindings associated with script engines created by this manager. */
  35. private Bindings globalScope;
  36. -
  37. - private boolean canCallerAccessLoader(ClassLoader loader) {
  38. - SecurityManager sm = System.getSecurityManager();
  39. - if (sm != null) {
  40. - ClassLoader callerLoader = getCallerClassLoader();
  41. - if (callerLoader != null) {
  42. - if (loader != callerLoader || !isAncestor(loader, callerLoader)) {
  43. - try {
  44. - sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
  45. - } catch (SecurityException exp) {
  46. - if (DEBUG) exp.printStackTrace();
  47. - return false;
  48. - }
  49. - } // else fallthru..
  50. - } // else fallthru..
  51. - } // else fallthru..
  52. -
  53. - return true;
  54. - }
  55. -
  56. - // Note that this code is same as ClassLoader.getCallerClassLoader().
  57. - // But, that method is package private and hence we can't call here.
  58. - private ClassLoader getCallerClassLoader() {
  59. - Class caller = Reflection.getCallerClass(3);
  60. - if (caller == null) {
  61. - return null;
  62. - }
  63. - return caller.getClassLoader();
  64. - }
  65. -
  66. - // is cl1 ancestor of cl2?
  67. - private boolean isAncestor(ClassLoader cl1, ClassLoader cl2) {
  68. - do {
  69. - cl2 = cl2.getParent();
  70. - if (cl1 == cl2) return true;
  71. - } while (cl2 != null);
  72. - return false;
  73. - }
  74. }