diff --git a/.hgtags b/.hgtags index 24dc9213f13fbcadddfb2807883e1d9b4f333064..8bd85bbd69d2492a0487169e5a312fe6b978f0d3 100644 --- a/.hgtags +++ b/.hgtags @@ -93,3 +93,6 @@ e250cef36ea05e627e7e6f7d75e5e19f529e2ba3 jdk7-b114 1657ed4e1d86c8aa2028ab5a41f9da1ac4a369f8 jdk7-b116 3e6726bbf80a4254ecd01051c8ed77ee19325e46 jdk7-b117 b357910aa04aead2a16b6d6ff395a8df4b51d1dd jdk7-b118 +ecab7eefb8f2326fd90fb632f47f1b6f81e928f8 jdk7-b119 +37d74e29687cf07c2bf9411af58c7e42440855c3 jdk7-b120 +a661d8587b5d8986aacae086f5df66af9e1a96b1 jdk7-b121 diff --git a/make/common/Defs.gmk b/make/common/Defs.gmk index 31e3a4a8f65c03213ad3f51e9e1a7942aa2a1856..71ab366ab61e07afc42c98b6a557cd0f08da7c17 100644 --- a/make/common/Defs.gmk +++ b/make/common/Defs.gmk @@ -83,14 +83,19 @@ ifndef CLOSED_SRC CLOSED_SRC = $(BUILDDIR)/../src/closed endif -# If we have no closed directory, force it to an openjdk build -CLOSED_SRC_DIR_EXISTS := $(shell \ - if [ -d $(CLOSED_SRC) ] ; then \ - echo true; \ - else \ - echo false; \ - fi) -ifeq ($(CLOSED_SRC_DIR_EXISTS), false) +# If CLOSE_SRC_INCLUDED isn't set to true, check if there's any +# closed directory. +ifneq ($(CLOSED_SRC_INCLUDED), true) + CLOSED_SRC_INCLUDED := $(shell \ + if [ -d $(CLOSED_SRC) ] ; then \ + echo true; \ + else \ + echo false; \ + fi) +endif + +# Set OPENJDK based on CLOSED_SRC_INCLUDED +ifeq ($(CLOSED_SRC_INCLUDED), false) OPENJDK = true endif diff --git a/make/sun/nio/cs/FILES_java.gmk b/make/sun/nio/cs/FILES_java.gmk index d930065d83f66d6ba583eabf112d6f18e647e54f..b177d64b4c10a753d5d4b45eeb56cf58917bd7e8 100644 --- a/make/sun/nio/cs/FILES_java.gmk +++ b/make/sun/nio/cs/FILES_java.gmk @@ -85,6 +85,7 @@ FILES_src = \ sun/io/ByteToCharCp500.java \ sun/io/ByteToCharCp737.java \ sun/io/ByteToCharCp775.java \ + sun/io/ByteToCharCp833.java \ sun/io/ByteToCharCp834.java \ sun/io/ByteToCharCp838.java \ sun/io/ByteToCharCp850.java \ @@ -214,6 +215,7 @@ FILES_src = \ sun/io/CharToByteCp500.java \ sun/io/CharToByteCp737.java \ sun/io/CharToByteCp775.java \ + sun/io/CharToByteCp833.java \ sun/io/CharToByteCp834.java \ sun/io/CharToByteCp838.java \ sun/io/CharToByteCp850.java \ @@ -331,6 +333,7 @@ FILES_gen_extcs = \ sun/nio/cs/ext/IBM420.java \ sun/nio/cs/ext/IBM424.java \ sun/nio/cs/ext/IBM500.java \ + sun/nio/cs/ext/IBM833.java \ sun/nio/cs/ext/IBM838.java \ sun/nio/cs/ext/IBM856.java \ sun/nio/cs/ext/IBM860.java \ diff --git a/make/sun/xawt/mapfile-vers b/make/sun/xawt/mapfile-vers index 0d951efff1d200ae6110026c0a6594869d5de64b..920d829fc93f52704767fde4d7c26ccb55d4cee2 100644 --- a/make/sun/xawt/mapfile-vers +++ b/make/sun/xawt/mapfile-vers @@ -432,6 +432,7 @@ SUNWprivate_1.1 { Java_sun_awt_X11_GtkFileDialogPeer_initIDs; Java_sun_awt_X11_GtkFileDialogPeer_run; Java_sun_awt_X11_GtkFileDialogPeer_quit; + Java_sun_awt_X11_GtkFileDialogPeer_toFront; Java_sun_print_CUPSPrinter_initIDs; Java_sun_print_CUPSPrinter_getCupsServer; diff --git a/make/tools/CharsetMapping/IBM833.c2b b/make/tools/CharsetMapping/IBM833.c2b new file mode 100644 index 0000000000000000000000000000000000000000..b751d80bc0064e8d2a792d722a860b0b90429b5d --- /dev/null +++ b/make/tools/CharsetMapping/IBM833.c2b @@ -0,0 +1,94 @@ +0x5A U+FF01 +0x7F U+FF02 +0x7B U+FF03 +0x5B U+FF04 +0x6C U+FF05 +0x50 U+FF06 +0x7D U+FF07 +0x4D U+FF08 +0x5D U+FF09 +0x5C U+FF0A +0x4E U+FF0B +0x6B U+FF0C +0x60 U+FF0D +0x4B U+FF0E +0x61 U+FF0F +0xF0 U+FF10 +0xF1 U+FF11 +0xF2 U+FF12 +0xF3 U+FF13 +0xF4 U+FF14 +0xF5 U+FF15 +0xF6 U+FF16 +0xF7 U+FF17 +0xF8 U+FF18 +0xF9 U+FF19 +0x7A U+FF1A +0x5E U+FF1B +0x4C U+FF1C +0x7E U+FF1D +0x6E U+FF1E +0x6F U+FF1F +0x7C U+FF20 +0xC1 U+FF21 +0xC2 U+FF22 +0xC3 U+FF23 +0xC4 U+FF24 +0xC5 U+FF25 +0xC6 U+FF26 +0xC7 U+FF27 +0xC8 U+FF28 +0xC9 U+FF29 +0xD1 U+FF2A +0xD2 U+FF2B +0xD3 U+FF2C +0xD4 U+FF2D +0xD5 U+FF2E +0xD6 U+FF2F +0xD7 U+FF30 +0xD8 U+FF31 +0xD9 U+FF32 +0xE2 U+FF33 +0xE3 U+FF34 +0xE4 U+FF35 +0xE5 U+FF36 +0xE6 U+FF37 +0xE7 U+FF38 +0xE8 U+FF39 +0xE9 U+FF3A +0x70 U+FF3B +0xB2 U+FF3C +0x80 U+FF3D +0xB0 U+FF3E +0x6D U+FF3F +0x79 U+FF40 +0x81 U+FF41 +0x82 U+FF42 +0x83 U+FF43 +0x84 U+FF44 +0x85 U+FF45 +0x86 U+FF46 +0x87 U+FF47 +0x88 U+FF48 +0x89 U+FF49 +0x91 U+FF4A +0x92 U+FF4B +0x93 U+FF4C +0x94 U+FF4D +0x95 U+FF4E +0x96 U+FF4F +0x97 U+FF50 +0x98 U+FF51 +0x99 U+FF52 +0xA2 U+FF53 +0xA3 U+FF54 +0xA4 U+FF55 +0xA5 U+FF56 +0xA6 U+FF57 +0xA7 U+FF58 +0xA8 U+FF59 +0xA9 U+FF5A +0xC0 U+FF5B +0x4F U+FF5C +0xD0 U+FF5D +0xA1 U+FF5E diff --git a/make/tools/CharsetMapping/IBM833.map b/make/tools/CharsetMapping/IBM833.map new file mode 100644 index 0000000000000000000000000000000000000000..b36860ae4e7a144ce372f6e181a082a37659adf2 --- /dev/null +++ b/make/tools/CharsetMapping/IBM833.map @@ -0,0 +1,217 @@ +0x00 U+0000 +0x01 U+0001 +0x02 U+0002 +0x03 U+0003 +0x37 U+0004 +0x2D U+0005 +0x2E U+0006 +0x2F U+0007 +0x16 U+0008 +0x05 U+0009 +0x25 U+000A +0x0B U+000B +0x0C U+000C +0x0D U+000D +0x0E U+000E +0x0F U+000F +0x10 U+0010 +0x11 U+0011 +0x12 U+0012 +0x13 U+0013 +0x3C U+0014 +0x3D U+0015 +0x32 U+0016 +0x26 U+0017 +0x18 U+0018 +0x19 U+0019 +0x3F U+001A +0x27 U+001B +0x1C U+001C +0x1D U+001D +0x1E U+001E +0x1F U+001F +0x40 U+0020 +0x5A U+0021 +0x7F U+0022 +0x7B U+0023 +0x5B U+0024 +0x6C U+0025 +0x50 U+0026 +0x7D U+0027 +0x4D U+0028 +0x5D U+0029 +0x5C U+002A +0x4E U+002B +0x6B U+002C +0x60 U+002D +0x4B U+002E +0x61 U+002F +0xF0 U+0030 +0xF1 U+0031 +0xF2 U+0032 +0xF3 U+0033 +0xF4 U+0034 +0xF5 U+0035 +0xF6 U+0036 +0xF7 U+0037 +0xF8 U+0038 +0xF9 U+0039 +0x7A U+003A +0x5E U+003B +0x4C U+003C +0x7E U+003D +0x6E U+003E +0x6F U+003F +0x7C U+0040 +0xC1 U+0041 +0xC2 U+0042 +0xC3 U+0043 +0xC4 U+0044 +0xC5 U+0045 +0xC6 U+0046 +0xC7 U+0047 +0xC8 U+0048 +0xC9 U+0049 +0xD1 U+004A +0xD2 U+004B +0xD3 U+004C +0xD4 U+004D +0xD5 U+004E +0xD6 U+004F +0xD7 U+0050 +0xD8 U+0051 +0xD9 U+0052 +0xE2 U+0053 +0xE3 U+0054 +0xE4 U+0055 +0xE5 U+0056 +0xE6 U+0057 +0xE7 U+0058 +0xE8 U+0059 +0xE9 U+005A +0x70 U+005B +0xB2 U+005C +0x80 U+005D +0xB0 U+005E +0x6D U+005F +0x79 U+0060 +0x81 U+0061 +0x82 U+0062 +0x83 U+0063 +0x84 U+0064 +0x85 U+0065 +0x86 U+0066 +0x87 U+0067 +0x88 U+0068 +0x89 U+0069 +0x91 U+006A +0x92 U+006B +0x93 U+006C +0x94 U+006D +0x95 U+006E +0x96 U+006F +0x97 U+0070 +0x98 U+0071 +0x99 U+0072 +0xA2 U+0073 +0xA3 U+0074 +0xA4 U+0075 +0xA5 U+0076 +0xA6 U+0077 +0xA7 U+0078 +0xA8 U+0079 +0xA9 U+007A +0xC0 U+007B +0x4F U+007C +0xD0 U+007D +0xA1 U+007E +0x07 U+007F +0x20 U+0080 +0x21 U+0081 +0x22 U+0082 +0x23 U+0083 +0x24 U+0084 +0x15 U+0085 +0x06 U+0086 +0x17 U+0087 +0x28 U+0088 +0x29 U+0089 +0x2A U+008A +0x2B U+008B +0x2C U+008C +0x09 U+008D +0x0A U+008E +0x1B U+008F +0x30 U+0090 +0x31 U+0091 +0x1A U+0092 +0x33 U+0093 +0x34 U+0094 +0x35 U+0095 +0x36 U+0096 +0x08 U+0097 +0x38 U+0098 +0x39 U+0099 +0x3A U+009A +0x3B U+009B +0x04 U+009C +0x14 U+009D +0x3E U+009E +0xFF U+009F +0x4A U+00A2 +0x6A U+00A6 +0x5F U+00AC +0xA0 U+203E +0xE0 U+20A9 +0x42 U+FFA0 +0x43 U+FFA1 +0x44 U+FFA2 +0x45 U+FFA3 +0x46 U+FFA4 +0x47 U+FFA5 +0x48 U+FFA6 +0x49 U+FFA7 +0x52 U+FFA8 +0x53 U+FFA9 +0x54 U+FFAA +0x55 U+FFAB +0x56 U+FFAC +0x57 U+FFAD +0x58 U+FFAE +0x59 U+FFAF +0x62 U+FFB0 +0x63 U+FFB1 +0x64 U+FFB2 +0x65 U+FFB3 +0x66 U+FFB4 +0x67 U+FFB5 +0x68 U+FFB6 +0x69 U+FFB7 +0x72 U+FFB8 +0x73 U+FFB9 +0x74 U+FFBA +0x75 U+FFBB +0x76 U+FFBC +0x77 U+FFBD +0x78 U+FFBE +0x8A U+FFC2 +0x8B U+FFC3 +0x8C U+FFC4 +0x8D U+FFC5 +0x8E U+FFC6 +0x8F U+FFC7 +0x9A U+FFCA +0x9B U+FFCB +0x9C U+FFCC +0x9D U+FFCD +0x9E U+FFCE +0x9F U+FFCF +0xAA U+FFD2 +0xAB U+FFD3 +0xAC U+FFD4 +0xAD U+FFD5 +0xAE U+FFD6 +0xAF U+FFD7 +0xBA U+FFDA +0xBB U+FFDB +0xBC U+FFDC diff --git a/make/tools/CharsetMapping/extsbcs b/make/tools/CharsetMapping/extsbcs index 81a6acdf8176650ba67d5c250907b11968c2c145..ac24dbe7a7dbd1f127a27259ef36d2c3e67f2194 100644 --- a/make/tools/CharsetMapping/extsbcs +++ b/make/tools/CharsetMapping/extsbcs @@ -32,6 +32,7 @@ IBM297 IBM297 Cp297 false sun.nio.cs.ext IBM420 IBM420 Cp420 false sun.nio.cs.ext IBM424 IBM424 Cp424 false sun.nio.cs.ext IBM500 IBM500 Cp500 false sun.nio.cs.ext +IBM833 x-IBM833 Cp833 false sun.nio.cs.ext IBM838 IBM-Thai Cp838 false sun.nio.cs.ext IBM856 x-IBM856 Cp856 false sun.nio.cs.ext IBM860 IBM860 Cp860 false sun.nio.cs.ext diff --git a/src/share/bin/java.c b/src/share/bin/java.c index 01eeb2a0547ab076b0db300e7e2eed29c301f54f..e02b8ac8bb0896eb147df78fd013c7be587ea57e 100644 --- a/src/share/bin/java.c +++ b/src/share/bin/java.c @@ -65,6 +65,7 @@ static jboolean printVersion = JNI_FALSE; /* print and exit */ static jboolean showVersion = JNI_FALSE; /* print but continue */ static jboolean printUsage = JNI_FALSE; /* print and exit*/ static jboolean printXUsage = JNI_FALSE; /* print and exit*/ +static char *showSettings = NULL; /* print but continue */ static const char *_program_name; static const char *_launcher_name; @@ -109,6 +110,7 @@ static void SetApplicationClassPath(const char**); static void PrintJavaVersion(JNIEnv *env, jboolean extraLF); static void PrintUsage(JNIEnv* env, jboolean doXUsage); +static void ShowSettings(JNIEnv* env, char *optString); static void SetPaths(int argc, char **argv); @@ -157,6 +159,7 @@ static jboolean IsWildCardEnabled(); * create a new thread to invoke JVM. See 6316197 for more information. */ static jlong threadStackSize = 0; /* stack size of the new thread */ +static jlong heapSize = 0; /* heap size */ int JNICALL JavaMain(void * args); /* entry point */ @@ -376,6 +379,10 @@ JavaMain(void * _args) } } + if (showSettings != NULL) { + ShowSettings(env, showSettings); + CHECK_EXCEPTION_LEAVE(0); + } /* If the user specified neither a class name nor a JAR file */ if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) { PrintUsage(env, printXUsage); @@ -611,7 +618,7 @@ CheckJvmType(int *pargc, char ***argv, jboolean speculative) { /* copied from HotSpot function "atomll()" */ static int -parse_stack_size(const char *s, jlong *result) { +parse_size(const char *s, jlong *result) { jlong n = 0; int args_read = sscanf(s, jlong_format_specifier(), &n); if (args_read != 1) { @@ -673,10 +680,17 @@ AddOption(char *str, void *info) options[numOptions++].extraInfo = info; if (JLI_StrCCmp(str, "-Xss") == 0) { - jlong tmp; - if (parse_stack_size(str + 4, &tmp)) { - threadStackSize = tmp; - } + jlong tmp; + if (parse_size(str + 4, &tmp)) { + threadStackSize = tmp; + } + } + + if (JLI_StrCCmp(str, "-Xmx") == 0) { + jlong tmp; + if (parse_size(str + 4, &tmp)) { + heapSize = tmp; + } } } @@ -1014,6 +1028,13 @@ ParseArguments(int *pargc, char ***pargv, char **pjarfile, } else if (JLI_StrCmp(arg, "-X") == 0) { printXUsage = JNI_TRUE; return JNI_TRUE; +/* + * The following case checks for -XshowSettings OR -XshowSetting:SUBOPT. + * In the latter case, any SUBOPT value not recognized will default to "all" + */ + } else if (JLI_StrCmp(arg, "-XshowSettings") == 0 || + JLI_StrCCmp(arg, "-XshowSettings:") == 0) { + showSettings = arg; /* * The following case provide backward compatibility with old-style * command line options. @@ -1474,6 +1495,27 @@ PrintJavaVersion(JNIEnv *env, jboolean extraLF) (*env)->CallStaticVoidMethod(env, ver, print); } +/* + * Prints all the Java settings, see the java implementation for more details. + */ +static void +ShowSettings(JNIEnv *env, char *optString) +{ + jclass cls; + jmethodID showSettingsID; + jstring joptString; + NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper")); + NULL_CHECK(showSettingsID = (*env)->GetStaticMethodID(env, cls, + "showSettings", "(ZLjava/lang/String;JJZ)V")); + joptString = (*env)->NewStringUTF(env, optString); + (*env)->CallStaticVoidMethod(env, cls, showSettingsID, + JNI_TRUE, + joptString, + (jlong)heapSize, + (jlong)threadStackSize, + ServerClassMachine()); +} + /* * Prints default usage or the Xusage message, see sun.launcher.LauncherHelper.java */ diff --git a/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java b/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java index 477806bd912f6e2cf851683107bfee938524f699..a782e8631e5a935c9dec9b3dba9813b0b7ca35a0 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java +++ b/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; /** * Adaptive coding. diff --git a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java index b662ebb9683ddfd1e5e4c6ccb8f3c29744fd32b1..7b838f26d022ddc35c6ec27787cf7ff5cb94d75b 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java @@ -25,9 +25,17 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * Represents an attribute in a class-file. diff --git a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java index 1c8266cd69f579b65f9b9c8fcd9f6d79e79d0a3c..7af5e38019d3ab1b3197d7ec4fc64b1bd8d87deb 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java +++ b/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java @@ -25,12 +25,28 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import java.util.jar.*; -import com.sun.java.util.jar.pack.Package.Class; -import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.Package.Class.Field; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.EOFException; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FilterInputStream; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.jar.Pack200; /** * Define the structure and ordering of "bands" in a packed file. @@ -1629,7 +1645,7 @@ class BandStructure implements Constants { } } - protected void setConstantValueIndex(Class.Field f) { + protected void setConstantValueIndex(com.sun.java.util.jar.pack.Package.Class.Field f) { Index ix = null; if (f != null) { byte tag = f.getLiteralTag(); diff --git a/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java b/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java index 356be128b450c14afeb0cda28fae068e7c5517a5..a1bce52a5e2b8e60587b248638b271372bc051ed 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java +++ b/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java @@ -25,11 +25,19 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.DataInputStream; +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Map; /** * Reader for a class file that is being incorporated into a package. diff --git a/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java b/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java index 516954c937a67e19c4b28f52111880d2d132dffc..a4ceff5768665b480255ba4fe3a047f008be89c4 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java +++ b/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java @@ -25,11 +25,19 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; + +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.NumberEntry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; +import java.util.List; /** * Writer for a class file that is incorporated into a package. diff --git a/src/share/classes/com/sun/java/util/jar/pack/Code.java b/src/share/classes/com/sun/java/util/jar/pack/Code.java index 3461d44293c171b69d229c54c85a142c9e000dbf..e6272f57a5bb528260c62818e9b5ef2454b8de13 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Code.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Code.java @@ -25,10 +25,10 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; import com.sun.java.util.jar.pack.Package.Class; import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Collection; /** * Represents a chunk of bytecodes. diff --git a/src/share/classes/com/sun/java/util/jar/pack/Coding.java b/src/share/classes/com/sun/java/util/jar/pack/Coding.java index 6e72d1baae8def13ab5aa316cb4ba9d817992b08..a35261f5db91bdcc65f79f786d29b19bc1cab487 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Coding.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Coding.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashMap; /** * Define the conversions between sequences of small integers and raw bytes. diff --git a/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java b/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java index 2f1f3e1b83900f3d014ac1c6fb4011688db7739e..61a6710a6f6d202208132ad92440b27d25e04122 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java +++ b/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java @@ -25,9 +25,17 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import java.util.zip.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.zip.Deflater; +import java.util.zip.DeflaterOutputStream; /** * Heuristic chooser of basic encodings. diff --git a/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java b/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java index 75f32a86118524d2d159299ba71266ce15c4ee5f..d0b1d9d9604a0cb436e58ed817ba17d5e44cca4d 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java +++ b/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java @@ -25,7 +25,9 @@ package com.sun.java.util.jar.pack; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; /** * Interface for encoding and decoding int arrays using bytewise codes. diff --git a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java index ac6199abe25e3dee29c821326bf683110e2f13a2..abafbd92b4096c644fdb74e7616a0c4844ed5b4d 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java +++ b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java @@ -25,7 +25,14 @@ package com.sun.java.util.jar.pack; -import java.util.*; +import java.util.AbstractList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; /** * Representation of constant pool entries and indexes. diff --git a/src/share/classes/com/sun/java/util/jar/pack/Constants.java b/src/share/classes/com/sun/java/util/jar/pack/Constants.java index 19ce04cf559612e4574d7dfc965a0e309a17e301..512dac7972fd09d803639a6a27c900ab081ddc91 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Constants.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Constants.java @@ -25,7 +25,8 @@ package com.sun.java.util.jar.pack; -import java.util.*; +import java.util.Arrays; +import java.util.List; /** * Shared constants diff --git a/src/share/classes/com/sun/java/util/jar/pack/Driver.java b/src/share/classes/com/sun/java/util/jar/pack/Driver.java index 2630febb7c35c721c54154cd3525f1fe03e28d9f..a7c47a8a8cc6b6e1f4f01031d73e5264927e4e06 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Driver.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Driver.java @@ -25,11 +25,32 @@ package com.sun.java.util.jar.pack; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; import java.text.MessageFormat; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; /** Command line interface for Pack200. */ diff --git a/src/share/classes/com/sun/java/util/jar/pack/Fixups.java b/src/share/classes/com/sun/java/util/jar/pack/Fixups.java index 3cb47069c8f3ee9334995202219f144cb58be8ee..77815b43b2275f05e88d3e872326fd465e09aab4 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Fixups.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Fixups.java @@ -25,9 +25,11 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import java.util.AbstractCollection; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; /** * Collection of relocatable constant pool references. diff --git a/src/share/classes/com/sun/java/util/jar/pack/Histogram.java b/src/share/classes/com/sun/java/util/jar/pack/Histogram.java index 1c03e592b0260e936b79371c39737de404fd921d..92cf6e4e918b36184eaa2b538966d607a43b27cf 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Histogram.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Histogram.java @@ -25,8 +25,10 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.util.Arrays; /** * Histogram derived from an integer array of events (int[]). diff --git a/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java b/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java index c6d9608518014840ae2750f3dcd118ee42436091..2ea9f4d4721c091b9e7a561576a5d0ed3ad796df 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java +++ b/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java @@ -26,10 +26,18 @@ package com.sun.java.util.jar.pack; -import java.nio.*; -import java.io.*; -import java.util.jar.*; -import java.util.zip.*; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.CRC32; +import java.util.zip.Deflater; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; class NativeUnpack { // Pointer to the native unpacker obj diff --git a/src/share/classes/com/sun/java/util/jar/pack/Package.java b/src/share/classes/com/sun/java/util/jar/pack/Package.java index 29d217687c49b1283ad03ba864bff6d24543509f..981bd53b75c67adbabb9ec9b02df6619e4bda90a 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Package.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Package.java @@ -26,11 +26,32 @@ package com.sun.java.util.jar.pack; import com.sun.java.util.jar.pack.Attribute.Layout; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.SequenceInputStream; import java.lang.reflect.Modifier; -import java.util.*; -import java.util.jar.*; -import java.io.*; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; +import java.util.jar.JarFile; /** * Define the main data structure transmitted by pack/unpack. diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java index 73efca5ca85e0f518663fc06d140a252643f29c2..be8ba0d008b0c0d7ac134d115ddcf42df05b579b 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java @@ -25,12 +25,18 @@ package com.sun.java.util.jar.pack; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; import java.io.*; import java.util.*; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.File; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; /** * Reader for a package file. diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java index 55b64cce5e851ca2bfa1072f419a17a088f524d3..cbfcb8aacfd0a13fbf283ffafc0e8d40fa6d91a0 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java @@ -25,12 +25,30 @@ package com.sun.java.util.jar.pack; -import java.io.*; -import java.util.*; +import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; +import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; +import com.sun.java.util.jar.pack.ConstantPool.Entry; +import com.sun.java.util.jar.pack.ConstantPool.Index; +import com.sun.java.util.jar.pack.ConstantPool.IndexGroup; +import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; +import com.sun.java.util.jar.pack.ConstantPool.NumberEntry; +import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; +import com.sun.java.util.jar.pack.ConstantPool.StringEntry; import com.sun.java.util.jar.pack.Package.Class; import com.sun.java.util.jar.pack.Package.File; import com.sun.java.util.jar.pack.Package.InnerClass; -import com.sun.java.util.jar.pack.ConstantPool.*; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; /** * Writer for a package file. diff --git a/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java b/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java index f48407099977518c970cb7b33bdf9858c669b64c..7e2f6a27c02f7bf6de89b495442783ff90980586 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java @@ -26,10 +26,27 @@ package com.sun.java.util.jar.pack; import com.sun.java.util.jar.pack.Attribute.Layout; -import java.util.*; -import java.util.jar.*; -import java.io.*; import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.SortedMap; +import java.util.TimeZone; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.Pack200; /* diff --git a/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java b/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java index 599d86fa6b2604e632257dd83ccb84d947673be0..3e5ecf170c3dd31b3279d4e0ee3cabef46302923 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java @@ -25,8 +25,12 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.HashSet; /** * Population-based coding. diff --git a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java index 78c709f343d554c5b2c25699a10574f29c9cd734..3072ef394eb0ddb53027fcf227063e94d821a539 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java +++ b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java @@ -25,13 +25,24 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.util.jar.*; -import java.util.jar.Pack200; -import java.util.zip.*; -import java.io.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.jar.Pack200; /** * Control block for publishing Pack200 options to the other classes. */ diff --git a/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java b/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java index 5b9f8ec61f6ee56434660cce13aa738f1ec41df8..a0c1e4d26ef457e873c5ce658fb66974b38077ca 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java +++ b/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java @@ -25,11 +25,25 @@ package com.sun.java.util.jar.pack; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; -import java.io.*; import java.beans.PropertyChangeListener; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashSet; +import java.util.Iterator; +import java.util.SortedMap; +import java.util.TimeZone; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.jar.Pack200; +import java.util.zip.CRC32; +import java.util.zip.CheckedOutputStream; +import java.util.zip.ZipEntry; /* * Implementation of the Pack provider. diff --git a/src/share/classes/com/sun/java/util/jar/pack/Utils.java b/src/share/classes/com/sun/java/util/jar/pack/Utils.java index 84f65ac2ccfcbbbc769f769e95b43eeef2c6b8da..d14d59926ca60471f10e6b7b2f150ce2bfc105b7 100644 --- a/src/share/classes/com/sun/java/util/jar/pack/Utils.java +++ b/src/share/classes/com/sun/java/util/jar/pack/Utils.java @@ -25,18 +25,27 @@ package com.sun.java.util.jar.pack; -import com.sun.java.util.jar.pack.Attribute.Layout; import com.sun.java.util.jar.pack.ConstantPool.ClassEntry; import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry; import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry; import com.sun.java.util.jar.pack.ConstantPool.MemberEntry; import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry; import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry; -import java.util.*; -import java.util.jar.*; -import java.util.zip.*; -import java.io.*; - +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Date; +import java.util.Enumeration; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarInputStream; +import java.util.jar.JarOutputStream; +import java.util.zip.ZipEntry; import sun.util.logging.PlatformLogger; class Utils { diff --git a/src/share/classes/com/sun/net/httpserver/HttpsConfigurator.java b/src/share/classes/com/sun/net/httpserver/HttpsConfigurator.java index a299c1acf5eab9346e30614dede36dd632a83bc5..355242b8aa4aa2d393b4e1f28a61718d7c6e2bee 100644 --- a/src/share/classes/com/sun/net/httpserver/HttpsConfigurator.java +++ b/src/share/classes/com/sun/net/httpserver/HttpsConfigurator.java @@ -91,6 +91,7 @@ public class HttpsConfigurator { return context; } +//BEGIN_TIGER_EXCLUDE /** * Called by the HttpsServer to configure the parameters * for a https connection currently being established. @@ -111,4 +112,5 @@ public class HttpsConfigurator { public void configure (HttpsParameters params) { params.setSSLParameters (getSSLContext().getDefaultSSLParameters()); } +//END_TIGER_EXCLUDE } diff --git a/src/share/classes/com/sun/net/httpserver/HttpsParameters.java b/src/share/classes/com/sun/net/httpserver/HttpsParameters.java index c54e917c02ea38ca50ce120a9ee168fe197e06b0..d4dc1ee3cf8248d239a47c332e2d28897a6571c5 100644 --- a/src/share/classes/com/sun/net/httpserver/HttpsParameters.java +++ b/src/share/classes/com/sun/net/httpserver/HttpsParameters.java @@ -25,7 +25,9 @@ package com.sun.net.httpserver; import java.net.InetSocketAddress; +//BEGIN_TIGER_EXCLUDE import javax.net.ssl.SSLParameters; +//END_TIGER_EXCLUDE /** * Represents the set of parameters for each https @@ -67,6 +69,7 @@ public abstract class HttpsParameters { */ public abstract InetSocketAddress getClientAddress(); +//BEGIN_TIGER_EXCLUDE /** * Sets the SSLParameters to use for this HttpsParameters. * The parameters must be supported by the SSLContext contained @@ -79,6 +82,7 @@ public abstract class HttpsParameters { * invalid or unsupported. */ public abstract void setSSLParameters (SSLParameters params); +//END_TIGER_EXCLUDE /** * Returns a copy of the array of ciphersuites or null if none diff --git a/src/share/classes/com/sun/rowset/RowSetResourceBundle.properties b/src/share/classes/com/sun/rowset/RowSetResourceBundle.properties index fce926ea4efaaef4ccbbb268307b8a099535950f..47ad98d28aec6157e89526bd35796ee0f79a0612 100644 --- a/src/share/classes/com/sun/rowset/RowSetResourceBundle.properties +++ b/src/share/classes/com/sun/rowset/RowSetResourceBundle.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2010, 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 @@ -140,7 +140,7 @@ syncrsimpl.valtores = Value to be resolved can either be in the database or in c #WebRowSetXmlReader exception wrsxmlreader.invalidcp = End of RowSet reached. Invalid cursor position wrsxmlreader.readxml = readXML : {0} -wrsxmlreader.parseerr = ** Parsing Error : {0} , line : {0} , uri : {0} +wrsxmlreader.parseerr = ** Parsing Error : {0} , line : {1} , uri : {2} #WebRowSetXmlWriter exceptions wrsxmlwriter.ioex = IOException : {0} @@ -151,7 +151,7 @@ wsrxmlwriter.notproper = Not a proper type #XmlReaderContentHandler exceptions xmlrch.errmap = Error setting Map : {0} xmlrch.errmetadata = Error setting metadata : {0} -xmlrch.errinsert = Error inserting values : {0} +xmlrch.errinsertval = Error inserting values : {0} xmlrch.errconstr = Error constructing row : {0} xmlrch.errdel = Error deleting row : {0} xmlrch.errinsert = Error constructing insert row : {0} @@ -161,7 +161,7 @@ xmlrch.errupdrow = Error updating row : {0} xmlrch.chars = characters : xmlrch.badvalue = Bad value ; non-nullable property xmlrch.badvalue1 = Bad value ; non-nullable metadata -xmlrch.warning = ** Warning : {0} , line : {0} , uri : {0} +xmlrch.warning = ** Warning : {0} , line : {1} , uri : {2} #RIOptimisticProvider Exceptions riop.locking = Locking classification is not supported diff --git a/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java b/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java index 5008a289e20ceeb350a85bc5b5647c19ce9870f8..47b78fd82859b4179513bf7ae0328242b90e1582 100644 --- a/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java +++ b/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java @@ -738,7 +738,7 @@ public class XmlReaderContentHandler extends DefaultHandler { // columnValue now need to be reset to the empty string columnValue = ""; } catch (SQLException ex) { - throw new SAXException(MessageFormat.format(resBundle.handleGetObject("xmlrch.errinsert").toString(), ex.getMessage())); + throw new SAXException(MessageFormat.format(resBundle.handleGetObject("xmlrch.errinsertval").toString(), ex.getMessage())); } break; case RowTag: diff --git a/src/share/classes/java/awt/Color.java b/src/share/classes/java/awt/Color.java index 8cbe667ca000e364b2577ee974ddf65dcd787dd9..2ff9a6d5e1b96e3f20adc4df0b41d5026e2b2d64 100644 --- a/src/share/classes/java/awt/Color.java +++ b/src/share/classes/java/awt/Color.java @@ -611,12 +611,15 @@ public class Color implements Paint, java.io.Serializable { *

* This method applies an arbitrary scale factor to each of the three RGB * components of this Color to create a brighter version - * of this Color. Although brighter and + * of this Color. + * The {@code alpha} value is preserved. + * Although brighter and * darker are inverse operations, the results of a * series of invocations of these two methods might be inconsistent * because of rounding errors. * @return a new Color object that is - * a brighter version of this Color. + * a brighter version of this Color + * with the same {@code alpha} value. * @see java.awt.Color#darker * @since JDK1.0 */ @@ -624,6 +627,7 @@ public class Color implements Paint, java.io.Serializable { int r = getRed(); int g = getGreen(); int b = getBlue(); + int alpha = getAlpha(); /* From 2D group: * 1. black.brighter() should return grey @@ -632,7 +636,7 @@ public class Color implements Paint, java.io.Serializable { */ int i = (int)(1.0/(1.0-FACTOR)); if ( r == 0 && g == 0 && b == 0) { - return new Color(i, i, i); + return new Color(i, i, i, alpha); } if ( r > 0 && r < i ) r = i; if ( g > 0 && g < i ) g = i; @@ -640,7 +644,8 @@ public class Color implements Paint, java.io.Serializable { return new Color(Math.min((int)(r/FACTOR), 255), Math.min((int)(g/FACTOR), 255), - Math.min((int)(b/FACTOR), 255)); + Math.min((int)(b/FACTOR), 255), + alpha); } /** @@ -649,19 +654,23 @@ public class Color implements Paint, java.io.Serializable { *

* This method applies an arbitrary scale factor to each of the three RGB * components of this Color to create a darker version of - * this Color. Although brighter and + * this Color. + * The {@code alpha} value is preserved. + * Although brighter and * darker are inverse operations, the results of a series * of invocations of these two methods might be inconsistent because * of rounding errors. * @return a new Color object that is - * a darker version of this Color. + * a darker version of this Color + * with the same {@code alpha} value. * @see java.awt.Color#brighter * @since JDK1.0 */ public Color darker() { return new Color(Math.max((int)(getRed() *FACTOR), 0), Math.max((int)(getGreen()*FACTOR), 0), - Math.max((int)(getBlue() *FACTOR), 0)); + Math.max((int)(getBlue() *FACTOR), 0), + getAlpha()); } /** diff --git a/src/share/classes/java/awt/Container.java b/src/share/classes/java/awt/Container.java index a7ee77e16cbf5a711e34256fade7a0d46796b97e..8a463b005e4a6ec1f44f18e4d659a29a66acec37 100644 --- a/src/share/classes/java/awt/Container.java +++ b/src/share/classes/java/awt/Container.java @@ -51,6 +51,7 @@ import javax.accessibility.*; import sun.util.logging.PlatformLogger; import sun.awt.AppContext; +import sun.awt.AWTAccessor; import sun.awt.CausedFocusEvent; import sun.awt.PeerEvent; import sun.awt.SunToolkit; @@ -247,6 +248,13 @@ public class Container extends Component { if (!GraphicsEnvironment.isHeadless()) { initIDs(); } + + AWTAccessor.setContainerAccessor(new AWTAccessor.ContainerAccessor() { + @Override + public void validateUnconditionally(Container cont) { + cont.validateUnconditionally(); + } + }); } /** diff --git a/src/share/classes/java/awt/Dialog.java b/src/share/classes/java/awt/Dialog.java index b408148b1cb8b410533ad70047122443c71ebd36..c3a87bda6ad063e00c8fde6b37eb642c03fd052d 100644 --- a/src/share/classes/java/awt/Dialog.java +++ b/src/share/classes/java/awt/Dialog.java @@ -1248,14 +1248,31 @@ public class Dialog extends Window { /** * Disables or enables decorations for this dialog. - * This method can only be called while the dialog is not displayable. - * @param undecorated true if no dialog decorations are - * to be enabled; - * false if dialog decorations are to be enabled. - * @throws IllegalComponentStateException if the dialog - * is displayable. + *

+ * This method can only be called while the dialog is not displayable. To + * make this dialog decorated, it must be opaque and have the default shape, + * otherwise the {@code IllegalComponentStateException} will be thrown. + * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link + * Window#setBackground} for details + * + * @param undecorated {@code true} if no dialog decorations are to be + * enabled; {@code false} if dialog decorations are to be enabled + * + * @throws IllegalComponentStateException if the dialog is displayable + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this dialog does not have the default shape + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this dialog opacity is less than {@code 1.0f} + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and the alpha value of this dialog background + * color is less than {@code 1.0f} + * * @see #isUndecorated * @see Component#isDisplayable + * @see Window#getShape + * @see Window#getOpacity + * @see Window#getBackground + * * @since 1.4 */ public void setUndecorated(boolean undecorated) { @@ -1264,6 +1281,18 @@ public class Dialog extends Window { if (isDisplayable()) { throw new IllegalComponentStateException("The dialog is displayable."); } + if (!undecorated) { + if (getOpacity() < 1.0f) { + throw new IllegalComponentStateException("The dialog is not opaque"); + } + if (getShape() != null) { + throw new IllegalComponentStateException("The dialog does not have a default shape"); + } + Color bg = getBackground(); + if ((bg != null) && (bg.getAlpha() < 255)) { + throw new IllegalComponentStateException("The dialog background color is not opaque"); + } + } this.undecorated = undecorated; } } @@ -1280,6 +1309,45 @@ public class Dialog extends Window { return undecorated; } + /** + * {@inheritDoc} + */ + @Override + public void setOpacity(float opacity) { + synchronized (getTreeLock()) { + if ((opacity < 1.0f) && !isUndecorated()) { + throw new IllegalComponentStateException("The dialog is decorated"); + } + super.setOpacity(opacity); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setShape(Shape shape) { + synchronized (getTreeLock()) { + if ((shape != null) && !isUndecorated()) { + throw new IllegalComponentStateException("The dialog is decorated"); + } + super.setShape(shape); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setBackground(Color bgColor) { + synchronized (getTreeLock()) { + if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) { + throw new IllegalComponentStateException("The dialog is decorated"); + } + super.setBackground(bgColor); + } + } + /** * Returns a string representing the state of this dialog. This * method is intended to be used only for debugging purposes, and the diff --git a/src/share/classes/java/awt/FileDialog.java b/src/share/classes/java/awt/FileDialog.java index 033b7660d0edbf36ab1af970cfc13437db93f755..5e35bfe2ea90d3d0a16257b07b5d9763157d4192 100644 --- a/src/share/classes/java/awt/FileDialog.java +++ b/src/share/classes/java/awt/FileDialog.java @@ -99,7 +99,7 @@ public class FileDialog extends Dialog { * Contains the File instances for all the files that the user selects. * * @serial - * @see getFiles + * @see #getFiles * @since 1.7 */ private File[] files; diff --git a/src/share/classes/java/awt/Frame.java b/src/share/classes/java/awt/Frame.java index f69e02f5239aa9453736c422528ba940d444fede..bd2539f055bd7a12ac8f28e589e2506d32929ea4 100644 --- a/src/share/classes/java/awt/Frame.java +++ b/src/share/classes/java/awt/Frame.java @@ -828,6 +828,11 @@ public class Frame extends Window implements MenuContainer { return frame.state; } } + public Rectangle getMaximizedBounds(Frame frame) { + synchronized(frame.getObjectLock()) { + return frame.maximizedBounds; + } + } } ); } @@ -855,8 +860,10 @@ public class Frame extends Window implements MenuContainer { * @see #getMaximizedBounds() * @since 1.4 */ - public synchronized void setMaximizedBounds(Rectangle bounds) { - this.maximizedBounds = bounds; + public void setMaximizedBounds(Rectangle bounds) { + synchronized(getObjectLock()) { + this.maximizedBounds = bounds; + } FramePeer peer = (FramePeer)this.peer; if (peer != null) { peer.setMaximizedBounds(bounds); @@ -873,21 +880,40 @@ public class Frame extends Window implements MenuContainer { * @since 1.4 */ public Rectangle getMaximizedBounds() { - return maximizedBounds; + synchronized(getObjectLock()) { + return maximizedBounds; + } } /** * Disables or enables decorations for this frame. - * This method can only be called while the frame is not displayable. - * @param undecorated true if no frame decorations are - * to be enabled; - * false if frame decorations are to be enabled. - * @throws IllegalComponentStateException if the frame - * is displayable. + *

+ * This method can only be called while the frame is not displayable. To + * make this frame decorated, it must be opaque and have the default shape, + * otherwise the {@code IllegalComponentStateException} will be thrown. + * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link + * Window#setBackground} for details + * + * @param undecorated {@code true} if no frame decorations are to be + * enabled; {@code false} if frame decorations are to be enabled + * + * @throws IllegalComponentStateException if the frame is displayable + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this frame does not have the default shape + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and this frame opacity is less than {@code 1.0f} + * @throws IllegalComponentStateException if {@code undecorated} is + * {@code false}, and the alpha value of this frame background + * color is less than {@code 1.0f} + * * @see #isUndecorated * @see Component#isDisplayable + * @see Window#getShape + * @see Window#getOpacity + * @see Window#getBackground * @see javax.swing.JFrame#setDefaultLookAndFeelDecorated(boolean) + * * @since 1.4 */ public void setUndecorated(boolean undecorated) { @@ -896,6 +922,18 @@ public class Frame extends Window implements MenuContainer { if (isDisplayable()) { throw new IllegalComponentStateException("The frame is displayable."); } + if (!undecorated) { + if (getOpacity() < 1.0f) { + throw new IllegalComponentStateException("The frame is not opaque"); + } + if (getShape() != null) { + throw new IllegalComponentStateException("The frame does not have a default shape"); + } + Color bg = getBackground(); + if ((bg != null) && (bg.getAlpha() < 255)) { + throw new IllegalComponentStateException("The frame background color is not opaque"); + } + } this.undecorated = undecorated; } } @@ -912,6 +950,45 @@ public class Frame extends Window implements MenuContainer { return undecorated; } + /** + * {@inheritDoc} + */ + @Override + public void setOpacity(float opacity) { + synchronized (getTreeLock()) { + if ((opacity < 1.0f) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setOpacity(opacity); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setShape(Shape shape) { + synchronized (getTreeLock()) { + if ((shape != null) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setShape(shape); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void setBackground(Color bgColor) { + synchronized (getTreeLock()) { + if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) { + throw new IllegalComponentStateException("The frame is decorated"); + } + super.setBackground(bgColor); + } + } + /** * Removes the specified menu bar from this frame. * @param m the menu component to remove. diff --git a/src/share/classes/java/awt/Window.java b/src/share/classes/java/awt/Window.java index 03dbd535e9f0d5f146c83ba2ad6247399096e1e6..064c8494f4e969479a92cf648b04ae7975af58db 100644 --- a/src/share/classes/java/awt/Window.java +++ b/src/share/classes/java/awt/Window.java @@ -3474,14 +3474,20 @@ public class Window extends Container implements Accessible { * level of 0 may or may not disable the mouse event handling on this * window. This is a platform-dependent behavior. *

- * In order for this method to enable the translucency effect, the {@link - * GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)} method must indicate that - * the {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} - * translucency is supported. + * The following conditions must be met in order to set the opacity value + * less than {@code 1.0f}: + *

*

- * Also note that the window must not be in the full-screen mode when - * setting the opacity value < 1.0f. Otherwise the {@code - * IllegalComponentStateException} is thrown. + * If the requested opacity value is less than {@code 1.0f}, and any of the + * above conditions are not met, the window opacity will not change, + * and the {@code IllegalComponentStateException} will be thrown. *

* The translucency levels of individual pixels may also be effected by the * alpha component of their color (see {@link Window#setBackground(Color)}) and the @@ -3491,15 +3497,20 @@ public class Window extends Container implements Accessible { * * @throws IllegalArgumentException if the opacity is out of the range * [0..1] + * @throws IllegalComponentStateException if the window is decorated and + * the opacity is less than {@code 1.0f} * @throws IllegalComponentStateException if the window is in full screen - * mode, and the opacity is less than 1.0f + * mode, and the opacity is less than {@code 1.0f} * @throws UnsupportedOperationException if the {@code * GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT} - * translucency kind is not supported and the opacity is less than 1.0f + * translucency is not supported and the opacity is less than + * {@code 1.0f} * * @see Window#getOpacity * @see Window#setBackground(Color) * @see Window#setShape(Shape) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @@ -3557,24 +3568,26 @@ public class Window extends Container implements Accessible { /** * Sets the shape of the window. *

- * Setting a shape enables cutting off some parts of the window, leaving - * visible and clickable only those parts belonging to the given shape - * (see {@link Shape}). If the shape argument is null, this methods - * restores the default shape (making the window rectangular on most - * platforms.) + * Setting a shape cuts off some parts of the window. Only the parts that + * belong to the given {@link Shape} remain visible and clickable. If + * the shape argument is {@code null}, this method restores the default + * shape, making the window rectangular on most platforms. *

- * The following conditions must be met in order to set a non-null shape: + * The following conditions must be met to set a non-null shape: *

- * If a certain condition is not met, either the {@code - * UnsupportedOperationException} or {@code IllegalComponentStateException} - * is thrown. + *

+ * If the requested shape is not {@code null}, and any of the above + * conditions are not met, the shape of this window will not change, + * and either the {@code UnsupportedOperationException} or {@code + * IllegalComponentStateException} will be thrown. *

* The tranlucency levels of individual pixels may also be effected by the * alpha component of their color (see {@link Window#setBackground(Color)}) and the @@ -3584,6 +3597,8 @@ public class Window extends Container implements Accessible { * @param shape the shape to set to the window * * @throws IllegalComponentStateException if the shape is not {@code + * null} and the window is decorated + * @throws IllegalComponentStateException if the shape is not {@code * null} and the window is in full-screen mode * @throws UnsupportedOperationException if the shape is not {@code * null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT @@ -3592,6 +3607,8 @@ public class Window extends Container implements Accessible { * @see Window#getShape() * @see Window#setBackground(Color) * @see Window#setOpacity(float) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @@ -3645,37 +3662,46 @@ public class Window extends Container implements Accessible { * GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT PERPIXEL_TRANSLUCENT} * tranclucency, the alpha component of the given background color * may effect the mode of operation for this window: it indicates whether - * this window must be opaque (alpha == 1.0f) or per-pixel translucent - * (alpha < 1.0f). All the following conditions must be met in order - * to be able to enable the per-pixel transparency mode for this window: + * this window must be opaque (alpha equals {@code 1.0f}) or per-pixel translucent + * (alpha is less than {@code 1.0f}). If the given background color is + * {@code null}, the window is considered completely opaque. + *

+ * All the following conditions must be met to enable the per-pixel + * transparency mode for this window: *

- * If a certain condition is not met at the time of calling this method, - * the alpha component of the given background color will not effect the - * mode of operation for this window. + *

+ * If the alpha component of the requested background color is less than + * {@code 1.0f}, and any of the above conditions are not met, the background + * color of this window will not change, the alpha component of the given + * background color will not affect the mode of operation for this window, + * and either the {@code UnsupportedOperationException} or {@code + * IllegalComponentStateException} will be thrown. *

* When the window is per-pixel translucent, the drawing sub-system * respects the alpha value of each individual pixel. If a pixel gets * painted with the alpha color component equal to zero, it becomes - * visually transparent, if the alpha of the pixel is equal to 1.0f, the + * visually transparent. If the alpha of the pixel is equal to 1.0f, the * pixel is fully opaque. Interim values of the alpha color component make - * the pixel semi-transparent. In this mode the background of the window - * gets painted with the alpha value of the given background color (meaning - * that it is not painted at all if the alpha value of the argument of this - * method is equal to zero.) + * the pixel semi-transparent. In this mode, the background of the window + * gets painted with the alpha value of the given background color. If the + * alpha value of the argument of this method is equal to {@code 0}, the + * background is not painted at all. *

* The actual level of translucency of a given pixel also depends on window * opacity (see {@link #setOpacity(float)}), as well as the current shape of * this window (see {@link #setShape(Shape)}). *

- * Note that painting a pixel with the alpha value of 0 may or may not - * disable the mouse event handling on this pixel. This is a - * platform-dependent behavior. To make sure the mouse clicks do not get + * Note that painting a pixel with the alpha value of {@code 0} may or may + * not disable the mouse event handling on this pixel. This is a + * platform-dependent behavior. To make sure the mouse events do not get * dispatched to a particular pixel, the pixel must be excluded from the * shape of the window. *

@@ -3685,17 +3711,21 @@ public class Window extends Container implements Accessible { * @param bgColor the color to become this window's background color. * * @throws IllegalComponentStateException if the alpha value of the given - * background color is less than 1.0f and the window is in + * background color is less than {@code 1.0f} and the window is decorated + * @throws IllegalComponentStateException if the alpha value of the given + * background color is less than {@code 1.0f} and the window is in * full-screen mode * @throws UnsupportedOperationException if the alpha value of the given - * background color is less than 1.0f and - * {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT + * background color is less than {@code 1.0f} and {@link + * GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT * PERPIXEL_TRANSLUCENT} translucency is not supported * * @see Window#getBackground * @see Window#isOpaque * @see Window#setOpacity(float) * @see Window#setShape(Shape) + * @see Frame#isUndecorated + * @see Dialog#isUndecorated * @see GraphicsDevice.WindowTranslucency * @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency) * @see GraphicsConfiguration#isTranslucencyCapable() @@ -3739,7 +3769,7 @@ public class Window extends Container implements Accessible { *

* The method returns {@code false} if the background color of the window * is not {@code null} and the alpha component of the color is less than - * 1.0f. The method returns {@code true} otherwise. + * {@code 1.0f}. The method returns {@code true} otherwise. * * @return {@code true} if the window is opaque, {@code false} otherwise * diff --git a/src/share/classes/java/io/BufferedInputStream.java b/src/share/classes/java/io/BufferedInputStream.java index d61f74bcbd38189f986c50ed28c38af2049c6106..73885f318d9b69a6c8b78a01cfde31adfcca3b12 100644 --- a/src/share/classes/java/io/BufferedInputStream.java +++ b/src/share/classes/java/io/BufferedInputStream.java @@ -395,7 +395,11 @@ class BufferedInputStream extends FilterInputStream { * or an I/O error occurs. */ public synchronized int available() throws IOException { - return getInIfOpen().available() + (count - pos); + int n = count - pos; + int avail = getInIfOpen().available(); + return n > (Integer.MAX_VALUE - avail) + ? Integer.MAX_VALUE + : n + avail; } /** diff --git a/src/share/classes/java/io/PushbackInputStream.java b/src/share/classes/java/io/PushbackInputStream.java index 1984247e57573c4179c80106d6e3c2abb886db3d..0a8e0c9cf64acfb7873792674969d8a60ec0d576 100644 --- a/src/share/classes/java/io/PushbackInputStream.java +++ b/src/share/classes/java/io/PushbackInputStream.java @@ -273,7 +273,11 @@ class PushbackInputStream extends FilterInputStream { */ public int available() throws IOException { ensureOpen(); - return (buf.length - pos) + super.available(); + int n = buf.length - pos; + int avail = super.available(); + return n > (Integer.MAX_VALUE - avail) + ? Integer.MAX_VALUE + : n + avail; } /** diff --git a/src/share/classes/java/lang/Readable.java b/src/share/classes/java/lang/Readable.java index c97d792cca8c7b65376829bbb4221a60c5b58a97..51279ef27ec186dcdaabc5bfd0d6afb927dee94b 100644 --- a/src/share/classes/java/lang/Readable.java +++ b/src/share/classes/java/lang/Readable.java @@ -44,11 +44,11 @@ public interface Readable { * rewinding of the buffer is performed. * * @param cb the buffer to read characters into - * @return @return The number of char values added to the buffer, + * @return The number of {@code char} values added to the buffer, * or -1 if this source of characters is at its end * @throws IOException if an I/O error occurs * @throws NullPointerException if cb is null - * @throws ReadOnlyBufferException if cb is a read only buffer + * @throws java.nio.ReadOnlyBufferException if cb is a read only buffer */ public int read(java.nio.CharBuffer cb) throws IOException; diff --git a/src/share/classes/java/nio/StringCharBuffer.java b/src/share/classes/java/nio/StringCharBuffer.java index b5df238573c1a09509b7092434d56a42668cb30e..52d7a2087a500371e2b54e63976d8b92064ff4e3 100644 --- a/src/share/classes/java/nio/StringCharBuffer.java +++ b/src/share/classes/java/nio/StringCharBuffer.java @@ -47,7 +47,7 @@ class StringCharBuffer // package-private 0, this.remaining(), this.remaining(), - this.position()); + offset + this.position()); } private StringCharBuffer(CharSequence s, diff --git a/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java b/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java index d37bd2efc463d7750a37dd4ddb14c972e55802ca..6d04f4f52a2a74309bb8eeb4d88435f566c30772 100644 --- a/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java +++ b/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java @@ -110,7 +110,8 @@ import java.nio.ByteBuffer; * state of the {@link ByteBuffer}, or the sequence of buffers, for the I/O * operation is not defined. Buffers should be discarded or at least care must * be taken to ensure that the buffers are not accessed while the channel remains - * open. + * open. All methods that accept timeout parameters treat values less than or + * equal to zero to mean that the I/O operation does not timeout. * * @since 1.7 */ @@ -367,7 +368,7 @@ public abstract class AsynchronousSocketChannel * @param dst * The buffer into which bytes are to be transferred * @param timeout - * The timeout, or {@code 0L} for no timeout + * The maximum time for the I/O operation to complete * @param unit * The time unit of the {@code timeout} argument * @param attachment @@ -376,8 +377,7 @@ public abstract class AsynchronousSocketChannel * The handler for consuming the result * * @throws IllegalArgumentException - * If the {@code timeout} parameter is negative or the buffer is - * read-only + * If the buffer is read-only * @throws ReadPendingException * If a read operation is already in progress on this channel * @throws NotYetConnectedException @@ -471,7 +471,7 @@ public abstract class AsynchronousSocketChannel * The maximum number of buffers to be accessed; must be non-negative * and no larger than {@code dsts.length - offset} * @param timeout - * The timeout, or {@code 0L} for no timeout + * The maximum time for the I/O operation to complete * @param unit * The time unit of the {@code timeout} argument * @param attachment @@ -483,8 +483,7 @@ public abstract class AsynchronousSocketChannel * If the pre-conditions for the {@code offset} and {@code length} * parameter aren't met * @throws IllegalArgumentException - * If the {@code timeout} parameter is negative, or a buffer is - * read-only + * If the buffer is read-only * @throws ReadPendingException * If a read operation is already in progress on this channel * @throws NotYetConnectedException @@ -524,7 +523,7 @@ public abstract class AsynchronousSocketChannel * @param src * The buffer from which bytes are to be retrieved * @param timeout - * The timeout, or {@code 0L} for no timeout + * The maximum time for the I/O operation to complete * @param unit * The time unit of the {@code timeout} argument * @param attachment @@ -532,8 +531,6 @@ public abstract class AsynchronousSocketChannel * @param handler * The handler for consuming the result * - * @throws IllegalArgumentException - * If the {@code timeout} parameter is negative * @throws WritePendingException * If a write operation is already in progress on this channel * @throws NotYetConnectedException @@ -623,7 +620,7 @@ public abstract class AsynchronousSocketChannel * The maximum number of buffers to be accessed; must be non-negative * and no larger than {@code srcs.length - offset} * @param timeout - * The timeout, or {@code 0L} for no timeout + * The maximum time for the I/O operation to complete * @param unit * The time unit of the {@code timeout} argument * @param attachment @@ -634,8 +631,6 @@ public abstract class AsynchronousSocketChannel * @throws IndexOutOfBoundsException * If the pre-conditions for the {@code offset} and {@code length} * parameter aren't met - * @throws IllegalArgumentException - * If the {@code timeout} parameter is negative * @throws WritePendingException * If a write operation is already in progress on this channel * @throws NotYetConnectedException diff --git a/src/share/classes/java/sql/SQLPermission.java b/src/share/classes/java/sql/SQLPermission.java index e7e799c1caca038fb4defc9d04046693f00f705d..9f45718853d020c53690e4b3fe7a4552c680671f 100644 --- a/src/share/classes/java/sql/SQLPermission.java +++ b/src/share/classes/java/sql/SQLPermission.java @@ -84,7 +84,7 @@ import java.security.*; * {@code setJNDIContext} and {@code setLogger} * Permits an application to specify the JNDI context from which the * {@code SyncProvider} implementations can be retrieved from and the logging - * object to be used by the{@codeSyncProvider} implementation. + * object to be used by the {@code SyncProvider} implementation. * * * diff --git a/src/share/classes/java/util/Formatter.java b/src/share/classes/java/util/Formatter.java index 55fd610d39d53244b9d9c389708a00aacf9f1bd3..6e115b5156b43d3cbf80e5d8880fe4db9f188edf 100644 --- a/src/share/classes/java/util/Formatter.java +++ b/src/share/classes/java/util/Formatter.java @@ -1581,6 +1581,7 @@ import sun.misc.FormattedFloatingDecimal; * instance of the Java virtual machine. * * {@code 'Z'} + * '\u005a' * A string representing the abbreviation for the time zone. This * value will be adjusted as necessary for Daylight Saving Time. For * {@code long}, {@link Long}, and {@link Date} the time zone used is diff --git a/src/share/classes/javax/security/auth/Policy.java b/src/share/classes/javax/security/auth/Policy.java index 6c508b2ce95eb5cd68ae57ee9e21c0250893796d..88264b3fc49e9d1f17b5f8bd7f9c43a901ca9d7c 100644 --- a/src/share/classes/javax/security/auth/Policy.java +++ b/src/share/classes/javax/security/auth/Policy.java @@ -25,6 +25,9 @@ package javax.security.auth; +import java.security.Security; +import sun.security.util.Debug; + /** *

This is an abstract class for representing the system policy for * Subject-based authorization. A subclass implementation @@ -159,6 +162,10 @@ public abstract class Policy { private static Policy policy; private static ClassLoader contextClassLoader; + // true if a custom (not com.sun.security.auth.PolicyFile) system-wide + // policy object is set + private static boolean isCustomPolicy; + static { contextClassLoader = java.security.AccessController.doPrivileged (new java.security.PrivilegedAction() { @@ -234,6 +241,8 @@ public abstract class Policy { contextClassLoader).newInstance(); } }); + isCustomPolicy = + !finalClass.equals("com.sun.security.auth.PolicyFile"); } catch (Exception e) { throw new SecurityException (sun.security.util.ResourcesMgr.getString @@ -265,6 +274,46 @@ public abstract class Policy { java.lang.SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(new AuthPermission("setPolicy")); Policy.policy = policy; + // all non-null policy objects are assumed to be custom + isCustomPolicy = policy != null ? true : false; + } + + /** + * Returns true if a custom (not com.sun.security.auth.PolicyFile) + * system-wide policy object has been set or installed. This method is + * called by SubjectDomainCombiner to provide backwards compatibility for + * developers that provide their own javax.security.auth.Policy + * implementations. + * + * @return true if a custom (not com.sun.security.auth.PolicyFile) + * system-wide policy object has been set; false otherwise + */ + static boolean isCustomPolicySet(Debug debug) { + if (policy != null) { + if (debug != null && isCustomPolicy) { + debug.println("Providing backwards compatibility for " + + "javax.security.auth.policy implementation: " + + policy.toString()); + } + return isCustomPolicy; + } + // check if custom policy has been set using auth.policy.provider prop + String policyClass = java.security.AccessController.doPrivileged + (new java.security.PrivilegedAction() { + public String run() { + return Security.getProperty("auth.policy.provider"); + } + }); + if (policyClass != null + && !policyClass.equals("com.sun.security.auth.PolicyFile")) { + if (debug != null) { + debug.println("Providing backwards compatibility for " + + "javax.security.auth.policy implementation: " + + policyClass); + } + return true; + } + return false; } /** diff --git a/src/share/classes/javax/security/auth/SubjectDomainCombiner.java b/src/share/classes/javax/security/auth/SubjectDomainCombiner.java index 00d57f6c6daa59684d91a6a69842995cd2f72bcd..9dc82fc0153a37f72c6114847a4ecec21e569f68 100644 --- a/src/share/classes/javax/security/auth/SubjectDomainCombiner.java +++ b/src/share/classes/javax/security/auth/SubjectDomainCombiner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2010, 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 @@ -26,8 +26,6 @@ package javax.security.auth; import java.security.AccessController; -import java.security.AccessControlContext; -import java.security.AllPermission; import java.security.Permission; import java.security.Permissions; import java.security.PermissionCollection; @@ -35,10 +33,8 @@ import java.security.Policy; import java.security.Principal; import java.security.PrivilegedAction; import java.security.ProtectionDomain; -import java.lang.ClassLoader; import java.security.Security; import java.util.Set; -import java.util.Iterator; import java.util.WeakHashMap; import java.lang.ref.WeakReference; @@ -61,7 +57,8 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { "\t[SubjectDomainCombiner]"); // Note: check only at classloading time, not dynamically during combine() - private static final boolean useJavaxPolicy = compatPolicy(); + private static final boolean useJavaxPolicy = + javax.security.auth.Policy.isCustomPolicySet(debug); // Relevant only when useJavaxPolicy is true private static final boolean allowCaching = @@ -202,8 +199,8 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { return null; } - // maintain backwards compatibility for people who provide - // their own javax.security.auth.Policy implementations + // maintain backwards compatibility for developers who provide + // their own custom javax.security.auth.Policy implementations if (useJavaxPolicy) { return combineJavaxPolicy(currentDomains, assignedDomains); } @@ -476,8 +473,7 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { String s = AccessController.doPrivileged (new PrivilegedAction() { public String run() { - return java.security.Security.getProperty - ("cache.auth.policy"); + return Security.getProperty("cache.auth.policy"); } }); if (s != null) { @@ -488,29 +484,6 @@ public class SubjectDomainCombiner implements java.security.DomainCombiner { return true; } - // maintain backwards compatibility for people who provide - // their own javax.security.auth.Policy implementations - private static boolean compatPolicy() { - javax.security.auth.Policy javaxPolicy = AccessController.doPrivileged - (new PrivilegedAction() { - public javax.security.auth.Policy run() { - return javax.security.auth.Policy.getPolicy(); - } - }); - - if (!(javaxPolicy instanceof com.sun.security.auth.PolicyFile)) { - if (debug != null) { - debug.println("Providing backwards compatibility for " + - "javax.security.auth.policy implementation: " + - javaxPolicy.toString()); - } - - return true; - } else { - return false; - } - } - private static void printInputDomains(ProtectionDomain[] currentDomains, ProtectionDomain[] assignedDomains) { if (currentDomains == null || currentDomains.length == 0) { diff --git a/src/share/classes/sun/awt/AWTAccessor.java b/src/share/classes/sun/awt/AWTAccessor.java index b9171ce9798eb7c133ec15175c70a5c520d1543b..abef250993d334d6b9cfb9cc6e4b7bd7a0e919e5 100644 --- a/src/share/classes/sun/awt/AWTAccessor.java +++ b/src/share/classes/sun/awt/AWTAccessor.java @@ -223,6 +223,16 @@ public final class AWTAccessor { void processEvent(Component comp, AWTEvent e); } + /* + * An interface of accessor for the java.awt.Container class. + */ + public interface ContainerAccessor { + /** + * Validates the container unconditionally. + */ + void validateUnconditionally(Container cont); + } + /* * An interface of accessor for java.awt.Window class. */ @@ -334,6 +344,10 @@ public final class AWTAccessor { * Gets the state of this frame. */ int getExtendedState(Frame frame); + /* + * Gets the maximized bounds of this frame. + */ + Rectangle getMaximizedBounds(Frame frame); } /* @@ -440,53 +454,19 @@ public final class AWTAccessor { } /* - * The java.awt.Component class accessor object. + * Accessor instances are initialized in the static initializers of + * corresponding AWT classes by using setters defined below. */ private static ComponentAccessor componentAccessor; - - /* - * The java.awt.Window class accessor object. - */ + private static ContainerAccessor containerAccessor; private static WindowAccessor windowAccessor; - - /* - * The java.awt.AWTEvent class accessor object. - */ private static AWTEventAccessor awtEventAccessor; - - /* - * The java.awt.event.InputEvent class accessor object. - */ private static InputEventAccessor inputEventAccessor; - - /* - * The java.awt.Frame class accessor object. - */ private static FrameAccessor frameAccessor; - - /* - * The java.awt.KeyboardFocusManager class accessor object. - */ private static KeyboardFocusManagerAccessor kfmAccessor; - - /* - * The java.awt.MenuComponent class accessor object. - */ private static MenuComponentAccessor menuComponentAccessor; - - /* - * The java.awt.EventQueue class accessor object. - */ private static EventQueueAccessor eventQueueAccessor; - - /* - * The java.awt.PopupMenu class accessor object. - */ private static PopupMenuAccessor popupMenuAccessor; - - /* - * The java.awt.FileDialog class accessor object. - */ private static FileDialogAccessor fileDialogAccessor; /* @@ -497,7 +477,7 @@ public final class AWTAccessor { } /* - * Retrieve the accessor object for the java.awt.Window class. + * Retrieve the accessor object for the java.awt.Component class. */ public static ComponentAccessor getComponentAccessor() { if (componentAccessor == null) { @@ -507,6 +487,24 @@ public final class AWTAccessor { return componentAccessor; } + /* + * Set an accessor object for the java.awt.Container class. + */ + public static void setContainerAccessor(ContainerAccessor ca) { + containerAccessor = ca; + } + + /* + * Retrieve the accessor object for the java.awt.Container class. + */ + public static ContainerAccessor getContainerAccessor() { + if (containerAccessor == null) { + unsafe.ensureClassInitialized(Container.class); + } + + return containerAccessor; + } + /* * Set an accessor object for the java.awt.Window class. */ diff --git a/src/share/classes/sun/io/ByteToCharCp833.java b/src/share/classes/sun/io/ByteToCharCp833.java new file mode 100644 index 0000000000000000000000000000000000000000..a83a893d137405ccadb7c94e63b6874e9d76e3f8 --- /dev/null +++ b/src/share/classes/sun/io/ByteToCharCp833.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2010 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. + */ + +package sun.io; + +import sun.nio.cs.ext.IBM833; + +public class ByteToCharCp833 extends ByteToCharSingleByte { + + private final static IBM833 nioCoder = new IBM833(); + + public String getCharacterEncoding() { + return "Cp833"; + } + + public ByteToCharCp833() { + super.byteToCharTable = nioCoder.getDecoderSingleByteMappings(); + } +} + diff --git a/src/share/classes/sun/io/CharToByteCp833.java b/src/share/classes/sun/io/CharToByteCp833.java new file mode 100644 index 0000000000000000000000000000000000000000..2d531406c17889362b40b7e97309b9839c52e940 --- /dev/null +++ b/src/share/classes/sun/io/CharToByteCp833.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010 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. + */ + +package sun.io; + +import sun.nio.cs.ext.IBM833; + +public class CharToByteCp833 extends CharToByteSingleByte { + + private final static IBM833 nioCoder = new IBM833(); + + public String getCharacterEncoding() { + return "Cp833"; + } + + public CharToByteCp833() { + super.mask1 = 0xFF00; + super.mask2 = 0x00FF; + super.shift = 8; + super.index1 = nioCoder.getEncoderIndex1(); + super.index2 = nioCoder.getEncoderIndex2(); + } +} + diff --git a/src/share/classes/sun/io/CharacterEncoding.java b/src/share/classes/sun/io/CharacterEncoding.java index 94ce7040f5dc694498b7ec6b48b543c8b1e8ab57..f577a9bc79bc31dfe1b01e2d93084b0b7f3f48a3 100644 --- a/src/share/classes/sun/io/CharacterEncoding.java +++ b/src/share/classes/sun/io/CharacterEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2010, 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 @@ -406,6 +406,11 @@ public class CharacterEncoding { aliasTable.put("cp775", "Cp775"); aliasTable.put("775", "Cp775"); + aliasTable.put("ibm833", "Cp833"); + aliasTable.put("ibm-833", "Cp833"); + aliasTable.put("cp833", "Cp833"); + aliasTable.put("833", "Cp833"); + aliasTable.put("ibm834", "Cp834"); aliasTable.put("ibm-834", "Cp834"); aliasTable.put("cp834", "Cp834"); diff --git a/src/share/classes/sun/launcher/LauncherHelper.java b/src/share/classes/sun/launcher/LauncherHelper.java index cba795968c69c0875894aed1da6f67ebe74ac60f..dbaebc0ee862d9a465cc4b7ae77cef0e8987425f 100644 --- a/src/share/classes/sun/launcher/LauncherHelper.java +++ b/src/share/classes/sun/launcher/LauncherHelper.java @@ -44,8 +44,16 @@ import java.io.IOException; import java.io.PrintStream; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.math.BigDecimal; +import java.math.MathContext; +import java.math.RoundingMode; import java.util.ResourceBundle; import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Properties; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; @@ -59,6 +67,17 @@ public enum LauncherHelper { private static StringBuilder outBuf = new StringBuilder(); private static ResourceBundle javarb = null; + + private static final String INDENT = " "; + private static final String VM_SETTINGS = "VM settings:"; + private static final String PROP_SETTINGS = "Property settings:"; + private static final String LOCALE_SETTINGS = "Locale settings:"; + + private static final long K = 1024; + private static final long M = K * K; + private static final long G = M * K; + private static final long T = G * K; + private static synchronized ResourceBundle getLauncherResourceBundle() { if (javarb == null) { javarb = ResourceBundle.getBundle(defaultBundleName); @@ -66,6 +85,184 @@ public enum LauncherHelper { return javarb; } + /* + * A method called by the launcher to print out the standard settings, + * by default -XshowSettings is equivalent to -XshowSettings:all, + * Specific information may be gotten by using suboptions with possible + * values vm, properties and locale. + * + * printToStderr: choose between stdout and stderr + * + * optionFlag: specifies which options to print default is all other + * possible values are vm, properties, locale. + * + * maxHeapSize: in bytes, as set by the launcher, a zero-value indicates + * this code should determine this value, using a suitable method. + * + * stackSize: in bytes, as set by the launcher, a zero-value indicates + * this code determine this value, using a suitable method. + */ + static void showSettings(boolean printToStderr, String optionFlag, + long maxHeapSize, long stackSize, boolean isServer) { + + PrintStream ostream = (printToStderr) ? System.err : System.out; + String opts[] = optionFlag.split(":"); + String optStr = (opts.length > 1 && opts[1] != null) + ? opts[1].trim() + : "all"; + switch (optStr) { + case "vm": + printVmSettings(ostream, maxHeapSize, stackSize, isServer); + break; + case "properties": + printProperties(ostream); + break; + case "locale": + printLocale(ostream); + break; + default: + printVmSettings(ostream, maxHeapSize, stackSize, isServer); + printProperties(ostream); + printLocale(ostream); + break; + } + } + + /* + * prints the main vm settings subopt/section + */ + private static void printVmSettings(PrintStream ostream, long maxHeapSize, + long stackSize, boolean isServer) { + + ostream.println(VM_SETTINGS); + if (stackSize != 0L) { + ostream.println(INDENT + "Stack Size: " + scaleValue(stackSize)); + } + if (maxHeapSize != 0L) { + ostream.println(INDENT + "Max. Heap Size: " + scaleValue(maxHeapSize)); + } else { + ostream.println(INDENT + "Max. Heap Size (Estimated): " + + scaleValue(Runtime.getRuntime().maxMemory())); + } + ostream.println(INDENT + "Ergonomics Machine Class: " + + ((isServer) ? "server" : "client")); + ostream.println(INDENT + "Using VM: " + + System.getProperty("java.vm.name")); + ostream.println(); + } + + /* + * scale the incoming values to a human readable form, represented as + * K, M, G and T, see java.c parse_size for the scaled values and + * suffixes. + */ + + private static String scaleValue(double v) { + MathContext mc2 = new MathContext(3, RoundingMode.HALF_EVEN); + + if (v >= K && v < M) { + return (new BigDecimal(v / K, mc2)).toPlainString() + "K"; + } else if (v >= M && v < G) { + return (new BigDecimal(v / M, mc2)).toPlainString() + "M"; + } else if (v >= G && v < T) { + return (new BigDecimal(v / G, mc2)).toPlainString() + "G"; + } else if (v >= T) { + return (new BigDecimal(v / T, mc2)).toPlainString() + "T"; + } else { + return String.format("%.0f", v); + } + } + + /* + * prints the properties subopt/section + */ + private static void printProperties(PrintStream ostream) { + Properties p = System.getProperties(); + ostream.println(PROP_SETTINGS); + List sortedPropertyKeys = new ArrayList<>(); + sortedPropertyKeys.addAll(p.stringPropertyNames()); + Collections.sort(sortedPropertyKeys); + for (String x : sortedPropertyKeys) { + printPropertyValue(ostream, x, p.getProperty(x)); + } + ostream.println(); + } + + private static boolean isPath(String key) { + return key.endsWith(".dirs") || key.endsWith(".path"); + } + + private static void printPropertyValue(PrintStream ostream, + String key, String value) { + ostream.print(INDENT + key + " = "); + if (key.equals("line.separator")) { + byte[] bytes = value.getBytes(); + for (byte b : bytes) { + switch (b) { + case 0xd: + ostream.print("CR "); + break; + case 0xa: + ostream.print("LF "); + break; + default: + ostream.printf("0x%02X", b & 0xff); + break; + } + } + ostream.println(); + return; + } + if (!isPath(key)) { + ostream.println(value); + return; + } + // pretty print the path values as a list + String[] values = value.split(System.getProperty("path.separator")); + int len = values.length; + for (int i = 0 ; i < len ; i++) { + if (i == 0) { // first line treated specially + ostream.println(values[i]); + } else { // following lines prefix with indents + ostream.print(INDENT + INDENT); + ostream.println(values[i]); + } + } + } + + /* + * prints the locale subopt/section + */ + private static void printLocale(PrintStream ostream) { + Locale locale = Locale.getDefault(); + ostream.println(LOCALE_SETTINGS); + ostream.println(INDENT + "default locale = " + locale.getDisplayLanguage()); + printLocales(ostream); + ostream.println(); + } + + private static void printLocales(PrintStream ostream) { + Locale[] locales = Locale.getAvailableLocales(); + final int len = locales == null ? 0 : locales.length; + if (len < 1 ) { + return; + } + ostream.print(INDENT + "available locales = "); + final int last = len - 1 ; + for (int i = 0; i < last ; i++) { + ostream.print(locales[i]); + if (i != last) { + ostream.print(", "); + } + // print columns of 8 + if ((i + 1) % 8 == 0) { + ostream.println(); + ostream.print(INDENT + INDENT); + } + } + ostream.println(locales[last]); + } + /** * A private helper method to get a localized message and also * apply any arguments that we might pass. diff --git a/src/share/classes/sun/launcher/resources/launcher.properties b/src/share/classes/sun/launcher/resources/launcher.properties index e89d147a5bba82b96edc51d297343ec426729607..17ba48a13842ea68a03ea9231f69fc344b550e7e 100644 --- a/src/share/classes/sun/launcher/resources/launcher.properties +++ b/src/share/classes/sun/launcher/resources/launcher.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2010, 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 @@ -97,7 +97,15 @@ java.launcher.X.usage=\ \ -Xcheck:jni perform additional checks for JNI functions\n\ \ -Xshare:off do not attempt to use shared class data\n\ \ -Xshare:auto use shared class data if possible (default)\n\ -\ -Xshare:on require using shared class data, otherwise fail.\n\n\ +\ -Xshare:on require using shared class data, otherwise fail.\n\ +\ -XshowSettings show all settings and continue\n\ +\ -XshowSettings:all\n\ +\ show all settings and continue\n\ +\ -XshowSettings:vm show all vm related settings and continue\n\ +\ -XshowSettings:properties\n\ +\ show all property settings and continue\n\ +\ -XshowSettings:locale\n\ +\ show all locale related settings and continue\n\n\ The -X options are non-standard and subject to change without notice.\n java.launcher.cls.error1=\ diff --git a/src/share/classes/sun/net/httpserver/ChunkedInputStream.java b/src/share/classes/sun/net/httpserver/ChunkedInputStream.java index 8a7c88ac6032dec7ed268a740766d4d38d73937c..6339e87bd4481e317e3839309997e0f44af18cc9 100644 --- a/src/share/classes/sun/net/httpserver/ChunkedInputStream.java +++ b/src/share/classes/sun/net/httpserver/ChunkedInputStream.java @@ -110,6 +110,7 @@ class ChunkedInputStream extends LeftOverInputStream { if (remaining == 0) { eof = true; consumeCRLF(); + t.getServerImpl().requestCompleted (t.getConnection()); return -1; } needToReadHeader = false; diff --git a/src/share/classes/sun/net/httpserver/Event.java b/src/share/classes/sun/net/httpserver/Event.java index fa7512b99e8c58ab7e285b4565dd0a98b645ca4e..e3109eeb61831699d23e2124e0df516fc91081bb 100644 --- a/src/share/classes/sun/net/httpserver/Event.java +++ b/src/share/classes/sun/net/httpserver/Event.java @@ -40,5 +40,7 @@ class Event { class WriteFinishedEvent extends Event { WriteFinishedEvent (ExchangeImpl t) { super (t); + assert !t.writefinished; + t.writefinished = true; } } diff --git a/src/share/classes/sun/net/httpserver/ExchangeImpl.java b/src/share/classes/sun/net/httpserver/ExchangeImpl.java index 26453e6973ead4a4b3e6d8a5d73174ad3e7a4861..edf813e2814a0faa3e044fac2b625eb93bf40b24 100644 --- a/src/share/classes/sun/net/httpserver/ExchangeImpl.java +++ b/src/share/classes/sun/net/httpserver/ExchangeImpl.java @@ -38,6 +38,7 @@ class ExchangeImpl { Headers reqHdrs, rspHdrs; Request req; String method; + boolean writefinished; URI uri; HttpConnection connection; long reqContentLen; diff --git a/src/share/classes/sun/net/httpserver/FixedLengthInputStream.java b/src/share/classes/sun/net/httpserver/FixedLengthInputStream.java index a98779295cba43abc87b8129d187394bddedba2c..abc5bf9244bfdab62703cccf83fdb78a06bddc7b 100644 --- a/src/share/classes/sun/net/httpserver/FixedLengthInputStream.java +++ b/src/share/classes/sun/net/httpserver/FixedLengthInputStream.java @@ -56,6 +56,9 @@ class FixedLengthInputStream extends LeftOverInputStream { int n = in.read(b, off, len); if (n > -1) { remaining -= n; + if (remaining == 0) { + t.getServerImpl().requestCompleted (t.getConnection()); + } } return n; } diff --git a/src/share/classes/sun/net/httpserver/HttpConnection.java b/src/share/classes/sun/net/httpserver/HttpConnection.java index 6d2cf7f954ca33089374a4a3d28c13d191038076..adb79556fc5c06258b924ab961632bf3b071871a 100644 --- a/src/share/classes/sun/net/httpserver/HttpConnection.java +++ b/src/share/classes/sun/net/httpserver/HttpConnection.java @@ -55,10 +55,15 @@ class HttpConnection { SelectionKey selectionKey; String protocol; long time; + volatile long creationTime; // time this connection was created + volatile long rspStartedTime; // time we started writing the response int remaining; boolean closed = false; Logger logger; + public enum State {IDLE, REQUEST, RESPONSE}; + volatile State state; + public String toString() { String s = null; if (chan != null) { @@ -78,6 +83,14 @@ class HttpConnection { context = ctx; } + State getState() { + return state; + } + + void setState (State s) { + state = s; + } + void setParameters ( InputStream in, OutputStream rawout, SocketChannel chan, SSLEngine engine, SSLStreams sslStreams, SSLContext sslContext, String protocol, diff --git a/src/share/classes/sun/net/httpserver/Request.java b/src/share/classes/sun/net/httpserver/Request.java index 56c2e137f57f80a0251b84cecf9b7e417dbb2ef8..a51664b32b0c2012a3536840eba053c19f44ab55 100644 --- a/src/share/classes/sun/net/httpserver/Request.java +++ b/src/share/classes/sun/net/httpserver/Request.java @@ -201,32 +201,22 @@ class Request { static class ReadStream extends InputStream { SocketChannel channel; - SelectorCache sc; - Selector selector; ByteBuffer chanbuf; - SelectionKey key; - int available; byte[] one; - boolean closed = false, eof = false; + private boolean closed = false, eof = false; ByteBuffer markBuf; /* reads may be satisifed from this buffer */ boolean marked; boolean reset; int readlimit; static long readTimeout; ServerImpl server; - - static { - readTimeout = ServerConfig.getReadTimeout(); - } + final static int BUFSIZE = 8 * 1024; public ReadStream (ServerImpl server, SocketChannel chan) throws IOException { this.channel = chan; this.server = server; - sc = SelectorCache.getSelectorCache(); - selector = sc.getSelector(); - chanbuf = ByteBuffer.allocate (8* 1024); - key = chan.register (selector, SelectionKey.OP_READ); - available = 0; + chanbuf = ByteBuffer.allocate (BUFSIZE); + chanbuf.clear(); one = new byte[1]; closed = marked = reset = false; } @@ -255,6 +245,12 @@ class Request { return -1; } + assert channel.isBlocking(); + + if (off < 0 || srclen < 0|| srclen > (b.length-off)) { + throw new IndexOutOfBoundsException (); + } + if (reset) { /* satisfy from markBuf */ canreturn = markBuf.remaining (); willreturn = canreturn>srclen ? srclen : canreturn; @@ -263,17 +259,19 @@ class Request { reset = false; } } else { /* satisfy from channel */ - canreturn = available(); - while (canreturn == 0 && !eof) { - block (); - canreturn = available(); + chanbuf.clear (); + if (srclen < BUFSIZE) { + chanbuf.limit (srclen); } - if (eof) { + do { + willreturn = channel.read (chanbuf); + } while (willreturn == 0); + if (willreturn == -1) { + eof = true; return -1; } - willreturn = canreturn>srclen ? srclen : canreturn; + chanbuf.flip (); chanbuf.get(b, off, willreturn); - available -= willreturn; if (marked) { /* copy into markBuf */ try { @@ -286,6 +284,11 @@ class Request { return willreturn; } + public boolean markSupported () { + return true; + } + + /* Does not query the OS socket */ public synchronized int available () throws IOException { if (closed) throw new IOException ("Stream is closed"); @@ -296,36 +299,7 @@ class Request { if (reset) return markBuf.remaining(); - if (available > 0) - return available; - - chanbuf.clear (); - available = channel.read (chanbuf); - if (available > 0) { - chanbuf.flip(); - } else if (available == -1) { - eof = true; - available = 0; - } - return available; - } - - /** - * block() only called when available==0 and buf is empty - */ - private synchronized void block () throws IOException { - long currtime = server.getTime(); - long maxtime = currtime + readTimeout; - - while (currtime < maxtime) { - if (selector.select (readTimeout) == 1) { - selector.selectedKeys().clear(); - available (); - return; - } - currtime = server.getTime(); - } - throw new SocketTimeoutException ("no data received"); + return chanbuf.remaining(); } public void close () throws IOException { @@ -333,8 +307,6 @@ class Request { return; } channel.close (); - selector.selectNow(); - sc.freeSelector(selector); closed = true; } @@ -362,23 +334,14 @@ class Request { SocketChannel channel; ByteBuffer buf; SelectionKey key; - SelectorCache sc; - Selector selector; boolean closed; byte[] one; ServerImpl server; - static long writeTimeout; - - static { - writeTimeout = ServerConfig.getWriteTimeout(); - } public WriteStream (ServerImpl server, SocketChannel channel) throws IOException { this.channel = channel; this.server = server; - sc = SelectorCache.getSelectorCache(); - selector = sc.getSelector(); - key = channel.register (selector, SelectionKey.OP_WRITE); + assert channel.isBlocking(); closed = false; one = new byte [1]; buf = ByteBuffer.allocate (4096); @@ -411,31 +374,14 @@ class Request { l -= n; if (l == 0) return; - block(); - } - } - - void block () throws IOException { - long currtime = server.getTime(); - long maxtime = currtime + writeTimeout; - - while (currtime < maxtime) { - if (selector.select (writeTimeout) == 1) { - selector.selectedKeys().clear (); - return; - } - currtime = server.getTime(); } - throw new SocketTimeoutException ("write blocked too long"); } - public void close () throws IOException { if (closed) return; + //server.logStackTrace ("Request.OS.close: isOpen="+channel.isOpen()); channel.close (); - selector.selectNow(); - sc.freeSelector(selector); closed = true; } } diff --git a/src/share/classes/sun/net/httpserver/SSLStreams.java b/src/share/classes/sun/net/httpserver/SSLStreams.java index fed7f4b49434518b391b8b3ab2151996e71e6d3c..8578177a61b3366d39439cfb6fb4c5ceab91702e 100644 --- a/src/share/classes/sun/net/httpserver/SSLStreams.java +++ b/src/share/classes/sun/net/httpserver/SSLStreams.java @@ -53,8 +53,6 @@ class SSLStreams { EngineWrapper wrapper; OutputStream os; InputStream is; - static long readTimeout = ServerConfig.getReadTimeout(); - static long writeTimeout = ServerConfig.getWriteTimeout(); /* held by thread doing the hand-shake on this connection */ Lock handshaking = new ReentrantLock(); @@ -77,10 +75,13 @@ class SSLStreams { if (cfg != null) { Parameters params = new Parameters (cfg, addr); cfg.configure (params); +//BEGIN_TIGER_EXCLUDE SSLParameters sslParams = params.getSSLParameters(); if (sslParams != null) { engine.setSSLParameters (sslParams); - } else { + } else +//END_TIGER_EXCLUDE + { /* tiger compatibility */ if (params.getCipherSuites() != null) { try { @@ -104,7 +105,6 @@ class SSLStreams { class Parameters extends HttpsParameters { InetSocketAddress addr; - SSLParameters params; HttpsConfigurator cfg; Parameters (HttpsConfigurator cfg, InetSocketAddress addr) { @@ -117,12 +117,15 @@ class SSLStreams { public HttpsConfigurator getHttpsConfigurator() { return cfg; } +//BEGIN_TIGER_EXCLUDE + SSLParameters params; public void setSSLParameters (SSLParameters p) { params = p; } SSLParameters getSSLParameters () { return params; } +//END_TIGER_EXCLUDE } /** @@ -245,9 +248,6 @@ class SSLStreams { SocketChannel chan; SSLEngine engine; - SelectorCache sc; - Selector write_selector, read_selector; - SelectionKey wkey, rkey; Object wrapLock, unwrapLock; ByteBuffer unwrap_src, wrap_dst; boolean closed = false; @@ -260,16 +260,9 @@ class SSLStreams { unwrapLock = new Object(); unwrap_src = allocate(BufType.PACKET); wrap_dst = allocate(BufType.PACKET); - sc = SelectorCache.getSelectorCache(); - write_selector = sc.getSelector(); - wkey = chan.register (write_selector, SelectionKey.OP_WRITE); - read_selector = sc.getSelector(); - wkey = chan.register (read_selector, SelectionKey.OP_READ); } void close () throws IOException { - sc.freeSelector (write_selector); - sc.freeSelector (read_selector); } /* try to wrap and send the data in src. Handles OVERFLOW. @@ -304,15 +297,7 @@ class SSLStreams { wrap_dst.flip(); int l = wrap_dst.remaining(); assert l == r.result.bytesProduced(); - long currtime = time.getTime(); - long maxtime = currtime + writeTimeout; while (l>0) { - write_selector.select(writeTimeout); // timeout - currtime = time.getTime(); - if (currtime > maxtime) { - throw new SocketTimeoutException ("write timed out"); - } - write_selector.selectedKeys().clear(); l -= chan.write (wrap_dst); } } @@ -342,20 +327,12 @@ class SSLStreams { needData = true; } synchronized (unwrapLock) { - int x,y; + int x; do { if (needData) { - long currTime = time.getTime(); - long maxtime = currTime + readTimeout; do { - if (currTime > maxtime) { - throw new SocketTimeoutException ("read timedout"); - } - y = read_selector.select (readTimeout); - currTime = time.getTime(); - } while (y != 1); - read_selector.selectedKeys().clear(); x = chan.read (unwrap_src); + } while (x == 0); if (x == -1) { throw new IOException ("connection closed for reading"); } diff --git a/src/share/classes/sun/net/httpserver/SelectorCache.java b/src/share/classes/sun/net/httpserver/SelectorCache.java deleted file mode 100644 index afd87c022356e363faae70569dfa9d09e5f15127..0000000000000000000000000000000000000000 --- a/src/share/classes/sun/net/httpserver/SelectorCache.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2006, 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. - */ - -package sun.net.httpserver; - -import java.util.*; -import java.nio.*; -import java.net.*; -import java.io.*; -import java.security.*; -import java.nio.channels.*; - -/* - * Implements a cache of java.nio.channels.Selector - * where Selectors are allocated on demand and placed - * in a temporary cache for a period of time, so they - * can be reused. If a period of between 2 and 4 minutes - * elapses without being used, then they are closed. - */ -public class SelectorCache { - - static SelectorCache cache = null; - - private SelectorCache () { - freeSelectors = new LinkedList(); - CacheCleaner c = AccessController.doPrivileged( - new PrivilegedAction() { - public CacheCleaner run() { - CacheCleaner cleaner = new CacheCleaner(); - cleaner.setDaemon (true); - return cleaner; - } - }); - c.start(); - } - - /** - * factory method for creating single instance - */ - public static SelectorCache getSelectorCache () { - synchronized (SelectorCache.class) { - if (cache == null) { - cache = new SelectorCache (); - } - } - return cache; - } - - private static class SelectorWrapper { - private Selector sel; - private boolean deleteFlag; - private SelectorWrapper (Selector sel) { - this.sel = sel; - this.deleteFlag = false; - } - public Selector getSelector() { return sel;} - public boolean getDeleteFlag () {return deleteFlag;} - public void setDeleteFlag (boolean b) {deleteFlag = b;} - } - - /* list of free selectors. Can be re-allocated for a period - * of time, after which if not allocated will be closed - * and removed from the list (by CacheCleaner thread) - */ - LinkedList freeSelectors; - - synchronized Selector getSelector () throws IOException { - SelectorWrapper wrapper = null; - Selector selector; - - if (freeSelectors.size() > 0) { - wrapper = freeSelectors.remove(); - selector = wrapper.getSelector(); - } else { - selector = Selector.open(); - } - return selector; - } - - synchronized void freeSelector (Selector selector) { - freeSelectors.add (new SelectorWrapper (selector)); - } - - /* Thread ensures that entries on freeSelector list - * remain there for at least 2 minutes and no longer - * than 4 minutes. - */ - class CacheCleaner extends Thread { - public void run () { - long timeout = ServerConfig.getSelCacheTimeout() * 1000; - while (true) { - try {Thread.sleep (timeout); } catch (Exception e) {} - synchronized (freeSelectors) { - ListIterator l = freeSelectors.listIterator(); - while (l.hasNext()) { - SelectorWrapper w = l.next(); - if (w.getDeleteFlag()) { - /* 2nd pass. Close the selector */ - try { - w.getSelector().close(); - } catch (IOException e) {} - l.remove(); - } else { - /* 1st pass. Set the flag */ - w.setDeleteFlag (true); - } - } - } - } - } - } -} diff --git a/src/share/classes/sun/net/httpserver/ServerConfig.java b/src/share/classes/sun/net/httpserver/ServerConfig.java index d4c87847547071c629348a705959a49ae5f01df9..cae3cdd84d9c7c5aeef345edb32cad97f1148424 100644 --- a/src/share/classes/sun/net/httpserver/ServerConfig.java +++ b/src/share/classes/sun/net/httpserver/ServerConfig.java @@ -27,6 +27,8 @@ package sun.net.httpserver; import com.sun.net.httpserver.*; import com.sun.net.httpserver.spi.*; +import java.util.logging.Logger; +import java.security.PrivilegedAction; /** * Parameters that users will not likely need to set @@ -37,23 +39,26 @@ class ServerConfig { static int clockTick; - static int defaultClockTick = 10000 ; // 10 sec. + static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec. /* These values must be a reasonable multiple of clockTick */ - static long defaultReadTimeout = 20 ; // 20 sec. - static long defaultWriteTimeout = 60 ; // 60 sec. - static long defaultIdleInterval = 300 ; // 5 min - static long defaultSelCacheTimeout = 120 ; // seconds - static int defaultMaxIdleConnections = 200 ; + static final long DEFAULT_IDLE_INTERVAL = 300 ; // 5 min + static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ; - static long defaultDrainAmount = 64 * 1024; + static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever + static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever + static final long DEFAULT_TIMER_MILLIS = 1000; + + static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024; - static long readTimeout; - static long writeTimeout; static long idleInterval; - static long selCacheTimeout; static long drainAmount; // max # of bytes to drain from an inputstream static int maxIdleConnections; + + // max time a request or response is allowed to take + static long maxReqTime; + static long maxRspTime; + static long timerMillis; static boolean debug = false; static { @@ -61,49 +66,79 @@ class ServerConfig { idleInterval = ((Long)java.security.AccessController.doPrivileged( new sun.security.action.GetLongAction( "sun.net.httpserver.idleInterval", - defaultIdleInterval))).longValue() * 1000; + DEFAULT_IDLE_INTERVAL))).longValue() * 1000; clockTick = ((Integer)java.security.AccessController.doPrivileged( new sun.security.action.GetIntegerAction( "sun.net.httpserver.clockTick", - defaultClockTick))).intValue(); + DEFAULT_CLOCK_TICK))).intValue(); maxIdleConnections = ((Integer)java.security.AccessController.doPrivileged( new sun.security.action.GetIntegerAction( "sun.net.httpserver.maxIdleConnections", - defaultMaxIdleConnections))).intValue(); + DEFAULT_MAX_IDLE_CONNECTIONS))).intValue(); - readTimeout = ((Long)java.security.AccessController.doPrivileged( + drainAmount = ((Long)java.security.AccessController.doPrivileged( new sun.security.action.GetLongAction( - "sun.net.httpserver.readTimeout", - defaultReadTimeout))).longValue()* 1000; + "sun.net.httpserver.drainAmount", + DEFAULT_DRAIN_AMOUNT))).longValue(); - selCacheTimeout = ((Long)java.security.AccessController.doPrivileged( + maxReqTime = ((Long)java.security.AccessController.doPrivileged( new sun.security.action.GetLongAction( - "sun.net.httpserver.selCacheTimeout", - defaultSelCacheTimeout))).longValue()* 1000; + "sun.net.httpserver.maxReqTime", + DEFAULT_MAX_REQ_TIME))).longValue(); - writeTimeout = ((Long)java.security.AccessController.doPrivileged( + maxRspTime = ((Long)java.security.AccessController.doPrivileged( new sun.security.action.GetLongAction( - "sun.net.httpserver.writeTimeout", - defaultWriteTimeout))).longValue()* 1000; + "sun.net.httpserver.maxRspTime", + DEFAULT_MAX_RSP_TIME))).longValue(); - drainAmount = ((Long)java.security.AccessController.doPrivileged( + timerMillis = ((Long)java.security.AccessController.doPrivileged( new sun.security.action.GetLongAction( - "sun.net.httpserver.drainAmount", - defaultDrainAmount))).longValue(); + "sun.net.httpserver.timerMillis", + DEFAULT_TIMER_MILLIS))).longValue(); debug = ((Boolean)java.security.AccessController.doPrivileged( new sun.security.action.GetBooleanAction( "sun.net.httpserver.debug"))).booleanValue(); } - static long getReadTimeout () { - return readTimeout; - } - static long getSelCacheTimeout () { - return selCacheTimeout; + static void checkLegacyProperties (final Logger logger) { + + // legacy properties that are no longer used + // print a warning to logger if they are set. + + java.security.AccessController.doPrivileged( + new PrivilegedAction() { + public Void run () { + if (System.getProperty("sun.net.httpserver.readTimeout") + !=null) + { + logger.warning ("sun.net.httpserver.readTimeout "+ + "property is no longer used. "+ + "Use sun.net.httpserver.maxReqTime instead." + ); + } + if (System.getProperty("sun.net.httpserver.writeTimeout") + !=null) + { + logger.warning ("sun.net.httpserver.writeTimeout "+ + "property is no longer used. Use "+ + "sun.net.httpserver.maxRspTime instead." + ); + } + if (System.getProperty("sun.net.httpserver.selCacheTimeout") + !=null) + { + logger.warning ("sun.net.httpserver.selCacheTimeout "+ + "property is no longer used." + ); + } + return null; + } + } + ); } static boolean debugEnabled () { @@ -122,11 +157,19 @@ class ServerConfig { return maxIdleConnections; } - static long getWriteTimeout () { - return writeTimeout; - } - static long getDrainAmount () { return drainAmount; } + + static long getMaxReqTime () { + return maxReqTime; + } + + static long getMaxRspTime () { + return maxRspTime; + } + + static long getTimerMillis () { + return timerMillis; + } } diff --git a/src/share/classes/sun/net/httpserver/ServerImpl.java b/src/share/classes/sun/net/httpserver/ServerImpl.java index a8b0287808230d5c5cbe7226b12775ad5e4be337..08edeaf8a80687c3859296ac2b6a24fd3fd5edc4 100644 --- a/src/share/classes/sun/net/httpserver/ServerImpl.java +++ b/src/share/classes/sun/net/httpserver/ServerImpl.java @@ -37,6 +37,7 @@ import java.util.logging.Level; import javax.net.ssl.*; import com.sun.net.httpserver.*; import com.sun.net.httpserver.spi.*; +import sun.net.httpserver.HttpConnection.State; /** * Provides implementation for both HTTP and HTTPS @@ -55,6 +56,12 @@ class ServerImpl implements TimeSource { private SelectionKey listenerKey; private Set idleConnections; private Set allConnections; + /* following two are used to keep track of the times + * when a connection/request is first received + * and when we start to send the response + */ + private Set reqConnections; + private Set rspConnections; private List events; private Object lolock = new Object(); private volatile boolean finished = false; @@ -62,14 +69,19 @@ class ServerImpl implements TimeSource { private boolean bound = false; private boolean started = false; private volatile long time; /* current time */ + private volatile long subticks = 0; private volatile long ticks; /* number of clock ticks since server started */ private HttpServer wrapper; final static int CLOCK_TICK = ServerConfig.getClockTick(); final static long IDLE_INTERVAL = ServerConfig.getIdleInterval(); final static int MAX_IDLE_CONNECTIONS = ServerConfig.getMaxIdleConnections(); + final static long TIMER_MILLIS = ServerConfig.getTimerMillis (); + final static long MAX_REQ_TIME=getTimeMillis(ServerConfig.getMaxReqTime()); + final static long MAX_RSP_TIME=getTimeMillis(ServerConfig.getMaxRspTime()); + final static boolean timer1Enabled = MAX_REQ_TIME != -1 || MAX_RSP_TIME != -1; - private Timer timer; + private Timer timer, timer1; private Logger logger; ServerImpl ( @@ -79,6 +91,7 @@ class ServerImpl implements TimeSource { this.protocol = protocol; this.wrapper = wrapper; this.logger = Logger.getLogger ("com.sun.net.httpserver"); + ServerConfig.checkLegacyProperties (logger); https = protocol.equalsIgnoreCase ("https"); this.address = addr; contexts = new ContextList(); @@ -94,9 +107,18 @@ class ServerImpl implements TimeSource { dispatcher = new Dispatcher(); idleConnections = Collections.synchronizedSet (new HashSet()); allConnections = Collections.synchronizedSet (new HashSet()); + reqConnections = Collections.synchronizedSet (new HashSet()); + rspConnections = Collections.synchronizedSet (new HashSet()); time = System.currentTimeMillis(); timer = new Timer ("server-timer", true); timer.schedule (new ServerTimerTask(), CLOCK_TICK, CLOCK_TICK); + if (timer1Enabled) { + timer1 = new Timer ("server-timer1", true); + timer1.schedule (new ServerTimerTask1(),TIMER_MILLIS,TIMER_MILLIS); + logger.config ("HttpServer timer1 enabled period in ms: "+TIMER_MILLIS); + logger.config ("MAX_REQ_TIME: "+MAX_REQ_TIME); + logger.config ("MAX_RSP_TIME: "+MAX_RSP_TIME); + } events = new LinkedList(); logger.config ("HttpServer created "+protocol+" "+ addr); } @@ -181,6 +203,9 @@ class ServerImpl implements TimeSource { allConnections.clear(); idleConnections.clear(); timer.cancel(); + if (timer1Enabled) { + timer1.cancel(); + } } Dispatcher dispatcher; @@ -236,13 +261,6 @@ class ServerImpl implements TimeSource { } } - int resultSize () { - synchronized (lolock) { - return events.size (); - } - } - - /* main server listener task */ class Dispatcher implements Runnable { @@ -257,7 +275,7 @@ class ServerImpl implements TimeSource { if (terminating && exchanges == 0) { finished = true; } - SocketChannel chan = c.getChannel(); + responseCompleted (c); LeftOverInputStream is = t.getOriginalInputStream(); if (!is.isEOF()) { t.close = true; @@ -268,17 +286,10 @@ class ServerImpl implements TimeSource { } else { if (is.isDataBuffered()) { /* don't re-enable the interestops, just handle it */ + requestStarted (c); handle (c.getChannel(), c); } else { - /* re-enable interestops */ - SelectionKey key = c.getSelectionKey(); - if (key.isValid()) { - key.interestOps ( - key.interestOps()|SelectionKey.OP_READ - ); - } - c.time = getTime() + IDLE_INTERVAL; - idleConnections.add (c); + connsToRegister.add (c); } } } @@ -290,22 +301,51 @@ class ServerImpl implements TimeSource { } } + final LinkedList connsToRegister = + new LinkedList(); + + void reRegister (HttpConnection c) { + /* re-register with selector */ + try { + SocketChannel chan = c.getChannel(); + chan.configureBlocking (false); + SelectionKey key = chan.register (selector, SelectionKey.OP_READ); + key.attach (c); + c.selectionKey = key; + c.time = getTime() + IDLE_INTERVAL; + idleConnections.add (c); + } catch (IOException e) { + dprint(e); + logger.log(Level.FINER, "Dispatcher(8)", e); + c.close(); + } + } + public void run() { while (!finished) { try { + ListIterator li = + connsToRegister.listIterator(); + for (HttpConnection c : connsToRegister) { + reRegister(c); + } + connsToRegister.clear(); - /* process the events list first */ + List list = null; + selector.select(1000); + synchronized (lolock) { + if (events.size() > 0) { + list = events; + events = new LinkedList(); + } + } - while (resultSize() > 0) { - Event r; - synchronized (lolock) { - r = events.remove(0); + if (list != null) { + for (Event r: list) { handleEvent (r); } } - selector.select(1000); - /* process the selected list now */ Set selected = selector.selectedKeys(); @@ -327,6 +367,7 @@ class ServerImpl implements TimeSource { c.selectionKey = newkey; c.setChannel (chan); newkey.attach (c); + requestStarted (c); allConnections.add (c); } else { try { @@ -334,27 +375,44 @@ class ServerImpl implements TimeSource { boolean closed; SocketChannel chan = (SocketChannel)key.channel(); HttpConnection conn = (HttpConnection)key.attachment(); - // interestOps will be restored at end of read - key.interestOps (0); + + key.cancel(); + chan.configureBlocking (true); + if (idleConnections.remove(conn)) { + // was an idle connection so add it + // to reqConnections set. + requestStarted (conn); + } handle (chan, conn); } else { assert false; } + } catch (CancelledKeyException e) { + handleException(key, null); } catch (IOException e) { - HttpConnection conn = (HttpConnection)key.attachment(); - logger.log ( - Level.FINER, "Dispatcher (2)", e - ); - conn.close(); + handleException(key, e); } } } + // call the selector just to process the cancelled keys + selector.selectNow(); + } catch (IOException e) { + logger.log (Level.FINER, "Dispatcher (4)", e); } catch (Exception e) { - logger.log (Level.FINER, "Dispatcher (3)", e); + e.printStackTrace(); + logger.log (Level.FINER, "Dispatcher (7)", e); } } } + private void handleException (SelectionKey key, Exception e) { + HttpConnection conn = (HttpConnection)key.attachment(); + if (e != null) { + logger.log (Level.FINER, "Dispatcher (2)", e); + } + closeConnection(conn); + } + public void handle (SocketChannel chan, HttpConnection conn) throws IOException { @@ -363,10 +421,10 @@ class ServerImpl implements TimeSource { executor.execute (t); } catch (HttpError e1) { logger.log (Level.FINER, "Dispatcher (4)", e1); - conn.close(); + closeConnection(conn); } catch (IOException e) { logger.log (Level.FINER, "Dispatcher (5)", e); - conn.close(); + closeConnection(conn); } } } @@ -390,7 +448,26 @@ class ServerImpl implements TimeSource { return logger; } - /* per exchange task */ + private void closeConnection(HttpConnection conn) { + conn.close(); + allConnections.remove(conn); + switch (conn.getState()) { + case REQUEST: + reqConnections.remove(conn); + break; + case RESPONSE: + rspConnections.remove(conn); + break; + case IDLE: + idleConnections.remove(conn); + break; + } + assert !reqConnections.remove(conn); + assert !rspConnections.remove(conn); + assert !idleConnections.remove(conn); + } + + /* per exchange task */ class Exchange implements Runnable { SocketChannel chan; @@ -450,8 +527,7 @@ class ServerImpl implements TimeSource { requestLine = req.requestLine(); if (requestLine == null) { /* connection closed */ - connection.close(); - allConnections.remove(connection); + closeConnection(connection); return; } int space = requestLine.indexOf (' '); @@ -482,6 +558,9 @@ class ServerImpl implements TimeSource { if (s != null) { clen = Long.parseLong(s); } + if (clen == 0) { + requestCompleted (connection); + } } ctx = contexts.findContext (protocol, uri.getPath()); if (ctx == null) { @@ -560,7 +639,7 @@ class ServerImpl implements TimeSource { } catch (IOException e1) { logger.log (Level.FINER, "ServerImpl.Exchange (1)", e1); - connection.close(); + closeConnection(connection); } catch (NumberFormatException e3) { reject (Code.HTTP_BAD_REQUEST, requestLine, "NumberFormatException thrown"); @@ -569,7 +648,7 @@ class ServerImpl implements TimeSource { requestLine, "URISyntaxException thrown"); } catch (Exception e4) { logger.log (Level.FINER, "ServerImpl.Exchange (2)", e4); - connection.close(); + closeConnection(connection); } } @@ -591,47 +670,60 @@ class ServerImpl implements TimeSource { rejected = true; logReply (code, requestStr, message); sendReply ( - code, true, "

"+code+Code.msg(code)+"

"+message + code, false, "

"+code+Code.msg(code)+"

"+message ); - /* connection is already closed by sendReply, now remove it */ - allConnections.remove(connection); + closeConnection(connection); } void sendReply ( int code, boolean closeNow, String text) { try { - String s = "HTTP/1.1 " + code + Code.msg(code) + "\r\n"; + StringBuilder builder = new StringBuilder (512); + builder.append ("HTTP/1.1 ") + .append (code).append (Code.msg(code)).append ("\r\n"); + if (text != null && text.length() != 0) { - s = s + "Content-Length: "+text.length()+"\r\n"; - s = s + "Content-Type: text/html\r\n"; + builder.append ("Content-Length: ") + .append (text.length()).append ("\r\n") + .append ("Content-Type: text/html\r\n"); } else { - s = s + "Content-Length: 0\r\n"; + builder.append ("Content-Length: 0\r\n"); text = ""; } if (closeNow) { - s = s + "Connection: close\r\n"; + builder.append ("Connection: close\r\n"); } - s = s + "\r\n" + text; + builder.append ("\r\n").append (text); + String s = builder.toString(); byte[] b = s.getBytes("ISO8859_1"); rawout.write (b); rawout.flush(); if (closeNow) { - connection.close(); + closeConnection(connection); } } catch (IOException e) { logger.log (Level.FINER, "ServerImpl.sendReply", e); - connection.close(); + closeConnection(connection); } } } void logReply (int code, String requestStr, String text) { + if (!logger.isLoggable(Level.FINE)) { + return; + } if (text == null) { text = ""; } - String message = requestStr + " [" + code + " " + + String r; + if (requestStr.length() > 80) { + r = requestStr.substring (0, 80) + ""; + } else { + r = requestStr; + } + String message = r + " [" + code + " " + Code.msg(code) + "] ("+text+")"; logger.fine (message); } @@ -667,6 +759,34 @@ class ServerImpl implements TimeSource { return wrapper; } + void requestStarted (HttpConnection c) { + c.creationTime = getTime(); + c.setState (State.REQUEST); + reqConnections.add (c); + } + + // called after a request has been completely read + // by the server. This stops the timer which would + // close the connection if the request doesn't arrive + // quickly enough. It then starts the timer + // that ensures the client reads the response in a timely + // fashion. + + void requestCompleted (HttpConnection c) { + assert c.getState() == State.REQUEST; + reqConnections.remove (c); + c.rspStartedTime = getTime(); + rspConnections.add (c); + c.setState (State.RESPONSE); + } + + // called after response has been sent + void responseCompleted (HttpConnection c) { + assert c.getState() == State.RESPONSE; + rspConnections.remove (c); + c.setState (State.IDLE); + } + /** * TimerTask run every CLOCK_TICK ms */ @@ -689,4 +809,62 @@ class ServerImpl implements TimeSource { } } } + + class ServerTimerTask1 extends TimerTask { + + // runs every TIMER_MILLIS + public void run () { + LinkedList toClose = new LinkedList(); + time = System.currentTimeMillis(); + synchronized (reqConnections) { + if (MAX_REQ_TIME != -1) { + for (HttpConnection c : reqConnections) { + if (c.creationTime + TIMER_MILLIS + MAX_REQ_TIME <= time) { + toClose.add (c); + } + } + for (HttpConnection c : toClose) { + logger.log (Level.FINE, "closing: no request: " + c); + reqConnections.remove (c); + allConnections.remove (c); + c.close(); + } + } + } + toClose = new LinkedList(); + synchronized (rspConnections) { + if (MAX_RSP_TIME != -1) { + for (HttpConnection c : rspConnections) { + if (c.rspStartedTime + TIMER_MILLIS +MAX_RSP_TIME <= time) { + toClose.add (c); + } + } + for (HttpConnection c : toClose) { + logger.log (Level.FINE, "closing: no response: " + c); + rspConnections.remove (c); + allConnections.remove (c); + c.close(); + } + } + } + } + } + + void logStackTrace (String s) { + logger.finest (s); + StringBuilder b = new StringBuilder (); + StackTraceElement[] e = Thread.currentThread().getStackTrace(); + for (int i=0; i 0) { + if (length == 0) { + return null; + } else { byte[] bytes = new byte[length]; read(bytes, 0, length); - Ticket ticket = new Ticket(bytes); - return ticket; + return bytes; } - else return null; } boolean[] readFlags() throws IOException { @@ -328,6 +328,17 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC } return flags; } + + /** + * Reads the next cred in stream. + * @return the next cred, null if ticket or second_ticket unparseable. + * + * Note: MIT krb5 1.8.1 might generate a config entry with server principal + * X-CACHECONF:/krb5_ccache_conf_data/fast_avail/krbtgt/REALM@REALM. The + * entry is used by KDC to inform the client that it support certain + * features. Its ticket is not a valid krb5 ticket and thus this method + * returns null. + */ Credentials readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception { PrincipalName cpname = readPrincipal(version); if (DEBUG) @@ -367,17 +378,17 @@ public class CCacheInputStream extends KrbDataInputStream implements FileCCacheC if (auData != null) { auData = new AuthorizationData(auDataEntry); } - Ticket ticket = readData(); - if (DEBUG) { - System.out.println(">>>DEBUG "); - if (ticket == null) { - System.out.println("///ticket is null"); - } + byte[] ticketData = readData(); + byte[] ticketData2 = readData(); + + try { + return new Credentials(cpname, spname, key, authtime, starttime, + endtime, renewTill, skey, tFlags, + addrs, auData, + ticketData != null ? new Ticket(ticketData) : null, + ticketData2 != null ? new Ticket(ticketData2) : null); + } catch (Exception e) { // If any of new Ticket(*) fails. + return null; } - Ticket secTicket = readData(); - Credentials cred = new Credentials(cpname, spname, key, authtime, starttime, - endtime, renewTill, skey, tFlags, - addrs, auData, ticket, secTicket); - return cred; } } diff --git a/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java b/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java index 6095077f503b31f27f3f4297a395912999c84044..4f874903f79596516101b8cbf7331cd7c18664bf 100644 --- a/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java +++ b/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2010, 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 @@ -186,7 +186,10 @@ public class FileCredentialsCache extends CredentialsCache primaryRealm = primaryPrincipal.getRealm(); credentialsList = new Vector (); while (cis.available() > 0) { - credentialsList.addElement(cis.readCred(version)); + Credentials cred = cis.readCred(version); + if (cred != null) { + credentialsList.addElement(cred); + } } cis.close(); } diff --git a/src/share/classes/sun/security/pkcs11/P11Cipher.java b/src/share/classes/sun/security/pkcs11/P11Cipher.java index 1ea39e799d1ad9c786c5befcd151ee92e321bf3f..5568887a5f61a40f80c1774a5fbf7e2a49c7b8b4 100644 --- a/src/share/classes/sun/security/pkcs11/P11Cipher.java +++ b/src/share/classes/sun/security/pkcs11/P11Cipher.java @@ -74,7 +74,7 @@ final class P11Cipher extends CipherSpi { // DEC: return the length of trailing padding bytes given the specified // padded data int unpad(byte[] paddedData, int len) - throws BadPaddingException; + throws BadPaddingException, IllegalBlockSizeException; } private static class PKCS5Padding implements Padding { @@ -96,9 +96,10 @@ final class P11Cipher extends CipherSpi { } public int unpad(byte[] paddedData, int len) - throws BadPaddingException { - if (len < 1 || len > paddedData.length) { - throw new BadPaddingException("Invalid pad array length!"); + throws BadPaddingException, IllegalBlockSizeException { + if ((len < 1) || (len % blockSize != 0)) { + throw new IllegalBlockSizeException + ("Input length must be multiples of " + blockSize); } byte padValue = paddedData[len - 1]; if (padValue < 1 || padValue > blockSize) { diff --git a/src/share/classes/sun/security/ssl/Krb5Helper.java b/src/share/classes/sun/security/ssl/Krb5Helper.java index 440b119861e1f3fe2afbe2bffc44611b88e73814..b61ab4f293829256fea775fe3021c3e7cbc1951b 100644 --- a/src/share/classes/sun/security/ssl/Krb5Helper.java +++ b/src/share/classes/sun/security/ssl/Krb5Helper.java @@ -10,7 +10,7 @@ * * 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 + * 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). * diff --git a/src/share/classes/sun/security/ssl/Krb5Proxy.java b/src/share/classes/sun/security/ssl/Krb5Proxy.java index 2e5915859420ec3ebcc355ab9044a7f3b4f9b760..24ace2b85dbb197bc77b5545d7a095c89db70974 100644 --- a/src/share/classes/sun/security/ssl/Krb5Proxy.java +++ b/src/share/classes/sun/security/ssl/Krb5Proxy.java @@ -10,7 +10,7 @@ * * 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 + * 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). * diff --git a/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java b/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java index 70dc7532e5bc540ac9bda71fb6fbae547fee2959..ce0479d78af564c37d6c075ea789b0e7250d741d 100644 --- a/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java +++ b/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java @@ -10,7 +10,7 @@ * * 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 + * 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). * diff --git a/src/share/demo/applets/NervousText/example1.html b/src/share/demo/applets/NervousText/example1.html index 38e4f840da5cd204c11813902ed022df08d2ea81..96013da6f4520abb0602ae25727e5ac66d2550da 100644 --- a/src/share/demo/applets/NervousText/example1.html +++ b/src/share/demo/applets/NervousText/example1.html @@ -1,7 +1,7 @@ Nervous Text 1.1
- +
The source. diff --git a/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java b/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java index 193264670d53c7fb9cd21cdd2f827e643a11b3de..e198c0c84245db5952218558d5933ab4444ba098 100644 --- a/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java +++ b/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java @@ -75,7 +75,8 @@ public class J2DBench { static JFrame guiFrame; - static final SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy 'at' HH:mm aaa z"); + static final SimpleDateFormat sdf = + new SimpleDateFormat("MM.dd.yyyy 'at' HH:mm aaa z"); public static void init() { progoptroot = new Group("prog", "Program Options"); @@ -176,6 +177,8 @@ public class J2DBench { public static void main(String argv[]) { init(); TestEnvironment.init(); + Result.init(); + Destinations.init(); GraphicsTests.init(); RenderTests.init(); @@ -323,7 +326,7 @@ public class J2DBench { } else if (type.equalsIgnoreCase("m")) { multiplyWith = 60; } else { - System.out.println("Invalid \"-loop\" option specified."); + System.err.println("Invalid \"-loop\" option specified."); usage(1); } @@ -331,32 +334,20 @@ public class J2DBench { try { val = Integer.parseInt(argv[i].substring(0, argv[i].length() - 1)); } catch(Exception e) { - System.out.println("Invalid \"-loop\" option specified."); + System.err.println("Invalid \"-loop\" option specified."); usage(1); } requiredLoopTime = val * multiplyWith * 1000; } - } else if (arg.length() > 7 && - arg.substring(0, 7).equalsIgnoreCase("-report")) - { - for (int j = 7; j < arg.length(); j++) { - char c = arg.charAt(j); - switch (c) { - case 'N': Result.unitScale = Result.UNITS_WHOLE; break; - case 'M': Result.unitScale = Result.UNITS_MILLIONS; break; - case 'K': Result.unitScale = Result.UNITS_THOUSANDS; break; - case 'A': Result.unitScale = Result.UNITS_AUTO; break; - case 'U': Result.useUnits = true; break; - case 'O': Result.useUnits = false; break; - case 's': Result.timeScale = Result.SECONDS_WHOLE; break; - case 'm': Result.timeScale = Result.SECONDS_MILLIS; break; - case 'u': Result.timeScale = Result.SECONDS_MICROS; break; - case 'n': Result.timeScale = Result.SECONDS_NANOS; break; - case 'a': Result.timeScale = Result.SECONDS_AUTO; break; - case '/': Result.invertRate = !Result.invertRate; break; - } + } else if (arg.length() > 8 && + arg.substring(0, 8).equalsIgnoreCase("-report:")) + { + String error = Result.parseRateOpt(arg.substring(8)); + if (error != null) { + System.err.println("Invalid rate: "+error); + usage(1); } } else { String reason = Group.root.setOption(arg); @@ -411,7 +402,7 @@ public class J2DBench { writer.flush(); } catch(IOException ioe) { ioe.printStackTrace(); - System.out.println("\nERROR : Could not create Loop-Report. Exit"); + System.err.println("\nERROR : Could not create Loop-Report. Exit"); System.exit(1); } } @@ -466,7 +457,7 @@ public class J2DBench { } while(J2DBench.looping); - if(J2DBench.looping) { + if (J2DBench.looping) { writer.println(""); writer.flush(); writer.close(); diff --git a/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java b/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java index 8ca540337f33ff431460d4798f904e22fcfa2f77..91186bd580ad53eca15ed2638e12a8e07c2ab4b0 100644 --- a/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java +++ b/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java @@ -170,7 +170,7 @@ public abstract class Option extends Node implements Modifier { updateGUI(); jcb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == e.SELECTED) { + if (e.getStateChange() == ItemEvent.SELECTED) { JComboBox jcb = (JComboBox) e.getItemSelectable(); value = jcb.getSelectedIndex(); if (J2DBench.verbose.isEnabled()) { @@ -261,7 +261,7 @@ public abstract class Option extends Node implements Modifier { updateGUI(); jcb.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - value = (e.getStateChange() == e.SELECTED); + value = (e.getStateChange() == ItemEvent.SELECTED); if (J2DBench.verbose.isEnabled()) { System.out.println(getOptionString()); } @@ -569,8 +569,6 @@ public abstract class Option extends Node implements Modifier { } public String setValueFromString(String value) { - int prev = 0; - int next = 0; int enabled = 0; StringTokenizer st = new StringTokenizer(value, ","); while (st.hasMoreTokens()) { @@ -588,7 +586,6 @@ public abstract class Option extends Node implements Modifier { if (s != null) { return "Bad value in list ("+s+")"; } - prev = next+1; } this.enabled = enabled; updateGUI(); @@ -623,6 +620,175 @@ public abstract class Option extends Node implements Modifier { } } + public static class ObjectChoice extends Option { + int size; + String optionnames[]; + Object optionvalues[]; + String abbrevnames[]; + String descnames[]; + int defaultselected; + int selected; + JPanel jp; + JComboBox jcombo; + + public ObjectChoice(Group parent, String nodeName, String description, + String optionnames[], + Object optionvalues[], + String abbrevnames[], + String descnames[], + int defaultselected) + { + this(parent, nodeName, description, + Math.min(Math.min(optionnames.length, + optionvalues.length), + Math.min(abbrevnames.length, + descnames.length)), + optionnames, optionvalues, + abbrevnames, descnames, defaultselected); + } + + public ObjectChoice(Group parent, String nodeName, String description, + int size, + String optionnames[], + Object optionvalues[], + String abbrevnames[], + String descnames[], + int defaultselected) + { + super(parent, nodeName, description); + this.size = size; + this.optionnames = trim(optionnames, size); + this.optionvalues = trim(optionvalues, size); + this.abbrevnames = trim(abbrevnames, size); + this.descnames = trim(descnames, size); + this.selected = this.defaultselected = defaultselected; + } + + private static String[] trim(String list[], int size) { + if (list.length == size) { + return list; + } + String newlist[] = new String[size]; + System.arraycopy(list, 0, newlist, 0, size); + return newlist; + } + + private static Object[] trim(Object list[], int size) { + if (list.length == size) { + return list; + } + Object newlist[] = new Object[size]; + System.arraycopy(list, 0, newlist, 0, size); + return newlist; + } + + public void restoreDefault() { + if (selected != defaultselected) { + selected = defaultselected; + updateGUI(); + } + } + + public void updateGUI() { + if (jcombo != null) { + jcombo.setSelectedIndex(this.selected); + } + } + + public boolean isDefault() { + return (selected == defaultselected); + } + + public Modifier.Iterator getIterator(TestEnvironment env) { + return new SwitchIterator(optionvalues, 1 << selected); + } + + public JComponent getJComponent() { + if (jp == null) { + jp = new JPanel(); + jp.setLayout(new BorderLayout()); + jp.add(new JLabel(getDescription()), BorderLayout.WEST); + jcombo = new JComboBox(descnames); + updateGUI(); + jcombo.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + selected = jcombo.getSelectedIndex(); + if (J2DBench.verbose.isEnabled()) { + System.out.println(getOptionString()); + } + } + } + }); + jp.add(jcombo, BorderLayout.EAST); + } + return jp; + } + + public Object getValue() { + return optionvalues[selected]; + } + + public int getIntValue() { + return ((Integer) optionvalues[selected]).intValue(); + } + + public boolean getBooleanValue() { + return ((Boolean) optionvalues[selected]).booleanValue(); + } + + public String getValString() { + return optionnames[selected]; + } + + int findValueIndex(Object value) { + for (int i = 0; i < size; i++) { + if (optionvalues[i] == value) { + return i; + } + } + return -1; + } + + public String getValString(Object value) { + return optionnames[findValueIndex(value)]; + } + + public String getAbbreviatedModifierDescription(Object value) { + return abbrevnames[findValueIndex(value)]; + } + + public String setValue(int v) { + return setValue(new Integer(v)); + } + + public String setValue(boolean v) { + return setValue(new Boolean(v)); + } + + public String setValue(Object value) { + for (int i = 0; i < size; i++) { + if (optionvalues[i].equals(value)) { + this.selected = i; + updateGUI(); + return null; + } + } + return "Bad value"; + } + + public String setValueFromString(String value) { + for (int i = 0; i < size; i++) { + if (optionnames[i].equals(value)) { + this.selected = i; + updateGUI(); + return null; + } + } + return "Bad value"; + } + } + public static class BooleanIterator implements Modifier.Iterator { private Boolean list[]; private int index; diff --git a/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java b/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java index 70dce03002687571b8f0695fbabf6fefc4a948f6..af056bb76ffffa16dddcc97ed9a169f97dfd5f88 100644 --- a/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java +++ b/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java @@ -35,23 +35,199 @@ import java.util.Vector; import java.util.Hashtable; import java.util.Enumeration; import java.io.PrintWriter; +import java.util.HashMap; public class Result { - public static final int UNITS_WHOLE = 0; - public static final int UNITS_THOUSANDS = 1; - public static final int UNITS_MILLIONS = 2; - public static final int UNITS_AUTO = 3; - - public static final int SECONDS_WHOLE = 0; - public static final int SECONDS_MILLIS = 1; - public static final int SECONDS_MICROS = 2; - public static final int SECONDS_NANOS = 3; - public static final int SECONDS_AUTO = 4; - - public static int unitScale = UNITS_WHOLE; - public static int timeScale = SECONDS_WHOLE; - public static boolean useUnits = true; - public static boolean invertRate = false; + public static final int RATE_UNKNOWN = 0; + + public static final int WORK_OPS = 1; + public static final int WORK_UNITS = 2; + public static final int WORK_THOUSANDS = 4; + public static final int WORK_MILLIONS = 6; + public static final int WORK_AUTO = 8; + + public static final int TIME_SECONDS = 10; + public static final int TIME_MILLIS = 11; + public static final int TIME_MICROS = 12; + public static final int TIME_NANOS = 13; + public static final int TIME_AUTO = 14; + + static Group resultoptroot; + static Option.ObjectChoice timeOpt; + static Option.ObjectChoice workOpt; + static Option.ObjectChoice rateOpt; + + public static void init() { + resultoptroot = new Group(TestEnvironment.globaloptroot, + "results", "Result Options"); + + String workStrings[] = { + "units", + "kilounits", + "megaunits", + "autounits", + "ops", + "kiloops", + "megaops", + "autoops", + }; + String workDescriptions[] = { + "Test Units", + "Thousands of Test Units", + "Millions of Test Units", + "Auto-scaled Test Units", + "Operations", + "Thousands of Operations", + "Millions of Operations", + "Auto-scaled Operations", + }; + Integer workObjects[] = { + new Integer(WORK_UNITS), + new Integer(WORK_THOUSANDS), + new Integer(WORK_MILLIONS), + new Integer(WORK_AUTO), + new Integer(WORK_OPS | WORK_UNITS), + new Integer(WORK_OPS | WORK_THOUSANDS), + new Integer(WORK_OPS | WORK_MILLIONS), + new Integer(WORK_OPS | WORK_AUTO), + }; + workOpt = new Option.ObjectChoice(resultoptroot, + "workunits", "Work Units", + workStrings, workObjects, + workStrings, workDescriptions, + 0); + String timeStrings[] = { + "sec", + "msec", + "usec", + "nsec", + "autosec", + }; + String timeDescriptions[] = { + "Seconds", + "Milliseconds", + "Microseconds", + "Nanoseconds", + "Auto-scaled seconds", + }; + Integer timeObjects[] = { + new Integer(TIME_SECONDS), + new Integer(TIME_MILLIS), + new Integer(TIME_MICROS), + new Integer(TIME_NANOS), + new Integer(TIME_AUTO), + }; + timeOpt = new Option.ObjectChoice(resultoptroot, + "timeunits", "Time Units", + timeStrings, timeObjects, + timeStrings, timeDescriptions, + 0); + String rateStrings[] = { + "unitspersec", + "secsperunit", + }; + String rateDescriptions[] = { + "Work units per Time", + "Time units per Work", + }; + Boolean rateObjects[] = { + Boolean.FALSE, + Boolean.TRUE, + }; + rateOpt = new Option.ObjectChoice(resultoptroot, + "ratio", "Rate Ratio", + rateStrings, rateObjects, + rateStrings, rateDescriptions, + 0); + } + + public static boolean isTimeUnit(int unit) { + return (unit >= TIME_SECONDS && unit <= TIME_AUTO); + } + + public static boolean isWorkUnit(int unit) { + return (unit >= WORK_OPS && unit <= (WORK_AUTO | WORK_OPS)); + } + + public static String parseRateOpt(String opt) { + int timeScale = timeOpt.getIntValue(); + int workScale = workOpt.getIntValue(); + boolean invertRate = rateOpt.getBooleanValue(); + int divindex = opt.indexOf('/'); + if (divindex < 0) { + int unit = parseUnit(opt); + if (isTimeUnit(unit)) { + timeScale = unit; + } else if (isWorkUnit(unit)) { + workScale = unit; + } else { + return "Bad unit: "+opt; + } + } else { + int unit1 = parseUnit(opt.substring(0,divindex)); + int unit2 = parseUnit(opt.substring(divindex+1)); + if (isTimeUnit(unit1)) { + if (isWorkUnit(unit2)) { + timeScale = unit1; + workScale = unit2; + invertRate = true; + } else if (isTimeUnit(unit2)) { + return "Both time units: "+opt; + } else { + return "Bad denominator: "+opt; + } + } else if (isWorkUnit(unit1)) { + if (isWorkUnit(unit2)) { + return "Both work units: "+opt; + } else if (isTimeUnit(unit2)) { + timeScale = unit2; + workScale = unit1; + invertRate = false; + } else { + return "Bad denominator: "+opt; + } + } else { + return "Bad numerator: "+opt; + } + } + timeOpt.setValue(timeScale); + workOpt.setValue(workScale); + rateOpt.setValue(invertRate); + return null; + } + + private static HashMap unitMap; + + static { + unitMap = new HashMap(); + unitMap.put("U", new Integer(WORK_UNITS)); + unitMap.put("M", new Integer(WORK_MILLIONS)); + unitMap.put("K", new Integer(WORK_THOUSANDS)); + unitMap.put("A", new Integer(WORK_AUTO)); + unitMap.put("MU", new Integer(WORK_MILLIONS)); + unitMap.put("KU", new Integer(WORK_THOUSANDS)); + unitMap.put("AU", new Integer(WORK_AUTO)); + + unitMap.put("O", new Integer(WORK_UNITS | WORK_OPS)); + unitMap.put("NO", new Integer(WORK_UNITS | WORK_OPS)); + unitMap.put("MO", new Integer(WORK_MILLIONS | WORK_OPS)); + unitMap.put("KO", new Integer(WORK_THOUSANDS | WORK_OPS)); + unitMap.put("AO", new Integer(WORK_AUTO | WORK_OPS)); + + unitMap.put("s", new Integer(TIME_SECONDS)); + unitMap.put("m", new Integer(TIME_MILLIS)); + unitMap.put("u", new Integer(TIME_MICROS)); + unitMap.put("n", new Integer(TIME_NANOS)); + unitMap.put("a", new Integer(TIME_AUTO)); + } + + public static int parseUnit(String c) { + Integer u = (Integer) unitMap.get(c); + if (u != null) { + return u.intValue(); + } + return RATE_UNKNOWN; + } String unitname = "unit"; Test test; @@ -157,69 +333,76 @@ public class Result { } public String getAverageString() { - double units = (useUnits ? getTotalUnits() : getTotalReps()); + int timeScale = timeOpt.getIntValue(); + int workScale = workOpt.getIntValue(); + boolean invertRate = rateOpt.getBooleanValue(); double time = getTotalTime(); + String timeprefix = ""; + switch (timeScale) { + case TIME_AUTO: + case TIME_SECONDS: + time /= 1000; + break; + case TIME_MILLIS: + timeprefix = "m"; + break; + case TIME_MICROS: + time *= 1000.0; + timeprefix = "u"; + break; + case TIME_NANOS: + time *= 1000000.0; + timeprefix = "n"; + break; + } + + String workprefix = ""; + boolean isOps = (workScale & WORK_OPS) != 0; + String workname = isOps ? "op" : unitname; + double work = isOps ? getTotalReps() : getTotalUnits(); + switch (workScale & (~WORK_OPS)) { + case WORK_AUTO: + case WORK_UNITS: + break; + case WORK_THOUSANDS: + work /= 1000.0; + workprefix = "K"; + break; + case WORK_MILLIONS: + work /= 1000000.0; + workprefix = "M"; + break; + } if (invertRate) { - double rate = time / units; - String prefix = ""; - switch (timeScale) { - case SECONDS_WHOLE: - rate /= 1000; - break; - case SECONDS_MILLIS: - prefix = "m"; - break; - case SECONDS_MICROS: - rate *= 1000.0; - prefix = "u"; - break; - case SECONDS_NANOS: - rate *= 1000000.0; - prefix = "n"; - break; - case SECONDS_AUTO: - rate /= 1000.0; + double rate = time / work; + if (timeScale == TIME_AUTO) { if (rate < 1.0) { rate *= 1000.0; - prefix = "m"; + timeprefix = "m"; if (rate < 1.0) { rate *= 1000.0; - prefix = "u"; + timeprefix = "u"; if (rate < 1.0) { rate *= 1000.0; - prefix = "n"; + timeprefix = "n"; } } } - break; } - return rate+" "+prefix+"secs/"+(useUnits ? unitname : "op"); + return rate+" "+timeprefix+"secs/"+workprefix+workname; } else { - double rate = units / (time / 1000.0); - String prefix = ""; - switch (unitScale) { - case UNITS_WHOLE: - break; - case UNITS_THOUSANDS: - rate /= 1000.0; - prefix = "K"; - break; - case UNITS_MILLIONS: - rate /= 1000000.0; - prefix = "M"; - break; - case UNITS_AUTO: + double rate = work / time; + if (workScale == WORK_AUTO) { if (rate > 1000.0) { rate /= 1000.0; - prefix = "K"; + workprefix = "K"; if (rate > 1000.0) { rate /= 1000.0; - prefix = "M"; + workprefix = "M"; } } - break; } - return rate+" "+prefix+(useUnits ? unitname : "op")+"s/sec"; + return rate+" "+workprefix+workname+"s/"+timeprefix+"sec"; } } diff --git a/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java b/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java index 37cab7587d45253784ddc6b6fc715d1fdbfa86be..ed3c7712c4db9d0df81690f6c28c3284d01dbccf 100644 --- a/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java +++ b/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java @@ -61,6 +61,8 @@ public class J2DAnalyzer { "the following result sets are combined into a group"); out.println(" -NoGroup "+ "the following result sets stand on their own"); + out.println(" -ShowUncontested "+ + "show results even when only result set has a result"); out.println(" -Graph "+ "graph the results visually (using lines of *'s)"); out.println(" -Best "+ @@ -83,6 +85,7 @@ public class J2DAnalyzer { public static void main(String argv[]) { boolean gavehelp = false; boolean graph = false; + boolean ignoreuncontested = true; if (argv.length > 0 && argv[0].equalsIgnoreCase("-html")) { String newargs[] = new String[argv.length-1]; System.arraycopy(argv, 1, newargs, 0, newargs.length); @@ -97,6 +100,8 @@ public class J2DAnalyzer { results.add(groupHolder); } else if (arg.equalsIgnoreCase("-NoGroup")) { groupHolder = null; + } else if (arg.equalsIgnoreCase("-ShowUncontested")) { + ignoreuncontested = false; } else if (arg.equalsIgnoreCase("-Graph")) { graph = true; } else if (arg.equalsIgnoreCase("-Best")) { @@ -171,18 +176,23 @@ public class J2DAnalyzer { String key = keys[k]; ResultHolder rh = base.getResultByKey(key); double score = rh.getScore(); - System.out.println(rh.getShortKey()+":"); double maxscore = score; - if (graph) { - for (int i = 0; i < numsets; i++) { - ResultSetHolder rsh = - (ResultSetHolder) results.elementAt(i); - ResultHolder rh2 = rsh.getResultByKey(key); - if (rh2 != null) { + int numcontesting = 0; + for (int i = 0; i < numsets; i++) { + ResultSetHolder rsh = + (ResultSetHolder) results.elementAt(i); + ResultHolder rh2 = rsh.getResultByKey(key); + if (rh2 != null) { + if (graph) { maxscore = Math.max(maxscore, rh2.getBestScore()); } + numcontesting++; } } + if (ignoreuncontested && numcontesting < 2) { + continue; + } + System.out.println(rh.getShortKey()+":"); for (int i = 0; i < numsets; i++) { ResultSetHolder rsh = (ResultSetHolder) results.elementAt(i); System.out.print(rsh.getTitle()+": "); diff --git a/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java b/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java index 2f638c634e7419f167db98210aadc09c068254ab..0746d6b12ae073e045b0bc674f71611c8e92aca7 100644 --- a/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java +++ b/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java @@ -38,6 +38,8 @@ import java.awt.RenderingHints; import java.awt.Polygon; import java.awt.Color; import java.awt.Dimension; +import java.awt.geom.Point2D; +import java.awt.geom.AffineTransform; import java.lang.reflect.Field; import j2dbench.Destinations; @@ -74,6 +76,7 @@ public abstract class GraphicsTests extends Test { static Option animList; static Option sizeList; static Option compRules; + static Option transforms; static Option doExtraAlpha; static Option doXor; static Option doClipping; @@ -167,6 +170,29 @@ public abstract class GraphicsTests extends Test { j, rulenames, rules, rulenames, ruledescs, (1 << defrule)); ((Option.ObjectList) compRules).setNumRows(4); + + Transform xforms[] = { + Identity.instance, + FTranslate.instance, + Scale2x2.instance, + Rotate15.instance, + ShearX.instance, + ShearY.instance, + }; + String xformnames[] = new String[xforms.length]; + String xformdescs[] = new String[xforms.length]; + for (int i = 0; i < xforms.length; i++) { + xformnames[i] = xforms[i].getShortName(); + xformdescs[i] = xforms[i].getDescription(); + } + transforms = + new Option.ObjectList(groptroot, "transform", + "Affine Transform", + xforms.length, + xformnames, xforms, xformnames, + xformdescs, 0x1); + ((Option.ObjectList) transforms).setNumRows(3); + doExtraAlpha = new Option.Toggle(groptroot, "extraalpha", "Render with an \"extra alpha\" of 0.125", @@ -200,6 +226,7 @@ public abstract class GraphicsTests extends Test { int orgX, orgY; int initX, initY; int maxX, maxY; + double pixscale; } public GraphicsTests(Group parent, String nodeName, String description) { @@ -211,7 +238,7 @@ public abstract class GraphicsTests extends Test { public Object initTest(TestEnvironment env, Result result) { Context ctx = createContext(); initContext(env, ctx); - result.setUnits(pixelsTouched(ctx)); + result.setUnits((int) (ctx.pixscale * pixelsTouched(ctx))); result.setUnitName("pixel"); return ctx; } @@ -232,6 +259,9 @@ public abstract class GraphicsTests extends Test { ctx.graphics = env.getGraphics(); int w = env.getWidth(); int h = env.getHeight(); + ctx.size = env.getIntValue(sizeList); + ctx.outdim = getOutputSize(ctx.size, ctx.size); + ctx.pixscale = 1.0; if (hasGraphics2D) { Graphics2D g2d = (Graphics2D) ctx.graphics; AlphaComposite ac = (AlphaComposite) env.getModifier(compRules); @@ -251,11 +281,14 @@ public abstract class GraphicsTests extends Test { p.addPoint(0, 0); g2d.clip(p); } + Transform tx = (Transform) env.getModifier(transforms); + Dimension envdim = new Dimension(w, h); + tx.init(g2d, ctx, envdim); + w = envdim.width; + h = envdim.height; g2d.setRenderingHint(RenderingHints.KEY_RENDERING, env.getModifier(renderHint)); } - ctx.size = env.getIntValue(sizeList); - ctx.outdim = getOutputSize(ctx.size, ctx.size); switch (env.getIntValue(animList)) { case 0: ctx.animate = false; @@ -290,4 +323,201 @@ public abstract class GraphicsTests extends Test { graphics.dispose(); ((Context) ctx).graphics = null; } + + public abstract static class Transform { + public abstract String getShortName(); + public abstract String getDescription(); + public abstract void init(Graphics2D g2d, Context ctx, Dimension dim); + + public static double scaleForPoint(AffineTransform at, + double xorig, double yorig, + double x, double y, + int w, int h) + { + Point2D.Double ptd = new Point2D.Double(x, y); + at.transform(ptd, ptd); + x = ptd.getX(); + y = ptd.getY(); + double scale = 1.0; + if (x < 0) { + scale = Math.min(scale, xorig / (xorig - x)); + } else if (x > w) { + scale = Math.min(scale, (w - xorig) / (x - xorig)); + } + if (y < 0) { + scale = Math.min(scale, yorig / (yorig - y)); + } else if (y > h) { + scale = Math.min(scale, (h - yorig) / (y - yorig)); + } + return scale; + } + + public static Dimension scaleForTransform(AffineTransform at, + Dimension dim) + { + int w = dim.width; + int h = dim.height; + Point2D.Double ptd = new Point2D.Double(0, 0); + at.transform(ptd, ptd); + double ox = ptd.getX(); + double oy = ptd.getY(); + if (ox < 0 || ox > w || oy < 0 || oy > h) { + throw new InternalError("origin outside destination"); + } + double scalex = scaleForPoint(at, ox, oy, w, h, w, h); + double scaley = scalex; + scalex = Math.min(scaleForPoint(at, ox, oy, w, 0, w, h), scalex); + scaley = Math.min(scaleForPoint(at, ox, oy, 0, h, w, h), scaley); + if (scalex < 0 || scaley < 0) { + throw new InternalError("could not fit dims to transform"); + } + return new Dimension((int) Math.floor(w * scalex), + (int) Math.floor(h * scaley)); + } + } + + public static class Identity extends Transform { + public static final Identity instance = new Identity(); + + private Identity() {} + + public String getShortName() { + return "ident"; + } + + public String getDescription() { + return "Identity"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + } + } + + public static class FTranslate extends Transform { + public static final FTranslate instance = new FTranslate(); + + private FTranslate() {} + + public String getShortName() { + return "ftrans"; + } + + public String getDescription() { + return "FTranslate 1.5"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + AffineTransform at = new AffineTransform(); + at.translate(1.5, 1.5); + g2d.transform(at); + dim.setSize(w-3, h-3); + } + } + + public static class Scale2x2 extends Transform { + public static final Scale2x2 instance = new Scale2x2(); + + private Scale2x2() {} + + public String getShortName() { + return "scale2x2"; + } + + public String getDescription() { + return "Scale 2x by 2x"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + AffineTransform at = new AffineTransform(); + at.scale(2.0, 2.0); + g2d.transform(at); + dim.setSize(w/2, h/2); + ctx.pixscale = 4; + } + } + + public static class Rotate15 extends Transform { + public static final Rotate15 instance = new Rotate15(); + + private Rotate15() {} + + public String getShortName() { + return "rot15"; + } + + public String getDescription() { + return "Rotate 15 degrees"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + double theta = Math.toRadians(15); + double cos = Math.cos(theta); + double sin = Math.sin(theta); + double xsize = sin * h + cos * w; + double ysize = sin * w + cos * h; + double scale = Math.min(w / xsize, h / ysize); + xsize *= scale; + ysize *= scale; + AffineTransform at = new AffineTransform(); + at.translate((w - xsize) / 2.0, (h - ysize) / 2.0); + at.translate(sin * h * scale, 0.0); + at.rotate(theta); + g2d.transform(at); + dim.setSize(scaleForTransform(at, dim)); + } + } + + public static class ShearX extends Transform { + public static final ShearX instance = new ShearX(); + + private ShearX() {} + + public String getShortName() { + return "shearx"; + } + + public String getDescription() { + return "Shear X to the right"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + AffineTransform at = new AffineTransform(); + at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2); + at.shear(0.1, 0.0); + g2d.transform(at); + dim.setSize(scaleForTransform(at, dim)); + } + } + + public static class ShearY extends Transform { + public static final ShearY instance = new ShearY(); + + private ShearY() {} + + public String getShortName() { + return "sheary"; + } + + public String getDescription() { + return "Shear Y down"; + } + + public void init(Graphics2D g2d, Context ctx, Dimension dim) { + int w = dim.width; + int h = dim.height; + AffineTransform at = new AffineTransform(); + at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0); + at.shear(0.0, 0.1); + g2d.transform(at); + dim.setSize(scaleForTransform(at, dim)); + } + } } diff --git a/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java b/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java index 9960a7b704619b1a080943ba6a50bf754fc8ad78..ef607fd0b08642b712df79f294cc0b1d00edcb5d 100644 --- a/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java +++ b/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java @@ -454,7 +454,7 @@ public abstract class TextTests extends Test { taaNames, taaHints, taaNames, taaNames, 0x1); - ((Option.ObjectList) taaList).setNumRows(2); + ((Option.ObjectList) taaList).setNumRows(6); // add special TextAAOpt for backwards compatibility with // older options files new TextAAOpt(); @@ -707,3 +707,4 @@ public abstract class TextTests extends Test { } } } + diff --git a/src/share/lib/security/sunpkcs11-solaris.cfg b/src/share/lib/security/sunpkcs11-solaris.cfg index 4ceccc3d08d14a9259bc2fedfce92196c2ed4867..d0b34ca134dcb1e643c856ef3b6682f654c83471 100644 --- a/src/share/lib/security/sunpkcs11-solaris.cfg +++ b/src/share/lib/security/sunpkcs11-solaris.cfg @@ -31,5 +31,9 @@ disabledMechanisms = { CKM_SHA256_RSA_PKCS CKM_SHA384_RSA_PKCS CKM_SHA512_RSA_PKCS +# the following mechanisms are disabled to ensure backward compatibility (Solaris bug 6545046) + CKM_DES_CBC_PAD + CKM_DES3_CBC_PAD + CKM_AES_CBC_PAD } diff --git a/src/share/native/java/util/zip/Deflater.c b/src/share/native/java/util/zip/Deflater.c index f0923c447ba1fb27149beabb6f1578f66534bebd..e12d540a5444865d1135e22bb1e74d3a119f7cbe 100644 --- a/src/share/native/java/util/zip/Deflater.c +++ b/src/share/native/java/util/zip/Deflater.c @@ -132,14 +132,17 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr, in_buf = (jbyte *) malloc(this_len); if (in_buf == 0) { - JNU_ThrowOutOfMemoryError(env, 0); + // Throw OOME only when length is not zero + if (this_len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } (*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf); out_buf = (jbyte *) malloc(len); if (out_buf == 0) { free(in_buf); - JNU_ThrowOutOfMemoryError(env, 0); + if (len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } @@ -173,7 +176,8 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr, jboolean finish = (*env)->GetBooleanField(env, this, finishID); in_buf = (jbyte *) malloc(this_len); if (in_buf == 0) { - JNU_ThrowOutOfMemoryError(env, 0); + if (this_len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } (*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf); @@ -181,7 +185,8 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr, out_buf = (jbyte *) malloc(len); if (out_buf == 0) { free(in_buf); - JNU_ThrowOutOfMemoryError(env, 0); + if (len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } diff --git a/src/share/native/java/util/zip/Inflater.c b/src/share/native/java/util/zip/Inflater.c index 78619f4ac0f0d7f9f1bd4ef9c2922251ae511f60..c1667a022e842defbeac6db191139172f2e36028 100644 --- a/src/share/native/java/util/zip/Inflater.c +++ b/src/share/native/java/util/zip/Inflater.c @@ -135,7 +135,8 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr, in_buf = (jbyte *) malloc(in_len); if (in_buf == 0) { - JNU_ThrowOutOfMemoryError(env, 0); + if (in_len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } (*env)->GetByteArrayRegion(env, this_buf, this_off, in_len, in_buf); @@ -143,7 +144,8 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr, out_buf = (jbyte *) malloc(len); if (out_buf == 0) { free(in_buf); - JNU_ThrowOutOfMemoryError(env, 0); + if (len != 0) + JNU_ThrowOutOfMemoryError(env, 0); return 0; } diff --git a/src/share/native/java/util/zip/zip_util.c b/src/share/native/java/util/zip/zip_util.c index 222fe7387584f9b80931f5695f30296b58c372f3..3fea30c549ecebf2f46de9eb5fe30e5d3c049461 100644 --- a/src/share/native/java/util/zip/zip_util.c +++ b/src/share/native/java/util/zip/zip_util.c @@ -314,7 +314,7 @@ findEND(jzfile *zip, void *endbuf) if (pos < 0) { /* Pretend there are some NUL bytes before start of file */ off = -pos; - memset(buf, '\0', off); + memset(buf, '\0', (size_t)off); } if (readFullyAt(zfd, buf + off, sizeof(buf) - off, @@ -426,7 +426,7 @@ static int isMetaName(const char *name, int length) { const char *s; - if (length < sizeof("META-INF/") - 1) + if (length < (int)sizeof("META-INF/") - 1) return 0; for (s = "META-INF/"; *s != '\0'; s++) { char c = *name++; @@ -912,7 +912,7 @@ readCENHeader(jzfile *zip, jlong cenpos, jint bufsize) ZFILE zfd = zip->zfd; char *cen; if (bufsize > zip->len - cenpos) - bufsize = zip->len - cenpos; + bufsize = (jint)(zip->len - cenpos); if ((cen = malloc(bufsize)) == NULL) goto Catch; if (readFullyAt(zfd, cen, bufsize, cenpos) == -1) goto Catch; censize = CENSIZE(cen); @@ -1256,6 +1256,9 @@ ZIP_GetEntryDataOffset(jzfile *zip, jzentry *entry) * file had been previously locked with ZIP_Lock(). Returns the * number of bytes read, or -1 if an error occurred. If zip->msg != 0 * then a zip error occurred and zip->msg contains the error text. + * + * The current implementation does not support reading an entry that + * has the size bigger than 2**32 bytes in ONE invocation. */ jint ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) @@ -1276,7 +1279,7 @@ ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) if (len <= 0) return 0; if (len > entry_size - pos) - len = entry_size - pos; + len = (jint)(entry_size - pos); /* Get file offset to start reading data */ start = ZIP_GetEntryDataOffset(zip, entry); @@ -1306,6 +1309,9 @@ ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) * from ZIP/JAR files specified in the class path. It is defined here * so that it can be dynamically loaded by the runtime if the zip library * is found. + * + * The current implementation does not support reading an entry that + * has the size bigger than 2**32 bytes in ONE invocation. */ jboolean InflateFully(jzfile *zip, jzentry *entry, void *buf, char **msg) @@ -1314,7 +1320,6 @@ InflateFully(jzfile *zip, jzentry *entry, void *buf, char **msg) char tmp[BUF_SIZE]; jlong pos = 0; jlong count = entry->csize; - jboolean status; *msg = 0; /* Reset error message */ @@ -1330,10 +1335,10 @@ InflateFully(jzfile *zip, jzentry *entry, void *buf, char **msg) } strm.next_out = buf; - strm.avail_out = entry->size; + strm.avail_out = (uInt)entry->size; while (count > 0) { - jint n = count > (jlong)sizeof(tmp) ? (jint)sizeof(tmp) : count; + jint n = count > (jlong)sizeof(tmp) ? (jint)sizeof(tmp) : (jint)count; ZIP_Lock(zip); n = ZIP_Read(zip, entry, pos, tmp, n); ZIP_Unlock(zip); @@ -1368,12 +1373,16 @@ InflateFully(jzfile *zip, jzentry *entry, void *buf, char **msg) return JNI_TRUE; } +/* + * The current implementation does not support reading an entry that + * has the size bigger than 2**32 bytes in ONE invocation. + */ jzentry * JNICALL ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP) { jzentry *entry = ZIP_GetEntry(zip, name, 0); if (entry) { - *sizeP = entry->size; + *sizeP = (jint)entry->size; *nameLenP = strlen(entry->name); } return entry; diff --git a/src/share/native/java/util/zip/zlib-1.2.3/compress.c b/src/share/native/java/util/zip/zlib-1.2.3/compress.c index c82999dcf9db70ea219a08473582f18143798b42..58669987cafa7ba414ddbfa6e34404536b400397 100644 --- a/src/share/native/java/util/zip/zlib-1.2.3/compress.c +++ b/src/share/native/java/util/zip/zlib-1.2.3/compress.c @@ -75,7 +75,7 @@ int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) deflateEnd(&stream); return err == Z_OK ? Z_BUF_ERROR : err; } - *destLen = stream.total_out; + *destLen = (uLong)stream.total_out; err = deflateEnd(&stream); return err; diff --git a/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c b/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c index c38dc304c45a4bcbbe4a3e0020680e545bba6531..d2e4ef4c97e2822bc9aa45fe9d797cfa09b2cc84 100644 --- a/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c +++ b/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c @@ -78,7 +78,7 @@ int ZEXPORT uncompress (dest, destLen, source, sourceLen) return Z_DATA_ERROR; return err; } - *destLen = stream.total_out; + *destLen = (uLong)stream.total_out; err = inflateEnd(&stream); return err; diff --git a/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java b/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java index f67efb57fb687b6982e343dd0f4f4c3082099827..572a9200064e7c96024f36d861024fdae332bb8e 100644 --- a/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java +++ b/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java @@ -57,9 +57,12 @@ class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer { private native void run(String title, int mode, String dir, String file, FilenameFilter filter, boolean isMultipleMode); - private native void quit(); + @Override + public native void toFront(); + + /** * Called exclusively by the native C code. */ diff --git a/src/solaris/classes/sun/awt/X11/XFramePeer.java b/src/solaris/classes/sun/awt/X11/XFramePeer.java index 8ff374b0f372f1fe55fc6f6b9e42112f954ee12f..771749fb8bbd67fcf0f146978cd975bff3888e7b 100644 --- a/src/solaris/classes/sun/awt/X11/XFramePeer.java +++ b/src/solaris/classes/sun/awt/X11/XFramePeer.java @@ -150,6 +150,8 @@ class XFramePeer extends XDecoratedPeer implements FramePeer { void updateChildrenSizes() { super.updateChildrenSizes(); + int height = getMenuBarHeight(); + // XWindow.reshape calls XBaseWindow.xSetBounds, which acquires // the AWT lock, so we have to acquire the AWT lock here // before getStateLock() to avoid a deadlock with the Toolkit thread @@ -159,7 +161,7 @@ class XFramePeer extends XDecoratedPeer implements FramePeer { synchronized(getStateLock()) { int width = dimensions.getClientSize().width; if (menubarPeer != null) { - menubarPeer.reshape(0, 0, width, getMenuBarHeight()); + menubarPeer.reshape(0, 0, width, height); } } } finally { diff --git a/src/solaris/native/java/net/net_util_md.c b/src/solaris/native/java/net/net_util_md.c index 43baab96ea8024d17b45f17ae7a91e3668365e1b..236c643c95971f9e31b353ebc6cf8933201aeaea 100644 --- a/src/solaris/native/java/net/net_util_md.c +++ b/src/solaris/native/java/net/net_util_md.c @@ -33,6 +33,7 @@ #include #include #include +#include #ifdef __solaris__ #include @@ -75,17 +76,17 @@ getnameinfo_f getnameinfo_ptr = NULL; #endif #ifdef __solaris__ -static int init_max_buf; +static int init_tcp_max_buf, init_udp_max_buf; static int tcp_max_buf; static int udp_max_buf; /* * Get the specified parameter from the specified driver. The value * of the parameter is assumed to be an 'int'. If the parameter - * cannot be obtained return the specified default value. + * cannot be obtained return -1 */ static int -getParam(char *driver, char *param, int dflt) +getParam(char *driver, char *param) { struct strioctl stri; char buf [64]; @@ -94,7 +95,7 @@ getParam(char *driver, char *param, int dflt) s = open (driver, O_RDWR); if (s < 0) { - return dflt; + return -1; } strncpy (buf, param, sizeof(buf)); stri.ic_cmd = ND_GET; @@ -102,13 +103,64 @@ getParam(char *driver, char *param, int dflt) stri.ic_dp = buf; stri.ic_len = sizeof(buf); if (ioctl (s, I_STR, &stri) < 0) { - value = dflt; + value = -1; } else { value = atoi(buf); } close (s); return value; } + +/* + * Iterative way to find the max value that SO_SNDBUF or SO_RCVBUF + * for Solaris versions that do not support the ioctl() in getParam(). + * Ugly, but only called once (for each sotype). + * + * As an optimisation, we make a guess using the default values for Solaris + * assuming they haven't been modified with ndd. + */ + +#define MAX_TCP_GUESS 1024 * 1024 +#define MAX_UDP_GUESS 2 * 1024 * 1024 + +#define FAIL_IF_NOT_ENOBUFS if (errno != ENOBUFS) return -1 + +static int findMaxBuf(int fd, int opt, int sotype) { + int a = 0; + int b = MAXINT; + int initial_guess; + int limit = -1; + + if (sotype == SOCK_DGRAM) { + initial_guess = MAX_UDP_GUESS; + } else { + initial_guess = MAX_TCP_GUESS; + } + + if (setsockopt(fd, SOL_SOCKET, opt, &initial_guess, sizeof(int)) == 0) { + initial_guess++; + if (setsockopt(fd, SOL_SOCKET, opt, &initial_guess,sizeof(int)) < 0) { + FAIL_IF_NOT_ENOBUFS; + return initial_guess - 1; + } + a = initial_guess; + } else { + FAIL_IF_NOT_ENOBUFS; + b = initial_guess - 1; + } + do { + int mid = a + (b-a)/2; + if (setsockopt(fd, SOL_SOCKET, opt, &mid, sizeof(int)) == 0) { + limit = mid; + a = mid + 1; + } else { + FAIL_IF_NOT_ENOBUFS; + b = mid - 1; + } + } while (b >= a); + + return limit; +} #endif #ifdef __linux__ @@ -1148,7 +1200,6 @@ NET_GetSockOpt(int fd, int level, int opt, void *result, return rv; } - /* * Wrapper for setsockopt system routine - performs any * necessary pre/post processing to deal with OS specific @@ -1212,7 +1263,7 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, #ifdef __solaris__ if (level == SOL_SOCKET) { if (opt == SO_SNDBUF || opt == SO_RCVBUF) { - int sotype, arglen; + int sotype=0, arglen; int *bufsize, maxbuf; int ret; @@ -1223,18 +1274,37 @@ NET_SetSockOpt(int fd, int level, int opt, const void *arg, /* Exceeded system limit so clamp and retry */ - if (!init_max_buf) { - tcp_max_buf = getParam("/dev/tcp", "tcp_max_buf", 1024*1024); - udp_max_buf = getParam("/dev/udp", "udp_max_buf", 2048*1024); - init_max_buf = 1; - } - arglen = sizeof(sotype); if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) < 0) { return -1; } + /* + * We try to get tcp_maxbuf (and udp_max_buf) using + * an ioctl() that isn't available on all versions of Solaris. + * If that fails, we use the search algorithm in findMaxBuf() + */ + if (!init_tcp_max_buf && sotype == SOCK_STREAM) { + tcp_max_buf = getParam("/dev/tcp", "tcp_max_buf"); + if (tcp_max_buf == -1) { + tcp_max_buf = findMaxBuf(fd, opt, SOCK_STREAM); + if (tcp_max_buf == -1) { + return -1; + } + } + init_tcp_max_buf = 1; + } else if (!init_udp_max_buf && sotype == SOCK_DGRAM) { + udp_max_buf = getParam("/dev/udp", "udp_max_buf"); + if (udp_max_buf == -1) { + udp_max_buf = findMaxBuf(fd, opt, SOCK_DGRAM); + if (udp_max_buf == -1) { + return -1; + } + } + init_udp_max_buf = 1; + } + maxbuf = (sotype == SOCK_STREAM) ? tcp_max_buf : udp_max_buf; bufsize = (int *)arg; if (*bufsize > maxbuf) { diff --git a/src/solaris/native/sun/awt/gtk2_interface.c b/src/solaris/native/sun/awt/gtk2_interface.c index a26a839d1200b29e5c333e91959090d9f70f17b3..767fe47cf07780955bace9bb5b541c9610968e71 100644 --- a/src/solaris/native/sun/awt/gtk2_interface.c +++ b/src/solaris/native/sun/awt/gtk2_interface.c @@ -607,6 +607,7 @@ gboolean gtk2_load() fp_gtk_tree_view_new = dl_symbol("gtk_tree_view_new"); fp_gtk_viewport_new = dl_symbol("gtk_viewport_new"); fp_gtk_window_new = dl_symbol("gtk_window_new"); + fp_gtk_window_present = dl_symbol("gtk_window_present"); fp_gtk_dialog_new = dl_symbol("gtk_dialog_new"); fp_gtk_frame_new = dl_symbol("gtk_frame_new"); diff --git a/src/solaris/native/sun/awt/gtk2_interface.h b/src/solaris/native/sun/awt/gtk2_interface.h index 3ecaf94af203883af8a18898cff019336f9a5746..c7265bff4a7ff7bfe59ea905a5d14accf2296d65 100644 --- a/src/solaris/native/sun/awt/gtk2_interface.h +++ b/src/solaris/native/sun/awt/gtk2_interface.h @@ -749,6 +749,7 @@ int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf); int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf); GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error); void (*fp_gtk_widget_destroy)(GtkWidget *widget); +void (*fp_gtk_window_present)(GtkWindow *window); /** diff --git a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c index 890284e570e423f7123035c75cd775f449e723ce..1832401e4fbce430ad078923a776420c70edef4c 100644 --- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c +++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c @@ -80,6 +80,28 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit quit(env, jpeer, FALSE); } +/* + * Class: sun_awt_X11_GtkFileDialogPeer + * Method: toFront + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront +(JNIEnv * env, jobject jpeer) +{ + GtkWidget * dialog; + + fp_gdk_threads_enter(); + + dialog = (GtkWidget*)jlong_to_ptr( + (*env)->GetLongField(env, jpeer, widgetFieldID)); + + if (dialog != NULL) { + fp_gtk_window_present((GtkWindow*)dialog); + } + + fp_gdk_threads_leave(); +} + /** * Convert a GSList to an array of filenames (without the parent folder) */ diff --git a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h index 7c3c2338d10d4a85ed286520141b32db94d0962f..81ed11ae5550ea594d3c85c20ecfcff90972b202 100644 --- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h +++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h @@ -33,6 +33,14 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_run JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit (JNIEnv *, jobject); +/* + * Class: sun_awt_X11_GtkFileDialogPeer + * Method: toFront + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront +(JNIEnv *, jobject); + #ifdef __cplusplus } #endif diff --git a/src/windows/classes/sun/awt/windows/WFramePeer.java b/src/windows/classes/sun/awt/windows/WFramePeer.java index f5b537c5ae5d26f50860b476831c7bd88f1b5d00..78eeaf0147ff84ab6f3903a4efdd028d5d9068e2 100644 --- a/src/windows/classes/sun/awt/windows/WFramePeer.java +++ b/src/windows/classes/sun/awt/windows/WFramePeer.java @@ -79,10 +79,50 @@ class WFramePeer extends WWindowPeer implements FramePeer { if (b == null) { clearMaximizedBounds(); } else { - setMaximizedBounds(b.x, b.y, b.width, b.height); + Rectangle adjBounds = (Rectangle)b.clone(); + adjustMaximizedBounds(adjBounds); + setMaximizedBounds(adjBounds.x, adjBounds.y, adjBounds.width, adjBounds.height); } } + /** + * The incoming bounds describe the maximized size and position of the + * window on the monitor that displays the window. But the window manager + * expects that the bounds are based on the size and position of the + * primary monitor, even if the window ultimately maximizes onto a + * secondary monitor. And the window manager adjusts these values to + * compensate for differences between the primary monitor and the monitor + * that displays the window. + * The method translates the incoming bounds to the values acceptable + * by the window manager. For more details, please refer to 6699851. + */ + private void adjustMaximizedBounds(Rectangle b) { + GraphicsConfiguration currentDevGC = getGraphicsConfiguration(); + + GraphicsDevice primaryDev = GraphicsEnvironment + .getLocalGraphicsEnvironment().getDefaultScreenDevice(); + GraphicsConfiguration primaryDevGC = primaryDev.getDefaultConfiguration(); + + if (currentDevGC != null && currentDevGC != primaryDevGC) { + Rectangle currentDevBounds = currentDevGC.getBounds(); + Rectangle primaryDevBounds = primaryDevGC.getBounds(); + + b.width -= (currentDevBounds.width - primaryDevBounds.width); + b.height -= (currentDevBounds.height - primaryDevBounds.height); + } + } + + @Override + public boolean updateGraphicsData(GraphicsConfiguration gc) { + boolean result = super.updateGraphicsData(gc); + Rectangle bounds = AWTAccessor.getFrameAccessor(). + getMaximizedBounds((Frame)target); + if (bounds != null) { + setMaximizedBounds(bounds); + } + return result; + } + @Override boolean isTargetUndecorated() { return ((Frame)target).isUndecorated(); diff --git a/src/windows/classes/sun/security/krb5/internal/tools/Ktab.java b/src/windows/classes/sun/security/krb5/internal/tools/Ktab.java index 9bcc935a1ca2f9fe5e9a9725d229aaf778a31933..216c3a30c1273b908801649438ce18d7bbc04a45 100644 --- a/src/windows/classes/sun/security/krb5/internal/tools/Ktab.java +++ b/src/windows/classes/sun/security/krb5/internal/tools/Ktab.java @@ -129,7 +129,7 @@ public class Ktab { ktab.deleteEntry(); break; default: - ktab.printHelp(); + ktab.error("A command must be provided"); } } @@ -232,7 +232,7 @@ public class Ktab { append = true; break; default: - printHelp(); + error("Unknown command: " + args[i]); break; } } else { // optional standalone arguments diff --git a/src/windows/native/sun/windows/awt_Choice.cpp b/src/windows/native/sun/windows/awt_Choice.cpp index 8c1621afec6f39a80461ecbb58a6dc7f76da1542..e8296d4c514e85e3fba96f370845e4f25c5e5e9d 100644 --- a/src/windows/native/sun/windows/awt_Choice.cpp +++ b/src/windows/native/sun/windows/awt_Choice.cpp @@ -86,6 +86,7 @@ static const UINT MINIMUM_NUMBER_OF_VISIBLE_ITEMS = 8; AwtChoice::AwtChoice() { m_hList = NULL; m_listDefWindowProc = NULL; + m_selectedItem = -1; } LPCTSTR AwtChoice::GetClassName() { @@ -437,9 +438,10 @@ LRESULT CALLBACK AwtChoice::ListWindowProc(HWND hwnd, UINT message, MsgRouting AwtChoice::WmNotify(UINT notifyCode) { if (notifyCode == CBN_SELCHANGE) { - int itemSelect = (int)SendMessage(CB_GETCURSEL); - if (itemSelect != CB_ERR){ - DoCallback("handleAction", "(I)V", itemSelect); + int selectedItem = (int)SendMessage(CB_GETCURSEL); + if (selectedItem != CB_ERR && m_selectedItem != selectedItem){ + m_selectedItem = selectedItem; + DoCallback("handleAction", "(I)V", selectedItem); } } else if (notifyCode == CBN_DROPDOWN) { diff --git a/src/windows/native/sun/windows/awt_Choice.h b/src/windows/native/sun/windows/awt_Choice.h index 4852301bb3d816bf945424fe53145497cc4883d8..ad0a21d23ae563157d2f59b21adbdcc0fc6e7ed9 100644 --- a/src/windows/native/sun/windows/awt_Choice.h +++ b/src/windows/native/sun/windows/awt_Choice.h @@ -94,6 +94,7 @@ private: static BOOL sm_isMouseMoveInList; HWND m_hList; WNDPROC m_listDefWindowProc; + int m_selectedItem; static LRESULT CALLBACK ListWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); }; diff --git a/src/windows/resource/java.manifest b/src/windows/resource/java.manifest index dde8ca07c0409bc542a5b212bf9784ce3d48a126..61ec5999e19d31bca7f71d2c544c0fd6018e5613 100644 --- a/src/windows/resource/java.manifest +++ b/src/windows/resource/java.manifest @@ -3,7 +3,7 @@ AWT diff --git a/test/ProblemList.txt b/test/ProblemList.txt index ed75606e211411a7856ac86ef015b27cf0a8346d..be1f7850556264c091c21f0892cebd7991ddfc44 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -734,10 +734,6 @@ java/util/concurrent/FutureTask/BlockingTaskExecutor.java generic-all # Problems on windows, jmap.exe hangs? (these run jmap), fails on Solaris 10 x86 java/util/concurrent/locks/Lock/TimedAcquireLeak.java generic-all -# Solaris sparc client, some failures, "1 not equal to 3"? -# also Linux problems with samevm mode, -server linux i586? 1 not equal to 3? -java/util/concurrent/Executors/AutoShutdown.java generic-all - # Fails on solaris-sparc -server (Set not equal to copy. 1) java/util/EnumSet/EnumSetBash.java solaris-sparc diff --git a/test/com/sun/net/httpserver/Test.java b/test/com/sun/net/httpserver/Test.java index dee86723a2d71362be6a6b1ad9a5bd580734f871..520912e111a10006fcddec805fd44c2362e1133d 100644 --- a/test/com/sun/net/httpserver/Test.java +++ b/test/com/sun/net/httpserver/Test.java @@ -22,8 +22,20 @@ */ import com.sun.net.httpserver.*; +import java.util.logging.*; public class Test { + + static Logger logger; + + static void enableLogging() { + logger = Logger.getLogger("com.sun.net.httpserver"); + Handler h = new ConsoleHandler(); + h.setLevel(Level.ALL); + logger.setLevel(Level.ALL); + logger.addHandler(h); + } + static void delay () { try { Thread.sleep (1000); diff --git a/test/com/sun/net/httpserver/Test1.java b/test/com/sun/net/httpserver/Test1.java index e58900e0f7da99468f103122c81cfdda78e4381a..37533d127498c5087951ff3fd95d7260f1694cc8 100644 --- a/test/com/sun/net/httpserver/Test1.java +++ b/test/com/sun/net/httpserver/Test1.java @@ -25,6 +25,7 @@ * @test * @bug 6270015 * @run main/othervm Test1 + * @run main/othervm -Dsun.net.httpserver.maxReqTime=10 Test1 * @summary Light weight HTTP server */ diff --git a/test/com/sun/net/httpserver/Test13.java b/test/com/sun/net/httpserver/Test13.java index a42993220385182c45ab37cca77e98cecf2c1ad6..baf9e9ef8b9afb26d48f0b6b058fd08d5610fef4 100644 --- a/test/com/sun/net/httpserver/Test13.java +++ b/test/com/sun/net/httpserver/Test13.java @@ -31,6 +31,7 @@ import com.sun.net.httpserver.*; import java.util.concurrent.*; +import java.util.logging.*; import java.io.*; import java.net.*; @@ -45,12 +46,19 @@ public class Test13 extends Test { static SSLContext ctx; + final static int NUM = 32; // was 32 + static boolean fail = false; public static void main (String[] args) throws Exception { HttpServer s1 = null; HttpsServer s2 = null; ExecutorService executor=null; + Logger l = Logger.getLogger ("com.sun.net.httpserver"); + Handler ha = new ConsoleHandler(); + ha.setLevel(Level.ALL); + l.setLevel(Level.ALL); + l.addHandler(ha); try { String root = System.getProperty ("test.src")+ "/docs"; System.out.print ("Test13: "); @@ -70,10 +78,10 @@ public class Test13 extends Test { int port = s1.getAddress().getPort(); int httpsport = s2.getAddress().getPort(); - Runner r[] = new Runner[64]; - for (int i=0; i<32; i++) { + Runner r[] = new Runner[NUM*2]; + for (int i=0; i>> StringCharBufferSliceTest-main: testing slice with result of slice"); + buff.position(0); + buff.limit(buff.capacity()); + slice = buff.slice(); + for (int i=0; i<4; i++) { + slice.position(i); + CharBuffer nextSlice = slice.slice(); + if (nextSlice.position() != 0) + throw new RuntimeException("New buffer's position should be zero"); + if (!nextSlice.equals(slice)) + throw new RuntimeException("New buffer should be equal"); + slice = nextSlice; + } + System.out.println( ">>> StringCharBufferSliceTest-main: testing toString."); buff.position(4); buff.limit(7); slice = buff.slice(); - if (! slice.toString().equals("tes")) { + if (!slice.toString().equals("tes")) { throw new RuntimeException("bad toString() after slice(): " + slice.toString()); } @@ -104,6 +119,7 @@ public class StringCharBufferSliceTest { || dupe.charAt(2) != 's' || dupe.charAt(3) != 't') { throw new RuntimeException("bad duplicate() after slice(): '" + dupe + "'"); } + System.out.println(">>> StringCharBufferSliceTest-main: done!"); } diff --git a/test/java/nio/channels/AsynchronousSocketChannel/Basic.java b/test/java/nio/channels/AsynchronousSocketChannel/Basic.java index e8f23f46866a4e333b3c68eb771ec3d3b1682591..b38e34efbc052bc83026e99db983014f608b9048 100644 --- a/test/java/nio/channels/AsynchronousSocketChannel/Basic.java +++ b/test/java/nio/channels/AsynchronousSocketChannel/Basic.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4607272 6842687 + * @bug 4607272 6842687 6878369 * @summary Unit test for AsynchronousSocketChannel * @run main/timeout=600 Basic */ @@ -712,52 +712,57 @@ public class Basic { } static void testTimeout() throws Exception { + System.out.println("-- timeouts --"); + testTimeout(Integer.MIN_VALUE, TimeUnit.SECONDS); + testTimeout(-1L, TimeUnit.SECONDS); + testTimeout(0L, TimeUnit.SECONDS); + testTimeout(2L, TimeUnit.SECONDS); + } + + static void testTimeout(final long timeout, final TimeUnit unit) throws Exception { Server server = new Server(); AsynchronousSocketChannel ch = AsynchronousSocketChannel.open(); ch.connect(server.address()).get(); - System.out.println("-- timeout when reading --"); - ByteBuffer dst = ByteBuffer.allocate(512); final AtomicReference readException = new AtomicReference(); - // this read should timeout - ch.read(dst, 3, TimeUnit.SECONDS, (Void)null, - new CompletionHandler() - { + // this read should timeout if value is > 0 + ch.read(dst, timeout, unit, null, new CompletionHandler() { public void completed(Integer result, Void att) { - throw new RuntimeException("Should not complete"); + readException.set(new RuntimeException("Should not complete")); } public void failed(Throwable exc, Void att) { readException.set(exc); } }); - // wait for exception - while (readException.get() == null) { - Thread.sleep(100); - } - if (!(readException.get() instanceof InterruptedByTimeoutException)) - throw new RuntimeException("InterruptedByTimeoutException expected"); + if (timeout > 0L) { + // wait for exception + while (readException.get() == null) { + Thread.sleep(100); + } + if (!(readException.get() instanceof InterruptedByTimeoutException)) + throw new RuntimeException("InterruptedByTimeoutException expected"); - // after a timeout then further reading should throw unspecified runtime exception - boolean exceptionThrown = false; - try { - ch.read(dst); - } catch (RuntimeException x) { - exceptionThrown = true; + // after a timeout then further reading should throw unspecified runtime exception + boolean exceptionThrown = false; + try { + ch.read(dst); + } catch (RuntimeException x) { + exceptionThrown = true; + } + if (!exceptionThrown) + throw new RuntimeException("RuntimeException expected after timeout."); + } else { + Thread.sleep(1000); + Throwable exc = readException.get(); + if (exc != null) + throw new RuntimeException(exc); } - if (!exceptionThrown) - throw new RuntimeException("RuntimeException expected after timeout."); - - - System.out.println("-- timeout when writing --"); final AtomicReference writeException = new AtomicReference(); - final long timeout = 5; - final TimeUnit unit = TimeUnit.SECONDS; - // write bytes to fill socket buffer ch.write(genBuffer(), timeout, unit, ch, new CompletionHandler() @@ -769,24 +774,32 @@ public class Basic { writeException.set(exc); } }); + if (timeout > 0) { + // wait for exception + while (writeException.get() == null) { + Thread.sleep(100); + } + if (!(writeException.get() instanceof InterruptedByTimeoutException)) + throw new RuntimeException("InterruptedByTimeoutException expected"); - // wait for exception - while (writeException.get() == null) { - Thread.sleep(100); - } - if (!(writeException.get() instanceof InterruptedByTimeoutException)) - throw new RuntimeException("InterruptedByTimeoutException expected"); - - // after a timeout then further writing should throw unspecified runtime exception - exceptionThrown = false; - try { - ch.write(genBuffer()); - } catch (RuntimeException x) { - exceptionThrown = true; + // after a timeout then further writing should throw unspecified runtime exception + boolean exceptionThrown = false; + try { + ch.write(genBuffer()); + } catch (RuntimeException x) { + exceptionThrown = true; + } + if (!exceptionThrown) + throw new RuntimeException("RuntimeException expected after timeout."); + } else { + Thread.sleep(1000); + Throwable exc = writeException.get(); + if (exc != null) + throw new RuntimeException(exc); } - if (!exceptionThrown) - throw new RuntimeException("RuntimeException expected after timeout."); + // clean-up + server.accept().close(); ch.close(); server.close(); } diff --git a/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh b/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh index 717857c9cbc628cc3bf433d1b295c98efa50f23b..b11ddd8929c8d8b5e227a4d2834d37bf2f6bef62 100644 --- a/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh +++ b/test/java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh @@ -68,11 +68,10 @@ case "$OS" in ;; esac -# remove old class files cd ${TESTCLASSES}${FILESEP} -rm -f ClassLoaderDeadlock.class -rm -rf provider -mkdir provider +if [ ! -d provider ] ; then + mkdir provider +fi # compile the test program ${TESTJAVA}${FILESEP}bin${FILESEP}javac \ @@ -88,4 +87,11 @@ ${TESTJAVA}${FILESEP}bin${FILESEP}java \ -classpath "${TESTCLASSES}${PATHSEP}${TESTSRC}${FILESEP}Deadlock.jar" \ ClassLoaderDeadlock -exit $? +STATUS=$? + +# clean up +rm -f 'ClassLoaderDeadlock.class' 'ClassLoaderDeadlock$1.class' \ +'ClassLoaderDeadlock$DelayClassLoader.class' \ +provider${FILESEP}HashProvider.class + +exit $STATUS diff --git a/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh b/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh index 2ed6da135cf17c838ce073d89bd543668ff1322b..f084942af21738d706a945c23c18fb792910ba53 100644 --- a/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh +++ b/test/java/security/Security/ClassLoaderDeadlock/Deadlock2.sh @@ -26,7 +26,6 @@ # @test # @bug 6440846 -# @ignore until 6203816 is dealt with. # @summary make sure we do not deadlock between ExtClassLoader and AppClassLoader # @author Valerie Peng # @run shell/timeout=20 Deadlock2.sh @@ -71,11 +70,14 @@ esac # remove old class files cd ${TESTCLASSES} -rm -f Deadlock2*.class if [ -d testlib ] ; then rm -rf testlib fi -cp -r ${TESTJAVA}${FILESEP}lib${FILESEP}ext testlib +if [ -d ${TESTJAVA}${FILESEP}lib${FILESEP}ext ] ; then + cp -r ${TESTJAVA}${FILESEP}lib${FILESEP}ext testlib +else + cp -r ${TESTJAVA}${FILESEP}jre${FILESEP}lib${FILESEP}ext testlib +fi # compile and package the test program ${TESTJAVA}${FILESEP}bin${FILESEP}javac \ diff --git a/test/java/util/concurrent/Executors/AutoShutdown.java b/test/java/util/concurrent/Executors/AutoShutdown.java index 67fe405f3c9a4d241f752e4500e1c9b34bf58517..3858ca79b64dbafe35f8153cc364d27ec16b08c2 100644 --- a/test/java/util/concurrent/Executors/AutoShutdown.java +++ b/test/java/util/concurrent/Executors/AutoShutdown.java @@ -32,21 +32,40 @@ import java.io.*; import java.util.*; import java.util.concurrent.*; import static java.util.concurrent.Executors.*; +import java.util.concurrent.Phaser; public class AutoShutdown { - private static void waitForFinalizersToRun() throws Throwable { - System.gc(); System.runFinalization(); Thread.sleep(10); - System.gc(); System.runFinalization(); Thread.sleep(10); + private static void waitForFinalizersToRun() { + for (int i = 0; i < 2; i++) + tryWaitForFinalizersToRun(); + } + + private static void tryWaitForFinalizersToRun() { + System.gc(); + final CountDownLatch fin = new CountDownLatch(1); + new Object() { protected void finalize() { fin.countDown(); }}; + System.gc(); + try { fin.await(); } + catch (InterruptedException ie) { throw new Error(ie); } } private static void realMain(String[] args) throws Throwable { - Runnable trivialRunnable = new Runnable() { public void run() {}}; + final Phaser phaser = new Phaser(3); + Runnable trivialRunnable = new Runnable() { + public void run() { + phaser.arriveAndAwaitAdvance(); + } + }; int count0 = Thread.activeCount(); - newSingleThreadExecutor().execute(trivialRunnable); - newSingleThreadExecutor(defaultThreadFactory()).execute(trivialRunnable); - Thread.sleep(100); + Executor e1 = newSingleThreadExecutor(); + Executor e2 = newSingleThreadExecutor(defaultThreadFactory()); + e1.execute(trivialRunnable); + e2.execute(trivialRunnable); + phaser.arriveAndAwaitAdvance(); equal(Thread.activeCount(), count0 + 2); - waitForFinalizersToRun(); + e1 = e2 = null; + for (int i = 0; i < 10 && Thread.activeCount() > count0; i++) + tryWaitForFinalizersToRun(); equal(Thread.activeCount(), count0); } diff --git a/test/sun/nio/cs/CheckHistoricalNames.java b/test/sun/nio/cs/CheckHistoricalNames.java index fdab32d75edcf18756be1cec075f9a3f7e09aa58..af04434bd824b4c0a0f9ac4c4c3ef6a1b504fb80 100644 --- a/test/sun/nio/cs/CheckHistoricalNames.java +++ b/test/sun/nio/cs/CheckHistoricalNames.java @@ -22,7 +22,7 @@ */ /* @test - @bug 4513767 4961027 + @bug 4513767 4961027 6217210 @summary Checks canonical names match between old and (NIO) core charsets */ import java.io.InputStreamReader; @@ -154,6 +154,7 @@ public class CheckHistoricalNames { checkHistoricalName("Cp500"); checkHistoricalName("Cp737"); checkHistoricalName("Cp775"); + checkHistoricalName("Cp833"); checkHistoricalName("Cp838"); checkHistoricalName("Cp850"); checkHistoricalName("Cp852"); @@ -228,6 +229,7 @@ public class CheckHistoricalNames { checkMappedName("IBM856", "Cp856"); checkMappedName("IBM857", "Cp857"); checkMappedName("IBM00858", "Cp858"); + checkMappedName("IBM833", "Cp833"); checkMappedName("IBM860", "Cp860"); checkMappedName("IBM861", "Cp861"); checkMappedName("IBM862", "Cp862"); diff --git a/test/sun/security/krb5/UnknownCCEntry.java b/test/sun/security/krb5/UnknownCCEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..17af51e2847c513f3eeb5768e0d6a0c2b6e31a53 --- /dev/null +++ b/test/sun/security/krb5/UnknownCCEntry.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2010, 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 6979329 + * @summary CCacheInputStream fails to read ticket cache files from Kerberos 1.8.1 + */ + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import sun.security.krb5.internal.ccache.CCacheInputStream; +import sun.security.krb5.internal.ccache.CredentialsCache; + +public class UnknownCCEntry { + public static void main(String[] args) throws Exception { + // This is a ccache file generated on a test machine: + // Default principal: dummy@MAX.LOCAL + // Valid starting Expires Service principal + // 08/24/10 10:37:28 08/25/10 10:37:28 krbtgt/MAX.LOCAL@MAX.LOCAL + // Flags: FI, Etype (skey, tkt): AES-128 CTS mode with 96-bit SHA-1 + // HMAC, AES-256 CTS mode with 96-bit SHA-1 HMAC + byte[] krb5cc = { + (byte)0x05, (byte)0x04, (byte)0x00, (byte)0x0C, + (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x08, + (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFA, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x05, (byte)0x64, (byte)0x75, (byte)0x6D, + (byte)0x6D, (byte)0x79, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x09, (byte)0x4D, (byte)0x41, + (byte)0x58, (byte)0x2E, (byte)0x4C, (byte)0x4F, + (byte)0x43, (byte)0x41, (byte)0x4C, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x05, (byte)0x64, + (byte)0x75, (byte)0x6D, (byte)0x6D, (byte)0x79, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x06, (byte)0x6B, (byte)0x72, (byte)0x62, + (byte)0x74, (byte)0x67, (byte)0x74, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x09, (byte)0x4D, + (byte)0x41, (byte)0x58, (byte)0x2E, (byte)0x4C, + (byte)0x4F, (byte)0x43, (byte)0x41, (byte)0x4C, + (byte)0x00, (byte)0x11, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x10, (byte)0x92, (byte)0x1D, + (byte)0x1A, (byte)0x0C, (byte)0x7F, (byte)0xB8, + (byte)0x01, (byte)0x2E, (byte)0xC9, (byte)0xF5, + (byte)0x7B, (byte)0x92, (byte)0x81, (byte)0xCA, + (byte)0x49, (byte)0xC5, (byte)0x4C, (byte)0x73, + (byte)0x30, (byte)0x68, (byte)0x4C, (byte)0x73, + (byte)0x30, (byte)0x68, (byte)0x4C, (byte)0x74, + (byte)0x81, (byte)0xE8, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x40, + (byte)0x41, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x01, (byte)0x29, (byte)0x61, + (byte)0x82, (byte)0x01, (byte)0x25, (byte)0x30, + (byte)0x82, (byte)0x01, (byte)0x21, (byte)0xA0, + (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x05, + (byte)0xA1, (byte)0x0B, (byte)0x1B, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0xA2, (byte)0x1E, (byte)0x30, + (byte)0x1C, (byte)0xA0, (byte)0x03, (byte)0x02, + (byte)0x01, (byte)0x00, (byte)0xA1, (byte)0x15, + (byte)0x30, (byte)0x13, (byte)0x1B, (byte)0x06, + (byte)0x6B, (byte)0x72, (byte)0x62, (byte)0x74, + (byte)0x67, (byte)0x74, (byte)0x1B, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0xA3, (byte)0x81, (byte)0xEC, + (byte)0x30, (byte)0x81, (byte)0xE9, (byte)0xA0, + (byte)0x03, (byte)0x02, (byte)0x01, (byte)0x12, + (byte)0xA1, (byte)0x03, (byte)0x02, (byte)0x01, + (byte)0x01, (byte)0xA2, (byte)0x81, (byte)0xDC, + (byte)0x04, (byte)0x81, (byte)0xD9, (byte)0xFB, + (byte)0x4B, (byte)0xD2, (byte)0x55, (byte)0x33, + (byte)0xA8, (byte)0x1A, (byte)0xE6, (byte)0xB5, + (byte)0x3D, (byte)0x67, (byte)0x46, (byte)0x69, + (byte)0x6F, (byte)0x0A, (byte)0x64, (byte)0xE7, + (byte)0x3D, (byte)0xEF, (byte)0x22, (byte)0xBE, + (byte)0x81, (byte)0x32, (byte)0xF3, (byte)0x72, + (byte)0xB4, (byte)0x50, (byte)0xE3, (byte)0xC3, + (byte)0xDB, (byte)0xE5, (byte)0x38, (byte)0x3C, + (byte)0x60, (byte)0xC8, (byte)0x08, (byte)0x53, + (byte)0x44, (byte)0x6F, (byte)0xDF, (byte)0x55, + (byte)0x67, (byte)0x32, (byte)0x02, (byte)0xDD, + (byte)0x6B, (byte)0xFB, (byte)0x23, (byte)0x1A, + (byte)0x88, (byte)0x71, (byte)0xE0, (byte)0xF8, + (byte)0xBB, (byte)0x51, (byte)0x1E, (byte)0x76, + (byte)0xC9, (byte)0x1F, (byte)0x45, (byte)0x9B, + (byte)0xA0, (byte)0xA5, (byte)0x61, (byte)0x45, + (byte)0x9E, (byte)0x65, (byte)0xB8, (byte)0xD6, + (byte)0x0E, (byte)0x3C, (byte)0xD9, (byte)0x56, + (byte)0xD6, (byte)0xA6, (byte)0xDD, (byte)0x36, + (byte)0x21, (byte)0x25, (byte)0x0E, (byte)0xE6, + (byte)0xAD, (byte)0xA0, (byte)0x3A, (byte)0x9B, + (byte)0x21, (byte)0x87, (byte)0xE2, (byte)0xAF, + (byte)0x3A, (byte)0xEF, (byte)0x75, (byte)0x85, + (byte)0xA8, (byte)0xD7, (byte)0xE5, (byte)0x46, + (byte)0xD8, (byte)0x5C, (byte)0x17, (byte)0x4E, + (byte)0x64, (byte)0x51, (byte)0xDB, (byte)0x38, + (byte)0x8E, (byte)0x6B, (byte)0x02, (byte)0x05, + (byte)0x46, (byte)0x77, (byte)0xD0, (byte)0x75, + (byte)0x8A, (byte)0xE0, (byte)0x42, (byte)0x5E, + (byte)0x8D, (byte)0x49, (byte)0x86, (byte)0xDE, + (byte)0x6C, (byte)0xBC, (byte)0xAF, (byte)0x10, + (byte)0x9A, (byte)0x97, (byte)0x64, (byte)0xA6, + (byte)0xBD, (byte)0xDB, (byte)0x01, (byte)0x40, + (byte)0xA9, (byte)0x3D, (byte)0x74, (byte)0x99, + (byte)0xDC, (byte)0x63, (byte)0x34, (byte)0x40, + (byte)0x31, (byte)0x57, (byte)0xC7, (byte)0x70, + (byte)0x9F, (byte)0xCE, (byte)0xC6, (byte)0x7B, + (byte)0x00, (byte)0x5B, (byte)0x02, (byte)0x5C, + (byte)0xC7, (byte)0x81, (byte)0x40, (byte)0x4D, + (byte)0xA7, (byte)0xB1, (byte)0xD2, (byte)0xEA, + (byte)0x8E, (byte)0xEC, (byte)0xA0, (byte)0xB3, + (byte)0x03, (byte)0x29, (byte)0xB8, (byte)0x44, + (byte)0xD7, (byte)0xA1, (byte)0x2B, (byte)0x37, + (byte)0x9D, (byte)0x19, (byte)0x11, (byte)0x1D, + (byte)0x58, (byte)0xE8, (byte)0x06, (byte)0xE7, + (byte)0x06, (byte)0xE3, (byte)0xF7, (byte)0xEF, + (byte)0x05, (byte)0xA9, (byte)0x05, (byte)0x93, + (byte)0x42, (byte)0x94, (byte)0x5A, (byte)0xD6, + (byte)0xA0, (byte)0x24, (byte)0x3A, (byte)0x52, + (byte)0x92, (byte)0xA3, (byte)0x79, (byte)0x98, + (byte)0x3C, (byte)0x68, (byte)0x55, (byte)0x1B, + (byte)0x6A, (byte)0xC5, (byte)0x83, (byte)0x89, + (byte)0x5A, (byte)0x79, (byte)0x5C, (byte)0x52, + (byte)0xBA, (byte)0xB8, (byte)0xF7, (byte)0x72, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x09, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x05, (byte)0x64, (byte)0x75, (byte)0x6D, + (byte)0x6D, (byte)0x79, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x03, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x0C, (byte)0x58, (byte)0x2D, + (byte)0x43, (byte)0x41, (byte)0x43, (byte)0x48, + (byte)0x45, (byte)0x43, (byte)0x4F, (byte)0x4E, + (byte)0x46, (byte)0x3A, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x15, (byte)0x6B, (byte)0x72, + (byte)0x62, (byte)0x35, (byte)0x5F, (byte)0x63, + (byte)0x63, (byte)0x61, (byte)0x63, (byte)0x68, + (byte)0x65, (byte)0x5F, (byte)0x63, (byte)0x6F, + (byte)0x6E, (byte)0x66, (byte)0x5F, (byte)0x64, + (byte)0x61, (byte)0x74, (byte)0x61, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x0A, (byte)0x66, + (byte)0x61, (byte)0x73, (byte)0x74, (byte)0x5F, + (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x69, + (byte)0x6C, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x1A, (byte)0x6B, (byte)0x72, (byte)0x62, + (byte)0x74, (byte)0x67, (byte)0x74, (byte)0x2F, + (byte)0x4D, (byte)0x41, (byte)0x58, (byte)0x2E, + (byte)0x4C, (byte)0x4F, (byte)0x43, (byte)0x41, + (byte)0x4C, (byte)0x40, (byte)0x4D, (byte)0x41, + (byte)0x58, (byte)0x2E, (byte)0x4C, (byte)0x4F, + (byte)0x43, (byte)0x41, (byte)0x4C, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, (byte)0x03, (byte)0x79, (byte)0x65, + (byte)0x73, (byte)0x00, (byte)0x00, (byte)0x00, + (byte)0x00, + }; + + File f = File.createTempFile("ccache", "cc", new File(".")); + FileOutputStream fout = new FileOutputStream(f); + fout.write(krb5cc); + fout.close(); + + CredentialsCache cc = CredentialsCache.getInstance(f.getPath()); + if (!cc.getDefaultCreds().getServicePrincipal().getNameStrings()[0] + .equals("krbtgt")) { + throw new Exception("No TGT found"); + } + } +} diff --git a/test/sun/security/krb5/tools/ktarg.sh b/test/sun/security/krb5/tools/ktarg.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed78b5807ce34cfa26f57e2f476f4d847831aa04 --- /dev/null +++ b/test/sun/security/krb5/tools/ktarg.sh @@ -0,0 +1,67 @@ +# +# Copyright (c) 2010, 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 7002036 +# @summary ktab return code changes on a error case +# @run shell ktarg.sh +# + +if [ "${TESTJAVA}" = "" ] ; then + JAVAC_CMD=`which javac` + TESTJAVA=`dirname $JAVAC_CMD`/.. +fi + +if [ "${TESTSRC}" = "" ] ; then + TESTSRC="." +fi + +OS=`uname -s` +case "$OS" in + CYGWIN* ) + FS="/" + ;; + Windows_* ) + FS="\\" + ;; + * ) + FS="/" + echo "Unsupported system!" + exit 0; + ;; +esac + +KEYTAB=ktarg.tmp + +rm $KEYTAB 2> /dev/null +KTAB="${TESTJAVA}${FS}bin${FS}ktab -k $KEYTAB" + +$KTAB -a me mine || exit 1 + +$KTAB -hello +if [ $? = 0 ]; then exit 2; fi + +$KTAB +if [ $? = 0 ]; then exit 3; fi + +exit 0 diff --git a/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java b/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java new file mode 100644 index 0000000000000000000000000000000000000000..f0721daa2e5355600f25998b83dabeb849c4c4b0 --- /dev/null +++ b/test/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2010, 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 6687725 + * @summary Test internal PKCS5Padding impl with various error conditions. + * @author Valerie Peng + * @library .. + */ +import java.io.*; +import java.nio.*; +import java.util.*; + +import java.security.*; +import java.security.spec.AlgorithmParameterSpec; + +import javax.crypto.*; +import javax.crypto.spec.IvParameterSpec; + +public class TestPKCS5PaddingError extends PKCS11Test { + private static class CI { // class for holding Cipher Information + String transformation; + String keyAlgo; + + CI(String transformation, String keyAlgo) { + this.transformation = transformation; + this.keyAlgo = keyAlgo; + } + } + + private static final CI[] TEST_LIST = { + // algorithms which use the native padding impl + new CI("DES/CBC/PKCS5Padding", "DES"), + new CI("DESede/CBC/PKCS5Padding", "DESede"), + new CI("AES/CBC/PKCS5Padding", "AES"), + // algorithms which use SunPKCS11's own padding impl + new CI("DES/ECB/PKCS5Padding", "DES"), + new CI("DESede/ECB/PKCS5Padding", "DESede"), + new CI("AES/ECB/PKCS5Padding", "AES"), + }; + + private static StringBuffer debugBuf = new StringBuffer(); + + public void main(Provider p) throws Exception { + boolean status = true; + Random random = new Random(); + + try { + byte[] plainText = new byte[200]; + + for (int i = 0; i < TEST_LIST.length; i++) { + CI currTest = TEST_LIST[i]; + System.out.println("===" + currTest.transformation + "==="); + try { + KeyGenerator kg = + KeyGenerator.getInstance(currTest.keyAlgo, p); + SecretKey key = kg.generateKey(); + Cipher c1 = Cipher.getInstance(currTest.transformation, + "SunJCE"); + c1.init(Cipher.ENCRYPT_MODE, key); + byte[] cipherText = c1.doFinal(plainText); + AlgorithmParameters params = c1.getParameters(); + Cipher c2 = Cipher.getInstance(currTest.transformation, p); + c2.init(Cipher.DECRYPT_MODE, key, params); + + // 1st test: wrong output length + // NOTE: Skip NSS since it reports CKR_DEVICE_ERROR when + // the data passed to its EncryptUpdate/DecryptUpdate is + // not multiple of blocks + if (!p.getName().equals("SunPKCS11-NSS")) { + try { + System.out.println("Testing with wrong cipherText length"); + c2.doFinal(cipherText, 0, cipherText.length - 2); + } catch (IllegalBlockSizeException ibe) { + // expected + } catch (Exception ex) { + System.out.println("Error: Unexpected Ex " + ex); + ex.printStackTrace(); + } + } + // 2nd test: wrong padding value + try { + System.out.println("Testing with wrong padding bytes"); + cipherText[cipherText.length - 1]++; + c2.doFinal(cipherText); + } catch (BadPaddingException bpe) { + // expected + } catch (Exception ex) { + System.out.println("Error: Unexpected Ex " + ex); + ex.printStackTrace(); + } + System.out.println("DONE"); + } catch (NoSuchAlgorithmException nsae) { + System.out.println("Skipping unsupported algorithm: " + + nsae); + } + } + } catch (Exception ex) { + // print out debug info when exception is encountered + if (debugBuf != null) { + System.out.println(debugBuf.toString()); + debugBuf = new StringBuffer(); + } + throw ex; + } + } + + public static void main(String[] args) throws Exception { + main(new TestPKCS5PaddingError()); + } +} diff --git a/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java b/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java index 0c79da6826f373480b01d4a0a7eb9454d55b7c21..912d9335b3337afb93bf49bb6200567da38c24e9 100644 --- a/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java +++ b/test/sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java @@ -23,7 +23,7 @@ /** * @test - * @bug 4917233 6461727 6490213 + * @bug 4917233 6461727 6490213 6720456 * @summary test the KeyGenerator * @author Andreas Sterbenz * @library .. @@ -104,7 +104,7 @@ public class TestKeyGenerator extends PKCS11Test { // Different PKCS11 impls have different ranges // of supported key sizes for variable-key-length // algorithms. - // Solaris> Blowfish: 32-128 bits, RC4: 8-128 bits + // Solaris> Blowfish: 32-128 or even 448 bits, RC4: 8-128 bits or as much as 2048 bits // NSS> Blowfish: n/a, RC4: 8-2048 bits // However, we explicitly disallowed key sizes less // than 40-bits. @@ -114,8 +114,8 @@ public class TestKeyGenerator extends PKCS11Test { test("Blowfish", 32, p, TestResult.FAIL); test("Blowfish", 40, p, TestResult.PASS); test("Blowfish", 128, p, TestResult.PASS); - test("Blowfish", 136, p, TestResult.FAIL); - test("Blowfish", 448, p, TestResult.FAIL); + test("Blowfish", 136, p, TestResult.TBD); + test("Blowfish", 448, p, TestResult.TBD); test("Blowfish", 456, p, TestResult.FAIL); test("ARCFOUR", 0, p, TestResult.FAIL); @@ -124,7 +124,7 @@ public class TestKeyGenerator extends PKCS11Test { test("ARCFOUR", 128, p, TestResult.PASS); if (p.getName().equals("SunPKCS11-Solaris")) { - test("ARCFOUR", 1024, p, TestResult.FAIL); + test("ARCFOUR", 1024, p, TestResult.TBD); } else if (p.getName().equals("SunPKCS11-NSS")) { test("ARCFOUR", 1024, p, TestResult.PASS); test("ARCFOUR", 2048, p, TestResult.PASS); diff --git a/test/tools/launcher/Settings.java b/test/tools/launcher/Settings.java new file mode 100644 index 0000000000000000000000000000000000000000..b78443acc6ba2bb97da2ec46e707a407c8f92378 --- /dev/null +++ b/test/tools/launcher/Settings.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2010, 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 java.io.File; +import java.io.IOException; + +/* + * @test + * @bug 6994753 + * @summary tests -XshowSettings options + * @compile -XDignore.symbol.file Settings.java TestHelper.java + * @run main Settings + * @author ksrini + */ +public class Settings { + private static File testJar = null; + + static void init() throws IOException { + if (testJar != null) { + return; + } + testJar = new File("test.jar"); + StringBuilder tsrc = new StringBuilder(); + tsrc.append("public static void main(String... args) {\n"); + tsrc.append(" for (String x : args) {\n"); + tsrc.append(" System.out.println(x);\n"); + tsrc.append(" }\n"); + tsrc.append("}\n"); + TestHelper.createJar(testJar, tsrc.toString()); + } + + static void checkContains(TestHelper.TestResult tr, String str) { + if (!tr.contains(str)) { + System.out.println(tr); + throw new RuntimeException(str + " not found"); + } + } + + static void checkNoContains(TestHelper.TestResult tr, String str) { + if (tr.contains(str)) { + System.out.println(tr.status); + throw new RuntimeException(str + " found"); + } + } + + private static final String VM_SETTINGS = "VM settings:"; + private static final String PROP_SETTINGS = "Property settings:"; + private static final String LOCALE_SETTINGS = "Locale settings:"; + + static void containsAllOptions(TestHelper.TestResult tr) { + checkContains(tr, VM_SETTINGS); + checkContains(tr, PROP_SETTINGS); + checkContains(tr, LOCALE_SETTINGS); + } + + static void runTestOptionDefault() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-Xmx512m", "-Xss128k", + "-XshowSettings", "-jar", testJar.getAbsolutePath()); + containsAllOptions(tr); + if (!tr.isOK()) { + System.out.println(tr.status); + throw new RuntimeException("test fails"); + } + } + + static void runTestOptionAll() throws IOException { + init(); + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:all"); + containsAllOptions(tr); + } + + static void runTestOptionVM() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:vm"); + checkContains(tr, VM_SETTINGS); + checkNoContains(tr, PROP_SETTINGS); + checkNoContains(tr, LOCALE_SETTINGS); + } + + static void runTestOptionProperty() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:properties"); + checkNoContains(tr, VM_SETTINGS); + checkContains(tr, PROP_SETTINGS); + checkNoContains(tr, LOCALE_SETTINGS); + } + + static void runTestOptionLocale() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:locale"); + checkNoContains(tr, VM_SETTINGS); + checkNoContains(tr, PROP_SETTINGS); + checkContains(tr, LOCALE_SETTINGS); + } + + static void runTestBadOptions() throws IOException { + TestHelper.TestResult tr = null; + tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettingsBadOption"); + checkNoContains(tr, VM_SETTINGS); + checkNoContains(tr, PROP_SETTINGS); + checkNoContains(tr, LOCALE_SETTINGS); + checkContains(tr, "Unrecognized option: -XshowSettingsBadOption"); + } + public static void main(String... args) { + try { + runTestOptionAll(); + runTestOptionDefault(); + runTestOptionVM(); + runTestOptionProperty(); + runTestOptionLocale(); + runTestBadOptions(); + } catch (IOException ioe) { + throw new RuntimeException(ioe); + } + } +}