Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/launcher/8261785/Test8261785.java
41149 views
1
/*
2
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
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
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
import java.io.IOException;
25
import java.nio.file.Files;
26
import java.nio.file.Path;
27
import java.nio.file.Paths;
28
import org.testng.annotations.Test;
29
import static org.testng.Assert.assertEquals;
30
import static org.testng.Assert.assertTrue;
31
32
/*
33
* @test
34
* @bug 8261785
35
* @summary Test static main methods in anonymous/local class won't cause launcher crash
36
* @modules jdk.compiler jdk.zipfs
37
* @compile ../TestHelper.java
38
* @run testng Test8261785
39
*/
40
public class Test8261785 {
41
private final Path inputDir;
42
43
public Test8261785() {
44
inputDir = Paths.get(System.getProperty("test.src", "."));
45
}
46
47
public void compile() {
48
Path file = inputDir.resolve("CrashTheJVM.java");
49
TestHelper.compile("-d", ".", file.toAbsolutePath().toString());
50
}
51
52
@Test
53
public void run() throws IOException {
54
System.out.println("Current folder: " + Paths.get(".").toAbsolutePath().toString());
55
compile();
56
String[] clz = Files.list(Paths.get("."))
57
.peek(p -> System.out.println("Found " + p.toString()))
58
.map(Path::getFileName)
59
.map(Path::toString)
60
.filter(f -> f.endsWith(".class"))
61
.map(f -> f.substring(0, f.length() - 6))
62
.toArray(String[]::new);
63
assertEquals(clz.length, 8);
64
for (String f: clz) {
65
System.out.println("Running class " + f);
66
var result = TestHelper.doExec(TestHelper.javaCmd, "-cp", ".", f);
67
assertTrue(result.isOK());
68
};
69
}
70
}
71
72