Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/test/tools/javah/T4942232/MissingParamClassTest.java
38813 views
1
/*
2
* Copyright (c) 2013, 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
/*
25
* @test
26
* @bug 4942232
27
* @summary Verifies that javah won't attempt to generate a header file if a
28
* native method in a supplied class contains a parameter type whose corresponding
29
* class is missing or not in the classpath
30
* @library /tools/javac/lib
31
* @build ToolBox
32
* @run compile MissingParamClassTest.java
33
* @clean MissingParamClassException
34
* @run main MissingParamClassTest
35
* @run compile MissingParamClassTest.java
36
* @clean Param
37
* @run main MissingParamClassTest
38
*/
39
40
import java.nio.file.Files;
41
import java.nio.file.Paths;
42
import java.util.ArrayList;
43
import java.util.List;
44
45
//original test: test/tools/javah/MissingParamClassTest.sh
46
public class MissingParamClassTest {
47
48
public static void main(String[] args) throws Exception {
49
//first steps done now by jtreg
50
//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
51
//rm -f MissingParamClassException.class
52
53
//"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
54
List<String> errOutput = new ArrayList<>();
55
ToolBox.JavaToolArgs javahParams =
56
new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
57
.setAllArgs("-classpath", System.getProperty("test.classes"), "ParamClassTest")
58
.setErrOutput(errOutput);
59
ToolBox.javah(javahParams);
60
61
//if [ -f $GENERATED_HEADER_FILE ]; then fail
62
//if [ ! -s ${TMP1} ]; then fail
63
if (Files.exists(Paths.get("ParamClassTest.h")) || errOutput.size() == 0)
64
throw new AssertionError("The only output generated by javah must be an error message");
65
//jtreg again
66
//rm -f MissingParamClassException.class ParamClassTest.class
67
//rm -f $GENERATED_HEADER_FILE $TMP1
68
}
69
70
}
71
72
class MissingParamClassException extends Exception {
73
public MissingParamClassException() {
74
System.out.println("MissingParamClassException constructor called");
75
}
76
}
77
78
class ParamClassTest {
79
public native void method(Param s);
80
81
public static void main(String args[]) {
82
}
83
}
84
85
class Param extends MissingParamClassException {
86
Param() {
87
System.out.println("Param constructor");
88
}
89
}
90
91