0N/A#!/bin/sh
2362N/A
0N/A#
0N/A# Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
0N/A# published by the Free Software Foundation.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
2362N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2362N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A# or visit www.oracle.com if you need additional information or have any
0N/A# questions.
0N/A#
0N/A
0N/A# @test
0N/A# @bug 4989093 5009164 5023880 5029482 6206786
0N/A# @run shell ../verifyVariables.sh
0N/A# @run shell scanner.sh
0N/A# @summary Test source order scanner
0N/A# @author Joseph D. Darcy
0N/A
0N/AOS=`uname -s`;
0N/Acase "${OS}" in
0N/A Windows* | CYGWIN* )
0N/A SEP=";"
0N/A ;;
0N/A
0N/A * )
0N/A SEP=":"
0N/A ;;
0N/Aesac
0N/A
0N/AJARCP=scanner.jar
0N/A
0N/A# Construct path to apt executable
0N/AAPT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile "
0N/A
0N/Aprintf "%s\n" "APT = ${APT}"
0N/A
0N/A# Construct path to javac executable
0N/AJAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
0N/AJAR="${TESTJAVA}/bin/jar "
0N/A
0N/A${JAVAC} ${TESTSRC}/Scanner.java ${TESTSRC}/VisitOrder.java ${TESTSRC}/Counter.java ${TESTSRC}/MemberOrderApf.java
0N/ARESULT=$?
0N/A
0N/Acase "${RESULT}" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A echo "Compilation failed."
0N/A exit 1
esac
echo "Making services directory and copying services information."
mkdir -p META-INF/services
cp ${TESTSRC}/servicesScanner META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
${JAR} cf0 scanner.jar Scanner*.class META-INF
# Jar files created; verify options properly present on both initial
# and recursive apt runs
#---------------------------------------------------------
unset CLASSPATH
printf "%s\n" "-classpath ${JARCP}" > options
printf "%s\n" "-sourcepath ${TESTSRC}" >> options
printf "%s\n" "${TESTSRC}/Order.java" >> options
${APT} @options
RESULT=$?
case "${RESULT}" in
0 )
;;
* )
echo "Program elements visited in wrong order"
exit 1
;;
esac
#---------------------------------------------------------
# Verify that plain decl' scanner and source order decl' scanner
# record the same number of elements for an enum
printf "%s\n" "-factorypath ." > options2
printf "%s\n" "-factory Counter" >> options2
printf "%s\n" "-sourcepath ${TESTSRC}" >> options2
printf "%s\n" "${TESTSRC}/TestEnum.java" >> options2
$APT @options2
RESULT=$?
case "${RESULT}" in
0 )
;;
* )
echo "Improper counts"
exit 1
;;
esac
#---------------------------------------------------------
# Verify that members happen to be returned in source order
printf "%s\n" "-factorypath ." > options3
printf "%s\n" "-factory MemberOrderApf" >> options3
printf "%s\n" "-sourcepath ${TESTSRC}" >> options3
printf "%s\n" "${TESTSRC}/Order.java" >> options3
$APT @options3
RESULT=$?
case "${RESULT}" in
0 )
;;
* )
echo "Improper counts"
exit 1
;;
esac
exit 0;