Merge
authoramurillo
Fri, 15 Jul 2016 09:05:36 -0700
changeset 39741 8bc25e077e83
parent 39652 4213518e2074 (current diff)
parent 39740 d49ff02bacc9 (diff)
child 39742 f5d65fcf55e4
child 40181 a8c9eb3e97e2
Merge
jdk/test/ProblemList.txt
--- a/jdk/src/java.base/share/native/include/jvmti.h	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/src/java.base/share/native/include/jvmti.h	Fri Jul 15 09:05:36 2016 -0700
@@ -1217,8 +1217,11 @@
     jmethodID method,
     jlocation location);
 
-  /*   40 :  RESERVED */
-  void *reserved40;
+  /*   40 : Get Named Module */
+  jvmtiError (JNICALL *GetNamedModule) (jvmtiEnv* env,
+    jobject class_loader,
+    const char* package_name,
+    jobject* module_ptr);
 
   /*   41 : Set Field Access Watch */
   jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv* env,
@@ -2146,6 +2149,12 @@
     return functions->GetAllModules(this, module_count_ptr, modules_ptr);
   }
 
+  jvmtiError GetNamedModule(jobject class_loader,
+            const char* package_name,
+            jobject* module_ptr) {
+    return functions->GetNamedModule(this, class_loader, package_name, module_ptr);
+  }
+
   jvmtiError GetLoadedClasses(jint* class_count_ptr,
             jclass** classes_ptr) {
     return functions->GetLoadedClasses(this, class_count_ptr, classes_ptr);
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/ClassFileTransformer.java	Fri Jul 15 09:05:36 2016 -0700
@@ -38,7 +38,7 @@
  * A transformer of class files. An agent registers an implementation of this
  * interface using the {@link Instrumentation#addTransformer addTransformer}
  * method so that the transformer's {@link
- * ClassFileTransformer#transform(Module,String,Class,ProtectionDomain,byte[])
+ * ClassFileTransformer#transform(Module,ClassLoader,String,Class,ProtectionDomain,byte[])
  * transform} method is invoked when classes are loaded,
  * {@link Instrumentation#redefineClasses redefined}, or
  * {@link Instrumentation#retransformClasses retransformed}. The implementation
@@ -170,13 +170,13 @@
     /**
      * Transforms the given class file and returns a new replacement class file.
      * This method is invoked when the {@link Module Module} bearing {@link
-     * ClassFileTransformer#transform(Module,String,Class,ProtectionDomain,byte[])
+     * ClassFileTransformer#transform(Module,ClassLoader,String,Class,ProtectionDomain,byte[])
      * transform} is not overridden.
      *
      * @implSpec The default implementation returns null.
      *
      * @param loader                the defining loader of the class to be transformed,
-     *                              may be <code>null</code> if the bootstrap loader
+     *                              may be {@code null} if the bootstrap loader
      * @param className             the name of the class in the internal form of fully
      *                              qualified class and interface names as defined in
      *                              <i>The Java Virtual Machine Specification</i>.
@@ -208,9 +208,11 @@
      *
      * @implSpec The default implementation of this method invokes the
      * {@link #transform(ClassLoader,String,Class,ProtectionDomain,byte[]) transform}
-     * method with the {@link Module#getClassLoader() ClassLoader} for the module.
+     * method.
      *
      * @param module                the module of the class to be transformed
+     * @param loader                the defining loader of the class to be transformed,
+     *                              may be {@code null} if the bootstrap loader
      * @param className             the name of the class in the internal form of fully
      *                              qualified class and interface names as defined in
      *                              <i>The Java Virtual Machine Specification</i>.
@@ -230,15 +232,13 @@
      */
     default byte[]
     transform(  Module              module,
+                ClassLoader         loader,
                 String              className,
                 Class<?>            classBeingRedefined,
                 ProtectionDomain    protectionDomain,
                 byte[]              classfileBuffer)
         throws IllegalClassFormatException {
 
-        PrivilegedAction<ClassLoader> pa = module::getClassLoader;
-        ClassLoader loader = AccessController.doPrivileged(pa);
-
         // invoke the legacy transform method
         return transform(loader,
                          className,
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java	Fri Jul 15 09:05:36 2016 -0700
@@ -162,7 +162,7 @@
      *    </li>
      *    <li>for each transformer that was added with <code>canRetransform</code>
      *      false, the bytes returned by
-     *      {@link ClassFileTransformer#transform(Module,String,Class,ProtectionDomain,byte[])
+     *      {@link ClassFileTransformer#transform(Module,ClassLoader,String,Class,ProtectionDomain,byte[])
      *      transform} during the last class load or redefine are
      *      reused as the output of the transformation; note that this is
      *      equivalent to reapplying the previous transformation, unaltered;
@@ -170,7 +170,7 @@
      *    </li>
      *    <li>for each transformer that was added with <code>canRetransform</code>
      *      true, the
-     *      {@link ClassFileTransformer#transform(Module,String,Class,ProtectionDomain,byte[])
+     *      {@link ClassFileTransformer#transform(Module,ClassLoader,String,Class,ProtectionDomain,byte[])
      *      transform} method is called in these transformers
      *    </li>
      *    <li>the transformed class file bytes are installed as the new
--- a/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java	Fri Jul 15 09:05:36 2016 -0700
@@ -420,8 +420,8 @@
 
     // WARNING: the native code knows the name & signature of this method
     private byte[]
-    transform(  ClassLoader         loader,
-                Module              module,
+    transform(  Module              module,
+                ClassLoader         loader,
                 String              classname,
                 Class<?>            classBeingRedefined,
                 ProtectionDomain    protectionDomain,
@@ -444,6 +444,7 @@
             return null; // no manager, no transform
         } else {
             return mgr.transform(   module,
+                                    loader,
                                     classname,
                                     classBeingRedefined,
                                     protectionDomain,
--- a/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/src/java.instrument/share/classes/sun/instrument/TransformerManager.java	Fri Jul 15 09:05:36 2016 -0700
@@ -169,6 +169,7 @@
 
     public byte[]
     transform(  Module              module,
+                ClassLoader         loader,
                 String              classname,
                 Class<?>            classBeingRedefined,
                 ProtectionDomain    protectionDomain,
@@ -187,6 +188,7 @@
 
             try {
                 transformedBytes = transformer.transform(   module,
+                                                            loader,
                                                             classname,
                                                             classBeingRedefined,
                                                             protectionDomain,
--- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.c	Fri Jul 15 09:05:36 2016 -0700
@@ -771,12 +771,11 @@
 }
 
 static jobject
-getModuleObject(JNIEnv *                jnienv,
+getModuleObject(jvmtiEnv*               jvmti,
                 jobject                 loaderObject,
                 const char*             cname) {
-    jboolean errorOutstanding = JNI_FALSE;
+    jvmtiError err = JVMTI_ERROR_NONE;
     jobject moduleObject = NULL;
-    jstring package = NULL;
 
     /* find last slash in the class name */
     char* last_slash = (cname == NULL) ? NULL : strrchr(cname, '/');
@@ -789,14 +788,9 @@
     }
     pkg_name_buf[len] = '\0';
 
-    package = (*jnienv)->NewStringUTF(jnienv, pkg_name_buf);
-    jplis_assert_msg(package != NULL, "OOM error in NewStringUTF");
+    err = (*jvmti)->GetNamedModule(jvmti, loaderObject, pkg_name_buf, &moduleObject);
+    jplis_assert_msg(err == JVMTI_ERROR_NONE, "error in the JVMTI GetNamedModule");
 
-    moduleObject = JVM_GetModuleByPackageName(jnienv, loaderObject, package);
-
-    errorOutstanding = checkForAndClearThrowable(jnienv);
-    jplis_assert_msg(!errorOutstanding,
-                     "error in lookup of a module of the class being instrumented");
     free((void*)pkg_name_buf);
     return moduleObject;
 }
@@ -862,7 +856,7 @@
             jobject moduleObject = NULL;
 
             if (classBeingRedefined == NULL) {
-                moduleObject = getModuleObject(jnienv, loaderObject, name);
+                moduleObject = getModuleObject(jvmti(agent), loaderObject, name);
             } else {
                 // Redefine or retransform, InstrumentationImpl.transform() will use
                 // classBeingRedefined.getModule() to get the module.
@@ -873,8 +867,8 @@
                                                 jnienv,
                                                 agent->mInstrumentationImpl,
                                                 agent->mTransform,
+                                                moduleObject,
                                                 loaderObject,
-                                                moduleObject,
                                                 classNameStringObject,
                                                 classBeingRedefined,
                                                 protectionDomain,
--- a/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/src/java.instrument/share/native/libinstrument/JPLISAgent.h	Fri Jul 15 09:05:36 2016 -0700
@@ -66,7 +66,7 @@
 #define JPLIS_INSTRUMENTIMPL_AGENTMAININVOKER_METHODSIGNATURE "(Ljava/lang/String;Ljava/lang/String;)V"
 #define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODNAME           "transform"
 #define JPLIS_INSTRUMENTIMPL_TRANSFORM_METHODSIGNATURE      \
-    "(Ljava/lang/ClassLoader;Ljava/lang/reflect/Module;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B"
+    "(Ljava/lang/reflect/Module;Ljava/lang/ClassLoader;Ljava/lang/String;Ljava/lang/Class;Ljava/security/ProtectionDomain;[BZ)[B"
 
 
 /*
--- a/jdk/test/ProblemList.txt	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/test/ProblemList.txt	Fri Jul 15 09:05:36 2016 -0700
@@ -138,6 +138,8 @@
 
 java/lang/instrument/BootClassPath/BootClassPathTest.sh         8072130 macosx-all
 
+java/lang/instrument/DaemonThread/TestDaemonThread.java         8161225 generic-all
+
 java/lang/management/MemoryMXBean/LowMemoryTest.java            8130339 generic-all
 
 java/lang/management/MemoryMXBean/Pending.java                  8158837 generic-all
--- a/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/test/java/lang/instrument/ATransformerManagementTestCase.java	Fri Jul 15 09:05:36 2016 -0700
@@ -302,6 +302,7 @@
         public byte[]
         transform(
             Module module,
+            ClassLoader loader,
             String className,
             Class<?> classBeingRedefined,
             ProtectionDomain    protectionDomain,
@@ -311,6 +312,7 @@
             if (classBeingRedefined != null) checkInTransformer(MyClassFileTransformer.this);
 
             return super.transform(     module,
+                                        loader,
                                         className,
                                         classBeingRedefined,
                                         protectionDomain,
--- a/jdk/test/java/lang/instrument/RetransformAgent.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/test/java/lang/instrument/RetransformAgent.java	Fri Jul 15 09:05:36 2016 -0700
@@ -69,6 +69,7 @@
         }
 
         public byte[] transform(Module module,
+                                ClassLoader loader,
                                 String className,
                                 Class<?> classBeingRedefined,
                                 ProtectionDomain    protectionDomain,
--- a/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/test/java/lang/instrument/SimpleIdentityTransformer.java	Fri Jul 15 09:05:36 2016 -0700
@@ -63,6 +63,7 @@
     public byte[]
     transform(
         Module module,
+        ClassLoader loader,
         String className,
         Class<?> classBeingRedefined,
         ProtectionDomain    protectionDomain,
--- a/jdk/test/sun/tools/jps/JpsBase.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/test/sun/tools/jps/JpsBase.java	Fri Jul 15 09:05:36 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,17 @@
         return JpsBase.class.getName();
     }
 
+    private static boolean userDirSanityCheck(String fullProcessName) {
+        String userDir = System.getProperty("user.dir");
+        if (!fullProcessName.startsWith(userDir)) {
+            System.err.printf("Test skipped. user.dir '%s' is not a prefix of '%s'\n", userDir, fullProcessName);
+            return false;
+        }
+        return true;
+    }
+
     public static void main(String[] args) throws Exception {
+        System.out.printf("INFO: user.dir:  '%s''\n", System.getProperty("user.dir"));
         long pid = ProcessTools.getProcessId();
 
         List<List<JpsHelper.JpsArg>> combinations = JpsHelper.JpsArg.generateCombinations();
@@ -85,8 +95,12 @@
                     // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ...
                     isFull = true;
                     String fullProcessName = getFullProcessName();
-                    pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
-                    output.shouldMatch(pattern);
+                    // Skip the test if user.dir is not a prefix of the current path
+                    // It's possible if the test is run from symlinked dir or windows alias drive
+                    if (userDirSanityCheck(fullProcessName)) {
+                        pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
+                        output.shouldMatch(pattern);
+                    }
                     break;
                 case m:
                     // If '-m' is specified output should contain the arguments passed to the main method:
--- a/jdk/test/sun/tools/jps/TestJpsJar.java	Thu Jul 14 19:42:16 2016 -0700
+++ b/jdk/test/sun/tools/jps/TestJpsJar.java	Fri Jul 15 09:05:36 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,7 @@
         cmd.addAll(JpsHelper.getVmArgs());
         cmd.add("-Dtest.jdk=" + testJdk);
         cmd.add("-Dtest.src=" + testSrc);
+        cmd.add("-Duser.dir=" + System.getProperty("user.dir"));
         cmd.add("-jar");
         cmd.add(jar.getAbsolutePath());
         cmd.add("monkey");