Merge
authoramurillo
Thu, 23 Jun 2016 17:07:31 -0700
changeset 39328 ba6d354b8dd8
parent 39146 b77e14fef723 (current diff)
parent 39327 aaf17117b16c (diff)
child 39329 3c1532acb5e0
child 39469 0c47ce572097
Merge
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu Jun 23 21:44:11 2016 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu Jun 23 17:07:31 2016 -0700
@@ -318,24 +318,6 @@
      */
     public native Object getUncompressedObject(long address);
 
-    /**
-     * Fetches the {@link java.lang.Class} Java mirror for the given native
-     * metaspace {@code Klass} pointer.
-     *
-     * @param metaspaceKlass a native metaspace {@code Klass} pointer
-     * @return the {@link java.lang.Class} Java mirror
-     */
-    public native Class<?> getJavaMirror(long metaspaceKlass);
-
-    /**
-     * Fetches a native metaspace {@code Klass} pointer for the given Java
-     * object.
-     *
-     * @param o Java heap object for which to fetch the class pointer
-     * @return a native metaspace {@code Klass} pointer
-     */
-    public native long getKlassPointer(Object o);
-
     // These work on values in the C heap.
 
     /**
--- a/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java	Thu Jun 23 21:44:11 2016 +0000
+++ b/jdk/src/jdk.management/share/classes/com/sun/management/internal/DiagnosticCommandImpl.java	Thu Jun 23 17:07:31 2016 -0700
@@ -259,9 +259,20 @@
                     && signature[0] != null
                     && signature[0].compareTo(strArrayClassName) == 0)) {
                 return w.execute((String[]) params[0]);
+            } else {
+                throw new ReflectionException(
+                    new NoSuchMethodException(actionName
+                    + ": mismatched signature "
+                    + (signature != null ? Arrays.toString(signature) : "[]")
+                    + " or parameters"));
             }
+        } else {
+            throw new ReflectionException(
+                new NoSuchMethodException("Method " + actionName
+                + " with signature "
+                + (signature != null ? Arrays.toString(signature) : "[]")
+                + " not found"));
         }
-        throw new ReflectionException(new NoSuchMethodException(actionName));
     }
 
     private static String transform(String name) {
--- a/jdk/test/com/sun/jdi/BacktraceFieldTest.java	Thu Jun 23 21:44:11 2016 +0000
+++ b/jdk/test/com/sun/jdi/BacktraceFieldTest.java	Thu Jun 23 17:07:31 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -24,7 +24,8 @@
 /**
  *  @test
  *  @bug 4446677
- *  @summary debuggee crashes when debugging under jbuilder
+ *  @bug 8158237
+ *  @summary debuggee used to crash when debugging under jbuilder
  *
  *  @author jjh
  *
@@ -101,6 +102,16 @@
         new BacktraceFieldTest(args).startTests();
     }
 
+    private void printval(ArrayReference backTraceVal, int index) throws Exception {
+        ArrayReference val = (ArrayReference)backTraceVal.getValue(index);
+        println("BT: val at " + index + " = " + val);
+
+        // The segv used to happen here for index = 0
+        // Now all objects in the backtrace are objects.
+        Object xVal = (Object)val.getValue(0);
+        println("BT: xVal = " + xVal);
+    }
+
     /********** test core **********/
 
     protected void runTests() throws Exception {
@@ -128,42 +139,45 @@
          * Search through the fields of ee to verify that
          * java.lang.Throwable.backtrace isn't there.
          */
+        boolean backtrace_found = false;
         Iterator iter = allFields.iterator();
         while(iter.hasNext()) {
             Field ff = (Field)iter.next();
             if (ff.toString().equals("java.lang.Throwable.backtrace")) {
-                failure("ERROR: java.lang.Throwable.backtrace field not filtered out.");
+                backtrace_found = true;
+                println("java.lang.Throwable.backtrace field not filtered out.");
 
                 /*
                  * If you want to experience the segv this bug causes, change
                  * this test to 1 == 1 and run it with jdk 1.4, build 74 or earlier
                  */
-                if (1 == 0) {
+                if (1 == 1) {
                     // The following code will show the segv that this can cause.
                     ObjectReference myVal = (ObjectReference)myFrame.getValue(lv);
                     println("BT: myVal = " + myVal);
 
-                    ArrayReference backTraceVal = null;
-                    backTraceVal = (ArrayReference)myVal.getValue(ff);
+                    ArrayReference backTraceVal = (ArrayReference)myVal.getValue(ff);
                     println("BT: backTraceVal = " + backTraceVal);
 
-                    ArrayReference secondVal = (ArrayReference)backTraceVal.getValue(1);
-                    println("BT: secondVal = " + secondVal);
-
-                    Object x2Val = (Object)secondVal.getValue(0);
-                    println("BT: x2Val = " + x2Val);
+                    printval(backTraceVal, 0);
+                    printval(backTraceVal, 1);
+                    printval(backTraceVal, 2);
+                    printval(backTraceVal, 3);  // backtrace has 4 elements
 
-                    ArrayReference firstVal = (ArrayReference)backTraceVal.getValue(0);
-                    println("BT: firstVal = " + firstVal);
-
-                    // The segv happens here.
-                    Object xVal = (Object)firstVal.getValue(0);
-                    println("BT: xVal = " + xVal);
+                    try {
+                        printval(backTraceVal, 4);
+                    } catch (Exception e) {
+                        println("Exception " + e);
+                    }
                 }
                 break;
             }
         }
 
+        if (!backtrace_found) {
+            failure("ERROR: java.lang.Throwable.backtrace field filtered out.");
+        }
+
         // Next, verify that we don't accidently discard a field that we shouldn't
 
         if (!testFailed) {
--- a/jdk/test/sun/tools/jps/JpsBase.java	Thu Jun 23 21:44:11 2016 +0000
+++ b/jdk/test/sun/tools/jps/JpsBase.java	Thu Jun 23 17:07:31 2016 -0700
@@ -35,27 +35,28 @@
  */
 public final class JpsBase {
 
-    private static final String shortProcessName;
-    private static final String fullProcessName;
-
     /**
      * The jps output should contain processes' names
      * (except when jps is started in quite mode).
      * The expected name of the test process is prepared here.
      */
-    static {
+
+    private static String getShortProcessName() {
         URL url = JpsBase.class.getResource("JpsBase.class");
         boolean isJar = url.getProtocol().equals("jar");
+        return (isJar) ? JpsBase.class.getSimpleName() + ".jar" : JpsBase.class.getSimpleName();
+    }
 
+    private static String getFullProcessName() {
+        URL url = JpsBase.class.getResource("JpsBase.class");
+        boolean isJar = url.getProtocol().equals("jar");
         if (isJar) {
-            shortProcessName = JpsBase.class.getSimpleName() + ".jar";
             String urlPath = url.getPath();
             File jar = new File(urlPath.substring(urlPath.indexOf("file:") + 5, urlPath.indexOf("jar!") + 3));
-            fullProcessName = jar.getAbsolutePath();
-        } else {
-            shortProcessName = JpsBase.class.getSimpleName();
-            fullProcessName = JpsBase.class.getName();
+            return jar.getAbsolutePath();
         }
+
+        return JpsBase.class.getName();
     }
 
     public static void main(String[] args) throws Exception {
@@ -83,6 +84,7 @@
                     // or the full path name to the application's JAR file:
                     // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ...
                     isFull = true;
+                    String fullProcessName = getFullProcessName();
                     pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*";
                     output.shouldMatch(pattern);
                     break;
@@ -120,6 +122,7 @@
                 // Output should only contain lines with pids after the first line with pid.
                 JpsHelper.verifyJpsOutput(output, "^\\d+\\s+.*");
                 if (!isFull) {
+                    String shortProcessName = getShortProcessName();
                     pattern = "^" + pid + "\\s+" + replaceSpecialChars(shortProcessName);
                     if (combination.isEmpty()) {
                         // If no arguments are specified output should only contain