changeset 8055:651cd13f8cc2

8072370: [TESTBUG] Modify/remove tests that depends on -Xbootclasspath:/p
author ctornqvi
date Tue, 17 Mar 2015 14:40:55 -0700
parents c651edf2ab08
children 9aede78465d8
files test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java test/runtime/BadObjectClass/BootstrapRedefine.java test/runtime/BadObjectClass/Object.java test/testlibrary/ClassFileInstaller.java
diffstat 4 files changed, 60 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java	Thu Mar 12 19:55:07 2015 -0400
+++ b/test/compiler/dependencies/MonomorphicObjectCall/TestMonomorphicObjectCall.java	Tue Mar 17 14:40:55 2015 -0700
@@ -22,6 +22,8 @@
  */
 
 import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collections;
 
@@ -32,12 +34,10 @@
  * @bug 8050079
  * @summary Compiles a monomorphic call to finalizeObject() on a modified java.lang.Object to test C1 CHA.
  * @library /testlibrary
- * @ignore 8072370
  * @compile -XDignore.symbol.file java/lang/Object.java TestMonomorphicObjectCall.java
  * @run main TestMonomorphicObjectCall
  */
 public class TestMonomorphicObjectCall {
-    final static String testClasses = System.getProperty("test.classes") + File.separator;
 
     private static void callFinalize(Object object) throws Throwable {
         // Call modified version of java.lang.Object::finalize() that is
@@ -48,6 +48,9 @@
 
     public static void main(String[] args) throws Throwable {
         if (args.length == 0) {
+            byte[] bytecode = Files.readAllBytes(Paths.get(System.getProperty("test.classes") + File.separator +
+                "java" + File.separator + "lang" + File.separator + "Object.class"));
+            ClassFileInstaller.writeClassToDisk("java.lang.Object", bytecode, "mods/java.base");
             // Execute new instance with modified java.lang.Object
             executeTestJvm();
         } else {
@@ -60,7 +63,7 @@
         // Execute test with modified version of java.lang.Object
         // in -Xbootclasspath.
         String[] vmOpts = new String[] {
-                "-Xbootclasspath/p:" + testClasses,
+                "-Xoverride:mods",
                 "-Xcomp",
                 "-XX:+IgnoreUnrecognizedVMOptions",
                 "-XX:-VerifyDependencies",
--- a/test/runtime/BadObjectClass/BootstrapRedefine.java	Thu Mar 12 19:55:07 2015 -0400
+++ b/test/runtime/BadObjectClass/BootstrapRedefine.java	Tue Mar 17 14:40:55 2015 -0700
@@ -26,8 +26,6 @@
  * @bug 6583051
  * @summary Give error if java.lang.Object has been incompatibly overridden on the bootpath
  * @library /testlibrary
- * @ignore 8072370
- * @compile Object.java
  * @run main BootstrapRedefine
  */
 
@@ -36,8 +34,18 @@
 public class BootstrapRedefine {
 
     public static void main(String[] args) throws Exception {
-        String testClasses = System.getProperty("test.classes", ".");
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xbootclasspath/p:" + testClasses, "-version");
+        String source = "package java.lang;" +
+                        "public class Object {" +
+                        "    void dummy1() { return; }" +
+                        "    void dummy2() { return; }" +
+                        "    void dummy3() { return; }" +
+                        "}";
+
+        ClassFileInstaller.writeClassToDisk("java/lang/Object",
+                                        InMemoryJavaCompiler.compile("java.lang.Object", source),
+                                        "mods/java.base");
+
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xoverride:mods", "-version");
         new OutputAnalyzer(pb.start())
             .shouldContain("Incompatible definition of java.lang.Object")
             .shouldHaveExitValue(1);
--- a/test/runtime/BadObjectClass/Object.java	Thu Mar 12 19:55:07 2015 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2015, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang;
-
-/**
- * This is a fake java.lang.Object class.
- */
-public class Object {
-
-    // Add some methods
-    void dummy1() { return; }
-    void dummy2() { return; }
-    void dummy3() { return; }
-}
--- a/test/testlibrary/ClassFileInstaller.java	Thu Mar 12 19:55:07 2015 -0400
+++ b/test/testlibrary/ClassFileInstaller.java	Tue Mar 17 14:40:55 2015 -0700
@@ -22,6 +22,7 @@
  */
 
 import java.io.InputStream;
+import java.io.ByteArrayInputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -37,19 +38,47 @@
      */
     public static void main(String... args) throws Exception {
         for (String arg : args) {
-            ClassLoader cl = ClassFileInstaller.class.getClassLoader();
-
-            // Convert dotted class name to a path to a class file
-            String pathName = arg.replace('.', '/').concat(".class");
-            InputStream is = cl.getResourceAsStream(pathName);
-
-            // Create the class file's package directory
-            Path p = Paths.get(pathName);
-            if (pathName.contains("/")) {
-                Files.createDirectories(p.getParent());
-            }
-            // Create the class file
-            Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
+            writeClassToDisk(arg);
         }
     }
+
+    public static void writeClassToDisk(String className) throws Exception {
+        writeClassToDisk(className, "");
+    }
+
+    public static void writeClassToDisk(String className, String prependPath) throws Exception {
+        ClassLoader cl = ClassFileInstaller.class.getClassLoader();
+
+        // Convert dotted class name to a path to a class file
+        String pathName = className.replace('.', '/').concat(".class");
+        InputStream is = cl.getResourceAsStream(pathName);
+        if (prependPath.length() > 0) {
+            pathName = prependPath + "/" + pathName;
+        }
+        writeToDisk(pathName, is);
+    }
+
+    public static void writeClassToDisk(String className, byte[] bytecode) throws Exception {
+        writeClassToDisk(className, bytecode, "");
+    }
+
+    public static void writeClassToDisk(String className, byte[] bytecode, String prependPath) throws Exception {
+        // Convert dotted class name to a path to a class file
+        String pathName = className.replace('.', '/').concat(".class");
+        if (prependPath.length() > 0) {
+            pathName = prependPath + "/" + pathName;
+        }
+        writeToDisk(pathName, new ByteArrayInputStream(bytecode));
+    }
+
+
+    private static void writeToDisk(String pathName, InputStream is) throws Exception {
+        // Create the class file's package directory
+        Path p = Paths.get(pathName);
+        if (pathName.contains("/")) {
+            Files.createDirectories(p.getParent());
+        }
+        // Create the class file
+        Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
+    }
 }