提交 00599318 编写于 作者: V vromero

8006212: javac, convert jtreg tests from shell script to java

Reviewed-by: jjg
上级 f1f0e9ed
/*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -121,19 +121,23 @@ public class JavacTaskImpl extends BasicJavacTask {
return result.toList();
}
public Boolean call() {
public Main.Result doCall() {
if (!used.getAndSet(true)) {
initContext();
notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
compilerMain.setAPIMode(true);
result = compilerMain.compile(args, classNames, context, fileObjects, processors);
cleanup();
return result.isOK();
return result;
} else {
throw new IllegalStateException("multiple calls to method 'call'");
}
}
public Boolean call() {
return doCall().isOK();
}
public void setProcessors(Iterable<? extends Processor> processors) {
processors.getClass(); // null check
// not mt-safe
......
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -84,4 +84,18 @@ public class ArrayUtils {
return result;
}
}
public static <T> T[] concat(T[] anArr, T[] anotherArr) {
int newLength = anArr.length + anotherArr.length;
@SuppressWarnings("unchecked")
T[] result = (T[]) Array.newInstance(anArr.getClass().getComponentType(), newLength);
System.arraycopy(anArr, 0, result, 0, anArr.length);
System.arraycopy(anotherArr, 0, result, anArr.length, anotherArr.length);
return result;
}
@SuppressWarnings("unchecked")
public static <T> T[] concatOpen(T[] anArr, T... anotherArr) {
return concat(anArr, anotherArr);
}
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
* @summary Make sure apt is removed and doesn't come back
* @library /tools/javac/lib
* @build ToolBox
* @run main CheckAptIsRemovedTest
*/
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
//original test: test/tools/apt/Basics/apt.sh
public class CheckAptIsRemovedTest {
//I think this class can be let with the imports only and that should be enough for as test's purpose
private static final String NullAPFSrc =
"import com.sun.mirror.apt.*;\n" +
"import com.sun.mirror.declaration.*;\n" +
"import com.sun.mirror.type.*;\n" +
"import com.sun.mirror.util.*;\n" +
"import java.util.Collection;\n" +
"import java.util.Set;\n\n" +
"public class NullAPF implements AnnotationProcessorFactory {\n" +
" static class NullAP implements AnnotationProcessor {\n" +
" NullAP(AnnotationProcessorEnvironment ape) {}\n" +
" public void process() {return;}\n" +
" }\n\n" +
" static Collection<String> supportedTypes;\n\n" +
" static {\n" +
" String types[] = {\"*\"};\n" +
" supportedTypes = java.util.Arrays.asList(types);\n" +
" }\n\n" +
" public Collection<String> supportedOptions() {\n" +
" return java.util.Collections.emptySet();\n" +
" }\n\n" +
" public Collection<String> supportedAnnotationTypes() {\n" +
" return supportedTypes;\n" +
" }\n\n" +
" public AnnotationProcessor getProcessorFor(" +
" Set<AnnotationTypeDeclaration> atds,\n" +
" AnnotationProcessorEnvironment env) {\n" +
" return new NullAP(env);\n" +
" }\n" +
"}";
public static void main(String[] args) throws Exception {
String testJDK = System.getProperty("test.jdk");
Path aptLin = Paths.get(testJDK, "bin", "apt");
Path aptWin = Paths.get(testJDK, "bin", "apt.exe");
// if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
if (Files.exists(aptLin) || Files.exists(aptWin)) {
throw new AssertionError("apt executable should not exist");
}
// JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
// $JAVAC ${TESTSRC}/NullAPF.java
Path classpath = Paths.get(testJDK, "lib", "tools.jar");
ToolBox.JavaToolArgs javacArgs =
new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
.setOptions("-source", "1.5", "-sourcepath", ".",
"-classpath", classpath.toString())
.setSources(NullAPFSrc);
ToolBox.javac(javacArgs);
}
}
#!/bin/sh
#
# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
# @run shell ../verifyVariables.sh
# @run shell apt.sh
# @summary Make sure apt is removed and doesn't come back
# @author Joseph D. Darcy
OS=`uname -s`;
case "${OS}" in
CYGWIN* )
DIFFOPTS="--strip-trailing-cr"
;;
* )
;;
esac
# Verify apt executable does not exist
if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
echo "apt executable should not exist."
exit 1
fi
# Construct path to javac executable
JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
$JAVAC ${TESTSRC}/NullAPF.java
RESULT=$?
case "${RESULT}" in
0 )
echo "Compilation of apt-using source passed improperly."
exit 1
;;
* )
;;
esac
#!/bin/sh
#
# Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
exit 0
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4846262
* @summary check that javac operates correctly in EBCDIC locale
* @library /tools/javac/lib
* @build ToolBox
* @run main CheckEBCDICLocaleTest
*/
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import com.sun.tools.javac.util.ArrayUtils;
//original test: test/tools/javac/4846262/Test.sh
public class CheckEBCDICLocaleTest {
private static final String TestSrc =
"public class Test {\n" +
" public void test() {\n" +
" abcdefg\n" +
" }\n" +
"}";
private static final String TestOut =
"output/Test.java:3: error: not a statement\n" +
" abcdefg\n" +
" ^\n" +
"output/Test.java:3: error: ';' expected\n" +
" abcdefg\n" +
" ^\n" +
"2 errors\n";
public static void main(String[] args) throws Exception {
new CheckEBCDICLocaleTest().test();
}
public void test() throws Exception {
String native2asciiBinary = Paths.get(
System.getProperty("test.jdk"),"bin", "native2ascii").toString();
String testVMOpts = System.getProperty("test.tool.vm.opts");
String[] mainArgs = ToolBox.getJavacBin();
ToolBox.createJavaFileFromSource(TestSrc);
Files.createDirectory(Paths.get("output"));
//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java
ToolBox.AnyToolArgs nativeCmdParams =
new ToolBox.AnyToolArgs()
.setAllArgs(native2asciiBinary, testVMOpts,
"-reverse", "-encoding", "IBM1047",
"Test.java", "output/Test.java");
ToolBox.executeCommand(nativeCmdParams);
//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp
ToolBox.AnyToolArgs javacParams =
new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
.setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Duser.language=en",
"-J-Duser.region=US", "-J-Dfile.encoding=IBM1047",
"output/Test.java"))
.setErrOutput(new File("Test.tmp"));
ToolBox.executeCommand(javacParams);
//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out
nativeCmdParams.setAllArgs(native2asciiBinary, "-encoding", "IBM1047",
"Test.tmp", "Test.out");
ToolBox.executeCommand(nativeCmdParams);
//diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
ToolBox.compareLines(Paths.get("Test.out"),
Arrays.asList(TestOut.split("\n")), null);
}
}
/* /nodynamiccopyright/ */
public class Test {
public void test() {
abcdefg
}
}
Test.java:4: error: not a statement
abcdefg
^
Test.java:4: error: ';' expected
abcdefg
^
2 errors
#!/bin/sh -f
#
# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# @test
# @bug 4846262
# @summary check that javac operates correctly in EBCDIC locale
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
FS="/"
;;
CYGWIN* )
FS="/"
DIFFOPTS="--strip-trailing-cr"
;;
Windows* )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
rm -f Test.java Test.out
"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp
"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out
diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result
/*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,11 +23,27 @@
/*
* @test
* @bug 4307565
* @summary Verify that access to inaccessable protected inner class is rejected.
* @author William Maddox (maddox)
*
* @run compile p1/ProtectedInnerClass1.java
* @run compile/fail p2/ProtectedInnerClass3.java
* @bug 6302184 6350124 6357979
* @summary javac hidden options that generate source should use the given
* encoding, if available
* @library /tools/javac/lib
* @build ToolBox
* @run compile -encoding iso-8859-1 -XD-printsource T6302184.java
* @run main HiddenOptionsShouldUseGivenEncodingTest
*/
class Dummy {}
import java.nio.file.Path;
import java.nio.file.Paths;
//original test: test/tools/javac/6302184/T6302184.sh
public class HiddenOptionsShouldUseGivenEncodingTest {
public static void main(String[] args) throws Exception {
//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -cp ${TC} -encoding iso-8859-1 -XD-printsource ${TS}${FS}T6302184.java 2>&1
//diff ${DIFFOPTS} -c ${TC}${FS}T6302184.java ${TS}${FS}T6302184.out
Path path1 = Paths.get(System.getProperty("test.classes"), "T6302184.java");
Path path2 = Paths.get(System.getProperty("test.src"), "T6302184.out");
ToolBox.compareLines(path1, path2, "iso-8859-1");
}
}
#! /bin/sh -f
#
# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# @test
# @bug 6302184 6350124 6357979
# @summary javac hidden options that generate source should use the given encoding, if available
# @run shell T6302184.sh
TS=${TESTSRC-.}
TC=${TESTCLASSES-.}
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
FS="/"
;;
CYGWIN* )
FS="/"
DIFFOPTS="--strip-trailing-cr"
;;
Windows* )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -cp ${TC} -encoding iso-8859-1 -XD-printsource ${TS}${FS}T6302184.java 2>&1
diff ${DIFFOPTS} -c ${TC}${FS}T6302184.java ${TS}${FS}T6302184.out
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4241229 4785453
* @summary Test -classpath option and classpath defaults.
* @library /tools/javac/lib
* @build ToolBox
* @run main ClassPathTest
*/
import java.nio.file.Paths;
import java.util.Map;
import java.util.TreeMap;
import com.sun.tools.javac.util.ArrayUtils;
//original test: test/tools/javac/ClassPathTest/ClassPathTest.sh
public class ClassPathTest {
private static final String ClassPathTest1Src =
"import pkg.*;\n" +
"public class ClassPathTest1 {\n" +
" ClassPathTestAux1 x;\n" +
"}";
private static final String ClassPathTest2Src =
"import pkg.*;\n" +
"public class ClassPathTest2 {\n" +
" ClassPathTestAux2 x;\n" +
"}";
private static final String ClassPathTest3Src =
"import pkg.*;\n" +
"public class ClassPathTest3 {\n" +
" ClassPathTestAux3 x;\n" +
"}";
private static final String fooPkgClassPathTestAux1Src =
"package pkg;\n" +
"public class ClassPathTestAux1 {}";
private static final String barPkgClassPathTestAux2Src =
"package pkg;\n" +
"public class ClassPathTestAux2 {}";
private static final String pkgClassPathTestAux3Src =
"package pkg;\n" +
"public class ClassPathTestAux3 {}";
ProcessBuilder pb = null;
public static void main(String[] args) throws Exception {
new ClassPathTest().test();
}
public void test() throws Exception {
createOutputDirAndSourceFiles();
checkCompileCommands();
}
void createOutputDirAndSourceFiles() throws Exception {
//dirs and files creation
ToolBox.createJavaFileFromSource(ClassPathTest1Src);
ToolBox.createJavaFileFromSource(ClassPathTest2Src);
ToolBox.createJavaFileFromSource(ClassPathTest3Src);
ToolBox.createJavaFileFromSource(Paths.get("foo"),
fooPkgClassPathTestAux1Src);
ToolBox.createJavaFileFromSource(Paths.get("bar"),
barPkgClassPathTestAux2Src);
ToolBox.createJavaFileFromSource(pkgClassPathTestAux3Src);
}
void checkCompileCommands() throws Exception {
String[] mainArgs = ToolBox.getJavacBin();
// Without the -cp . parameter the command will fail seems like when called
// from the command line, the current dir is added to the classpath
// automatically but this is not happening when called using ProcessBuilder
// testJavac success ClassPathTest3.java
String[] commonArgs = ArrayUtils.concatOpen(mainArgs, "-cp", ".");
ToolBox.AnyToolArgs successParams =
new ToolBox.AnyToolArgs()
.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest3.java"));
ToolBox.executeCommand(successParams);
// testJavac failure ClassPathTest1.java
ToolBox.AnyToolArgs failParams =
new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest1.java"));
ToolBox.executeCommand(failParams);
// This is done inside the executeCommand method
// CLASSPATH=bar; export CLASSPATH
Map<String, String> extVars = new TreeMap<>();
extVars.put("CLASSPATH", "bar");
// testJavac success ClassPathTest2.java
successParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest2.java")).set(extVars);
ToolBox.executeCommand(successParams);
// testJavac failure ClassPathTest1.java
failParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest1.java")).set(extVars);
ToolBox.executeCommand(failParams);
// testJavac failure ClassPathTest3.java
failParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest3.java"));
ToolBox.executeCommand(failParams);
// testJavac success -classpath foo ClassPathTest1.java
commonArgs = ArrayUtils.concatOpen(mainArgs, "-cp", "foo");
successParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest1.java"));
ToolBox.executeCommand(successParams);
// testJavac failure -classpath foo ClassPathTest2.java
failParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest2.java"));
ToolBox.executeCommand(failParams);
// testJavac failure -classpath foo ClassPathTest3.java
failParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest3.java"));
ToolBox.executeCommand(failParams);
}
}
#!/bin/sh
#
# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4241229 4785453
# @summary Test -classpath option and classpath defaults.
# @author maddox
#
# @run shell/timeout=180 ClassPathTest.sh
# TODO: Should test sourcepath and classpath separately.
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows* )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
javac="${TESTJAVA}${FS}bin${FS}javac"
cleanup() {
rm -f *.class pkg${FS}*.class foo${FS}pkg${FS}*.class bar${FS}pkg${FS}*.class
cp -rf $TESTSRC${FS}* .
}
fail() {
echo "FAIL: $1"
failed="yes"
}
# report expectedResult $?
report() {
if test "$1" = "success" -a "$2" = 0; then
echo "PASS: succeeded as expected"
elif test "$1" = "failure" -a "$2" != 0; then
echo "PASS: failed as expected"
elif test "$1" = "success" -a "$2" != 0; then
fail "test failed unexpectedly"
elif test "$1" = "failure" -a "$2" = 0; then
fail "test succeeded unexpectedly"
else
fail "internal error"
fi
}
# testJavac expectedResult javacArgs...
testJavac() {
expectedResult="$1"; shift
cleanup
echo $javac ${TESTTOOLVMOPTS} "$@"
"$javac" ${TESTTOOLVMOPTS} "$@"
report $expectedResult $?
}
unset CLASSPATH
# classpath should default to current directory
testJavac success ClassPathTest3.java
testJavac failure ClassPathTest1.java
# if CLASSPATH is set, it should be honored
CLASSPATH=bar; export CLASSPATH
testJavac success ClassPathTest2.java
testJavac failure ClassPathTest1.java
testJavac failure ClassPathTest3.java
# -classpath option should override default
testJavac success -classpath foo ClassPathTest1.java
testJavac failure -classpath foo ClassPathTest2.java
testJavac failure -classpath foo ClassPathTest3.java
if test -n "$failed"; then
echo "Some tests failed"
exit 1
else
echo PASS: all tests gave expected results
exit 0
fi
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import pkg.*;
public class ClassPathTest1 {
ClassPathTestAux1 x;
}
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import pkg.*;
public class ClassPathTest2 {
ClassPathTestAux2 x;
}
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import pkg.*;
public class ClassPathTest3 {
ClassPathTestAux3 x;
}
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg;
public class ClassPathTestAux2 {}
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg;
public class ClassPathTestAux1 {}
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package pkg;
public class ClassPathTestAux3 {}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4204897 4256097 4785453 4863609
* @summary Test that '.jar' files in -extdirs are found.
* @library /tools/javac/lib
* @build ToolBox
* @run main ExtDirTest
*/
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
//original test: test/tools/javac/ExtDirs/ExtDirs.sh
public class ExtDirTest {
private static final String ExtDirTestClass1Src =
"package pkg1;\n" +
"\n" +
"public class ExtDirTestClass1 {}";
private static final String ExtDirTestClass2Src =
"package pkg2;\n" +
"\n" +
"public class ExtDirTestClass2 {}";
private static final String ExtDirTest_1Src =
"import pkg1.*;\n" +
"\n" +
"public class ExtDirTest_1 {\n" +
" ExtDirTestClass1 x;\n" +
"}";
private static final String ExtDirTest_2Src =
"import pkg1.*;\n" +
"import pkg2.*;\n" +
"\n" +
"public class ExtDirTest_2 {\n" +
" ExtDirTestClass1 x;\n" +
" ExtDirTestClass2 y;\n" +
"}";
private static final String ExtDirTest_3Src =
"import pkg1.*;\n" +
"import pkg2.*;\n" +
"\n" +
"public class ExtDirTest_3 {\n" +
" ExtDirTestClass1 x;\n" +
" ExtDirTestClass2 y;\n" +
"}";
private static final String jar1Manifest =
"Manifest-Version: 1.0\n" +
"\n" +
"Name: pkg1/ExtDirTestClass1.class\n" +
"Digest-Algorithms: SHA MD5 \n" +
"SHA-Digest: 9HEcO9LJmND3cvOlq/AbUsbD9S0=\n" +
"MD5-Digest: hffPBwfqcUcnEdNv4PXu1Q==\n" +
"\n" +
"Name: pkg1/ExtDirTestClass1.java\n" +
"Digest-Algorithms: SHA MD5 \n" +
"SHA-Digest: 2FQVe6w3n2Ma1ACYpe8a988EBU8=\n" +
"MD5-Digest: /Ivr4zVI9MSM26NmqWtZpQ==\n";
private static final String jar2Manifest =
"Manifest-Version: 1.0\n" +
"\n" +
"Name: pkg2/ExtDirTestClass2.class\n" +
"Digest-Algorithms: SHA MD5 \n" +
"SHA-Digest: elbPaqWf8hjj1+ZkkdW3PGTsilo=\n" +
"MD5-Digest: 57Nn0e2t1yEQfu/4kSw8yg==\n" +
"\n" +
"Name: pkg2/ExtDirTestClass2.java\n" +
"Digest-Algorithms: SHA MD5 \n" +
"SHA-Digest: ILJOhwHg5US+yuw1Sc1d+Avu628=\n" +
"MD5-Digest: j8wnz8wneEcuJ/gjXBBQNA==\n";
List<String> ouputDirParam = Arrays.asList("-d", ".");
public static void main(String args[]) throws Exception {
new ExtDirTest().run();
}
void run() throws Exception {
createJars();
compileWithExtDirs();
}
void createJars() throws Exception {
// for i in 1 2 3; do
// if test ! -d ext${i}; then mkdir ext${i}; fi
// cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
// done
sun.tools.jar.Main jarGenerator =
new sun.tools.jar.Main(System.out, System.err, "jar");
ToolBox.JavaToolArgs javacParams =
new ToolBox.JavaToolArgs()
.setOptions(ouputDirParam)
.setSources(ExtDirTestClass1Src);
ToolBox.javac(javacParams);
ToolBox.writeFile(Paths.get("pkg1", "MANIFEST.MF"), jar1Manifest);
jarGenerator.run(new String[] {"cfm", "pkg1.jar", "pkg1/MANIFEST.MF",
"pkg1/ExtDirTestClass1.class"});
javacParams.setSources(ExtDirTestClass2Src);
ToolBox.javac(javacParams);
ToolBox.writeFile(Paths.get("pkg2", "MANIFEST.MF"), jar2Manifest);
jarGenerator.run(new String[] {"cfm", "pkg2.jar", "pkg2/MANIFEST.MF",
"pkg2/ExtDirTestClass2.class"});
ToolBox.copyFile(Paths.get("ext1", "pkg1.jar"), Paths.get("pkg1.jar"));
ToolBox.copyFile(Paths.get("ext2", "pkg2.jar"), Paths.get("pkg2.jar"));
ToolBox.copyFile(Paths.get("ext3", "pkg1.jar"), Paths.get("pkg1.jar"));
ToolBox.copyFile(Paths.get("ext3", "pkg2.jar"), Paths.get("pkg2.jar"));
Files.delete(Paths.get("pkg1.jar"));
Files.delete(Paths.get("pkg2.jar"));
Files.delete(Paths.get("pkg1", "ExtDirTestClass1.class"));
Files.delete(Paths.get("pkg1", "MANIFEST.MF"));
Files.delete(Paths.get("pkg1"));
Files.delete(Paths.get("pkg2", "ExtDirTestClass2.class"));
Files.delete(Paths.get("pkg2", "MANIFEST.MF"));
Files.delete(Paths.get("pkg2"));
}
void compileWithExtDirs() throws Exception {
//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
ToolBox.JavaToolArgs params =
new ToolBox.JavaToolArgs()
.setOptions("-d", ".", "-extdirs", "ext1")
.setSources(ExtDirTest_1Src);
ToolBox.javac(params);
//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
params.setOptions("-d", ".", "-extdirs", "ext1" + File.pathSeparator + "ext2")
.setSources(ExtDirTest_2Src);
ToolBox.javac(params);
//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
params.setOptions("-d", ".", "-extdirs", "ext3")
.setSources(ExtDirTest_3Src);
ToolBox.javac(params);
}
}
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import pkg1.*;
public class ExtDirTest_1 {
ExtDirTestClass1 x;
}
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import pkg1.*;
import pkg2.*;
public class ExtDirTest_2 {
ExtDirTestClass1 x;
ExtDirTestClass2 y;
}
/*
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import pkg1.*;
import pkg2.*;
public class ExtDirTest_3 {
ExtDirTestClass1 x;
ExtDirTestClass2 y;
}
#!/bin/sh
#
# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4204897 4256097 4785453 4863609
# @summary Test that '.jar' files in -extdirs are found.
# @author maddox
#
# @run shell/timeout=180 ExtDirs.sh
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
PS=":"
FS="/"
;;
CYGWIN* )
PS=";" # native PS, not Cygwin PS
FS="/"
;;
Windows* )
PS=";"
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
fail() {
echo 'FAIL: unexpected result encountered'
exit 1
}
javac="${TESTJAVA}${FS}bin${FS}javac"
for i in 1 2 3; do
if test ! -d ext${i}; then mkdir ext${i}; fi
cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
done
echo "Test 1"
"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
if [ $? -ne 0 ] ; then fail ; fi
echo "Test 2"
"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
if [ $? -ne 0 ] ; then fail ; fi
echo "Test 3"
"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
if [ $? -ne 0 ] ; then fail ; fi
echo PASS: all tests gave expected results
exit 0
#!/bin/sh
#
# Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows* )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
TMP1=OUTPUT.txt
cp "${TESTSRC}${FS}MissingInclude.java" .
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} @/nonexistent_file MissingInclude.java 2> ${TMP1}
result=$?
cat ${TMP1}
rm ${TMP1}
if [ $result -eq 0 ]
then
echo "Failed"
exit 1
else
echo "Passed"
exit 0
fi
/*
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -24,10 +24,27 @@
/*
* @test
* @bug 4509051 4785453
* @summary javac <AT>sourcefiles should catch Exception, when sourcefiles doesn't exist.
* @author gafter
*
* @run shell MissingInclude.sh
* @summary javac <AT>sourcefiles should catch Exception, when sourcefiles
* doesn't exist.
* @library /tools/javac/lib
* @build ToolBox
* @run main MissingIncludeTest
*/
class MissingInclude {}
//original test: test/tools/javac/MissingInclude.sh
public class MissingIncludeTest {
private static final String MissingIncludeSrc =
"class MissingInclude {}";
public static void main(String[] args) throws Exception {
ToolBox.createJavaFileFromSource(MissingIncludeSrc);
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} @/nonexistent_file MissingInclude.java 2> ${TMP1}
ToolBox.JavaToolArgs params =
new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
.setAllArgs("@/nonexistent_file", "MissingInclude.java");
ToolBox.javac(params);
}
}
#
# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4087314 4800342
# @summary Verify allowed access to protected class from another package.
# @author William Maddox (maddox)
#
# @run shell ProtectedInnerClass.sh
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
PS=":"
FS="/"
;;
CYGWIN* )
PS=";" # native PS, not Cygwin PS
FS="/"
;;
Windows* )
PS=";"
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
rm -f ${TESTCLASSES}${FS}p1${FS}*.class ${TESTCLASSES}${FS}p2${FS}*.class
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" "${TESTSRC}${FS}p1${FS}ProtectedInnerClass1.java" "${TESTSRC}${FS}p2${FS}ProtectedInnerClass2.java"
"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4087314 4800342 4307565
* @summary Verify allowed access to protected class from another package
* @library /tools/javac/lib
* @build ToolBox
* @run main ProtectedInnerClassesTest
*/
//original tests: test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh
//and test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
public class ProtectedInnerClassesTest {
private static final String protectedInnerClass1Src =
"package p1;\n" +
"\n" +
"public class ProtectedInnerClass1 {\n" +
" protected class Foo {\n" +
" public String getBar() { return \"bar\"; }\n" +
" }\n" +
"}";
private static final String protectedInnerClass2Src =
"package p2;\n" +
"\n" +
"public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1\n" +
"{\n" +
" class Bug extends Foo {\n" +
" String getBug() { return getBar(); }\n" +
" }\n" +
"\n" +
" public static void main(String[] args) {\n" +
" ProtectedInnerClass2 x = new ProtectedInnerClass2();\n" +
" Bug y = x.new Bug();\n" +
" System.out.println(y.getBug());\n" +
" }\n" +
"}";
private static final String protectedInnerClass3Src =
"package p2;\n" +
"\n" +
"public class ProtectedInnerClass3 {\n" +
"\n" +
" void test() {\n" +
" p1.ProtectedInnerClass1.Foo x;\n" +
" }\n" +
"\n" +
"}";
public static void main(String args[]) throws Exception {
new ProtectedInnerClassesTest().run();
}
void run() throws Exception {
compileAndExecute();
compileOnly();
}
void compileAndExecute() throws Exception {
//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" "${TESTSRC}${FS}p1${FS}ProtectedInnerClass1.java" "${TESTSRC}${FS}p2${FS}ProtectedInnerClass2.java"
ToolBox.JavaToolArgs javacParams =
new ToolBox.JavaToolArgs()
.setOptions("-d", ".")
.setSources(protectedInnerClass1Src, protectedInnerClass2Src);
ToolBox.javac(javacParams);
//"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2
ToolBox.AnyToolArgs javaParams =
new ToolBox.AnyToolArgs()
.setAllArgs(ToolBox.javaBinary, "-classpath", System.getProperty("user.dir"),
"p2.ProtectedInnerClass2");
ToolBox.executeCommand(javaParams);
}
//from test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
void compileOnly() throws Exception {
//@run compile p1/ProtectedInnerClass1.java
ToolBox.JavaToolArgs javacParams =
new ToolBox.JavaToolArgs()
.setOptions("-d", ".")
.setSources(protectedInnerClass1Src);
ToolBox.javac(javacParams);
//@run compile/fail p2/ProtectedInnerClass3.java
javacParams.setSources(protectedInnerClass3Src)
.set(ToolBox.Expect.FAIL);
ToolBox.javac(javacParams);
}
}
/*
* Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Auxiliary file for test for 4087314.
* Verify allowed access to protected class from another package.
* This file must be compiled prior to compiling p2.ProtectedInnerClass2.
* It is that compilation that will either succeed or fail.
*/
package p1;
public class ProtectedInnerClass1 {
protected class Foo {
public String getBar() { return "bar"; }
}
}
/*
* Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Auxiliary file for test for 4087314.
* Verify allowed access to protected class from another package.
*
* This file should compile and run successfully.
* Note that class p1.ProtectedInnerClass1 must be compiled first.
*/
package p2;
public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1
{
class Bug extends Foo {
String getBug() { return getBar(); }
}
public static void main(String[] args) {
ProtectedInnerClass2 x = new ProtectedInnerClass2();
Bug y = x.new Bug();
System.out.println(y.getBug());
}
}
/*
* Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Auxiliary file for ProtectedInnerClass_2.java (bugid 4307565)
*/
package p2;
public class ProtectedInnerClass3 {
void test() {
p1.ProtectedInnerClass1.Foo x;
}
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 5090006
* @summary javac fails with assertion error
* @library /tools/javac/lib
* @build ToolBox
* @run main AssertionFailureTest
*/
import java.io.File;
import java.nio.file.Paths;
//original test: test/tools/javac/T5090006/compiler.sh
public class AssertionFailureTest {
private static final String testSrc =
"import stub_tie_gen.wsdl_hello_lit.client.*;\n" +
"import junit.framework.*;\n" +
"import testutil.ClientServerTestUtil;\n" +
"\n" +
"public class Test {\n" +
"\n" +
" void getStub() throws Exception {\n" +
" Hello_PortType_Stub x = null;\n" +
" new ClientServerTestUtil().setTransport(x, null, null, null);\n" +
" }\n" +
"\n" +
" public static void main(String[] args) {\n" +
" System.out.println(\"FISK\");\n" +
" }\n" +
"}";
public static void main(String args[]) throws Exception {
String classpath = Paths.get(System.getProperty("test.src"), "broken.jar")
.toString();
classpath = new StringBuilder(classpath)
.append(File.pathSeparator).append(".").toString();
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -verbose -d "${TESTCLASSES}" -cp "${TESTSRC}${FS}broken.jar" "${TESTSRC}${FS}$1"
ToolBox.JavaToolArgs params =
new ToolBox.JavaToolArgs()
.setOptions("-cp", classpath)
.setSources(testSrc);
ToolBox.javac(params);
}
}
#!/bin/sh
#
# Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows* )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -verbose -d "${TESTCLASSES}" -cp "${TESTSRC}${FS}broken.jar" "${TESTSRC}${FS}$1"
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result
#!/bin/sh
#
# Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
PS=":"
FS="/"
;;
CYGWIN* )
PS=";" # Platform PS, not Cygwin PS
FS="/"
;;
Windows* )
PS=";"
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
TMP1=OUTPUT.txt
cp "${TESTSRC}${FS}$1.java" .
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
result=$?
if [ $result -ne 0 ]; then exit $result; fi
if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then
echo "Failed"
exit 1;
else
echo "Passed"
exit 0;
fi
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -25,11 +25,27 @@
* @test
* @bug 4645152 4785453
* @summary javac compiler incorrectly inserts <clinit> when -g is specified
* @author gafter
*
* @run shell ConstDebug.sh ConstDebug
* @library /tools/javac/lib
* @build ToolBox
* @run compile -g ConstDebugTest.java
* @run main ConstDebugTest
*/
public class ConstDebug {
//original test: test/tools/javac/constDebug/ConstDebug.sh
public class ConstDebugTest {
public static final long l = 12;
public static void main(String args[]) throws Exception {
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
// if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then fail
ToolBox.JavaToolArgs javapArgs =
new ToolBox.JavaToolArgs().setAllArgs("-v",
"-classpath", System.getProperty("test.classes"), "ConstDebugTest.class");
if (ToolBox.javap(javapArgs).contains("clinit")) {
throw new AssertionError(
"javac should not create a <clinit> method for ConstDebugTest class");
}
}
}
Fatal Error: Unable to find package java.lang in classpath or bootclasspath
#!/bin/sh
#
# Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
printf '%s' "TESTSRC=${TESTSRC}" ; echo
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
printf '%s' "TESTJAVA=${TESTJAVA}" ; echo
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
printf '%s' "TESTCLASSES=${TESTCLASSES}" ; echo
printf '%s' "CLASSPATH=${CLASSPATH}" ; echo
echo
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
FS="/"
;;
CYGWIN* )
FS="/"
DIFFOPTS="--strip-trailing-cr"
;;
Windows* )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
TMP1=OUTPUT.txt
cp "${TESTSRC}${FS}NoJavaLang.java" .
echo "- verifing that fatal error is not produced in the regular case"
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NoJavaLang.java 2> "${TMP1}"
result=$?
if [ $result -eq 0 ]
then
echo "Passed - base compilation successful"
else
echo "Failed - unable to compile test"
exit $result
fi
echo
echo "- verifing the fatal error is produced"
rm "${TMP1}"
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -bootclasspath . NoJavaLang.java 2> "${TMP1}"
# return code should be EXIT_SYSERR
result=$?
if [ $result -ne 3 ]
then
echo "Failed - unexpected return code"
exit $result
else
echo "Passed - expected return code"
fi
# expected message
cat "${TMP1}"
diff ${DIFFOPTS} -c "${TESTSRC}${FS}NoJavaLang.out" "${TMP1}"
result=$?
rm "${TMP1}"
if [ $result -eq 0 ]
then
echo "Passed - expected message"
else
echo "Failed - unexpected message"
exit $result
fi
exit
/*
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -21,20 +21,56 @@
* questions.
*/
/**
/*
* @test
* @bug 4263768 4785453
* @summary Verify that the compiler does not crash when java.lang is not
* found.
* @author iag
*
* @run shell NoJavaLang.sh
* @library /tools/javac/lib
* @build ToolBox
* @run main NoJavaLangTest
*/
public class NoJavaLang {
private String s;
import java.util.ArrayList;
import java.util.List;
//original test: test/tools/javac/fatalErrors/NoJavaLang.sh
public class NoJavaLangTest {
private static final String noJavaLangSrc =
"public class NoJavaLang {\n" +
" private String s;\n" +
"\n" +
" public String s() {\n" +
" return s;\n" +
" }\n" +
"}";
private static final String compilerErrorMessage =
"Fatal Error: Unable to find package java.lang in classpath or bootclasspath";
public String s() {
return s;
public static void main(String[] args) throws Exception {
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NoJavaLang.java 2> "${TMP1}"
ToolBox.JavaToolArgs javacSuccessArgs =
new ToolBox.JavaToolArgs().setSources(noJavaLangSrc);
ToolBox.javac(javacSuccessArgs);
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -bootclasspath . NoJavaLang.java 2> "${TMP1}"
List<String> output = new ArrayList<>();
ToolBox.JavaToolArgs javacFailArgs =
new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
.setOptions("-bootclasspath", ".")
.setSources(noJavaLangSrc)
.setErrOutput(output);
int cr = ToolBox.javac(javacFailArgs);
if (cr != 3) {
throw new AssertionError("Compiler exit result should be 3");
}
// diff ${DIFFOPTS} -c "${TESTSRC}${FS}NoJavaLang.out" "${TMP1}"
if (!(output.size() == 1 && output.get(0).equals(compilerErrorMessage))) {
throw new AssertionError("javac generated error output is not correct");
}
}
}
#!/bin/sh
#
# Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4491755 4785453
# @summary Prob w/static inner class with same name as a regular class
# @author gafter
#
# @run shell Driver.sh
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows* )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
set -x
mkdir src
cp -r ${TESTSRC}${FS}* src
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath . -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
rm y/R3.class
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath . -sourcepath src src/y/Main.java
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4491755 4785453
* @summary Prob w/static inner class with same name as a regular class
* @library /tools/javac/lib
* @build ToolBox
* @run main InnerClassFileTest
*/
import java.nio.file.Paths;
//original test: test/tools/javac/innerClassFile/Driver.sh
public class InnerClassFileTest {
private static final String BSrc =
"package x;\n" +
"\n" +
"import x.*;\n" +
"\n" +
"public class B {\n" +
" public static class C {}\n" +
"}";
private static final String CSrc =
"package x;\n" +
"\n" +
"import x.*;\n" +
"\n" +
"public class C {}";
private static final String MainSrc =
"package y;\n" +
"\n" +
"class Main {\n" +
" private R1 a;\n" +
" private R2 b;\n" +
" private R3 c;\n" +
"}";
private static final String R1Src =
"package y;\n" +
"\n" +
"public final class R1 {\n" +
" x.B.C a = null;\n" +
" x.C b = null;\n" +
" R2 c = new R2();\n" +
"}";
private static final String R2Src =
"package y;\n" +
"\n" +
"public final class R2 {\n" +
" x.B.C a = null;\n" +
" x.C b = null;\n" +
"}";
private static final String R3Src =
"package y;\n" +
"\n" +
"public final class R3 {\n" +
" x.B.C a = null;\n" +
" x.C b = null;\n" +
" R1 c = new R1();\n" +
"}";
public static void main(String args[]) throws Exception {
new InnerClassFileTest().run();
}
void run() throws Exception {
createFiles();
compileFiles();
}
void createFiles() throws Exception {
// mkdir src
// cp -r ${TESTSRC}${FS}* src
ToolBox.createJavaFileFromSource(Paths.get("src"), BSrc);
ToolBox.createJavaFileFromSource(Paths.get("src"), CSrc);
ToolBox.createJavaFileFromSource(Paths.get("src"), MainSrc);
ToolBox.createJavaFileFromSource(Paths.get("src"), R1Src);
ToolBox.createJavaFileFromSource(Paths.get("src"), R2Src);
ToolBox.createJavaFileFromSource(Paths.get("src"), R3Src);
}
void compileFiles() throws Exception {
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
// -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
ToolBox.JavaToolArgs args =
new ToolBox.JavaToolArgs()
.setAllArgs("-d", ".", "-cp" , ".", "-sourcepath", "src",
"src/x/B.java", "src/x/C.java", "src/y/Main.java");
ToolBox.javac(args);
// rm y/R3.class
ToolBox.rm(Paths.get("y", "R3.class"));
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
// -sourcepath src src/y/Main.java
args.setAllArgs("-d", ".", "-cp", ".", "-sourcepath", "src", "src/y/Main.java");
ToolBox.javac(args);
}
}
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package x;
import x.*;
public class B {
public static class C {}
}
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package x;
import x.*;
public class C {}
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package y;
class Main {
private R1 a;
private R2 b;
private R3 c;
}
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package y;
public final class R1 {
x.B.C a = null;
x.C b = null;
R2 c = new R2();
}
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package y;
public final class R2 {
x.B.C a = null;
x.C b = null;
}
/*
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package y;
public final class R3 {
x.B.C a = null;
x.C b = null;
R1 c = new R1();
}
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// A class that references another
class A {
B b;
}
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4098712 6304984 6388453
* @summary check that source files inside zip files on the class path are ignored
* @library /tools/javac/lib
* @build ToolBox
* @run main JavaZipTest
*/
import java.io.File;
import java.nio.file.Paths;
//original test: test/tools/javac/javazip/Test.sh
public class JavaZipTest {
private static final String ASrc =
"class A {\n" +
" B b;\n" +
"}";
private static final String BGoodSrc =
"public class B {}";
private static final String BBadSrc =
"class B";
private static final String[][] jarArgs = {
{"cf", "good.jar", "-C", "good", "B.java"},
{"cf", "good.zip", "-C", "good", "B.java"},
{"cf", "bad.jar", "-C", "bad", "B.java"},
{"cf", "bad.zip", "-C", "bad", "B.java"},
};
private static final String[][] successfulCompilationArgs = {
{"-d", "output", "A.java", "good/B.java"},
{"-d", "output", "-cp", "good", "A.java"},
{"-d", "output", "-sourcepath", "good", "A.java"},
{"-d", "output", "-cp", "good.zip", "A.java"},
{"-d", "output", "-cp", "good.jar", "A.java"},
};
private static final String[][] unSuccessfulCompilationArgs = {
{"-d", "output", "A.java", "bad/B.java"},
{"-d", "output", "-cp", "bad", "A.java"},
{"-d", "output", "-sourcepath", "bad", "A.java"},
{"-d", "output", "-sourcepath", "bad.zip", "A.java"},
{"-d", "output", "-sourcepath", "bad.jar", "A.java"},
};
public static void main(String[] args) throws Exception {
new JavaZipTest().test();
}
public void test() throws Exception {
createOutputDirAndSourceFiles();
createZipsAndJars();
check(ToolBox.Expect.SUCCESS, successfulCompilationArgs);
check(ToolBox.Expect.FAIL, unSuccessfulCompilationArgs);
}
void createOutputDirAndSourceFiles() throws Exception {
//create output dir
new File("output").mkdir();
//source file creation
ToolBox.createJavaFileFromSource(Paths.get("good"), BGoodSrc);
ToolBox.createJavaFileFromSource(Paths.get("bad"), BBadSrc);
ToolBox.createJavaFileFromSource(ASrc);
}
void createZipsAndJars() throws Exception {
//jar and zip creation
// check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
// check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
// check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar" -C "${TESTSRC}${FS}bad" B.java
// check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip" -C "${TESTSRC}${FS}bad" B.java
for (String[] args: jarArgs) {
ToolBox.jar(args);
}
}
void check(ToolBox.Expect whatToExpect, String[][] theArgs) throws Exception {
// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good" "${TESTSRC}${FS}A.java"
// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good" "${TESTSRC}${FS}A.java"
// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip" "${TESTSRC}${FS}A.java"
// check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar" "${TESTSRC}${FS}A.java"
// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad" "${TESTSRC}${FS}A.java"
// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad" "${TESTSRC}${FS}A.java"
// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip" "${TESTSRC}${FS}A.java"
// check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar" "${TESTSRC}${FS}A.java"
ToolBox.JavaToolArgs args =
new ToolBox.JavaToolArgs(whatToExpect);
for (String[] allArgs: theArgs) {
args.setAllArgs(allArgs);
ToolBox.javac(args);
}
}
}
#! /bin/sh -f
#
# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4098712 6304984 6388453
# @summary check that source files inside zip files on the class path are ignored
# @run shell Test.sh
TS=${TESTSRC-.}
TC=${TESTCLASSES-.}
SCR=`pwd`
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
FS="/"
SCR=`pwd`
;;
CYGWIN* )
FS="/"
SCR=`pwd | cygpath -d -f -`
;;
Windows* )
FS="\\"
SCR=`pwd`
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
check() {
expected=$1
shift
# clean old classes
rm -f ${TC}${FS}*.class
echo "$@"
if "$@" 2>&1 ; then
actual=ok
else
actual=err
fi
if [ "$actual" != "$expected" ]; then
case "$actual" in
ok ) echo "error: unexpected result: command succeeded" ;;
err ) echo "error: unexpected result: command failed"
esac
exit 1
else
case "$actual" in
ok ) echo "command succeeded as expected" ;;
err ) echo "command failed as expected."
esac
fi
echo
}
echo "# create zip/jar files with source code"
check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar" -C "${TESTSRC}${FS}bad" B.java
check ok "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip" -C "${TESTSRC}${FS}bad" B.java
echo "# control tests, with no paths"
check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
echo "# test that source files are found in directories on path"
check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good" "${TESTSRC}${FS}A.java"
check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good" "${TESTSRC}${FS}A.java"
check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad" "${TESTSRC}${FS}A.java"
check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad" "${TESTSRC}${FS}A.java"
echo "# test that source files are found in zip/jar files on path"
check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip" "${TESTSRC}${FS}A.java"
check ok "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar" "${TESTSRC}${FS}A.java"
check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip" "${TESTSRC}${FS}A.java"
check err "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar" "${TESTSRC}${FS}A.java"
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// this class is invalid
class B
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// this is a valid class
public class B {
}
此差异已折叠。
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4266026
* @summary javac no longer follows symlinks
* @library /tools/javac/lib
* @build ToolBox
* @run main LinksTest
*/
import java.nio.file.Files;
import java.nio.file.Paths;
//original test: test/tools/javac/links/links.sh
public class LinksTest {
private static final String BSrc =
"package a;\n" +
"\n" +
"public class B {}";
private static final String TSrc =
"class T extends a.B {}";
public static void main(String args[])
throws Exception {
// mkdir tmp
// cp ${TESTSRC}/b/B.java tmp
ToolBox.writeFile(Paths.get("tmp", "B.java"), BSrc);
// ln -s `pwd`/tmp "${TESTCLASSES}/a"
Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp"));
//
////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
ToolBox.JavaToolArgs javacArgs =
new ToolBox.JavaToolArgs()
.setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc);
ToolBox.javac(javacArgs);
}
}
/*
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
class T extends a.B {}
/*
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package a;
public class B {}
#!/bin/sh
#
# Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4266026
# @summary javac no longer follows symlinks
#
# @run shell links.sh
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
NULL=/dev/null
PS=":"
FS="/"
;;
* )
echo "Unrecognized system - test skipped."
exit 0;
;;
esac
mkdir tmp
cp ${TESTSRC}/b/B.java tmp
rm -rf T.class B.class b/B.class "${TESTCLASSES}/a" "${TESTCLASSES}/classes"
ln -s `pwd`/tmp "${TESTCLASSES}/a"
mkdir "${TESTCLASSES}/classes"
"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4110560 4785453
* @summary portability : javac.properties
* @library /tools/javac/lib
* @build ToolBox
* @run main NewLineTest
*/
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.List;
import com.sun.tools.javac.util.ArrayUtils;
//original test: test/tools/javac/newlines/Newlines.sh
public class NewLineTest {
public static void main(String args[]) throws Exception {
String[] mainArgs = ToolBox.getJavacBin();
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1
File javacErrOutput = new File("output.txt");
ToolBox.AnyToolArgs cmdArgs =
new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
.setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Dline.separator='@'"))
.setErrOutput(javacErrOutput);
ToolBox.executeCommand(cmdArgs);
// result=`cat ${TMP1} | wc -l`
// if [ "$result" -eq 0 ] passed
List<String> lines = Files.readAllLines(javacErrOutput.toPath(),
Charset.defaultCharset());
if (lines.size() != 1) {
throw new AssertionError("The compiler output should have one line only");
}
}
}
#
# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 4110560 4785453
# @summary portability : javac.properties
#
# @run shell Newlines.sh
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows* )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
TMP1=OUTPUT.txt
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1
cat ${TMP1}
result=`cat ${TMP1} | wc -l`
if [ "$result" -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result
/*
* Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -21,52 +21,45 @@
* questions.
*/
/*
* @test
* @bug 4955930
* @summary The "method0" StackMap attribute should have two entries instead of three
* @library /tools/javac/lib
* @build ToolBox
* @run compile -source 6 -target 6 StackMapTest.java
* @run main StackMapTest
*/
import com.sun.mirror.apt.*;
import com.sun.mirror.declaration.*;
import com.sun.mirror.type.*;
import com.sun.mirror.util.*;
import java.util.Collection;
import java.util.Set;
import java.nio.file.Path;
import java.nio.file.Paths;
public class NullAPF implements AnnotationProcessorFactory {
static class NullAP implements AnnotationProcessor {
NullAP(AnnotationProcessorEnvironment ape) {
}
//original test: test/tools/javac/stackmap/T4955930.sh
public class StackMapTest {
public void process() {
return;
class Test {
void method0(boolean aboolean) throws Exception {
label_0:
while (true) {
if (aboolean) ;
else break label_0;
}
}
}
static Collection<String> supportedTypes;
public static void main(String args[]) throws Exception {
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -source 6 -target 6 T4955930.java
static {
String types[] = {"*"};
supportedTypes = java.util.Arrays.asList(types);
}
/*
* Processor doesn't examine any options.
*/
public Collection<String> supportedOptions() {
return java.util.Collections.emptySet();
}
// "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -verbose T4955930 > ${TMP1}
Path pathToClass = Paths.get(System.getProperty("test.classes"),
"StackMapTest$Test.class");
ToolBox.JavaToolArgs javapArgs =
new ToolBox.JavaToolArgs().setAllArgs("-v", pathToClass.toString());
/*
* All annotation types are supported.
*/
public Collection<String> supportedAnnotationTypes() {
return supportedTypes;
// grep "StackMapTable: number_of_entries = 2" ${TMP1}
if (!ToolBox.javap(javapArgs).contains("StackMapTable: number_of_entries = 2"))
throw new AssertionError("The number of entries of the stack map "
+ "table should be equal to 2");
}
/*
* Return the same processor independent of what annotations are
* present, if any.
*/
public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
AnnotationProcessorEnvironment env) {
return new NullAP(env);
}
}
#!/bin/sh
#
# Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
FS="/"
;;
Windows_95 | Windows_98 | Windows_NT )
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
TMP1=T4955930.javap
cp "${TESTSRC}${FS}T4955930.java" .
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -source 6 -target 6 T4955930.java
result=$?
if [ $result -ne 0 ]
then
exit $result
fi
"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -verbose T4955930 > ${TMP1}
grep "StackMapTable: number_of_entries = 2" ${TMP1}
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result
/*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -21,12 +21,20 @@
* questions.
*/
/*
* @test
* @bug 4914724 4973116 5014511
* @summary Ensure that a supplementary character can be used as part/whole of a
* class name on platforms that have Unicode aware filesystems.
* @run main SupplementaryJavaID6
*/
public class SupplementaryJavaID6 {
public static void main(String[] s) {
new SupplementaryJavaID6();
new SupplementaryJavaID6().test();
}
public SupplementaryJavaID6() {
void test() {
\ud801\udc00 instance = new \ud801\udc00();
instance.\ud801\udc01();
}
......
#!/bin/sh
#
# Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# @test
# @bug 4914724 4973116 5014511
# @summary Ensure that a supplementary character can be used as part/whole of a class
# name on platforms that have Unicode aware filesystems.
# @author Naoto Sato
# @run shell SupplementaryJavaID6.sh SupplementaryJavaID6
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
if [ -d /usr/lib/locale/en_US.UTF-8 -o -d /usr/lib/locale/en_US.utf8 ]
then
ENV="env LANG=en_US.UTF-8"
PS=":"
FS="/"
else
echo "As there is no en_US.UTF-8 locale available on this system, the compilation of the test case may or may not fail. Ignoring this test."
exit 0;
fi
;;
Windows_98 | Windows_ME )
echo "As Windows 98/Me do not provide Unicode-aware file system, the compilation of the test case is expected to fail on these platforms. Ignoring this test."
exit 0;
;;
Windows* )
ENV=""
PS=";"
FS="\\"
;;
CYGWIN* )
ENV=""
PS=";" # platform PS, not cygwin PS
FS="/"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
# compile
cp "${TESTSRC}${FS}$1.java" .
${ENV} "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath ".${PS}${TESTSRC}" $1.java
result=$?
if [ $result -ne 0 ]
then
echo "Failed"
exit $result
fi
# run
${ENV} "${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} $1
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
# Cleanup
${ENV} rm -f ./$1*.class
exit $result
/*
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -21,6 +21,58 @@
* questions.
*/
/*
* @test
* @bug 6257087
* @summary javah doesn't produce proper signatures for inner class native methods
* @library /tools/javac/lib
* @build ToolBox
* @run main T6257087
*/
import java.nio.file.Paths;
//original test: test/tools/javah/6257087/foo.sh
public class T6257087 {
private static final String fooBarGoldenFile =
"/* DO NOT EDIT THIS FILE - it is machine generated */\n" +
"#include <jni.h>\n" +
"/* Header for class foo_bar */\n" +
"\n" +
"#ifndef _Included_foo_bar\n" +
"#define _Included_foo_bar\n" +
"#ifdef __cplusplus\n" +
"extern \"C\" {\n" +
"#endif\n" +
"/*\n" +
" * Class: foo_bar\n" +
" * Method: aardvark\n" +
" * Signature: ()V\n" +
" */\n" +
"JNIEXPORT void JNICALL Java_foo_00024bar_aardvark\n" +
" (JNIEnv *, jobject);\n" +
"\n" +
"#ifdef __cplusplus\n" +
"}\n" +
"#endif\n" +
"#endif";
public static void main(String[] args) throws Exception {
// "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TC}" "${TS}${FS}foo.java"
// "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} -classpath "${TC}" -d "${TC}" foo
ToolBox.JavaToolArgs javahArgs =
new ToolBox.JavaToolArgs()
.setAllArgs("-cp", System.getProperty("test.classes"), "foo");
ToolBox.javah(javahArgs);
// diff ${DIFFOPTS} -c "${TS}${FS}foo_bar.h" "${TC}${FS}foo_bar.h"
ToolBox.compareLines(Paths.get("foo_bar.h"),
ToolBox.splitLines(fooBarGoldenFile), null);
}
}
class foo {
class bar {
......
#! /bin/sh -f
#
# Copyright (c) 2006, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# @test
# @bug 6257087
# @run shell foo.sh
TS=${TESTSRC-.}
TC=${TESTCLASSES-.}
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
PS=":"
FS="/"
;;
CYGWIN* )
PS=":"
FS="/"
DIFFOPTS="--strip-trailing-cr"
;;
Windows* )
PS=";"
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TC}" "${TS}${FS}foo.java"
"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} -classpath "${TC}" -d "${TC}" foo
diff ${DIFFOPTS} -c "${TS}${FS}foo_bar.h" "${TC}${FS}foo_bar.h"
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class foo_bar */
#ifndef _Included_foo_bar
#define _Included_foo_bar
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: foo_bar
* Method: aardvark
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_foo_00024bar_aardvark
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
#!/bin/sh
#
# Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
#
# @bug 4786406 4781221 4780341 6214324
# Validates rewritten javah handling of class defined constants
# and ensures that the appropriate macro definitions are placed
# in the generated header file.
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
EXPECTED_JAVAH_OUT_FILE=SubClassConsts.out
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin )
PS=":"
FS="/"
;;
CYGWIN* )
PS=":"
FS="/"
DIFFOPTS="--strip-trailing-cr"
EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
;;
Windows* )
PS=";"
FS="\\"
EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
GENERATED_HEADER_FILE=SubClassConsts.h
HEADER_FILE_FILTERED=SubClassConsts.h.linefeed-filtered
rm -rf SuperClassConsts.class SubClassConsts.class
cp "${TESTSRC}${FS}SuperClassConsts.java" .
cp "${TESTSRC}${FS}SubClassConsts.java" .
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}SubClassConsts.java"
"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} SubClassConsts
diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
result=$?
rm ${GENERATED_HEADER_FILE}
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result
/*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* ParamClassTest has a native method param which subclasses
* this class
*
*/
public class MissingParamClassException extends Exception {
public MissingParamClassException() {
System.out.println("MissingParamClassException constructor called");
}
}
#!/bin/sh
#
# Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
#
# @bug 4942232
#
# Verifies that javah won't attempt to generate a header file
# if a native method in a supplied class contains a parameter
# type whose corresponding class is missing or not in the
# classpath
TMP1=OUTPUT.txt
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux | Darwin | CYGWIN* )
PS=":"
FS="/"
;;
Windows* )
PS=";"
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
GENERATED_HEADER_FILE=ParamClassTest.h
rm -f ParamClassTest.class MissingParamClassException.class ParamClassTest.h
rm -f ${TMP1}
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
# Before running javah remove dependent class file
rm -f MissingParamClassException.class
"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
if [ -f $GENERATED_HEADER_FILE ]; then
echo "1-- Failed: $GENERATED_HEADER_FILE found"
rc=1
fi
if [ ! -s ${TMP1} ]; then
echo "1-- Failed: ${TMP1} is empty"
rc=1
fi
# Clean out work dir
rm -f MissingParamClassException.class ParamClassTest.class
rm -f $GENERATED_HEADER_FILE $TMP1
# Re-compile everything
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
# Before re-run of javah remove dependent class file Param.class
rm -f Param.class
"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
if [ -f $GENERATED_HEADER_FILE ]; then
echo "2-- Failed: $GENERATED_HEADER_FILE found"
rc=1
fi
if [ ! -s ${TMP1} ]; then
echo "2-- Failed: ${TMP1} is empty"
rc=1
fi
if [ "$rc" = "" ]; then
echo Passed
else
echo Failed
exit 1
fi
/*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Subclass defines its own set of constants
* It is itself serializable by virtue of extending SuperClassConsts
*
*/
public class SubClassConsts extends SuperClassConsts {
private final static int SUB_INT_CONSTANT = 2;
private final static double SUB_DOUBLE_CONSTANT = 2.25;
private final static float SUB_FLOAT_CONSTANT = 7.90f;
private final static boolean SUB_BOOLEAN_CONSTANT = true;
public SubClassConsts(String p) {
super(p);
}
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class SubClassConsts */
#ifndef _Included_SubClassConsts
#define _Included_SubClassConsts
#ifdef __cplusplus
extern "C" {
#endif
#undef SubClassConsts_serialVersionUID
#define SubClassConsts_serialVersionUID 6733861379283244755LL
#undef SubClassConsts_SUPER_INT_CONSTANT
#define SubClassConsts_SUPER_INT_CONSTANT 3L
#undef SubClassConsts_SUPER_FLOAT_CONSTANT
#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f
#undef SubClassConsts_SUPER_DOUBLE_CONSTANT
#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2
#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT
#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L
#undef SubClassConsts_SUB_INT_CONSTANT
#define SubClassConsts_SUB_INT_CONSTANT 2L
#undef SubClassConsts_SUB_DOUBLE_CONSTANT
#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25
#undef SubClassConsts_SUB_FLOAT_CONSTANT
#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f
#undef SubClassConsts_SUB_BOOLEAN_CONSTANT
#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L
#ifdef __cplusplus
}
#endif
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
frame_type = 255 /* full_frame */
frame_type = 255 /* full_frame */
frame_type = 73 /* same_locals_1_stack_item */
frame_type = 255 /* full_frame */
offset_delta = 19
offset_delta = 0
offset_delta = 2
stack = [ uninitialized 0, uninitialized 0 ]
stack = [ uninitialized 0, uninitialized 0, double ]
stack = [ this ]
stack = [ this, double ]
locals = [ class "[Ljava/lang/String;" ]
locals = [ class "[Ljava/lang/String;" ]
locals = [ this, int ]
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册