[openjdk-7-jre-dcevm] 01/04: Backported the new JVM_FindClassFromCaller function added in Java 7u71 (Closes: #768715)

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Nov 17 10:17:52 UTC 2014


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository openjdk-7-jre-dcevm.

commit ea567ac5842cb5c6a17cf15f47a562c36491e1de
Author: Emmanuel Bourg <ebourg at apache.org>
Date:   Mon Nov 17 10:57:13 2014 +0100

    Backported the new JVM_FindClassFromCaller function added in Java 7u71 (Closes: #768715)
---
 debian/changelog                            |   7 ++
 debian/patches/java7u71-compatibility.patch | 146 ++++++++++++++++++++++++++++
 debian/patches/series                       |   1 +
 3 files changed, 154 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index de3be3a..4dfa7b3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+openjdk-7-jre-dcevm (7u60-3) UNRELEASED; urgency=medium
+
+  * Backported the new JVM_FindClassFromCaller function added in Java 7u71
+    (Closes: #768715)
+
+ -- Emmanuel Bourg <ebourg at apache.org>  Mon, 17 Nov 2014 10:32:08 +0100
+
 openjdk-7-jre-dcevm (7u60-2) unstable; urgency=medium
 
   * Fixed a build failure on i386 (Closes: #760304)
diff --git a/debian/patches/java7u71-compatibility.patch b/debian/patches/java7u71-compatibility.patch
new file mode 100644
index 0000000..b3fe730
--- /dev/null
+++ b/debian/patches/java7u71-compatibility.patch
@@ -0,0 +1,146 @@
+Description: Improve protection domain check in forName() (JDK-8015256)
+Origin: backport, http://hg.openjdk.java.net/jdk7u/jdk7u/hotspot/rev/61d1e75e0a58
+Bug-Debian: https://bugs.debian.org/768715
+--- a/make/bsd/makefiles/mapfile-vers-debug
++++ b/make/bsd/makefiles/mapfile-vers-debug
+@@ -82,6 +82,7 @@
+                 _JVM_EnableCompiler
+                 _JVM_Exit
+                 _JVM_FillInStackTrace
++                _JVM_FindClassFromCaller
+                 _JVM_FindClassFromClass
+                 _JVM_FindClassFromClassLoader
+                 _JVM_FindClassFromBootLoader
+--- a/make/bsd/makefiles/mapfile-vers-product
++++ b/make/bsd/makefiles/mapfile-vers-product
+@@ -82,6 +82,7 @@
+                 _JVM_EnableCompiler
+                 _JVM_Exit
+                 _JVM_FillInStackTrace
++                _JVM_FindClassFromCaller
+                 _JVM_FindClassFromClass
+                 _JVM_FindClassFromClassLoader
+                 _JVM_FindClassFromBootLoader
+--- a/make/linux/makefiles/mapfile-vers-debug
++++ b/make/linux/makefiles/mapfile-vers-debug
+@@ -84,6 +84,7 @@
+                 JVM_EnableCompiler;
+                 JVM_Exit;
+                 JVM_FillInStackTrace;
++                JVM_FindClassFromCaller;
+                 JVM_FindClassFromClass;
+                 JVM_FindClassFromClassLoader;
+                 JVM_FindClassFromBootLoader;
+--- a/make/linux/makefiles/mapfile-vers-product
++++ b/make/linux/makefiles/mapfile-vers-product
+@@ -84,6 +84,7 @@
+                 JVM_EnableCompiler;
+                 JVM_Exit;
+                 JVM_FillInStackTrace;
++                JVM_FindClassFromCaller;
+                 JVM_FindClassFromClass;
+                 JVM_FindClassFromClassLoader;
+                 JVM_FindClassFromBootLoader;
+--- a/make/solaris/makefiles/mapfile-vers
++++ b/make/solaris/makefiles/mapfile-vers
+@@ -84,6 +84,7 @@
+ 		JVM_EnableCompiler;
+ 		JVM_Exit;
+ 		JVM_FillInStackTrace;
++		JVM_FindClassFromCaller;
+ 		JVM_FindClassFromClass;
+ 		JVM_FindClassFromClassLoader;
+ 		JVM_FindClassFromBootLoader;
+--- a/src/share/vm/prims/jvm.cpp
++++ b/src/share/vm/prims/jvm.cpp
+@@ -746,6 +746,7 @@
+   return (jclass) JNIHandles::make_local(env, Klass::cast(k)->java_mirror());
+ JVM_END
+ 
++// Not used; JVM_FindClassFromCaller replaces this.
+ JVM_ENTRY(jclass, JVM_FindClassFromClassLoader(JNIEnv* env, const char* name,
+                                                jboolean init, jobject loader,
+                                                jboolean throwError))
+@@ -772,6 +773,42 @@
+   return result;
+ JVM_END
+ 
++// Find a class with this name in this loader, using the caller's protection domain.
++JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name,
++                                          jboolean init, jobject loader,
++                                          jclass caller))
++  JVMWrapper2("JVM_FindClassFromCaller %s throws ClassNotFoundException", name);
++  // Java libraries should ensure that name is never null...
++  if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
++    // It's impossible to create this class;  the name cannot fit
++    // into the constant pool.
++    THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
++  }
++
++  TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
++
++  oop loader_oop = JNIHandles::resolve(loader);
++  oop from_class = JNIHandles::resolve(caller);
++  oop protection_domain = NULL;
++  // If loader is null, shouldn't call ClassLoader.checkPackageAccess; otherwise get
++  // NPE. Put it in another way, the bootstrap class loader has all permission and
++  // thus no checkPackageAccess equivalence in the VM class loader.
++  // The caller is also passed as NULL by the java code if there is no security
++  // manager to avoid the performance cost of getting the calling class.
++  if (from_class != NULL && loader_oop != NULL) {
++    protection_domain = instanceKlass::cast(java_lang_Class::as_klassOop(from_class))->protection_domain();
++  }
++
++  Handle h_loader(THREAD, loader_oop);
++  Handle h_prot(THREAD, protection_domain);
++  jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
++                                               h_prot, false, THREAD);
++
++  if (TraceClassResolution && result != NULL) {
++    trace_class_resolution(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(result)));
++  }
++  return result;
++JVM_END
+ 
+ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name,
+                                          jboolean init, jclass from))
+@@ -4098,10 +4135,15 @@
+ 
+ // Shared JNI/JVM entry points //////////////////////////////////////////////////////////////
+ 
+-jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) {
++jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init,
++                                    Handle loader, Handle protection_domain,
++                                    jboolean throwError, TRAPS) {
+   // Security Note:
+   //   The Java level wrapper will perform the necessary security check allowing
+-  //   us to pass the NULL as the initiating class loader.
++  //   us to pass the NULL as the initiating class loader.  The VM is responsible for
++  //   the checkPackageAccess relative to the initiating class loader via the
++  //   protection_domain. The protection_domain is passed as NULL by the java code
++  //   if there is no security manager in 3-arg Class.forName().
+   klassOop klass = SystemDictionary::resolve_or_fail(name, loader, protection_domain, throwError != 0, CHECK_NULL);
+ 
+   KlassHandle klass_handle(THREAD, klass);
+--- a/src/share/vm/prims/jvm.h
++++ b/src/share/vm/prims/jvm.h
+@@ -415,6 +415,19 @@
+ JVM_FindClassFromBootLoader(JNIEnv *env, const char *name);
+ 
+ /*
++ * Find a class from a given class loader.  Throws ClassNotFoundException.
++ *  name:   name of class
++ *  init:   whether initialization is done
++ *  loader: class loader to look up the class. This may not be the same as the caller's
++ *          class loader.
++ *  caller: initiating class. The initiating class may be null when a security
++ *          manager is not installed.
++ */
++JNIEXPORT jclass JNICALL
++JVM_FindClassFromCaller(JNIEnv *env, const char *name, jboolean init,
++                        jobject loader, jclass caller);
++
++/*
+  * Find a class from a given class.
+  */
+ JNIEXPORT jclass JNICALL
diff --git a/debian/patches/series b/debian/patches/series
index bdb102e..d140ccc 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 distro-name.patch
 full-jdk7u60-b09.patch
+java7u71-compatibility.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/openjdk-7-jre-dcevm.git



More information about the pkg-java-commits mailing list