author | ohair |
Tue, 25 May 2010 15:54:51 -0700 | |
changeset 5520 | 86e4b9a9da40 |
parent 3998 | c66be272f350 |
child 12084 | b367473ef0f1 |
permissions | -rw-r--r-- |
10 | 1 |
#!/bin/sh |
2 |
||
3 |
# |
|
5520 | 4 |
# Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. |
10 | 5 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6 |
# |
|
7 |
# This code is free software; you can redistribute it and/or modify it |
|
8 |
# under the terms of the GNU General Public License version 2 only, as |
|
9 |
# published by the Free Software Foundation. |
|
10 |
# |
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
# accompanied this code). |
|
16 |
# |
|
17 |
# You should have received a copy of the GNU General Public License version |
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
# |
|
5520 | 21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
10 | 24 |
# |
25 |
||
26 |
# @test |
|
27 |
# |
|
28 |
# @bug 4942232 |
|
29 |
||
30 |
# |
|
31 |
# Verifies that javah won't attempt to generate a header file |
|
32 |
# if a native method in a supplied class contains a parameter |
|
33 |
# type whose corresponding class is missing or not in the |
|
34 |
# classpath |
|
35 |
||
36 |
TMP1=OUTPUT.txt |
|
37 |
||
38 |
if [ "${TESTSRC}" = "" ] |
|
39 |
then |
|
40 |
echo "TESTSRC not set. Test cannot execute. Failed." |
|
41 |
exit 1 |
|
42 |
fi |
|
43 |
echo "TESTSRC=${TESTSRC}" |
|
44 |
if [ "${TESTJAVA}" = "" ] |
|
45 |
then |
|
46 |
echo "TESTJAVA not set. Test cannot execute. Failed." |
|
47 |
exit 1 |
|
48 |
fi |
|
49 |
echo "TESTJAVA=${TESTJAVA}" |
|
50 |
if [ "${TESTCLASSES}" = "" ] |
|
51 |
then |
|
52 |
echo "TESTCLASSES not set. Test cannot execute. Failed." |
|
53 |
exit 1 |
|
54 |
fi |
|
55 |
echo "TESTCLASSES=${TESTCLASSES}" |
|
56 |
echo "CLASSPATH=${CLASSPATH}" |
|
57 |
||
58 |
# set platform-dependent variables |
|
59 |
OS=`uname -s` |
|
60 |
case "$OS" in |
|
3770 | 61 |
SunOS | Linux | CYGWIN* ) |
10 | 62 |
PS=":" |
63 |
FS="/" |
|
64 |
;; |
|
65 |
Windows* ) |
|
66 |
PS=";" |
|
67 |
FS="\\" |
|
68 |
;; |
|
69 |
* ) |
|
70 |
echo "Unrecognized system!" |
|
71 |
exit 1; |
|
72 |
;; |
|
73 |
esac |
|
74 |
||
75 |
GENERATED_HEADER_FILE=ParamClassTest.h |
|
76 |
||
77 |
rm -f ParamClassTest.class MissingParamClassException.class ParamClassTest.h |
|
78 |
rm -f ${TMP1} |
|
79 |
||
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
80 |
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java" |
10 | 81 |
|
82 |
# Before running javah remove dependent class file |
|
83 |
rm -f MissingParamClassException.class |
|
84 |
||
85 |
"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1} |
|
86 |
||
87 |
if [ -f $GENERATED_HEADER_FILE ]; then |
|
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
88 |
echo "1-- Failed: $GENERATED_HEADER_FILE found" |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
89 |
rc=1 |
10 | 90 |
fi |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
91 |
if [ ! -s ${TMP1} ]; then |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
92 |
echo "1-- Failed: ${TMP1} is empty" |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
93 |
rc=1 |
10 | 94 |
fi |
95 |
||
96 |
# Clean out work dir |
|
97 |
rm -f MissingParamClassException.class ParamClassTest.class |
|
98 |
rm -f $GENERATED_HEADER_FILE $TMP1 |
|
99 |
||
100 |
# Re-compile everything |
|
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
101 |
|
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
102 |
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java" |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
103 |
|
10 | 104 |
|
105 |
# Before re-run of javah remove dependent class file Param.class |
|
106 |
rm -f Param.class |
|
107 |
||
108 |
"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1} |
|
109 |
||
110 |
if [ -f $GENERATED_HEADER_FILE ]; then |
|
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
111 |
echo "2-- Failed: $GENERATED_HEADER_FILE found" |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
112 |
rc=1 |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
113 |
fi |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
114 |
if [ ! -s ${TMP1} ]; then |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
115 |
echo "2-- Failed: ${TMP1} is empty" |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
116 |
rc=1 |
10 | 117 |
fi |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
118 |
|
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
119 |
if [ "$rc" = "" ]; then |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
120 |
echo Passed |
10 | 121 |
else |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
122 |
echo Failed |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
3770
diff
changeset
|
123 |
exit 1 |
10 | 124 |
fi |