0N/A#!/bin/sh
0N/A
0N/A#
553N/A# Copyright (c) 2004, 2009, 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,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
553N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A# or visit www.oracle.com if you need additional information or have any
553N/A# questions.
0N/A#
0N/A
0N/A# @test
0N/A# @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059
0N/A# @run shell ../verifyVariables.sh
0N/A# @build Milk MethodAnnotations NestedClassAnnotations StaticFieldAnnotations StaticMethodAnnotations ParameterAnnotations
0N/A# @run shell apt.sh
0N/A# @summary test consistency of annotation discovery
0N/A# @author Joseph D. Darcy
0N/A
0N/AOS=`uname -s`;
0N/Acase "${OS}" in
386N/A CYGWIN* )
386N/A DIFFOPTS="--strip-trailing-cr"
0N/A ;;
0N/A
0N/A * )
0N/A ;;
0N/Aesac
0N/A
0N/A# Construct path to apt executable
330N/AAPT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message "
0N/A
0N/Aprintf "%s\n" "-classpath ${TESTCLASSES}" > options
0N/Aprintf "%s\n" "-factorypath ./nullap.jar" >> options
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC} " >> options
0N/Aprintf "%s\n" "-nocompile" >> options
0N/Aprintf "%s\n" "-XListAnnotationTypes" >> options
0N/A
0N/Aprintf "%s\n" "-classpath ${TESTCLASSES}" > options1
0N/Aprintf "%s\n" "-factorypath ./nullap.jar" >> options1
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC} " >> options1
0N/Aprintf "%s\n" "-nocompile" >> options1
0N/Aprintf "%s\n" "-XListAnnotationTypes" >> options1
0N/Aprintf "%s\n" "-XclassesAsDecls" >> options1
0N/A
330N/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}/NullAPF.java \
0N/A${TESTSRC}/FreshnessApf.java \
0N/A${TESTSRC}/TestGetTypeDeclarationApf.java \
0N/A${TESTSRC}/TestGetPackageApf.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
0N/Aesac
0N/A
0N/Aecho "Making services directory and copying services information."
0N/Amkdir -p META-INF/services
0N/Acp ${TESTSRC}/com.sun.mirror.apt.AnnotationProcessorFactory ./META-INF/services
0N/A$JAR cvf0 nullap.jar NullAPF*.class META-INF
0N/A
0N/AANNOTATION_FILES="${TESTSRC}/ClassAnnotations.java \
0N/A${TESTSRC}/MethodAnnotations.java \
0N/A${TESTSRC}/NestedClassAnnotations.java \
0N/A${TESTSRC}/StaticFieldAnnotations.java \
0N/A${TESTSRC}/StaticMethodAnnotations.java \
0N/A${TESTSRC}/ParameterAnnotations.java"
0N/A
0N/Afor i in ${ANNOTATION_FILES}
0N/Ado
0N/A printf "%s\n" "Testing annotations on source file ${i}"
0N/A ${APT} @options ${i} 2> result.txt
386N/A diff ${DIFFOPTS} ${TESTSRC}/golden.txt result.txt
0N/A
0N/A RESULT=$?
0N/A case "$RESULT" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A echo "Unexpected set of annotations on source files found."
0N/A exit 1
0N/A esac
0N/A
0N/A CLASS=`basename ${i} .java`
0N/A printf "%s\n" "Testing annotations on class file ${CLASS}"
0N/A ${APT} @options1 ${CLASS} 2> result2.txt
386N/A diff ${DIFFOPTS} ${TESTSRC}/golden.txt result2.txt
0N/A
0N/A RESULT=$?
0N/A case "$RESULT" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A echo "Unexpected set of annotations on class files found."
0N/A exit 1
0N/A esac
0N/Adone
0N/A
0N/A# Verify source files are favored over class files
0N/A
0N/Aprintf "%s\n" "-factorypath ." > options2
0N/Aprintf "%s\n" "-factory FreshnessApf" >> options2
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC}" >> options2
0N/Aprintf "%s\n" "-classpath ${TESTCLASSES}" >> options2
0N/Aprintf "%s\n" "-nocompile" >> options2
0N/A
0N/A${APT} @options2 ${TESTSRC}/Indirect.java
0N/A
0N/ARESULT=$?
0N/Acase "$RESULT" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A exit 1
0N/Aesac
0N/A
0N/A# Verify new classes can be loaded by getTypeDeclaration
0N/A
0N/Aprintf "%s\n" "-factorypath ." > options3
0N/Aprintf "%s\n" "-factory TestGetTypeDeclarationApf" >> options3
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC}" >> options3
0N/A
0N/A# ${APT} @options3
0N/A
0N/ARESULT=$?
0N/Acase "$RESULT" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A exit 1
0N/Aesac
0N/A
0N/A# Verify packages can be loaded by getPackage
0N/A
0N/Aprintf "%s\n" "-factorypath ." > options4
0N/Aprintf "%s\n" "-factory TestGetPackageApf" >> options4
0N/Aprintf "%s\n" "-sourcepath ${TESTSRC}" >> options4
0N/A
0N/A${APT} @options4
0N/A
0N/ARESULT=$?
0N/Acase "$RESULT" in
0N/A 0 )
0N/A ;;
0N/A
0N/A * )
0N/A exit 1
0N/Aesac
0N/Aexit 0