1 /* |
1 /* |
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
23 |
23 |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 4842196 |
26 * @bug 4842196 |
27 * @summary Test that there is no difference between the JMX version and the |
27 * @summary Test that there is no difference between the JMX version and the |
28 * JDK version when JMX is bundled into the Java platform and the application |
28 * JDK version when the application is run with a security manager and the |
29 * is run with a security manager and the test codebase has the java permission |
29 * test codebase has the java permission to read the "java.runtime.version" |
30 * to read the "java.runtime.version" system property. |
30 * system property. |
31 * @author Luis-Miguel Alventosa |
31 * @author Luis-Miguel Alventosa |
32 * @modules java.management |
32 * @modules java.management |
33 * @run clean ImplVersionTest ImplVersionCommand |
33 * @run clean ImplVersionTest ImplVersionCommand |
34 * @run build ImplVersionTest ImplVersionCommand ImplVersionReader |
34 * @run build ImplVersionTest ImplVersionCommand ImplVersionReader |
35 * @run main ImplVersionTest |
35 * @run main ImplVersionTest |
36 */ |
36 */ |
37 |
37 |
38 import java.io.File; |
38 import java.io.File; |
39 import java.security.CodeSource; |
|
40 import javax.management.MBeanServer; |
|
41 |
39 |
42 public class ImplVersionTest { |
40 public class ImplVersionTest { |
43 |
41 |
44 public static void main(String[] args) { |
42 public static void main(String[] args) { |
45 try { |
43 try { |
68 // |
66 // |
69 String testClasses = System.getProperty("test.classes"); |
67 String testClasses = System.getProperty("test.classes"); |
70 System.out.println("testClasses = " + testClasses); |
68 System.out.println("testClasses = " + testClasses); |
71 // Get boot class path |
69 // Get boot class path |
72 // |
70 // |
73 boolean checkVersion = true; |
|
74 String bootClassPath = System.getProperty("sun.boot.class.path"); |
|
75 if (bootClassPath != null && |
|
76 bootClassPath.indexOf("jmxri.jar") != -1) |
|
77 checkVersion = false; |
|
78 String command = |
71 String command = |
79 javaHome + File.separator + "bin" + File.separator + "java " + |
72 javaHome + File.separator + "bin" + File.separator + "java " + |
80 " -classpath " + testClasses + |
73 " -classpath " + testClasses + |
81 " -Djava.security.manager -Djava.security.policy==" + testSrc + |
74 " -Djava.security.manager -Djava.security.policy==" + testSrc + |
82 File.separator + "policy -Dtest.classes=" + testClasses + |
75 File.separator + "policy -Dtest.classes=" + testClasses + |
83 " ImplVersionCommand " + |
76 " ImplVersionCommand " + |
84 System.getProperty("java.runtime.version") + " " + checkVersion; |
77 System.getProperty("java.runtime.version"); |
85 System.out.println("ImplVersionCommand Exec Command = " +command); |
78 System.out.println("ImplVersionCommand Exec Command = " +command); |
86 Process proc = Runtime.getRuntime().exec(command); |
79 Process proc = Runtime.getRuntime().exec(command); |
87 new ImplVersionReader(proc, proc.getInputStream()).start(); |
80 new ImplVersionReader(proc, proc.getInputStream()).start(); |
88 new ImplVersionReader(proc, proc.getErrorStream()).start(); |
81 new ImplVersionReader(proc, proc.getErrorStream()).start(); |
89 int exitValue = proc.waitFor(); |
82 int exitValue = proc.waitFor(); |