author | redestad |
Mon, 18 Apr 2016 16:48:12 +0200 | |
changeset 37370 | 4dcebdd2bbc0 |
parent 33402 | 1156d495a525 |
permissions | -rw-r--r-- |
19403
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
1 |
/* |
33402
1156d495a525
8140336: Add @modules for exported dependencies to jdk_core tests
shurailine
parents:
21596
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
19403
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
4 |
* |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
21596 | 7 |
* published by the Free Software Foundation. |
19403
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
8 |
* |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
13 |
* accompanied this code). |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
14 |
* |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
18 |
* |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
21 |
* questions. |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
22 |
*/ |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
23 |
|
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
24 |
/** |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
25 |
* @test |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
26 |
* @bug 8003639 |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
27 |
* @summary defaultMethod resolution and verification using an URLClassLoader |
33402
1156d495a525
8140336: Add @modules for exported dependencies to jdk_core tests
shurailine
parents:
21596
diff
changeset
|
28 |
* @modules jdk.compiler |
19403
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
29 |
* @compile -XDignore.symbol.file=true DefaultMethodRegressionTestsRun.java |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
30 |
* @run main DefaultMethodRegressionTestsRun |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
31 |
*/ |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
32 |
import java.io.File; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
33 |
import java.lang.reflect.Method; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
34 |
import java.net.URL; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
35 |
import java.net.URLClassLoader; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
36 |
import java.nio.file.DirectoryStream; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
37 |
import java.nio.file.Files; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
38 |
import java.nio.file.Path; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
39 |
/** |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
40 |
* This test is a variant of DefaultMethodRegressionTests, this one creates |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
41 |
* an URLClassLoader to load the support classes. |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
42 |
* |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
43 |
*/ |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
44 |
public class DefaultMethodRegressionTestsRun { |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
45 |
public static void main(String... args) throws Exception { |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
46 |
File scratchDir = new File("."); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
47 |
File testDir = new File(scratchDir, "testdir"); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
48 |
testDir.mkdirs(); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
49 |
File srcFile = new File(new File(System.getProperty("test.src")), |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
50 |
"DefaultMethodRegressionTests.java"); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
51 |
String[] javacargs = { |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
52 |
srcFile.getAbsolutePath(), |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
53 |
"-d", |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
54 |
testDir.getAbsolutePath() |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
55 |
}; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
56 |
com.sun.tools.javac.Main.compile(javacargs); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
57 |
runClass(testDir, "DefaultMethodRegressionTests"); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
58 |
} |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
59 |
static void runClass( |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
60 |
File classPath, |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
61 |
String classname) throws Exception { |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
62 |
URL[] urls = {classPath.toURI().toURL()}; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
63 |
ClassLoader loader = new URLClassLoader(urls); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
64 |
Class<?> c = loader.loadClass(classname); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
65 |
|
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
66 |
Class<?>[] argTypes = new Class<?>[]{String[].class}; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
67 |
Object[] methodArgs = new Object[]{null}; |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
68 |
|
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
69 |
Method method = c.getMethod("main", argTypes); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
70 |
method.invoke(c, methodArgs); |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
71 |
} |
d4f40eee1188
8022547: [verifier] move DefaultMethodRegressionTests.java to jdk
ksrini
parents:
diff
changeset
|
72 |
} |