This commit is contained in:
Phil Race 2018-03-23 10:02:55 -07:00
commit cb1ef28563
10 changed files with 289 additions and 94 deletions

View File

@ -40,7 +40,7 @@
$ make run-test-jdk_lang JTREG="JOBS=8"
$ make run-test TEST=jdk_lang
$ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
$ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
$ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug"
$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
$ make exploded-run-test TEST=hotspot_tier1</code></pre>
<h3 id="configuration">Configuration</h3>
@ -77,8 +77,8 @@ TEST FAILURE</code></pre>
<h2 id="test-suite-control">Test suite control</h2>
<p>It is possible to control various aspects of the test suites using make control variables.</p>
<p>These variables use a keyword=value approach to allow multiple values to be set. So, for instance, <code>JTREG=&quot;JOBS=1;TIMEOUT=8&quot;</code> will set the JTReg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting <code>JTREG_JOBS=1 JTREG_TIMEOUT=8</code>, but using the keyword format means that the <code>JTREG</code> variable is parsed and verified for correctness, so <code>JTREG=&quot;TMIEOUT=8&quot;</code> would give an error, while <code>JTREG_TMIEOUT=8</code> would just pass unnoticed.</p>
<p>To separate multiple keyword=value pairs, use <code>;</code> (semicolon). Since the shell normally eats <code>;</code>, the recommended usage is to write the assignment inside qoutes, e.g. <code>JTREG=&quot;...;...&quot;</code>. This will also make sure spaces are preserved, as in <code>JTREG=&quot;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;</code>.</p>
<p>(Other ways are possible, e.g. using backslash: <code>JTREG=JOBS=1\;TIMEOUT=8</code>. Also, as a special technique, the string <code>%20</code> will be replaced with space for certain options, e.g. <code>JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug</code>. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)</p>
<p>To separate multiple keyword=value pairs, use <code>;</code> (semicolon). Since the shell normally eats <code>;</code>, the recommended usage is to write the assignment inside qoutes, e.g. <code>JTREG=&quot;...;...&quot;</code>. This will also make sure spaces are preserved, as in <code>JTREG=&quot;VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;</code>.</p>
<p>(Other ways are possible, e.g. using backslash: <code>JTREG=JOBS=1\;TIMEOUT=8</code>. Also, as a special technique, the string <code>%20</code> will be replaced with space for certain options, e.g. <code>JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug</code>. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)</p>
<p>As far as possible, the names of the keywords have been standardized between test suites.</p>
<h3 id="jtreg-keywords">JTReg keywords</h3>
<h4 id="jobs">JOBS</h4>

View File

@ -18,7 +18,7 @@ Some example command-lines:
$ make run-test-jdk_lang JTREG="JOBS=8"
$ make run-test TEST=jdk_lang
$ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
$ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
$ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug"
$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
$ make exploded-run-test TEST=hotspot_tier1
@ -140,11 +140,11 @@ pass unnoticed.
To separate multiple keyword=value pairs, use `;` (semicolon). Since the shell
normally eats `;`, the recommended usage is to write the assignment inside
qoutes, e.g. `JTREG="...;..."`. This will also make sure spaces are preserved,
as in `JTREG="VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"`.
as in `JTREG="VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug"`.
(Other ways are possible, e.g. using backslash: `JTREG=JOBS=1\;TIMEOUT=8`.
Also, as a special technique, the string `%20` will be replaced with space for
certain options, e.g. `JTREG=VM_OTIONS=-XshowSettings%20-Xlog:gc+ref=debug`.
certain options, e.g. `JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug`.
This can be useful if you have layers of scripts and have trouble getting
proper quoting of command line arguments through.)

View File

@ -1298,22 +1298,37 @@ if [ "$SKIP_DEFAULT" != "true" ]; then
# Find the common images to compare, prioritizing later build stages
if [ -d "$THIS/install/jdk" ] && [ -d "$OTHER/install/jdk" ]; then
THIS_JDK="$THIS/install/jdk"
THIS_JRE="$THIS/install/jre"
OTHER_JDK="$OTHER/install/jdk"
OTHER_JRE="$OTHER/install/jre"
echo "Selecting install images for compare"
echo "Selecting install images for JDK compare"
if [ -d "$THIS/install/jre" ] && [ -d "$OTHER/install/jre" ]; then
THIS_JRE="$THIS/install/jre"
OTHER_JRE="$OTHER/install/jre"
echo "Also selecting install images for JRE compare"
else
echo "No install JRE image found"
fi
elif [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/deploy/images/jdk" ]; then
THIS_JDK="$THIS/images/jdk"
THIS_JRE="$THIS/images/jre"
OTHER_JDK="$OTHER/deploy/images/jdk"
OTHER_JRE="$OTHER/deploy/images/jre"
echo "Selecting deploy images for compare"
echo "Selecting deploy images for JDK compare"
if [ -d "$THIS/images/jre" ] && [ -d "$OTHER/deploy/images/jre" ]; then
THIS_JRE="$THIS/images/jre"
OTHER_JRE="$OTHER/deploy/images/jre"
echo "Selecting deploy images for JRE compare"
else
echo "No deploy JRE image found"
fi
elif [ -d "$THIS/images/jdk" ] && [ -d "$OTHER/images/jdk" ]; then
THIS_JDK="$THIS/images/jdk"
THIS_JRE="$THIS/images/jre"
OTHER_JDK="$OTHER/images/jdk"
OTHER_JRE="$OTHER/images/jre"
echo "Selecting jdk images for compare"
echo "Selecting normal images for JDK compare"
if [ -d "$THIS/images/jre" ] && [ -d "$OTHER/images/jre" ]; then
THIS_JRE="$THIS/images/jre"
OTHER_JRE="$OTHER/images/jre"
echo "Selecting normal images for JRE compare"
else
echo "No normal JRE image found"
fi
elif [ -d "$(ls -d $THIS/licensee-src/build/*/images/jdk 2> /dev/null)" ] \
&& [ -d "$(ls -d $OTHER/licensee-src/build/*/images/jdk 2> /dev/null)" ]
then
@ -1406,9 +1421,11 @@ if [ "$SKIP_DEFAULT" != "true" ]; then
else
OTHER_SEC_DIR="$OTHER/tmp"
fi
OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip"
THIS_SEC_DIR="$THIS/images"
THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip"
if [ -f "$THIS_SEC_DIR/sec-bin.zip" ]; then
OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip"
THIS_SEC_DIR="$THIS/images"
THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip"
fi
if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip"
@ -1437,11 +1454,12 @@ if [ "$CMP_NAMES" = "true" ]; then
if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
echo -n "JDK "
compare_dirs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
echo -n "JRE "
compare_dirs $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
echo -n "JDK "
compare_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
fi
if [ -n "$THIS_JRE" ] && [ -n "$OTHER_JRE" ]; then
echo -n "JRE "
compare_dirs $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
echo -n "JRE "
compare_files $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
fi
@ -1480,49 +1498,38 @@ if [ "$CMP_NAMES" = "true" ]; then
fi
fi
if [ "$CMP_PERMS" = "true" ]; then
if [ "$CMP_LIBS" = "true" ]; then
if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
echo -n "JDK "
compare_permissions $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
echo -n "JRE "
compare_permissions $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
compare_all_libs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
fi
if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
compare_permissions $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
compare_all_libs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
fi
if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
echo -n "JavaAppletPlugin "
compare_permissions $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
compare_all_libs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
fi
if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
echo -n "Sparkle.framework "
compare_permissions $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
compare_all_libs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
fi
fi
if [ "$CMP_TYPES" = "true" ]; then
if [ "$CMP_EXECS" = "true" ]; then
if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
echo -n "JDK "
compare_file_types $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
echo -n "JRE "
compare_file_types $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
fi
if [ -n "$THIS_JDK_BUNDLE" ] && [ -n "$OTHER_JDK_BUNDLE" ]; then
echo -n "JDK Bundle "
compare_file_types $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle
echo -n "JRE Bundle "
compare_file_types $THIS_JRE_BUNDLE $OTHER_JRE_BUNDLE $COMPARE_ROOT/jre-bundle
compare_all_execs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
fi
if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
compare_file_types $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
compare_all_execs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
fi
if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
echo -n "JavaAppletPlugin "
compare_file_types $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
compare_all_execs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
fi
if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
echo -n "Sparkle.framework "
compare_file_types $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
compare_all_execs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
fi
fi
@ -1530,6 +1537,8 @@ if [ "$CMP_GENERAL" = "true" ]; then
if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
echo -n "JDK "
compare_general_files $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
fi
if [ -n "$THIS_JRE" ] && [ -n "$OTHER_JRE" ]; then
echo -n "JRE "
compare_general_files $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
fi
@ -1601,46 +1610,53 @@ if [ "$CMP_JARS" = "true" ]; then
fi
fi
if [ "$CMP_LIBS" = "true" ]; then
if [ "$CMP_PERMS" = "true" ]; then
if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
echo -n "JDK "
compare_all_libs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
echo -n "JRE "
compare_all_libs $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
fi
compare_permissions $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
fi
if [ -n "$THIS_JRE" ] && [ -n "$OTHER_JRE" ]; then
echo -n "JRE "
compare_permissions $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
fi
if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
compare_all_libs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
compare_permissions $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
fi
if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
echo -n "JavaAppletPlugin "
compare_all_libs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
compare_permissions $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
fi
if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
echo -n "Sparkle.framework "
compare_all_libs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
compare_permissions $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
fi
fi
if [ "$CMP_EXECS" = "true" ]; then
if [ "$CMP_TYPES" = "true" ]; then
if [ -n "$THIS_JDK" ] && [ -n "$OTHER_JDK" ]; then
compare_all_execs $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
echo -n "JRE "
compare_all_execs $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
fi
echo -n "JDK "
compare_file_types $THIS_JDK $OTHER_JDK $COMPARE_ROOT/jdk
fi
if [ -n "$THIS_JRE" ] && [ -n "$OTHER_JRE" ]; then
echo -n "JRE "
compare_file_types $THIS_JRE $OTHER_JRE $COMPARE_ROOT/jre
fi
if [ -n "$THIS_JDK_BUNDLE" ] && [ -n "$OTHER_JDK_BUNDLE" ]; then
echo -n "JDK Bundle "
compare_file_types $THIS_JDK_BUNDLE $OTHER_JDK_BUNDLE $COMPARE_ROOT/jdk-bundle
echo -n "JRE Bundle "
compare_file_types $THIS_JRE_BUNDLE $OTHER_JRE_BUNDLE $COMPARE_ROOT/jre-bundle
fi
if [ -n "$THIS_BASE_DIR" ] && [ -n "$OTHER_BASE_DIR" ]; then
compare_all_execs $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
compare_file_types $THIS_BASE_DIR $OTHER_BASE_DIR $COMPARE_ROOT/base_dir
fi
if [ -n "$THIS_DEPLOY_APPLET_PLUGIN_DIR" ] && [ -n "$OTHER_DEPLOY_APPLET_PLUGIN_DIR" ]; then
echo -n "JavaAppletPlugin "
compare_all_execs $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
compare_file_types $THIS_DEPLOY_APPLET_PLUGIN_DIR $OTHER_DEPLOY_APPLET_PLUGIN_DIR $COMPARE_ROOT/plugin
fi
if [ -n "$THIS_SPARKLE_DIR" ] && [ -n "$OTHER_SPARKLE_DIR" ]; then
echo -n "Sparkle.framework "
compare_all_execs $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
compare_file_types $THIS_SPARKLE_DIR $OTHER_SPARKLE_DIR $COMPARE_ROOT/sparkle
fi
fi

View File

@ -339,7 +339,7 @@ if [ "$OPENJDK_TARGET_OS" = "solaris" ] && [ "$OPENJDK_TARGET_CPU" = "sparcv9" ]
DIS_DIFF_FILTER="$SED \
-e 's/^[0-9a-f]\{16\}/<ADDR>:/' \
-e 's/^ *[0-9a-f]\{3,8\}:/ <ADDR>:/' \
-e 's/^ *[0-9a-f]\{3,12\}:/ <ADDR>:/' \
-e 's/: [0-9a-f][0-9a-f]\( [0-9a-f][0-9a-f]\)\{2,10\}/: <NUMS>/' \
-e 's/\$[a-zA-Z0-9_\$]\{15\}\./<SYM>./' \
-e 's/, [0-9a-fx\-]\{1,8\}/, <ADDR>/g' \

View File

@ -244,21 +244,8 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
PUTPROP(props, "line.separator", sprops->line_separator);
/*
* user.language
* user.script, user.country, user.variant (if user's environment specifies them)
* file.encoding
* file encoding for stdout and stderr
*/
PUTPROP(props, "user.language", sprops->language);
if (sprops->script) {
PUTPROP(props, "user.script", sprops->script);
}
if (sprops->country) {
PUTPROP(props, "user.country", sprops->country);
}
if (sprops->variant) {
PUTPROP(props, "user.variant", sprops->variant);
}
PUTPROP(props, "file.encoding", sprops->encoding);
if (sprops->sun_stdout_encoding != NULL) {
PUTPROP(props, "sun.stdout.encoding", sprops->sun_stdout_encoding);
}
@ -314,7 +301,7 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
#endif
/* !!! DO NOT call PUTPROP_ForPlatformNString before this line !!!
* !!! I18n properties have not been set up yet !!!
* !!! The platform native encoding for strings has not been set up yet !!!
*/
InitializeEncoding(env, sprops->sun_jnu_encoding);
@ -379,17 +366,6 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
PUTPROP(props, "sun.desktop", sprops->desktop);
}
/*
* unset "user.language", "user.script", "user.country", and "user.variant"
* in order to tell whether the command line option "-DXXXX=YYYY" is
* specified or not. They will be reset in fillI18nProps() below.
*/
REMOVEPROP(props, "user.language");
REMOVEPROP(props, "user.script");
REMOVEPROP(props, "user.country");
REMOVEPROP(props, "user.variant");
REMOVEPROP(props, "file.encoding");
ret = JVM_InitProperties(env, props);
/* reconstruct i18n related properties */

View File

@ -828,7 +828,7 @@ public class Check {
return buf.toList();
}
boolean checkDenotable(Type t) {
public boolean checkDenotable(Type t) {
return denotableChecker.visit(t, null);
}
// where

View File

@ -43,6 +43,7 @@ import com.sun.tools.javac.code.Directive.*;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.code.Type.*;
import com.sun.tools.javac.code.Types.UniqueType;
import com.sun.tools.javac.comp.Check;
import com.sun.tools.javac.file.PathFileObject;
import com.sun.tools.javac.jvm.Pool.DynamicMethod;
import com.sun.tools.javac.jvm.Pool.Method;
@ -101,6 +102,8 @@ public class ClassWriter extends ClassFile {
/** Type utilities. */
private Types types;
private Check check;
/**
* If true, class files will be written in module-specific subdirectories
* of the CLASS_OUTPUT location.
@ -178,6 +181,7 @@ public class ClassWriter extends ClassFile {
target = Target.instance(context);
source = Source.instance(context);
types = Types.instance(context);
check = Check.instance(context);
fileManager = context.get(JavaFileManager.class);
signatureGen = new CWSignatureGenerator(types);
@ -1294,10 +1298,10 @@ public class ClassWriter extends ClassFile {
//where
private boolean needsLocalVariableTypeEntry(Type t) {
//a local variable needs a type-entry if its type T is generic
//(i.e. |T| != T) and if it's not an intersection type (not supported
//in signature attribute grammar)
return (!types.isSameType(t, types.erasure(t)) &&
!t.isCompound());
//(i.e. |T| != T) and if it's not an non-denotable type (non-denotable
// types are not supported in signature attribute grammar!)
return !types.isSameType(t, types.erasure(t)) &&
check.checkDenotable(t);
}
void writeStackMap(Code code) {

View File

@ -0,0 +1,152 @@
/*
* Copyright (c) 2018, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.List;
/*
* @test
* @modules java.management
* @summary verify that overriddes on the command line affect *.display and *.format properties
* @run main/othervm
* LocaleCmdOverrides
* @run main/othervm -Duser.language=XX
* -Duser.country=X1
* -Duser.script=X2
* -Duser.variant=X3
* LocaleCmdOverrides
* @run main/othervm -Duser.language=XX -Duser.language.display=YY
* -Duser.country=X1 -Duser.country.display=Y1
* -Duser.script=X2 -Duser.script.display=Y2
* -Duser.variant=X3 -Duser.variant.display=Y3
* LocaleCmdOverrides
* @run main/othervm -Duser.language=XX -Duser.language.display=YY -Duser.language.format=ZZ
* -Duser.country=X1 -Duser.country.display=Y1 -Duser.country.format=Z1
* -Duser.script=X2 -Duser.script.display=Y2 -Duser.script.format=Z2
* -Duser.variant=X3 -Duser.variant.display=Y3 -Duser.variant.format=Z3
* LocaleCmdOverrides
* @run main/othervm -Duser.language=XX -Duser.language.format=ZZ
* -Duser.country=X1 -Duser.country.format=Z1
* -Duser.script=X2 -Duser.script.format=Z2
* -Duser.variant=X3 -Duser.variant.format=Z3
* LocaleCmdOverrides
* @run main/othervm -Duser.language=XX -Duser.language.display=XX
* -Duser.country=X1 -Duser.country.display=X1
* -Duser.script=X2 -Duser.script.display=X2
* -Duser.variant=X3 -Duser.variant.display=X3
* LocaleCmdOverrides
* @run main/othervm -Duser.language=XX -Duser.language.display=XX -Duser.language.format=XX
* -Duser.country=X1 -Duser.country.display=X1 -Duser.country.format=X1
* -Duser.script=X2 -Duser.script.display=X2 -Duser.script.format=X2
* -Duser.variant=X3 -Duser.variant.display=X3 -Duser.variant.format=X3
* LocaleCmdOverrides
* @run main/othervm -Duser.language=XX -Duser.language.format=X1
* -Duser.country.format=X1
* -Duser.script.format=X2
* -Duser.variant.format=X3
* LocaleCmdOverrides
*/
public class LocaleCmdOverrides {
// Language, country, script, variant
public static void main(String[] args) {
Map<String, String> props = commandLineDefines();
System.out.printf("props: %s%n", props);
test("user.language", props);
test("user.country", props);
test("user.script", props);
test("user.variant", props);
}
/*
* Check each of the properties for a given basename.
*/
static void test(String baseName, Map<String, String> args) {
validateArg(baseName,"", args);
validateArg(baseName,".display", args);
validateArg(baseName,".format", args);
}
// If an argument is -D defined, the corresponding property must be equal
static void validateArg(String name, String ext, Map<String, String> args) {
String extName = name.concat(ext);
String arg = args.get(extName);
String prop = System.getProperty(extName);
if (arg == null && prop == null) {
System.out.printf("No values for %s%n", extName);
} else {
System.out.printf("validateArg %s: arg: %s, prop: %s%n", extName, arg, prop);
}
if (arg != null) {
if (!Objects.equals(arg, prop)) {
throw new RuntimeException(extName + ": -D value should match property: "
+ arg + " != " + prop);
}
} else if (prop != null) {
// no command line arg for extName and some value for prop
// Check that if a property is not overridden then it is not equal to the base
if (ext != null && !ext.isEmpty()) {
String value = System.getProperty(name);
if (Objects.equals(value, prop)) {
throw new RuntimeException(extName + " property should not be equals to "
+ name + " property: " + prop);
}
}
}
}
/**
* Extract the -D arguments from the command line and return a map of key, value.
* @return a map of key, values defined by -D on the command line.
*/
static HashMap<String, String> commandLineDefines() {
HashMap<String, String> props = new HashMap<>();
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
List<String> args = runtime.getInputArguments();
System.out.printf("args: %s%n", args);
for (String arg : args) {
if (arg.startsWith("-Duser.")) {
String[] kv = arg.substring(2).split("=");
switch (kv.length) {
case 1:
props.put(kv[0], "");
break;
case 2:
props.put(kv[0], kv[1]);
break;
default:
throw new IllegalArgumentException("Illegal property syntax: " + arg);
}
}
}
return props;
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2018, 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 8199910
* @summary Compile variables of intersection type inferred by `var` with -g option
* @compile -g T8199910.java
*/
import java.util.List;
class T8199910 {
<T> T first(T... ts) {
return ts[0];
}
void m() {
var list1 = List.of("", 1);
var list2 = List.of(1, 2.0);
var a = first("", 1);
var b = first(1, 2.0);
}
}

View File

@ -80,12 +80,16 @@ public class LocalVariableInferenceTester {
void compileAndCheck(JavaFileObject input) throws IOException {
JavaCompiler c = ToolProvider.getSystemJavaCompiler();
JavacTask task = (JavacTask) c.getTask(null, fm, null, null, null, Arrays.asList(input));
JavacTask task = (JavacTask) c.getTask(null, fm, null, Arrays.asList("-g"), null, Arrays.asList(input));
JavacTrees trees = JavacTrees.instance(task);
Types types = Types.instance(((JavacTaskImpl)task).getContext());
Iterable<? extends CompilationUnitTree> roots = task.parse();
task.analyze(); //force attribution
Log log = Log.instance(((JavacTaskImpl)task).getContext());
//force code generation (to shake out non-denotable issues)
boolean hasClasses = task.generate().iterator().hasNext();
if (!hasClasses) {
throw new AssertionError("Errors occurred during compilation!");
}
errors += log.nerrors;
new LocalVarTypeChecker(trees, types).scan(roots, null);
System.err.println("Checks executed: " + checks);