From 6f7b6c816a170bb2cd6b9f33ce215d4d90ff2dcd Mon Sep 17 00:00:00 2001
From: Martin von Gagern
Date: Fri, 12 Dec 2008 17:38:14 +0300
Subject: [PATCH 001/283] 5106550: PNG writer merge standard metadata fails for
TextEntry sans #IMPLIED attributes
Reviewed-by: igor, prr
---
.../sun/imageio/plugins/png/PNGMetadata.java | 93 +++++++++++++------
.../plugins/png/MergeStdCommentTest.java | 64 +++++++++++++
2 files changed, 131 insertions(+), 26 deletions(-)
create mode 100644 jdk/test/javax/imageio/plugins/png/MergeStdCommentTest.java
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
index 5475fc79651..23281fe5330 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
@@ -1040,7 +1040,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
node.setAttribute("language",
iTXt_languageTag.get(i));
if (iTXt_compressionFlag.get(i)) {
- node.setAttribute("compression", "deflate");
+ node.setAttribute("compression", "zip");
} else {
node.setAttribute("compression", "none");
}
@@ -1052,7 +1052,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
node = new IIOMetadataNode("TextEntry");
node.setAttribute("keyword", (String)zTXt_keyword.get(i));
node.setAttribute("value", (String)zTXt_text.get(i));
- node.setAttribute("compression", "deflate");
+ node.setAttribute("compression", "zip");
text_node.appendChild(node);
}
@@ -1421,26 +1421,30 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
String keyword = getAttribute(iTXt_node, "keyword");
- iTXt_keyword.add(keyword);
+ if (isValidKeyword(keyword)) {
+ iTXt_keyword.add(keyword);
- boolean compressionFlag =
- getBooleanAttribute(iTXt_node, "compressionFlag");
- iTXt_compressionFlag.add(Boolean.valueOf(compressionFlag));
+ boolean compressionFlag =
+ getBooleanAttribute(iTXt_node, "compressionFlag");
+ iTXt_compressionFlag.add(Boolean.valueOf(compressionFlag));
- String compressionMethod =
- getAttribute(iTXt_node, "compressionMethod");
- iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
+ String compressionMethod =
+ getAttribute(iTXt_node, "compressionMethod");
+ iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
- String languageTag =
- getAttribute(iTXt_node, "languageTag");
- iTXt_languageTag.add(languageTag);
+ String languageTag =
+ getAttribute(iTXt_node, "languageTag");
+ iTXt_languageTag.add(languageTag);
- String translatedKeyword =
- getAttribute(iTXt_node, "translatedKeyword");
- iTXt_translatedKeyword.add(translatedKeyword);
+ String translatedKeyword =
+ getAttribute(iTXt_node, "translatedKeyword");
+ iTXt_translatedKeyword.add(translatedKeyword);
- String text = getAttribute(iTXt_node, "text");
- iTXt_text.add(text);
+ String text = getAttribute(iTXt_node, "text");
+ iTXt_text.add(text);
+
+ }
+ // silently skip invalid text entry
iTXt_node = iTXt_node.getNextSibling();
}
@@ -1692,11 +1696,45 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
}
- private boolean isISOLatin(String s) {
+ /*
+ * Accrding to PNG spec, keywords are restricted to 1 to 79 bytes
+ * in length. Keywords shall contain only printable Latin-1 characters
+ * and spaces; To reduce the chances for human misreading of a keyword,
+ * leading spaces, trailing spaces, and consecutive spaces are not
+ * permitted in keywords.
+ *
+ * See: http://www.w3.org/TR/PNG/#11keywords
+ */
+ private boolean isValidKeyword(String s) {
+ int len = s.length();
+ if (len < 1 || len >= 80) {
+ return false;
+ }
+ if (s.startsWith(" ") || s.endsWith(" ") || s.contains(" ")) {
+ return false;
+ }
+ return isISOLatin(s, false);
+ }
+
+ /*
+ * According to PNG spec, keyword shall contain only printable
+ * Latin-1 [ISO-8859-1] characters and spaces; that is, only
+ * character codes 32-126 and 161-255 decimal are allowed.
+ * For Latin-1 value fields the 0x10 (linefeed) control
+ * character is aloowed too.
+ *
+ * See: http://www.w3.org/TR/PNG/#11keywords
+ */
+ private boolean isISOLatin(String s, boolean isLineFeedAllowed) {
int len = s.length();
for (int i = 0; i < len; i++) {
- if (s.charAt(i) > 255) {
- return false;
+ char c = s.charAt(i);
+ if (c < 32 || c > 255 || (c > 126 && c < 161)) {
+ // not printable. Check whether this is an allowed
+ // control char
+ if (!isLineFeedAllowed || c != 0x10) {
+ return false;
+ }
}
}
return true;
@@ -1929,19 +1967,22 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
while (child != null) {
String childName = child.getNodeName();
if (childName.equals("TextEntry")) {
- String keyword = getAttribute(child, "keyword");
+ String keyword =
+ getAttribute(child, "keyword", "", false);
String value = getAttribute(child, "value");
- String encoding = getAttribute(child, "encoding");
- String language = getAttribute(child, "language");
+ String language =
+ getAttribute(child, "language", "", false);
String compression =
- getAttribute(child, "compression");
+ getAttribute(child, "compression", "none", false);
- if (isISOLatin(value)) {
+ if (!isValidKeyword(keyword)) {
+ // Just ignore this node, PNG requires keywords
+ } else if (isISOLatin(value, true)) {
if (compression.equals("zip")) {
// Use a zTXt node
zTXt_keyword.add(keyword);
zTXt_text.add(value);
- zTXt_compressionMethod.add(new Integer(0));
+ zTXt_compressionMethod.add(Integer.valueOf(0));
} else {
// Use a tEXt node
tEXt_keyword.add(keyword);
diff --git a/jdk/test/javax/imageio/plugins/png/MergeStdCommentTest.java b/jdk/test/javax/imageio/plugins/png/MergeStdCommentTest.java
new file mode 100644
index 00000000000..21a7c5f10d0
--- /dev/null
+++ b/jdk/test/javax/imageio/plugins/png/MergeStdCommentTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 5106550
+ * @summary Merge a comment using the standard metdata format
+ * and only a minimal set of attributes
+ */
+
+import java.awt.image.BufferedImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+
+public class MergeStdCommentTest {
+
+ public static void main(String[] args) throws Exception {
+ String format = "javax_imageio_1.0";
+ BufferedImage img =
+ new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+ ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next();
+ IIOMetadata meta =
+ iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null);
+ DOMImplementationRegistry registry;
+ registry = DOMImplementationRegistry.newInstance();
+ DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
+ Document doc = impl.createDocument(null, format, null);
+ Element root, text, entry;
+ root = doc.getDocumentElement();
+ root.appendChild(text = doc.createElement("Text"));
+ text.appendChild(entry = doc.createElement("TextEntry"));
+ // keyword isn't #REQUIRED by the standard metadata format.
+ // However, it is required by the PNG format, so we include it here.
+ entry.setAttribute("keyword", "Comment");
+ entry.setAttribute("value", "Some demo comment");
+ meta.mergeTree(format, root);
+ }
+}
From 8848b3ab632432de85c70173dc26a4bdc2790479 Mon Sep 17 00:00:00 2001
From: Igor Nekrestyanov
Date: Wed, 17 Dec 2008 22:00:37 +0300
Subject: [PATCH 002/283] 6761791: Crash in the FontManager code due to use of
JNIEnv saved by another thread
Reviewed-by: bae, prr
---
.../share/native/sun/font/freetypeScaler.c | 27 ++++++++++++++++---
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/jdk/src/share/native/sun/font/freetypeScaler.c b/jdk/src/share/native/sun/font/freetypeScaler.c
index 59c1a180c29..4028d4d97c4 100644
--- a/jdk/src/share/native/sun/font/freetypeScaler.c
+++ b/jdk/src/share/native/sun/font/freetypeScaler.c
@@ -394,12 +394,14 @@ static int setupFTContext(JNIEnv *env,
scalerInfo->env = env;
scalerInfo->font2D = font2D;
- FT_Set_Transform(scalerInfo->face, &context->transform, NULL);
+ if (context != NULL) {
+ FT_Set_Transform(scalerInfo->face, &context->transform, NULL);
- errCode = FT_Set_Char_Size(scalerInfo->face, 0, context->ptsz, 72, 72);
+ errCode = FT_Set_Char_Size(scalerInfo->face, 0, context->ptsz, 72, 72);
- if (errCode == 0) {
- errCode = FT_Activate_Size(scalerInfo->face->size);
+ if (errCode == 0) {
+ errCode = FT_Activate_Size(scalerInfo->face->size);
+ }
}
return errCode;
@@ -885,6 +887,14 @@ Java_sun_font_FreetypeFontScaler_disposeNativeScaler(
JNIEnv *env, jobject scaler, jlong pScaler) {
FTScalerInfo* scalerInfo = (FTScalerInfo *) jlong_to_ptr(pScaler);
+ /* Freetype functions *may* cause callback to java
+ that can use cached values. Make sure our cache is up to date.
+ NB: scaler context is not important at this point, can use NULL. */
+ int errCode = setupFTContext(env, scaler, scalerInfo, NULL);
+ if (errCode) {
+ return;
+ }
+
freeNativeResources(env, scalerInfo);
}
@@ -932,12 +942,21 @@ Java_sun_font_FreetypeFontScaler_getGlyphCodeNative(
JNIEnv *env, jobject scaler, jlong pScaler, jchar charCode) {
FTScalerInfo* scalerInfo = (FTScalerInfo *) jlong_to_ptr(pScaler);
+ int errCode;
if (scaler == NULL || scalerInfo->face == NULL) { /* bad/null scaler */
invalidateJavaScaler(env, scaler, scalerInfo);
return 0;
}
+ /* Freetype functions *may* cause callback to java
+ that can use cached values. Make sure our cache is up to date.
+ Scaler context is not important here, can use NULL. */
+ errCode = setupFTContext(env, scaler, scalerInfo, NULL);
+ if (errCode) {
+ return 0;
+ }
+
return FT_Get_Char_Index(scalerInfo->face, charCode);
}
From 5b1de891b340083d3bc451e8c56c318634193994 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Thu, 18 Dec 2008 11:25:09 -0800
Subject: [PATCH 003/283] 6708137: Remove obsolete fontconfig.98.properties
from JDK 7
Reviewed-by: jgodinez, naoto
---
jdk/make/sun/awt/Makefile | 3 +-
.../sun/awt/windows/WFontConfiguration.java | 16 +-
.../sun/awt/windows/fontconfig.98.properties | 241 ------------------
.../sun/awt/windows/fontconfig.Me.properties | 241 ------------------
4 files changed, 5 insertions(+), 496 deletions(-)
delete mode 100644 jdk/src/windows/classes/sun/awt/windows/fontconfig.98.properties
delete mode 100644 jdk/src/windows/classes/sun/awt/windows/fontconfig.Me.properties
diff --git a/jdk/make/sun/awt/Makefile b/jdk/make/sun/awt/Makefile
index ed35dcd2bdf..3f9fa64eb11 100644
--- a/jdk/make/sun/awt/Makefile
+++ b/jdk/make/sun/awt/Makefile
@@ -333,8 +333,7 @@ ifeq ($(PLATFORM), windows)
FONTCONFIGS_SRC = $(PLATFORM_SRC)/classes/sun/awt/windows
_FONTCONFIGS = \
- fontconfig.properties \
- fontconfig.98.properties
+ fontconfig.properties
FONTCONFIGS_SRC_PREFIX =
diff --git a/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java b/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java
index 4f2f8324ae4..2c7b00124a7 100644
--- a/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java
+++ b/jdk/src/windows/classes/sun/awt/windows/WFontConfiguration.java
@@ -61,18 +61,10 @@ public class WFontConfiguration extends FontConfiguration {
* been opened and its fonts loaded.
* Also note this usage is only enabled if a private flag is set.
*/
- if ("98".equals(osName) || "Me".equals(osName)) {
- localeMap.put("dialoginput.plain.japanese", "\uff2d\uff33 \u660e\u671d");
- localeMap.put("dialoginput.bold.japanese", "\uff2d\uff33 \u660e\u671d");
- localeMap.put("dialoginput.italic.japanese", "\uff2d\uff33 \u660e\u671d");
- localeMap.put("dialoginput.bolditalic.japanese", "\uff2d\uff33 \u660e\u671d");
- } else {
-
- localeMap.put("dialoginput.plain.japanese", "MS Mincho");
- localeMap.put("dialoginput.bold.japanese", "MS Mincho");
- localeMap.put("dialoginput.italic.japanese", "MS Mincho");
- localeMap.put("dialoginput.bolditalic.japanese", "MS Mincho");
- }
+ localeMap.put("dialoginput.plain.japanese", "MS Mincho");
+ localeMap.put("dialoginput.bold.japanese", "MS Mincho");
+ localeMap.put("dialoginput.italic.japanese", "MS Mincho");
+ localeMap.put("dialoginput.bolditalic.japanese", "MS Mincho");
}
reorderMap = new HashMap();
reorderMap.put("UTF-8.hi", "devanagari");
diff --git a/jdk/src/windows/classes/sun/awt/windows/fontconfig.98.properties b/jdk/src/windows/classes/sun/awt/windows/fontconfig.98.properties
deleted file mode 100644
index 8d69d410e25..00000000000
--- a/jdk/src/windows/classes/sun/awt/windows/fontconfig.98.properties
+++ /dev/null
@@ -1,241 +0,0 @@
-#
-#
-# Copyright 2003-2004 Sun Microsystems, Inc. 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. Sun designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-# CA 95054 USA or visit www.sun.com if you need additional information or
-# have any questions.
-#
-
-# Version
-
-version=1
-
-# Component Font Mappings
-
-allfonts.chinese-ms936=SimSun
-allfonts.dingbats=Wingdings
-allfonts.lucida=Lucida Sans Regular
-allfonts.symbol=Symbol
-allfonts.thai=Lucida Sans Regular
-
-serif.plain.alphabetic=Times New Roman
-serif.plain.chinese-ms950=MingLiU
-serif.plain.hebrew=David
-serif.plain.japanese=\uff2d\uff33 \u660e\u671d
-serif.plain.korean=Batang
-
-serif.bold.alphabetic=Times New Roman Bold
-serif.bold.chinese-ms950=PMingLiU
-serif.bold.hebrew=David Bold
-serif.bold.japanese=\uff2d\uff33 \u660e\u671d
-serif.bold.korean=Batang
-
-serif.italic.alphabetic=Times New Roman Italic
-serif.italic.chinese-ms950=PMingLiU
-serif.italic.hebrew=David
-serif.italic.japanese=\uff2d\uff33 \u660e\u671d
-serif.italic.korean=Batang
-
-serif.bolditalic.alphabetic=Times New Roman Bold Italic
-serif.bolditalic.chinese-ms950=PMingLiU
-serif.bolditalic.hebrew=David Bold
-serif.bolditalic.japanese=\uff2d\uff33 \u660e\u671d
-serif.bolditalic.korean=Batang
-
-sansserif.plain.alphabetic=Arial
-sansserif.plain.chinese-ms950=MingLiU
-sansserif.plain.hebrew=David
-sansserif.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.plain.korean=Gulim
-
-sansserif.bold.alphabetic=Arial Bold
-sansserif.bold.chinese-ms950=PMingLiU
-sansserif.bold.hebrew=David Bold
-sansserif.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.bold.korean=Gulim
-
-sansserif.italic.alphabetic=Arial Italic
-sansserif.italic.chinese-ms950=PMingLiU
-sansserif.italic.hebrew=David
-sansserif.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.italic.korean=Gulim
-
-sansserif.bolditalic.alphabetic=Arial Bold Italic
-sansserif.bolditalic.chinese-ms950=PMingLiU
-sansserif.bolditalic.hebrew=David Bold
-sansserif.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.bolditalic.korean=Gulim
-
-monospaced.plain.alphabetic=Courier New
-monospaced.plain.chinese-ms950=MingLiU
-monospaced.plain.hebrew=David
-monospaced.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.plain.korean=GulimChe
-
-monospaced.bold.alphabetic=Courier New Bold
-monospaced.bold.chinese-ms950=PMingLiU
-monospaced.bold.hebrew=David Bold
-monospaced.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.bold.korean=GulimChe
-
-monospaced.italic.alphabetic=Courier New Italic
-monospaced.italic.chinese-ms950=PMingLiU
-monospaced.italic.hebrew=David
-monospaced.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.italic.korean=GulimChe
-
-monospaced.bolditalic.alphabetic=Courier New Bold Italic
-monospaced.bolditalic.chinese-ms950=PMingLiU
-monospaced.bolditalic.hebrew=David Bold
-monospaced.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.bolditalic.korean=GulimChe
-
-dialog.plain.alphabetic=Arial
-dialog.plain.chinese-ms950=MingLiU
-dialog.plain.hebrew=David
-dialog.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.plain.korean=Gulim
-
-dialog.bold.alphabetic=Arial Bold
-dialog.bold.chinese-ms950=PMingLiU
-dialog.bold.hebrew=David Bold
-dialog.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.bold.korean=Gulim
-
-dialog.italic.alphabetic=Arial Italic
-dialog.italic.chinese-ms950=PMingLiU
-dialog.italic.hebrew=David
-dialog.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.italic.korean=Gulim
-
-dialog.bolditalic.alphabetic=Arial Bold Italic
-dialog.bolditalic.chinese-ms950=PMingLiU
-dialog.bolditalic.hebrew=David Bold
-dialog.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.bolditalic.korean=Gulim
-
-dialoginput.plain.alphabetic=Courier New
-dialoginput.plain.chinese-ms950=MingLiU
-dialoginput.plain.hebrew=David
-dialoginput.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.plain.korean=Gulim
-
-dialoginput.bold.alphabetic=Courier New Bold
-dialoginput.bold.chinese-ms950=PMingLiU
-dialoginput.bold.hebrew=David Bold
-dialoginput.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.bold.korean=Gulim
-
-dialoginput.italic.alphabetic=Courier New Italic
-dialoginput.italic.chinese-ms950=PMingLiU
-dialoginput.italic.hebrew=David
-dialoginput.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.italic.korean=Gulim
-
-dialoginput.bolditalic.alphabetic=Courier New Bold Italic
-dialoginput.bolditalic.chinese-ms950=PMingLiU
-dialoginput.bolditalic.hebrew=David Bold
-dialoginput.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.bolditalic.korean=Gulim
-
-# Search Sequences
-
-sequence.allfonts=alphabetic/default,dingbats,symbol
-
-sequence.serif.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.sansserif.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.monospaced.GBK=chinese-ms936,alphabetic/1252,dingbats,symbol
-sequence.dialog.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.dialoginput.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-
-sequence.serif.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.sansserif.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.monospaced.x-windows-950=chinese-ms950,alphabetic/1252,dingbats,symbol
-sequence.dialog.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.dialoginput.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-
-sequence.allfonts.windows-1255=hebrew,alphabetic/1252,dingbats,symbol
-
-sequence.serif.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.sansserif.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.monospaced.windows-31j=japanese,alphabetic/1252,dingbats,symbol
-sequence.dialog.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.dialoginput.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-
-sequence.serif.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.sansserif.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.monospaced.x-windows-949=korean,alphabetic/1252,dingbats,symbol
-sequence.dialog.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.dialoginput.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-
-sequence.allfonts.x-windows-874=alphabetic/1252,thai,dingbats,symbol
-
-sequence.fallback=lucida
-
-# Exclusion Ranges
-
-exclusion.alphabetic=0700-1e9f,1f00-20ab,20ad-f8ff
-exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
-
-# Monospaced to Proportional width variant mapping
-# (Experimental private syntax)
-proportional.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af
-proportional.\uff2d\uff33_\u660e\u671d=\uff2d\uff33 \uff30\u660e\u671d
-proportional.MingLiU=PMingLiU
-
-# Font File Names
-
-filename.Arial=ARIAL.TTF
-filename.Arial_Bold=ARIALBD.TTF
-filename.Arial_Italic=ARIALI.TTF
-filename.Arial_Bold_Italic=ARIALBI.TTF
-
-filename.Courier_New=COUR.TTF
-filename.Courier_New_Bold=COURBD.TTF
-filename.Courier_New_Italic=COURI.TTF
-filename.Courier_New_Bold_Italic=COURBI.TTF
-
-filename.Times_New_Roman=TIMES.TTF
-filename.Times_New_Roman_Bold=TIMESBD.TTF
-filename.Times_New_Roman_Italic=TIMESI.TTF
-filename.Times_New_Roman_Bold_Italic=TIMESBI.TTF
-
-filename.SimSun=SIMSUN.TTF
-
-filename.MingLiU=MINGLIU.TTC
-filename.PMingLiU=MINGLIU.TTC
-
-filename.David=DAVID.TTF
-filename.David_Bold=DAVIDBD.TTF
-
-filename.\uff2d\uff33_\u660e\u671d=MSMINCHO.TTC
-filename.\uff2d\uff33_\uff30\u660e\u671d=MSMINCHO.TTC
-filename.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=MSGOTHIC.TTC
-filename.\uff2d\uff33_\uff30\u30b4\u30b7\u30c3\u30af=MSGOTHIC.TTC
-
-filename.Gulim=gulim.TTC
-filename.Batang=batang.TTC
-filename.GulimChe=gulim.TTC
-
-filename.Lucida_Sans_Regular=LucidaSansRegular.ttf
-filename.Symbol=SYMBOL.TTF
-filename.Wingdings=WINGDING.TTF
-
diff --git a/jdk/src/windows/classes/sun/awt/windows/fontconfig.Me.properties b/jdk/src/windows/classes/sun/awt/windows/fontconfig.Me.properties
deleted file mode 100644
index 8d69d410e25..00000000000
--- a/jdk/src/windows/classes/sun/awt/windows/fontconfig.Me.properties
+++ /dev/null
@@ -1,241 +0,0 @@
-#
-#
-# Copyright 2003-2004 Sun Microsystems, Inc. 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. Sun designates this
-# particular file as subject to the "Classpath" exception as provided
-# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
-# CA 95054 USA or visit www.sun.com if you need additional information or
-# have any questions.
-#
-
-# Version
-
-version=1
-
-# Component Font Mappings
-
-allfonts.chinese-ms936=SimSun
-allfonts.dingbats=Wingdings
-allfonts.lucida=Lucida Sans Regular
-allfonts.symbol=Symbol
-allfonts.thai=Lucida Sans Regular
-
-serif.plain.alphabetic=Times New Roman
-serif.plain.chinese-ms950=MingLiU
-serif.plain.hebrew=David
-serif.plain.japanese=\uff2d\uff33 \u660e\u671d
-serif.plain.korean=Batang
-
-serif.bold.alphabetic=Times New Roman Bold
-serif.bold.chinese-ms950=PMingLiU
-serif.bold.hebrew=David Bold
-serif.bold.japanese=\uff2d\uff33 \u660e\u671d
-serif.bold.korean=Batang
-
-serif.italic.alphabetic=Times New Roman Italic
-serif.italic.chinese-ms950=PMingLiU
-serif.italic.hebrew=David
-serif.italic.japanese=\uff2d\uff33 \u660e\u671d
-serif.italic.korean=Batang
-
-serif.bolditalic.alphabetic=Times New Roman Bold Italic
-serif.bolditalic.chinese-ms950=PMingLiU
-serif.bolditalic.hebrew=David Bold
-serif.bolditalic.japanese=\uff2d\uff33 \u660e\u671d
-serif.bolditalic.korean=Batang
-
-sansserif.plain.alphabetic=Arial
-sansserif.plain.chinese-ms950=MingLiU
-sansserif.plain.hebrew=David
-sansserif.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.plain.korean=Gulim
-
-sansserif.bold.alphabetic=Arial Bold
-sansserif.bold.chinese-ms950=PMingLiU
-sansserif.bold.hebrew=David Bold
-sansserif.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.bold.korean=Gulim
-
-sansserif.italic.alphabetic=Arial Italic
-sansserif.italic.chinese-ms950=PMingLiU
-sansserif.italic.hebrew=David
-sansserif.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.italic.korean=Gulim
-
-sansserif.bolditalic.alphabetic=Arial Bold Italic
-sansserif.bolditalic.chinese-ms950=PMingLiU
-sansserif.bolditalic.hebrew=David Bold
-sansserif.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-sansserif.bolditalic.korean=Gulim
-
-monospaced.plain.alphabetic=Courier New
-monospaced.plain.chinese-ms950=MingLiU
-monospaced.plain.hebrew=David
-monospaced.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.plain.korean=GulimChe
-
-monospaced.bold.alphabetic=Courier New Bold
-monospaced.bold.chinese-ms950=PMingLiU
-monospaced.bold.hebrew=David Bold
-monospaced.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.bold.korean=GulimChe
-
-monospaced.italic.alphabetic=Courier New Italic
-monospaced.italic.chinese-ms950=PMingLiU
-monospaced.italic.hebrew=David
-monospaced.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.italic.korean=GulimChe
-
-monospaced.bolditalic.alphabetic=Courier New Bold Italic
-monospaced.bolditalic.chinese-ms950=PMingLiU
-monospaced.bolditalic.hebrew=David Bold
-monospaced.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-monospaced.bolditalic.korean=GulimChe
-
-dialog.plain.alphabetic=Arial
-dialog.plain.chinese-ms950=MingLiU
-dialog.plain.hebrew=David
-dialog.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.plain.korean=Gulim
-
-dialog.bold.alphabetic=Arial Bold
-dialog.bold.chinese-ms950=PMingLiU
-dialog.bold.hebrew=David Bold
-dialog.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.bold.korean=Gulim
-
-dialog.italic.alphabetic=Arial Italic
-dialog.italic.chinese-ms950=PMingLiU
-dialog.italic.hebrew=David
-dialog.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.italic.korean=Gulim
-
-dialog.bolditalic.alphabetic=Arial Bold Italic
-dialog.bolditalic.chinese-ms950=PMingLiU
-dialog.bolditalic.hebrew=David Bold
-dialog.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialog.bolditalic.korean=Gulim
-
-dialoginput.plain.alphabetic=Courier New
-dialoginput.plain.chinese-ms950=MingLiU
-dialoginput.plain.hebrew=David
-dialoginput.plain.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.plain.korean=Gulim
-
-dialoginput.bold.alphabetic=Courier New Bold
-dialoginput.bold.chinese-ms950=PMingLiU
-dialoginput.bold.hebrew=David Bold
-dialoginput.bold.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.bold.korean=Gulim
-
-dialoginput.italic.alphabetic=Courier New Italic
-dialoginput.italic.chinese-ms950=PMingLiU
-dialoginput.italic.hebrew=David
-dialoginput.italic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.italic.korean=Gulim
-
-dialoginput.bolditalic.alphabetic=Courier New Bold Italic
-dialoginput.bolditalic.chinese-ms950=PMingLiU
-dialoginput.bolditalic.hebrew=David Bold
-dialoginput.bolditalic.japanese=\uff2d\uff33 \u30b4\u30b7\u30c3\u30af
-dialoginput.bolditalic.korean=Gulim
-
-# Search Sequences
-
-sequence.allfonts=alphabetic/default,dingbats,symbol
-
-sequence.serif.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.sansserif.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.monospaced.GBK=chinese-ms936,alphabetic/1252,dingbats,symbol
-sequence.dialog.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-sequence.dialoginput.GBK=alphabetic/1252,chinese-ms936,dingbats,symbol
-
-sequence.serif.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.sansserif.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.monospaced.x-windows-950=chinese-ms950,alphabetic/1252,dingbats,symbol
-sequence.dialog.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-sequence.dialoginput.x-windows-950=alphabetic/1252,chinese-ms950,dingbats,symbol
-
-sequence.allfonts.windows-1255=hebrew,alphabetic/1252,dingbats,symbol
-
-sequence.serif.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.sansserif.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.monospaced.windows-31j=japanese,alphabetic/1252,dingbats,symbol
-sequence.dialog.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-sequence.dialoginput.windows-31j=alphabetic/1252,japanese,dingbats,symbol
-
-sequence.serif.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.sansserif.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.monospaced.x-windows-949=korean,alphabetic/1252,dingbats,symbol
-sequence.dialog.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-sequence.dialoginput.x-windows-949=alphabetic/1252,korean,dingbats,symbol
-
-sequence.allfonts.x-windows-874=alphabetic/1252,thai,dingbats,symbol
-
-sequence.fallback=lucida
-
-# Exclusion Ranges
-
-exclusion.alphabetic=0700-1e9f,1f00-20ab,20ad-f8ff
-exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
-
-# Monospaced to Proportional width variant mapping
-# (Experimental private syntax)
-proportional.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=\uff2d\uff33 \uff30\u30b4\u30b7\u30c3\u30af
-proportional.\uff2d\uff33_\u660e\u671d=\uff2d\uff33 \uff30\u660e\u671d
-proportional.MingLiU=PMingLiU
-
-# Font File Names
-
-filename.Arial=ARIAL.TTF
-filename.Arial_Bold=ARIALBD.TTF
-filename.Arial_Italic=ARIALI.TTF
-filename.Arial_Bold_Italic=ARIALBI.TTF
-
-filename.Courier_New=COUR.TTF
-filename.Courier_New_Bold=COURBD.TTF
-filename.Courier_New_Italic=COURI.TTF
-filename.Courier_New_Bold_Italic=COURBI.TTF
-
-filename.Times_New_Roman=TIMES.TTF
-filename.Times_New_Roman_Bold=TIMESBD.TTF
-filename.Times_New_Roman_Italic=TIMESI.TTF
-filename.Times_New_Roman_Bold_Italic=TIMESBI.TTF
-
-filename.SimSun=SIMSUN.TTF
-
-filename.MingLiU=MINGLIU.TTC
-filename.PMingLiU=MINGLIU.TTC
-
-filename.David=DAVID.TTF
-filename.David_Bold=DAVIDBD.TTF
-
-filename.\uff2d\uff33_\u660e\u671d=MSMINCHO.TTC
-filename.\uff2d\uff33_\uff30\u660e\u671d=MSMINCHO.TTC
-filename.\uff2d\uff33_\u30b4\u30b7\u30c3\u30af=MSGOTHIC.TTC
-filename.\uff2d\uff33_\uff30\u30b4\u30b7\u30c3\u30af=MSGOTHIC.TTC
-
-filename.Gulim=gulim.TTC
-filename.Batang=batang.TTC
-filename.GulimChe=gulim.TTC
-
-filename.Lucida_Sans_Regular=LucidaSansRegular.ttf
-filename.Symbol=SYMBOL.TTF
-filename.Wingdings=WINGDING.TTF
-
From fa5248c9db8c661b898ff4e9e03433128b2534c4 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Wed, 24 Dec 2008 09:53:52 -0800
Subject: [PATCH 004/283] 6728838: Native memory leak in StrikeCache.java
Reviewed-by: bae, igor
---
jdk/src/share/classes/sun/font/StrikeCache.java | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/jdk/src/share/classes/sun/font/StrikeCache.java b/jdk/src/share/classes/sun/font/StrikeCache.java
index 560be3af2cd..56539e7489f 100644
--- a/jdk/src/share/classes/sun/font/StrikeCache.java
+++ b/jdk/src/share/classes/sun/font/StrikeCache.java
@@ -232,6 +232,16 @@ public final class StrikeCache {
if (disposer.pScalerContext != 0L) {
freeLongMemory(new long[0], disposer.pScalerContext);
}
+ } else if (disposer.pScalerContext != 0L) {
+ /* Rarely a strike may have been created that never cached
+ * any glyphs. In this case we still want to free the scaler
+ * context.
+ */
+ if (FontManager.longAddresses) {
+ freeLongMemory(new long[0], disposer.pScalerContext);
+ } else {
+ freeIntMemory(new int[0], disposer.pScalerContext);
+ }
}
}
From 6f0de04c8704af289dcfa836939be14c9dc0a365 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Wed, 24 Dec 2008 09:57:48 -0800
Subject: [PATCH 005/283] 6752638:
java.awt.GraphicsEnvironment.preferLocaleFonts() throws NPE on Linux 6755034:
Legal notice repair:
jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
Reviewed-by: bae, igor
---
.../classes/java/awt/GraphicsEnvironment.java | 6 ++
.../classes/sun/awt/FontConfiguration.java | 6 +-
.../classes/sun/font/FcFontConfiguration.java | 3 +-
.../PreferLocaleFonts.java | 62 +++++++++++++++++++
4 files changed, 75 insertions(+), 2 deletions(-)
create mode 100644 jdk/test/java/awt/GraphicsEnvironment/PreferLocaleFonts.java
diff --git a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
index 167db051910..cf1852e2fc0 100644
--- a/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
+++ b/jdk/src/share/classes/java/awt/GraphicsEnvironment.java
@@ -356,6 +356,9 @@ public abstract class GraphicsEnvironment {
* @since 1.5
*/
public void preferLocaleFonts() {
+ if (!(this instanceof SunGraphicsEnvironment)) {
+ return;
+ }
sun.font.FontManager.preferLocaleFonts();
}
@@ -376,6 +379,9 @@ public abstract class GraphicsEnvironment {
* @since 1.5
*/
public void preferProportionalFonts() {
+ if (!(this instanceof SunGraphicsEnvironment)) {
+ return;
+ }
sun.font.FontManager.preferProportionalFonts();
}
diff --git a/jdk/src/share/classes/sun/awt/FontConfiguration.java b/jdk/src/share/classes/sun/awt/FontConfiguration.java
index 6349aa778ea..4504af24e9d 100644
--- a/jdk/src/share/classes/sun/awt/FontConfiguration.java
+++ b/jdk/src/share/classes/sun/awt/FontConfiguration.java
@@ -98,7 +98,7 @@ public abstract class FontConfiguration {
if (!inited) {
this.preferLocaleFonts = false;
this.preferPropFonts = false;
- fontConfig = this; /* static initialization */
+ setFontConfiguration();
readFontConfigFile(fontConfigFile);
initFontConfig();
inited = true;
@@ -1244,6 +1244,10 @@ public abstract class FontConfiguration {
return fontConfig;
}
+ protected void setFontConfiguration() {
+ fontConfig = this; /* static initialization */
+ }
+
//////////////////////////////////////////////////////////////////////
// FontConfig data tables and the index constants in binary file //
//////////////////////////////////////////////////////////////////////
diff --git a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
index fe2e5dbf836..95154df0a47 100644
--- a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
+++ b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
@@ -15,7 +15,7 @@
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
- * along with this work; if not, write to the Free Software Foundation,
+ * 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
@@ -87,6 +87,7 @@ public class FcFontConfiguration extends FontConfiguration {
return true;
}
+ setFontConfiguration();
readFcInfo();
if (fcCompFonts == null) {
fcCompFonts = FontManager.loadFontConfig();
diff --git a/jdk/test/java/awt/GraphicsEnvironment/PreferLocaleFonts.java b/jdk/test/java/awt/GraphicsEnvironment/PreferLocaleFonts.java
new file mode 100644
index 00000000000..3d8cb5934f5
--- /dev/null
+++ b/jdk/test/java/awt/GraphicsEnvironment/PreferLocaleFonts.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6752638
+ * @summary Test no NPE calling preferLocaleFonts() on custom GE.
+ * @run main PreferLocaleFonts
+ */
+
+import java.util.*;
+import java.awt.*;
+import java.awt.image.*;
+
+public class PreferLocaleFonts extends GraphicsEnvironment {
+
+ public static void main(String args[]) {
+(new PreferLocaleFonts()).preferLocaleFonts();
+ }
+ public PreferLocaleFonts() {
+ super();
+ }
+ public Graphics2D createGraphics(BufferedImage image) {
+ return null;
+ }
+ public String[] getAvailableFontFamilyNames(Locale locale) {
+ return null;
+ }
+ public String[] getAvailableFontFamilyNames() {
+ return null;
+ }
+ public Font[] getAllFonts() {
+ return null;
+ }
+ public GraphicsDevice getDefaultScreenDevice() throws HeadlessException {
+ return null;
+ }
+ public GraphicsDevice[] getScreenDevices() throws HeadlessException {
+ return null;
+ }
+}
+
From a0930ff4d46ce23e6b298e862857768afd6d9d15 Mon Sep 17 00:00:00 2001
From: Phil Race
Date: Tue, 6 Jan 2009 13:52:03 -0800
Subject: [PATCH 006/283] 6785424: SecurityException locating physical fonts on
Windows Terminal Server
Reviewed-by: campbell, jgodinez
---
.../share/classes/sun/font/FontManager.java | 21 +++++---
jdk/test/java/awt/FontClass/FontAccess.java | 48 +++++++++++++++++++
2 files changed, 63 insertions(+), 6 deletions(-)
create mode 100644 jdk/test/java/awt/FontClass/FontAccess.java
diff --git a/jdk/src/share/classes/sun/font/FontManager.java b/jdk/src/share/classes/sun/font/FontManager.java
index f709f381ada..a8b721daffc 100644
--- a/jdk/src/share/classes/sun/font/FontManager.java
+++ b/jdk/src/share/classes/sun/font/FontManager.java
@@ -1601,18 +1601,27 @@ public final class FontManager {
/* Path may be absolute or a base file name relative to one of
* the platform font directories
*/
- private static String getPathName(String s) {
+ private static String getPathName(final String s) {
File f = new File(s);
if (f.isAbsolute()) {
return s;
} else if (pathDirs.length==1) {
return pathDirs[0] + File.separator + s;
} else {
- for (int p=0; p() {
+ public String run() {
+ for (int p=0; p
Date: Mon, 12 Jan 2009 16:02:47 -0800
Subject: [PATCH 007/283] 6752622: java.awt.Font.getPeer throws
"java.lang.InternalError: Not implemented" on Linux
Reviewed-by: igor, yan
---
jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java | 7 -------
jdk/src/solaris/classes/sun/font/FcFontConfiguration.java | 2 +-
2 files changed, 1 insertion(+), 8 deletions(-)
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java
index 62044ace53e..3d03a2503aa 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFontPeer.java
@@ -27,9 +27,6 @@ package sun.awt.X11;
import sun.awt.PlatformFont;
import java.awt.GraphicsEnvironment;
-/* FIX ME */
-import sun.awt.motif.MFontConfiguration;
-
public class XFontPeer extends PlatformFont {
/*
@@ -51,10 +48,6 @@ public class XFontPeer extends PlatformFont {
public XFontPeer(String name, int style){
super(name, style);
-
- if (fontConfig != null){
- xfsname = ((MFontConfiguration) fontConfig).getMotifFontSet(familyName, style);
- }
}
protected char getMissingGlyphCharacter() {
diff --git a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
index 95154df0a47..a34fed02e15 100644
--- a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
+++ b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java
@@ -173,7 +173,7 @@ public class FcFontConfiguration extends FontConfiguration {
@Override
public FontDescriptor[] getFontDescriptors(String fontName, int style) {
- throw new InternalError("Not implemented");
+ return new FontDescriptor[0];
}
@Override
From bf4d190698d0b36f90af28f05ef856b7d03ffd52 Mon Sep 17 00:00:00 2001
From: Martin von Gagern
Date: Tue, 13 Jan 2009 16:55:12 +0300
Subject: [PATCH 008/283] 5082756: Image I/O plug-ins set metadata boolean
attributes to "true" or "false"
Reviewed-by: igor, prr
---
.../imageio/plugins/gif/GIFImageMetadata.java | 6 +-
.../sun/imageio/plugins/gif/GIFMetadata.java | 9 +-
.../plugins/gif/GIFStreamMetadata.java | 2 +-
.../imageio/plugins/jpeg/JPEGMetadata.java | 2 +-
.../sun/imageio/plugins/png/PNGMetadata.java | 13 +-
.../imageio/metadata/IIOMetadataFormat.java | 8 +-
.../imageio/metadata/BooleanAttributes.java | 202 ++++++++++++++++++
.../javax/imageio/plugins/png/ITXtTest.java | 2 +-
8 files changed, 224 insertions(+), 20 deletions(-)
create mode 100644 jdk/test/javax/imageio/metadata/BooleanAttributes.java
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java
index 08da84856b7..9660d82603a 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageMetadata.java
@@ -153,7 +153,7 @@ public class GIFImageMetadata extends GIFMetadata {
node.setAttribute("imageWidth", Integer.toString(imageWidth));
node.setAttribute("imageHeight", Integer.toString(imageHeight));
node.setAttribute("interlaceFlag",
- interlaceFlag ? "true" : "false");
+ interlaceFlag ? "TRUE" : "FALSE");
root.appendChild(node);
// Local color table
@@ -185,9 +185,9 @@ public class GIFImageMetadata extends GIFMetadata {
node.setAttribute("disposalMethod",
disposalMethodNames[disposalMethod]);
node.setAttribute("userInputFlag",
- userInputFlag ? "true" : "false");
+ userInputFlag ? "TRUE" : "FALSE");
node.setAttribute("transparentColorFlag",
- transparentColorFlag ? "true" : "false");
+ transparentColorFlag ? "TRUE" : "FALSE");
node.setAttribute("delayTime",
Integer.toString(delayTime));
node.setAttribute("transparentColorIndex",
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFMetadata.java
index 42dfbd0bed9..8acdaa2db49 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFMetadata.java
@@ -158,13 +158,10 @@ abstract class GIFMetadata extends IIOMetadata {
}
}
String value = attr.getNodeValue();
- // XXX Should be able to use equals() here instead of
- // equalsIgnoreCase() but some boolean attributes are incorrectly
- // set to "true" or "false" by the J2SE core metadata classes
- // getAsTree() method (which are duplicated above). See bug 5082756.
- if (value.equalsIgnoreCase("TRUE")) {
+ // Allow lower case booleans for backward compatibility, #5082756
+ if (value.equals("TRUE") || value.equals("true")) {
return true;
- } else if (value.equalsIgnoreCase("FALSE")) {
+ } else if (value.equals("FALSE") || value.equals("false")) {
return false;
} else {
fatal(node, "Attribute " + name + " must be 'TRUE' or 'FALSE'!");
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFStreamMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFStreamMetadata.java
index 0979bf3d849..bc0a784b272 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFStreamMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFStreamMetadata.java
@@ -202,7 +202,7 @@ public class GIFStreamMetadata extends GIFMetadata {
compression_node.appendChild(node);
node = new IIOMetadataNode("Lossless");
- node.setAttribute("value", "true");
+ node.setAttribute("value", "TRUE");
compression_node.appendChild(node);
// NumProgressiveScans not in stream
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
index 7f753341c93..c84003c9f22 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
@@ -955,7 +955,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
// Lossless - false
IIOMetadataNode lossless = new IIOMetadataNode("Lossless");
- lossless.setAttribute("value", "false");
+ lossless.setAttribute("value", "FALSE");
compression.appendChild(lossless);
// NumProgressiveScans - count sos segments
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
index 23281fe5330..1ad78ad165f 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
@@ -600,7 +600,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
IIOMetadataNode iTXt_node = new IIOMetadataNode("iTXtEntry");
iTXt_node.setAttribute("keyword", iTXt_keyword.get(i));
iTXt_node.setAttribute("compressionFlag",
- iTXt_compressionFlag.get(i) ? "1" : "0");
+ iTXt_compressionFlag.get(i) ? "TRUE" : "FALSE");
iTXt_node.setAttribute("compressionMethod",
iTXt_compressionMethod.get(i).toString());
iTXt_node.setAttribute("languageTag",
@@ -832,7 +832,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
node = new IIOMetadataNode("BlackIsZero");
- node.setAttribute("value", "true");
+ node.setAttribute("value", "TRUE");
chroma_node.appendChild(node);
if (PLTE_present) {
@@ -894,7 +894,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
compression_node.appendChild(node);
node = new IIOMetadataNode("Lossless");
- node.setAttribute("value", "true");
+ node.setAttribute("value", "TRUE");
compression_node.appendChild(node);
node = new IIOMetadataNode("NumProgressiveScans");
@@ -1162,12 +1162,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
}
}
String value = attr.getNodeValue();
- if (value.equals("true")) {
+ // Allow lower case booleans for backward compatibility, #5082756
+ if (value.equals("TRUE") || value.equals("true")) {
return true;
- } else if (value.equals("false")) {
+ } else if (value.equals("FALSE") || value.equals("false")) {
return false;
} else {
- fatal(node, "Attribute " + name + " must be 'true' or 'false'!");
+ fatal(node, "Attribute " + name + " must be 'TRUE' or 'FALSE'!");
return false;
}
}
diff --git a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormat.java b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormat.java
index 88ea8e98756..cff46177d62 100644
--- a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormat.java
+++ b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataFormat.java
@@ -242,8 +242,12 @@ public interface IIOMetadataFormat {
/**
* A constant returned by getAttributeDataType
- * indicating that the value of an attribute is one of 'true' or
- * 'false'.
+ * indicating that the value of an attribute is one of the boolean
+ * values 'true' or 'false'.
+ * Attribute values of type DATATYPE_BOOLEAN should be marked as
+ * enumerations, and the permitted values should be the string
+ * literal values "TRUE" or "FALSE", although a plugin may also
+ * recognise lower or mixed case equivalents.
*/
int DATATYPE_BOOLEAN = 1;
diff --git a/jdk/test/javax/imageio/metadata/BooleanAttributes.java b/jdk/test/javax/imageio/metadata/BooleanAttributes.java
new file mode 100644
index 00000000000..104b12432c8
--- /dev/null
+++ b/jdk/test/javax/imageio/metadata/BooleanAttributes.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 5082756
+ * @summary ensure that boolean attributes follow ( "TRUE" | "FALSE" )
+ * including correct (i.e. upper) case
+ *
+ * @run main BooleanAttributes
+ */
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+import java.util.Arrays;
+import java.util.List;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.MemoryCacheImageInputStream;
+import javax.imageio.stream.MemoryCacheImageOutputStream;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class BooleanAttributes {
+
+ private static TransformerFactory transformerFactory =
+ TransformerFactory.newInstance();
+
+ private static XPath xpathEngine = XPathFactory.newInstance().newXPath();
+
+ public static void main(String[] args) throws Exception {
+ test("image/png", false, "",
+ "Chroma/BlackIsZero/@value",
+ "Compression/Lossless/@value");
+
+ test("image/png", false,
+ "" +
+ "" +
+ "",
+ "iTXt/iTXtEntry/@compressionFlag");
+
+ test("image/png", false,
+ "" +
+ "" +
+ "",
+ "iTXt/iTXtEntry/@compressionFlag");
+
+ test("image/gif", false, "",
+ "Chroma/BlackIsZero/@value",
+ "Compression/Lossless/@value");
+
+ test("image/gif", false,
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "",
+ "ImageDescriptor/@interlaceFlag",
+ "LocalColorTable/@sortFlag",
+ "GraphicControlExtension/@userInputFlag",
+ "GraphicControlExtension/@transparentColorFlag");
+
+ test("image/gif", true,
+ "" +
+ "" +
+ "" +
+ "" +
+ "" +
+ "",
+ "GlobalColorTable/@sortFlag");
+
+ test("image/jpeg", false, "",
+ "Compression/Lossless/@value");
+ }
+
+ private static void transform(Source src, Result dst)
+ throws Exception
+ {
+ transformerFactory.newTransformer().transform(src, dst);
+ }
+
+ private static void verify(Node meta, String[] xpaths, boolean required)
+ throws Exception
+ {
+ for (String xpath: xpaths) {
+ NodeList list = (NodeList)
+ xpathEngine.evaluate(xpath, meta, XPathConstants.NODESET);
+ if (list.getLength() == 0 && required)
+ throw new AssertionError("Missing value: " + xpath);
+ for (int i = 0; i < list.getLength(); ++i) {
+ String value = list.item(i).getNodeValue();
+ if (!(value.equals("TRUE") || value.equals("FALSE")))
+ throw new AssertionError(xpath + " has value " + value);
+ }
+ }
+ }
+
+ public static void test(String mimeType, boolean useStreamMeta,
+ String metaXml, String... boolXpaths)
+ throws Exception
+ {
+ BufferedImage img =
+ new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+ ImageWriter iw = ImageIO.getImageWritersByMIMEType(mimeType).next();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ImageOutputStream ios = new MemoryCacheImageOutputStream(os);
+ iw.setOutput(ios);
+ ImageWriteParam param = null;
+ IIOMetadata streamMeta = iw.getDefaultStreamMetadata(param);
+ IIOMetadata imageMeta =
+ iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), param);
+ IIOMetadata meta = useStreamMeta ? streamMeta : imageMeta;
+ Source src = new StreamSource(new StringReader(metaXml));
+ DOMResult dst = new DOMResult();
+ transform(src, dst);
+ Document doc = (Document)dst.getNode();
+ Element node = doc.getDocumentElement();
+ String metaFormat = node.getNodeName();
+
+ // Verify that the default metadata gets formatted correctly.
+ verify(meta.getAsTree(metaFormat), boolXpaths, false);
+
+ meta.mergeTree(metaFormat, node);
+
+ // Verify that the merged metadata gets formatte correctly.
+ verify(meta.getAsTree(metaFormat), boolXpaths, true);
+
+ iw.write(streamMeta, new IIOImage(img, null, imageMeta), param);
+ iw.dispose();
+ ios.close();
+ ImageReader ir = ImageIO.getImageReader(iw);
+ byte[] bytes = os.toByteArray();
+ if (bytes.length == 0)
+ throw new AssertionError("Zero length image file");
+ ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+ ImageInputStream iis = new MemoryCacheImageInputStream(is);
+ ir.setInput(iis);
+ if (useStreamMeta) meta = ir.getStreamMetadata();
+ else meta = ir.getImageMetadata(0);
+
+ // Verify again after writing and re-reading the image
+ verify(meta.getAsTree(metaFormat), boolXpaths, true);
+ }
+
+ public static void xtest(Object... eatAnyArguments) {
+ System.err.println("Disabled test! Change xtest back into test!");
+ }
+
+}
diff --git a/jdk/test/javax/imageio/plugins/png/ITXtTest.java b/jdk/test/javax/imageio/plugins/png/ITXtTest.java
index 9bace746227..ec81bd874ac 100644
--- a/jdk/test/javax/imageio/plugins/png/ITXtTest.java
+++ b/jdk/test/javax/imageio/plugins/png/ITXtTest.java
@@ -123,7 +123,7 @@ public class ITXtTest {
}
t.keyword = e.getAttribute("keyword");
t.isCompressed =
- (Integer.valueOf(e.getAttribute("compressionFlag")).intValue() == 1);
+ Boolean.valueOf(e.getAttribute("compressionFlag")).booleanValue();
t.compression =
Integer.valueOf(e.getAttribute("compressionMethod")).intValue();
t.language = e.getAttribute("languageTag");
From 57a1271b06b6a1cc4548fb353d8c0cf261eb0a38 Mon Sep 17 00:00:00 2001
From: Martin von Gagern
Date: Tue, 13 Jan 2009 18:38:44 +0300
Subject: [PATCH 009/283] 6782079: PNG: reading metadata may cause OOM on
truncated images
Reviewed-by: igor, prr
---
.../imageio/plugins/png/PNGImageReader.java | 45 ++--
.../imageio/plugins/png/PNGImageWriter.java | 9 +-
.../sun/imageio/plugins/png/PNGMetadata.java | 43 ++--
.../imageio/plugins/png/ItxtUtf8Test.java | 241 ++++++++++++++++++
4 files changed, 281 insertions(+), 57 deletions(-)
create mode 100644 jdk/test/javax/imageio/plugins/png/ItxtUtf8Test.java
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
index 84a593264be..f35165420e9 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
@@ -37,6 +37,7 @@ import java.awt.image.WritableRaster;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
+import java.io.EOFException;
import java.io.InputStream;
import java.io.IOException;
import java.io.SequenceInputStream;
@@ -59,7 +60,7 @@ import com.sun.imageio.plugins.common.SubImageInputStream;
import java.io.ByteArrayOutputStream;
import sun.awt.image.ByteInterleavedRaster;
-class PNGImageDataEnumeration implements Enumeration {
+class PNGImageDataEnumeration implements Enumeration {
boolean firstTime = true;
ImageInputStream stream;
@@ -72,7 +73,7 @@ class PNGImageDataEnumeration implements Enumeration {
int type = stream.readInt(); // skip chunk type
}
- public Object nextElement() {
+ public InputStream nextElement() {
try {
firstTime = false;
ImageInputStream iis = new SubImageInputStream(stream, length);
@@ -207,25 +208,17 @@ public class PNGImageReader extends ImageReader {
resetStreamSettings();
}
- private String readNullTerminatedString(String charset) throws IOException {
+ private String readNullTerminatedString(String charset, int maxLen) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int b;
- while ((b = stream.read()) != 0) {
+ int count = 0;
+ while ((maxLen > count++) && ((b = stream.read()) != 0)) {
+ if (b == -1) throw new EOFException();
baos.write(b);
}
return new String(baos.toByteArray(), charset);
}
- private String readNullTerminatedString() throws IOException {
- StringBuilder b = new StringBuilder();
- int c;
-
- while ((c = stream.read()) != 0) {
- b.append((char)c);
- }
- return b.toString();
- }
-
private void readHeader() throws IIOException {
if (gotHeader) {
return;
@@ -434,7 +427,7 @@ public class PNGImageReader extends ImageReader {
}
private void parse_iCCP_chunk(int chunkLength) throws IOException {
- String keyword = readNullTerminatedString();
+ String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.iCCP_profileName = keyword;
metadata.iCCP_compressionMethod = stream.readUnsignedByte();
@@ -450,7 +443,7 @@ public class PNGImageReader extends ImageReader {
private void parse_iTXt_chunk(int chunkLength) throws IOException {
long chunkStart = stream.getStreamPosition();
- String keyword = readNullTerminatedString();
+ String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.iTXt_keyword.add(keyword);
int compressionFlag = stream.readUnsignedByte();
@@ -459,15 +452,17 @@ public class PNGImageReader extends ImageReader {
int compressionMethod = stream.readUnsignedByte();
metadata.iTXt_compressionMethod.add(Integer.valueOf(compressionMethod));
- String languageTag = readNullTerminatedString("UTF8");
+ String languageTag = readNullTerminatedString("UTF8", 80);
metadata.iTXt_languageTag.add(languageTag);
+ long pos = stream.getStreamPosition();
+ int maxLen = (int)(chunkStart + chunkLength - pos);
String translatedKeyword =
- readNullTerminatedString("UTF8");
+ readNullTerminatedString("UTF8", maxLen);
metadata.iTXt_translatedKeyword.add(translatedKeyword);
String text;
- long pos = stream.getStreamPosition();
+ pos = stream.getStreamPosition();
byte[] b = new byte[(int)(chunkStart + chunkLength - pos)];
stream.readFully(b);
@@ -511,7 +506,7 @@ public class PNGImageReader extends ImageReader {
private void parse_sPLT_chunk(int chunkLength)
throws IOException, IIOException {
- metadata.sPLT_paletteName = readNullTerminatedString();
+ metadata.sPLT_paletteName = readNullTerminatedString("ISO-8859-1", 80);
chunkLength -= metadata.sPLT_paletteName.length() + 1;
int sampleDepth = stream.readUnsignedByte();
@@ -554,12 +549,12 @@ public class PNGImageReader extends ImageReader {
}
private void parse_tEXt_chunk(int chunkLength) throws IOException {
- String keyword = readNullTerminatedString();
+ String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.tEXt_keyword.add(keyword);
byte[] b = new byte[chunkLength - keyword.length() - 1];
stream.readFully(b);
- metadata.tEXt_text.add(new String(b));
+ metadata.tEXt_text.add(new String(b, "ISO-8859-1"));
}
private void parse_tIME_chunk() throws IOException {
@@ -640,7 +635,7 @@ public class PNGImageReader extends ImageReader {
}
private void parse_zTXt_chunk(int chunkLength) throws IOException {
- String keyword = readNullTerminatedString();
+ String keyword = readNullTerminatedString("ISO-8859-1", 80);
metadata.zTXt_keyword.add(keyword);
int method = stream.readUnsignedByte();
@@ -648,7 +643,7 @@ public class PNGImageReader extends ImageReader {
byte[] b = new byte[chunkLength - keyword.length() - 2];
stream.readFully(b);
- metadata.zTXt_text.add(new String(inflate(b)));
+ metadata.zTXt_text.add(new String(inflate(b), "ISO-8859-1"));
}
private void readMetadata() throws IIOException {
@@ -1263,7 +1258,7 @@ public class PNGImageReader extends ImageReader {
try {
stream.seek(imageStartPosition);
- Enumeration e = new PNGImageDataEnumeration(stream);
+ Enumeration e = new PNGImageDataEnumeration(stream);
InputStream is = new SequenceInputStream(e);
/* InflaterInputStream uses an Inflater instance which consumes
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
index ea4233a68ea..0f9cc785f92 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
@@ -674,13 +674,8 @@ public class PNGImageWriter extends ImageWriter {
private byte[] deflate(byte[] b) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DeflaterOutputStream dos = new DeflaterOutputStream(baos);
-
- int len = b.length;
- for (int i = 0; i < len; i++) {
- dos.write((int)(0xff & b[i]));
- }
+ dos.write(b);
dos.close();
-
return baos.toByteArray();
}
@@ -736,7 +731,7 @@ public class PNGImageWriter extends ImageWriter {
cs.writeByte(compressionMethod);
String text = (String)textIter.next();
- cs.write(deflate(text.getBytes()));
+ cs.write(deflate(text.getBytes("ISO-8859-1")));
cs.finish();
}
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
index 1ad78ad165f..9da72298884 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
@@ -211,8 +211,8 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
public int sRGB_renderingIntent;
// tEXt chunk
- public ArrayList tEXt_keyword = new ArrayList(); // 1-79 char Strings
- public ArrayList tEXt_text = new ArrayList(); // Strings
+ public ArrayList tEXt_keyword = new ArrayList(); // 1-79 characters
+ public ArrayList tEXt_text = new ArrayList();
// tIME chunk
public boolean tIME_present;
@@ -235,13 +235,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
public int tRNS_blue;
// zTXt chunk
- public ArrayList zTXt_keyword = new ArrayList(); // Strings
- public ArrayList zTXt_compressionMethod = new ArrayList(); // Integers
- public ArrayList zTXt_text = new ArrayList(); // Strings
+ public ArrayList zTXt_keyword = new ArrayList();
+ public ArrayList zTXt_compressionMethod = new ArrayList();
+ public ArrayList zTXt_text = new ArrayList();
// Unknown chunks
- public ArrayList unknownChunkType = new ArrayList(); // Strings
- public ArrayList unknownChunkData = new ArrayList(); // byte arrays
+ public ArrayList unknownChunkType = new ArrayList();
+ public ArrayList unknownChunkData = new ArrayList();
public PNGMetadata() {
super(true,
@@ -426,21 +426,14 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
return false;
}
- private ArrayList cloneBytesArrayList(ArrayList in) {
+ private ArrayList cloneBytesArrayList(ArrayList in) {
if (in == null) {
return null;
} else {
- ArrayList list = new ArrayList(in.size());
- Iterator iter = in.iterator();
- while (iter.hasNext()) {
- Object o = iter.next();
- if (o == null) {
- list.add(null);
- } else {
- list.add(((byte[])o).clone());
- }
+ ArrayList list = new ArrayList(in.size());
+ for (byte[] b: in) {
+ list.add((b == null) ? null : (byte[])b.clone());
}
-
return list;
}
}
@@ -2040,14 +2033,14 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
sBIT_present = false;
sPLT_present = false;
sRGB_present = false;
- tEXt_keyword = new ArrayList();
- tEXt_text = new ArrayList();
+ tEXt_keyword = new ArrayList();
+ tEXt_text = new ArrayList();
tIME_present = false;
tRNS_present = false;
- zTXt_keyword = new ArrayList();
- zTXt_compressionMethod = new ArrayList();
- zTXt_text = new ArrayList();
- unknownChunkType = new ArrayList();
- unknownChunkData = new ArrayList();
+ zTXt_keyword = new ArrayList();
+ zTXt_compressionMethod = new ArrayList();
+ zTXt_text = new ArrayList();
+ unknownChunkType = new ArrayList();
+ unknownChunkData = new ArrayList();
}
}
diff --git a/jdk/test/javax/imageio/plugins/png/ItxtUtf8Test.java b/jdk/test/javax/imageio/plugins/png/ItxtUtf8Test.java
new file mode 100644
index 00000000000..e35495bdee1
--- /dev/null
+++ b/jdk/test/javax/imageio/plugins/png/ItxtUtf8Test.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6541476 6782079
+ * @summary Write and read a PNG file including an non-latin1 iTXt chunk
+ * Test also verifies that trunkated png images does not cause
+ * an OoutOfMemory error.
+ *
+ * @run main ItxtUtf8Test
+ *
+ * @run main/othervm/timeout=10 -Xmx2m ItxtUtf8Test truncate
+ */
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.List;
+import javax.imageio.IIOException;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.MemoryCacheImageInputStream;
+import javax.imageio.stream.MemoryCacheImageOutputStream;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+
+public class ItxtUtf8Test {
+
+ public static final String
+ TEXT = "\u24c9\u24d4\u24e7\u24e3" +
+ "\ud835\udc13\ud835\udc1e\ud835\udc31\ud835\udc2d" +
+ "\u24c9\u24d4\u24e7\u24e3", // a repetition for compression
+ VERBATIM = "\u24e5\u24d4\u24e1\u24d1\u24d0\u24e3\u24d8\u24dc",
+ COMPRESSED = "\u24d2\u24de\u24dc\u24df\u24e1\u24d4\u24e2\u24e2\u24d4\u24d3";
+
+ public static final byte[]
+ VBYTES = {
+ (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x56, // chunk length
+ (byte)0x69, (byte)0x54, (byte)0x58, (byte)0x74, // chunk type "iTXt"
+ (byte)0x76, (byte)0x65, (byte)0x72, (byte)0x62,
+ (byte)0x61, (byte)0x74, (byte)0x69, (byte)0x6d, // keyword "verbatim"
+ (byte)0x00, // separator terminating keyword
+ (byte)0x00, // compression flag
+ (byte)0x00, // compression method, must be zero
+ (byte)0x78, (byte)0x2d, (byte)0x63, (byte)0x69,
+ (byte)0x72, (byte)0x63, (byte)0x6c, (byte)0x65,
+ (byte)0x64, // language tag "x-circled"
+ (byte)0x00, // separator terminating language tag
+ (byte)0xe2, (byte)0x93, (byte)0xa5, // '\u24e5'
+ (byte)0xe2, (byte)0x93, (byte)0x94, // '\u24d4'
+ (byte)0xe2, (byte)0x93, (byte)0xa1, // '\u24e1'
+ (byte)0xe2, (byte)0x93, (byte)0x91, // '\u24d1'
+ (byte)0xe2, (byte)0x93, (byte)0x90, // '\u24d0'
+ (byte)0xe2, (byte)0x93, (byte)0xa3, // '\u24e3'
+ (byte)0xe2, (byte)0x93, (byte)0x98, // '\u24d8'
+ (byte)0xe2, (byte)0x93, (byte)0x9c, // '\u24dc'
+ (byte)0x00, // separator terminating the translated keyword
+ (byte)0xe2, (byte)0x93, (byte)0x89, // '\u24c9'
+ (byte)0xe2, (byte)0x93, (byte)0x94, // '\u24d4'
+ (byte)0xe2, (byte)0x93, (byte)0xa7, // '\u24e7'
+ (byte)0xe2, (byte)0x93, (byte)0xa3, // '\u24e3'
+ (byte)0xf0, (byte)0x9d, (byte)0x90, (byte)0x93, // '\ud835\udc13'
+ (byte)0xf0, (byte)0x9d, (byte)0x90, (byte)0x9e, // '\ud835\udc1e'
+ (byte)0xf0, (byte)0x9d, (byte)0x90, (byte)0xb1, // '\ud835\udc31'
+ (byte)0xf0, (byte)0x9d, (byte)0x90, (byte)0xad, // '\ud835\udc2d'
+ (byte)0xe2, (byte)0x93, (byte)0x89, // '\u24c9'
+ (byte)0xe2, (byte)0x93, (byte)0x94, // '\u24d4'
+ (byte)0xe2, (byte)0x93, (byte)0xa7, // '\u24e7'
+ (byte)0xe2, (byte)0x93, (byte)0xa3, // '\u24e3'
+ (byte)0xb5, (byte)0xcc, (byte)0x97, (byte)0x56 // CRC
+ },
+ CBYTES = {
+ // we don't want to check the chunk length,
+ // as this might depend on implementation.
+ (byte)0x69, (byte)0x54, (byte)0x58, (byte)0x74, // chunk type "iTXt"
+ (byte)0x63, (byte)0x6f, (byte)0x6d, (byte)0x70,
+ (byte)0x72, (byte)0x65, (byte)0x73, (byte)0x73,
+ (byte)0x65, (byte)0x64, // keyword "compressed"
+ (byte)0x00, // separator terminating keyword
+ (byte)0x01, // compression flag
+ (byte)0x00, // compression method, 0=deflate
+ (byte)0x78, (byte)0x2d, (byte)0x63, (byte)0x69,
+ (byte)0x72, (byte)0x63, (byte)0x6c, (byte)0x65,
+ (byte)0x64, // language tag "x-circled"
+ (byte)0x00, // separator terminating language tag
+ // we don't want to check the actual compressed data,
+ // as this might depend on implementation.
+ };
+/*
+*/
+
+ public static void main(String[] args) throws Exception {
+ List argList = Arrays.asList(args);
+ if (argList.contains("truncate")) {
+ try {
+ runTest(false, true);
+ throw new AssertionError("Expect an error for truncated file");
+ }
+ catch (IIOException e) {
+ // expected an error for a truncated image file.
+ }
+ }
+ else {
+ runTest(argList.contains("dump"), false);
+ }
+ }
+
+ public static void runTest(boolean dump, boolean truncate)
+ throws Exception
+ {
+ String format = "javax_imageio_png_1.0";
+ BufferedImage img =
+ new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+ ImageWriter iw = ImageIO.getImageWritersByMIMEType("image/png").next();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ ImageOutputStream ios = new MemoryCacheImageOutputStream(os);
+ iw.setOutput(ios);
+ IIOMetadata meta =
+ iw.getDefaultImageMetadata(new ImageTypeSpecifier(img), null);
+ DOMImplementationRegistry registry;
+ registry = DOMImplementationRegistry.newInstance();
+ DOMImplementation impl = registry.getDOMImplementation("XML 3.0");
+ Document doc = impl.createDocument(null, format, null);
+ Element root, itxt, entry;
+ root = doc.getDocumentElement();
+ root.appendChild(itxt = doc.createElement("iTXt"));
+ itxt.appendChild(entry = doc.createElement("iTXtEntry"));
+ entry.setAttribute("keyword", "verbatim");
+ entry.setAttribute("compressionFlag", "false");
+ entry.setAttribute("compressionMethod", "0");
+ entry.setAttribute("languageTag", "x-circled");
+ entry.setAttribute("translatedKeyword", VERBATIM);
+ entry.setAttribute("text", TEXT);
+ itxt.appendChild(entry = doc.createElement("iTXtEntry"));
+ entry.setAttribute("keyword", "compressed");
+ entry.setAttribute("compressionFlag", "true");
+ entry.setAttribute("compressionMethod", "0");
+ entry.setAttribute("languageTag", "x-circled");
+ entry.setAttribute("translatedKeyword", COMPRESSED);
+ entry.setAttribute("text", TEXT);
+ meta.mergeTree(format, root);
+ iw.write(new IIOImage(img, null, meta));
+ iw.dispose();
+
+ byte[] bytes = os.toByteArray();
+ if (dump)
+ System.out.write(bytes);
+ if (findBytes(VBYTES, bytes) < 0)
+ throw new AssertionError("verbatim block not found");
+ if (findBytes(CBYTES, bytes) < 0)
+ throw new AssertionError("compressed block not found");
+ int length = bytes.length;
+ if (truncate)
+ length = findBytes(VBYTES, bytes) + 32;
+
+ ImageReader ir = ImageIO.getImageReader(iw);
+ ByteArrayInputStream is = new ByteArrayInputStream(bytes, 0, length);
+ ImageInputStream iis = new MemoryCacheImageInputStream(is);
+ ir.setInput(iis);
+ meta = ir.getImageMetadata(0);
+ Node node = meta.getAsTree(format);
+ for (node = node.getFirstChild();
+ !"iTXt".equals(node.getNodeName());
+ node = node.getNextSibling());
+ boolean verbatimSeen = false, compressedSeen = false;
+ for (node = node.getFirstChild();
+ node != null;
+ node = node.getNextSibling()) {
+ entry = (Element)node;
+ String keyword = entry.getAttribute("keyword");
+ String translatedKeyword = entry.getAttribute("translatedKeyword");
+ String text = entry.getAttribute("text");
+ if ("verbatim".equals(keyword)) {
+ if (verbatimSeen) throw new AssertionError("Duplicate");
+ verbatimSeen = true;
+ if (!VERBATIM.equals(translatedKeyword))
+ throw new AssertionError("Wrong translated keyword");
+ if (!TEXT.equals(text))
+ throw new AssertionError("Wrong text");
+ }
+ else if ("compressed".equals(keyword)) {
+ if (compressedSeen) throw new AssertionError("Duplicate");
+ compressedSeen = true;
+ if (!COMPRESSED.equals(translatedKeyword))
+ throw new AssertionError("Wrong translated keyword");
+ if (!TEXT.equals(text))
+ throw new AssertionError("Wrong text");
+ }
+ else {
+ throw new AssertionError("Unexpected keyword");
+ }
+ }
+ if (!(verbatimSeen && compressedSeen))
+ throw new AssertionError("Missing chunk");
+ }
+
+ private static final int findBytes(byte[] needle, byte[] haystack) {
+ HAYSTACK: for (int h = 0; h <= haystack.length - needle.length; ++h) {
+ for (int n = 0; n < needle.length; ++n) {
+ if (needle[n] != haystack[h + n]) {
+ continue HAYSTACK;
+ }
+ }
+ return h;
+ }
+ return -1;
+ }
+
+}
From 47a5b98c7f6ad40e66f40caa5d3017a5579870c7 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Thu, 15 Jan 2009 13:55:30 +0300
Subject: [PATCH 010/283] 6788096: ImageIO SreamCloser causes memory leak in FX
applets
Reviewed-by: igor, prr
---
.../com/sun/imageio/stream/StreamCloser.java | 4 +
.../stream/StreamCloserLeak/run_test.sh | 205 +++++++++++++
.../stream/StreamCloserLeak/test/Main.java | 284 ++++++++++++++++++
.../stream/StreamCloserLeak/testapp/Main.java | 109 +++++++
4 files changed, 602 insertions(+)
create mode 100644 jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh
create mode 100644 jdk/test/javax/imageio/stream/StreamCloserLeak/test/Main.java
create mode 100644 jdk/test/javax/imageio/stream/StreamCloserLeak/testapp/Main.java
diff --git a/jdk/src/share/classes/com/sun/imageio/stream/StreamCloser.java b/jdk/src/share/classes/com/sun/imageio/stream/StreamCloser.java
index f39b98eb05d..03c6ce32364 100644
--- a/jdk/src/share/classes/com/sun/imageio/stream/StreamCloser.java
+++ b/jdk/src/share/classes/com/sun/imageio/stream/StreamCloser.java
@@ -94,6 +94,10 @@ public class StreamCloser {
tgn != null;
tg = tgn, tgn = tg.getParent());
streamCloser = new Thread(tg, streamCloserRunnable);
+ /* Set context class loader to null in order to avoid
+ * keeping a strong reference to an application classloader.
+ */
+ streamCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(streamCloser);
return null;
}
diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh
new file mode 100644
index 00000000000..af3e428cb30
--- /dev/null
+++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/run_test.sh
@@ -0,0 +1,205 @@
+#!/bin/ksh -p
+#
+# Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+#
+# @test
+# @bug 6788096
+# @summary Test simulates the case of multiple applets executed in
+# the same VM and verifies that ImageIO shutdown hook
+# StreamCloser does not cause a leak of classloaders.
+#
+# @build test.Main
+# @build testapp.Main
+# @run shell run_test.sh
+
+# There are several resources which need to be present before many
+# shell scripts can run. Following are examples of how to check for
+# many common ones.
+#
+# Note that the shell used is the Korn Shell, KSH
+#
+# Also note, it is recommended that make files NOT be used. Rather,
+# put the individual commands directly into this file. That way,
+# it is possible to use command line arguments and other shell tech-
+# niques to find the compiler, etc on different systems. For example,
+# a different path could be used depending on whether this were a
+# Solaris or Win32 machine, which is more difficult (if even possible)
+# in a make file.
+
+
+# Beginning of subroutines:
+status=1
+
+#Call this from anywhere to fail the test with an error message
+# usage: fail "reason why the test failed"
+fail()
+ { echo "The test failed :-("
+ echo "$*" 1>&2
+ echo "exit status was $status"
+ exit $status
+ } #end of fail()
+
+#Call this from anywhere to pass the test with a message
+# usage: pass "reason why the test passed if applicable"
+pass()
+ { echo "The test passed!!!"
+ echo "$*" 1>&2
+ exit 0
+ } #end of pass()
+
+# end of subroutines
+
+
+# The beginning of the script proper
+
+# Checking for proper OS
+OS=`uname -s`
+case "$OS" in
+ SunOS )
+ VAR="One value for Sun"
+ DEFAULT_JDK=/usr/local/java/jdk1.2/solaris
+ FILESEP="/"
+ PATHSEP=":"
+ TMP="/tmp"
+ ;;
+
+ Linux )
+ VAR="A different value for Linux"
+ DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386
+ FILESEP="/"
+ PATHSEP=":"
+ TMP="/tmp"
+ ;;
+
+ Windows_95 | Windows_98 | Windows_NT | Windows_ME )
+ VAR="A different value for Win32"
+ DEFAULT_JDK=/usr/local/java/jdk1.2/win32
+ FILESEP="\\"
+ PATHSEP=";"
+ TMP=`cd "${SystemRoot}/Temp"; echo ${PWD}`
+ ;;
+
+ # catch all other OSs
+ * )
+ echo "Unrecognized system! $OS"
+ fail "Unrecognized system! $OS"
+ ;;
+esac
+
+# Want this test to run standalone as well as in the harness, so do the
+# following to copy the test's directory into the harness's scratch directory
+# and set all appropriate variables:
+
+if [ -z "${TESTJAVA}" ] ; then
+ # TESTJAVA is not set, so the test is running stand-alone.
+ # TESTJAVA holds the path to the root directory of the build of the JDK
+ # to be tested. That is, any java files run explicitly in this shell
+ # should use TESTJAVA in the path to the java interpreter.
+ # So, we'll set this to the JDK spec'd on the command line. If none
+ # is given on the command line, tell the user that and use a cheesy
+ # default.
+ # THIS IS THE JDK BEING TESTED.
+ if [ -n "$1" ] ;
+ then TESTJAVA=$1
+ else echo "no JDK specified on command line so using default!"
+ TESTJAVA=$DEFAULT_JDK
+ fi
+ TESTSRC=.
+ TESTCLASSES=.
+ STANDALONE=1;
+fi
+echo "JDK under test is: $TESTJAVA"
+
+
+############### YOUR TEST CODE HERE!!!!!!! #############
+
+#All files required for the test should be in the same directory with
+# this file. If converting a standalone test to run with the harness,
+# as long as all files are in the same directory and it returns 0 for
+# pass, you should be able to cut and paste it into here and it will
+# run with the test harness.
+
+# This is an example of running something -- test
+# The stuff below catches the exit status of test then passes or fails
+# this shell test as appropriate ( 0 status is considered a pass here )
+
+echo "Create TestApp.jar..."
+
+if [ -f TestApp.jar ] ; then
+ rm -f TestApp.jar
+fi
+
+${TESTJAVA}/bin/jar -cvf TestApp.jar -C ${TESTCLASSES} testapp
+
+if [ $? -ne "0" ] ; then
+ fail "Failed to create TestApp.jar"
+fi
+
+echo "Create Test.jar..."
+if [ -f Test.jar ] ; then
+ rm -f Test.jar
+fi
+
+${TESTJAVA}/bin/jar -cvf Test.jar -C ${TESTCLASSES} test
+
+if [ $? -ne 0 ] ; then
+ fail "Failed to create Test.jar"
+fi
+
+# Prepare temp dir for cahce files
+mkdir ./tmp
+if [ $? -ne 0 ] ; then
+ fail "Unable to create temp directory."
+fi
+
+# Verify that all classoladers are destroyed
+${TESTJAVA}/bin/java -cp Test.jar test.Main
+if [ $? -ne 0 ] ; then
+ fail "Test FAILED: some classloaders weren't destroyed."
+fi
+
+
+# Verify that ImageIO shutdown hook works correcly
+${TESTJAVA}/bin/java -cp Test.jar -DforgetSomeStreams=true test.Main
+if [ $? -ne 0 ] ; then
+ fail "Test FAILED: some classloaders weren't destroyed of shutdown hook failed."
+fi
+
+# sanity check: verify that all cache files were deleted
+cache_files=`ls tmp`
+
+if [ "x${cache_files}" != "x" ] ; then
+ echo "WARNING: some cache files was not deleted: ${cache_files}"
+fi
+
+echo "Test done."
+
+status=$?
+
+if [ $status -eq "0" ] ; then
+ pass ""
+else
+ fail "Test failed due to test plugin was not found."
+fi
+
diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/test/Main.java b/jdk/test/javax/imageio/stream/StreamCloserLeak/test/Main.java
new file mode 100644
index 00000000000..b87299967c6
--- /dev/null
+++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/test/Main.java
@@ -0,0 +1,284 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package test;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
+import javax.imageio.stream.ImageInputStream;
+import sun.awt.AppContext;
+import sun.awt.SunToolkit;
+
+public class Main {
+
+ private static ThreadGroup appsThreadGroup;
+
+ private static WeakHashMap refs =
+ new WeakHashMap();
+
+ /** Collection to simulate forgrotten streams **/
+ private static HashMap strongRefs =
+ new HashMap();
+
+ private static ConcurrentLinkedQueue problems =
+ new ConcurrentLinkedQueue();
+
+ private static AppContext mainAppContext = null;
+
+ private static CountDownLatch doneSignal;
+
+ private static final int gcTimeout =
+ Integer.getInteger("gcTimeout", 10).intValue();
+
+ private static boolean forgetSomeStreams =
+ Boolean.getBoolean("forgetSomeStreams");
+
+ public static void main(String[] args) throws IOException {
+ mainAppContext = SunToolkit.createNewAppContext();
+ System.out.println("Current context class loader: " +
+ Thread.currentThread().getContextClassLoader());
+
+ appsThreadGroup = new ThreadGroup("MyAppsThreadGroup");
+
+ File jar = new File("TestApp.jar");
+ if (!jar.exists()) {
+ System.out.println(jar.getAbsolutePath() + " was not found!\n" +
+ "Please install the jar with test application correctly!");
+ throw new RuntimeException("Test failed: no TestApp.jar");
+ }
+
+ URL[] urls = new URL[]{jar.toURL()};
+
+ int numApps = Integer.getInteger("numApps", 20).intValue();
+
+ doneSignal = new CountDownLatch(numApps);
+ int cnt = 0;
+ while (cnt++ < numApps) {
+ launch(urls, "testapp.Main", "launch");
+
+ checkErrors();
+ }
+
+ System.out.println("Wait for apps completion....");
+
+ try {
+ doneSignal.await();
+ } catch (InterruptedException e) {
+ }
+
+ System.out.println("All apps finished.");
+
+ System.gc();
+
+ System.out.flush();
+
+ System.out.println("Enumerate strong refs:");
+ for (String is : strongRefs.keySet()) {
+ System.out.println("-> " + is);
+ }
+
+ System.out.println("=======================");
+
+ // wait few seconds
+ waitAndGC(gcTimeout);
+
+ doneSignal = new CountDownLatch(1);
+
+ Runnable workaround = new Runnable() {
+
+ public void run() {
+ AppContext ctx = null;
+ try {
+ ctx = SunToolkit.createNewAppContext();
+ } catch (Throwable e) {
+ // ignore...
+ } finally {
+ doneSignal.countDown();
+ }
+ }
+ };
+
+ Thread wt = new Thread(appsThreadGroup, workaround, "Workaround");
+ wt.setContextClassLoader(new MyClassLoader(urls, "workaround"));
+ wt.start();
+ wt = null;
+ workaround = null;
+
+ System.out.println("Wait for workaround completion...");
+
+ try {
+ doneSignal.await();
+ } catch (InterruptedException e) {
+ }
+
+ // give a chance to GC
+ waitAndGC(gcTimeout);
+
+ if (!refs.isEmpty()) {
+ System.out.println("Classloaders still alive:");
+
+ for (MyClassLoader l : refs.keySet()) {
+ String val = refs.get(l);
+
+ if (val == null) {
+ throw new RuntimeException("Test FAILED: Invalid classloader name");
+ }
+ System.out.println("->" + val + (strongRefs.get(val) != null ?
+ " (has strong ref)" : ""));
+ if (strongRefs.get(val) == null) {
+ throw new RuntimeException("Test FAILED: exta class loader is detected! ");
+ }
+ }
+ } else {
+ System.out.println("No alive class loaders!!");
+ }
+ System.out.println("Test PASSED.");
+ }
+
+ private static void waitAndGC(int sec) {
+ int cnt = sec;
+ System.out.print("Wait ");
+ while (cnt-- > 0) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ // do GC every 3 seconds
+ if (cnt % 3 == 2) {
+ System.gc();
+ System.out.print("+");
+ } else {
+ System.out.print(".");
+ }
+ checkErrors();
+ }
+ System.out.println("");
+ }
+
+ private static void checkErrors() {
+ while (!problems.isEmpty()) {
+ Throwable theProblem = problems.poll();
+ System.out.println("Test FAILED!");
+ do {
+ theProblem.printStackTrace(System.out);
+ theProblem = theProblem.getCause();
+ } while (theProblem != null);
+ throw new RuntimeException("Test FAILED");
+ }
+ }
+ static int counter = 0;
+
+ private static void launch(URL[] urls, final String className,
+ final String methodName)
+ {
+ final String uniqClassName = "testapp/Uniq" + counter;
+ final boolean saveStrongRef = forgetSomeStreams ? (counter % 5 == 4) : false;
+
+ System.out.printf("%s: launch the app\n", uniqClassName);
+ Runnable launchIt = new Runnable() {
+ public void run() {
+ AppContext ctx = SunToolkit.createNewAppContext();
+
+ try {
+ Class appMain =
+ ctx.getContextClassLoader().loadClass(className);
+ Method launch = appMain.getDeclaredMethod(methodName,
+ strongRefs.getClass());
+
+ Constructor c = appMain.getConstructor(String.class,
+ problems.getClass());
+
+ Object o = c.newInstance(uniqClassName, problems);
+
+ if (saveStrongRef) {
+ System.out.printf("%s: force strong ref\n",
+ uniqClassName);
+ launch.invoke(o, strongRefs);
+ } else {
+ HashMap empty = null;
+ launch.invoke(o, empty);
+ }
+
+ ctx = null;
+ } catch (Throwable e) {
+ problems.add(e);
+ } finally {
+ doneSignal.countDown();
+ }
+ }
+ };
+
+ MyClassLoader appClassLoader = new MyClassLoader(urls, uniqClassName);
+
+ refs.put(appClassLoader, uniqClassName);
+
+ Thread appThread = new Thread(appsThreadGroup, launchIt,
+ "AppThread" + counter++);
+ appThread.setContextClassLoader(appClassLoader);
+
+ appThread.start();
+ launchIt = null;
+ appThread = null;
+ appClassLoader = null;
+ }
+
+ private static class MyClassLoader extends URLClassLoader {
+
+ private static boolean verbose =
+ Boolean.getBoolean("verboseClassLoading");
+ private String uniqClassName;
+
+ public MyClassLoader(URL[] urls, String uniq) {
+ super(urls);
+
+ uniqClassName = uniq;
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ if (verbose) {
+ System.out.printf("%s: load class %s\n", uniqClassName, name);
+ }
+ if (uniqClassName.equals(name)) {
+ return Object.class;
+ }
+ return super.loadClass(name);
+ }
+
+ public String toString() {
+ return "MyClassLoader(" + uniqClassName + ")";
+ }
+ }
+}
diff --git a/jdk/test/javax/imageio/stream/StreamCloserLeak/testapp/Main.java b/jdk/test/javax/imageio/stream/StreamCloserLeak/testapp/Main.java
new file mode 100644
index 00000000000..3c4bb5ec3ff
--- /dev/null
+++ b/jdk/test/javax/imageio/stream/StreamCloserLeak/testapp/Main.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package testapp;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import javax.imageio.stream.FileCacheImageInputStream;
+import javax.imageio.stream.ImageInputStream;
+
+public class Main {
+
+ public static void main(String[] args) {
+ Main o = new Main("testapp.some.class", null);
+ o.launch(null);
+ }
+
+ private final String uniqClassName;
+ private final ConcurrentLinkedQueue problems;
+
+ public Main(String uniq, ConcurrentLinkedQueue p) {
+ uniqClassName = uniq;
+ problems = p;
+ }
+
+ public void launch(HashMap refs) {
+ System.out.printf("%s: current context class loader: %s\n",
+ uniqClassName,
+ Thread.currentThread().getContextClassLoader());
+ try {
+ byte[] data = new byte[1024];
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ MyImageInputStream iis = new MyImageInputStream(bais,
+ uniqClassName,
+ problems);
+ if (refs != null) {
+ System.out.printf("%s: added to strong store\n",
+ uniqClassName);
+ refs.put(uniqClassName, iis);
+ }
+ iis.read();
+ //leave stream open : let's shutdown hook work!
+ } catch (IOException e) {
+ problems.add(e);
+ }
+ }
+
+ private static class MyImageInputStream extends FileCacheImageInputStream {
+ private final String uniqClassName;
+ private ConcurrentLinkedQueue problems;
+ public MyImageInputStream(InputStream is, String uniq,
+ ConcurrentLinkedQueue p) throws IOException
+ {
+ super(is, new File("tmp"));
+ uniqClassName = uniq;
+ problems = p;
+ }
+
+ @Override
+ public void close() throws IOException {
+ Test t = new Test();
+ try {
+ t.doTest(uniqClassName);
+ } catch (Throwable e) {
+ problems.add(e);
+ }
+
+ super.close();
+
+ problems = null;
+ }
+ }
+}
+
+class Test {
+ public void doTest(String uniqClassName) throws ClassNotFoundException {
+ System.out.printf("%s: Current thread: %s\n", uniqClassName,
+ Thread.currentThread());
+
+ ClassLoader thisCL = this.getClass().getClassLoader();
+ Class uniq = thisCL.loadClass(uniqClassName);
+
+ System.out.printf("%s: test is done!\n",uniqClassName);
+ }
+}
From 8c2a336349c8ff82c6ab4484a68ca4b7dc4e11e1 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 23 Jan 2009 17:43:29 +0300
Subject: [PATCH 011/283] 6795544: GIFImageWriter does not write the subImage
of BufferedImage to a file correctly
Reviewed-by: igor, prr
---
.../imageio/plugins/gif/GIFImageWriter.java | 16 +-
.../plugins/gif/EncodeSubImageTest.java | 161 ++++++++++++++++++
2 files changed, 175 insertions(+), 2 deletions(-)
create mode 100644 jdk/test/javax/imageio/plugins/gif/EncodeSubImageTest.java
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
index 4c7903bfe84..89f735d8793 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
@@ -55,6 +55,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sun.imageio.plugins.common.LZWCompressor;
import com.sun.imageio.plugins.common.PaletteBuilder;
+import sun.awt.image.ByteComponentRaster;
public class GIFImageWriter extends ImageWriter {
private static final boolean DEBUG = false; // XXX false for release!
@@ -905,10 +906,18 @@ public class GIFImageWriter extends ImageWriter {
LZWCompressor compressor =
new LZWCompressor(stream, initCodeSize, false);
+ /* At this moment we know that input image is indexed image.
+ * We can directly copy data iff:
+ * - no subsampling required (periodX = 1, periodY = 0)
+ * - we can access data directly (image is non-tiled,
+ * i.e. image data are in single block)
+ * - we can calculate offset in data buffer (next 3 lines)
+ */
boolean isOptimizedCase =
periodX == 1 && periodY == 1 &&
- sampleModel instanceof ComponentSampleModel &&
image.getNumXTiles() == 1 && image.getNumYTiles() == 1 &&
+ sampleModel instanceof ComponentSampleModel &&
+ image.getTile(0, 0) instanceof ByteComponentRaster &&
image.getTile(0, 0).getDataBuffer() instanceof DataBufferByte;
int numRowsWritten = 0;
@@ -921,11 +930,14 @@ public class GIFImageWriter extends ImageWriter {
if (DEBUG) System.out.println("Writing interlaced");
if (isOptimizedCase) {
- Raster tile = image.getTile(0, 0);
+ ByteComponentRaster tile =
+ (ByteComponentRaster)image.getTile(0, 0);
byte[] data = ((DataBufferByte)tile.getDataBuffer()).getData();
ComponentSampleModel csm =
(ComponentSampleModel)tile.getSampleModel();
int offset = csm.getOffset(sourceXOffset, sourceYOffset, 0);
+ // take into account the raster data offset
+ offset += tile.getDataOffset(0);
int lineStride = csm.getScanlineStride();
writeRowsOpt(data, offset, lineStride, compressor,
diff --git a/jdk/test/javax/imageio/plugins/gif/EncodeSubImageTest.java b/jdk/test/javax/imageio/plugins/gif/EncodeSubImageTest.java
new file mode 100644
index 00000000000..407242161c2
--- /dev/null
+++ b/jdk/test/javax/imageio/plugins/gif/EncodeSubImageTest.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6795544
+ *
+ * @summary Test verifes that Image I/O gif writer correctly handles
+ * buffered images based on translated reasters (typically
+ * produced by getSubImage() method).
+ *
+ * @run main EncodeSubImageTest gif
+ */
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.io.File;
+import java.io.IOException;
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+
+public class EncodeSubImageTest {
+ private static String format = "gif";
+ private static ImageWriter writer;
+ private static String file_suffix;
+ private static final int subSampleX = 2;
+ private static final int subSampleY = 2;
+
+ public static void main(String[] args) throws IOException {
+ if (args.length > 0) {
+ format = args[0];
+ }
+
+ writer = ImageIO.getImageWritersByFormatName(format).next();
+
+ file_suffix =writer.getOriginatingProvider().getFileSuffixes()[0];
+
+ BufferedImage src = createTestImage();
+ EncodeSubImageTest m1 = new EncodeSubImageTest(src);
+ m1.doTest("test_src");
+
+ BufferedImage sub = src.getSubimage(subImageOffset, subImageOffset,
+ src.getWidth() - 2 * subImageOffset,
+ src.getHeight() - 2 * subImageOffset);
+ EncodeSubImageTest m2 = new EncodeSubImageTest(sub);
+ m2.doTest("test_sub");
+ }
+
+ BufferedImage img;
+
+ public EncodeSubImageTest(BufferedImage img) {
+ this.img = img;
+ }
+
+ public void doTest(String prefix) throws IOException {
+ System.out.println(prefix);
+ File f = new File(prefix + file_suffix);
+ write(f, false);
+ verify(f, false);
+
+ System.out.println(prefix + "_subsampled");
+ f = new File(prefix + "_subsampled");
+ write(f, true);
+ verify(f, true);
+
+ System.out.println(prefix + ": Test PASSED.");
+ }
+
+ private static final int subImageOffset = 10;
+
+ private void verify(File f, boolean isSubsampled) {
+ BufferedImage dst = null;
+ try {
+ dst = ImageIO.read(f);
+ } catch (IOException e) {
+ throw new RuntimeException("Test FAILED: can't readin test image " +
+ f.getAbsolutePath(), e);
+ }
+ if (dst == null) {
+ throw new RuntimeException("Test FAILED: no dst image available.");
+ }
+
+ checkPixel(dst, 0, 0, isSubsampled);
+
+ checkPixel(dst, img.getWidth() / 2, img.getHeight() / 2, isSubsampled);
+ }
+
+ private void checkPixel(BufferedImage dst, int x, int y,
+ boolean isSubsampled)
+ {
+ int dx = isSubsampled ? x / subSampleX : x;
+ int dy = isSubsampled ? y / subSampleY : y;
+ int src_rgb = img.getRGB(x, y);
+ System.out.printf("src_rgb: %x\n", src_rgb);
+
+ int dst_rgb = dst.getRGB(dx, dy);
+ System.out.printf("dst_rgb: %x\n", dst_rgb);
+
+ if (src_rgb != dst_rgb) {
+ throw new RuntimeException("Test FAILED: invalid color in dst");
+ }
+ }
+
+ private static BufferedImage createTestImage() {
+ int w = 100;
+ int h = 100;
+
+ BufferedImage src = new BufferedImage(w, h,
+ BufferedImage.TYPE_BYTE_INDEXED);
+ Graphics g = src.createGraphics();
+ g.setColor(Color.red);
+ g.fillRect(0, 0, w, h);
+ g.setColor(Color.green);
+ g.fillRect(subImageOffset, subImageOffset,
+ w - 2 * subImageOffset, h - 2* subImageOffset);
+ g.setColor(Color.blue);
+ g.fillRect(2 * subImageOffset, 2 * subImageOffset,
+ w - 4 * subImageOffset, h - 4 * subImageOffset);
+ g.dispose();
+
+ return src;
+ }
+
+ private void write(File f, boolean subsample) throws IOException {
+ ImageOutputStream ios = ImageIO.createImageOutputStream(f);
+
+ writer.setOutput(ios);
+ ImageWriteParam p = writer.getDefaultWriteParam();
+ if (subsample) {
+ p.setSourceSubsampling(subSampleX, subSampleY, 0, 0);
+ }
+ writer.write(null, new IIOImage(img, null, null), p);
+ ios.close();
+ writer.reset();
+ }
+}
From 2726f2a3621dd2562d4fb660b4c3d376c65027aa Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 23 Jan 2009 21:14:31 +0300
Subject: [PATCH 012/283] 6793818: JpegImageReader is too greedy creating color
profiles
Reviewed-by: igor, prr
---
.../classes/java/awt/color/ICC_Profile.java | 78 +++++++++++--------
.../sun/java2d/cmm/ProfileActivator.java | 3 +-
.../sun/java2d/cmm/ProfileDeferralMgr.java | 27 ++++++-
3 files changed, 71 insertions(+), 37 deletions(-)
diff --git a/jdk/src/share/classes/java/awt/color/ICC_Profile.java b/jdk/src/share/classes/java/awt/color/ICC_Profile.java
index 3ef8d437bb4..705d2560e1f 100644
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java
@@ -737,7 +737,7 @@ public class ICC_Profile implements Serializable {
ICC_Profile(ProfileDeferralInfo pdi) {
this.deferralInfo = pdi;
this.profileActivator = new ProfileActivator() {
- public void activate() {
+ public void activate() throws ProfileDataException {
activateDeferredProfile();
}
};
@@ -830,20 +830,16 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_sRGB:
synchronized(ICC_Profile.class) {
if (sRGBprofile == null) {
- try {
- /*
- * Deferral is only used for standard profiles.
- * Enabling the appropriate access privileges is handled
- * at a lower level.
- */
- sRGBprofile = getDeferredInstance(
- new ProfileDeferralInfo("sRGB.pf",
- ColorSpace.TYPE_RGB,
- 3, CLASS_DISPLAY));
- } catch (IOException e) {
- throw new IllegalArgumentException(
- "Can't load standard profile: sRGB.pf");
- }
+ /*
+ * Deferral is only used for standard profiles.
+ * Enabling the appropriate access privileges is handled
+ * at a lower level.
+ */
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("sRGB.pf",
+ ColorSpace.TYPE_RGB, 3,
+ CLASS_DISPLAY);
+ sRGBprofile = getDeferredInstance(pInfo);
}
thisProfile = sRGBprofile;
}
@@ -853,7 +849,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_CIEXYZ:
synchronized(ICC_Profile.class) {
if (XYZprofile == null) {
- XYZprofile = getStandardProfile("CIEXYZ.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("CIEXYZ.pf",
+ ColorSpace.TYPE_XYZ, 3,
+ CLASS_DISPLAY);
+ XYZprofile = getDeferredInstance(pInfo);
}
thisProfile = XYZprofile;
}
@@ -863,7 +863,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_PYCC:
synchronized(ICC_Profile.class) {
if (PYCCprofile == null) {
- PYCCprofile = getStandardProfile("PYCC.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("PYCC.pf",
+ ColorSpace.TYPE_3CLR, 3,
+ CLASS_DISPLAY);
+ PYCCprofile = getDeferredInstance(pInfo);
}
thisProfile = PYCCprofile;
}
@@ -873,7 +877,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_GRAY:
synchronized(ICC_Profile.class) {
if (GRAYprofile == null) {
- GRAYprofile = getStandardProfile("GRAY.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("GRAY.pf",
+ ColorSpace.TYPE_GRAY, 1,
+ CLASS_DISPLAY);
+ GRAYprofile = getDeferredInstance(pInfo);
}
thisProfile = GRAYprofile;
}
@@ -883,7 +891,11 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_LINEAR_RGB:
synchronized(ICC_Profile.class) {
if (LINEAR_RGBprofile == null) {
- LINEAR_RGBprofile = getStandardProfile("LINEAR_RGB.pf");
+ ProfileDeferralInfo pInfo =
+ new ProfileDeferralInfo("LINEAR_RGB.pf",
+ ColorSpace.TYPE_RGB, 3,
+ CLASS_DISPLAY);
+ LINEAR_RGBprofile = getDeferredInstance(pInfo);
}
thisProfile = LINEAR_RGBprofile;
}
@@ -1047,9 +1059,7 @@ public class ICC_Profile implements Serializable {
* code will take care of access privileges.
* @see activateDeferredProfile()
*/
- static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi)
- throws IOException {
-
+ static ICC_Profile getDeferredInstance(ProfileDeferralInfo pdi) {
if (!ProfileDeferralMgr.deferring) {
return getStandardProfile(pdi.filename);
}
@@ -1063,33 +1073,37 @@ public class ICC_Profile implements Serializable {
}
- void activateDeferredProfile() {
- byte profileData[];
- FileInputStream fis;
- String fileName = deferralInfo.filename;
+ void activateDeferredProfile() throws ProfileDataException {
+ byte profileData[];
+ FileInputStream fis;
+ String fileName = deferralInfo.filename;
profileActivator = null;
deferralInfo = null;
if ((fis = openProfile(fileName)) == null) {
- throw new IllegalArgumentException("Cannot open file " + fileName);
+ throw new ProfileDataException("Cannot open file " + fileName);
}
try {
profileData = getProfileDataFromStream(fis);
fis.close(); /* close the file */
}
catch (IOException e) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
- fileName);
+ ProfileDataException pde = new
+ ProfileDataException("Invalid ICC Profile Data" + fileName);
+ pde.initCause(e);
+ throw pde;
}
if (profileData == null) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
+ throw new ProfileDataException("Invalid ICC Profile Data" +
fileName);
}
try {
ID = CMSManager.getModule().loadProfile(profileData);
} catch (CMMException c) {
- throw new IllegalArgumentException("Invalid ICC Profile Data" +
- fileName);
+ ProfileDataException pde = new
+ ProfileDataException("Invalid ICC Profile Data" + fileName);
+ pde.initCause(c);
+ throw pde;
}
}
diff --git a/jdk/src/share/classes/sun/java2d/cmm/ProfileActivator.java b/jdk/src/share/classes/sun/java2d/cmm/ProfileActivator.java
index 32c4e477fb9..f5a28f84232 100644
--- a/jdk/src/share/classes/sun/java2d/cmm/ProfileActivator.java
+++ b/jdk/src/share/classes/sun/java2d/cmm/ProfileActivator.java
@@ -25,6 +25,7 @@
package sun.java2d.cmm;
+import java.awt.color.ProfileDataException;
/**
* An interface to allow the ProfileDeferralMgr to activate a
@@ -35,6 +36,6 @@ public interface ProfileActivator {
/**
* Activate a previously deferred ICC_Profile object.
*/
- public void activate();
+ public void activate() throws ProfileDataException;
}
diff --git a/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java b/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java
index 41804c3fd9b..116f339da0a 100644
--- a/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java
+++ b/jdk/src/share/classes/sun/java2d/cmm/ProfileDeferralMgr.java
@@ -25,6 +25,7 @@
package sun.java2d.cmm;
+import java.awt.color.ProfileDataException;
import java.util.Vector;
@@ -39,7 +40,7 @@ import java.util.Vector;
public class ProfileDeferralMgr {
public static boolean deferring = true;
- private static Vector aVector;
+ private static Vector aVector;
/**
* Records a ProfileActivator object whose activate method will
@@ -51,7 +52,7 @@ public class ProfileDeferralMgr {
return;
}
if (aVector == null) {
- aVector = new Vector(3, 3);
+ aVector = new Vector(3, 3);
}
aVector.addElement(pa);
return;
@@ -89,8 +90,26 @@ public class ProfileDeferralMgr {
return;
}
n = aVector.size();
- for (i = 0; i < n; i++) {
- ((ProfileActivator) aVector.get(i)).activate();
+ for (ProfileActivator pa : aVector) {
+ try {
+ pa.activate();
+ } catch (ProfileDataException e) {
+ /*
+ * Ignore profile activation error for now:
+ * such exception is pssible due to absence
+ * or corruption of standard color profile.
+ * As for now we expect all profiles should
+ * be shiped with jre and presence of this
+ * exception is indication of some configuration
+ * problem in jre installation.
+ *
+ * NB: we still are greedy loading deferred profiles
+ * and load them all if any of them is needed.
+ * Therefore broken profile (if any) might be never used.
+ * If there will be attempt to use broken profile then
+ * it will result in CMMException.
+ */
+ }
}
aVector.removeAllElements();
aVector = null;
From 55076b2558a836ff91b27c6cee714f39cae75878 Mon Sep 17 00:00:00 2001
From: Red Hat
Date: Wed, 28 Jan 2009 09:38:55 -0800
Subject: [PATCH 013/283] 6793344: BasicStroke's first element dash pattern is
not a dash
Reviewed-by: igor, flar
---
.../classes/sun/java2d/pisces/Dasher.java | 2 +-
jdk/test/sun/pisces/DashStrokeTest.java | 86 +++++++++++++++++++
2 files changed, 87 insertions(+), 1 deletion(-)
create mode 100644 jdk/test/sun/pisces/DashStrokeTest.java
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Dasher.java b/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
index 81c92f44a60..99215e01b8e 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
@@ -120,7 +120,7 @@ public class Dasher extends LineSink {
// Normalize so 0 <= phase < dash[0]
int idx = 0;
- dashOn = false;
+ dashOn = true;
int d;
while (phase >= (d = dash[idx])) {
phase -= d;
diff --git a/jdk/test/sun/pisces/DashStrokeTest.java b/jdk/test/sun/pisces/DashStrokeTest.java
new file mode 100644
index 00000000000..f77acbeacfe
--- /dev/null
+++ b/jdk/test/sun/pisces/DashStrokeTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ * @summary verify that first element is a dash
+ * @bug 6793344
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.WindowConstants;
+
+public class DashStrokeTest extends Component {
+
+ static BufferedImage bi;
+ static boolean printed = false;
+
+ public Dimension getPreferredSize() {
+ return new Dimension(200,200);
+ }
+
+ public static void drawGui() {
+ bi = new BufferedImage(200, 20, BufferedImage.TYPE_INT_RGB);
+ Graphics2D g2d = bi.createGraphics();
+ BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
+ BasicStroke.JOIN_ROUND, 1.0f, new float[] { 0.0f, 200 },
+ 1.0f);
+
+ g2d.setStroke(dashStroke);
+ g2d.setColor(Color.RED);
+ g2d.drawLine(5,10, 100,10);
+ printed =true;
+ }
+
+ public static void main(String[] args) {
+ try {
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ @Override
+ public void run() {
+ drawGui();
+ }
+
+ });
+ } catch (Exception e) {
+ }
+
+ if (printed) {
+ checkBI(bi, Color.RED);
+ }
+ }
+
+ static void checkBI(BufferedImage bi, Color badColor) {
+ int badrgb = badColor.getRGB();
+
+ int col = bi.getRGB(6, 9);
+ if (col == badrgb) {
+ throw new RuntimeException("A pixel was turned on. ");
+ }
+ }
+}
+
From 2a2bbe287903c73e0de793d2f1c6a2bb88125151 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Thu, 29 Jan 2009 13:19:34 +0300
Subject: [PATCH 014/283] 6631559: Registration of ImageIO plugins should not
cause loading of jpeg.dlli and cmm.dll
Reviewed-by: igor, prr
---
.../plugins/jpeg/JFIFMarkerSegment.java | 2 +-
.../com/sun/imageio/plugins/jpeg/JPEG.java | 25 +-
.../imageio/plugins/jpeg/JPEGImageReader.java | 26 +-
.../plugins/jpeg/JPEGImageReaderSpi.java | 22 --
.../imageio/plugins/jpeg/JPEGImageWriter.java | 10 +-
.../plugins/jpeg/JPEGImageWriterSpi.java | 19 --
.../imageio/plugins/jpeg/JPEGMetadata.java | 2 +-
.../javax/imageio/ImageTypeSpecifier.java | 247 +++++++++---------
8 files changed, 167 insertions(+), 186 deletions(-)
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java
index 883bd1a7447..d59a8885c9b 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java
@@ -1003,7 +1003,7 @@ class JFIFMarkerSegment extends MarkerSegment {
3,
new int [] {0, 1, 2},
null);
- ColorModel cm = new ComponentColorModel(JPEG.sRGB,
+ ColorModel cm = new ComponentColorModel(JPEG.JCS.sRGB,
false,
false,
ColorModel.OPAQUE,
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEG.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEG.java
index b16669bc089..3ed5c5083c3 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEG.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEG.java
@@ -208,15 +208,24 @@ public class JPEG {
public static final int [] bOffsRGB = { 2, 1, 0 };
- protected static final ColorSpace sRGB =
- ColorSpace.getInstance(ColorSpace.CS_sRGB);
- protected static ColorSpace YCC = null; // Can't be final
+ /* These are kept in the inner class to avoid static initialization
+ * of the CMM class until someone actually needs it.
+ * (e.g. do not init CMM on the request for jpeg mime types)
+ */
+ public static class JCS {
+ public static final ColorSpace sRGB =
+ ColorSpace.getInstance(ColorSpace.CS_sRGB);
+ public static final ColorSpace YCC;
- static {
- try {
- YCC = ColorSpace.getInstance(ColorSpace.CS_PYCC);
- } catch (IllegalArgumentException e) {
- // PYCC.pf may not always be installed
+ static {
+ ColorSpace cs = null;
+ try {
+ cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
+ } catch (IllegalArgumentException e) {
+ // PYCC.pf may not always be installed
+ } finally {
+ YCC = cs;
+ }
}
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
index 48afd2f354c..faf8261544c 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
@@ -228,31 +228,31 @@ public class JPEGImageReader extends ImageReader {
(BufferedImage.TYPE_BYTE_GRAY);
defaultTypes[JPEG.JCS_RGB] =
ImageTypeSpecifier.createInterleaved
- (JPEG.sRGB,
+ (JPEG.JCS.sRGB,
JPEG.bOffsRGB,
DataBuffer.TYPE_BYTE,
false,
false);
defaultTypes[JPEG.JCS_RGBA] =
ImageTypeSpecifier.createPacked
- (JPEG.sRGB,
+ (JPEG.JCS.sRGB,
0xff000000,
0x00ff0000,
0x0000ff00,
0x000000ff,
DataBuffer.TYPE_INT,
false);
- if (JPEG.YCC != null) {
+ if (JPEG.JCS.YCC != null) {
defaultTypes[JPEG.JCS_YCC] =
ImageTypeSpecifier.createInterleaved
- (JPEG.YCC,
+ (JPEG.JCS.YCC,
JPEG.bandOffsets[2],
DataBuffer.TYPE_BYTE,
false,
false);
defaultTypes[JPEG.JCS_YCCA] =
ImageTypeSpecifier.createInterleaved
- (JPEG.YCC,
+ (JPEG.JCS.YCC,
JPEG.bandOffsets[3],
DataBuffer.TYPE_BYTE,
true,
@@ -774,7 +774,7 @@ public class JPEGImageReader extends ImageReader {
case JPEG.JCS_RGB:
list.add(raw);
list.add(getImageType(JPEG.JCS_GRAYSCALE));
- if (JPEG.YCC != null) {
+ if (JPEG.JCS.YCC != null) {
list.add(getImageType(JPEG.JCS_YCC));
}
break;
@@ -811,7 +811,7 @@ public class JPEGImageReader extends ImageReader {
}
list.add(getImageType(JPEG.JCS_GRAYSCALE));
- if (JPEG.YCC != null) { // Might be null if PYCC.pf not installed
+ if (JPEG.JCS.YCC != null) { // Might be null if PYCC.pf not installed
list.add(getImageType(JPEG.JCS_YCC));
}
break;
@@ -893,7 +893,7 @@ public class JPEGImageReader extends ImageReader {
(!cs.isCS_sRGB()) &&
(cm.getNumComponents() == numComponents)) {
// Target isn't sRGB, so convert from sRGB to the target
- convert = new ColorConvertOp(JPEG.sRGB, cs, null);
+ convert = new ColorConvertOp(JPEG.JCS.sRGB, cs, null);
} else if (csType != ColorSpace.TYPE_RGB) {
throw new IIOException("Incompatible color conversion");
}
@@ -906,18 +906,18 @@ public class JPEGImageReader extends ImageReader {
}
break;
case JPEG.JCS_YCC:
- if (JPEG.YCC == null) { // We can't do YCC at all
+ if (JPEG.JCS.YCC == null) { // We can't do YCC at all
throw new IIOException("Incompatible color conversion");
}
- if ((cs != JPEG.YCC) &&
+ if ((cs != JPEG.JCS.YCC) &&
(cm.getNumComponents() == numComponents)) {
- convert = new ColorConvertOp(JPEG.YCC, cs, null);
+ convert = new ColorConvertOp(JPEG.JCS.YCC, cs, null);
}
break;
case JPEG.JCS_YCCA:
// No conversions available; image must be YCCA
- if ((JPEG.YCC == null) || // We can't do YCC at all
- (cs != JPEG.YCC) ||
+ if ((JPEG.JCS.YCC == null) || // We can't do YCC at all
+ (cs != JPEG.JCS.YCC) ||
(cm.getNumComponents() != numComponents)) {
throw new IIOException("Incompatible color conversion");
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java
index 5bed06158af..13327e3ea9c 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReaderSpi.java
@@ -39,8 +39,6 @@ public class JPEGImageReaderSpi extends ImageReaderSpi {
private static String [] writerSpiNames =
{"com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi"};
- private boolean registered = false;
-
public JPEGImageReaderSpi() {
super(JPEG.vendor,
JPEG.version,
@@ -61,26 +59,6 @@ public class JPEGImageReaderSpi extends ImageReaderSpi {
);
}
- public void onRegistration(ServiceRegistry registry,
- Class> category) {
- if (registered) {
- return;
- }
- try {
- java.security.AccessController.doPrivileged(
- new sun.security.action.LoadLibraryAction("jpeg"));
- // Stuff it all into one lib for first pass
- //java.security.AccessController.doPrivileged(
- //new sun.security.action.LoadLibraryAction("imageioIJG"));
- } catch (Throwable e) { // Fail on any Throwable
- // if it can't be loaded, deregister and return
- registry.deregisterServiceProvider(this);
- return;
- }
-
- registered = true;
- }
-
public String getDescription(Locale locale) {
return "Standard JPEG Image Reader";
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
index 0fbe8f33945..9c585047faa 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
@@ -812,13 +812,13 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
if (!alpha) {
if (jfif != null) {
convertTosRGB = true;
convertOp =
new ColorConvertOp(cs,
- JPEG.sRGB,
+ JPEG.JCS.sRGB,
null);
outCsType = JPEG.JCS_YCbCr;
} else if (adobe != null) {
@@ -1494,7 +1494,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
@@ -1533,7 +1533,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
@@ -1579,7 +1579,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java
index 936c65c544f..717b4360794 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriterSpi.java
@@ -42,8 +42,6 @@ public class JPEGImageWriterSpi extends ImageWriterSpi {
private static String [] readerSpiNames =
{"com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi"};
- private boolean registered = false;
-
public JPEGImageWriterSpi() {
super(JPEG.vendor,
JPEG.version,
@@ -68,23 +66,6 @@ public class JPEGImageWriterSpi extends ImageWriterSpi {
return "Standard JPEG Image Writer";
}
- public void onRegistration(ServiceRegistry registry,
- Class> category) {
- if (registered) {
- return;
- }
- try {
- java.security.AccessController.doPrivileged(
- new sun.security.action.LoadLibraryAction("jpeg"));
- } catch (Throwable e) { // Fail on any Throwable
- // if it can't be loaded, deregister and return
- registry.deregisterServiceProvider(this);
- return;
- }
-
- registered = true;
- }
-
public boolean isFormatLossless() {
return false;
}
diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
index c84003c9f22..044f7d632f6 100644
--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGMetadata.java
@@ -490,7 +490,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
}
break;
case ColorSpace.TYPE_3CLR:
- if (cs == JPEG.YCC) {
+ if (cs == JPEG.JCS.YCC) {
wantJFIF = false;
componentIDs[0] = (byte) 'Y';
componentIDs[1] = (byte) 'C';
diff --git a/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java b/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java
index 4ba0c1062d4..184bf8870cc 100644
--- a/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java
+++ b/jdk/src/share/classes/javax/imageio/ImageTypeSpecifier.java
@@ -67,126 +67,13 @@ public class ImageTypeSpecifier {
* BufferedImage
types.
*/
private static ImageTypeSpecifier[] BISpecifier;
-
+ private static ColorSpace sRGB;
// Initialize the standard specifiers
static {
- ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
+ sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
BISpecifier =
new ImageTypeSpecifier[BufferedImage.TYPE_BYTE_INDEXED + 1];
-
- BISpecifier[BufferedImage.TYPE_CUSTOM] = null;
-
- BISpecifier[BufferedImage.TYPE_INT_RGB] =
- createPacked(sRGB,
- 0x00ff0000,
- 0x0000ff00,
- 0x000000ff,
- 0x0,
- DataBuffer.TYPE_INT,
- false);
-
- BISpecifier[BufferedImage.TYPE_INT_ARGB] =
- createPacked(sRGB,
- 0x00ff0000,
- 0x0000ff00,
- 0x000000ff,
- 0xff000000,
- DataBuffer.TYPE_INT,
- false);
-
- BISpecifier[BufferedImage.TYPE_INT_ARGB_PRE] =
- createPacked(sRGB,
- 0x00ff0000,
- 0x0000ff00,
- 0x000000ff,
- 0xff000000,
- DataBuffer.TYPE_INT,
- true);
-
- BISpecifier[BufferedImage.TYPE_INT_BGR] =
- createPacked(sRGB,
- 0x000000ff,
- 0x0000ff00,
- 0x00ff0000,
- 0x0,
- DataBuffer.TYPE_INT,
- false);
-
- int[] bOffsRGB = { 2, 1, 0 };
- BISpecifier[BufferedImage.TYPE_3BYTE_BGR] =
- createInterleaved(sRGB,
- bOffsRGB,
- DataBuffer.TYPE_BYTE,
- false,
- false);
-
- int[] bOffsABGR = { 3, 2, 1, 0 };
- BISpecifier[BufferedImage.TYPE_4BYTE_ABGR] =
- createInterleaved(sRGB,
- bOffsABGR,
- DataBuffer.TYPE_BYTE,
- true,
- false);
-
- BISpecifier[BufferedImage.TYPE_4BYTE_ABGR_PRE] =
- createInterleaved(sRGB,
- bOffsABGR,
- DataBuffer.TYPE_BYTE,
- true,
- true);
-
- BISpecifier[BufferedImage.TYPE_USHORT_565_RGB] =
- createPacked(sRGB,
- 0xF800,
- 0x07E0,
- 0x001F,
- 0x0,
- DataBuffer.TYPE_USHORT,
- false);
-
- BISpecifier[BufferedImage.TYPE_USHORT_555_RGB] =
- createPacked(sRGB,
- 0x7C00,
- 0x03E0,
- 0x001F,
- 0x0,
- DataBuffer.TYPE_USHORT,
- false);
-
- BISpecifier[BufferedImage.TYPE_BYTE_GRAY] =
- createGrayscale(8,
- DataBuffer.TYPE_BYTE,
- false);
-
- BISpecifier[BufferedImage.TYPE_USHORT_GRAY] =
- createGrayscale(16,
- DataBuffer.TYPE_USHORT,
- false);
-
- BISpecifier[BufferedImage.TYPE_BYTE_BINARY] =
- createGrayscale(1,
- DataBuffer.TYPE_BYTE,
- false);
-
- BufferedImage bi =
- new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED);
- IndexColorModel icm = (IndexColorModel)bi.getColorModel();
- int mapSize = icm.getMapSize();
- byte[] redLUT = new byte[mapSize];
- byte[] greenLUT = new byte[mapSize];
- byte[] blueLUT = new byte[mapSize];
- byte[] alphaLUT = new byte[mapSize];
-
- icm.getReds(redLUT);
- icm.getGreens(greenLUT);
- icm.getBlues(blueLUT);
- icm.getAlphas(alphaLUT);
-
- BISpecifier[BufferedImage.TYPE_BYTE_INDEXED] =
- createIndexed(redLUT, greenLUT, blueLUT, alphaLUT,
- 8,
- DataBuffer.TYPE_BYTE);
}
/**
@@ -1011,7 +898,7 @@ public class ImageTypeSpecifier {
ImageTypeSpecifier createFromBufferedImageType(int bufferedImageType) {
if (bufferedImageType >= BufferedImage.TYPE_INT_RGB &&
bufferedImageType <= BufferedImage.TYPE_BYTE_INDEXED) {
- return BISpecifier[bufferedImageType];
+ return getSpecifier(bufferedImageType);
} else if (bufferedImageType == BufferedImage.TYPE_CUSTOM) {
throw new IllegalArgumentException("Cannot create from TYPE_CUSTOM!");
} else {
@@ -1041,7 +928,7 @@ public class ImageTypeSpecifier {
if (image instanceof BufferedImage) {
int bufferedImageType = ((BufferedImage)image).getType();
if (bufferedImageType != BufferedImage.TYPE_CUSTOM) {
- return BISpecifier[bufferedImageType];
+ return getSpecifier(bufferedImageType);
}
}
@@ -1225,4 +1112,130 @@ public class ImageTypeSpecifier {
public int hashCode() {
return (9 * colorModel.hashCode()) + (14 * sampleModel.hashCode());
}
+
+ private static ImageTypeSpecifier getSpecifier(int type) {
+ if (BISpecifier[type] == null) {
+ BISpecifier[type] = createSpecifier(type);
+ }
+ return BISpecifier[type];
+ }
+
+ private static ImageTypeSpecifier createSpecifier(int type) {
+ switch(type) {
+ case BufferedImage.TYPE_INT_RGB:
+ return createPacked(sRGB,
+ 0x00ff0000,
+ 0x0000ff00,
+ 0x000000ff,
+ 0x0,
+ DataBuffer.TYPE_INT,
+ false);
+
+ case BufferedImage.TYPE_INT_ARGB:
+ return createPacked(sRGB,
+ 0x00ff0000,
+ 0x0000ff00,
+ 0x000000ff,
+ 0xff000000,
+ DataBuffer.TYPE_INT,
+ false);
+
+ case BufferedImage.TYPE_INT_ARGB_PRE:
+ return createPacked(sRGB,
+ 0x00ff0000,
+ 0x0000ff00,
+ 0x000000ff,
+ 0xff000000,
+ DataBuffer.TYPE_INT,
+ true);
+
+ case BufferedImage.TYPE_INT_BGR:
+ return createPacked(sRGB,
+ 0x000000ff,
+ 0x0000ff00,
+ 0x00ff0000,
+ 0x0,
+ DataBuffer.TYPE_INT,
+ false);
+
+ case BufferedImage.TYPE_3BYTE_BGR:
+ return createInterleaved(sRGB,
+ new int[] { 2, 1, 0 },
+ DataBuffer.TYPE_BYTE,
+ false,
+ false);
+
+ case BufferedImage.TYPE_4BYTE_ABGR:
+ return createInterleaved(sRGB,
+ new int[] { 3, 2, 1, 0 },
+ DataBuffer.TYPE_BYTE,
+ true,
+ false);
+
+ case BufferedImage.TYPE_4BYTE_ABGR_PRE:
+ return createInterleaved(sRGB,
+ new int[] { 3, 2, 1, 0 },
+ DataBuffer.TYPE_BYTE,
+ true,
+ true);
+
+ case BufferedImage.TYPE_USHORT_565_RGB:
+ return createPacked(sRGB,
+ 0xF800,
+ 0x07E0,
+ 0x001F,
+ 0x0,
+ DataBuffer.TYPE_USHORT,
+ false);
+
+ case BufferedImage.TYPE_USHORT_555_RGB:
+ return createPacked(sRGB,
+ 0x7C00,
+ 0x03E0,
+ 0x001F,
+ 0x0,
+ DataBuffer.TYPE_USHORT,
+ false);
+
+ case BufferedImage.TYPE_BYTE_GRAY:
+ return createGrayscale(8,
+ DataBuffer.TYPE_BYTE,
+ false);
+
+ case BufferedImage.TYPE_USHORT_GRAY:
+ return createGrayscale(16,
+ DataBuffer.TYPE_USHORT,
+ false);
+
+ case BufferedImage.TYPE_BYTE_BINARY:
+ return createGrayscale(1,
+ DataBuffer.TYPE_BYTE,
+ false);
+
+ case BufferedImage.TYPE_BYTE_INDEXED:
+ {
+
+ BufferedImage bi =
+ new BufferedImage(1, 1, BufferedImage.TYPE_BYTE_INDEXED);
+ IndexColorModel icm = (IndexColorModel)bi.getColorModel();
+ int mapSize = icm.getMapSize();
+ byte[] redLUT = new byte[mapSize];
+ byte[] greenLUT = new byte[mapSize];
+ byte[] blueLUT = new byte[mapSize];
+ byte[] alphaLUT = new byte[mapSize];
+
+ icm.getReds(redLUT);
+ icm.getGreens(greenLUT);
+ icm.getBlues(blueLUT);
+ icm.getAlphas(alphaLUT);
+
+ return createIndexed(redLUT, greenLUT, blueLUT, alphaLUT,
+ 8,
+ DataBuffer.TYPE_BYTE);
+ }
+ default:
+ throw new IllegalArgumentException("Invalid BufferedImage type!");
+ }
+ }
+
}
From 454a7c0732e7b5c5bfd1e45a4ff6ef5e9c394438 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 30 Jan 2009 22:30:32 +0300
Subject: [PATCH 015/283] 6791502: IIOException "Invalid icc profile" on jpeg
after update from JDK5 to JDK6
Reviewed-by: igor, prr
---
.../native/sun/awt/image/jpeg/imageioJPEG.c | 112 +++++++++++-------
1 file changed, 70 insertions(+), 42 deletions(-)
diff --git a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
index 8c30b5ce69e..0a99c3fdb93 100644
--- a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+++ b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
@@ -396,7 +396,7 @@ static imageIODataPtr initImageioData (JNIEnv *env,
data->jpegObj = cinfo;
cinfo->client_data = data;
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("new structures: data is %p, cinfo is %p\n", data, cinfo);
#endif
@@ -673,7 +673,7 @@ static int setQTables(JNIEnv *env,
j_decompress_ptr decomp;
qlen = (*env)->GetArrayLength(env, qtables);
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("in setQTables, qlen = %d, write is %d\n", qlen, write);
#endif
for (i = 0; i < qlen; i++) {
@@ -876,7 +876,7 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
return FALSE;
}
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("Filling input buffer, remaining skip is %ld, ",
sb->remaining_skip);
printf("Buffer length is %d\n", sb->bufferLength);
@@ -906,7 +906,7 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
cinfo->err->error_exit((j_common_ptr) cinfo);
}
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("Buffer filled. ret = %d\n", ret);
#endif
/*
@@ -917,7 +917,7 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
*/
if (ret <= 0) {
jobject reader = data->imageIOobj;
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("YO! Early EOI! ret = %d\n", ret);
#endif
RELEASE_ARRAYS(env, data, src->next_input_byte);
@@ -1216,21 +1216,24 @@ read_icc_profile (JNIEnv *env, j_decompress_ptr cinfo)
{
jpeg_saved_marker_ptr marker;
int num_markers = 0;
+ int num_found_markers = 0;
int seq_no;
JOCTET *icc_data;
+ JOCTET *dst_ptr;
unsigned int total_length;
#define MAX_SEQ_NO 255 // sufficient since marker numbers are bytes
- char marker_present[MAX_SEQ_NO+1]; // 1 if marker found
- unsigned int data_length[MAX_SEQ_NO+1]; // size of profile data in marker
- unsigned int data_offset[MAX_SEQ_NO+1]; // offset for data in marker
+ jpeg_saved_marker_ptr icc_markers[MAX_SEQ_NO + 1];
+ int first; // index of the first marker in the icc_markers array
+ int last; // index of the last marker in the icc_markers array
jbyteArray data = NULL;
/* This first pass over the saved markers discovers whether there are
* any ICC markers and verifies the consistency of the marker numbering.
*/
- for (seq_no = 1; seq_no <= MAX_SEQ_NO; seq_no++)
- marker_present[seq_no] = 0;
+ for (seq_no = 0; seq_no <= MAX_SEQ_NO; seq_no++)
+ icc_markers[seq_no] = NULL;
+
for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
if (marker_is_icc(marker)) {
@@ -1242,37 +1245,58 @@ read_icc_profile (JNIEnv *env, j_decompress_ptr cinfo)
return NULL;
}
seq_no = GETJOCTET(marker->data[12]);
- if (seq_no <= 0 || seq_no > num_markers) {
+
+ /* Some third-party tools produce images with profile chunk
+ * numeration started from zero. It is inconsistent with ICC
+ * spec, but seems to be recognized by majority of image
+ * processing tools, so we should be more tolerant to this
+ * departure from the spec.
+ */
+ if (seq_no < 0 || seq_no > num_markers) {
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid icc profile: bad sequence number");
return NULL;
}
- if (marker_present[seq_no]) {
+ if (icc_markers[seq_no] != NULL) {
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid icc profile: duplicate sequence numbers");
return NULL;
}
- marker_present[seq_no] = 1;
- data_length[seq_no] = marker->data_length - ICC_OVERHEAD_LEN;
+ icc_markers[seq_no] = marker;
+ num_found_markers ++;
}
}
if (num_markers == 0)
return NULL; // There is no profile
- /* Check for missing markers, count total space needed,
- * compute offset of each marker's part of the data.
- */
+ if (num_markers != num_found_markers) {
+ JNU_ThrowByName(env, "javax/imageio/IIOException",
+ "Invalid icc profile: invalid number of icc markers");
+ return NULL;
+ }
+ first = icc_markers[0] ? 0 : 1;
+ last = num_found_markers + first;
+
+ /* Check for missing markers, count total space needed.
+ */
total_length = 0;
- for (seq_no = 1; seq_no <= num_markers; seq_no++) {
- if (marker_present[seq_no] == 0) {
+ for (seq_no = first; seq_no < last; seq_no++) {
+ unsigned int length;
+ if (icc_markers[seq_no] == NULL) {
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid icc profile: missing sequence number");
return NULL;
}
- data_offset[seq_no] = total_length;
- total_length += data_length[seq_no];
+ /* check the data length correctness */
+ length = icc_markers[seq_no]->data_length;
+ if (ICC_OVERHEAD_LEN > length || length > MAX_BYTES_IN_MARKER) {
+ JNU_ThrowByName(env, "javax/imageio/IIOException",
+ "Invalid icc profile: invalid data length");
+ return NULL;
+ }
+ total_length += (length - ICC_OVERHEAD_LEN);
}
if (total_length <= 0) {
@@ -1301,19 +1325,14 @@ read_icc_profile (JNIEnv *env, j_decompress_ptr cinfo)
}
/* and fill it in */
- for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
- if (marker_is_icc(marker)) {
- JOCTET FAR *src_ptr;
- JOCTET *dst_ptr;
- unsigned int length;
- seq_no = GETJOCTET(marker->data[12]);
- dst_ptr = icc_data + data_offset[seq_no];
- src_ptr = marker->data + ICC_OVERHEAD_LEN;
- length = data_length[seq_no];
- while (length--) {
- *dst_ptr++ = *src_ptr++;
- }
- }
+ dst_ptr = icc_data;
+ for (seq_no = first; seq_no < last; seq_no++) {
+ JOCTET FAR *src_ptr = icc_markers[seq_no]->data + ICC_OVERHEAD_LEN;
+ unsigned int length =
+ icc_markers[seq_no]->data_length - ICC_OVERHEAD_LEN;
+
+ memcpy(dst_ptr, src_ptr, length);
+ dst_ptr += length;
}
/* finally, unpin the array */
@@ -1530,6 +1549,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
j_decompress_ptr cinfo;
struct jpeg_source_mgr *src;
sun_jpeg_error_ptr jerr;
+ jbyteArray profileData = NULL;
if (data == NULL) {
JNU_ThrowByName(env,
@@ -1557,7 +1577,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
return retval;
}
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("In readImageHeader, data is %p cinfo is %p\n", data, cinfo);
printf("clearFirst is %d\n", clearFirst);
#endif
@@ -1584,7 +1604,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
if (ret == JPEG_HEADER_TABLES_ONLY) {
retval = JNI_TRUE;
imageio_term_source(cinfo); // Pushback remaining buffer contents
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("just read tables-only image; q table 0 at %p\n",
cinfo->quant_tbl_ptrs[0]);
#endif
@@ -1691,6 +1711,14 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
}
}
RELEASE_ARRAYS(env, data, src->next_input_byte);
+
+ /* read icc profile data */
+ profileData = read_icc_profile(env, cinfo);
+
+ if ((*env)->ExceptionCheck(env)) {
+ return retval;
+ }
+
(*env)->CallVoidMethod(env, this,
JPEGImageReader_setImageDataID,
cinfo->image_width,
@@ -1698,7 +1726,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader
cinfo->jpeg_color_space,
cinfo->out_color_space,
cinfo->num_components,
- read_icc_profile(env, cinfo));
+ profileData);
if (reset) {
jpeg_abort_decompress(cinfo);
}
@@ -1827,7 +1855,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
(*env)->ReleaseIntArrayElements(env, srcBands, body, JNI_ABORT);
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("---- in reader.read ----\n");
printf("numBands is %d\n", numBands);
printf("bands array: ");
@@ -2487,7 +2515,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables
data->streamBuf.suspendable = FALSE;
if (qtables != NULL) {
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("in writeTables: qtables not NULL\n");
#endif
setQTables(env, (j_common_ptr) cinfo, qtables, TRUE);
@@ -2763,7 +2791,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage
cinfo->restart_interval = restartInterval;
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
printf("writer setup complete, starting compressor\n");
#endif
@@ -2812,13 +2840,13 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage
for (i = 0; i < numBands; i++) {
if (scale !=NULL && scale[i] != NULL) {
*out++ = scale[i][*(in+i)];
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
if (in == data->pixelBuf.buf.bp){ // Just the first pixel
printf("in %d -> out %d, ", *(in+i), *(out-i-1));
}
#endif
-#ifdef DEBUG
+#ifdef DEBUG_IIO_JPEG
if (in == data->pixelBuf.buf.bp){ // Just the first pixel
printf("\n");
}
From 614df1958ca812c31f6097489ef348de9f90a5a8 Mon Sep 17 00:00:00 2001
From: Kelly O'Hair
Date: Sat, 31 Jan 2009 15:26:34 -0800
Subject: [PATCH 016/283] 6791649: add "SKIP_MSIVAL2=true" to the Windows
section of make/jprt.config
Reviewed-by: tbell
---
make/jdk-rules.gmk | 2 +-
make/jprt.config | 7 +++++++
make/jprt.gmk | 2 +-
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/make/jdk-rules.gmk b/make/jdk-rules.gmk
index 821f5d739c6..d0ca905ff02 100644
--- a/make/jdk-rules.gmk
+++ b/make/jdk-rules.gmk
@@ -106,7 +106,7 @@ jdk-clobber::
$(MAKE) $(JDK_CLOBBER_TARGETS) $(JDK_BUILD_ARGUMENTS) ; )
jdk-sanity::
- @( $(CD) $(JDK_TOPDIR)/make && \
+ ( $(CD) $(JDK_TOPDIR)/make && \
$(MAKE) sanity HOTSPOT_IMPORT_CHECK=false $(JDK_BUILD_ARGUMENTS) ; )
compare-images: compare-image
diff --git a/make/jprt.config b/make/jprt.config
index f3ff50615ef..895d9432e01 100644
--- a/make/jprt.config
+++ b/make/jprt.config
@@ -358,6 +358,13 @@ else
ALT_SPONSOR2DIR=C:/sponsor_binaries
export ALT_SPONSOR2DIR
+ # JPRT systems can never run msival2.exe, set this to avoid them
+ SKIP_MSIVAL2=true
+ export SKIP_MSIVAL2
+ # Not easy to do
+ SKIP_COMPARE_IMAGES=true
+ export SKIP_COMPARE_IMAGES
+
fi
# Export PATH setting
diff --git a/make/jprt.gmk b/make/jprt.gmk
index fcf67f80b36..32803e06256 100644
--- a/make/jprt.gmk
+++ b/make/jprt.gmk
@@ -36,7 +36,7 @@ DEFAULT_BUILD_FLAVOR=product
JPRT_ARCHIVE_BUNDLE=$(ABS_OUTPUTDIR)/$(DEFAULT_BUILD_FLAVOR)-bundle.zip
JPRT_ARCHIVE_INSTALL_BUNDLE=$(ABS_OUTPUTDIR)/$(DEFAULT_BUILD_FLAVOR)-install-bundle.zip
-jprt_build_product: all_product_build
+jprt_build_product: sanity all_product_build
( $(CD) $(OUTPUTDIR)/j2sdk-image && \
$(ZIPEXE) -q -r $(JPRT_ARCHIVE_BUNDLE) . )
ifdef HAVE_JPRT_SAVE_BUNDLES
From 09010fe0a7622ad2bf5f4b32b43ff4ca9eb846e5 Mon Sep 17 00:00:00 2001
From: Kelly O'Hair
Date: Sat, 31 Jan 2009 17:19:42 -0800
Subject: [PATCH 017/283] 6799141: Build with --hash-style=both so that
binaries can work on SuSE 10
Reviewed-by: tbell
---
hotspot/make/linux/makefiles/gcc.make | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make
index 4a01c29c50e..1a1f1465c81 100644
--- a/hotspot/make/linux/makefiles/gcc.make
+++ b/hotspot/make/linux/makefiles/gcc.make
@@ -131,6 +131,14 @@ endif
# Enable linker optimization
LFLAGS += -Xlinker -O1
+# If this is a --hash-style=gnu system, use --hash-style=both
+# The gnu .hash section won't work on some Linux systems like SuSE 10.
+_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu')
+ifneq ($(_HAS_HASH_STYLE_GNU),)
+ LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
+endif
+LFLAGS += $(LDFLAGS_HASH_STYLE)
+
# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file.
MAPFLAG = -Xlinker --version-script=FILENAME
From 2fa7dc18d777048fcce291eb6b93d339db9f97e7 Mon Sep 17 00:00:00 2001
From: Kelly O'Hair
Date: Sat, 31 Jan 2009 17:31:21 -0800
Subject: [PATCH 018/283] 6799141: Build with --hash-style=both so that
binaries can work on SuSE 10
Reviewed-by: tbell
---
jdk/make/common/Defs-linux.gmk | 8 +
jdk/make/common/shared/Compiler-gcc.gmk | 28 +--
jdk/make/common/shared/Compiler-msvc.gmk | 18 --
jdk/make/common/shared/Compiler-sun.gmk | 12 +-
jdk/make/common/shared/Defs-versions.gmk | 183 ++++++++++++++++
jdk/make/common/shared/Defs-windows.gmk | 5 +-
jdk/make/common/shared/Defs.gmk | 37 ++--
jdk/make/common/shared/Platform.gmk | 81 -------
jdk/make/common/shared/Sanity-Settings.gmk | 10 +-
jdk/make/common/shared/Sanity.gmk | 238 ++++++++++-----------
10 files changed, 337 insertions(+), 283 deletions(-)
create mode 100644 jdk/make/common/shared/Defs-versions.gmk
diff --git a/jdk/make/common/Defs-linux.gmk b/jdk/make/common/Defs-linux.gmk
index 28d58376fe2..9ecdd4d7156 100644
--- a/jdk/make/common/Defs-linux.gmk
+++ b/jdk/make/common/Defs-linux.gmk
@@ -116,6 +116,14 @@ LDFLAGS_COMMON_sparc += -m32 -mcpu=v9
CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH))
+# If this is a --hash-style=gnu system, use --hash-style=both
+# The gnu .hash section won't work on some Linux systems like SuSE 10.
+_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | $(GREP) -- '--hash-style=gnu')
+ifneq ($(_HAS_HASH_STYLE_GNU),)
+ LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
+endif
+LDFLAGS_COMMON += $(LDFLAGS_HASH_STYLE)
+
#
# Selection of warning messages
#
diff --git a/jdk/make/common/shared/Compiler-gcc.gmk b/jdk/make/common/shared/Compiler-gcc.gmk
index 27501956368..13feb4cf98c 100644
--- a/jdk/make/common/shared/Compiler-gcc.gmk
+++ b/jdk/make/common/shared/Compiler-gcc.gmk
@@ -68,24 +68,6 @@ ifeq ($(PLATFORM), linux)
else
CXX = $(COMPILER_PATH)g++
endif
- ifneq ("$(findstring sparc,$(ARCH))", "")
- # sparc or sparcv9
- REQUIRED_CC_VER = 4.0
- REQUIRED_GCC_VER = 4.0.*
- else
- REQUIRED_CC_VER = 3.2
- ifeq ($(ARCH_DATA_MODEL), 32)
- REQUIRED_GCC_VER = 3.2.1*
- REQUIRED_GCC_VER_INT = 3.2.1-7a
- else
- ifeq ($(ARCH), amd64)
- REQUIRED_GCC_VER = 3.2.*
- endif
- ifeq ($(ARCH), ia64)
- REQUIRED_GCC_VER = 2.9[56789].*
- endif
- endif
- endif
# Option used to create a shared library
SHARED_LIBRARY_FLAG = -shared -mimpure-text
SUN_COMP_VER := $(shell $(CC) --verbose 2>&1 )
@@ -98,18 +80,10 @@ ifeq ($(PLATFORM), solaris)
CC = $(COMPILER_PATH)gcc
CPP = $(COMPILER_PATH)gcc -E
CXX = $(COMPILER_PATH)g++
- REQUIRED_CC_VER = 3.2
# Option used to create a shared library
SHARED_LIBRARY_FLAG = -G
- # But gcc is still needed no matter what on 32bit
- ifeq ($(ARCH_DATA_MODEL), 32)
- REQUIRED_GCC_VER = 2.95
- GCC =$(GCC_COMPILER_PATH)gcc
- _GCC_VER :=$(shell $(GCC) -dumpversion 2>&1 )
- GCC_VER :=$(call GetVersion,"$(_GCC_VER)")
- endif
-
+
endif
# Get gcc version
diff --git a/jdk/make/common/shared/Compiler-msvc.gmk b/jdk/make/common/shared/Compiler-msvc.gmk
index d23529f3935..4671366b5c3 100644
--- a/jdk/make/common/shared/Compiler-msvc.gmk
+++ b/jdk/make/common/shared/Compiler-msvc.gmk
@@ -41,8 +41,6 @@ ifeq ($(PLATFORM), windows)
# Fill in unknown values
COMPILER_NAME=Unknown MSVC Compiler
COMPILER_VERSION=
- REQUIRED_CC_VER=
- REQUIRED_LINK_VER=
# unset any GNU Make settings of MFLAGS and MAKEFLAGS which may mess up nmake
NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo
@@ -56,8 +54,6 @@ ifeq ($(PLATFORM), windows)
CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
ifeq ($(CC_MAJORVER), 13)
# This should be: CC_VER=13.10.3077 LINK_VER=7.10.3077
- REQUIRED_CC_VER = 13.10.3077
- REQUIRED_LINK_VER = 7.10.3077
COMPILER_NAME=Visual Studio .NET 2003 Professional C++
COMPILER_VERSION=VS2003
REBASE = $(COMPILER_PATH)../../Common7/Tools/Bin/rebase
@@ -67,9 +63,6 @@ ifeq ($(PLATFORM), windows)
endif
endif
ifeq ($(CC_MAJORVER), 14)
- # This should be: CC_VER=14.00.50727.42 LINK_VER=8.00.50727.42
- REQUIRED_CC_VER = 14.00.50727.42
- REQUIRED_LINK_VER = 8.00.50727.42
COMPILER_NAME=Visual Studio 8
COMPILER_VERSION=VS2005
REBASE = $(COMPILER_PATH)../../Common8/Tools/Bin/rebase
@@ -80,9 +73,6 @@ ifeq ($(PLATFORM), windows)
endif
endif
ifeq ($(CC_MAJORVER), 15)
- # This should be: CC_VER=15.00.21022.08 LINK_VER=9.00.21022.08
- REQUIRED_CC_VER = 15.00.21022.08
- REQUIRED_LINK_VER = 9.00.21022.08
COMPILER_NAME=Visual Studio 9
COMPILER_VERSION=VS2008
#rebase and midl moved out of Visual Studio into the SDK:
@@ -99,14 +89,6 @@ ifeq ($(PLATFORM), windows)
CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
CC_MINORVER :=$(call MinorVersion,$(CC_VER))
CC_MICROVER :=$(call MicroVersion,$(CC_VER))
- ifeq ($(ARCH), ia64)
- REQUIRED_CC_VER = 13.00.9337.7
- REQUIRED_LINK_VER = 7.00.9337.7
- endif
- ifeq ($(ARCH), amd64)
- REQUIRED_CC_VER = 14.00.40310.41
- REQUIRED_LINK_VER = 8.00.40310.39
- endif
ifeq ($(CC_MAJORVER), 13)
ifeq ($(ARCH), ia64)
# This should be: CC_VER=13.00.9337.7 LINK_VER=7.00.9337.7
diff --git a/jdk/make/common/shared/Compiler-sun.gmk b/jdk/make/common/shared/Compiler-sun.gmk
index b3c4e2a90b1..a22196b34f0 100644
--- a/jdk/make/common/shared/Compiler-sun.gmk
+++ b/jdk/make/common/shared/Compiler-sun.gmk
@@ -32,27 +32,19 @@ COMPILER_NAME=Sun Studio
# Sun Studio Compiler settings specific to Solaris
ifeq ($(PLATFORM), solaris)
COMPILER_VERSION=SS12
- REQUIRED_CC_VER=5.9
CC = $(COMPILER_PATH)cc
CPP = $(COMPILER_PATH)cc -E
CXX = $(COMPILER_PATH)CC
LINT = $(COMPILER_PATH)lint
# Option used to create a shared library
SHARED_LIBRARY_FLAG = -G
- # But gcc is still needed no matter what on 32bit
- ifeq ($(ARCH_DATA_MODEL), 32)
- REQUIRED_GCC_VER = 2.95
- GCC =$(GCC_COMPILER_PATH)gcc
- _GCC_VER :=$(shell $(GCC) -dumpversion 2>&1 )
- GCC_VER :=$(call GetVersion,"$(_GCC_VER)")
- endif
+ GCC =$(GCC_COMPILER_PATH)gcc
endif
# Sun Studio Compiler settings specific to Linux
ifeq ($(PLATFORM), linux)
# This has not been tested
COMPILER_VERSION=SS12
- REQUIRED_CC_VER=5.9
CC = $(COMPILER_PATH)cc
CPP = $(COMPILER_PATH)cc -E
CXX = $(COMPILER_PATH)CC
@@ -73,7 +65,7 @@ endif
# Get compiler version
_CC_VER :=$(shell $(CC) -V 2>&1 | $(HEAD) -n 1)
CC_VER :=$(call GetVersion,"$(_CC_VER)")
-
+
# Arch specific settings (determines type of .o files and instruction set)
# Starting in SS12 (5.9), the arch options changed.
# The assembler /usr/ccs/bin/as wants older SS11 (5.8) style options.
diff --git a/jdk/make/common/shared/Defs-versions.gmk b/jdk/make/common/shared/Defs-versions.gmk
new file mode 100644
index 00000000000..007c08fd6bf
--- /dev/null
+++ b/jdk/make/common/shared/Defs-versions.gmk
@@ -0,0 +1,183 @@
+#
+# Copyright 2009 Sun Microsystems, Inc. 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. Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+#
+# WARNING: This file is shared with other workspaces.
+#
+
+# This file needs these set: CC_VERSION, PLATFORM, ARCH_FAMILY, and ARCH_DATA_MODEL.
+
+##########################################################################
+#
+# List of JDK official minimum, expected, or required versions:
+#
+# REQUIRED_ALSA_VERSION
+# Linux only: The ALSA sound library version expected.
+#
+# REQUIRED_ANT_VER
+# The minimum 'ant' version.
+#
+# REQUIRED_BOOT_VER
+# The minimum boot jdk version.
+#
+# REQUIRED_CC_VER
+# The primary C compiler version expected.
+#
+# REQUIRED_CYGWIN_VER
+# Windows only: If CYGWIN is used, the minimum CYGWIN version.
+#
+# REQUIRED_DXSDK_VER
+# Windows only: The version of DirectX SDK expected.
+#
+# REQUIRED_FREE_SPACE
+# The minimum disk space needed as determined by running 'du -sk' on a fully
+# built workspace.
+#
+# REQUIRED_FREETYPE_VERSION
+# If we are using freetype, the freetype version expected.
+#
+# REQUIRED_GCC_VER
+# Solaris and Linux only. The required version of gcc/g++ for the plugin.
+#
+# REQUIRED_LINK_VER
+# Windows only: The version of link.exe expected.
+#
+# REQUIRED_MAKE_VER
+# The minimum version of GNU make.
+#
+# REQUIRED_MKS_VER
+# Windows only: If MKS used instead of CYGWIN, the minimum version of MKS.
+#
+# REQUIRED_OS_VARIANT_NAME
+# The OS variation name required.
+# Solaris: Solaris or OpenSolaris
+# Windows: Windows2000, WindowsXP, Windows2003, etc.
+# Linux: Fedora, RedHat, SuSE, Ubuntu, etc.
+#
+# REQUIRED_OS_VARIANT_VERSION
+# The version number associated with the above OS variant name.
+# Solaris: output of uname -r
+# Windows: 5.0 for Windows2000, 5.1 for WindowsXP, 5.2 for Windows2003, etc.
+# Linux: number for the variant, e.g. 9 for Fedora 9
+#
+# REQUIRED_OS_VERSION
+# The formal OS version number.
+# Solaris & Windows: same as REQUIRED_OS_VARIANT_VERSION
+# Linux: the kernel version, or output of uname -r
+#
+# REQUIRED_UNZIP_VER
+# The minimum version of unzip.
+#
+# REQUIRED_ZIP_VER
+# The minimum version of unzip.
+#
+###########
+#
+# Differences in the build platform from these versions may trigger warnings
+# messages during the sanity checking when building the JDK.
+#
+# When building the OpenJDK most of these required or expected versions are
+# ignored or allowed to vary widely to accomodate the many build situations
+# of the OpenJDK.
+#
+##########################################################################
+
+# Solaris specific
+ifeq ($(PLATFORM), solaris)
+ REQUIRED_OS_VERSION = 5.10
+ REQUIRED_OS_VARIANT_NAME = Solaris
+ REQUIRED_OS_VARIANT_VERSION = $(REQUIRED_OS_VERSION)
+ ifeq ($(ARCH_FAMILY), sparc)
+ REQUIRED_FREE_SPACE = 1300000
+ else
+ REQUIRED_FREE_SPACE = 1040000
+ endif
+ ifeq ($(CC_VERSION),sun)
+ REQUIRED_CC_VER = 5.9
+ endif
+ ifeq ($(CC_VERSION),gcc)
+ REQUIRED_CC_VER = 3.4.3
+ endif
+ REQUIRED_GCC_VER = 2.95.2
+endif
+
+# Linux specific
+ifeq ($(PLATFORM), linux)
+ REQUIRED_OS_VERSION = 2.6
+ REQUIRED_OS_VARIANT_NAME = Fedora
+ REQUIRED_OS_VARIANT_VERSION = 9
+ REQUIRED_FREE_SPACE = 1460000
+ REQUIRED_ALSA_VERSION = 0.9.1
+ REQUIRED_GCC_VER = 2.95
+ ifeq ($(CC_VERSION),gcc)
+ REQUIRED_CC_VER = 4.3.0
+ endif
+ ifeq ($(CC_VERSION),sun)
+ REQUIRED_CC_VER = 5.9
+ endif
+endif
+
+# Windows specific
+ifeq ($(PLATFORM), windows)
+ ifeq ($(ARCH_DATA_MODEL),64)
+ REQUIRED_OS_VERSION = 5.2
+ REQUIRED_OS_VARIANT_NAME = Windows2003
+ else
+ REQUIRED_OS_VERSION = 5.1
+ REQUIRED_OS_VARIANT_NAME = WindowsXP
+ endif
+ REQUIRED_OS_VARIANT_VERSION = $(REQUIRED_OS_VERSION)
+ REQUIRED_CYGWIN_VER = 4.0
+ REQUIRED_MKS_VER = 6.1
+ REQUIRED_FREE_SPACE = 500000
+ REQUIRED_DXSDK_VER = 0x0900
+ ifeq ($(CC_VERSION),msvc)
+ ifeq ($(ARCH_DATA_MODEL), 32)
+ REQUIRED_CC_VER = 15.00.21022.08
+ REQUIRED_LINK_VER = 9.00.21022.08
+ else
+ ifeq ($(ARCH), ia64)
+ REQUIRED_CC_VER = 13.00.9337.7
+ REQUIRED_LINK_VER = 7.00.9337.7
+ endif
+ ifeq ($(ARCH), amd64)
+ REQUIRED_CC_VER = 14.00.40310.41
+ REQUIRED_LINK_VER = 8.00.40310.39
+ endif
+ endif
+ endif
+ ifeq ($(CC_VERSION),gcc)
+ REQUIRED_CC_VER = 3.4.3
+ endif
+endif
+
+# Generic
+REQUIRED_ANT_VER = 1.6.3
+REQUIRED_BOOT_VER = 1.5
+REQUIRED_FREETYPE_VERSION = 2.3.0
+REQUIRED_MAKE_VER = 3.78
+REQUIRED_UNZIP_VER = 5.12
+REQUIRED_ZIP_VER = 2.2
+
diff --git a/jdk/make/common/shared/Defs-windows.gmk b/jdk/make/common/shared/Defs-windows.gmk
index 1ceb017b2f9..a7caa194893 100644
--- a/jdk/make/common/shared/Defs-windows.gmk
+++ b/jdk/make/common/shared/Defs-windows.gmk
@@ -136,10 +136,7 @@ endif
UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
# Get version of MKS or CYGWIN
-ifdef USING_CYGWIN
-_CYGWIN_VER :=$(shell $(UNAME))
-CYGWIN_VER :=$(call GetVersion,$(_CYGWIN_VER))
-else # MKS
+ifndef USING_CYGWIN
_MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
MKS_VER :=$(call GetVersion,$(_MKS_VER))
# At this point, we can re-define FullPath to use DOSNAME_CMD
diff --git a/jdk/make/common/shared/Defs.gmk b/jdk/make/common/shared/Defs.gmk
index 638cd363696..c297bfa4d08 100644
--- a/jdk/make/common/shared/Defs.gmk
+++ b/jdk/make/common/shared/Defs.gmk
@@ -116,9 +116,9 @@ $(shell \
fi)
endef
-# Given a line of text, get the major.minor version number from it
+# Given a line of text, get the version number from it
define GetVersion
-$(shell echo $1 | sed -e 's@[^1-9]*\([1-9][0-9]*\.[0-9][0-9]*\).*@\1@' )
+$(shell echo $1 | sed -e 's@[^0-9]*\([0-9][0-9]*\.[0-9][.0-9]*\).*@\1@' )
endef
# Given a major.minor.micro version, return the major, minor, or micro number
@@ -133,26 +133,26 @@ $(if $(word 3, $(subst ., ,$1)),$(word 3, $(subst ., ,$1)),0)
endef
# Macro that returns missing, same, newer, or older $1=version $2=required
-# (currently does not check the micro number)
define CheckVersions
$(shell \
if [ "$1" = "" -o "$2" = "" ]; then \
echo missing; \
+ elif [ "$1" = "$2" ]; then \
+ echo same; \
+ elif [ $(call MajorVersion,$1) -lt $(call MajorVersion,$2) ] ; then \
+ echo older; \
+ elif [ $(call MajorVersion,$1) -gt $(call MajorVersion,$2) ] ; then \
+ echo newer; \
+ elif [ $(call MinorVersion,$1) -lt $(call MinorVersion,$2) ]; then \
+ echo older; \
+ elif [ $(call MinorVersion,$1) -gt $(call MinorVersion,$2) ]; then \
+ echo newer; \
+ elif [ $(call MicroVersion,$1) -lt $(call MicroVersion,$2) ]; then \
+ echo older; \
+ elif [ $(call MicroVersion,$1) -gt $(call MicroVersion,$2) ]; then \
+ echo newer; \
else \
- if [ "$1" = "$2" ]; then \
- echo same; \
- else \
- if [ $(call MajorVersion,$1) -lt $(call MajorVersion,$2) ] ; then \
- echo older; \
- else \
- if [ $(call MajorVersion,$1) -eq $(call MajorVersion,$2) -a \
- $(call MinorVersion,$1) -lt $(call MinorVersion,$2) ]; then \
- echo older; \
- else \
- echo newer; \
- fi; \
- fi; \
- fi; \
+ echo same; \
fi)
endef
@@ -561,3 +561,6 @@ endif
# Get shared compiler settings
include $(JDK_MAKE_SHARED_DIR)/Compiler.gmk
+# Get the REQUIRED versions
+include $(JDK_MAKE_SHARED_DIR)/Defs-versions.gmk
+
diff --git a/jdk/make/common/shared/Platform.gmk b/jdk/make/common/shared/Platform.gmk
index 8da23c83fc4..d343cdea1c3 100644
--- a/jdk/make/common/shared/Platform.gmk
+++ b/jdk/make/common/shared/Platform.gmk
@@ -51,9 +51,6 @@ PLATFORM_SHARED=done
# USER login name of user (minus blanks)
# PLATFORM windows, solaris, or linux
# VARIANT OPT or DBG, OPT is the default
-# OS_NAME solaris, linux, or nt
-# OS_VERSION specific version of os, 5.10, 2.4.9-e.3, etc.
-# OS_VENDOR company name
# TEMP_DISK /tmp or C:/temp
# ARCH_DATA_MODEL 32 or 64
# ARCH sparc, sparcv9, i586, amd64, or ia64
@@ -72,29 +69,11 @@ PLATFORM_SHARED=done
# ISA_DIR solaris only: /sparcv9 or /amd64
# LIBARCH32 solaris only: sparc or i386
# LIBARCH64 solaris only: sparcv9 or amd64
-# REQUIRED_WINDOWS_VERSION windows only: specific version of windows
# USING_CYGWIN windows only: true or false
-# WINDOWS_NT_VERSION_STRING windows only: long version name
-# REQUIRED_OS_VERSION required OS version, e.g. 5.10, 2.4
-# REQUIRED_FREE_SPACE minimum disk space needed for outputdir
# ISHIELD_TEMP_MIN windows only: minimum disk space in temp area
-# REQUIRED_ZIP_VER required version of zip
-# REQUIRED_UNZIP_VER required version of unzip
-# REQUIRED_DXSDK_VER windows only: required version of DirectX
-# LINUX_VERSION_INFO linux only: location of linux release file
-# REQUIRED_LINUX_VER linux only: required version of linux
-# REQUIRED_LINUX_FULLVER linux only: required full version of linux
-# REQUIRED_ALSA_VERSION linux only: required version of ALSA
-# REQUIRED_FREETYPE_VERSION openjdk only: required version of freetype
SYSTEM_UNAME := $(shell uname)
-# Normal boot jdk is previous release, but a hard requirement is a 1.5 boot
-REQUIRED_BOOT_VER = 1.5
-
-# If we are using freetype, this is the required version
-REQUIRED_FREETYPE_VERSION=2.3.0
-
#
# Prune out all known SCM (Source Code Management) directories
# so they will not be included when copying directory trees
@@ -113,8 +92,6 @@ endif
# Platform settings specific to Solaris
ifeq ($(SYSTEM_UNAME), SunOS)
PLATFORM = solaris
- OS_NAME = solaris
- OS_VERSION := $(shell uname -r)
# Solaris sparc build can be either 32-bit or 64-bit.
# Default to 32, but allow explicit setting to 32 or 64.
ifndef ARCH_DATA_MODEL
@@ -166,16 +143,6 @@ ifeq ($(SYSTEM_UNAME), SunOS)
endif
# Suffix for file bundles used in previous release
BUNDLE_FILE_SUFFIX=.tar
- OS_VENDOR = Sun Microsystems
- # Required Solaris version
- REQUIRED_OS_VERSION = 5.10
- # Minimum disk space needed as determined by running 'du -sk' on
- # a fully built workspace.
- ifeq ($(ARCH_FAMILY), sparc)
- REQUIRED_FREE_SPACE=1300000
- else
- REQUIRED_FREE_SPACE=1040000
- endif
# How much RAM does this machine have:
MB_OF_MEMORY=$(shell /etc/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3)
endif
@@ -183,8 +150,6 @@ endif
# Platform settings specific to Linux
ifeq ($(SYSTEM_UNAME), Linux)
PLATFORM = linux
- OS_NAME = linux
- OS_VERSION := $(shell uname -r)
# Arch and OS name/version
mach := $(shell uname -m)
archExpr = case "$(mach)" in \
@@ -242,32 +207,6 @@ ifeq ($(SYSTEM_UNAME), Linux)
# Suffix for file bundles used in previous release
BUNDLE_FILE_SUFFIX=.tar.gz
- # Minimum disk space needed as determined by running 'du -sk' on
- # a fully built workspace.
- REQUIRED_FREE_SPACE=1460000
- LINUX_VERSION_INFO = /etc/redhat-release
- OS_VENDOR = Red Hat
- ifeq ($(ARCH_DATA_MODEL), 32)
- REQUIRED_LINUX_VER = Advanced Server
- REQUIRED_LINUX_FULLVER = Advanced Server release 2.1AS
- REQUIRED_OS_VERSION = 2.4.9-e.3
- else
- ifeq ($(ARCH), amd64)
- LINUX_VERSION_INFO = /etc/SuSE-release
- OS_VENDOR = SuSE Enterprise
- REQUIRED_LINUX_VER = 8.1
- REQUIRED_LINUX_FULLVER = $(REQUIRED_LINUX_VER) SLSE AMD64
- REQUIRED_OS_VERSION = 2.4.19-SMP
- else
- REQUIRED_LINUX_VER = Advanced Server
- REQUIRED_LINUX_FULLVER = Advanced Server release 2.1AS 64 bit
- REQUIRED_OS_VERSION = 2.4.19-SMP
- endif
- endif
- ifneq ($(ARCH), ia64)
- # ALSA 0.9.1 and above
- REQUIRED_ALSA_VERSION = ^((0[.]9[.][1-9])|(1[.]0[.][0-9]))[0-9]*
- endif
# How much RAM does this machine have:
MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' )
endif
@@ -275,23 +214,15 @@ endif
# Windows with and without CYGWIN will be slightly different
ifeq ($(SYSTEM_UNAME), Windows_NT)
PLATFORM = windows
- OS_VERSION := $(shell uname -r)
- WINDOWS_NT_VERSION_STRING=Windows_NT
- REQUIRED_MKS_VER=6.1
endif
ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
PLATFORM = windows
- OS_VERSION := 5
USING_CYGWIN = true
export USING_CYGWIN
- WINDOWS_NT_VERSION_STRING=CYGWIN_NT
- REQUIRED_CYGWIN_VER=4.0
endif
# Platform settings specific to Windows
ifeq ($(PLATFORM), windows)
- OS_NAME = nt
- REQUIRED_OS_VERSION=5
# Windows builds default to the appropriate for the underlaying
# architecture.
# Temporary disk area
@@ -314,7 +245,6 @@ ifeq ($(PLATFORM), windows)
# If the user wants to perform a cross compile build then they must
# - set ARCH_DATA_MODEL=64 and either
# + set ARCH to ia64 or amd64, or
- REQUIRED_WINDOWS_VERSION=Server 2003 Enterprise x64 Edition
ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)), AMD64)
ARCH=amd64
else
@@ -324,8 +254,6 @@ ifeq ($(PLATFORM), windows)
# Value of Java os.arch property
ARCHPROP=$(LIBARCH)
else
- REQUIRED_WINDOWS_VERSION=2000 or Unknown
- #REQUIRED_WINDOWS_VERSION=XP Professional
# LIBARCH is used to preserve the jre/lib/i386 directory name for 32-bit intel
ARCH=i586
LIBARCH=i386
@@ -364,14 +292,9 @@ ifeq ($(PLATFORM), windows)
ARCH_VM_SUBDIR=jre/bin
# Suffix for file bundles used in previous release
BUNDLE_FILE_SUFFIX=.tar
- # Minimum disk space needed as determined by running 'du -sk' on
- # a fully built workspace.
- REQUIRED_FREE_SPACE=500000
# ISHIELD_TEMP_MIN is the difference of an empty C:\TEMP vs. one after a
# bundles build on windows.
ISHIELD_TEMP_MIN=250000
- REQUIRED_DXSDK_VER = 0x0900
- OS_VENDOR = Microsoft
# How much RAM does this machine have:
ifeq ($(JDK_HAS_MEM_INFO),)
ifeq ($(USING_CYGWIN),true)
@@ -410,10 +333,6 @@ ifeq ($(PLATFORM), windows)
endif
endif
-REQUIRED_ZIP_VER = 2.2
-REQUIRED_UNZIP_VER = 5.12
-REQUIRED_MAKE_VER = 3.78
-
# Unix type settings (same for all unix platforms)
ifneq ($(PLATFORM), windows)
# Temporary disk area
diff --git a/jdk/make/common/shared/Sanity-Settings.gmk b/jdk/make/common/shared/Sanity-Settings.gmk
index f3ea2b35a79..54f1f5fc143 100644
--- a/jdk/make/common/shared/Sanity-Settings.gmk
+++ b/jdk/make/common/shared/Sanity-Settings.gmk
@@ -167,8 +167,6 @@ ALL_SETTINGS+=$(call addRequiredSetting,ARCHPROP)
ifeq ($(PLATFORM),windows)
ALL_SETTINGS+=$(call addRequiredSetting,PROCESSOR_ARCHITECTURE)
ALL_SETTINGS+=$(call addRequiredSetting,PROCESSOR_IDENTIFIER)
- ALL_SETTINGS+=$(call addRequiredSetting,WINDOWS_VERSION)
- ALL_SETTINGS+=$(call addRequiredSetting,WINDOWS_NT_VERSION_STRING)
ifdef USING_CYGWIN
ALL_SETTINGS+=$(call addRequiredSetting,USING_CYGWIN)
ALL_SETTINGS+=$(call addRequiredVersionSetting,CYGWIN_VER)
@@ -179,13 +177,11 @@ ifeq ($(PLATFORM),windows)
endif
endif
ifeq ($(PLATFORM),linux)
- ALL_SETTINGS+=$(call addRequiredSetting,LINUX_VERSION)
- ifneq ($(ARCH), ia64)
- ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION)
- endif
+ ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION)
endif
ALL_SETTINGS+=$(call addRequiredVersionSetting,OS_VERSION)
-ALL_SETTINGS+=$(call addRequiredSetting,OS_NAME)
+ALL_SETTINGS+=$(call addOptionalSetting,OS_VARIANT_NAME)
+ALL_SETTINGS+=$(call addOptionalSetting,OS_VARIANT_VERSION)
ALL_SETTINGS+=$(call addRequiredSetting,TEMP_FREE_SPACE)
ALL_SETTINGS+=$(call addRequiredSetting,FREE_SPACE)
ALL_SETTINGS+=$(call addRequiredSetting,MB_OF_MEMORY)
diff --git a/jdk/make/common/shared/Sanity.gmk b/jdk/make/common/shared/Sanity.gmk
index 997e848904a..a3c421e74b3 100644
--- a/jdk/make/common/shared/Sanity.gmk
+++ b/jdk/make/common/shared/Sanity.gmk
@@ -38,60 +38,106 @@
SANITY_FILES = $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)
# How to say "The Release Engineering people use this"
-THE_OFFICIAL_USES=The official $(PLATFORM) builds use
+THE_OFFICIAL_USES=The official builds on $(PLATFORM) use
# How to say "You are using:"
YOU_ARE_USING=You appear to be using
+# Error message
+define SanityError
+$(ECHO) "ERROR: $1\n" >> $(ERROR_FILE)
+endef
+
+# Warning message
+define SanityWarning
+$(ECHO) "WARNING: $1\n" >> $(WARNING_FILE)
+endef
+
+# Official version error message: name version required_version
+define OfficialErrorMessage
+$(call SanityError,\
+$(THE_OFFICIAL_USES) $1 $3. Your $1 $(if $2,undefined,$2) will not work.)
+endef
+
+# Official version warning message: name version required_version
+define OfficialWarningMessage
+$(call SanityWarning,\
+$(THE_OFFICIAL_USES) $1 $3. $(YOU_ARE_USING) $1 $2.)
+endef
+
+
# Settings and rules to validate the JDK build environment.
ifeq ($(PLATFORM), solaris)
FREE_SPACE := $(shell $(DF) -b $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
TEMP_FREE_SPACE := $(shell $(DF) -b $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
+ # What kind of system we are using (Variations are Solaris and OpenSolaris)
+ OS_VERSION := $(shell uname -r)
+ OS_VARIANT_NAME := $(strip $(shell head -1 /etc/release | awk '{print $$1;}') )
+ OS_VARIANT_VERSION := $(OS_VERSION)
REQ_PATCH_LIST = $(JDK_TOPDIR)/make/PatchList.solaris
ifeq ($(ARCH_FAMILY), sparc)
PATCH_POSITION = $$4
else
PATCH_POSITION = $$6
endif
+ ifndef OPENJDK
+ _GCC_VER :=$(shell $(GCC) -dumpversion 2>&1 )
+ GCC_VER :=$(call GetVersion,"$(_GCC_VER)")
+ endif
endif
ifeq ($(PLATFORM), linux)
FREE_SPACE := $(shell $(DF) --sync -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
TEMP_FREE_SPACE := $(shell $(DF) --sync -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
- ifeq ($(ARCH), amd64)
- LINUX_VERSION := $(shell \
- if [ -r "$(LINUX_VERSION_INFO)" ] ; then \
- $(CAT) $(LINUX_VERSION_INFO) | $(TAIL) -1 | $(NAWK) '{ print $$3; }';\
- else \
- $(ECHO) "Unknown linux"; \
- fi )
- else
- LINUX_VERSION := $(shell \
- if [ -r "$(LINUX_VERSION_INFO)" ] ; then \
- $(NAWK) '{ print $$4" "$$5; }' $(LINUX_VERSION_INFO) ; \
- else \
- $(ECHO) "Unknown linux"; \
- fi )
- endif
- ifneq ($(ARCH), ia64)
- # dummy program that outputs ALSA's version (created in target sane-alsa-versioncheck)
- ALSA_VERSION_CHECK = $(TEMPDIR)/alsaversioncheck
- ALSA_VERSION = `if [ -f "$(ALSA_VERSION_CHECK)" ] ; then $(ALSA_VERSION_CHECK) ; fi`
- endif
+ # What kind of system we are using (Variation is the Linux vendor)
+ OS_VERSION := $(shell uname -r)
+ OS_VARIANT_NAME := $(shell \
+ if [ -f /etc/fedora-release ] ; then \
+ echo "Fedora"; \
+ elif [ -f /etc/redhat-release ] ; then \
+ echo "RedHat"; \
+ elif [ -f /etc/SuSE-release ] ; then \
+ echo "SuSE"; \
+ else \
+ echo "Unknown"; \
+ fi)
+ OS_VARIANT_VERSION := $(shell \
+ if [ "$(OS_VARIANT_NAME)" = "Fedora" ] ; then \
+ $(CAT) /etc/fedora-release | $(HEAD) -1 | $(NAWK) '{ print $$3; }' ; \
+ fi)
+ ALSA_INCLUDE=/usr/include/alsa/version.h
+ ALSA_LIBRARY=/usr/lib/libasound.so
+ _ALSA_VERSION := $(shell $(EGREP) SND_LIB_VERSION_STR $(ALSA_INCLUDE) | \
+ $(SED) -e 's@.*\"\(.*\)\".*@\1@' )
+ ALSA_VERSION := $(call GetVersion,$(_ALSA_VERSION))
endif
ifeq ($(PLATFORM), windows)
FREE_SPACE := $(shell $(DF) -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
TEMP_FREE_SPACE := $(shell $(DF) -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
- # Localized systeminfo has localized labels, but not localized values.
- _WINDOWS_VERSION := \
- $(shell systeminfo 2> $(DEV_NULL) | grep 'Microsoft' | grep 'Windows' | \
- cut -d':' -f2)
- ifeq ($(_WINDOWS_VERSION),)
- _WINDOWS_VERSION := Windows 2000 or Unknown (no systeminfo utility)
+ # Windows 2000 is 5.0, Windows XP is 5.1, Windows 2003 is 5.2
+ # Assume 5.0 (Windows 2000) if systeminfo does not help
+ WINDOWS_MAPPING-5.0 := Windows2000
+ WINDOWS_MAPPING-5.1 := WindowsXP
+ WINDOWS_MAPPING-5.2 := Windows2003
+ # What kind of system we are using (Variation is the common name)
+ _OS_VERSION := \
+ $(shell systeminfo 2> $(DEV_NULL) | \
+ egrep '^OS Version:' | \
+ awk '{print $$3;}' )
+ ifeq ($(_OS_VERSION),)
+ OS_VERSION = 5.0
+ else
+ OS_VERSION = $(_OS_VERSION)
+ endif
+ OS_VARIANT_NAME := $(WINDOWS_MAPPING-$(OS_VERSION))
+ OS_VARIANT_VERSION := $(OS_VERSION)
+ ifdef USING_CYGWIN
+ # CYGWIN version
+ _CYGWIN_VER := $(SYSTEM_UNAME)
+ CYGWIN_VER :=$(call GetVersion,$(_CYGWIN_VER))
endif
- WINDOWS_VERSION := $(strip $(_WINDOWS_VERSION))
DXSDK_VER := $(shell $(EGREP) DIRECT3D_VERSION $(DXSDK_INCLUDE_PATH)/d3d9.h 2>&1 | \
$(EGREP) "\#define" | $(NAWK) '{print $$3}')
endif
@@ -106,7 +152,6 @@ ZIP_VER :=$(call GetVersion,"$(_ZIP_VER)")
UNZIP_VER :=$(call GetVersion,"$(_UNZIP_VER)")
BOOT_VER :=$(call GetVersion,"$(_BOOT_VER)")
-REQUIRED_ANT_VER := 1.6.3
_ANT_VER:=$(shell $(ANT) -version 2>&1 )
ANT_VER:=$(call GetVersion,"$(_ANT_VER)")
@@ -167,7 +212,6 @@ include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk
sane-compiler \
sane-link \
sane-cacerts \
- sane-alsa-versioncheck \
sane-alsa-headers \
sane-ant_version \
sane-zip_version \
@@ -239,35 +283,29 @@ sane-arch_data_model:
# generate a fatal sanity error, and a warning about the official
# build platform just becomes clutter.
######################################################
-OS_CHECK :=$(call CheckVersions,$(OS_VERSION),$(REQUIRED_OS_VERSION))
+ifndef OPENJDK
+ OS_VERSION_CHECK := \
+ $(call CheckVersions,$(OS_VERSION),$(REQUIRED_OS_VERSION))
+ ifeq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
+ OS_VARIANT_VERSION_CHECK := \
+ $(call CheckVersions,$(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION))
+ endif
+endif
sane-os_version:: sane-arch_data_model sane-memory_check sane-locale sane-os_patch_level
ifndef OPENJDK
- @if [ "$(OS_CHECK)" = "missing" ]; then \
- $(ECHO) "ERROR: The $(PLATFORM) OS version is undefined (Try: uname -r). \n" \
- "" >> $(ERROR_FILE) ; \
- fi
- @if [ "$(OS_CHECK)" != "same" ]; then \
- $(ECHO) "WARNING: $(THE_OFFICIAL_USES) OS version $(REQUIRED_OS_VERSION). \n" \
- " $(YOU_ARE_USING) OS version $(OS_VERSION). \n" \
- "" >> $(WARNING_FILE) ; \
- fi
- ifeq ($(PLATFORM), windows)
- @if [ "$(findstring $(REQUIRED_WINDOWS_VERSION),$(WINDOWS_VERSION))" = "" ]; then \
- $(ECHO) "WARNING: $(YOU_ARE_USING) an unknown version of Windows. \n" \
- " The required version is $(REQUIRED_WINDOWS_VERSION). \n" \
- " $(YOU_ARE_USING) $(WINDOWS_VERSION) \n" \
- "" >> $(WARNING_FILE) ; \
- fi
- endif # windows
- ifeq ($(PLATFORM), linux)
- @if [ `$(ECHO) "$(LINUX_VERSION)" | $(EGREP) -c '$(REQUIRED_LINUX_VER)'` -ne 1 ]; then \
- $(ECHO) "WARNING: The build is being done on Linux $(LINUX_VERSION). \n" \
- " $(THE_OFFICIAL_USES) Linux $(REQUIRED_LINUX_VER), \n" \
- " specifically Linux $(REQUIRED_LINUX_FULLVER). \n" \
- " The version found was '$(OS_VERSION)'. \n" \
- "" >> $(WARNING_FILE) ; \
- fi
- endif # linux
+ ifneq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
+ ifeq ($(OS_VERSION_CHECK),missing)
+ @$(call OfficialErrorMessage,OS version,$(OS_VERSION),$(REQUIRED_OS_VERSION))
+ endif
+ ifneq ($(OS_VERSION_CHECK),same)
+ @$(call OfficialWarningMessage,OS version,$(OS_VERSION),$(REQUIRED_OS_VERSION))
+ endif
+ @$(call OfficialWarningMessage,OS variant,$(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
+ else
+ ifneq ($(OS_VARIANT_VERSION_CHECK),same)
+ @$(call OfficialWarningMessage,$(OS_VARIANT_NAME) version,$(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION))
+ endif
+ endif
endif # OPENJDK
ifeq ($(PLATFORM), windows)
@@ -308,16 +346,12 @@ ifeq ($(PLATFORM), windows)
CYGWIN_CHECK :=$(call CheckVersions,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
sane-cygwin:
ifdef USING_CYGWIN
- @if [ "$(CYGWIN_CHECK)" = "missing" ]; then \
- $(ECHO) "ERROR: The CYGWIN version is undefined. \n" \
- " $(THE_OFFICIAL_USES) CYGWIN $(REQUIRED_CYGWIN_VER). \n" \
- "" >> $(ERROR_FILE) ; \
- fi
- @if [ "$(CYGWIN_CHECK)" = "older" ]; then \
- $(ECHO) "ERROR: The build cannot be done on CYGWIN $(CYGWIN_VER). \n" \
- " Use CYGWIN $(REQUIRED_CYGWIN_VER) or higher. \n" \
- "" >> $(ERROR_FILE) ; \
- fi
+ ifeq ($(CYGWIN_CHECK),missing)
+ @$(call OfficialErrorMessage,CYGWIN version,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
+ endif
+ ifeq ($(CYGWIN_CHECK),older)
+ @$(call OfficialWarningMessage,CYGWIN version,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
+ endif
endif
endif
@@ -345,16 +379,12 @@ ifeq ($(PLATFORM), windows)
MKS_CHECK :=$(call CheckVersions,$(MKS_VER),$(REQUIRED_MKS_VER))
sane-mks:
ifndef USING_CYGWIN
- @if [ "$(MKS_CHECK)" = "missing" ]; then \
- $(ECHO) "ERROR: The MKS version is undefined. \n" \
- " $(THE_OFFICIAL_USES) MKS $(REQUIRED_MKS_VER). \n" \
- "" >> $(ERROR_FILE) ; \
- fi
- @if [ "$(MKS_CHECK)" = "older" ]; then \
- $(ECHO) "ERROR: The build cannot be done on MKS $(MKS_VER). \n" \
- " Use MKS $(REQUIRED_MKS_VER) or higher. \n" \
- "" >> $(ERROR_FILE) ; \
- fi
+ ifeq ($(MKS_CHECK),missing)
+ @$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER))
+ endif
+ ifeq ($(MKS_CHECK),older)
+ @$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER))
+ endif
endif
endif
@@ -1295,11 +1325,6 @@ endif
# Check the compiler version(s)
######################################################
CC_CHECK :=$(call CheckVersions,$(CC_VER),$(REQUIRED_CC_VER))
-ifeq ($(PLATFORM), solaris)
- ifeq ($(ARCH_DATA_MODEL), 32)
- GCC_CHECK :=$(call CheckVersions,$(GCC_VER),$(REQUIRED_GCC_VER))
- endif
-endif
sane-compiler: sane-link
@if [ "$(CC_CHECK)" = "missing" ]; then \
$(ECHO) "ERROR: The Compiler version is undefined. \n" \
@@ -1314,16 +1339,6 @@ ifndef OPENJDK
" $(COMPILER_PATH) \n" \
"" >> $(WARNING_FILE) ; \
fi
- ifdef GCC_CHECK
- @if [ "$(GCC_CHECK)" != "same" ]; then \
- $(ECHO) "WARNING: The $(PLATFORM) GCC compiler must be version $(REQUIRED_GCC_VER) \n" \
- " $(YOU_ARE_USING) compiler version: $(GCC_VER) \n" \
- " The compiler was obtained from the following location: \n" \
- " $(GCC_COMPILER_PATH) \n" \
- " Please change your compiler. \n" \
- "" >> $(WARNING_FILE) ; \
- fi
- endif
ifeq ($(PLATFORM), windows)
ifeq ($(ARCH_DATA_MODEL), 64)
ifneq ($(COMPILER_VERSION), VS2005)
@@ -1337,39 +1352,24 @@ endif
######################################################
# Check that ALSA headers and libs are installed and
# that the header has the right version. We only
-# need /usr/include/alsa/*.h and /usr/lib/libasound.so
+# need /usr/include/alsa/version.h and /usr/lib/libasound.so
######################################################
-ifdef ALSA_VERSION_CHECK
-$(ALSA_VERSION_CHECK): $(ALSA_VERSION_CHECK).c
- @$(prep-target)
- @$(CC) -lasound -o $@ $<
-
-$(ALSA_VERSION_CHECK).c:
- @$(prep-target)
- @$(ECHO) "#include \n" \
- "#include \n" \
- "int main(int argc, char** argv) {\n" \
- " printf(\"%s\", SND_LIB_VERSION_STR);\n" \
- " return 0;\n" \
- "}\n" \
- > $@
+ifdef REQUIRED_ALSA_VERSION
+ ALSA_CHECK := $(call CheckVersions,$(ALSA_VERSION),$(REQUIRED_ALSA_VERSION))
endif
-
-sane-alsa-versioncheck: $(ALSA_VERSION_CHECK)
-sane-alsa-headers: sane-alsa-versioncheck
-ifdef ALSA_VERSION_CHECK
- @if [ -f "$(ALSA_VERSION_CHECK)" ]; then \
- if [ `$(ALSA_VERSION_CHECK) | $(EGREP) -c '$(REQUIRED_ALSA_VERSION)'` -ne 1 ] ; then \
- $(ECHO) "ERROR: The ALSA version must be 0.9.1 or higher. \n" \
- " You have the following ALSA version installed: $(ALSA_VERSION) \n" \
+sane-alsa-headers:
+ifdef REQUIRED_ALSA_VERSION
+ if [ "$(ALSA_CHECK)" != "same" -a "$(ALSA_CHECK)" != "newer" ] ; then \
+ $(ECHO) "ERROR: The ALSA version must be $(REQUIRED_ALSA_VERSION) or higher. \n" \
+ " You have the following ALSA version installed: $${alsa_version) \n" \
" Please reinstall ALSA (drivers and lib). You can download \n" \
" the source distribution from http://www.alsa-project.org \n" \
" or go to http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \
"" >> $(ERROR_FILE) ; \
fi \
else \
- $(ECHO) "ERROR: You seem to not have installed ALSA 0.9.1 or higher. \n" \
+ $(ECHO) "ERROR: You seem to not have installed ALSA $(REQUIRED_ALSA_VERSION) or higher. \n" \
" Please install ALSA (drivers and lib). You can download the \n" \
" source distribution from http://www.alsa-project.org or go to \n" \
" http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \
@@ -1384,7 +1384,7 @@ $(SANITY_FILES):
######################################################
# dump out the variable settings...
######################################################
-sane-settings:: sane-alsa-versioncheck
+sane-settings::
@$(ECHO) >> $(MESSAGE_FILE)
@$(ECHO) $(ALL_SETTINGS) >> $(MESSAGE_FILE)
@$(ECHO) >> $(MESSAGE_FILE)
@@ -1453,8 +1453,8 @@ sane-gcc-compiler:
ifeq ($(PLATFORM), solaris)
ifndef OPENJDK
@if [ -r $(GCC_COMPILER_PATH) ]; then \
- if [ ! "$(GCC_VER)" = 2.95.2 ]; then \
- $(ECHO) "ERROR: The Solaris GCC compiler version must be 2.95.2. \n" \
+ if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \
+ $(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION). \n" \
" You are using the following compiler version: $(GCC_VER) \n" \
" The compiler was obtained from the following location: \n" \
" $(GCC_COMPILER_PATH) \n" \
From b56f07314820fea8178028ee1b80ea6a924bd2e1 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Wed, 4 Feb 2009 14:06:18 +0300
Subject: [PATCH 019/283] 6799583: LogManager shutdown hook may cause a memory
leak
Reviewed-by: igor, swamyv
---
.../classes/java/util/logging/LogManager.java | 8 +
.../util/logging/ClassLoaderLeakTest.java | 190 ++++++++++++++++++
2 files changed, 198 insertions(+)
create mode 100644 jdk/test/java/util/logging/ClassLoaderLeakTest.java
diff --git a/jdk/src/share/classes/java/util/logging/LogManager.java b/jdk/src/share/classes/java/util/logging/LogManager.java
index 412f749404d..fc8f080eb71 100644
--- a/jdk/src/share/classes/java/util/logging/LogManager.java
+++ b/jdk/src/share/classes/java/util/logging/LogManager.java
@@ -215,6 +215,14 @@ public class LogManager {
// This private class is used as a shutdown hook.
// It does a "reset" to close all open handlers.
private class Cleaner extends Thread {
+
+ private Cleaner() {
+ /* Set context class loader to null in order to avoid
+ * keeping a strong reference to an application classloader.
+ */
+ this.setContextClassLoader(null);
+ }
+
public void run() {
// This is to ensure the LogManager. is completed
// before synchronized block. Otherwise deadlocks are possible.
diff --git a/jdk/test/java/util/logging/ClassLoaderLeakTest.java b/jdk/test/java/util/logging/ClassLoaderLeakTest.java
new file mode 100644
index 00000000000..988041472fc
--- /dev/null
+++ b/jdk/test/java/util/logging/ClassLoaderLeakTest.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6799583
+ *
+ * @summary Test verifes that LogManager shutdown hook does not cause
+ * an application classloader leaks.
+ *
+ * @run main/othervm ClassLoaderLeakTest
+ */
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.concurrent.CountDownLatch;
+import java.util.logging.Logger;
+import java.util.logging.Logger;
+
+public class ClassLoaderLeakTest {
+
+ private static CountDownLatch doneSignal;
+ private static CountDownLatch launchSignal;
+ private static ThreadGroup appsThreadGroup;
+ private static Throwable launchFailure = null;
+
+ public static void main(String[] args) {
+ appsThreadGroup = new ThreadGroup("MyAppsThreadGroup");
+ doneSignal = new CountDownLatch(1);
+ launchSignal = new CountDownLatch(1);
+
+ Runnable launcher = new Runnable() {
+ public void run() {
+ try {
+ ClassLoader cl =
+ Thread.currentThread().getContextClassLoader();
+ Class appMain = cl.loadClass("AppTest");
+ Method launch =
+ appMain.getDeclaredMethod("launch", doneSignal.getClass());
+
+ Constructor c = appMain.getConstructor();
+
+ Object o = c.newInstance();
+
+ launch.invoke(o, doneSignal);
+
+ } catch (Throwable e) {
+ launchFailure = e;
+ } finally {
+ launchSignal.countDown();
+ }
+ }
+ };
+
+ /* prepare test class loader */
+ URL pwd = null;
+ try {
+
+ pwd = new File(System.getProperty("test.classes",".")).toURL();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Test failed.", e);
+ }
+ URL[] urls = new URL[] { pwd };
+
+ MyClassLoader appClassLoader = new MyClassLoader(urls, "test0");
+ WeakReference ref =
+ new WeakReference(appClassLoader);
+
+
+ Thread appThread = new Thread(appsThreadGroup, launcher, "AppThread-0");
+ appThread.setContextClassLoader(appClassLoader);
+
+ appThread.start();
+ appClassLoader = null;
+ launcher = null;
+ appThread = null;
+
+ /* wait for laucnh completion */
+ try {
+ launchSignal.await();
+ } catch (InterruptedException e) {
+ }
+
+ /* check if launch failed */
+ if (launchFailure != null) {
+ throw new RuntimeException("Test failed.", launchFailure);
+ }
+
+ /* wait for test app excution completion */
+ try {
+ doneSignal.await();
+ } catch (InterruptedException e) {
+ }
+
+ /* give a chence to GC */
+ waitAndGC(5);
+
+ if (ref.get() != null) {
+ throw new RuntimeException("Test failed: classloader is still alive");
+ }
+
+ System.out.println("Test passed.");
+ }
+
+ private static class MyClassLoader extends URLClassLoader {
+
+ private static boolean verbose =
+ Boolean.getBoolean("verboseClassLoading");
+ private String uniqClassName;
+
+ public MyClassLoader(URL[] urls, String uniq) {
+ super(urls);
+
+ uniqClassName = uniq;
+ }
+
+ public Class loadClass(String name) throws ClassNotFoundException {
+ if (verbose) {
+ System.out.printf("%s: load class %s\n", uniqClassName, name);
+ }
+ if (uniqClassName.equals(name)) {
+ return Object.class;
+ }
+ return super.loadClass(name);
+ }
+
+ public String toString() {
+ return "MyClassLoader(" + uniqClassName + ")";
+ }
+ }
+
+ private static void waitAndGC(int sec) {
+ int cnt = sec;
+ System.out.print("Wait ");
+ while (cnt-- > 0) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ // do GC every 3 seconds
+ if (cnt % 3 == 2) {
+ System.gc();
+ System.out.print("+");
+ } else {
+ System.out.print(".");
+ }
+ //checkErrors();
+ }
+ System.out.println("");
+ }
+}
+
+
+class AppTest {
+ public AppTest() {
+
+ }
+
+ public void launch(CountDownLatch done) {
+ Logger log = Logger.getLogger("app_test_logger");
+ log.fine("Test app is launched");
+
+ done.countDown();
+ }
+}
From 06d5f1e07f8ba64f7fb29daf7b717e533c93dce1 Mon Sep 17 00:00:00 2001
From: Peter Zhelezniakov
Date: Wed, 4 Feb 2009 18:48:24 +0300
Subject: [PATCH 020/283] 6588003: LayoutQueue shares mutable implementation
across AppContexts
DefaultQueue property is made per-AppContext
Reviewed-by: alexp
---
.../classes/javax/swing/text/LayoutQueue.java | 31 +++++++---
.../swing/text/LayoutQueue/Test6588003.java | 59 +++++++++++++++++++
2 files changed, 81 insertions(+), 9 deletions(-)
create mode 100644 jdk/test/javax/swing/text/LayoutQueue/Test6588003.java
diff --git a/jdk/src/share/classes/javax/swing/text/LayoutQueue.java b/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
index e02f9b0f9b6..dbb5d00ccce 100644
--- a/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
+++ b/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
@@ -25,6 +25,7 @@
package javax.swing.text;
import java.util.Vector;
+import sun.awt.AppContext;
/**
* A queue of text layout tasks.
@@ -35,10 +36,10 @@ import java.util.Vector;
*/
public class LayoutQueue {
- Vector tasks;
- Thread worker;
+ private static final Object DEFAULT_QUEUE = new Object();
- static LayoutQueue defaultQueue;
+ private Vector tasks;
+ private Thread worker;
/**
* Construct a layout queue.
@@ -51,19 +52,31 @@ public class LayoutQueue {
* Fetch the default layout queue.
*/
public static LayoutQueue getDefaultQueue() {
- if (defaultQueue == null) {
- defaultQueue = new LayoutQueue();
+ AppContext ac = AppContext.getAppContext();
+ synchronized (DEFAULT_QUEUE) {
+ LayoutQueue defaultQueue = (LayoutQueue) ac.get(DEFAULT_QUEUE);
+ if (defaultQueue == null) {
+ defaultQueue = new LayoutQueue();
+ ac.put(DEFAULT_QUEUE, defaultQueue);
+ }
+ return defaultQueue;
}
- return defaultQueue;
}
/**
* Set the default layout queue.
*
- * @param q the new queue.
+ * @param defaultQueue the new queue.
*/
- public static void setDefaultQueue(LayoutQueue q) {
- defaultQueue = q;
+ public static void setDefaultQueue(LayoutQueue defaultQueue) {
+ synchronized (DEFAULT_QUEUE) {
+ AppContext ac = AppContext.getAppContext();
+ if (defaultQueue == null) {
+ ac.remove(DEFAULT_QUEUE);
+ } else {
+ ac.put(DEFAULT_QUEUE, defaultQueue);
+ }
+ }
}
/**
diff --git a/jdk/test/javax/swing/text/LayoutQueue/Test6588003.java b/jdk/test/javax/swing/text/LayoutQueue/Test6588003.java
new file mode 100644
index 00000000000..d14d6a56a95
--- /dev/null
+++ b/jdk/test/javax/swing/text/LayoutQueue/Test6588003.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 6588003
+ @summary LayoutQueue should not share its DefaultQueue across AppContexts
+ @author Peter Zhelezniakov
+ @run main Test6588003
+*/
+
+import javax.swing.text.LayoutQueue;
+import sun.awt.SunToolkit;
+
+public class Test6588003 implements Runnable {
+ private static final LayoutQueue DEFAULT = new LayoutQueue();
+
+ public static void main(String[] args) throws InterruptedException {
+ LayoutQueue.setDefaultQueue(DEFAULT);
+
+ ThreadGroup group = new ThreadGroup("Test6588003");
+ Thread thread = new Thread(group, new Test6588003());
+ thread.start();
+ thread.join();
+
+ if (LayoutQueue.getDefaultQueue() != DEFAULT) {
+ throw new RuntimeException("Sharing detected");
+ }
+ }
+
+ public void run() {
+ SunToolkit.createNewAppContext();
+
+ if (LayoutQueue.getDefaultQueue() == DEFAULT) {
+ throw new RuntimeException("Sharing detected");
+ }
+
+ LayoutQueue.setDefaultQueue(new LayoutQueue());
+ }
+}
From 837ece487dd4c28c9d20b914695e5eae5277bb24 Mon Sep 17 00:00:00 2001
From: Sergey Malenkov
Date: Thu, 5 Feb 2009 14:48:10 +0300
Subject: [PATCH 021/283] 4769844: classes in java.beans that are serializable
but don't define serialVersionUID
Reviewed-by: peterz, rupashka
---
.../share/classes/java/beans/IndexedPropertyChangeEvent.java | 3 ++-
jdk/src/share/classes/java/beans/IntrospectionException.java | 3 ++-
jdk/src/share/classes/java/beans/PropertyChangeEvent.java | 3 ++-
jdk/src/share/classes/java/beans/PropertyVetoException.java | 4 ++--
.../classes/java/beans/beancontext/BeanContextEvent.java | 3 ++-
.../java/beans/beancontext/BeanContextMembershipEvent.java | 3 ++-
.../beans/beancontext/BeanContextServiceAvailableEvent.java | 3 ++-
.../beans/beancontext/BeanContextServiceRevokedEvent.java | 3 ++-
.../java/beans/beancontext/BeanContextServicesSupport.java | 4 +++-
jdk/src/share/classes/sun/beans/editors/ColorEditor.java | 4 +++-
jdk/src/share/classes/sun/beans/editors/FontEditor.java | 3 ++-
11 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java b/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
index ea78643e435..951cd871fe5 100644
--- a/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. 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
@@ -41,6 +41,7 @@ package java.beans;
* @author Mark Davidson
*/
public class IndexedPropertyChangeEvent extends PropertyChangeEvent {
+ private static final long serialVersionUID = -320227448495806870L;
private int index;
diff --git a/jdk/src/share/classes/java/beans/IntrospectionException.java b/jdk/src/share/classes/java/beans/IntrospectionException.java
index cac0b20fc01..2f5a65eda73 100644
--- a/jdk/src/share/classes/java/beans/IntrospectionException.java
+++ b/jdk/src/share/classes/java/beans/IntrospectionException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. 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
@@ -36,6 +36,7 @@ package java.beans;
public
class IntrospectionException extends Exception {
+ private static final long serialVersionUID = -3728150539969542619L;
/**
* Constructs an IntrospectionException
with a
diff --git a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
index 69f523d92e3..3e0c9cef6f9 100644
--- a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
+++ b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. 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
@@ -44,6 +44,7 @@ package java.beans;
*/
public class PropertyChangeEvent extends java.util.EventObject {
+ private static final long serialVersionUID = 7042693688939648123L;
/**
* Constructs a new PropertyChangeEvent
.
diff --git a/jdk/src/share/classes/java/beans/PropertyVetoException.java b/jdk/src/share/classes/java/beans/PropertyVetoException.java
index f736b3bade5..73376496b53 100644
--- a/jdk/src/share/classes/java/beans/PropertyVetoException.java
+++ b/jdk/src/share/classes/java/beans/PropertyVetoException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-1998 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. 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
@@ -33,7 +33,7 @@ package java.beans;
public
class PropertyVetoException extends Exception {
-
+ private static final long serialVersionUID = 129596057694162164L;
/**
* Constructs a PropertyVetoException
with a
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextEvent.java
index 4574605a154..2530869534b 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -48,6 +48,7 @@ import java.beans.beancontext.BeanContext;
*/
public abstract class BeanContextEvent extends EventObject {
+ private static final long serialVersionUID = 7267998073569045052L;
/**
* Contruct a BeanContextEvent
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
index 7e6c1ae0a69..3752e390341 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -55,6 +55,7 @@ import java.util.Iterator;
* @see java.beans.beancontext.BeanContextMembershipListener
*/
public class BeanContextMembershipEvent extends BeanContextEvent {
+ private static final long serialVersionUID = 3499346510334590959L;
/**
* Contruct a BeanContextMembershipEvent
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java
index 558c7f9f363..7bb47a66033 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. 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
@@ -40,6 +40,7 @@ import java.util.Iterator;
*/
public class BeanContextServiceAvailableEvent extends BeanContextEvent {
+ private static final long serialVersionUID = -5333985775656400778L;
/**
* Construct a BeanContextAvailableServiceEvent
.
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java
index a508f4ca157..50d888cdf7e 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. 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
@@ -37,6 +37,7 @@ import java.beans.beancontext.BeanContextServices;
*
*/
public class BeanContextServiceRevokedEvent extends BeanContextEvent {
+ private static final long serialVersionUID = -1295543154724961754L;
/**
* Construct a BeanContextServiceEvent
.
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java
index d9552c8a34e..54dfdd7d227 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2009 Sun Microsystems, Inc. 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
@@ -60,6 +60,7 @@ import java.util.Locale;
public class BeanContextServicesSupport extends BeanContextSupport
implements BeanContextServices {
+ private static final long serialVersionUID = -8494482757288719206L;
/**
*
@@ -594,6 +595,7 @@ public class BeanContextServicesSupport extends BeanContextSupport
*/
protected static class BCSSServiceProvider implements Serializable {
+ private static final long serialVersionUID = 861278251667444782L;
BCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) {
super();
diff --git a/jdk/src/share/classes/sun/beans/editors/ColorEditor.java b/jdk/src/share/classes/sun/beans/editors/ColorEditor.java
index a3610e0ee2e..55dd9137be1 100644
--- a/jdk/src/share/classes/sun/beans/editors/ColorEditor.java
+++ b/jdk/src/share/classes/sun/beans/editors/ColorEditor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. 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
@@ -29,6 +29,8 @@ import java.awt.*;
import java.beans.*;
public class ColorEditor extends Panel implements PropertyEditor {
+ private static final long serialVersionUID = 1781257185164716054L;
+
public ColorEditor() {
setLayout(null);
diff --git a/jdk/src/share/classes/sun/beans/editors/FontEditor.java b/jdk/src/share/classes/sun/beans/editors/FontEditor.java
index 88de9aea48f..04d4c187e22 100644
--- a/jdk/src/share/classes/sun/beans/editors/FontEditor.java
+++ b/jdk/src/share/classes/sun/beans/editors/FontEditor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. 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
@@ -29,6 +29,7 @@ import java.awt.*;
import java.beans.*;
public class FontEditor extends Panel implements java.beans.PropertyEditor {
+ private static final long serialVersionUID = 6732704486002715933L;
public FontEditor() {
setLayout(null);
From 8f96eb9cea9b9b3886bb21a76da4aa9bcc5dc0a6 Mon Sep 17 00:00:00 2001
From: Sergey Malenkov
Date: Thu, 5 Feb 2009 17:00:57 +0300
Subject: [PATCH 022/283] 6669869: Beans.isDesignTime() and other queries
should be per-AppContext
Reviewed-by: peterz, rupashka
---
jdk/src/share/classes/java/beans/Beans.java | 96 ++++++++++---------
.../beans/Beans/6669869/TestDesignTime.java | 52 ++++++++++
.../beans/Beans/6669869/TestGuiAvailable.java | 53 ++++++++++
3 files changed, 158 insertions(+), 43 deletions(-)
create mode 100644 jdk/test/java/beans/Beans/6669869/TestDesignTime.java
create mode 100644 jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
diff --git a/jdk/src/share/classes/java/beans/Beans.java b/jdk/src/share/classes/java/beans/Beans.java
index f19b21aead2..8a750a8b15c 100644
--- a/jdk/src/share/classes/java/beans/Beans.java
+++ b/jdk/src/share/classes/java/beans/Beans.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1996-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1996-2009 Sun Microsystems, Inc. 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
@@ -27,26 +27,41 @@ package java.beans;
import com.sun.beans.finder.ClassFinder;
-import java.applet.*;
+import java.applet.Applet;
+import java.applet.AppletContext;
+import java.applet.AppletStub;
+import java.applet.AudioClip;
-import java.awt.*;
-
-import java.beans.AppletInitializer;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
import java.beans.beancontext.BeanContext;
-import java.io.*;
-
-import java.lang.reflect.Constructor;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.io.StreamCorruptedException;
import java.net.URL;
-import java.lang.reflect.Array;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import sun.awt.AppContext;
/**
* This class provides some general purpose beans control methods.
*/
public class Beans {
+ private static final Object DESIGN_TIME = new Object();
+ private static final Object GUI_AVAILABLE = new Object();
/**
*
@@ -59,12 +74,12 @@ public class Beans {
* @param beanName the name of the bean within the class-loader.
* For example "sun.beanbox.foobah"
*
- * @exception java.lang.ClassNotFoundException if the class of a serialized
+ * @exception ClassNotFoundException if the class of a serialized
* object could not be found.
- * @exception java.io.IOException if an I/O error occurs.
+ * @exception IOException if an I/O error occurs.
*/
- public static Object instantiate(ClassLoader cls, String beanName) throws java.io.IOException, ClassNotFoundException {
+ public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException {
return Beans.instantiate(cls, beanName, null, null);
}
@@ -80,12 +95,12 @@ public class Beans {
* For example "sun.beanbox.foobah"
* @param beanContext The BeanContext in which to nest the new bean
*
- * @exception java.lang.ClassNotFoundException if the class of a serialized
+ * @exception ClassNotFoundException if the class of a serialized
* object could not be found.
- * @exception java.io.IOException if an I/O error occurs.
+ * @exception IOException if an I/O error occurs.
*/
- public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws java.io.IOException, ClassNotFoundException {
+ public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException {
return Beans.instantiate(cls, beanName, beanContext, null);
}
@@ -135,19 +150,19 @@ public class Beans {
* @param beanContext The BeanContext in which to nest the new bean
* @param initializer The AppletInitializer for the new bean
*
- * @exception java.lang.ClassNotFoundException if the class of a serialized
+ * @exception ClassNotFoundException if the class of a serialized
* object could not be found.
- * @exception java.io.IOException if an I/O error occurs.
+ * @exception IOException if an I/O error occurs.
*/
public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer)
- throws java.io.IOException, ClassNotFoundException {
+ throws IOException, ClassNotFoundException {
- java.io.InputStream ins;
- java.io.ObjectInputStream oins = null;
+ InputStream ins;
+ ObjectInputStream oins = null;
Object result = null;
boolean serialized = false;
- java.io.IOException serex = null;
+ IOException serex = null;
// If the given classloader is null, we check if an
// system classloader is available and (if so)
@@ -166,8 +181,8 @@ public class Beans {
// Try to find a serialized object with this name
final String serName = beanName.replace('.','/').concat(".ser");
final ClassLoader loader = cls;
- ins = (InputStream)java.security.AccessController.doPrivileged
- (new java.security.PrivilegedAction() {
+ ins = (InputStream)AccessController.doPrivileged
+ (new PrivilegedAction() {
public Object run() {
if (loader == null)
return ClassLoader.getSystemResourceAsStream(serName);
@@ -185,7 +200,7 @@ public class Beans {
result = oins.readObject();
serialized = true;
oins.close();
- } catch (java.io.IOException ex) {
+ } catch (IOException ex) {
ins.close();
// Drop through and try opening the class. But remember
// the exception in case we can't find the class either.
@@ -264,8 +279,8 @@ public class Beans {
final ClassLoader cloader = cls;
objectUrl = (URL)
- java.security.AccessController.doPrivileged
- (new java.security.PrivilegedAction() {
+ AccessController.doPrivileged
+ (new PrivilegedAction() {
public Object run() {
if (cloader == null)
return ClassLoader.getSystemResource
@@ -377,10 +392,11 @@ public class Beans {
* @return True if we are running in an application construction
* environment.
*
- * @see java.beans.DesignMode
+ * @see DesignMode
*/
public static boolean isDesignTime() {
- return designTime;
+ Object value = AppContext.getAppContext().get(DESIGN_TIME);
+ return (value instanceof Boolean) && (Boolean) value;
}
/**
@@ -393,11 +409,12 @@ public class Beans {
* false in a server environment or if an application is
* running as part of a batch job.
*
- * @see java.beans.Visibility
+ * @see Visibility
*
*/
public static boolean isGuiAvailable() {
- return guiAvailable;
+ Object value = AppContext.getAppContext().get(GUI_AVAILABLE);
+ return (value instanceof Boolean) ? (Boolean) value : !GraphicsEnvironment.isHeadless();
}
/**
@@ -423,7 +440,7 @@ public class Beans {
if (sm != null) {
sm.checkPropertiesAccess();
}
- designTime = isDesignTime;
+ AppContext.getAppContext().put(DESIGN_TIME, Boolean.valueOf(isDesignTime));
}
/**
@@ -449,14 +466,7 @@ public class Beans {
if (sm != null) {
sm.checkPropertiesAccess();
}
- guiAvailable = isGuiAvailable;
- }
-
-
- private static boolean designTime;
- private static boolean guiAvailable;
- static {
- guiAvailable = !GraphicsEnvironment.isHeadless();
+ AppContext.getAppContext().put(GUI_AVAILABLE, Boolean.valueOf(isGuiAvailable));
}
}
@@ -501,7 +511,7 @@ class ObjectInputStreamWithLoader extends ObjectInputStream
class BeansAppletContext implements AppletContext {
Applet target;
- java.util.Hashtable imageCache = new java.util.Hashtable();
+ Hashtable imageCache = new Hashtable();
BeansAppletContext(Applet target) {
this.target = target;
@@ -546,8 +556,8 @@ class BeansAppletContext implements AppletContext {
return null;
}
- public java.util.Enumeration getApplets() {
- java.util.Vector applets = new java.util.Vector();
+ public Enumeration getApplets() {
+ Vector applets = new Vector();
applets.addElement(target);
return applets.elements();
}
@@ -573,7 +583,7 @@ class BeansAppletContext implements AppletContext {
return null;
}
- public java.util.Iterator getStreamKeys(){
+ public Iterator getStreamKeys(){
// We do nothing.
return null;
}
diff --git a/jdk/test/java/beans/Beans/6669869/TestDesignTime.java b/jdk/test/java/beans/Beans/6669869/TestDesignTime.java
new file mode 100644
index 00000000000..e78142a2b90
--- /dev/null
+++ b/jdk/test/java/beans/Beans/6669869/TestDesignTime.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6669869
+ * @summary Tests DesignTime property in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import java.beans.Beans;
+import sun.awt.SunToolkit;
+
+public class TestDesignTime implements Runnable {
+ public static void main(String[] args) throws InterruptedException {
+ if (Beans.isDesignTime()) {
+ throw new Error("unexpected DesignTime property");
+ }
+ Beans.setDesignTime(!Beans.isDesignTime());
+ ThreadGroup group = new ThreadGroup("$$$");
+ Thread thread = new Thread(group, new TestDesignTime());
+ thread.start();
+ thread.join();
+ }
+
+ public void run() {
+ SunToolkit.createNewAppContext();
+ if (Beans.isDesignTime()) {
+ throw new Error("shared DesignTime property");
+ }
+ }
+}
diff --git a/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java b/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
new file mode 100644
index 00000000000..7144b6fad3b
--- /dev/null
+++ b/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6669869
+ * @summary Tests GuiAvailable property in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import java.awt.GraphicsEnvironment;
+import java.beans.Beans;
+import sun.awt.SunToolkit;
+
+public class TestGuiAvailable implements Runnable {
+ public static void main(String[] args) throws InterruptedException {
+ if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
+ throw new Error("unexpected GuiAvailable property");
+ }
+ Beans.setGuiAvailable(!Beans.isGuiAvailable());
+ ThreadGroup group = new ThreadGroup("$$$");
+ Thread thread = new Thread(group, new TestGuiAvailable());
+ thread.start();
+ thread.join();
+ }
+
+ public void run() {
+ SunToolkit.createNewAppContext();
+ if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
+ throw new Error("shared GuiAvailable property");
+ }
+ }
+}
From a21476939e4a000ab5ee85f0939c99b4afb80312 Mon Sep 17 00:00:00 2001
From: Peter Zhelezniakov
Date: Thu, 5 Feb 2009 19:16:13 +0300
Subject: [PATCH 023/283] 6801769: 6588003 should be backed out from jdk7
Reviewed-by: alexp
---
.../classes/javax/swing/text/LayoutQueue.java | 31 ++++++-------------
1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/jdk/src/share/classes/javax/swing/text/LayoutQueue.java b/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
index dbb5d00ccce..e02f9b0f9b6 100644
--- a/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
+++ b/jdk/src/share/classes/javax/swing/text/LayoutQueue.java
@@ -25,7 +25,6 @@
package javax.swing.text;
import java.util.Vector;
-import sun.awt.AppContext;
/**
* A queue of text layout tasks.
@@ -36,10 +35,10 @@ import sun.awt.AppContext;
*/
public class LayoutQueue {
- private static final Object DEFAULT_QUEUE = new Object();
+ Vector tasks;
+ Thread worker;
- private Vector tasks;
- private Thread worker;
+ static LayoutQueue defaultQueue;
/**
* Construct a layout queue.
@@ -52,31 +51,19 @@ public class LayoutQueue {
* Fetch the default layout queue.
*/
public static LayoutQueue getDefaultQueue() {
- AppContext ac = AppContext.getAppContext();
- synchronized (DEFAULT_QUEUE) {
- LayoutQueue defaultQueue = (LayoutQueue) ac.get(DEFAULT_QUEUE);
- if (defaultQueue == null) {
- defaultQueue = new LayoutQueue();
- ac.put(DEFAULT_QUEUE, defaultQueue);
- }
- return defaultQueue;
+ if (defaultQueue == null) {
+ defaultQueue = new LayoutQueue();
}
+ return defaultQueue;
}
/**
* Set the default layout queue.
*
- * @param defaultQueue the new queue.
+ * @param q the new queue.
*/
- public static void setDefaultQueue(LayoutQueue defaultQueue) {
- synchronized (DEFAULT_QUEUE) {
- AppContext ac = AppContext.getAppContext();
- if (defaultQueue == null) {
- ac.remove(DEFAULT_QUEUE);
- } else {
- ac.put(DEFAULT_QUEUE, defaultQueue);
- }
- }
+ public static void setDefaultQueue(LayoutQueue q) {
+ defaultQueue = q;
}
/**
From d83e26cba476db741b0638154ae0d2d922fe91f9 Mon Sep 17 00:00:00 2001
From: Andrew Brygin
Date: Fri, 6 Feb 2009 20:49:53 +0300
Subject: [PATCH 024/283] 6800846: REGRESSION: Printing quality degraded with
Java 6 compared to 5.0
Reviewed-by: igor, prr
---
jdk/src/share/native/sun/awt/image/dither.c | 11 +--
jdk/test/sun/awt/image/DrawByteBinary.java | 75 +++++++++++++++++++++
2 files changed, 81 insertions(+), 5 deletions(-)
create mode 100644 jdk/test/sun/awt/image/DrawByteBinary.java
diff --git a/jdk/src/share/native/sun/awt/image/dither.c b/jdk/src/share/native/sun/awt/image/dither.c
index a935d6766f6..cb2303e76d7 100644
--- a/jdk/src/share/native/sun/awt/image/dither.c
+++ b/jdk/src/share/native/sun/awt/image/dither.c
@@ -169,6 +169,7 @@ initCubemap(int* cmap,
int cubesize = cube_dim * cube_dim * cube_dim;
unsigned char *useFlags;
unsigned char *newILut = (unsigned char*)malloc(cubesize);
+ int cmap_mid = (cmap_len >> 1) + (cmap_len & 0x1);
if (newILut) {
useFlags = (unsigned char *)calloc(cubesize, 1);
@@ -188,7 +189,7 @@ initCubemap(int* cmap,
currentState.iLUT = newILut;
currentState.rgb = (unsigned short *)
- malloc(256 * sizeof(unsigned short));
+ malloc(cmap_len * sizeof(unsigned short));
if (currentState.rgb == NULL) {
free(newILut);
free(useFlags);
@@ -199,7 +200,7 @@ initCubemap(int* cmap,
}
currentState.indices = (unsigned char *)
- malloc(256 * sizeof(unsigned char));
+ malloc(cmap_len * sizeof(unsigned char));
if (currentState.indices == NULL) {
free(currentState.rgb);
free(newILut);
@@ -210,18 +211,18 @@ initCubemap(int* cmap,
return NULL;
}
- for (i = 0; i < 128; i++) {
+ for (i = 0; i < cmap_mid; i++) {
unsigned short rgb;
int pixel = cmap[i];
rgb = (pixel & 0x00f80000) >> 9;
rgb |= (pixel & 0x0000f800) >> 6;
rgb |= (pixel & 0xf8) >> 3;
INSERTNEW(currentState, rgb, i);
- pixel = cmap[255-i];
+ pixel = cmap[cmap_len - i - 1];
rgb = (pixel & 0x00f80000) >> 9;
rgb |= (pixel & 0x0000f800) >> 6;
rgb |= (pixel & 0xf8) >> 3;
- INSERTNEW(currentState, rgb, 255-i);
+ INSERTNEW(currentState, rgb, cmap_len - i - 1);
}
if (!recurseLevel(¤tState)) {
diff --git a/jdk/test/sun/awt/image/DrawByteBinary.java b/jdk/test/sun/awt/image/DrawByteBinary.java
new file mode 100644
index 00000000000..e9db5c63f23
--- /dev/null
+++ b/jdk/test/sun/awt/image/DrawByteBinary.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6800846
+ *
+ * @summary Test verifes that images with short palette are rendered
+ * withourt artifacts.
+ *
+ * @run main DrawByteBinary
+ */
+
+
+import java.awt.*;
+import java.awt.color.*;
+import java.awt.image.*;
+import static java.awt.image.BufferedImage.*;
+
+
+public class DrawByteBinary {
+
+ public static void main(String args[]) {
+ int w = 100, h = 30;
+ int x = 10;
+ byte[] arr = {(byte)0xff, (byte)0x0, (byte)0x00};
+
+ IndexColorModel newCM = new IndexColorModel(1, 2, arr, arr, arr);
+ BufferedImage orig = new BufferedImage(w, h, TYPE_BYTE_BINARY, newCM);
+ Graphics2D g2d = orig.createGraphics();
+ g2d.setColor(Color.white);
+ g2d.fillRect(0, 0, w, h);
+ g2d.setColor(Color.black);
+ g2d.drawLine(x, 0, x, h);
+ g2d.dispose();
+
+ IndexColorModel origCM = (IndexColorModel)orig.getColorModel();
+ BufferedImage test = new BufferedImage(w, h, TYPE_BYTE_BINARY,origCM);
+ g2d = test.createGraphics();
+ g2d.drawImage(orig, 0, 0, null);
+ g2d.dispose();
+
+ int y = h / 2;
+
+ // we expect white color outside the line
+ if (test.getRGB(x - 1, y) != 0xffffffff) {
+ throw new RuntimeException("Invalid color outside the line.");
+ }
+
+ // we expect black color on the line
+ if (test.getRGB(x, y) != 0xff000000) {
+ throw new RuntimeException("Invalid color on the line.");
+ }
+ }
+}
From 9aab9d4aeb4f606a9dc732b928f77edd5733ba81 Mon Sep 17 00:00:00 2001
From: Poonam Bajaj
Date: Tue, 10 Feb 2009 03:26:31 -0800
Subject: [PATCH 025/283] 6755621: Include SA binaries into Windows JDK
These changes will enable inclusion of sa-jdi.jar and sawindbg.dll into Windows JDK bundle.
Reviewed-by: never, jjh, alanb
---
jdk/make/common/Defs-windows.gmk | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/jdk/make/common/Defs-windows.gmk b/jdk/make/common/Defs-windows.gmk
index 7b178497e12..75da038ffee 100644
--- a/jdk/make/common/Defs-windows.gmk
+++ b/jdk/make/common/Defs-windows.gmk
@@ -398,16 +398,7 @@ ifeq ($(ARCH), ia64)
# SA will never be supported here.
INCLUDE_SA = false
else
- # Hopefully, SA will be supported here one of these days,
- # and these will be changed to true. Until then,
- # to build SA on windows, do a control build with
- # BUILD_WIN_SA=1
- # on the make command.
- ifdef BUILD_WIN_SA
- INCLUDE_SA = true
- else
- INCLUDE_SA = false
- endif
+ INCLUDE_SA = true
endif
# Settings for the VERSIONINFO tap on windows.
From 68c4bef9747fcf01fab8731618161eb332f8b30b Mon Sep 17 00:00:00 2001
From: Christos Zoulas
Date: Wed, 11 Feb 2009 13:16:53 +0000
Subject: [PATCH 026/283] 6799040: Portability issues in
src/solaris/native/java/net/Inet4AddressImpl.c
Reviewed-by: alanb
---
jdk/src/solaris/native/java/net/Inet4AddressImpl.c | 7 +++++--
jdk/src/solaris/native/java/net/Inet6AddressImpl.c | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
index a41aa96e10f..9e3cca486db 100644
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c
@@ -165,16 +165,18 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
CHECK_NULL_RETURN(hostname, NULL);
+#ifdef __solaris__
/*
* Workaround for Solaris bug 4160367 - if a hostname contains a
* white space then 0.0.0.0 is returned
*/
- if (isspace(hostname[0])) {
+ if (isspace((unsigned char)hostname[0])) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
}
+#endif
/* Try once, with our static buffer. */
#ifdef __GLIBC__
@@ -325,7 +327,8 @@ static jboolean
ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
struct sockaddr_in* netif, jint ttl) {
jint size;
- jint n, len, hlen1, icmplen;
+ jint n, hlen1, icmplen;
+ socklen_t len;
char sendbuf[1500];
char recvbuf[1500];
struct icmp *icmp;
diff --git a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c
index 181307fcba8..5ecedbc6c4f 100644
--- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c
+++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c
@@ -196,16 +196,18 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
+#ifdef __solaris__
/*
* Workaround for Solaris bug 4160367 - if a hostname contains a
* white space then 0.0.0.0 is returned
*/
- if (isspace(hostname[0])) {
+ if (isspace((unsigned char)hostname[0])) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
return NULL;
}
+#endif
error = (*getaddrinfo_ptr)(hostname, NULL, &hints, &res);
@@ -455,7 +457,8 @@ static jboolean
ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
struct sockaddr_in6* netif, jint ttl) {
jint size;
- jint n, len;
+ jint n;
+ socklen_t len;
char sendbuf[1500];
unsigned char recvbuf[1500];
struct icmp6_hdr *icmp6;
From b8af3d50192f8bc98d83f8102f0fd1989f302e32 Mon Sep 17 00:00:00 2001
From: Artem Ananiev
Date: Thu, 12 Feb 2009 14:19:06 +0300
Subject: [PATCH 027/283] 6799345: JFC demos threw exception in the Java
Console when applets are closed
Reviewed-by: alexp, peterz
---
.../classes/javax/swing/SwingWorker.java | 50 +++--
.../share/classes/javax/swing/TimerQueue.java | 9 +-
.../swing/system/6799345/TestShutdown.java | 203 ++++++++++++++++++
3 files changed, 234 insertions(+), 28 deletions(-)
create mode 100644 jdk/test/javax/swing/system/6799345/TestShutdown.java
diff --git a/jdk/src/share/classes/javax/swing/SwingWorker.java b/jdk/src/share/classes/javax/swing/SwingWorker.java
index 9eca7d535f6..263284acc4e 100644
--- a/jdk/src/share/classes/javax/swing/SwingWorker.java
+++ b/jdk/src/share/classes/javax/swing/SwingWorker.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. 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
@@ -778,35 +778,33 @@ public abstract class SwingWorker implements RunnableFuture {
threadFactory);
appContext.put(SwingWorker.class, executorService);
- //register shutdown hook for this executor service
+ // Don't use ShutdownHook here as it's not enough. We should track
+ // AppContext disposal instead of JVM shutdown, see 6799345 for details
final ExecutorService es = executorService;
- final Runnable shutdownHook =
- new Runnable() {
- final WeakReference executorServiceRef =
- new WeakReference(es);
- public void run() {
- final ExecutorService executorService =
- executorServiceRef.get();
- if (executorService != null) {
- AccessController.doPrivileged(
- new PrivilegedAction() {
- public Void run() {
- executorService.shutdown();
- return null;
+ appContext.addPropertyChangeListener(AppContext.DISPOSED_PROPERTY_NAME,
+ new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent pce) {
+ boolean disposed = (Boolean)pce.getNewValue();
+ if (disposed) {
+ final WeakReference executorServiceRef =
+ new WeakReference(es);
+ final ExecutorService executorService =
+ executorServiceRef.get();
+ if (executorService != null) {
+ AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Void run() {
+ executorService.shutdown();
+ return null;
+ }
}
- });
+ );
+ }
}
}
- };
-
- AccessController.doPrivileged(
- new PrivilegedAction() {
- public Void run() {
- Runtime.getRuntime().addShutdownHook(
- new Thread(shutdownHook));
- return null;
- }
- });
+ }
+ );
}
return executorService;
}
diff --git a/jdk/src/share/classes/javax/swing/TimerQueue.java b/jdk/src/share/classes/javax/swing/TimerQueue.java
index f68f4e99688..642bc56bac7 100644
--- a/jdk/src/share/classes/javax/swing/TimerQueue.java
+++ b/jdk/src/share/classes/javax/swing/TimerQueue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -191,7 +191,12 @@ class TimerQueue implements Runnable
} finally {
timer.getLock().unlock();
}
- } catch (InterruptedException ignore) {
+ } catch (InterruptedException ie) {
+ // Shouldn't ignore InterruptedExceptions here, so AppContext
+ // is disposed gracefully, see 6799345 for details
+ if (AppContext.getAppContext().isDisposed()) {
+ break;
+ }
}
}
}
diff --git a/jdk/test/javax/swing/system/6799345/TestShutdown.java b/jdk/test/javax/swing/system/6799345/TestShutdown.java
new file mode 100644
index 00000000000..694df3eac01
--- /dev/null
+++ b/jdk/test/javax/swing/system/6799345/TestShutdown.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/* @test
+ @bug 6799345
+ @summary Tests that no exceptions are thrown from TimerQueue and
+SwingWorker on AppContext shutdown
+ @author art
+ @run main TestShutdown
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+import java.util.*;
+
+import javax.swing.*;
+
+import sun.awt.*;
+
+public class TestShutdown
+{
+ private static AppContext targetAppContext;
+
+ private static JFrame f;
+ private static JTextField tf;
+
+ private static volatile boolean exceptionsOccurred = false;
+ private static volatile boolean appcontextInitDone = false;
+
+ private static int timerValue = 0;
+
+ public static void main(String[] args)
+ throws Exception
+ {
+ ThreadGroup tg = new TestThreadGroup("TTG");
+ Thread t = new Thread(tg, new TestRunnable(), "InitThread");
+ t.start();
+
+ while (!appcontextInitDone)
+ {
+ Thread.sleep(500);
+ }
+
+ targetAppContext.dispose();
+
+ if (exceptionsOccurred)
+ {
+ throw new RuntimeException("Test FAILED: some exceptions occurred");
+ }
+ }
+
+ static void initGUI()
+ {
+ f = new JFrame("F");
+ f.setBounds(100, 100, 200, 100);
+ tf = new JTextField("Test");
+ f.add(tf);
+ f.setVisible(true);
+ }
+
+ static void startGUI()
+ {
+ // caret blink Timer
+ tf.requestFocusInWindow();
+
+ // misc Timer
+ ActionListener al = new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent ae)
+ {
+ System.out.println("Timer tick: " + timerValue++);
+ }
+ };
+ new javax.swing.Timer(30, al).start();
+ }
+
+ static class TestThreadGroup extends ThreadGroup
+ {
+ public TestThreadGroup(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public synchronized void uncaughtException(Thread thread, Throwable t)
+ {
+ if (t instanceof ThreadDeath)
+ {
+ // this one is expected, rethrow
+ throw (ThreadDeath)t;
+ }
+ System.err.println("Test FAILED: an exception is caught in the " +
+ "target thread group on thread " + thread.getName());
+ t.printStackTrace(System.err);
+ exceptionsOccurred = true;
+ }
+ }
+
+ static class TestRunnable implements Runnable
+ {
+ @Override
+ public void run()
+ {
+ SunToolkit stk = (SunToolkit)Toolkit.getDefaultToolkit();
+ targetAppContext = stk.createNewAppContext();
+
+ // create and show frame and text field
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ initGUI();
+ }
+ });
+ stk.realSync();
+
+ // start some Timers
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ startGUI();
+ }
+ });
+ stk.realSync();
+
+ // start multiple SwingWorkers
+ while (!Thread.interrupted())
+ {
+ try
+ {
+ new TestSwingWorker().execute();
+ Thread.sleep(40);
+ }
+ catch (Exception e)
+ {
+ // exception here is expected, skip
+ break;
+ }
+ }
+ }
+ }
+
+ static class TestSwingWorker extends SwingWorker
+ {
+ @Override
+ public String doInBackground()
+ {
+ Random r = new Random();
+ for (int i = 0; i < 10; i++)
+ {
+ try
+ {
+ int delay = r.nextInt() % 50;
+ Thread.sleep(delay);
+ publish(delay);
+ }
+ catch (Exception z)
+ {
+ break;
+ }
+ }
+ if (!appcontextInitDone)
+ {
+ appcontextInitDone = true;
+ }
+ return "Done";
+ }
+
+ @Override
+ public void process(java.util.List chunks)
+ {
+ for (Integer i : chunks)
+ {
+ System.err.println("Processed: " + i);
+ }
+ }
+ }
+}
From 198f2427b42ca7b72a5f95d9408363d41f6ed2e9 Mon Sep 17 00:00:00 2001
From: Maurizio Cimadamore
Date: Fri, 13 Feb 2009 11:57:33 +0000
Subject: [PATCH 028/283] 6769027: Source line should be displayed immediately
after the first diagnostic line
Added support for customizing diagnostic output via API/command line flags
Reviewed-by: jjg
---
.../tools/javac/api/DiagnosticFormatter.java | 101 +++-
.../com/sun/tools/javac/api/Messages.java | 2 +-
.../com/sun/tools/javac/main/OptionName.java | 1 +
.../tools/javac/main/RecognizedOptions.java | 16 +
.../tools/javac/resources/compiler.properties | 24 +-
.../util/AbstractDiagnosticFormatter.java | 241 +++++++--
.../javac/util/BasicDiagnosticFormatter.java | 288 ++++++++--
.../tools/javac/util/LayoutCharacters.java | 8 +-
.../classes/com/sun/tools/javac/util/Log.java | 18 +-
.../javac/util/RawDiagnosticFormatter.java | 69 +--
.../test/tools/javac/6304921/T6304921.out | 10 +-
.../tools/javac/6668794/badClass/Test.java | 4 +-
.../tools/javac/6668794/badSource/Test.out | 2 +-
.../test/tools/javac/6758789/T6758789b.out | 2 +-
.../javac/Diagnostics/6769027/T6769027.java | 499 ++++++++++++++++++
.../Diagnostics/6769027/tester.properties | 13 +
langtools/test/tools/javac/ExtendArray.out | 4 +-
langtools/test/tools/javac/T5048776b.out | 4 +-
langtools/test/tools/javac/T6214885a.out | 4 +-
langtools/test/tools/javac/T6214885b.out | 4 +-
langtools/test/tools/javac/T6230128.out | 2 +-
.../tools/javac/annotations/6365854/test1.out | 2 +-
.../tools/javac/cast/6557182/T6557182.out | 4 +-
.../tools/javac/cast/6665356/T6665356.out | 14 +-
.../tools/javac/cast/6795580/T6795580.out | 14 +-
.../tools/javac/generics/6207386/T6207386.out | 2 +-
.../generics/inference/6315770/T6315770.out | 4 +-
.../generics/inference/6718364/T6718364.out | 2 +-
.../generics/typevars/6680106/T6680106.out | 24 +-
.../MissingSuperRecovery.out | 2 +-
.../tools/javac/unicode/UnicodeNewline.out | 4 +-
31 files changed, 1186 insertions(+), 202 deletions(-)
create mode 100644 langtools/test/tools/javac/Diagnostics/6769027/T6769027.java
create mode 100644 langtools/test/tools/javac/Diagnostics/6769027/tester.properties
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java
index 6fd51b146b1..1c035fb0ab1 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/DiagnosticFormatter.java
@@ -25,16 +25,18 @@
package com.sun.tools.javac.api;
import java.util.Locale;
+import java.util.Set;
import javax.tools.Diagnostic;
+import com.sun.tools.javac.api.DiagnosticFormatter.*;
/**
- * Provides simple functionalities for javac diagnostic formatting
+ * Provides simple functionalities for javac diagnostic formatting.
* @param type of diagnostic handled by this formatter
*/
public interface DiagnosticFormatter> {
/**
- * Whether the source code output for this diagnostic is to be displayed
+ * Whether the source code output for this diagnostic is to be displayed.
*
* @param diag diagnostic to be formatted
* @return true if the source line this diagnostic refers to is to be displayed
@@ -42,7 +44,7 @@ public interface DiagnosticFormatter> {
boolean displaySource(D diag);
/**
- * Format the contents of a diagnostics
+ * Format the contents of a diagnostics.
*
* @param diag the diagnostic to be formatted
* @param l locale object to be used for i18n
@@ -115,4 +117,97 @@ public interface DiagnosticFormatter> {
*/
OFFSET
}
+
+ /**
+ * Get a list of all the enabled verbosity options.
+ * @return verbosity options
+ */
+ public Configuration getConfiguration();
+ //where
+
+ /**
+ * This interface provides functionalities for tuning the output of a
+ * diagnostic formatter in multiple ways.
+ */
+ interface Configuration {
+ /**
+ * Configure the set of diagnostic parts that should be displayed
+ * by the formatter.
+ * @param options options to set
+ */
+ public void setVisible(Set visibleParts);
+
+ /**
+ * Retrieve the set of diagnostic parts that should be displayed
+ * by the formatter.
+ * @return verbosity options
+ */
+ public Set getVisible();
+
+ //where
+ /**
+ * A given diagnostic message can be divided into sub-parts each of which
+ * might/might not be displayed by the formatter, according to the
+ * current configuration settings.
+ */
+ public enum DiagnosticPart {
+ /**
+ * Short description of the diagnostic - usually one line long.
+ */
+ SUMMARY,
+ /**
+ * Longer description that provides additional details w.r.t. the ones
+ * in the diagnostic's description.
+ */
+ DETAILS,
+ /**
+ * Source line the diagnostic refers to (if applicable).
+ */
+ SOURCE,
+ /**
+ * Subdiagnostics attached to a given multiline diagnostic.
+ */
+ SUBDIAGNOSTICS,
+ /**
+ * JLS paragraph this diagnostic might refer to (if applicable).
+ */
+ JLS;
+ }
+
+ /**
+ * Set a limit for multiline diagnostics.
+ * Note: Setting a limit has no effect if multiline diagnostics are either
+ * fully enabled or disabled.
+ *
+ * @param limit the kind of limit to be set
+ * @param value the limit value
+ */
+ public void setMultilineLimit(MultilineLimit limit, int value);
+
+ /**
+ * Get a multiline diagnostic limit.
+ *
+ * @param limit the kind of limit to be retrieved
+ * @return limit value or -1 if no limit is set
+ */
+ public int getMultilineLimit(MultilineLimit limit);
+ //where
+ /**
+ * A multiline limit control the verbosity of multiline diagnostics
+ * either by setting a maximum depth of nested multidiagnostics,
+ * or by limiting the amount of subdiagnostics attached to a given
+ * diagnostic (or both).
+ */
+ public enum MultilineLimit {
+ /**
+ * Controls the maximum depth of nested multiline diagnostics.
+ */
+ DEPTH,
+ /**
+ * Controls the maximum amount of subdiagnostics that are part of a
+ * given multiline diagnostic.
+ */
+ LENGTH;
+ }
+ }
}
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/Messages.java b/langtools/src/share/classes/com/sun/tools/javac/api/Messages.java
index 7b67fe617cd..bc38794fe2d 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/Messages.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/Messages.java
@@ -44,7 +44,7 @@ public interface Messages {
void add(String bundleName) throws MissingResourceException;
/**
- * Get a localized formatted string
+ * Get a localized formatted string.
* @param l locale in which the text is to be localized
* @param key locale-independent message key
* @param args misc message arguments
diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java b/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java
index 3ffbccdbc35..61a2d1ba98e 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java
@@ -40,6 +40,7 @@ public enum OptionName {
G_CUSTOM("-g:"),
XLINT("-Xlint"),
XLINT_CUSTOM("-Xlint:"),
+ DIAGS("-XDdiags="),
NOWARN("-nowarn"),
VERBOSE("-verbose"),
DEPRECATION("-deprecation"),
diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java b/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
index 980d6779674..f69f0c1377e 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java
@@ -145,6 +145,7 @@ public class RecognizedOptions {
TARGET,
VERSION,
FULLVERSION,
+ DIAGS,
HELP,
A,
X,
@@ -372,6 +373,21 @@ public class RecognizedOptions {
return super.process(options, option);
}
},
+ new HiddenOption(DIAGS) {
+ @Override
+ public boolean process(Options options, String option) {
+ Option xd = getOptions(helper, EnumSet.of(XD))[0];
+ option = option.substring(option.indexOf('=') + 1);
+ String diagsOption = option.contains("%") ?
+ "-XDdiagsFormat=" :
+ "-XDdiags=";
+ diagsOption += option;
+ if (xd.matches(diagsOption))
+ return xd.process(options, diagsOption);
+ else
+ return false;
+ }
+ },
new Option(HELP, "opt.help") {
@Override
public boolean process(Options options, String option) {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
index a7e75fa5f1e..d892db06077 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
@@ -907,16 +907,16 @@ compiler.err.not.within.bounds.explain=\
compiler.err.prob.found.req=\
{0}\n\
-found : {1}\n\
-required: {2}
+required: {2}\n\
+found: {1}
compiler.warn.prob.found.req=\
{0}\n\
-found : {1}\n\
-required: {2}
+required: {2}\n\
+found: {1}
compiler.err.prob.found.req.1=\
{0} {3}\n\
-found : {1}\n\
-required: {2}
+required: {2}\n\
+found: {1}
## The following are all possible strings for the first argument ({0}) of the
## above strings.
@@ -951,8 +951,8 @@ compiler.misc.assignment.to.extends-bound=\
compiler.err.type.found.req=\
unexpected type\n\
-found : {0}\n\
-required: {1}
+required: {1}\n\
+found: {0}
## The following are all possible strings for the first argument ({0}) of the
## above string.
@@ -1003,7 +1003,7 @@ compiler.err.non-static.cant.be.ref=\
compiler.err.unexpected.type=\
unexpected type\n\
required: {0}\n\
-found : {1}
+found: {1}
## The first argument {0} is a "kindname" (e.g. 'constructor', 'field', etc.)
## The second argument {1} is the non-resolved symbol
@@ -1026,17 +1026,17 @@ compiler.err.cant.resolve.args.params=\
## The sixth argument {5} is the location type
compiler.err.cant.resolve.location=\
cannot find symbol\n\
- symbol : {0} {1}\n\
+ symbol: {0} {1}\n\
location: {4} {5}
compiler.err.cant.resolve.location.args=\
cannot find symbol\n\
- symbol : {0} {1}({3})\n\
+ symbol: {0} {1}({3})\n\
location: {4} {5}
compiler.err.cant.resolve.location.args.params=\
cannot find symbol\n\
- symbol : {0} <{2}>{1}({3})\n\
+ symbol: {0} <{2}>{1}({3})\n\
location: {4} {5}
## The following are all possible string for "kindname".
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java
index e930c75d67b..179e284a22c 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java
@@ -24,16 +24,23 @@
*/
package com.sun.tools.javac.util;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.EnumSet;
+import java.util.HashMap;
import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import javax.tools.JavaFileObject;
import com.sun.tools.javac.api.DiagnosticFormatter;
-import com.sun.tools.javac.api.Formattable;
+import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.DiagnosticPart;
+import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.MultilineLimit;
import com.sun.tools.javac.api.DiagnosticFormatter.PositionKind;
+import com.sun.tools.javac.api.Formattable;
import com.sun.tools.javac.file.JavacFileManager;
+
import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
-import static com.sun.tools.javac.util.LayoutCharacters.*;
/**
* This abstract class provides a basic implementation of the functionalities that should be provided
@@ -50,35 +57,19 @@ import static com.sun.tools.javac.util.LayoutCharacters.*;
public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter {
/**
- * JavacMessages object used by this formatter for i18n
+ * JavacMessages object used by this formatter for i18n.
*/
protected JavacMessages messages;
- protected boolean showSource;
+ private SimpleConfiguration config;
+ protected int depth = 0;
/**
- * Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object
+ * Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object.
* @param messages
*/
- protected AbstractDiagnosticFormatter(JavacMessages messages, Options options, boolean showSource) {
+ protected AbstractDiagnosticFormatter(JavacMessages messages, SimpleConfiguration config) {
this.messages = messages;
- this.showSource = options.get("showSource") == null ? showSource :
- options.get("showSource").equals("true");
- }
-
- protected AbstractDiagnosticFormatter(JavacMessages messages, boolean showSource) {
- this.messages = messages;
- this.showSource = showSource;
- }
-
- public String formatMessage(JCDiagnostic d, Locale l) {
- //this code should rely on the locale settings but it's not! See RFE 6443132
- StringBuilder buf = new StringBuilder();
- Collection args = formatArguments(d, l);
- buf.append(localize(l, d.getCode(), args.toArray()));
- if (d.isMultiline()) {
- buf.append(formatSubdiagnostics(d, l));
- }
- return buf.toString();
+ this.config = config;
}
public String formatKind(JCDiagnostic d, Locale l) {
@@ -96,8 +87,8 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
assert (d.getPosition() != Position.NOPOS);
return String.valueOf(getPosition(d, pk));
}
- //WHERE
- public long getPosition(JCDiagnostic d, PositionKind pk) {
+ //where
+ private long getPosition(JCDiagnostic d, PositionKind pk) {
switch (pk) {
case START: return d.getIntStartPosition();
case END: return d.getIntEndPosition();
@@ -138,8 +129,17 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
* @return string representation of the diagnostic argument
*/
protected String formatArgument(JCDiagnostic d, Object arg, Locale l) {
- if (arg instanceof JCDiagnostic)
- return format((JCDiagnostic)arg, l);
+ if (arg instanceof JCDiagnostic) {
+ String s = null;
+ depth++;
+ try {
+ s = formatMessage((JCDiagnostic)arg, l);
+ }
+ finally {
+ depth--;
+ }
+ return s;
+ }
else if (arg instanceof Iterable>) {
return formatIterable(d, (Iterable>)arg, l);
}
@@ -171,45 +171,74 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
}
/**
- * Format all the subdiagnostics attached to a given diagnostic
+ * Format all the subdiagnostics attached to a given diagnostic.
*
* @param d diagnostic whose subdiagnostics are to be formatted
* @param l locale object to be used for i18n
+ * @return list of all string representations of the subdiagnostics
+ */
+ protected List formatSubdiagnostics(JCDiagnostic d, Locale l) {
+ List subdiagnostics = List.nil();
+ int maxDepth = config.getMultilineLimit(MultilineLimit.DEPTH);
+ if (maxDepth == -1 || depth < maxDepth) {
+ depth++;
+ try {
+ int maxCount = config.getMultilineLimit(MultilineLimit.LENGTH);
+ int count = 0;
+ for (JCDiagnostic d2 : d.getSubdiagnostics()) {
+ if (maxCount == -1 || count < maxCount) {
+ subdiagnostics = subdiagnostics.append(formatSubdiagnostic(d, d2, l));
+ count++;
+ }
+ else
+ break;
+ }
+ }
+ finally {
+ depth--;
+ }
+ }
+ return subdiagnostics;
+ }
+
+ /**
+ * Format a subdiagnostics attached to a given diagnostic.
+ *
+ * @param parent multiline diagnostic whose subdiagnostics is to be formatted
+ * @param sub subdiagnostic to be formatted
+ * @param l locale object to be used for i18n
* @return string representation of the subdiagnostics
*/
- protected String formatSubdiagnostics(JCDiagnostic d, Locale l) {
- StringBuilder buf = new StringBuilder();
- for (JCDiagnostic d2 : d.getSubdiagnostics()) {
- buf.append('\n');
- String subdiagMsg = format(d2, l);
- buf.append(indent(subdiagMsg, DiagInc));
- }
- return buf.toString();
+ protected String formatSubdiagnostic(JCDiagnostic parent, JCDiagnostic sub, Locale l) {
+ return formatMessage(sub, l);
}
/** Format the faulty source code line and point to the error.
* @param d The diagnostic for which the error line should be printed
*/
- protected String formatSourceLine(JCDiagnostic d) {
+ protected String formatSourceLine(JCDiagnostic d, int nSpaces) {
StringBuilder buf = new StringBuilder();
DiagnosticSource source = d.getDiagnosticSource();
int pos = d.getIntPosition();
- if (d.getIntPosition() != Position.NOPOS) {
- String line = (source == null ? null : source.getLine(pos));
- if (line == null)
- return "";
- buf.append(line+"\n");
- int col = source.getColumnNumber(pos, false);
+ if (d.getIntPosition() == Position.NOPOS)
+ throw new AssertionError();
+ String line = (source == null ? null : source.getLine(pos));
+ if (line == null)
+ return "";
+ buf.append(indent(line, nSpaces));
+ int col = source.getColumnNumber(pos, false);
+ if (config.isCaretEnabled()) {
+ buf.append("\n");
for (int i = 0; i < col - 1; i++) {
buf.append((line.charAt(i) == '\t') ? "\t" : " ");
}
- buf.append("^");
- }
- return buf.toString();
+ buf.append(indent("^", nSpaces));
+ }
+ return buf.toString();
}
/**
- * Converts a String into a locale-dependent representation accordingly to a given locale
+ * Converts a String into a locale-dependent representation accordingly to a given locale.
*
* @param l locale object to be used for i18n
* @param key locale-independent key used for looking up in a resource file
@@ -221,7 +250,9 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
}
public boolean displaySource(JCDiagnostic d) {
- return showSource && d.getType() != FRAGMENT;
+ return config.getVisible().contains(DiagnosticPart.SOURCE) &&
+ d.getType() != FRAGMENT &&
+ d.getIntPosition() != Position.NOPOS;
}
/**
@@ -245,7 +276,7 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
/**
* Indent a string by prepending a given amount of empty spaces to each line
- * of the string
+ * of the string.
*
* @param s the string to be indented
* @param nSpaces the amount of spaces that should be prepended to each line
@@ -263,4 +294,114 @@ public abstract class AbstractDiagnosticFormatter implements DiagnosticFormatter
}
return buf.toString();
}
+
+ public SimpleConfiguration getConfiguration() {
+ return config;
+ }
+
+ static public class SimpleConfiguration implements Configuration {
+
+ protected Map multilineLimits;
+ protected EnumSet visibleParts;
+ protected boolean caretEnabled;
+
+ public SimpleConfiguration(Set parts) {
+ multilineLimits = new HashMap();
+ setVisible(parts);
+ setMultilineLimit(MultilineLimit.DEPTH, -1);
+ setMultilineLimit(MultilineLimit.LENGTH, -1);
+ setCaretEnabled(true);
+ }
+
+ @SuppressWarnings("fallthrough")
+ public SimpleConfiguration(Options options, Set parts) {
+ this(parts);
+ String showSource = null;
+ if ((showSource = options.get("showSource")) != null) {
+ if (showSource.equals("true"))
+ visibleParts.add(DiagnosticPart.SOURCE);
+ else if (showSource.equals("false"))
+ visibleParts.remove(DiagnosticPart.SOURCE);
+ }
+ String diagOpts = options.get("diags");
+ if (diagOpts != null) {//override -XDshowSource
+ Collection args = Arrays.asList(diagOpts.split(","));
+ if (args.contains("short")) {
+ visibleParts.remove(DiagnosticPart.DETAILS);
+ visibleParts.remove(DiagnosticPart.SUBDIAGNOSTICS);
+ }
+ if (args.contains("source"))
+ visibleParts.add(DiagnosticPart.SOURCE);
+ if (args.contains("-source"))
+ visibleParts.remove(DiagnosticPart.SOURCE);
+ }
+ String multiPolicy = null;
+ if ((multiPolicy = options.get("multilinePolicy")) != null) {
+ if (multiPolicy.equals("disabled"))
+ visibleParts.remove(DiagnosticPart.SUBDIAGNOSTICS);
+ else if (multiPolicy.startsWith("limit:")) {
+ String limitString = multiPolicy.substring("limit:".length());
+ String[] limits = limitString.split(":");
+ try {
+ switch (limits.length) {
+ case 2: {
+ if (!limits[1].equals("*"))
+ setMultilineLimit(MultilineLimit.DEPTH, Integer.parseInt(limits[1]));
+ }
+ case 1: {
+ if (!limits[0].equals("*"))
+ setMultilineLimit(MultilineLimit.LENGTH, Integer.parseInt(limits[0]));
+ }
+ }
+ }
+ catch(NumberFormatException ex) {
+ setMultilineLimit(MultilineLimit.DEPTH, -1);
+ setMultilineLimit(MultilineLimit.LENGTH, -1);
+ }
+ }
+ }
+ String showCaret = null;
+ if (((showCaret = options.get("showCaret")) != null) &&
+ showCaret.equals("false"))
+ setCaretEnabled(false);
+ else
+ setCaretEnabled(true);
+ }
+
+ public int getMultilineLimit(MultilineLimit limit) {
+ return multilineLimits.get(limit);
+ }
+
+ public EnumSet getVisible() {
+ return EnumSet.copyOf(visibleParts);
+ }
+
+ public void setMultilineLimit(MultilineLimit limit, int value) {
+ multilineLimits.put(limit, value < -1 ? -1 : value);
+ }
+
+
+ public void setVisible(Set diagParts) {
+ visibleParts = EnumSet.copyOf(diagParts);
+ }
+
+ /**
+ * Shows a '^' sign under the source line displayed by the formatter
+ * (if applicable).
+ *
+ * @param caretEnabled if true enables caret
+ */
+ public void setCaretEnabled(boolean caretEnabled) {
+ this.caretEnabled = caretEnabled;
+ }
+
+ /**
+ * Tells whether the caret display is active or not.
+ *
+ * @param caretEnabled if true the caret is enabled
+ */
+ public boolean isCaretEnabled() {
+ return caretEnabled;
+ }
+ }
}
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
index 02102452cd2..e3cc45c06e4 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
@@ -25,13 +25,20 @@
package com.sun.tools.javac.util;
+import java.util.Collection;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import java.util.regex.Matcher;
import javax.tools.JavaFileObject;
-import static com.sun.tools.javac.util.BasicDiagnosticFormatter.BasicFormatKind.*;
+import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
+import com.sun.tools.javac.util.BasicDiagnosticFormatter.BasicConfiguration;
+
import static com.sun.tools.javac.api.DiagnosticFormatter.PositionKind.*;
+import static com.sun.tools.javac.util.BasicDiagnosticFormatter.BasicConfiguration.*;
+import static com.sun.tools.javac.util.LayoutCharacters.*;
/**
* A basic formatter for diagnostic messages.
@@ -53,7 +60,7 @@ import static com.sun.tools.javac.api.DiagnosticFormatter.PositionKind.*;
*/
public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
- protected Map availableFormats;
+ protected int currentIndentation = 0;
/**
* Create a basic formatter based on the supplied options.
@@ -62,21 +69,8 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
* @param msgs JavacMessages object used for i18n
*/
@SuppressWarnings("fallthrough")
- BasicDiagnosticFormatter(Options opts, JavacMessages msgs) {
- super(msgs, opts, true);
- initAvailableFormats();
- String fmt = opts.get("diags");
- if (fmt != null) {
- String[] formats = fmt.split("\\|");
- switch (formats.length) {
- case 3:
- availableFormats.put(DEFAULT_CLASS_FORMAT, formats[2]);
- case 2:
- availableFormats.put(DEFAULT_NO_POS_FORMAT, formats[1]);
- default:
- availableFormats.put(DEFAULT_POS_FORMAT, formats[0]);
- }
- }
+ public BasicDiagnosticFormatter(Options options, JavacMessages msgs) {
+ super(msgs, new BasicConfiguration(options));
}
/**
@@ -85,15 +79,7 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
* @param msgs JavacMessages object used for i18n
*/
public BasicDiagnosticFormatter(JavacMessages msgs) {
- super(msgs, true);
- initAvailableFormats();
- }
-
- public void initAvailableFormats() {
- availableFormats = new HashMap();
- availableFormats.put(DEFAULT_POS_FORMAT, "%f:%l:%_%t%m");
- availableFormats.put(DEFAULT_NO_POS_FORMAT, "%p%m");
- availableFormats.put(DEFAULT_CLASS_FORMAT, "%f:%_%t%m");
+ super(msgs, new BasicConfiguration());
}
public String format(JCDiagnostic d, Locale l) {
@@ -110,10 +96,55 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
}
buf.append(meta ? formatMeta(c, d, l) : String.valueOf(c));
}
- if (displaySource(d)) {
- buf.append("\n" + formatSourceLine(d));
+ if (depth == 0)
+ return addSourceLineIfNeeded(d, buf.toString());
+ else
+ return buf.toString();
+ }
+
+ public String formatMessage(JCDiagnostic d, Locale l) {
+ int prevIndentation = currentIndentation;
+ try {
+ StringBuilder buf = new StringBuilder();
+ Collection args = formatArguments(d, l);
+ String msg = localize(l, d.getCode(), args.toArray());
+ String[] lines = msg.split("\n");
+ if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) {
+ currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY);
+ buf.append(indent(lines[0], currentIndentation)); //summary
+ }
+ if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) {
+ currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS);
+ for (int i = 1;i < lines.length; i++) {
+ buf.append("\n" + indent(lines[i], currentIndentation));
+ }
+ }
+ if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
+ currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS);
+ for (String sub : formatSubdiagnostics(d, l)) {
+ buf.append("\n" + sub);
+ }
+ }
+ return buf.toString();
+ }
+ finally {
+ currentIndentation = prevIndentation;
+ }
+ }
+
+ protected String addSourceLineIfNeeded(JCDiagnostic d, String msg) {
+ if (!displaySource(d))
+ return msg;
+ else {
+ BasicConfiguration conf = getConfiguration();
+ int indentSource = conf.getIndentation(DiagnosticPart.SOURCE);
+ String sourceLine = "\n" + formatSourceLine(d, indentSource);
+ boolean singleLine = msg.indexOf("\n") == -1;
+ if (singleLine || getConfiguration().getSourcePosition() == SourcePosition.BOTTOM)
+ return msg + sourceLine;
+ else
+ return msg.replaceFirst("\n", Matcher.quoteReplacement(sourceLine) + "\n");
}
- return buf.toString();
}
protected String formatMeta(char c, JCDiagnostic d, Locale l) {
@@ -164,34 +195,199 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
private String selectFormat(JCDiagnostic d) {
DiagnosticSource source = d.getDiagnosticSource();
- String format = availableFormats.get(DEFAULT_NO_POS_FORMAT);
+ String format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT);
if (source != null) {
if (d.getIntPosition() != Position.NOPOS) {
- format = availableFormats.get(DEFAULT_POS_FORMAT);
+ format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_POS_FORMAT);
} else if (source.getFile() != null &&
source.getFile().getKind() == JavaFileObject.Kind.CLASS) {
- format = availableFormats.get(DEFAULT_CLASS_FORMAT);
+ format = getConfiguration().getFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT);
}
}
return format;
}
- /**
- * This enum contains all the kinds of formatting patterns supported
- * by a basic diagnostic formatter.
- */
- public enum BasicFormatKind {
+ @Override
+ public BasicConfiguration getConfiguration() {
+ return (BasicConfiguration)super.getConfiguration();
+ }
+
+ static public class BasicConfiguration extends SimpleConfiguration {
+
+ protected Map indentationLevels;
+ protected Map availableFormats;
+ protected SourcePosition sourcePosition;
+
+ @SuppressWarnings("fallthrough")
+ public BasicConfiguration(Options options) {
+ super(options, EnumSet.of(DiagnosticPart.SUMMARY,
+ DiagnosticPart.DETAILS,
+ DiagnosticPart.SUBDIAGNOSTICS,
+ DiagnosticPart.SOURCE));
+ initFormat();
+ initIndentation();
+ String fmt = options.get("diagsFormat");
+ if (fmt != null) {
+ String[] formats = fmt.split("\\|");
+ switch (formats.length) {
+ case 3:
+ setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]);
+ case 2:
+ setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]);
+ default:
+ setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]);
+ }
+ }
+ String sourcePosition = null;
+ if ((((sourcePosition = options.get("sourcePosition")) != null)) &&
+ sourcePosition.equals("bottom"))
+ setSourcePosition(SourcePosition.BOTTOM);
+ else
+ setSourcePosition(SourcePosition.AFTER_SUMMARY);
+ String indent = options.get("diagsIndentation");
+ if (indent != null) {
+ String[] levels = indent.split("\\|");
+ try {
+ switch (levels.length) {
+ case 5:
+ setIndentation(DiagnosticPart.JLS,
+ Integer.parseInt(levels[4]));
+ case 4:
+ setIndentation(DiagnosticPart.SUBDIAGNOSTICS,
+ Integer.parseInt(levels[3]));
+ case 3:
+ setIndentation(DiagnosticPart.SOURCE,
+ Integer.parseInt(levels[2]));
+ case 2:
+ setIndentation(DiagnosticPart.DETAILS,
+ Integer.parseInt(levels[1]));
+ default:
+ setIndentation(DiagnosticPart.SUMMARY,
+ Integer.parseInt(levels[0]));
+ }
+ }
+ catch (NumberFormatException ex) {
+ initIndentation();
+ }
+ }
+ }
+
+ public BasicConfiguration() {
+ super(EnumSet.of(DiagnosticPart.SUMMARY,
+ DiagnosticPart.DETAILS,
+ DiagnosticPart.SUBDIAGNOSTICS,
+ DiagnosticPart.SOURCE));
+ initFormat();
+ initIndentation();
+ }
+ //where
+ private void initFormat() {
+ availableFormats = new HashMap();
+ setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, "%f:%l:%_%t%m");
+ setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, "%p%m");
+ setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, "%f:%_%t%m");
+ }
+ //where
+ private void initIndentation() {
+ indentationLevels = new HashMap();
+ setIndentation(DiagnosticPart.SUMMARY, 0);
+ setIndentation(DiagnosticPart.DETAILS, DetailsInc);
+ setIndentation(DiagnosticPart.SUBDIAGNOSTICS, DiagInc);
+ setIndentation(DiagnosticPart.SOURCE, 0);
+ }
+
/**
- * A format string to be used for diagnostics with a given position.
- */
- DEFAULT_POS_FORMAT,
+ * Get the amount of spaces for a given indentation kind
+ * @param diagPart the diagnostic part for which the indentation is
+ * to be retrieved
+ * @return the amount of spaces used for the specified indentation kind
+ */
+ public int getIndentation(DiagnosticPart diagPart) {
+ return indentationLevels.get(diagPart);
+ }
+
/**
- * A format string to be used for diagnostics without a given position.
- */
- DEFAULT_NO_POS_FORMAT,
+ * Set the indentation level for various element of a given diagnostic -
+ * this might lead to more readable diagnostics
+ *
+ * @param indentationKind kind of indentation to be set
+ * @param nSpaces amount of spaces for the specified diagnostic part
+ */
+ public void setIndentation(DiagnosticPart diagPart, int nSpaces) {
+ indentationLevels.put(diagPart, nSpaces);
+ }
+
/**
- * A format string to be used for diagnostics regarding classfiles
- */
- DEFAULT_CLASS_FORMAT;
+ * Set the source line positioning used by this formatter
+ *
+ * @param sourcePos a positioning value for source line
+ */
+ public void setSourcePosition(SourcePosition sourcePos) {
+ sourcePosition = sourcePos;
+ }
+
+ /**
+ * Get the source line positioning used by this formatter
+ *
+ * @return the positioning value used by this formatter
+ */
+ public SourcePosition getSourcePosition() {
+ return sourcePosition;
+ }
+ //where
+ /**
+ * A source positioning value controls the position (within a given
+ * diagnostic message) in which the source line the diagnostic refers to
+ * should be displayed (if applicable)
+ */
+ public enum SourcePosition {
+ /**
+ * Source line is displayed after the diagnostic message
+ */
+ BOTTOM,
+ /**
+ * Source line is displayed after the first line of the diagnostic
+ * message
+ */
+ AFTER_SUMMARY;
+ }
+
+ /**
+ * Set a metachar string for a specific format
+ *
+ * @param kind the format kind to be set
+ * @param s the metachar string specifying the format
+ */
+ public void setFormat(BasicFormatKind kind, String s) {
+ availableFormats.put(kind, s);
+ }
+
+ /**
+ * Get a metachar string for a specific format
+ *
+ * @param sourcePos a positioning value for source line
+ */
+ public String getFormat(BasicFormatKind kind) {
+ return availableFormats.get(kind);
+ }
+ //where
+ /**
+ * This enum contains all the kinds of formatting patterns supported
+ * by a basic diagnostic formatter.
+ */
+ public enum BasicFormatKind {
+ /**
+ * A format string to be used for diagnostics with a given position.
+ */
+ DEFAULT_POS_FORMAT,
+ /**
+ * A format string to be used for diagnostics without a given position.
+ */
+ DEFAULT_NO_POS_FORMAT,
+ /**
+ * A format string to be used for diagnostics regarding classfiles
+ */
+ DEFAULT_CLASS_FORMAT;
+ }
}
}
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java b/langtools/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java
index 7e332ebc0f8..b6f275f2d46 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/LayoutCharacters.java
@@ -39,9 +39,13 @@ public interface LayoutCharacters {
*/
final static int TabInc = 8;
- /** Diagnostic standard indentation
+ /** Standard indentation for subdiagnostics
*/
- final static int DiagInc = 2;
+ final static int DiagInc = 4;
+
+ /** Standard indentation for additional diagnostic lines
+ */
+ final static int DetailsInc = 2;
/** Tabulator character.
*/
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java
index e7359a3c283..e22f615c3a5 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java
@@ -93,17 +93,17 @@ public class Log extends AbstractLog {
protected DiagnosticListener super JavaFileObject> diagListener;
/**
- * Formatter for diagnostics
+ * Formatter for diagnostics.
*/
private DiagnosticFormatter diagFormatter;
/**
- * Keys for expected diagnostics
+ * Keys for expected diagnostics.
*/
public Set expectDiagKeys;
/**
- * JavacMessages object used for localization
+ * JavacMessages object used for localization.
*/
private JavacMessages messages;
@@ -206,6 +206,18 @@ public class Log extends AbstractLog {
return source == null ? null : source.getFile();
}
+ /** Get the current diagnostic formatter.
+ */
+ public DiagnosticFormatter getDiagnosticFormatter() {
+ return diagFormatter;
+ }
+
+ /** Set the current diagnostic formatter.
+ */
+ public void setDiagnosticFormatter(DiagnosticFormatter diagFormatter) {
+ this.diagFormatter = diagFormatter;
+ }
+
/** Flush the logs
*/
public void flush() {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java
index 433779764b5..db05a732dfe 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java
@@ -24,9 +24,14 @@
*/
package com.sun.tools.javac.util;
+import java.util.Collection;
+import java.util.EnumSet;
import java.util.Locale;
+import com.sun.tools.javac.api.DiagnosticFormatter.Configuration.*;
import com.sun.tools.javac.api.Formattable;
+import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
+
import static com.sun.tools.javac.api.DiagnosticFormatter.PositionKind.*;
/**
@@ -35,14 +40,17 @@ import static com.sun.tools.javac.api.DiagnosticFormatter.PositionKind.*;
* or not the source name and position are set. This formatter provides a standardized, localize-independent
* implementation of a diagnostic formatter; as such, this formatter is best suited for testing purposes.
*/
-public class RawDiagnosticFormatter extends AbstractDiagnosticFormatter {
+public final class RawDiagnosticFormatter extends AbstractDiagnosticFormatter {
/**
* Create a formatter based on the supplied options.
* @param msgs
*/
- public RawDiagnosticFormatter(Options opts) {
- super(null, opts, false);
+ public RawDiagnosticFormatter(Options options) {
+ super(null, new SimpleConfiguration(options,
+ EnumSet.of(DiagnosticPart.SUMMARY,
+ DiagnosticPart.DETAILS,
+ DiagnosticPart.SUBDIAGNOSTICS)));
}
//provide common default formats
@@ -62,7 +70,7 @@ public class RawDiagnosticFormatter extends AbstractDiagnosticFormatter {
buf.append(' ');
buf.append(formatMessage(d, null));
if (displaySource(d))
- buf.append("\n" + formatSourceLine(d));
+ buf.append("\n" + formatSourceLine(d, 0));
return buf.toString();
}
catch (Exception e) {
@@ -71,6 +79,32 @@ public class RawDiagnosticFormatter extends AbstractDiagnosticFormatter {
}
}
+ public String formatMessage(JCDiagnostic d, Locale l) {
+ StringBuilder buf = new StringBuilder();
+ Collection args = formatArguments(d, l);
+ buf.append(d.getCode());
+ String sep = ": ";
+ for (Object o : args) {
+ buf.append(sep);
+ buf.append(o);
+ sep = ", ";
+ }
+ if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
+ List subDiags = formatSubdiagnostics(d, null);
+ if (subDiags.nonEmpty()) {
+ sep = "";
+ buf.append(",{");
+ for (String sub : formatSubdiagnostics(d, null)) {
+ buf.append(sep);
+ buf.append("(" + sub + ")");
+ sep = ",";
+ }
+ buf.append('}');
+ }
+ }
+ return buf.toString();
+ }
+
@Override
protected String formatArgument(JCDiagnostic diag, Object arg, Locale l) {
String s;
@@ -83,31 +117,4 @@ public class RawDiagnosticFormatter extends AbstractDiagnosticFormatter {
else
return s;
}
-
- @Override
- protected String formatSubdiagnostics(JCDiagnostic d, Locale l) {
- StringBuilder buf = new StringBuilder();
- String sep = "";
- buf.append(",{");
- for (JCDiagnostic d2 : d.getSubdiagnostics()) {
- buf.append(sep);
- buf.append("(" + format(d2, l) + ")");
- sep = ",";
- }
- buf.append('}');
- return buf.toString();
- }
-
- @Override
- protected String localize(Locale l, String s, Object... args) {
- StringBuffer buf = new StringBuffer();
- buf.append(s);
- String sep = ": ";
- for (Object o : args) {
- buf.append(sep);
- buf.append(o);
- sep = ", ";
- }
- return buf.toString();
- }
}
diff --git a/langtools/test/tools/javac/6304921/T6304921.out b/langtools/test/tools/javac/6304921/T6304921.out
index d69e1bd9aba..7a18b056006 100644
--- a/langtools/test/tools/javac/6304921/T6304921.out
+++ b/langtools/test/tools/javac/6304921/T6304921.out
@@ -1,18 +1,18 @@
T6304921.java:671/671/680: warning: [rawtypes] found raw type: java.util.ArrayList
-missing type parameters for generic class java.util.ArrayList
List list = new ArrayList();
^
+ missing type parameters for generic class java.util.ArrayList
T6304921.java:667/667/682: warning: [unchecked] unchecked conversion
-found : java.util.ArrayList
-required: java.util.List
List list = new ArrayList();
^
+ required: java.util.List
+ found: java.util.ArrayList
error: warnings found and -Werror specified
T6304921.java:727/733/737: cannot find symbol
-symbol : variable orr
-location: class java.lang.System
System.orr.println("abc"); // name not found
^
+ symbol: variable orr
+ location: class java.lang.System
T6304921.java:812/816/822: operator + cannot be applied to int,boolean
return 123 + true; // bad binary expression
^
diff --git a/langtools/test/tools/javac/6668794/badClass/Test.java b/langtools/test/tools/javac/6668794/badClass/Test.java
index 40e514f89a5..e78ce5fcc3d 100644
--- a/langtools/test/tools/javac/6668794/badClass/Test.java
+++ b/langtools/test/tools/javac/6668794/badClass/Test.java
@@ -54,8 +54,8 @@ public class Test {
throw new Error("no diagnostics generated");
String expected = "B.java:6:6: compiler.err.cant.access: p.A, " +
- "(- compiler.misc.bad.class.file.header: A.class, " +
- "(- compiler.misc.class.file.wrong.class: q.A))";
+ "(compiler.misc.bad.class.file.header: A.class, " +
+ "(compiler.misc.class.file.wrong.class: q.A))";
if (!out[0].equals(expected)) {
System.err.println("expected: " + expected);
diff --git a/langtools/test/tools/javac/6668794/badSource/Test.out b/langtools/test/tools/javac/6668794/badSource/Test.out
index e9fbdf99bda..94e1416d7a7 100644
--- a/langtools/test/tools/javac/6668794/badSource/Test.out
+++ b/langtools/test/tools/javac/6668794/badSource/Test.out
@@ -1 +1 @@
-Test.java:10:6: compiler.err.cant.access: p.A, (- compiler.misc.bad.source.file.header: A.java, (- compiler.misc.file.doesnt.contain.class: p.A))
+Test.java:10:6: compiler.err.cant.access: p.A, (compiler.misc.bad.source.file.header: A.java, (compiler.misc.file.doesnt.contain.class: p.A))
diff --git a/langtools/test/tools/javac/6758789/T6758789b.out b/langtools/test/tools/javac/6758789/T6758789b.out
index eae65eb4422..af29552ca25 100644
--- a/langtools/test/tools/javac/6758789/T6758789b.out
+++ b/langtools/test/tools/javac/6758789/T6758789b.out
@@ -1,4 +1,4 @@
-T6758789b.java:39:11: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo
+T6758789b.java:39:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo
T6758789b.java:39:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo, T6758789a.Foo, kindname.class, T6758789a
- compiler.err.warnings.and.werror
1 error
diff --git a/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java b/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java
new file mode 100644
index 00000000000..6ede4dce723
--- /dev/null
+++ b/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java
@@ -0,0 +1,499 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6769027
+ * @summary Source line should be displayed immediately after the first diagnostic line
+ * @author Maurizio Cimadamore
+ * @run main/othervm T6769027
+ */
+import java.net.URI;
+import java.util.regex.Matcher;
+import javax.tools.*;
+import com.sun.tools.javac.util.*;
+
+public class T6769027 {
+
+ enum OutputKind {
+ RAW("rawDiagnostics","rawDiagnostics"),
+ BASIC("","");
+
+ String key;
+ String value;
+
+ void init(Options opts) {
+ opts.put(key, value);
+ }
+
+ OutputKind(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+ }
+
+ enum CaretKind {
+ DEFAULT("", ""),
+ SHOW("showCaret","true"),
+ HIDE("showCaret","false");
+
+ String key;
+ String value;
+
+ void init(Options opts) {
+ opts.put(key, value);
+ }
+
+ CaretKind(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ boolean isEnabled() {
+ return this == DEFAULT || this == SHOW;
+ }
+ }
+
+ enum SourceLineKind {
+ DEFAULT("", ""),
+ AFTER_SUMMARY("sourcePosition", "top"),
+ BOTTOM("sourcePosition", "bottom");
+
+ String key;
+ String value;
+
+ void init(Options opts) {
+ opts.put(key, value);
+ }
+
+ SourceLineKind(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ boolean isAfterSummary() {
+ return this == DEFAULT || this == AFTER_SUMMARY;
+ }
+ }
+
+ enum XDiagsSource {
+ DEFAULT(""),
+ SOURCE("source"),
+ NO_SOURCE("-source");
+
+ String flag;
+
+ void init(Options opts) {
+ if (this != DEFAULT) {
+ String flags = opts.get("diags");
+ flags = flags == null ? flag : flags + "," + flag;
+ opts.put("diags", flags);
+ }
+ }
+
+ XDiagsSource(String flag) {
+ this.flag = flag;
+ }
+
+ String getOutput(CaretKind caretKind, IndentKind indent, OutputKind outKind) {
+ String spaces = (outKind == OutputKind.BASIC) ? indent.string : "";
+ return "\n" + spaces + "This is a source line" +
+ (caretKind.isEnabled() ? "\n" + spaces + " ^" : "");
+ }
+ }
+
+ enum XDiagsCompact {
+ DEFAULT(""),
+ COMPACT("short"),
+ NO_COMPACT("-short");
+
+ String flag;
+
+ void init(Options opts) {
+ if (this != DEFAULT) {
+ String flags = opts.get("diags");
+ flags = flags == null ? flag : flags + "," + flag;
+ opts.put("diags", flags);
+ }
+ }
+
+ XDiagsCompact(String flag) {
+ this.flag = flag;
+ }
+ }
+
+ enum ErrorKind {
+ SINGLE("single",
+ "compiler.err.single: Hello!",
+ "KXThis is a test error message Hello!"),
+ DOUBLE("double",
+ "compiler.err.double: Hello!",
+ "KXThis is a test error message.\n" +
+ "KXYThis is another line of the above error message Hello!");
+
+ String key;
+ String rawOutput;
+ String nonRawOutput;
+
+ String key() {
+ return key;
+ }
+
+ ErrorKind(String key, String rawOutput, String nonRawOutput) {
+ this.key = key;
+ this.rawOutput = rawOutput;
+ this.nonRawOutput = nonRawOutput;
+ }
+
+ String getOutput(OutputKind outKind, IndentKind summaryIndent, IndentKind detailsIndent) {
+ return outKind == OutputKind.RAW ?
+ rawOutput :
+ nonRawOutput.replace("X", summaryIndent.string).replace("Y", detailsIndent.string).replace("K", "");
+ }
+
+ String getOutput(OutputKind outKind, IndentKind summaryIndent, IndentKind detailsIndent, String indent) {
+ return outKind == OutputKind.RAW ?
+ rawOutput :
+ nonRawOutput.replace("X", summaryIndent.string).replace("Y", detailsIndent.string).replace("K", indent);
+ }
+ }
+
+ enum MultilineKind {
+ NONE(0),
+ DOUBLE(1),
+ NESTED(2),
+ DOUBLE_NESTED(3);
+
+ static String[][] rawTemplates = {
+ {"", ",{(E),(E)}", ",{(E,{(E)})}", ",{(E,{(E)}),(E,{(E)})}"}, //ENABLED
+ {"", "", "", "",""}, //DISABLED
+ {"", ",{(E)}", ",{(E,{(E)})}", ",{(E,{(E)})}"}, //LIMIT_LENGTH
+ {"", ",{(E),(E)}", ",{(E)}", ",{(E),(E)}"}, //LIMIT_DEPTH
+ {"", ",{(E)}", ",{(E)}", ",{(E)}"}}; //LIMIT_BOTH
+
+ static String[][] basicTemplates = {
+ {"", "\nE\nE", "\nE\nQ", "\nE\nQ\nE\nQ"}, //ENABLED
+ {"", "", "", "",""}, //DISABLED
+ {"", "\nE", "\nE\nQ", "\nE\nQ"}, //LIMIT_LENGTH
+ {"", "\nE\nE", "\nE", "\nE\nE"}, //LIMIT_DEPTH
+ {"", "\nE", "\nE", "\nE"}}; //LIMIT_BOTH
+
+
+ int index;
+
+ MultilineKind (int index) {
+ this.index = index;
+ }
+
+ boolean isDouble() {
+ return this == DOUBLE || this == DOUBLE_NESTED;
+ }
+
+ boolean isNested() {
+ return this == NESTED || this == DOUBLE_NESTED;
+ }
+
+ String getOutput(OutputKind outKind, ErrorKind errKind, MultilinePolicy policy,
+ IndentKind summaryIndent, IndentKind detailsIndent, IndentKind multiIndent) {
+ String constIndent = (errKind == ErrorKind.DOUBLE) ?
+ summaryIndent.string + detailsIndent.string :
+ summaryIndent.string;
+ constIndent += multiIndent.string;
+
+ String errMsg1 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent);
+ String errMsg2 = errKind.getOutput(outKind, summaryIndent, detailsIndent, constIndent + constIndent);
+
+ errMsg1 = errMsg1.replaceAll("compiler.err", "compiler.misc");
+ errMsg1 = errMsg1.replaceAll("error message", "subdiagnostic");
+ errMsg2 = errMsg2.replaceAll("compiler.err", "compiler.misc");
+ errMsg2 = errMsg2.replaceAll("error message", "subdiagnostic");
+
+ String template = outKind == OutputKind.RAW ?
+ rawTemplates[policy.index][index] :
+ basicTemplates[policy.index][index];
+
+ template = template.replaceAll("E", errMsg1);
+ return template.replaceAll("Q", errMsg2);
+ }
+ }
+
+ enum MultilinePolicy {
+ ENABLED(0, "multilinePolicy", "enabled"),
+ DISABLED(1, "multilinePolicy", "disabled"),
+ LIMIT_LENGTH(2, "multilinePolicy", "limit:1:*"),
+ LIMIT_DEPTH(3, "multilinePolicy", "limit:*:1"),
+ LIMIT_BOTH(4, "multilinePolicy", "limit:1:1");
+
+ String name;
+ String value;
+ int index;
+
+ MultilinePolicy(int index, String name, String value) {
+ this.name = name;
+ this.value = value;
+ this.index = index;
+ }
+
+ void init(Options options) {
+ options.put(name, value);
+ }
+ }
+
+ enum PositionKind {
+ NOPOS(Position.NOPOS, "- ", "error: "),
+ POS(5, "/Test.java:1:6: ", "myfo:/Test.java:1: ");
+
+ int pos;
+ String rawOutput;
+ String nonRawOutput;
+
+ PositionKind(int pos, String rawOutput, String nonRawOutput) {
+ this.pos = pos;
+ this.rawOutput = rawOutput;
+ this.nonRawOutput = nonRawOutput;
+ }
+
+ JCDiagnostic.DiagnosticPosition pos() {
+ return new JCDiagnostic.SimpleDiagnosticPosition(pos);
+ }
+
+ String getOutput(OutputKind outputKind) {
+ return outputKind == OutputKind.RAW ?
+ rawOutput :
+ nonRawOutput;
+ }
+ }
+
+ static class MyFileObject extends SimpleJavaFileObject {
+ private String text;
+ public MyFileObject(String text) {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ this.text = text;
+ }
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return text;
+ }
+ }
+
+ enum IndentKind {
+ NONE(""),
+ CUSTOM(" ");
+
+ String string;
+
+ IndentKind(String indent) {
+ string = indent;
+ }
+ }
+
+ class MyLog extends Log {
+ MyLog(Context ctx) {
+ super(ctx);
+ }
+
+ @Override
+ protected java.io.PrintWriter getWriterForDiagnosticType(JCDiagnostic.DiagnosticType dt) {
+ return new java.io.PrintWriter(System.out);
+ }
+
+ @Override
+ protected boolean shouldReport(JavaFileObject jfo, int pos) {
+ return true;
+ }
+ }
+
+ int nerrors = 0;
+
+ void exec(OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
+ MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
+ XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
+ IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
+ IndentKind subdiagsIndent) {
+ Context ctx = new Context();
+ Options options = Options.instance(ctx);
+ outputKind.init(options);
+ multiPolicy.init(options);
+ xdiagsSource.init(options);
+ xdiagsCompact.init(options);
+ caretKind.init(options);
+ sourceLineKind.init(options);
+ String indentString = "";
+ indentString = (summaryIndent == IndentKind.CUSTOM) ? "3" : "0";
+ indentString += (detailsIndent == IndentKind.CUSTOM) ? "|3" : "|0";
+ indentString += (sourceIndent == IndentKind.CUSTOM) ? "|3" : "|0";
+ indentString += (subdiagsIndent == IndentKind.CUSTOM) ? "|3" : "|0";
+ options.put("diagsIndentation", indentString);
+ MyLog log = new MyLog(ctx);
+ JavacMessages messages = JavacMessages.instance(ctx);
+ messages.add("tester");
+ JCDiagnostic.Factory diags = JCDiagnostic.Factory.instance(ctx);
+ log.useSource(new MyFileObject("This is a source line"));
+ JCDiagnostic d = diags.error(log.currentSource(),
+ posKind.pos(),
+ errorKind.key(), "Hello!");
+ if (multiKind != MultilineKind.NONE) {
+ JCDiagnostic sub = diags.fragment(errorKind.key(), "Hello!");
+ if (multiKind.isNested())
+ sub = new JCDiagnostic.MultilineDiagnostic(sub, List.of(sub));
+ List subdiags = multiKind.isDouble() ?
+ List.of(sub, sub) :
+ List.of(sub);
+ d = new JCDiagnostic.MultilineDiagnostic(d, subdiags);
+ }
+ String diag = log.getDiagnosticFormatter().format(d, messages.getCurrentLocale());
+ checkOutput(diag,
+ outputKind,
+ errorKind,
+ multiKind,
+ multiPolicy,
+ posKind,
+ xdiagsSource,
+ xdiagsCompact,
+ caretKind,
+ sourceLineKind,
+ summaryIndent,
+ detailsIndent,
+ sourceIndent,
+ subdiagsIndent);
+ }
+
+ void test() {
+ for (OutputKind outputKind : OutputKind.values()) {
+ for (ErrorKind errKind : ErrorKind.values()) {
+ for (MultilineKind multiKind : MultilineKind.values()) {
+ for (MultilinePolicy multiPolicy : MultilinePolicy.values()) {
+ for (PositionKind posKind : PositionKind.values()) {
+ for (XDiagsSource xdiagsSource : XDiagsSource.values()) {
+ for (XDiagsCompact xdiagsCompact : XDiagsCompact.values()) {
+ for (CaretKind caretKind : CaretKind.values()) {
+ for (SourceLineKind sourceLineKind : SourceLineKind.values()) {
+ for (IndentKind summaryIndent : IndentKind.values()) {
+ for (IndentKind detailsIndent : IndentKind.values()) {
+ for (IndentKind sourceIndent : IndentKind.values()) {
+ for (IndentKind subdiagsIndent : IndentKind.values()) {
+ exec(outputKind,
+ errKind,
+ multiKind,
+ multiPolicy,
+ posKind,
+ xdiagsSource,
+ xdiagsCompact,
+ caretKind,
+ sourceLineKind,
+ summaryIndent,
+ detailsIndent,
+ sourceIndent,
+ subdiagsIndent);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (nerrors != 0)
+ throw new AssertionError(nerrors + " errors found");
+ }
+
+ void printInfo(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
+ MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
+ XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
+ IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
+ IndentKind subdiagsIndent, String errorLine) {
+ String sep = "*********************************************************";
+ String desc = "raw=" + outputKind + " pos=" + posKind + " key=" + errorKind.key() +
+ " multiline=" + multiKind +" multiPolicy=" + multiPolicy.value +
+ " diags= " + java.util.Arrays.asList(xdiagsSource.flag, xdiagsCompact.flag) +
+ " caret=" + caretKind + " sourcePosition=" + sourceLineKind +
+ " summaryIndent=" + summaryIndent + " detailsIndent=" + detailsIndent +
+ " sourceIndent=" + sourceIndent + " subdiagsIndent=" + subdiagsIndent;
+ System.out.println(sep);
+ System.out.println(desc);
+ System.out.println(sep);
+ System.out.println(msg);
+ System.out.println("Diagnostic formatting problem - expected diagnostic...\n" + errorLine);
+ }
+
+ void checkOutput(String msg, OutputKind outputKind, ErrorKind errorKind, MultilineKind multiKind,
+ MultilinePolicy multiPolicy, PositionKind posKind, XDiagsSource xdiagsSource,
+ XDiagsCompact xdiagsCompact, CaretKind caretKind, SourceLineKind sourceLineKind,
+ IndentKind summaryIndent, IndentKind detailsIndent, IndentKind sourceIndent,
+ IndentKind subdiagsIndent) {
+ boolean shouldPrintSource = posKind == PositionKind.POS &&
+ xdiagsSource != XDiagsSource.NO_SOURCE &&
+ (xdiagsSource == XDiagsSource.SOURCE ||
+ outputKind == OutputKind.BASIC);
+ String errorLine = posKind.getOutput(outputKind) +
+ errorKind.getOutput(outputKind, summaryIndent, detailsIndent);
+ if (xdiagsCompact != XDiagsCompact.COMPACT)
+ errorLine += multiKind.getOutput(outputKind, errorKind, multiPolicy, summaryIndent, detailsIndent, subdiagsIndent);
+ String[] lines = errorLine.split("\n");
+ if (xdiagsCompact == XDiagsCompact.COMPACT) {
+ errorLine = lines[0];
+ lines = new String[] {errorLine};
+ }
+ if (shouldPrintSource) {
+ if (sourceLineKind.isAfterSummary()) {
+ String sep = "\n";
+ if (lines.length == 1) {
+ errorLine += "\n";
+ sep = "";
+ }
+ errorLine = errorLine.replaceFirst("\n",
+ Matcher.quoteReplacement(xdiagsSource.getOutput(caretKind, sourceIndent, outputKind) + sep));
+ }
+ else
+ errorLine += xdiagsSource.getOutput(caretKind, sourceIndent, outputKind);
+ }
+
+ if (!msg.equals(errorLine)) {
+ printInfo(msg,
+ outputKind,
+ errorKind,
+ multiKind,
+ multiPolicy,
+ posKind,
+ xdiagsSource,
+ xdiagsCompact,
+ caretKind,
+ sourceLineKind,
+ summaryIndent,
+ detailsIndent,
+ sourceIndent,
+ subdiagsIndent,
+ errorLine);
+ nerrors++;
+ }
+ }
+
+ public static void main(String... args) throws Exception {
+ new T6769027().test();
+ }
+}
diff --git a/langtools/test/tools/javac/Diagnostics/6769027/tester.properties b/langtools/test/tools/javac/Diagnostics/6769027/tester.properties
new file mode 100644
index 00000000000..666a52eb198
--- /dev/null
+++ b/langtools/test/tools/javac/Diagnostics/6769027/tester.properties
@@ -0,0 +1,13 @@
+compiler.err.single=\
+ This is a test error message {0}
+
+compiler.err.double=\
+ This is a test error message.\n\
+ This is another line of the above error message {0}
+
+compiler.misc.single=\
+ This is a test subdiagnostic {0}
+
+compiler.misc.double=\
+ This is a test subdiagnostic.\n\
+ This is another line of the above subdiagnostic {0}
diff --git a/langtools/test/tools/javac/ExtendArray.out b/langtools/test/tools/javac/ExtendArray.out
index 86878431daa..ad5d8877c71 100644
--- a/langtools/test/tools/javac/ExtendArray.out
+++ b/langtools/test/tools/javac/ExtendArray.out
@@ -1,6 +1,6 @@
ExtendArray.java:11: unexpected type
-found : java.lang.Object[]
-required: class
public class ExtendArray extends Object[] {}
^
+ required: class
+ found: java.lang.Object[]
1 error
diff --git a/langtools/test/tools/javac/T5048776b.out b/langtools/test/tools/javac/T5048776b.out
index 5eb9b79ef59..ab9688edb01 100644
--- a/langtools/test/tools/javac/T5048776b.out
+++ b/langtools/test/tools/javac/T5048776b.out
@@ -1,3 +1,3 @@
-T5048776.java:12:10: compiler.warn.override.varargs.missing: (- compiler.misc.varargs.override: foo(java.lang.Object...), A1a, foo(java.lang.Object[]), A1)
-T5048776.java:20:10: compiler.warn.override.varargs.extra: (- compiler.misc.varargs.override: foo(java.lang.Object[]), A2a, foo(java.lang.Object...), A2)
+T5048776.java:12:10: compiler.warn.override.varargs.missing: (compiler.misc.varargs.override: foo(java.lang.Object...), A1a, foo(java.lang.Object[]), A1)
+T5048776.java:20:10: compiler.warn.override.varargs.extra: (compiler.misc.varargs.override: foo(java.lang.Object[]), A2a, foo(java.lang.Object...), A2)
2 warnings
diff --git a/langtools/test/tools/javac/T6214885a.out b/langtools/test/tools/javac/T6214885a.out
index f09fff67b0e..8ca1aaced2d 100644
--- a/langtools/test/tools/javac/T6214885a.out
+++ b/langtools/test/tools/javac/T6214885a.out
@@ -1,6 +1,6 @@
T6214885.java:11 cannot find symbol
-symbol : variable x
-location: class T6214885
x = 1;
^
+ symbol: variable x
+ location: class T6214885
1 error
diff --git a/langtools/test/tools/javac/T6214885b.out b/langtools/test/tools/javac/T6214885b.out
index 1ee86363a12..4dc30190da0 100644
--- a/langtools/test/tools/javac/T6214885b.out
+++ b/langtools/test/tools/javac/T6214885b.out
@@ -1,6 +1,6 @@
T6214885.java:11:9 cannot find symbol
-symbol : variable x
-location: class T6214885
x = 1;
^
+ symbol: variable x
+ location: class T6214885
1 error
diff --git a/langtools/test/tools/javac/T6230128.out b/langtools/test/tools/javac/T6230128.out
index d6a08595385..32863533ef1 100644
--- a/langtools/test/tools/javac/T6230128.out
+++ b/langtools/test/tools/javac/T6230128.out
@@ -1,2 +1,2 @@
-T6230128.java:11:10: compiler.err.override.weaker.access: (- compiler.misc.cant.override: foo(java.lang.Object...), A1a, foo(java.lang.Object[]), A1), public
+T6230128.java:11:10: compiler.err.override.weaker.access: (compiler.misc.cant.override: foo(java.lang.Object...), A1a, foo(java.lang.Object[]), A1), public
1 error
diff --git a/langtools/test/tools/javac/annotations/6365854/test1.out b/langtools/test/tools/javac/annotations/6365854/test1.out
index ed81b94111b..00eaf216db2 100644
--- a/langtools/test/tools/javac/annotations/6365854/test1.out
+++ b/langtools/test/tools/javac/annotations/6365854/test1.out
@@ -1,2 +1,2 @@
-- compiler.warn.annotation.method.not.found.reason: test.annotation.TestAnnotation, test, (- compiler.misc.class.file.not.found: test.annotation.TestAnnotation)
+- compiler.warn.annotation.method.not.found.reason: test.annotation.TestAnnotation, test, (compiler.misc.class.file.not.found: test.annotation.TestAnnotation)
1 warning
diff --git a/langtools/test/tools/javac/cast/6557182/T6557182.out b/langtools/test/tools/javac/cast/6557182/T6557182.out
index 9ebe10e9c9f..5f25497ace2 100644
--- a/langtools/test/tools/javac/cast/6557182/T6557182.out
+++ b/langtools/test/tools/javac/cast/6557182/T6557182.out
@@ -1,4 +1,4 @@
-T6557182.java:35:56: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T, java.lang.Comparable
-T6557182.java:39:56: compiler.warn.prob.found.req: (- compiler.misc.unchecked.cast.to.type), T, java.lang.Comparable
+T6557182.java:35:56: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T, java.lang.Comparable
+T6557182.java:39:56: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T, java.lang.Comparable
1 error
1 warning
diff --git a/langtools/test/tools/javac/cast/6665356/T6665356.out b/langtools/test/tools/javac/cast/6665356/T6665356.out
index 029c66400a2..1db10c64ca4 100644
--- a/langtools/test/tools/javac/cast/6665356/T6665356.out
+++ b/langtools/test/tools/javac/cast/6665356/T6665356.out
@@ -1,8 +1,8 @@
-T6665356.java:54:55: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer super java.lang.Number>.Inner
-T6665356.java:58:58: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner super java.lang.Number>
-T6665356.java:62:65: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer super java.lang.Number>.Inner super java.lang.Number>
-T6665356.java:66:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer extends java.lang.String>.Inner
-T6665356.java:70:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner extends java.lang.String>
-T6665356.java:74:55: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer super java.lang.String>.Inner
-T6665356.java:78:58: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner super java.lang.String>
+T6665356.java:54:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer super java.lang.Number>.Inner
+T6665356.java:58:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner super java.lang.Number>
+T6665356.java:62:65: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer super java.lang.Number>.Inner super java.lang.Number>
+T6665356.java:66:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer extends java.lang.String>.Inner
+T6665356.java:70:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner extends java.lang.String>
+T6665356.java:74:55: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer super java.lang.String>.Inner
+T6665356.java:78:58: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6665356.Outer.Inner, T6665356.Outer.Inner super java.lang.String>
7 errors
\ No newline at end of file
diff --git a/langtools/test/tools/javac/cast/6795580/T6795580.out b/langtools/test/tools/javac/cast/6795580/T6795580.out
index f754e1dc2c5..a5d70401650 100644
--- a/langtools/test/tools/javac/cast/6795580/T6795580.out
+++ b/langtools/test/tools/javac/cast/6795580/T6795580.out
@@ -1,8 +1,8 @@
-T6795580.java:54:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer super java.lang.Number>.Inner[]
-T6795580.java:58:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner super java.lang.Number>[]
-T6795580.java:62:67: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer super java.lang.Number>.Inner super java.lang.Number>[]
-T6795580.java:66:59: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer extends java.lang.String>.Inner[]
-T6795580.java:70:62: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner extends java.lang.String>[]
-T6795580.java:74:57: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer super java.lang.String>.Inner[]
-T6795580.java:78:60: compiler.err.prob.found.req: (- compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner super java.lang.String>[]
+T6795580.java:54:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer super java.lang.Number>.Inner[]
+T6795580.java:58:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner super java.lang.Number>[]
+T6795580.java:62:67: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer super java.lang.Number>.Inner super java.lang.Number>[]
+T6795580.java:66:59: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer extends java.lang.String>.Inner[]
+T6795580.java:70:62: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner extends java.lang.String>[]
+T6795580.java:74:57: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer super java.lang.String>.Inner[]
+T6795580.java:78:60: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), T6795580.Outer.Inner[], T6795580.Outer.Inner super java.lang.String>[]
7 errors
diff --git a/langtools/test/tools/javac/generics/6207386/T6207386.out b/langtools/test/tools/javac/generics/6207386/T6207386.out
index bd98d3123c8..768c5c2d341 100644
--- a/langtools/test/tools/javac/generics/6207386/T6207386.out
+++ b/langtools/test/tools/javac/generics/6207386/T6207386.out
@@ -1,2 +1,2 @@
-T6207386.java:13:30: compiler.err.prob.found.req: (- compiler.misc.incompatible.types), X, T6207386.F super X>
+T6207386.java:13:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), X, T6207386.F super X>
1 error
diff --git a/langtools/test/tools/javac/generics/inference/6315770/T6315770.out b/langtools/test/tools/javac/generics/inference/6315770/T6315770.out
index 8dc60f97d6d..dd1fdb9e3d3 100644
--- a/langtools/test/tools/javac/generics/inference/6315770/T6315770.out
+++ b/langtools/test/tools/javac/generics/inference/6315770/T6315770.out
@@ -1,3 +1,3 @@
-T6315770.java:39:42: compiler.err.undetermined.type.1: T6315770, (- compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable)
-T6315770.java:40:40: compiler.err.prob.found.req: (- compiler.misc.incompatible.types.1: (- compiler.misc.no.conforming.instance.exists: T, T6315770, T6315770 super java.lang.String>)), T6315770, T6315770 super java.lang.String>
+T6315770.java:39:42: compiler.err.undetermined.type.1: T6315770, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable)
+T6315770.java:40:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T6315770, T6315770 super java.lang.String>)), T6315770, T6315770 super java.lang.String>
2 errors
diff --git a/langtools/test/tools/javac/generics/inference/6718364/T6718364.out b/langtools/test/tools/javac/generics/inference/6718364/T6718364.out
index e049269d284..1b5ed9ad241 100644
--- a/langtools/test/tools/javac/generics/inference/6718364/T6718364.out
+++ b/langtools/test/tools/javac/generics/inference/6718364/T6718364.out
@@ -1,3 +1,3 @@
-T6718364.java:36:32: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6718364.X, T6718364.X
+T6718364.java:36:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6718364.X, T6718364.X
T6718364.java:36:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6718364.X,T, T6718364.X>,T6718364.X, kindname.class, T6718364
2 warnings
\ No newline at end of file
diff --git a/langtools/test/tools/javac/generics/typevars/6680106/T6680106.out b/langtools/test/tools/javac/generics/typevars/6680106/T6680106.out
index 06f1eaf100f..f26d2a47c23 100644
--- a/langtools/test/tools/javac/generics/typevars/6680106/T6680106.out
+++ b/langtools/test/tools/javac/generics/typevars/6680106/T6680106.out
@@ -1,13 +1,13 @@
-T6680106.java:34:25: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
-T6680106.java:35:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
-T6680106.java:35:40: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
-T6680106.java:36:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
-T6680106.java:36:40: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class)
-T6680106.java:36:55: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
-T6680106.java:37:30: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
-T6680106.java:38:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
-T6680106.java:38:50: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
-T6680106.java:39:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class)
-T6680106.java:39:50: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class)
-T6680106.java:39:70: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class)
+T6680106.java:34:25: compiler.err.type.found.req: T[], (compiler.misc.type.req.class)
+T6680106.java:35:25: compiler.err.type.found.req: S[], (compiler.misc.type.req.class)
+T6680106.java:35:40: compiler.err.type.found.req: T[], (compiler.misc.type.req.class)
+T6680106.java:36:25: compiler.err.type.found.req: S[], (compiler.misc.type.req.class)
+T6680106.java:36:40: compiler.err.type.found.req: U[], (compiler.misc.type.req.class)
+T6680106.java:36:55: compiler.err.type.found.req: T[], (compiler.misc.type.req.class)
+T6680106.java:37:30: compiler.err.type.found.req: T[], (compiler.misc.type.req.class)
+T6680106.java:38:30: compiler.err.type.found.req: S[], (compiler.misc.type.req.class)
+T6680106.java:38:50: compiler.err.type.found.req: T[], (compiler.misc.type.req.class)
+T6680106.java:39:30: compiler.err.type.found.req: S[], (compiler.misc.type.req.class)
+T6680106.java:39:50: compiler.err.type.found.req: U[], (compiler.misc.type.req.class)
+T6680106.java:39:70: compiler.err.type.found.req: T[], (compiler.misc.type.req.class)
12 errors
\ No newline at end of file
diff --git a/langtools/test/tools/javac/missingSuperRecovery/MissingSuperRecovery.out b/langtools/test/tools/javac/missingSuperRecovery/MissingSuperRecovery.out
index 94a21c0ae5f..b049ccd5aab 100644
--- a/langtools/test/tools/javac/missingSuperRecovery/MissingSuperRecovery.out
+++ b/langtools/test/tools/javac/missingSuperRecovery/MissingSuperRecovery.out
@@ -1,5 +1,5 @@
MissingSuperRecovery.java:15: cannot access base
-class file for base not found
public class MissingSuperRecovery extends impl {
^
+ class file for base not found
1 error
diff --git a/langtools/test/tools/javac/unicode/UnicodeNewline.out b/langtools/test/tools/javac/unicode/UnicodeNewline.out
index 366d8c6eb0a..5b71702fb4d 100644
--- a/langtools/test/tools/javac/unicode/UnicodeNewline.out
+++ b/langtools/test/tools/javac/unicode/UnicodeNewline.out
@@ -1,6 +1,6 @@
UnicodeNewline.java:11: cannot find symbol
-symbol : class xyzzy
-location: class UnicodeNewline
xyzzy plugh; // error should be HERE
^
+ symbol: class xyzzy
+ location: class UnicodeNewline
1 error
From 030a13d8feee89f8852a4bd66f45a5c45ed160e3 Mon Sep 17 00:00:00 2001
From: Alan Bateman
Date: Sun, 15 Feb 2009 12:25:54 +0000
Subject: [PATCH 029/283] 6781363: New I/O: Update socket-channel API to
jsr203/nio2-b99 4313887: New I/O: Improved filesystem interface 4607272: New
I/O: Support asynchronous I/O
Reviewed-by: sherman, chegar
---
jdk/make/docs/CORE_PKGS.gmk | 5 +-
jdk/make/docs/NON_CORE_PKGS.gmk | 5 +-
jdk/make/java/nio/Exportedfiles.gmk | 4 +-
jdk/make/java/nio/FILES_c.gmk | 4 +-
jdk/make/java/nio/FILES_java.gmk | 137 +-
jdk/make/java/nio/Makefile | 214 ++-
jdk/make/java/nio/mapfile-linux | 113 +-
jdk/make/java/nio/mapfile-solaris | 101 +-
jdk/make/mksample/nio/Makefile | 4 +-
jdk/make/mksample/nio/file/Makefile | 56 +
.../com/sun/nio/file/ExtendedCopyOption.java | 43 +
.../com/sun/nio/file/ExtendedOpenOption.java | 50 +
.../nio/file/ExtendedWatchEventModifier.java | 43 +
.../file/SensitivityWatchEventModifier.java | 62 +
jdk/src/share/classes/java/io/File.java | 349 +++-
.../share/classes/java/io/FilePermission.java | 58 +-
.../java/net/StandardProtocolFamily.java | 4 +-
.../java/net/StandardSocketOption.java | 39 +-
.../nio/channels/AsynchronousByteChannel.java | 205 +++
.../nio/channels/AsynchronousChannel.java | 116 ++
.../channels/AsynchronousChannelGroup.java | 344 ++++
.../channels/AsynchronousDatagramChannel.java | 718 ++++++++
.../nio/channels/AsynchronousFileChannel.java | 774 ++++++++
.../AsynchronousServerSocketChannel.java | 303 ++++
.../channels/AsynchronousSocketChannel.java | 670 +++++++
.../classes/java/nio/channels/Channels.java | 157 +-
.../java/nio/channels/CompletionHandler.java | 77 +
.../java/nio/channels/DatagramChannel.java | 18 +-
.../java/nio/channels/FileChannel.java | 252 ++-
.../classes/java/nio/channels/FileLock.java | 77 +-
.../java/nio/channels/MembershipKey.java | 22 +-
.../java/nio/channels/MulticastChannel.java | 27 +-
.../java/nio/channels/NetworkChannel.java | 16 +-
.../nio/channels/SeekableByteChannel.java | 168 ++
.../nio/channels/ServerSocketChannel.java | 6 +-
.../java/nio/channels/SocketChannel.java | 16 +-
.../classes/java/nio/channels/exceptions | 37 +-
.../java/nio/channels/package-info.java | 64 +-
.../spi/AsynchronousChannelProvider.java | 264 +++
.../nio/channels/spi/SelectorProvider.java | 6 +-
.../java/nio/channels/spi/package.html | 6 +-
.../java/nio/file/AccessDeniedException.java | 68 +
.../classes/java/nio/file/AccessMode.java | 49 +
.../file/AtomicMoveNotSupportedException.java | 56 +
.../file/ClosedDirectoryStreamException.java | 45 +
.../nio/file/ClosedFileSystemException.java | 43 +
.../nio/file/ClosedWatchServiceException.java | 43 +
.../classes/java/nio/file/CopyOption.java | 41 +
.../nio/file/DirectoryNotEmptyException.java | 49 +
.../java/nio/file/DirectoryStream.java | 138 ++
.../java/nio/file/DirectoryStreamFilters.java | 210 +++
.../classes/java/nio/file/FileAction.java | 64 +
.../nio/file/FileAlreadyExistsException.java | 63 +
.../share/classes/java/nio/file/FileRef.java | 424 +++++
.../classes/java/nio/file/FileStore.java | 169 ++
.../classes/java/nio/file/FileSystem.java | 453 +++++
.../FileSystemAlreadyExistsException.java | 53 +
.../java/nio/file/FileSystemException.java | 125 ++
.../nio/file/FileSystemNotFoundException.java | 52 +
.../classes/java/nio/file/FileSystems.java | 413 +++++
.../classes/java/nio/file/FileTreeWalker.java | 244 +++
.../java/nio/file/FileVisitOption.java | 45 +
.../java/nio/file/FileVisitResult.java | 62 +
.../classes/java/nio/file/FileVisitor.java | 175 ++
.../share/classes/java/nio/file/Files.java | 406 +++++
.../java/nio/file/InvalidPathException.java | 130 ++
.../classes/java/nio/file/LinkOption.java | 43 +
.../classes/java/nio/file/LinkPermission.java | 107 ++
.../java/nio/file/NoSuchFileException.java | 63 +
.../java/nio/file/NotDirectoryException.java | 49 +
.../java/nio/file/NotLinkException.java | 63 +
.../classes/java/nio/file/OpenOption.java | 45 +
jdk/src/share/classes/java/nio/file/Path.java | 1612 +++++++++++++++++
.../classes/java/nio/file/PathMatcher.java | 49 +
.../share/classes/java/nio/file/Paths.java | 123 ++
.../nio/file/ProviderMismatchException.java | 53 +
.../nio/file/ProviderNotFoundException.java | 52 +
.../nio/file/ReadOnlyFileSystemException.java | 43 +
.../java/nio/file/SecureDirectoryStream.java | 324 ++++
.../java/nio/file/SimpleFileVisitor.java | 121 ++
.../java/nio/file/StandardCopyOption.java | 47 +
.../java/nio/file/StandardOpenOption.java | 125 ++
.../java/nio/file/StandardWatchEventKind.java | 94 +
.../classes/java/nio/file/WatchEvent.java | 116 ++
.../share/classes/java/nio/file/WatchKey.java | 138 ++
.../classes/java/nio/file/WatchService.java | 178 ++
.../classes/java/nio/file/Watchable.java | 127 ++
.../java/nio/file/attribute/AclEntry.java | 394 ++++
.../java/nio/file/attribute/AclEntryFlag.java | 65 +
.../file/attribute/AclEntryPermission.java | 130 ++
.../java/nio/file/attribute/AclEntryType.java | 56 +
.../file/attribute/AclFileAttributeView.java | 211 +++
.../nio/file/attribute/AttributeView.java | 118 ++
.../java/nio/file/attribute/Attributes.java | 703 +++++++
.../attribute/BasicFileAttributeView.java | 186 ++
.../file/attribute/BasicFileAttributes.java | 163 ++
.../file/attribute/DosFileAttributeView.java | 179 ++
.../nio/file/attribute/DosFileAttributes.java | 84 +
.../nio/file/attribute/FileAttribute.java | 50 +
.../nio/file/attribute/FileAttributeView.java | 43 +
.../attribute/FileOwnerAttributeView.java | 101 ++
.../attribute/FileStoreAttributeView.java | 38 +
.../FileStoreSpaceAttributeView.java | 85 +
.../attribute/FileStoreSpaceAttributes.java | 66 +
.../nio/file/attribute/GroupPrincipal.java | 42 +
.../attribute/PosixFileAttributeView.java | 196 ++
.../file/attribute/PosixFileAttributes.java | 77 +
.../file/attribute/PosixFilePermission.java | 86 +
.../file/attribute/PosixFilePermissions.java | 180 ++
.../UserDefinedFileAttributeView.java | 232 +++
.../nio/file/attribute/UserPrincipal.java | 54 +
.../attribute/UserPrincipalLookupService.java | 104 ++
.../UserPrincipalNotFoundException.java | 64 +
.../java/nio/file/attribute/package-info.java | 119 ++
.../classes/java/nio/file/package-info.java | 116 ++
.../java/nio/file/spi/AbstractPath.java | 568 ++++++
.../java/nio/file/spi/FileSystemProvider.java | 434 +++++
.../java/nio/file/spi/FileTypeDetector.java | 106 ++
.../java/nio/file/spi/package-info.java | 39 +
jdk/src/share/classes/java/util/Scanner.java | 46 +-
.../classes/sun/nio/ch/AbstractFuture.java | 63 +
.../nio/ch/AsynchronousChannelGroupImpl.java | 341 ++++
.../nio/ch/AsynchronousFileChannelImpl.java | 164 ++
.../AsynchronousServerSocketChannelImpl.java | 219 +++
.../nio/ch/AsynchronousSocketChannelImpl.java | 542 ++++++
.../share/classes/sun/nio/ch/Cancellable.java | 39 +
.../classes/sun/nio/ch/CompletedFuture.java | 113 ++
.../sun/nio/ch/DatagramChannelImpl.java | 102 +-
.../sun/nio/ch/ExtendedSocketOption.java | 2 +-
.../classes/sun/nio/ch/FileChannelImpl.java | 399 +---
.../classes/sun/nio/ch/FileDispatcher.java | 48 +
.../classes/sun/nio/ch/FileLockImpl.java | 21 +-
.../classes/sun/nio/ch/FileLockTable.java | 282 +++
.../share/classes/sun/nio/ch/Groupable.java | 35 +
jdk/src/share/classes/sun/nio/ch/IOUtil.java | 255 +--
jdk/src/share/classes/sun/nio/ch/Invoker.java | 261 +++
.../classes/sun/nio/ch/MembershipKeyImpl.java | 20 +-
.../sun/nio/ch/MembershipRegistry.java | 22 +-
.../classes/sun/nio/ch/NativeThreadSet.java | 14 +-
jdk/src/share/classes/sun/nio/ch/Net.java | 6 +-
.../share/classes/sun/nio/ch/OptionKey.java | 2 +-
.../classes/sun/nio/ch/PendingFuture.java | 257 +++
jdk/src/share/classes/sun/nio/ch/Reflect.java | 6 +-
.../sun/nio/ch/ServerSocketChannelImpl.java | 23 +-
...SimpleAsynchronousDatagramChannelImpl.java | 612 +++++++
.../ch/SimpleAsynchronousFileChannelImpl.java | 426 +++++
.../classes/sun/nio/ch/SocketChannelImpl.java | 24 +-
.../share/classes/sun/nio/ch/ThreadPool.java | 176 ++
jdk/src/share/classes/sun/nio/ch/Util.java | 6 +-
.../nio/fs/AbstractAclFileAttributeView.java | 110 ++
.../fs/AbstractBasicFileAttributeView.java | 208 +++
.../AbstractFileStoreSpaceAttributeView.java | 119 ++
.../sun/nio/fs/AbstractFileTypeDetector.java | 69 +
.../classes/sun/nio/fs/AbstractPoller.java | 290 +++
.../AbstractUserDefinedFileAttributeView.java | 124 ++
.../classes/sun/nio/fs/AbstractWatchKey.java | 180 ++
.../sun/nio/fs/AbstractWatchService.java | 161 ++
.../share/classes/sun/nio/fs/Cancellable.java | 137 ++
.../nio/fs/FileOwnerAttributeViewImpl.java | 111 ++
jdk/src/share/classes/sun/nio/fs/Globs.java | 217 +++
.../share/classes/sun/nio/fs/MimeType.java | 73 +
.../classes/sun/nio/fs/NativeBuffer.java | 87 +
.../classes/sun/nio/fs/NativeBuffers.java | 140 ++
.../sun/nio/fs/PollingWatchService.java | 429 +++++
jdk/src/share/classes/sun/nio/fs/Reflect.java | 63 +
.../sun/security/util/SecurityConstants.java | 3 +-
.../sun/nio/ch/genSocketOptionRegistry.c | 8 +-
jdk/src/share/sample/nio/file/AclEdit.java | 296 +++
jdk/src/share/sample/nio/file/Chmod.java | 347 ++++
jdk/src/share/sample/nio/file/Copy.java | 217 +++
jdk/src/share/sample/nio/file/DiskUsage.java | 74 +
jdk/src/share/sample/nio/file/FileType.java | 57 +
jdk/src/share/sample/nio/file/WatchDir.java | 196 ++
jdk/src/share/sample/nio/file/Xdd.java | 112 ++
.../sun/nio/ch/DatagramDispatcher.java | 6 +-
.../DefaultAsynchronousChannelProvider.java | 56 +
.../sun/nio/ch/DevPollArrayWrapper.java | 4 +-
.../sun/nio/ch/DevPollSelectorImpl.java | 6 +-
jdk/src/solaris/classes/sun/nio/ch/EPoll.java | 121 ++
.../classes/sun/nio/ch/EPollArrayWrapper.java | 4 +-
.../solaris/classes/sun/nio/ch/EPollPort.java | 322 ++++
.../classes/sun/nio/ch/EPollSelectorImpl.java | 6 +-
...ispatcher.java => FileDispatcherImpl.java} | 45 +-
.../ch/LinuxAsynchronousChannelProvider.java | 99 +
.../classes/sun/nio/ch/PollSelectorImpl.java | 6 +-
jdk/src/solaris/classes/sun/nio/ch/Port.java | 168 ++
.../classes/sun/nio/ch/SinkChannelImpl.java | 4 +-
.../classes/sun/nio/ch/SocketDispatcher.java | 14 +-
.../SolarisAsynchronousChannelProvider.java | 102 ++
.../classes/sun/nio/ch/SolarisEventPort.java | 244 +++
.../classes/sun/nio/ch/SourceChannelImpl.java | 4 +-
...ixAsynchronousServerSocketChannelImpl.java | 327 ++++
.../ch/UnixAsynchronousSocketChannelImpl.java | 673 +++++++
.../sun/nio/fs/DefaultFileSystemProvider.java | 73 +
.../sun/nio/fs/DefaultFileTypeDetector.java | 36 +
.../sun/nio/fs/GnomeFileTypeDetector.java | 101 ++
.../sun/nio/fs/LinuxDosFileAttributeView.java | 297 +++
.../classes/sun/nio/fs/LinuxFileStore.java | 152 ++
.../classes/sun/nio/fs/LinuxFileSystem.java | 175 ++
.../sun/nio/fs/LinuxFileSystemProvider.java | 41 +
.../sun/nio/fs/LinuxNativeDispatcher.java | 126 ++
.../fs/LinuxUserDefinedFileAttributeView.java | 350 ++++
.../classes/sun/nio/fs/LinuxWatchService.java | 466 +++++
.../nio/fs/SolarisAclFileAttributeView.java | 408 +++++
.../classes/sun/nio/fs/SolarisFileStore.java | 103 ++
.../classes/sun/nio/fs/SolarisFileSystem.java | 164 ++
.../sun/nio/fs/SolarisFileSystemProvider.java | 41 +
.../sun/nio/fs/SolarisNativeDispatcher.java | 56 +
.../SolarisUserDefinedFileAttributeView.java | 293 +++
.../sun/nio/fs/SolarisWatchService.java | 770 ++++++++
.../sun/nio/fs/UnixChannelFactory.java | 286 +++
.../classes/sun/nio/fs/UnixCopyFile.java | 608 +++++++
.../sun/nio/fs/UnixDirectoryStream.java | 267 +++
.../classes/sun/nio/fs/UnixException.java | 113 ++
.../sun/nio/fs/UnixFileAttributeViews.java | 392 ++++
.../sun/nio/fs/UnixFileAttributes.java | 307 ++++
.../classes/sun/nio/fs/UnixFileKey.java | 56 +
.../sun/nio/fs/UnixFileModeAttribute.java | 84 +
.../classes/sun/nio/fs/UnixFileStore.java | 290 +++
.../sun/nio/fs/UnixFileStoreAttributes.java | 59 +
.../classes/sun/nio/fs/UnixFileSystem.java | 380 ++++
.../sun/nio/fs/UnixFileSystemProvider.java | 139 ++
.../classes/sun/nio/fs/UnixMountEntry.java | 85 +
.../sun/nio/fs/UnixNativeDispatcher.java | 556 ++++++
.../solaris/classes/sun/nio/fs/UnixPath.java | 1228 +++++++++++++
.../sun/nio/fs/UnixSecureDirectoryStream.java | 643 +++++++
.../classes/sun/nio/fs/UnixUriUtils.java | 216 +++
.../sun/nio/fs/UnixUserPrincipals.java | 175 ++
jdk/src/solaris/native/sun/nio/ch/EPoll.c | 151 ++
jdk/src/solaris/native/sun/nio/ch/EPollPort.c | 76 +
.../native/sun/nio/ch/FileChannelImpl.c | 102 +-
...{FileDispatcher.c => FileDispatcherImpl.c} | 133 +-
.../native/sun/nio/ch/SocketDispatcher.c | 3 +-
.../native/sun/nio/ch/SolarisEventPort.c | 120 ++
.../UnixAsynchronousServerSocketChannelImpl.c | 47 +
.../ch/UnixAsynchronousSocketChannelImpl.c | 53 +
.../native/sun/nio/fs/GnomeFileTypeDetector.c | 205 +++
.../native/sun/nio/fs/LinuxNativeDispatcher.c | 160 ++
.../native/sun/nio/fs/LinuxWatchService.c | 195 ++
.../sun/nio/fs/SolarisNativeDispatcher.c | 61 +
.../native/sun/nio/fs/SolarisWatchService.c | 104 ++
.../solaris/native/sun/nio/fs/UnixCopyFile.c | 85 +
.../native/sun/nio/fs/UnixNativeDispatcher.c | 1080 +++++++++++
.../native/sun/nio/fs/genSolarisConstants.c | 105 ++
.../native/sun/nio/fs/genUnixConstants.c | 125 ++
.../DefaultAsynchronousChannelProvider.java | 43 +
...ispatcher.java => FileDispatcherImpl.java} | 46 +-
jdk/src/windows/classes/sun/nio/ch/Iocp.java | 437 +++++
.../classes/sun/nio/ch/PendingIoCache.java | 161 ++
.../WindowsAsynchronousChannelProvider.java | 101 ++
.../WindowsAsynchronousFileChannelImpl.java | 741 ++++++++
...wsAsynchronousServerSocketChannelImpl.java | 367 ++++
.../WindowsAsynchronousSocketChannelImpl.java | 911 ++++++++++
.../sun/nio/fs/DefaultFileSystemProvider.java | 38 +
.../sun/nio/fs/DefaultFileTypeDetector.java | 36 +
.../sun/nio/fs/RegistryFileTypeDetector.java | 82 +
.../nio/fs/WindowsAclFileAttributeView.java | 226 +++
.../sun/nio/fs/WindowsChannelFactory.java | 341 ++++
.../classes/sun/nio/fs/WindowsConstants.java | 192 ++
.../sun/nio/fs/WindowsDirectoryStream.java | 232 +++
.../classes/sun/nio/fs/WindowsException.java | 109 ++
.../sun/nio/fs/WindowsFileAttributeViews.java | 296 +++
.../sun/nio/fs/WindowsFileAttributes.java | 403 +++++
.../classes/sun/nio/fs/WindowsFileCopy.java | 519 ++++++
.../classes/sun/nio/fs/WindowsFileStore.java | 337 ++++
.../classes/sun/nio/fs/WindowsFileSystem.java | 319 ++++
.../sun/nio/fs/WindowsFileSystemProvider.java | 146 ++
.../sun/nio/fs/WindowsLinkSupport.java | 446 +++++
.../sun/nio/fs/WindowsNativeDispatcher.java | 1133 ++++++++++++
.../classes/sun/nio/fs/WindowsPath.java | 1316 ++++++++++++++
.../classes/sun/nio/fs/WindowsPathParser.java | 225 +++
.../classes/sun/nio/fs/WindowsPathType.java | 38 +
.../classes/sun/nio/fs/WindowsSecurity.java | 123 ++
.../sun/nio/fs/WindowsSecurityDescriptor.java | 392 ++++
.../classes/sun/nio/fs/WindowsUriSupport.java | 167 ++
.../WindowsUserDefinedFileAttributeView.java | 342 ++++
.../sun/nio/fs/WindowsUserPrincipals.java | 169 ++
.../sun/nio/fs/WindowsWatchService.java | 582 ++++++
.../native/sun/nio/ch/FileChannelImpl.c | 175 +-
...{FileDispatcher.c => FileDispatcherImpl.c} | 146 +-
jdk/src/windows/native/sun/nio/ch/Iocp.c | 147 ++
.../ch/WindowsAsynchronousFileChannelImpl.c | 132 ++
...ndowsAsynchronousServerSocketChannelImpl.c | 142 ++
.../ch/WindowsAsynchronousSocketChannelImpl.c | 222 +++
.../sun/nio/fs/RegistryFileTypeDetector.c | 62 +
.../sun/nio/fs/WindowsNativeDispatcher.c | 1345 ++++++++++++++
.../AsynchronousChannelGroup/AsExecutor.java | 81 +
.../AsynchronousChannelGroup/Attack.java | 63 +
.../BadProperties.java | 41 +
.../AsynchronousChannelGroup/Basic.java | 259 +++
.../AsynchronousChannelGroup/GroupOfOne.java | 140 ++
.../AsynchronousChannelGroup/Identity.java | 166 ++
.../PrivilegedThreadFactory.java | 50 +
.../AsynchronousChannelGroup/Restart.java | 133 ++
.../AsynchronousChannelGroup/Unbounded.java | 120 ++
.../AsynchronousChannelGroup/run_any_task.sh | 52 +
.../AsynchronousDatagramChannel/Basic.java | 448 +++++
.../AsynchronousFileChannel/Basic.java | 585 ++++++
.../CustomThreadPool.java | 67 +
.../AsynchronousFileChannel/Lock.java | 340 ++++
.../MyThreadFactory.java | 49 +
.../Basic.java | 136 ++
.../WithSecurityManager.java | 76 +
.../java.policy.allow | 3 +
.../java.policy.deny | 3 +
.../AsynchronousSocketChannel/Basic.java | 805 ++++++++
.../AsynchronousSocketChannel/Leaky.java | 104 ++
.../java/nio/channels/Channels/Basic2.java | 172 ++
.../DatagramChannel/BasicMulticastTests.java | 14 +-
.../DatagramChannel/SocketOptionTests.java | 4 +-
.../SocketOptionTests.java | 4 +-
.../SocketChannel/SocketOptionTests.java | 4 +-
.../nio/channels/etc/NetworkChannelTests.java | 25 +-
.../CheckProvider.java | 38 +
...o.channels.spi.AsynchronousChannelProvider | 1 +
.../Provider1.java | 69 +
.../Provider2.java | 69 +
.../custom_provider.sh | 71 +
.../java/nio/file/DirectoryStream/Basic.java | 168 ++
.../nio/file/DirectoryStream/Filters.java | 241 +++
.../nio/file/DirectoryStream/SecureDS.java | 370 ++++
jdk/test/java/nio/file/FileStore/Basic.java | 87 +
jdk/test/java/nio/file/FileSystem/Basic.java | 82 +
jdk/test/java/nio/file/Files/ContentType.java | 91 +
.../java/nio/file/Files/CreateFileTree.java | 96 +
jdk/test/java/nio/file/Files/ForceLoad.java | 38 +
.../java.nio.file.spi.FileTypeDetector | 1 +
jdk/test/java/nio/file/Files/Misc.java | 126 ++
.../java/nio/file/Files/PrintFileTree.java | 78 +
.../file/Files/SimpleFileTypeDetector.java | 47 +
.../java/nio/file/Files/SkipSiblings.java | 85 +
.../java/nio/file/Files/TerminateWalk.java | 70 +
jdk/test/java/nio/file/Files/content_type.sh | 71 +
.../java/nio/file/Files/walk_file_tree.sh | 86 +
jdk/test/java/nio/file/Path/CopyAndMove.java | 983 ++++++++++
.../java/nio/file/Path/DeleteOnClose.java | 77 +
.../java/nio/file/Path/InterruptCopy.java | 119 ++
jdk/test/java/nio/file/Path/Links.java | 147 ++
jdk/test/java/nio/file/Path/Misc.java | 389 ++++
jdk/test/java/nio/file/Path/PathOps.java | 752 ++++++++
jdk/test/java/nio/file/Path/SBC.java | 468 +++++
.../java/nio/file/Path/TemporaryFiles.java | 76 +
.../java/nio/file/Path/UriImportExport.java | 80 +
.../java/nio/file/Path/delete_on_close.sh | 61 +
.../java/nio/file/Path/temporary_files.sh | 65 +
jdk/test/java/nio/file/PathMatcher/Basic.java | 174 ++
jdk/test/java/nio/file/TestUtil.java | 125 ++
.../java/nio/file/WatchService/Basic.java | 493 +++++
.../file/WatchService/FileTreeModifier.java | 148 ++
.../WatchService/SensitivityModifier.java | 122 ++
.../WatchService/WithSecurityManager.java | 83 +
.../java/nio/file/WatchService/denyAll.policy | 3 +
.../WatchService/grantDirAndOneLevel.policy | 5 +
.../file/WatchService/grantDirAndTree.policy | 5 +
.../nio/file/WatchService/grantDirOnly.policy | 4 +
.../attribute/AclFileAttributeView/Basic.java | 166 ++
.../nio/file/attribute/Attributes/Basic.java | 254 +++
.../BasicFileAttributeView/Basic.java | 150 ++
.../attribute/DosFileAttributeView/Basic.java | 155 ++
.../FileStoreAttributeView/Basic.java | 171 ++
.../PosixFileAttributeView/Basic.java | 398 ++++
.../UserDefinedFileAttributeView/Basic.java | 273 +++
.../java/nio/file/spi/SetDefaultProvider.java | 44 +
jdk/test/java/nio/file/spi/TestProvider.java | 128 ++
364 files changed, 65095 insertions(+), 1160 deletions(-)
create mode 100644 jdk/make/mksample/nio/file/Makefile
create mode 100644 jdk/src/share/classes/com/sun/nio/file/ExtendedCopyOption.java
create mode 100644 jdk/src/share/classes/com/sun/nio/file/ExtendedOpenOption.java
create mode 100644 jdk/src/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java
create mode 100644 jdk/src/share/classes/com/sun/nio/file/SensitivityWatchEventModifier.java
create mode 100644 jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java
create mode 100644 jdk/src/share/classes/java/nio/channels/AsynchronousChannel.java
create mode 100644 jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java
create mode 100644 jdk/src/share/classes/java/nio/channels/AsynchronousDatagramChannel.java
create mode 100644 jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java
create mode 100644 jdk/src/share/classes/java/nio/channels/AsynchronousServerSocketChannel.java
create mode 100644 jdk/src/share/classes/java/nio/channels/AsynchronousSocketChannel.java
create mode 100644 jdk/src/share/classes/java/nio/channels/CompletionHandler.java
create mode 100644 jdk/src/share/classes/java/nio/channels/SeekableByteChannel.java
create mode 100644 jdk/src/share/classes/java/nio/channels/spi/AsynchronousChannelProvider.java
create mode 100644 jdk/src/share/classes/java/nio/file/AccessDeniedException.java
create mode 100644 jdk/src/share/classes/java/nio/file/AccessMode.java
create mode 100644 jdk/src/share/classes/java/nio/file/AtomicMoveNotSupportedException.java
create mode 100644 jdk/src/share/classes/java/nio/file/ClosedDirectoryStreamException.java
create mode 100644 jdk/src/share/classes/java/nio/file/ClosedFileSystemException.java
create mode 100644 jdk/src/share/classes/java/nio/file/ClosedWatchServiceException.java
create mode 100644 jdk/src/share/classes/java/nio/file/CopyOption.java
create mode 100644 jdk/src/share/classes/java/nio/file/DirectoryNotEmptyException.java
create mode 100644 jdk/src/share/classes/java/nio/file/DirectoryStream.java
create mode 100644 jdk/src/share/classes/java/nio/file/DirectoryStreamFilters.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileAction.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileAlreadyExistsException.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileRef.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileStore.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileSystem.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileSystemAlreadyExistsException.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileSystemException.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileSystemNotFoundException.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileSystems.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileTreeWalker.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileVisitOption.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileVisitResult.java
create mode 100644 jdk/src/share/classes/java/nio/file/FileVisitor.java
create mode 100644 jdk/src/share/classes/java/nio/file/Files.java
create mode 100644 jdk/src/share/classes/java/nio/file/InvalidPathException.java
create mode 100644 jdk/src/share/classes/java/nio/file/LinkOption.java
create mode 100644 jdk/src/share/classes/java/nio/file/LinkPermission.java
create mode 100644 jdk/src/share/classes/java/nio/file/NoSuchFileException.java
create mode 100644 jdk/src/share/classes/java/nio/file/NotDirectoryException.java
create mode 100644 jdk/src/share/classes/java/nio/file/NotLinkException.java
create mode 100644 jdk/src/share/classes/java/nio/file/OpenOption.java
create mode 100644 jdk/src/share/classes/java/nio/file/Path.java
create mode 100644 jdk/src/share/classes/java/nio/file/PathMatcher.java
create mode 100644 jdk/src/share/classes/java/nio/file/Paths.java
create mode 100644 jdk/src/share/classes/java/nio/file/ProviderMismatchException.java
create mode 100644 jdk/src/share/classes/java/nio/file/ProviderNotFoundException.java
create mode 100644 jdk/src/share/classes/java/nio/file/ReadOnlyFileSystemException.java
create mode 100644 jdk/src/share/classes/java/nio/file/SecureDirectoryStream.java
create mode 100644 jdk/src/share/classes/java/nio/file/SimpleFileVisitor.java
create mode 100644 jdk/src/share/classes/java/nio/file/StandardCopyOption.java
create mode 100644 jdk/src/share/classes/java/nio/file/StandardOpenOption.java
create mode 100644 jdk/src/share/classes/java/nio/file/StandardWatchEventKind.java
create mode 100644 jdk/src/share/classes/java/nio/file/WatchEvent.java
create mode 100644 jdk/src/share/classes/java/nio/file/WatchKey.java
create mode 100644 jdk/src/share/classes/java/nio/file/WatchService.java
create mode 100644 jdk/src/share/classes/java/nio/file/Watchable.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/AclEntry.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/AclEntryFlag.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/AclEntryPermission.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/AclEntryType.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/AclFileAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/AttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/Attributes.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/BasicFileAttributes.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/DosFileAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/DosFileAttributes.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/FileAttribute.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/FileAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/FileOwnerAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/FileStoreAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/FileStoreSpaceAttributes.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/GroupPrincipal.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/PosixFileAttributes.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/PosixFilePermission.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/PosixFilePermissions.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/UserDefinedFileAttributeView.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/UserPrincipal.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/UserPrincipalLookupService.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/UserPrincipalNotFoundException.java
create mode 100644 jdk/src/share/classes/java/nio/file/attribute/package-info.java
create mode 100644 jdk/src/share/classes/java/nio/file/package-info.java
create mode 100644 jdk/src/share/classes/java/nio/file/spi/AbstractPath.java
create mode 100644 jdk/src/share/classes/java/nio/file/spi/FileSystemProvider.java
create mode 100644 jdk/src/share/classes/java/nio/file/spi/FileTypeDetector.java
create mode 100644 jdk/src/share/classes/java/nio/file/spi/package-info.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/AbstractFuture.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/AsynchronousChannelGroupImpl.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/AsynchronousFileChannelImpl.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/AsynchronousServerSocketChannelImpl.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/Cancellable.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/CompletedFuture.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/FileDispatcher.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/FileLockTable.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/Groupable.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/Invoker.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/PendingFuture.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousDatagramChannelImpl.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/SimpleAsynchronousFileChannelImpl.java
create mode 100644 jdk/src/share/classes/sun/nio/ch/ThreadPool.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/AbstractAclFileAttributeView.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/AbstractBasicFileAttributeView.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/AbstractFileStoreSpaceAttributeView.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/AbstractFileTypeDetector.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/AbstractPoller.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/AbstractUserDefinedFileAttributeView.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/AbstractWatchKey.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/AbstractWatchService.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/Cancellable.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/FileOwnerAttributeViewImpl.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/Globs.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/MimeType.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/NativeBuffer.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/NativeBuffers.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/PollingWatchService.java
create mode 100644 jdk/src/share/classes/sun/nio/fs/Reflect.java
create mode 100644 jdk/src/share/sample/nio/file/AclEdit.java
create mode 100644 jdk/src/share/sample/nio/file/Chmod.java
create mode 100644 jdk/src/share/sample/nio/file/Copy.java
create mode 100644 jdk/src/share/sample/nio/file/DiskUsage.java
create mode 100644 jdk/src/share/sample/nio/file/FileType.java
create mode 100644 jdk/src/share/sample/nio/file/WatchDir.java
create mode 100644 jdk/src/share/sample/nio/file/Xdd.java
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/EPoll.java
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/EPollPort.java
rename jdk/src/solaris/classes/sun/nio/ch/{FileDispatcher.java => FileDispatcherImpl.java} (72%)
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/LinuxAsynchronousChannelProvider.java
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/Port.java
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/SolarisAsynchronousChannelProvider.java
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/SolarisEventPort.java
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java
create mode 100644 jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/DefaultFileSystemProvider.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/DefaultFileTypeDetector.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/GnomeFileTypeDetector.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/LinuxDosFileAttributeView.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/LinuxUserDefinedFileAttributeView.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/LinuxWatchService.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/SolarisAclFileAttributeView.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/SolarisFileStore.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystem.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/SolarisUserDefinedFileAttributeView.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/SolarisWatchService.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixCopyFile.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixDirectoryStream.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixException.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributeViews.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixFileAttributes.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixFileKey.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixFileModeAttribute.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixFileStoreAttributes.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixFileSystem.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixMountEntry.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixPath.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixSecureDirectoryStream.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixUriUtils.java
create mode 100644 jdk/src/solaris/classes/sun/nio/fs/UnixUserPrincipals.java
create mode 100644 jdk/src/solaris/native/sun/nio/ch/EPoll.c
create mode 100644 jdk/src/solaris/native/sun/nio/ch/EPollPort.c
rename jdk/src/solaris/native/sun/nio/ch/{FileDispatcher.c => FileDispatcherImpl.c} (50%)
create mode 100644 jdk/src/solaris/native/sun/nio/ch/SolarisEventPort.c
create mode 100644 jdk/src/solaris/native/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.c
create mode 100644 jdk/src/solaris/native/sun/nio/ch/UnixAsynchronousSocketChannelImpl.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/LinuxWatchService.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/SolarisNativeDispatcher.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/SolarisWatchService.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/UnixCopyFile.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/genSolarisConstants.c
create mode 100644 jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c
create mode 100644 jdk/src/windows/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
rename jdk/src/windows/classes/sun/nio/ch/{FileDispatcher.java => FileDispatcherImpl.java} (71%)
create mode 100644 jdk/src/windows/classes/sun/nio/ch/Iocp.java
create mode 100644 jdk/src/windows/classes/sun/nio/ch/PendingIoCache.java
create mode 100644 jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousChannelProvider.java
create mode 100644 jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
create mode 100644 jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java
create mode 100644 jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/DefaultFileSystemProvider.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/DefaultFileTypeDetector.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsAclFileAttributeView.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsChannelFactory.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsConstants.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsException.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsFileCopy.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsFileSystem.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsPath.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsPathParser.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsPathType.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsSecurity.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsSecurityDescriptor.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsUriSupport.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsUserDefinedFileAttributeView.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsUserPrincipals.java
create mode 100644 jdk/src/windows/classes/sun/nio/fs/WindowsWatchService.java
rename jdk/src/windows/native/sun/nio/ch/{FileDispatcher.c => FileDispatcherImpl.c} (67%)
create mode 100644 jdk/src/windows/native/sun/nio/ch/Iocp.c
create mode 100644 jdk/src/windows/native/sun/nio/ch/WindowsAsynchronousFileChannelImpl.c
create mode 100644 jdk/src/windows/native/sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.c
create mode 100644 jdk/src/windows/native/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.c
create mode 100644 jdk/src/windows/native/sun/nio/fs/RegistryFileTypeDetector.c
create mode 100644 jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/BadProperties.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/Basic.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/Identity.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/Restart.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh
create mode 100644 jdk/test/java/nio/channels/AsynchronousDatagramChannel/Basic.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousFileChannel/Basic.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousFileChannel/CustomThreadPool.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousFileChannel/Lock.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousFileChannel/MyThreadFactory.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousServerSocketChannel/Basic.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.allow
create mode 100644 jdk/test/java/nio/channels/AsynchronousServerSocketChannel/java.policy.deny
create mode 100644 jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
create mode 100644 jdk/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java
create mode 100644 jdk/test/java/nio/channels/Channels/Basic2.java
create mode 100644 jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/CheckProvider.java
create mode 100644 jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/META-INF/services/java.nio.channels.spi.AsynchronousChannelProvider
create mode 100644 jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider1.java
create mode 100644 jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/Provider2.java
create mode 100644 jdk/test/java/nio/channels/spi/AsynchronousChannelProvider/custom_provider.sh
create mode 100644 jdk/test/java/nio/file/DirectoryStream/Basic.java
create mode 100644 jdk/test/java/nio/file/DirectoryStream/Filters.java
create mode 100644 jdk/test/java/nio/file/DirectoryStream/SecureDS.java
create mode 100644 jdk/test/java/nio/file/FileStore/Basic.java
create mode 100644 jdk/test/java/nio/file/FileSystem/Basic.java
create mode 100644 jdk/test/java/nio/file/Files/ContentType.java
create mode 100644 jdk/test/java/nio/file/Files/CreateFileTree.java
create mode 100644 jdk/test/java/nio/file/Files/ForceLoad.java
create mode 100644 jdk/test/java/nio/file/Files/META-INF/services/java.nio.file.spi.FileTypeDetector
create mode 100644 jdk/test/java/nio/file/Files/Misc.java
create mode 100644 jdk/test/java/nio/file/Files/PrintFileTree.java
create mode 100644 jdk/test/java/nio/file/Files/SimpleFileTypeDetector.java
create mode 100644 jdk/test/java/nio/file/Files/SkipSiblings.java
create mode 100644 jdk/test/java/nio/file/Files/TerminateWalk.java
create mode 100644 jdk/test/java/nio/file/Files/content_type.sh
create mode 100644 jdk/test/java/nio/file/Files/walk_file_tree.sh
create mode 100644 jdk/test/java/nio/file/Path/CopyAndMove.java
create mode 100644 jdk/test/java/nio/file/Path/DeleteOnClose.java
create mode 100644 jdk/test/java/nio/file/Path/InterruptCopy.java
create mode 100644 jdk/test/java/nio/file/Path/Links.java
create mode 100644 jdk/test/java/nio/file/Path/Misc.java
create mode 100644 jdk/test/java/nio/file/Path/PathOps.java
create mode 100644 jdk/test/java/nio/file/Path/SBC.java
create mode 100644 jdk/test/java/nio/file/Path/TemporaryFiles.java
create mode 100644 jdk/test/java/nio/file/Path/UriImportExport.java
create mode 100644 jdk/test/java/nio/file/Path/delete_on_close.sh
create mode 100644 jdk/test/java/nio/file/Path/temporary_files.sh
create mode 100644 jdk/test/java/nio/file/PathMatcher/Basic.java
create mode 100644 jdk/test/java/nio/file/TestUtil.java
create mode 100644 jdk/test/java/nio/file/WatchService/Basic.java
create mode 100644 jdk/test/java/nio/file/WatchService/FileTreeModifier.java
create mode 100644 jdk/test/java/nio/file/WatchService/SensitivityModifier.java
create mode 100644 jdk/test/java/nio/file/WatchService/WithSecurityManager.java
create mode 100644 jdk/test/java/nio/file/WatchService/denyAll.policy
create mode 100644 jdk/test/java/nio/file/WatchService/grantDirAndOneLevel.policy
create mode 100644 jdk/test/java/nio/file/WatchService/grantDirAndTree.policy
create mode 100644 jdk/test/java/nio/file/WatchService/grantDirOnly.policy
create mode 100644 jdk/test/java/nio/file/attribute/AclFileAttributeView/Basic.java
create mode 100644 jdk/test/java/nio/file/attribute/Attributes/Basic.java
create mode 100644 jdk/test/java/nio/file/attribute/BasicFileAttributeView/Basic.java
create mode 100644 jdk/test/java/nio/file/attribute/DosFileAttributeView/Basic.java
create mode 100644 jdk/test/java/nio/file/attribute/FileStoreAttributeView/Basic.java
create mode 100644 jdk/test/java/nio/file/attribute/PosixFileAttributeView/Basic.java
create mode 100644 jdk/test/java/nio/file/attribute/UserDefinedFileAttributeView/Basic.java
create mode 100644 jdk/test/java/nio/file/spi/SetDefaultProvider.java
create mode 100644 jdk/test/java/nio/file/spi/TestProvider.java
diff --git a/jdk/make/docs/CORE_PKGS.gmk b/jdk/make/docs/CORE_PKGS.gmk
index 4a41a2005bf..f9b9ee59cc1 100644
--- a/jdk/make/docs/CORE_PKGS.gmk
+++ b/jdk/make/docs/CORE_PKGS.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2001-2009 Sun Microsystems, Inc. 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
@@ -110,6 +110,9 @@ CORE_PKGS = \
java.nio.channels.spi \
java.nio.charset \
java.nio.charset.spi \
+ java.nio.file \
+ java.nio.file.attribute \
+ java.nio.file.spi \
java.rmi \
java.rmi.activation \
java.rmi.dgc \
diff --git a/jdk/make/docs/NON_CORE_PKGS.gmk b/jdk/make/docs/NON_CORE_PKGS.gmk
index ccf7a0f79a8..6028a85da34 100644
--- a/jdk/make/docs/NON_CORE_PKGS.gmk
+++ b/jdk/make/docs/NON_CORE_PKGS.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2002-2009 Sun Microsystems, Inc. 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
@@ -65,6 +65,8 @@ OLD_JSSE_PKGS = com.sun.net.ssl
HTTPSERVER_PKGS = com.sun.net.httpserver \
com.sun.net.httpserver.spi
+NIO_PKGS = com.sun.nio.file
+
DOCLETAPI_PKGS = com.sun.javadoc
TAGLETAPI_FILE = com/sun/tools/doclets/Taglet.java
@@ -92,6 +94,7 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \
$(MGMT_PKGS) \
$(JAAS_PKGS) \
$(JGSS_PKGS) \
+ $(NIO_PKGS) \
$(OLD_JSSE_PKGS) \
$(HTTPSERVER_PKGS) \
$(SMARTCARDIO_PKGS) \
diff --git a/jdk/make/java/nio/Exportedfiles.gmk b/jdk/make/java/nio/Exportedfiles.gmk
index 49c4e24ac3f..fd8b73f64b9 100644
--- a/jdk/make/java/nio/Exportedfiles.gmk
+++ b/jdk/make/java/nio/Exportedfiles.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2000-2009 Sun Microsystems, Inc. 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
@@ -33,7 +33,7 @@ FILES_export = \
sun/nio/ch/DatagramChannelImpl.java \
sun/nio/ch/DatagramDispatcher.java \
sun/nio/ch/FileChannelImpl.java \
- sun/nio/ch/FileDispatcher.java \
+ sun/nio/ch/FileDispatcherImpl.java \
sun/nio/ch/FileKey.java \
sun/nio/ch/FileLockImpl.java \
sun/nio/ch/IOStatus.java \
diff --git a/jdk/make/java/nio/FILES_c.gmk b/jdk/make/java/nio/FILES_c.gmk
index 6f7c3ff3f74..b1670c20dfe 100644
--- a/jdk/make/java/nio/FILES_c.gmk
+++ b/jdk/make/java/nio/FILES_c.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2000-2009 Sun Microsystems, Inc. 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
@@ -27,7 +27,7 @@ FILES_c = \
DatagramChannelImpl.c \
DatagramDispatcher.c \
FileChannelImpl.c \
- FileDispatcher.c \
+ FileDispatcherImpl.c \
FileKey.c \
IOUtil.c \
MappedByteBuffer.c \
diff --git a/jdk/make/java/nio/FILES_java.gmk b/jdk/make/java/nio/FILES_java.gmk
index 29f1f8f42c4..01bfbfcf45b 100644
--- a/jdk/make/java/nio/FILES_java.gmk
+++ b/jdk/make/java/nio/FILES_java.gmk
@@ -1,5 +1,5 @@
#
-# Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2000-2009 Sun Microsystems, Inc. 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
@@ -31,19 +31,29 @@ FILES_src = \
java/nio/MappedByteBuffer.java \
java/nio/StringCharBuffer.java \
\
+ java/nio/channels/AsynchronousByteChannel.java \
+ java/nio/channels/AsynchronousChannel.java \
+ java/nio/channels/AsynchronousChannelGroup.java \
+ java/nio/channels/AsynchronousDatagramChannel.java \
+ java/nio/channels/AsynchronousFileChannel.java \
+ java/nio/channels/AsynchronousServerSocketChannel.java \
+ java/nio/channels/AsynchronousSocketChannel.java \
java/nio/channels/ByteChannel.java \
java/nio/channels/Channel.java \
java/nio/channels/Channels.java \
+ java/nio/channels/CompletionHandler.java \
java/nio/channels/DatagramChannel.java \
java/nio/channels/FileChannel.java \
java/nio/channels/FileLock.java \
java/nio/channels/GatheringByteChannel.java \
java/nio/channels/InterruptibleChannel.java \
+ java/nio/channels/Pipe.java \
java/nio/channels/MembershipKey.java \
java/nio/channels/MulticastChannel.java \
java/nio/channels/NetworkChannel.java \
java/nio/channels/ReadableByteChannel.java \
java/nio/channels/ScatteringByteChannel.java \
+ java/nio/channels/SeekableByteChannel.java \
java/nio/channels/SelectableChannel.java \
java/nio/channels/Selector.java \
java/nio/channels/SelectionKey.java \
@@ -55,6 +65,7 @@ FILES_src = \
java/nio/channels/spi/AbstractSelectableChannel.java \
java/nio/channels/spi/AbstractSelectionKey.java \
java/nio/channels/spi/AbstractSelector.java \
+ java/nio/channels/spi/AsynchronousChannelProvider.java \
java/nio/channels/spi/SelectorProvider.java \
\
java/nio/charset/Charset.java \
@@ -66,21 +77,117 @@ FILES_src = \
\
java/nio/charset/spi/CharsetProvider.java \
\
+ java/nio/file/AccessDeniedException.java \
+ java/nio/file/AccessMode.java \
+ java/nio/file/AtomicMoveNotSupportedException.java \
+ java/nio/file/ClosedDirectoryStreamException.java \
+ java/nio/file/ClosedFileSystemException.java \
+ java/nio/file/ClosedWatchServiceException.java \
+ java/nio/file/CopyOption.java \
+ java/nio/file/DirectoryNotEmptyException.java \
+ java/nio/file/DirectoryStream.java \
+ java/nio/file/DirectoryStreamFilters.java \
+ java/nio/file/FileAction.java \
+ java/nio/file/FileAlreadyExistsException.java \
+ java/nio/file/FileRef.java \
+ java/nio/file/FileStore.java \
+ java/nio/file/FileSystem.java \
+ java/nio/file/FileSystemAlreadyExistsException.java \
+ java/nio/file/FileSystemException.java \
+ java/nio/file/FileSystemNotFoundException.java \
+ java/nio/file/FileSystems.java \
+ java/nio/file/FileTreeWalker.java \
+ java/nio/file/FileVisitOption.java \
+ java/nio/file/FileVisitResult.java \
+ java/nio/file/FileVisitor.java \
+ java/nio/file/Files.java \
+ java/nio/file/InvalidPathException.java \
+ java/nio/file/LinkOption.java \
+ java/nio/file/LinkPermission.java \
+ java/nio/file/NoSuchFileException.java \
+ java/nio/file/NotDirectoryException.java \
+ java/nio/file/NotLinkException.java \
+ java/nio/file/OpenOption.java \
+ java/nio/file/Path.java \
+ java/nio/file/PathMatcher.java \
+ java/nio/file/Paths.java \
+ java/nio/file/ProviderMismatchException.java \
+ java/nio/file/ProviderNotFoundException.java \
+ java/nio/file/ReadOnlyFileSystemException.java \
+ java/nio/file/SecureDirectoryStream.java \
+ java/nio/file/SimpleFileVisitor.java \
+ java/nio/file/StandardCopyOption.java \
+ java/nio/file/StandardOpenOption.java \
+ java/nio/file/StandardWatchEventKind.java \
+ java/nio/file/WatchEvent.java \
+ java/nio/file/WatchKey.java \
+ java/nio/file/WatchService.java \
+ java/nio/file/Watchable.java \
+ \
+ java/nio/file/attribute/AclEntry.java \
+ java/nio/file/attribute/AclEntryFlag.java \
+ java/nio/file/attribute/AclEntryPermission.java \
+ java/nio/file/attribute/AclEntryType.java \
+ java/nio/file/attribute/AclFileAttributeView.java \
+ java/nio/file/attribute/AttributeView.java \
+ java/nio/file/attribute/Attributes.java \
+ java/nio/file/attribute/BasicFileAttributeView.java \
+ java/nio/file/attribute/BasicFileAttributes.java \
+ java/nio/file/attribute/DosFileAttributeView.java \
+ java/nio/file/attribute/DosFileAttributes.java \
+ java/nio/file/attribute/FileAttribute.java \
+ java/nio/file/attribute/FileAttributeView.java \
+ java/nio/file/attribute/FileOwnerAttributeView.java \
+ java/nio/file/attribute/FileStoreAttributeView.java \
+ java/nio/file/attribute/FileStoreSpaceAttributeView.java \
+ java/nio/file/attribute/FileStoreSpaceAttributes.java \
+ java/nio/file/attribute/GroupPrincipal.java \
+ java/nio/file/attribute/UserDefinedFileAttributeView.java \
+ java/nio/file/attribute/PosixFileAttributeView.java \
+ java/nio/file/attribute/PosixFileAttributes.java \
+ java/nio/file/attribute/PosixFilePermission.java \
+ java/nio/file/attribute/PosixFilePermissions.java \
+ java/nio/file/attribute/UserPrincipal.java \
+ java/nio/file/attribute/UserPrincipalLookupService.java \
+ java/nio/file/attribute/UserPrincipalNotFoundException.java \
+ \
+ java/nio/file/spi/AbstractPath.java \
+ java/nio/file/spi/FileSystemProvider.java \
+ java/nio/file/spi/FileTypeDetector.java \
+ \
+ com/sun/nio/file/ExtendedCopyOption.java \
+ com/sun/nio/file/ExtendedOpenOption.java \
+ com/sun/nio/file/ExtendedWatchEventModifier.java \
+ com/sun/nio/file/SensitivityWatchEventModifier.java \
+ \
sun/nio/ByteBuffered.java \
\
+ sun/nio/ch/AbstractFuture.java \
sun/nio/ch/AbstractPollArrayWrapper.java \
sun/nio/ch/AllocatedNativeObject.java \
+ sun/nio/ch/AsynchronousChannelGroupImpl.java \
+ sun/nio/ch/AsynchronousFileChannelImpl.java \
+ sun/nio/ch/AsynchronousServerSocketChannelImpl.java \
+ sun/nio/ch/AsynchronousSocketChannelImpl.java \
+ sun/nio/ch/Cancellable.java \
sun/nio/ch/ChannelInputStream.java \
+ sun/nio/ch/CompletedFuture.java \
sun/nio/ch/DatagramChannelImpl.java \
sun/nio/ch/DatagramDispatcher.java \
sun/nio/ch/DatagramSocketAdaptor.java \
+ sun/nio/ch/DefaultAsynchronousChannelProvider.java \
sun/nio/ch/DefaultSelectorProvider.java \
sun/nio/ch/DirectBuffer.java \
sun/nio/ch/ExtendedSocketOption.java \
sun/nio/ch/FileChannelImpl.java \
sun/nio/ch/FileDispatcher.java \
+ sun/nio/ch/FileDispatcherImpl.java \
sun/nio/ch/FileKey.java \
+ sun/nio/ch/FileLockImpl.java \
+ sun/nio/ch/FileLockTable.java \
+ sun/nio/ch/Groupable.java \
sun/nio/ch/Interruptible.java \
+ sun/nio/ch/Invoker.java \
sun/nio/ch/IOUtil.java \
sun/nio/ch/IOStatus.java \
sun/nio/ch/IOVecWrapper.java \
@@ -92,6 +199,7 @@ FILES_src = \
sun/nio/ch/NativeThreadSet.java \
sun/nio/ch/Net.java \
sun/nio/ch/OptionKey.java \
+ sun/nio/ch/PendingFuture.java \
sun/nio/ch/PipeImpl.java \
sun/nio/ch/PollArrayWrapper.java \
sun/nio/ch/Reflect.java \
@@ -101,12 +209,14 @@ FILES_src = \
sun/nio/ch/SelChImpl.java \
sun/nio/ch/ServerSocketAdaptor.java \
sun/nio/ch/ServerSocketChannelImpl.java \
+ sun/nio/ch/SimpleAsynchronousDatagramChannelImpl.java \
sun/nio/ch/SinkChannelImpl.java \
sun/nio/ch/SocketAdaptor.java \
sun/nio/ch/SocketChannelImpl.java \
sun/nio/ch/SocketDispatcher.java \
sun/nio/ch/SocketOptionRegistry.java \
sun/nio/ch/SourceChannelImpl.java \
+ sun/nio/ch/ThreadPool.java \
sun/nio/ch/Util.java \
\
sun/nio/cs/AbstractCharsetProvider.java \
@@ -134,6 +244,24 @@ FILES_src = \
sun/nio/cs/UTF_32LE_BOM.java \
sun/nio/cs/UTF_32Coder.java \
\
+ sun/nio/fs/AbstractAclFileAttributeView.java \
+ sun/nio/fs/AbstractBasicFileAttributeView.java \
+ sun/nio/fs/AbstractFileStoreSpaceAttributeView.java \
+ sun/nio/fs/AbstractFileTypeDetector.java \
+ sun/nio/fs/AbstractPoller.java \
+ sun/nio/fs/AbstractUserDefinedFileAttributeView.java \
+ sun/nio/fs/AbstractWatchKey.java \
+ sun/nio/fs/AbstractWatchService.java \
+ sun/nio/fs/Cancellable.java \
+ sun/nio/fs/DefaultFileSystemProvider.java \
+ sun/nio/fs/DefaultFileTypeDetector.java \
+ sun/nio/fs/FileOwnerAttributeViewImpl.java \
+ sun/nio/fs/Globs.java \
+ sun/nio/fs/MimeType.java \
+ sun/nio/fs/NativeBuffer.java \
+ sun/nio/fs/NativeBuffers.java \
+ sun/nio/fs/Reflect.java \
+ \
java/net/DatagramSocket.java \
java/net/DatagramSocketImpl.java \
java/net/PlainSocketImpl.java \
@@ -244,24 +372,31 @@ FILES_gen_ex = \
java/nio/InvalidMarkException.java \
java/nio/ReadOnlyBufferException.java \
\
+ java/nio/channels/AcceptPendingException.java \
java/nio/channels/AlreadyBoundException.java \
java/nio/channels/AlreadyConnectedException.java \
java/nio/channels/AsynchronousCloseException.java \
+ java/nio/channels/CancelledKeyException.java \
java/nio/channels/ClosedByInterruptException.java \
java/nio/channels/ClosedChannelException.java \
java/nio/channels/ClosedSelectorException.java \
java/nio/channels/ConnectionPendingException.java \
java/nio/channels/FileLockInterruptionException.java \
java/nio/channels/IllegalBlockingModeException.java \
+ java/nio/channels/IllegalChannelGroupException.java \
java/nio/channels/IllegalSelectorException.java \
+ java/nio/channels/InterruptedByTimeoutException.java \
java/nio/channels/NoConnectionPendingException.java \
java/nio/channels/NonReadableChannelException.java \
java/nio/channels/NonWritableChannelException.java \
java/nio/channels/NotYetBoundException.java \
java/nio/channels/NotYetConnectedException.java \
java/nio/channels/OverlappingFileLockException.java \
+ java/nio/channels/ReadPendingException.java \
+ java/nio/channels/ShutdownChannelGroupException.java \
java/nio/channels/UnresolvedAddressException.java \
java/nio/channels/UnsupportedAddressTypeException.java \
+ java/nio/channels/WritePendingException.java \
\
java/nio/charset/CharacterCodingException.java \
java/nio/charset/IllegalCharsetNameException.java \
diff --git a/jdk/make/java/nio/Makefile b/jdk/make/java/nio/Makefile
index bf7bc2e0236..f85cc69e525 100644
--- a/jdk/make/java/nio/Makefile
+++ b/jdk/make/java/nio/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2000-2009 Sun Microsystems, Inc. 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
@@ -56,56 +56,214 @@ FILES_java += \
sun/nio/ch/DevPollSelectorProvider.java \
sun/nio/ch/InheritedChannel.java \
sun/nio/ch/PollSelectorProvider.java \
- sun/nio/ch/PollSelectorImpl.java
+ sun/nio/ch/PollSelectorImpl.java \
+ sun/nio/ch/Port.java \
+ sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \
+ sun/nio/ch/SolarisAsynchronousChannelProvider.java \
+ sun/nio/ch/SolarisEventPort.java \
+ sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
+ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+ \
+ sun/nio/fs/GnomeFileTypeDetector.java \
+ sun/nio/fs/PollingWatchService.java \
+ sun/nio/fs/SolarisAclFileAttributeView.java \
+ sun/nio/fs/SolarisFileStore.java \
+ sun/nio/fs/SolarisFileSystem.java \
+ sun/nio/fs/SolarisFileSystemProvider.java \
+ sun/nio/fs/SolarisUserDefinedFileAttributeView.java \
+ sun/nio/fs/SolarisNativeDispatcher.java \
+ sun/nio/fs/SolarisWatchService.java \
+ sun/nio/fs/UnixChannelFactory.java \
+ sun/nio/fs/UnixCopyFile.java \
+ sun/nio/fs/UnixDirectoryStream.java \
+ sun/nio/fs/UnixException.java \
+ sun/nio/fs/UnixFileAttributeViews.java \
+ sun/nio/fs/UnixFileAttributes.java \
+ sun/nio/fs/UnixFileKey.java \
+ sun/nio/fs/UnixFileModeAttribute.java \
+ sun/nio/fs/UnixFileStore.java \
+ sun/nio/fs/UnixFileStoreAttributes.java \
+ sun/nio/fs/UnixFileSystem.java \
+ sun/nio/fs/UnixFileSystemProvider.java \
+ sun/nio/fs/UnixMountEntry.java \
+ sun/nio/fs/UnixNativeDispatcher.java \
+ sun/nio/fs/UnixPath.java \
+ sun/nio/fs/UnixSecureDirectoryStream.java \
+ sun/nio/fs/UnixUriUtils.java \
+ sun/nio/fs/UnixUserPrincipals.java
FILES_c += \
DevPollArrayWrapper.c \
InheritedChannel.c \
NativeThread.c \
- PollArrayWrapper.c
+ PollArrayWrapper.c \
+ SolarisEventPort.c \
+ UnixAsynchronousServerSocketChannelImpl.c \
+ UnixAsynchronousSocketChannelImpl.c \
+ \
+ GnomeFileTypeDetector.c \
+ SolarisNativeDispatcher.c \
+ SolarisWatchService.c \
+ UnixCopyFile.c \
+ UnixNativeDispatcher.c
FILES_export += \
sun/nio/ch/DevPollArrayWrapper.java \
sun/nio/ch/InheritedChannel.java \
- sun/nio/ch/NativeThread.java
+ sun/nio/ch/NativeThread.java \
+ sun/nio/ch/SolarisEventPort.java \
+ sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
+ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+ \
+ sun/nio/fs/GnomeFileTypeDetector.java \
+ sun/nio/fs/SolarisNativeDispatcher.java \
+ sun/nio/fs/SolarisWatchService.java \
+ sun/nio/fs/UnixCopyFile.java \
+ sun/nio/fs/UnixNativeDispatcher.java
+
+FILES_gen += \
+ sun/nio/fs/SolarisConstants.java \
+ sun/nio/fs/UnixConstants.java
endif # PLATFORM = solaris
ifeq ($(PLATFORM), windows)
FILES_java += \
+ sun/nio/ch/Iocp.java \
+ sun/nio/ch/PendingIoCache.java \
+ sun/nio/ch/WindowsAsynchronousChannelProvider.java \
+ sun/nio/ch/WindowsAsynchronousFileChannelImpl.java \
+ sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java \
+ sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java \
sun/nio/ch/WindowsSelectorImpl.java \
- sun/nio/ch/WindowsSelectorProvider.java
+ sun/nio/ch/WindowsSelectorProvider.java \
+ \
+ sun/nio/fs/RegistryFileTypeDetector.java \
+ sun/nio/fs/WindowsAclFileAttributeView.java \
+ sun/nio/fs/WindowsChannelFactory.java \
+ sun/nio/fs/WindowsConstants.java \
+ sun/nio/fs/WindowsDirectoryStream.java \
+ sun/nio/fs/WindowsException.java \
+ sun/nio/fs/WindowsFileAttributeViews.java \
+ sun/nio/fs/WindowsFileAttributes.java \
+ sun/nio/fs/WindowsFileCopy.java \
+ sun/nio/fs/WindowsFileStore.java \
+ sun/nio/fs/WindowsFileSystem.java \
+ sun/nio/fs/WindowsFileSystemProvider.java \
+ sun/nio/fs/WindowsLinkSupport.java \
+ sun/nio/fs/WindowsUserDefinedFileAttributeView.java \
+ sun/nio/fs/WindowsNativeDispatcher.java \
+ sun/nio/fs/WindowsPath.java \
+ sun/nio/fs/WindowsPathParser.java \
+ sun/nio/fs/WindowsPathType.java \
+ sun/nio/fs/WindowsSecurity.java \
+ sun/nio/fs/WindowsSecurityDescriptor.java \
+ sun/nio/fs/WindowsUriSupport.java \
+ sun/nio/fs/WindowsUserPrincipals.java \
+ sun/nio/fs/WindowsWatchService.java
FILES_c += \
+ Iocp.c \
+ RegistryFileTypeDetector.c \
+ WindowsAsynchronousFileChannelImpl.c \
+ WindowsAsynchronousServerSocketChannelImpl.c \
+ WindowsAsynchronousSocketChannelImpl.c \
+ WindowsNativeDispatcher.c \
WindowsSelectorImpl.c
FILES_export += \
- sun/nio/ch/WindowsSelectorImpl.java
+ sun/nio/ch/Iocp.java \
+ sun/nio/ch/WindowsAsynchronousFileChannelImpl.java \
+ sun/nio/ch/WindowsAsynchronousServerSocketChannelImpl.java \
+ sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java \
+ sun/nio/ch/WindowsSelectorImpl.java \
+ sun/nio/fs/WindowsNativeDispatcher.java \
+ sun/nio/fs/RegistryFileTypeDetector.java
endif # PLATFORM = windows
ifeq ($(PLATFORM), linux)
FILES_java += \
sun/nio/ch/AbstractPollSelectorImpl.java \
+ sun/nio/ch/EPoll.java \
sun/nio/ch/EPollArrayWrapper.java \
+ sun/nio/ch/EPollPort.java \
sun/nio/ch/EPollSelectorProvider.java \
sun/nio/ch/EPollSelectorImpl.java \
sun/nio/ch/InheritedChannel.java \
+ sun/nio/ch/LinuxAsynchronousChannelProvider.java \
sun/nio/ch/PollSelectorProvider.java \
- sun/nio/ch/PollSelectorImpl.java
+ sun/nio/ch/PollSelectorImpl.java \
+ sun/nio/ch/Port.java \
+ sun/nio/ch/SimpleAsynchronousFileChannelImpl.java \
+ sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
+ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+ \
+ sun/nio/fs/GnomeFileTypeDetector.java \
+ sun/nio/fs/LinuxDosFileAttributeView.java \
+ sun/nio/fs/LinuxFileStore.java \
+ sun/nio/fs/LinuxFileSystem.java \
+ sun/nio/fs/LinuxFileSystemProvider.java \
+ sun/nio/fs/LinuxUserDefinedFileAttributeView.java \
+ sun/nio/fs/LinuxNativeDispatcher.java \
+ sun/nio/fs/LinuxWatchService.java \
+ sun/nio/fs/PollingWatchService.java \
+ sun/nio/fs/UnixChannelFactory.java \
+ sun/nio/fs/UnixCopyFile.java \
+ sun/nio/fs/UnixDirectoryStream.java \
+ sun/nio/fs/UnixException.java \
+ sun/nio/fs/UnixFileAttributeViews.java \
+ sun/nio/fs/UnixFileAttributes.java \
+ sun/nio/fs/UnixFileKey.java \
+ sun/nio/fs/UnixFileModeAttribute.java \
+ sun/nio/fs/UnixFileStore.java \
+ sun/nio/fs/UnixFileStoreAttributes.java \
+ sun/nio/fs/UnixFileSystem.java \
+ sun/nio/fs/UnixFileSystemProvider.java \
+ sun/nio/fs/UnixMountEntry.java \
+ sun/nio/fs/UnixNativeDispatcher.java \
+ sun/nio/fs/UnixPath.java \
+ sun/nio/fs/UnixSecureDirectoryStream.java \
+ sun/nio/fs/UnixUriUtils.java \
+ sun/nio/fs/UnixUserPrincipals.java
FILES_c += \
+ EPoll.c \
EPollArrayWrapper.c \
+ EPollPort.c \
InheritedChannel.c \
NativeThread.c \
- PollArrayWrapper.c
+ PollArrayWrapper.c \
+ UnixAsynchronousServerSocketChannelImpl.c \
+ UnixAsynchronousSocketChannelImpl.c \
+ \
+ GnomeFileTypeDetector.c \
+ LinuxNativeDispatcher.c \
+ LinuxWatchService.c \
+ UnixCopyFile.c \
+ UnixNativeDispatcher.c
FILES_export += \
+ sun/nio/ch/EPoll.java \
sun/nio/ch/EPollArrayWrapper.java \
+ sun/nio/ch/EPollPort.java \
sun/nio/ch/InheritedChannel.java \
- sun/nio/ch/NativeThread.java
+ sun/nio/ch/NativeThread.java \
+ sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
+ sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
+ \
+ sun/nio/fs/GnomeFileTypeDetector.java \
+ sun/nio/fs/LinuxNativeDispatcher.java \
+ sun/nio/fs/LinuxWatchService.java \
+ sun/nio/fs/UnixCopyFile.java \
+ sun/nio/fs/UnixNativeDispatcher.java
+
+FILES_gen += \
+ sun/nio/fs/UnixConstants.java
endif # PLATFORM = linux
+#
# Find platform-specific C source files
#
+vpath %.c $(PLATFORM_SRC)/native/sun/nio/fs
vpath %.c $(PLATFORM_SRC)/native/sun/nio/ch
vpath %.c $(SHARE_SRC)/native/sun/nio/ch
@@ -175,12 +333,14 @@ CH_SRC=$(NIO_SRC)/channels
CS_SRC=$(NIO_SRC)/charset
SCH_SRC=$(SNIO_SRC)/ch
SCS_SRC=$(SNIO_SRC)/cs
+SFS_SRC=$(SNIO_SRC)/fs
BUF_GEN=$(NIO_GEN)
CH_GEN=$(NIO_GEN)/channels
CS_GEN=$(NIO_GEN)/charset
SCH_GEN=$(SNIO_GEN)/ch
SCS_GEN=$(SNIO_GEN)/cs
+SFS_GEN=$(SNIO_GEN)/fs
FILES_gensbcs_out = $(FILES_gen_sbcs:%.java=$(GENSRCDIR)/%.java)
@@ -670,4 +830,40 @@ $(FILES_gensbcs_out): $(GENCSSRC)/SingleByte-X.java $(GENCSSRC)/sbcs
$(BOOT_JAVA_CMD) -cp $(CHARSETMAPPING_JARFILE) build.tools.charsetmapping.GenerateSBCS \
$(GENCSSRC) $(SCS_GEN) sbcs
+#
+# Generated file system implementation classes (Unix only)
+#
+
+GENUC_SRC = $(PLATFORM_SRC)/native/sun/nio/fs/genUnixConstants.c
+
+GENUC_EXE = $(TEMPDIR)/genUnixConstants
+
+GENUC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENUC_SRC) | \
+ $(NAWK) '/^.*Copyright.*Sun/ { print $$3 }')
+
+$(GENUC_EXE) : $(GENUC_SRC)
+ $(prep-target)
+ $(CC) $(CPPFLAGS) -o $@ $(GENUC_SRC)
+
+$(SFS_GEN)/UnixConstants.java: $(GENUC_EXE)
+ $(prep-target)
+ NAWK="$(NAWK)" SH="$(SH)" $(SH) -e addNotices.sh $(GENUC_COPYRIGHT_YEARS) > $@
+ $(GENUC_EXE) >> $@
+
+GENSC_SRC = $(PLATFORM_SRC)/native/sun/nio/fs/genSolarisConstants.c
+
+GENSC_EXE = $(TEMPDIR)/genSolarisConstants
+
+GENSC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSC_SRC) | \
+ $(NAWK) '/^.*Copyright.*Sun/ { print $$3 }')
+
+$(GENSC_EXE) : $(GENSC_SRC)
+ $(prep-target)
+ $(CC) $(CPPFLAGS) -o $@ $(GENSC_SRC)
+
+$(SFS_GEN)/SolarisConstants.java: $(GENSC_EXE)
+ $(prep-target)
+ NAWK="$(NAWK)" SH="$(SH)" $(SH) -e addNotices.sh $(GENSC_COPYRIGHT_YEARS) > $@
+ $(GENSC_EXE) >> $@
+
.PHONY: sources
diff --git a/jdk/make/java/nio/mapfile-linux b/jdk/make/java/nio/mapfile-linux
index 3fb47b0eb7c..0bd240811c5 100644
--- a/jdk/make/java/nio/mapfile-linux
+++ b/jdk/make/java/nio/mapfile-linux
@@ -1,5 +1,5 @@
#
-# Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2001-2009 Sun Microsystems, Inc. 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
@@ -44,27 +44,38 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_EPollArrayWrapper_interrupt;
Java_sun_nio_ch_EPollArrayWrapper_offsetofData;
Java_sun_nio_ch_EPollArrayWrapper_sizeofEPollEvent;
+ Java_sun_nio_ch_EPoll_init;
+ Java_sun_nio_ch_EPoll_eventSize;
+ Java_sun_nio_ch_EPoll_eventsOffset;
+ Java_sun_nio_ch_EPoll_dataOffset;
+ Java_sun_nio_ch_EPoll_epollCreate;
+ Java_sun_nio_ch_EPoll_epollCtl;
+ Java_sun_nio_ch_EPoll_epollWait;
+ Java_sun_nio_ch_EPollPort_close0;
+ Java_sun_nio_ch_EPollPort_drain1;
+ Java_sun_nio_ch_EPollPort_interrupt;
+ Java_sun_nio_ch_EPollPort_socketpair;
Java_sun_nio_ch_FileChannelImpl_close0;
- Java_sun_nio_ch_FileChannelImpl_force0;
Java_sun_nio_ch_FileChannelImpl_initIDs;
- Java_sun_nio_ch_FileChannelImpl_lock0;
Java_sun_nio_ch_FileChannelImpl_map0;
Java_sun_nio_ch_FileChannelImpl_position0;
- Java_sun_nio_ch_FileChannelImpl_release0;
- Java_sun_nio_ch_FileChannelImpl_size0;
Java_sun_nio_ch_FileChannelImpl_transferTo0;
- Java_sun_nio_ch_FileChannelImpl_truncate0;
Java_sun_nio_ch_FileChannelImpl_unmap0;
- Java_sun_nio_ch_FileDispatcher_close0;
- Java_sun_nio_ch_FileDispatcher_closeIntFD;
- Java_sun_nio_ch_FileDispatcher_init;
- Java_sun_nio_ch_FileDispatcher_preClose0;
- Java_sun_nio_ch_FileDispatcher_pread0;
- Java_sun_nio_ch_FileDispatcher_pwrite0;
- Java_sun_nio_ch_FileDispatcher_read0;
- Java_sun_nio_ch_FileDispatcher_readv0;
- Java_sun_nio_ch_FileDispatcher_write0;
- Java_sun_nio_ch_FileDispatcher_writev0;
+ Java_sun_nio_ch_FileDispatcherImpl_close0;
+ Java_sun_nio_ch_FileDispatcherImpl_closeIntFD;
+ Java_sun_nio_ch_FileDispatcherImpl_force0;
+ Java_sun_nio_ch_FileDispatcherImpl_init;
+ Java_sun_nio_ch_FileDispatcherImpl_lock0;
+ Java_sun_nio_ch_FileDispatcherImpl_preClose0;
+ Java_sun_nio_ch_FileDispatcherImpl_pread0;
+ Java_sun_nio_ch_FileDispatcherImpl_pwrite0;
+ Java_sun_nio_ch_FileDispatcherImpl_read0;
+ Java_sun_nio_ch_FileDispatcherImpl_readv0;
+ Java_sun_nio_ch_FileDispatcherImpl_release0;
+ Java_sun_nio_ch_FileDispatcherImpl_size0;
+ Java_sun_nio_ch_FileDispatcherImpl_truncate0;
+ Java_sun_nio_ch_FileDispatcherImpl_write0;
+ Java_sun_nio_ch_FileDispatcherImpl_writev0;
Java_sun_nio_ch_FileKey_init;
Java_sun_nio_ch_FileKey_initIDs;
Java_sun_nio_ch_InheritedChannel_close0;
@@ -108,6 +119,76 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_ServerSocketChannelImpl_accept0;
Java_sun_nio_ch_ServerSocketChannelImpl_initIDs;
Java_sun_nio_ch_SocketChannelImpl_checkConnect;
+ Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_accept0;
+ Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_initIDs;
+ Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect;
+ Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio;
+ Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
+ Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
+ Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs;
+ Java_sun_nio_fs_LinuxWatchService_init;
+ Java_sun_nio_fs_LinuxWatchService_eventSize;
+ Java_sun_nio_fs_LinuxWatchService_eventOffsets;
+ Java_sun_nio_fs_LinuxWatchService_inotifyInit;
+ Java_sun_nio_fs_LinuxWatchService_inotifyAddWatch;
+ Java_sun_nio_fs_LinuxWatchService_inotifyRmWatch;
+ Java_sun_nio_fs_LinuxWatchService_configureBlocking;
+ Java_sun_nio_fs_LinuxWatchService_socketpair;
+ Java_sun_nio_fs_LinuxWatchService_poll;
+ Java_sun_nio_fs_LinuxNativeDispatcher_init;
+ Java_sun_nio_fs_LinuxNativeDispatcher_fgetxattr0;
+ Java_sun_nio_fs_LinuxNativeDispatcher_flistxattr;
+ Java_sun_nio_fs_LinuxNativeDispatcher_fsetxattr0;
+ Java_sun_nio_fs_LinuxNativeDispatcher_fremovexattr0;
+ Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0;
+ Java_sun_nio_fs_LinuxNativeDispatcher_endmntent;
+ Java_sun_nio_fs_UnixNativeDispatcher_initIDs;
+ Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
+ Java_sun_nio_fs_UnixNativeDispatcher_strerror;
+ Java_sun_nio_fs_UnixNativeDispatcher_dup;
+ Java_sun_nio_fs_UnixNativeDispatcher_access0;
+ Java_sun_nio_fs_UnixNativeDispatcher_stat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_lstat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fstat;
+ Java_sun_nio_fs_UnixNativeDispatcher_fstatat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_chmod0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fchmod;
+ Java_sun_nio_fs_UnixNativeDispatcher_chown0;
+ Java_sun_nio_fs_UnixNativeDispatcher_lchown0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fchown;
+ Java_sun_nio_fs_UnixNativeDispatcher_utimes0;
+ Java_sun_nio_fs_UnixNativeDispatcher_futimes;
+ Java_sun_nio_fs_UnixNativeDispatcher_open0;
+ Java_sun_nio_fs_UnixNativeDispatcher_openat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_close;
+ Java_sun_nio_fs_UnixNativeDispatcher_read;
+ Java_sun_nio_fs_UnixNativeDispatcher_write;
+ Java_sun_nio_fs_UnixNativeDispatcher_fopen0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fclose;
+ Java_sun_nio_fs_UnixNativeDispatcher_opendir0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fdopendir;
+ Java_sun_nio_fs_UnixNativeDispatcher_readdir;
+ Java_sun_nio_fs_UnixNativeDispatcher_closedir;
+ Java_sun_nio_fs_UnixNativeDispatcher_link0;
+ Java_sun_nio_fs_UnixNativeDispatcher_unlink0;
+ Java_sun_nio_fs_UnixNativeDispatcher_unlinkat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_rename0;
+ Java_sun_nio_fs_UnixNativeDispatcher_renameat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_mkdir0;
+ Java_sun_nio_fs_UnixNativeDispatcher_rmdir0;
+ Java_sun_nio_fs_UnixNativeDispatcher_symlink0;
+ Java_sun_nio_fs_UnixNativeDispatcher_readlink0;
+ Java_sun_nio_fs_UnixNativeDispatcher_realpath0;
+ Java_sun_nio_fs_UnixNativeDispatcher_statvfs0;
+ Java_sun_nio_fs_UnixNativeDispatcher_pathconf0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fpathconf;
+ Java_sun_nio_fs_UnixNativeDispatcher_mknod0;
+ Java_sun_nio_fs_UnixNativeDispatcher_getpwuid;
+ Java_sun_nio_fs_UnixNativeDispatcher_getgrgid;
+ Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
+ Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
+ Java_sun_nio_fs_UnixNativeDispatcher_getextmntent;
+ Java_sun_nio_fs_UnixCopyFile_transfer;
local:
*;
diff --git a/jdk/make/java/nio/mapfile-solaris b/jdk/make/java/nio/mapfile-solaris
index 6e109e2faba..2192a5a7751 100644
--- a/jdk/make/java/nio/mapfile-solaris
+++ b/jdk/make/java/nio/mapfile-solaris
@@ -1,5 +1,5 @@
#
-# Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2001-2009 Sun Microsystems, Inc. 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
@@ -43,26 +43,26 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_DevPollArrayWrapper_register;
Java_sun_nio_ch_DevPollArrayWrapper_registerMultiple;
Java_sun_nio_ch_FileChannelImpl_close0;
- Java_sun_nio_ch_FileChannelImpl_force0;
Java_sun_nio_ch_FileChannelImpl_initIDs;
- Java_sun_nio_ch_FileChannelImpl_lock0;
Java_sun_nio_ch_FileChannelImpl_map0;
Java_sun_nio_ch_FileChannelImpl_position0;
- Java_sun_nio_ch_FileChannelImpl_release0;
- Java_sun_nio_ch_FileChannelImpl_size0;
Java_sun_nio_ch_FileChannelImpl_transferTo0;
- Java_sun_nio_ch_FileChannelImpl_truncate0;
Java_sun_nio_ch_FileChannelImpl_unmap0;
- Java_sun_nio_ch_FileDispatcher_close0;
- Java_sun_nio_ch_FileDispatcher_closeIntFD;
- Java_sun_nio_ch_FileDispatcher_init;
- Java_sun_nio_ch_FileDispatcher_preClose0;
- Java_sun_nio_ch_FileDispatcher_pread0;
- Java_sun_nio_ch_FileDispatcher_pwrite0;
- Java_sun_nio_ch_FileDispatcher_read0;
- Java_sun_nio_ch_FileDispatcher_readv0;
- Java_sun_nio_ch_FileDispatcher_write0;
- Java_sun_nio_ch_FileDispatcher_writev0;
+ Java_sun_nio_ch_FileDispatcherImpl_close0;
+ Java_sun_nio_ch_FileDispatcherImpl_closeIntFD;
+ Java_sun_nio_ch_FileDispatcherImpl_force0;
+ Java_sun_nio_ch_FileDispatcherImpl_init;
+ Java_sun_nio_ch_FileDispatcherImpl_lock0;
+ Java_sun_nio_ch_FileDispatcherImpl_preClose0;
+ Java_sun_nio_ch_FileDispatcherImpl_pread0;
+ Java_sun_nio_ch_FileDispatcherImpl_pwrite0;
+ Java_sun_nio_ch_FileDispatcherImpl_read0;
+ Java_sun_nio_ch_FileDispatcherImpl_readv0;
+ Java_sun_nio_ch_FileDispatcherImpl_release0;
+ Java_sun_nio_ch_FileDispatcherImpl_size0;
+ Java_sun_nio_ch_FileDispatcherImpl_truncate0;
+ Java_sun_nio_ch_FileDispatcherImpl_write0;
+ Java_sun_nio_ch_FileDispatcherImpl_writev0;
Java_sun_nio_ch_FileKey_init;
Java_sun_nio_ch_FileKey_initIDs;
Java_sun_nio_ch_InheritedChannel_close0;
@@ -106,6 +106,75 @@ SUNWprivate_1.1 {
Java_sun_nio_ch_ServerSocketChannelImpl_accept0;
Java_sun_nio_ch_ServerSocketChannelImpl_initIDs;
Java_sun_nio_ch_SocketChannelImpl_checkConnect;
+ Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_accept0;
+ Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_initIDs;
+ Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect;
+ Java_sun_nio_ch_SolarisEventPort_init;
+ Java_sun_nio_ch_SolarisEventPort_portCreate;
+ Java_sun_nio_ch_SolarisEventPort_portClose;
+ Java_sun_nio_ch_SolarisEventPort_portAssociate;
+ Java_sun_nio_ch_SolarisEventPort_portGet;
+ Java_sun_nio_ch_SolarisEventPort_portGetn;
+ Java_sun_nio_ch_SolarisEventPort_portSend;
+ Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio;
+ Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
+ Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
+ Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs;
+ Java_sun_nio_fs_UnixNativeDispatcher_initIDs;
+ Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
+ Java_sun_nio_fs_UnixNativeDispatcher_strerror;
+ Java_sun_nio_fs_UnixNativeDispatcher_dup;
+ Java_sun_nio_fs_UnixNativeDispatcher_access0;
+ Java_sun_nio_fs_UnixNativeDispatcher_stat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_lstat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fstat;
+ Java_sun_nio_fs_UnixNativeDispatcher_fstatat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_chmod0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fchmod;
+ Java_sun_nio_fs_UnixNativeDispatcher_chown0;
+ Java_sun_nio_fs_UnixNativeDispatcher_lchown0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fchown;
+ Java_sun_nio_fs_UnixNativeDispatcher_utimes0;
+ Java_sun_nio_fs_UnixNativeDispatcher_futimes;
+ Java_sun_nio_fs_UnixNativeDispatcher_open0;
+ Java_sun_nio_fs_UnixNativeDispatcher_openat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_close;
+ Java_sun_nio_fs_UnixNativeDispatcher_read;
+ Java_sun_nio_fs_UnixNativeDispatcher_write;
+ Java_sun_nio_fs_UnixNativeDispatcher_fopen0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fclose;
+ Java_sun_nio_fs_UnixNativeDispatcher_opendir0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fdopendir;
+ Java_sun_nio_fs_UnixNativeDispatcher_readdir;
+ Java_sun_nio_fs_UnixNativeDispatcher_closedir;
+ Java_sun_nio_fs_UnixNativeDispatcher_link0;
+ Java_sun_nio_fs_UnixNativeDispatcher_unlink0;
+ Java_sun_nio_fs_UnixNativeDispatcher_unlinkat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_rename0;
+ Java_sun_nio_fs_UnixNativeDispatcher_renameat0;
+ Java_sun_nio_fs_UnixNativeDispatcher_mkdir0;
+ Java_sun_nio_fs_UnixNativeDispatcher_rmdir0;
+ Java_sun_nio_fs_UnixNativeDispatcher_symlink0;
+ Java_sun_nio_fs_UnixNativeDispatcher_readlink0;
+ Java_sun_nio_fs_UnixNativeDispatcher_realpath0;
+ Java_sun_nio_fs_UnixNativeDispatcher_statvfs0;
+ Java_sun_nio_fs_UnixNativeDispatcher_pathconf0;
+ Java_sun_nio_fs_UnixNativeDispatcher_fpathconf;
+ Java_sun_nio_fs_UnixNativeDispatcher_mknod0;
+ Java_sun_nio_fs_UnixNativeDispatcher_getpwuid;
+ Java_sun_nio_fs_UnixNativeDispatcher_getgrgid;
+ Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
+ Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
+ Java_sun_nio_fs_UnixNativeDispatcher_getextmntent;
+ Java_sun_nio_fs_UnixCopyFile_transfer;
+ Java_sun_nio_fs_SolarisNativeDispatcher_init;
+ Java_sun_nio_fs_SolarisNativeDispatcher_facl;
+ Java_sun_nio_fs_SolarisWatchService_init;
+ Java_sun_nio_fs_SolarisWatchService_portCreate;
+ Java_sun_nio_fs_SolarisWatchService_portAssociate;
+ Java_sun_nio_fs_SolarisWatchService_portDissociate;
+ Java_sun_nio_fs_SolarisWatchService_portSend;
+ Java_sun_nio_fs_SolarisWatchService_portGetn;
local:
*;
diff --git a/jdk/make/mksample/nio/Makefile b/jdk/make/mksample/nio/Makefile
index e05106293bb..5fcfd03a783 100644
--- a/jdk/make/mksample/nio/Makefile
+++ b/jdk/make/mksample/nio/Makefile
@@ -1,5 +1,5 @@
#
-# Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
+# Copyright 2004-2009 Sun Microsystems, Inc. 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
@@ -31,7 +31,7 @@ BUILDDIR = ../..
PRODUCT = java
include $(BUILDDIR)/common/Defs.gmk
-SUBDIRS = multicast server
+SUBDIRS = file multicast server
all build clean clobber::
$(SUBDIRS-loop)
diff --git a/jdk/make/mksample/nio/file/Makefile b/jdk/make/mksample/nio/file/Makefile
new file mode 100644
index 00000000000..f7159de83a3
--- /dev/null
+++ b/jdk/make/mksample/nio/file/Makefile
@@ -0,0 +1,56 @@
+#
+# Copyright 2008-2009 Sun Microsystems, Inc. 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. Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+#
+# Makefile for the nio/file sample code
+#
+
+BUILDDIR = ../../..
+
+PRODUCT = java
+
+include $(BUILDDIR)/common/Defs.gmk
+
+SAMPLE_SRC_DIR = $(SHARE_SRC)/sample/nio/file
+SAMPLE_DST_DIR = $(SAMPLEDIR)/nio/file
+
+SAMPLE_FILES = \
+ $(SAMPLE_DST_DIR)/AclEdit.java \
+ $(SAMPLE_DST_DIR)/Chmod.java \
+ $(SAMPLE_DST_DIR)/Copy.java \
+ $(SAMPLE_DST_DIR)/DiskUsage.java \
+ $(SAMPLE_DST_DIR)/FileType.java \
+ $(SAMPLE_DST_DIR)/WatchDir.java \
+ $(SAMPLE_DST_DIR)/Xdd.java
+
+all build: $(SAMPLE_FILES)
+
+$(SAMPLE_DST_DIR)/%: $(SAMPLE_SRC_DIR)/%
+ $(install-file)
+
+clean clobber:
+ $(RM) -r $(SAMPLE_DST_DIR)
+
+.PHONY: all build clean clobber
diff --git a/jdk/src/share/classes/com/sun/nio/file/ExtendedCopyOption.java b/jdk/src/share/classes/com/sun/nio/file/ExtendedCopyOption.java
new file mode 100644
index 00000000000..b612c0e8d59
--- /dev/null
+++ b/jdk/src/share/classes/com/sun/nio/file/ExtendedCopyOption.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.nio.file;
+
+import java.nio.file.CopyOption;
+
+/**
+ * Defines extended copy options supported on some platforms
+ * by Sun's provider implementation.
+ *
+ * @since 1.7
+ */
+
+public enum ExtendedCopyOption implements CopyOption {
+ /**
+ * The copy may be interrupted by the {@link Thread#interrupt interrupt}
+ * method.
+ */
+ INTERRUPTIBLE,
+}
diff --git a/jdk/src/share/classes/com/sun/nio/file/ExtendedOpenOption.java b/jdk/src/share/classes/com/sun/nio/file/ExtendedOpenOption.java
new file mode 100644
index 00000000000..25208d81257
--- /dev/null
+++ b/jdk/src/share/classes/com/sun/nio/file/ExtendedOpenOption.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.nio.file;
+
+import java.nio.file.OpenOption;
+
+/**
+ * Defines extended open options supported on some platforms
+ * by Sun's provider implementation.
+ *
+ * @since 1.7
+ */
+
+public enum ExtendedOpenOption implements OpenOption {
+ /**
+ * Prevent operations on the file that request read access.
+ */
+ NOSHARE_READ,
+ /**
+ * Prevent operations on the file that request write access.
+ */
+ NOSHARE_WRITE,
+ /**
+ * Prevent operations on the file that request delete access.
+ */
+ NOSHARE_DELETE;
+}
diff --git a/jdk/src/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java b/jdk/src/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java
new file mode 100644
index 00000000000..0f6ddc3276a
--- /dev/null
+++ b/jdk/src/share/classes/com/sun/nio/file/ExtendedWatchEventModifier.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.nio.file;
+
+import java.nio.file.WatchEvent.Modifier;
+
+/**
+ * Defines extended watch event modifiers supported on some platforms
+ * by Sun's provider implementation.
+ *
+ * @since 1.7
+ */
+
+public enum ExtendedWatchEventModifier implements Modifier {
+
+ /**
+ * Register a file tree instead of a single directory.
+ */
+ FILE_TREE,
+}
diff --git a/jdk/src/share/classes/com/sun/nio/file/SensitivityWatchEventModifier.java b/jdk/src/share/classes/com/sun/nio/file/SensitivityWatchEventModifier.java
new file mode 100644
index 00000000000..57ab111b00b
--- /dev/null
+++ b/jdk/src/share/classes/com/sun/nio/file/SensitivityWatchEventModifier.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package com.sun.nio.file;
+
+import java.nio.file.WatchEvent.Modifier;
+
+/**
+ * Defines the sensitivity levels when registering objects with a
+ * watch service implementation that polls the file system.
+ *
+ * @since 1.7
+ */
+
+public enum SensitivityWatchEventModifier implements Modifier {
+ /**
+ * High sensitivity.
+ */
+ HIGH(2),
+ /**
+ * Medium sensitivity.
+ */
+ MEDIUM(10),
+ /**
+ * Low sensitivity.
+ */
+ LOW(30);
+
+ /**
+ * Returns the sensitivity in seconds.
+ */
+ public int sensitivityValueInSeconds() {
+ return sensitivity;
+ }
+
+ private final int sensitivity;
+ private SensitivityWatchEventModifier(int sensitivity) {
+ this.sensitivity = sensitivity;
+ }
+}
diff --git a/jdk/src/share/classes/java/io/File.java b/jdk/src/share/classes/java/io/File.java
index d573b89f483..6a0415101fb 100644
--- a/jdk/src/share/classes/java/io/File.java
+++ b/jdk/src/share/classes/java/io/File.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1994-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1994-2009 Sun Microsystems, Inc. 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
@@ -30,12 +30,12 @@ import java.net.URI;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Hashtable;
-import java.util.Random;
+import java.util.*;
+import java.nio.file.*;
+import java.nio.file.attribute.*;
import java.security.AccessController;
-import java.security.AccessControlException;
+import java.security.PrivilegedAction;
+import java.security.SecureRandom;
import sun.security.action.GetPropertyAction;
@@ -131,6 +131,18 @@ import sun.security.action.GetPropertyAction;
* created, the abstract pathname represented by a File
object
* will never change.
*
+ * Interoperability with {@code java.nio.file} package
+ *
+ * The {@code java.nio.file}
+ * package defines interfaces and classes for the Java virtual machine to access
+ * files, file attributes, and file systems. This API may be used to overcome
+ * many of the limitations of the {@code java.io.File} class.
+ * The {@link #toPath toPath} method may be used to obtain a {@link
+ * Path} that uses the abstract path represented by a {@code File} object to
+ * locate a file. The resulting {@code Path} provides more efficient and
+ * extensive access to file attributes, additional file operations, and I/O
+ * exceptions to help diagnose errors when an operation on a file fails.
+ *
* @author unascribed
* @since JDK1.0
*/
@@ -573,6 +585,7 @@ public class File
* read access to the file
*
* @since JDK1.1
+ * @see Path#toRealPath
*/
public String getCanonicalPath() throws IOException {
return fs.canonicalize(fs.resolve(this));
@@ -597,6 +610,7 @@ public class File
* read access to the file
*
* @since 1.2
+ * @see Path#toRealPath
*/
public File getCanonicalFile() throws IOException {
String canonPath = getCanonicalPath();
@@ -663,6 +677,14 @@ public class File
* system is converted into an abstract pathname in a virtual machine on a
* different operating system.
*
+ *
Note that when this abstract pathname represents a UNC pathname then
+ * all components of the UNC (including the server name component) are encoded
+ * in the {@code URI} path. The authority component is undefined, meaning
+ * that it is represented as {@code null}. The {@link Path} class defines the
+ * {@link Path#toUri toUri} method to encode the server name in the authority
+ * component of the resulting {@code URI}. The {@link #toPath toPath} method
+ * may be used to obtain a {@code Path} representing this abstract pathname.
+ *
* @return An absolute, hierarchical URI with a scheme equal to
* "file", a path representing this abstract pathname,
* and undefined authority, query, and fragment components
@@ -764,6 +786,8 @@ public class File
* If a security manager exists and its {@link
* java.lang.SecurityManager#checkRead(java.lang.String)}
* method denies read access to the file
+ *
+ * @see Attributes#readBasicFileAttributes
*/
public boolean isDirectory() {
SecurityManager security = System.getSecurityManager();
@@ -788,6 +812,8 @@ public class File
* If a security manager exists and its {@link
* java.lang.SecurityManager#checkRead(java.lang.String)}
* method denies read access to the file
+ *
+ * @see Attributes#readBasicFileAttributes
*/
public boolean isFile() {
SecurityManager security = System.getSecurityManager();
@@ -836,6 +862,8 @@ public class File
* If a security manager exists and its {@link
* java.lang.SecurityManager#checkRead(java.lang.String)}
* method denies read access to the file
+ *
+ * @see Attributes#readBasicFileAttributes
*/
public long lastModified() {
SecurityManager security = System.getSecurityManager();
@@ -858,6 +886,8 @@ public class File
* If a security manager exists and its {@link
* java.lang.SecurityManager#checkRead(java.lang.String)}
* method denies read access to the file
+ *
+ * @see Attributes#readBasicFileAttributes
*/
public long length() {
SecurityManager security = System.getSecurityManager();
@@ -907,6 +937,12 @@ public class File
* this pathname denotes a directory, then the directory must be empty in
* order to be deleted.
*
+ *
Note that the {@link Path} class defines the {@link Path#delete
+ * delete} method to throw an {@link IOException} when a file cannot be
+ * deleted. This is useful for error reporting and to diagnose why a file
+ * cannot be deleted. The {@link #toPath toPath} method may be used to
+ * obtain a {@code Path} representing this abstract pathname.
+ *
* @return true
if and only if the file or directory is
* successfully deleted; false
otherwise
*
@@ -973,6 +1009,13 @@ public class File
* will appear in any specific order; they are not, in particular,
* guaranteed to appear in alphabetical order.
*
+ *
Note that the {@link Path} class defines the {@link
+ * Path#newDirectoryStream newDirectoryStream} method to open a directory
+ * and iterate over the names of the files in the directory. This may use
+ * less resources when working with very large directories. The {@link
+ * #toPath toPath} method may be used to obtain a {@code Path} representing
+ * this abstract pathname.
+ *
* @return An array of strings naming the files and directories in the
* directory denoted by this abstract pathname. The array will be
* empty if the directory is empty. Returns {@code null} if
@@ -1024,13 +1067,13 @@ public class File
if ((names == null) || (filter == null)) {
return names;
}
- ArrayList v = new ArrayList();
+ List v = new ArrayList();
for (int i = 0 ; i < names.length ; i++) {
if (filter.accept(this, names[i])) {
v.add(names[i]);
}
}
- return (String[])(v.toArray(new String[v.size()]));
+ return v.toArray(new String[v.size()]);
}
/**
@@ -1052,6 +1095,13 @@ public class File
* will appear in any specific order; they are not, in particular,
* guaranteed to appear in alphabetical order.
*
+ * Note that the {@link Path} class defines the {@link
+ * Path#newDirectoryStream newDirectoryStream} method to open a directory
+ * and iterate over the names of the files in the directory. This may use
+ * less resources when working with very large directories. The {@link
+ * #toPath toPath} method may be used to obtain a {@code Path} representing
+ * this abstract pathname.
+ *
* @return An array of abstract pathnames denoting the files and
* directories in the directory denoted by this abstract pathname.
* The array will be empty if the directory is empty. Returns
@@ -1157,6 +1207,12 @@ public class File
/**
* Creates the directory named by this abstract pathname.
*
+ *
Note that the {@link Path} class defines the {@link Path#createDirectory
+ * createDirectory} method to throw an {@link IOException} when a directory
+ * cannot be created. This is useful for error reporting and to diagnose why
+ * a directory cannot be created. The {@link #toPath toPath} method may be
+ * used to obtain a {@code Path} representing this abstract pathname.
+ *
* @return true
if and only if the directory was
* created; false
otherwise
*
@@ -1222,6 +1278,11 @@ public class File
* already exists. The return value should always be checked to make sure
* that the rename operation was successful.
*
+ *
Note that the {@link Path} class defines the {@link Path#moveTo
+ * moveTo} method to move or rename a file in a platform independent manner.
+ * The {@link #toPath toPath} method may be used to obtain a {@code Path}
+ * representing this abstract pathname.
+ *
* @param dest The new abstract pathname for the named file
*
* @return true
if and only if the renaming succeeded;
@@ -1304,10 +1365,14 @@ public class File
return fs.setReadOnly(this);
}
- /**
+ /**
* Sets the owner's or everybody's write permission for this abstract
* pathname.
*
+ *
The {@link Attributes Attributes} class defines methods that operate
+ * on file attributes including file permissions. This may be used when
+ * finer manipulation of file permissions is required.
+ *
* @param writable
* If true
, sets the access permission to allow write
* operations; if false
to disallow write operations
@@ -1371,6 +1436,10 @@ public class File
* Sets the owner's or everybody's read permission for this abstract
* pathname.
*
+ *
The {@link Attributes Attributes} class defines methods that operate
+ * on file attributes including file permissions. This may be used when
+ * finer manipulation of file permissions is required.
+ *
* @param readable
* If true
, sets the access permission to allow read
* operations; if false
to disallow read operations
@@ -1440,6 +1509,10 @@ public class File
* Sets the owner's or everybody's execute permission for this abstract
* pathname.
*
+ *
The {@link Attributes Attributes} class defines methods that operate
+ * on file attributes including file permissions. This may be used when
+ * finer manipulation of file permissions is required.
+ *
* @param executable
* If true
, sets the access permission to allow execute
* operations; if false
to disallow execute operations
@@ -1678,44 +1751,44 @@ public class File
/* -- Temporary files -- */
- private static final Object tmpFileLock = new Object();
+ private static class TemporaryDirectory {
+ private TemporaryDirectory() { }
- private static int counter = -1; /* Protected by tmpFileLock */
+ static final String valueAsString = fs.normalize(
+ AccessController.doPrivileged(new GetPropertyAction("java.io.tmpdir")));
+ static final File valueAsFile =
+ new File(valueAsString, fs.prefixLength(valueAsString));
- private static File generateFile(String prefix, String suffix, File dir)
- throws IOException
- {
- if (counter == -1) {
- counter = new Random().nextInt() & 0xffff;
- }
- counter++;
- return new File(dir, prefix + Integer.toString(counter) + suffix);
- }
-
- private static String tmpdir; /* Protected by tmpFileLock */
-
- private static String getTempDir() {
- if (tmpdir == null)
- tmpdir = fs.normalize(
- AccessController.doPrivileged(
- new GetPropertyAction("java.io.tmpdir")));
- return tmpdir;
- }
-
- private static boolean checkAndCreate(String filename, SecurityManager sm)
- throws IOException
- {
- if (sm != null) {
- try {
- sm.checkWrite(filename);
- } catch (AccessControlException x) {
- /* Throwing the original AccessControlException could disclose
- the location of the default temporary directory, so we
- re-throw a more innocuous SecurityException */
- throw new SecurityException("Unable to create temporary file");
+ // file name generation
+ private static final SecureRandom random = new SecureRandom();
+ static File generateFile(String prefix, String suffix, File dir) {
+ long n = random.nextLong();
+ if (n == Long.MIN_VALUE) {
+ n = 0; // corner case
+ } else {
+ n = Math.abs(n);
}
+ return new File(dir, prefix + Long.toString(n) + suffix);
+ }
+
+ // default file permissions
+ static final FileAttribute> defaultPosixFilePermissions =
+ PosixFilePermissions.asFileAttribute(EnumSet
+ .of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE));
+ static final boolean isPosix = isPosix();
+ static boolean isPosix() {
+ return AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public Boolean run() {
+ try {
+ return FileSystems.getDefault().getPath(valueAsString)
+ .getFileStore().supportsFileAttributeView("posix");
+ } catch (IOException e) {
+ throw new IOError(e);
+ }
+ }
+ });
}
- return fs.createFileExclusively(filename);
}
/**
@@ -1791,22 +1864,29 @@ public class File
File directory)
throws IOException
{
- if (prefix == null) throw new NullPointerException();
if (prefix.length() < 3)
throw new IllegalArgumentException("Prefix string too short");
- String s = (suffix == null) ? ".tmp" : suffix;
- synchronized (tmpFileLock) {
- if (directory == null) {
- String tmpDir = getTempDir();
- directory = new File(tmpDir, fs.prefixLength(tmpDir));
+ if (suffix == null)
+ suffix = ".tmp";
+
+ File tmpdir = (directory != null) ?
+ directory : TemporaryDirectory.valueAsFile;
+ SecurityManager sm = System.getSecurityManager();
+ File f;
+ do {
+ f = TemporaryDirectory.generateFile(prefix, suffix, tmpdir);
+ if (sm != null) {
+ try {
+ sm.checkWrite(f.getPath());
+ } catch (SecurityException se) {
+ // don't reveal temporary directory location
+ if (directory == null)
+ throw new SecurityException("Unable to create temporary file");
+ throw se;
+ }
}
- SecurityManager sm = System.getSecurityManager();
- File f;
- do {
- f = generateFile(prefix, s, directory);
- } while (!checkAndCreate(f.getPath(), sm));
- return f;
- }
+ } while (!fs.createFileExclusively(f.getPath()));
+ return f;
}
/**
@@ -1844,6 +1924,122 @@ public class File
return createTempFile(prefix, suffix, null);
}
+ /**
+ * Creates an empty file in the default temporary-file directory, using
+ * the given prefix and suffix to generate its name. This method is
+ * equivalent to invoking the {@link #createTempFile(String,String)
+ * createTempFile(prefix, suffix)} method with the addition that the
+ * resulting pathname may be requested to be deleted when the Java virtual
+ * machine terminates, and the initial file attributes to set atomically
+ * when creating the file may be specified.
+ *
+ * When the value of the {@code deleteOnExit} method is {@code true}
+ * then the resulting file is requested to be deleted when the Java virtual
+ * machine terminates as if by invoking the {@link #deleteOnExit deleteOnExit}
+ * method.
+ *
+ *
The {@code attrs} parameter is an optional array of {@link FileAttribute
+ * attributes} to set atomically when creating the file. Each attribute is
+ * identified by its {@link FileAttribute#name name}. If more than one attribute
+ * of the same name is included in the array then all but the last occurrence
+ * is ignored.
+ *
+ * @param prefix
+ * The prefix string to be used in generating the file's
+ * name; must be at least three characters long
+ * @param suffix
+ * The suffix string to be used in generating the file's
+ * name; may be {@code null}, in which case the suffix
+ * {@code ".tmp"} will be used
+ * @param deleteOnExit
+ * {@code true} if the file denoted by resulting pathname be
+ * deleted when the Java virtual machine terminates
+ * @param attrs
+ * An optional list of file attributes to set atomically when creating
+ * the file
+ *
+ * @return An abstract pathname denoting a newly-created empty file
+ *
+ * @throws IllegalArgumentException
+ * If the prefix
argument contains fewer than three
+ * characters
+ * @throws UnsupportedOperationException
+ * If the array contains an attribute that cannot be set atomically
+ * when creating the file
+ * @throws IOException
+ * If a file could not be created
+ * @throws SecurityException
+ * If a security manager exists and its {@link
+ * java.lang.SecurityManager#checkWrite(java.lang.String)}
+ * method does not allow a file to be created. When the {@code
+ * deleteOnExit} parameter has the value {@code true} then the
+ * security manager's {@link
+ * java.lang.SecurityManager#checkDelete(java.lang.String)} is
+ * invoked to check delete access to the file.
+ * @since 1.7
+ */
+ public static File createTempFile(String prefix,
+ String suffix,
+ boolean deleteOnExit,
+ FileAttribute>... attrs)
+ throws IOException
+ {
+ if (prefix.length() < 3)
+ throw new IllegalArgumentException("Prefix string too short");
+ suffix = (suffix == null) ? ".tmp" : suffix;
+
+ // special case POSIX environments so that 0600 is used as the file mode
+ if (TemporaryDirectory.isPosix) {
+ if (attrs.length == 0) {
+ // no attributes so use default permissions
+ attrs = new FileAttribute>[1];
+ attrs[0] = TemporaryDirectory.defaultPosixFilePermissions;
+ } else {
+ // check if posix permissions given; if not use default
+ boolean hasPermissions = false;
+ for (int i=0; i[] copy = new FileAttribute>[attrs.length+1];
+ System.arraycopy(attrs, 0, copy, 0, attrs.length);
+ attrs = copy;
+ attrs[attrs.length-1] =
+ TemporaryDirectory.defaultPosixFilePermissions;
+ }
+ }
+ }
+
+ // use Path#createFile to create file
+ SecurityManager sm = System.getSecurityManager();
+ for (;;) {
+ File f = TemporaryDirectory
+ .generateFile(prefix, suffix, TemporaryDirectory.valueAsFile);
+ if (sm != null && deleteOnExit)
+ sm.checkDelete(f.getPath());
+ try {
+ f.toPath().createFile(attrs);
+ if (deleteOnExit)
+ DeleteOnExitHook.add(f.getPath());
+ return f;
+ } catch (InvalidPathException e) {
+ // don't reveal temporary directory location
+ if (sm != null)
+ throw new IllegalArgumentException("Invalid prefix or suffix");
+ throw e;
+ } catch (SecurityException e) {
+ // don't reveal temporary directory location
+ if (sm != null)
+ throw new SecurityException("Unable to create temporary file");
+ throw e;
+ } catch (FileAlreadyExistsException e) {
+ // ignore
+ }
+ }
+ }
/* -- Basic infrastructure -- */
@@ -1963,5 +2159,46 @@ public class File
);
}
+ // -- Integration with java.nio.file --
+ private volatile transient Path filePath;
+
+ /**
+ * Returns a {@link Path java.nio.file.Path} object constructed from the
+ * this abstract path. The first invocation of this method works as if
+ * invoking it were equivalent to evaluating the expression:
+ *
+ * {@link FileSystems#getDefault FileSystems.getDefault}().{@link FileSystem#getPath getPath}(this.{@link #getPath getPath}());
+ *
+ * Subsequent invocations of this method return the same {@code Path}.
+ *
+ * If this abstract pathname is the empty abstract pathname then this
+ * method returns a {@code Path} that may be used to access to the current
+ * user directory.
+ *
+ * @return A {@code Path} constructed from this abstract path. The resulting
+ * {@code Path} is associated with the {@link FileSystems#getDefault
+ * default-filesystem}.
+ *
+ * @throws InvalidPathException
+ * If a {@code Path} object cannot be constructed from the abstract
+ * path (see {@link java.nio.file.FileSystem#getPath FileSystem.getPath})
+ *
+ * @since 1.7
+ */
+ public Path toPath() {
+ if (filePath == null) {
+ synchronized (this) {
+ if (filePath == null) {
+ if (path.length() == 0) {
+ // assume default file system treats "." as current directory
+ filePath = Paths.get(".");
+ } else {
+ filePath = Paths.get(path);
+ }
+ }
+ }
+ }
+ return filePath;
+ }
}
diff --git a/jdk/src/share/classes/java/io/FilePermission.java b/jdk/src/share/classes/java/io/FilePermission.java
index 9758e35de60..88c98fbddf3 100644
--- a/jdk/src/share/classes/java/io/FilePermission.java
+++ b/jdk/src/share/classes/java/io/FilePermission.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2009 Sun Microsystems, Inc. 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
@@ -29,7 +29,6 @@ import java.security.*;
import java.util.Enumeration;
import java.util.List;
import java.util.ArrayList;
-import java.util.StringTokenizer;
import java.util.Vector;
import java.util.Collections;
import java.io.ObjectStreamField;
@@ -58,7 +57,8 @@ import sun.security.util.SecurityConstants;
*
* The actions to be granted are passed to the constructor in a string containing
* a list of one or more comma-separated keywords. The possible keywords are
- * "read", "write", "execute", and "delete". Their meaning is defined as follows:
+ * "read", "write", "execute", "delete", and "readlink". Their meaning is
+ * defined as follows:
*
*
* - read
- read permission
@@ -69,6 +69,11 @@ import sun.security.util.SecurityConstants;
*
- delete
*
- delete permission. Allows
File.delete
to
* be called. Corresponds to SecurityManager.checkDelete
.
+ * - readlink
+ *
- read link permission. Allows the target of a
+ * symbolic link
+ * to be read by invoking the {@link java.nio.file.Path#readSymbolicLink
+ * readSymbolicLink } method.
*
*
* The actions string is converted to lowercase before processing.
@@ -114,11 +119,15 @@ public final class FilePermission extends Permission implements Serializable {
* Delete action.
*/
private final static int DELETE = 0x8;
+ /**
+ * Read link action.
+ */
+ private final static int READLINK = 0x10;
/**
- * All actions (read,write,execute,delete)
+ * All actions (read,write,execute,delete,readlink)
*/
- private final static int ALL = READ|WRITE|EXECUTE|DELETE;
+ private final static int ALL = READ|WRITE|EXECUTE|DELETE|READLINK;
/**
* No actions.
*/
@@ -235,7 +244,7 @@ public final class FilePermission extends Permission implements Serializable {
* path is the pathname of a file or directory, and actions
* contains a comma-separated list of the desired actions granted on the
* file or directory. Possible actions are
- * "read", "write", "execute", and "delete".
+ * "read", "write", "execute", "delete", and "readlink".
*
*
A pathname that ends in "/*" (where "/" is
* the file separator character, File.separatorChar
)
@@ -425,6 +434,8 @@ public final class FilePermission extends Permission implements Serializable {
return EXECUTE;
} else if (actions == SecurityConstants.FILE_DELETE_ACTION) {
return DELETE;
+ } else if (actions == SecurityConstants.FILE_READLINK_ACTION) {
+ return READLINK;
}
char[] a = actions.toCharArray();
@@ -485,6 +496,18 @@ public final class FilePermission extends Permission implements Serializable {
matchlen = 6;
mask |= DELETE;
+ } else if (i >= 7 && (a[i-7] == 'r' || a[i-7] == 'R') &&
+ (a[i-6] == 'e' || a[i-6] == 'E') &&
+ (a[i-5] == 'a' || a[i-5] == 'A') &&
+ (a[i-4] == 'd' || a[i-4] == 'D') &&
+ (a[i-3] == 'l' || a[i-3] == 'L') &&
+ (a[i-2] == 'i' || a[i-2] == 'I') &&
+ (a[i-1] == 'n' || a[i-1] == 'N') &&
+ (a[i] == 'k' || a[i] == 'K'))
+ {
+ matchlen = 8;
+ mask |= READLINK;
+
} else {
// parse error
throw new IllegalArgumentException(
@@ -529,7 +552,7 @@ public final class FilePermission extends Permission implements Serializable {
/**
* Return the canonical string representation of the actions.
* Always returns present actions in the following order:
- * read, write, execute, delete.
+ * read, write, execute, delete, readlink.
*
* @return the canonical string representation of the actions.
*/
@@ -561,14 +584,20 @@ public final class FilePermission extends Permission implements Serializable {
sb.append("delete");
}
+ if ((mask & READLINK) == READLINK) {
+ if (comma) sb.append(',');
+ else comma = true;
+ sb.append("readlink");
+ }
+
return sb.toString();
}
/**
* Returns the "canonical string representation" of the actions.
* That is, this method always returns present actions in the following order:
- * read, write, execute, delete. For example, if this FilePermission object
- * allows both write and read actions, a call to getActions
+ * read, write, execute, delete, readlink. For example, if this FilePermission
+ * object allows both write and read actions, a call to getActions
* will return the string "read,write".
*
* @return the canonical string representation of the actions.
@@ -678,7 +707,7 @@ final class FilePermissionCollection extends PermissionCollection
implements Serializable {
// Not serialized; see serialization section at end of class
- private transient List perms;
+ private transient List perms;
/**
* Create an empty FilePermissions object.
@@ -686,7 +715,7 @@ implements Serializable {
*/
public FilePermissionCollection() {
- perms = new ArrayList();
+ perms = new ArrayList();
}
/**
@@ -791,7 +820,7 @@ implements Serializable {
// Don't call out.defaultWriteObject()
// Write out Vector
- Vector permissions = new Vector(perms.size());
+ Vector permissions = new Vector(perms.size());
synchronized (this) {
permissions.addAll(perms);
}
@@ -804,6 +833,7 @@ implements Serializable {
/*
* Reads in a Vector of FilePermissions and saves them in the perms field.
*/
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
// Don't call defaultReadObject()
@@ -812,8 +842,8 @@ implements Serializable {
ObjectInputStream.GetField gfields = in.readFields();
// Get the one we want
- Vector permissions = (Vector)gfields.get("permissions", null);
- perms = new ArrayList(permissions.size());
+ Vector permissions = (Vector)gfields.get("permissions", null);
+ perms = new ArrayList(permissions.size());
perms.addAll(permissions);
}
}
diff --git a/jdk/src/share/classes/java/net/StandardProtocolFamily.java b/jdk/src/share/classes/java/net/StandardProtocolFamily.java
index 7c11b32f59f..d4b03ed887f 100644
--- a/jdk/src/share/classes/java/net/StandardProtocolFamily.java
+++ b/jdk/src/share/classes/java/net/StandardProtocolFamily.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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,7 +26,7 @@
package java.net;
/**
- * Defines the standard family of communication protocols.
+ * Defines the standard families of communication protocols.
*
* @since 1.7
*/
diff --git a/jdk/src/share/classes/java/net/StandardSocketOption.java b/jdk/src/share/classes/java/net/StandardSocketOption.java
index 405038cc1c2..dba8ff22d90 100644
--- a/jdk/src/share/classes/java/net/StandardSocketOption.java
+++ b/jdk/src/share/classes/java/net/StandardSocketOption.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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
@@ -59,6 +59,7 @@ public final class StandardSocketOption {
*
* @see RFC 929:
* Broadcasting Internet Datagrams
+ * @see DatagramSocket#setBroadcast
*/
public static final SocketOption SO_BROADCAST =
new StdSocketOption("SO_BROADCAST", Boolean.class);
@@ -78,6 +79,7 @@ public final class StandardSocketOption {
*
* @see RFC 1122
* Requirements for Internet Hosts -- Communication Layers
+ * @see Socket#setKeepAlive
*/
public static final SocketOption SO_KEEPALIVE =
new StdSocketOption("SO_KEEPALIVE", Boolean.class);
@@ -107,6 +109,8 @@ public final class StandardSocketOption {
* socket is bound or connected. Whether an implementation allows the
* socket send buffer to be changed after the socket is bound is system
* dependent.
+ *
+ * @see Socket#setSendBufferSize
*/
public static final SocketOption SO_SNDBUF =
new StdSocketOption("SO_SNDBUF", Integer.class);
@@ -145,6 +149,8 @@ public final class StandardSocketOption {
*
* @see RFC 1323: TCP
* Extensions for High Performance
+ * @see Socket#setReceiveBufferSize
+ * @see ServerSocket#setReceiveBufferSize
*/
public static final SocketOption SO_RCVBUF =
new StdSocketOption("SO_RCVBUF", Integer.class);
@@ -175,6 +181,7 @@ public final class StandardSocketOption {
*
* @see RFC 793: Transmission
* Control Protocol
+ * @see ServerSocket#setReuseAddress
*/
public static final SocketOption SO_REUSEADDR =
new StdSocketOption("SO_REUSEADDR", Boolean.class);
@@ -205,6 +212,8 @@ public final class StandardSocketOption {
* is system dependent. Setting the linger interval to a value that is
* greater than its maximum value causes the linger interval to be set to
* its maximum value.
+ *
+ * @see Socket#setSoLinger
*/
public static final SocketOption SO_LINGER =
new StdSocketOption("SO_LINGER", Integer.class);
@@ -215,15 +224,15 @@ public final class StandardSocketOption {
/**
* The Type of Service (ToS) octet in the Internet Protocol (IP) header.
*
- * The value of this socket option is an {@code Integer}, the least
- * significant 8 bits of which represents the value of the ToS octet in IP
- * packets sent by sockets to an {@link StandardProtocolFamily#INET IPv4}
- * socket. The interpretation of the ToS octet is network specific and
- * is not defined by this class. Further information on the ToS octet can be
- * found in RFC 1349
- * and RFC 2474. The
- * value of the socket option is a hint. An implementation may
- * ignore the value, or ignore specific values.
+ *
The value of this socket option is an {@code Integer} representing
+ * the value of the ToS octet in IP packets sent by sockets to an {@link
+ * StandardProtocolFamily#INET IPv4} socket. The interpretation of the ToS
+ * octet is network specific and is not defined by this class. Further
+ * information on the ToS octet can be found in RFC 1349 and RFC 2474. The value
+ * of the socket option is a hint. An implementation may ignore the
+ * value, or ignore specific values.
*
*
The initial/default value of the TOS field in the ToS octet is
* implementation specific but will typically be {@code 0}. For
@@ -235,6 +244,8 @@ public final class StandardSocketOption {
*
The behavior of this socket option on a stream-oriented socket, or an
* {@link StandardProtocolFamily#INET6 IPv6} socket, is not defined in this
* release.
+ *
+ * @see DatagramSocket#setTrafficClass
*/
public static final SocketOption IP_TOS =
new StdSocketOption("IP_TOS", Integer.class);
@@ -257,6 +268,7 @@ public final class StandardSocketOption {
* is system dependent.
*
* @see java.nio.channels.MulticastChannel
+ * @see MulticastSocket#setInterface
*/
public static final SocketOption IP_MULTICAST_IF =
new StdSocketOption("IP_MULTICAST_IF", NetworkInterface.class);
@@ -283,6 +295,7 @@ public final class StandardSocketOption {
* prior to binding the socket is system dependent.
*
* @see java.nio.channels.MulticastChannel
+ * @see MulticastSocket#setTimeToLive
*/
public static final SocketOption IP_MULTICAST_TTL =
new StdSocketOption("IP_MULTICAST_TTL", Integer.class);
@@ -307,6 +320,7 @@ public final class StandardSocketOption {
* binding the socket is system dependent.
*
* @see java.nio.channels.MulticastChannel
+ * @see MulticastSocket#setLoopbackMode
*/
public static final SocketOption IP_MULTICAST_LOOP =
new StdSocketOption("IP_MULTICAST_LOOP", Boolean.class);
@@ -328,11 +342,12 @@ public final class StandardSocketOption {
* coalescing impacts performance. The socket option may be enabled at any
* time. In other words, the Nagle Algorithm can be disabled. Once the option
* is enabled, it is system dependent whether it can be subsequently
- * disabled. In that case, invoking the {@code setOption} method to disable
- * the option has no effect.
+ * disabled. If it cannot, then invoking the {@code setOption} method to
+ * disable the option has no effect.
*
* @see RFC 1122:
* Requirements for Internet Hosts -- Communication Layers
+ * @see Socket#setTcpNoDelay
*/
public static final SocketOption TCP_NODELAY =
new StdSocketOption("TCP_NODELAY", Boolean.class);
diff --git a/jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java b/jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java
new file mode 100644
index 00000000000..7bc43357479
--- /dev/null
+++ b/jdk/src/share/classes/java/nio/channels/AsynchronousByteChannel.java
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.nio.channels;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.Future;
+
+/**
+ * An asynchronous channel that can read and write bytes.
+ *
+ * Some channels may not allow more than one read or write to be outstanding
+ * at any given time. If a thread invokes a read method before a previous read
+ * operation has completed then a {@link ReadPendingException} will be thrown.
+ * Similarly, if a write method is invoked before a previous write has completed
+ * then {@link WritePendingException} is thrown. Whether or not other kinds of
+ * I/O operations may proceed concurrently with a read operation depends upon
+ * the type of the channel.
+ *
+ *
Note that {@link java.nio.ByteBuffer ByteBuffers} are not safe for use by
+ * multiple concurrent threads. When a read or write operation is initiated then
+ * care must be taken to ensure that the buffer is not accessed until the
+ * operation completes.
+ *
+ * @see Channels#newInputStream(AsynchronousByteChannel)
+ * @see Channels#newOutputStream(AsynchronousByteChannel)
+ *
+ * @since 1.7
+ */
+
+public interface AsynchronousByteChannel
+ extends AsynchronousChannel
+{
+ /**
+ * Reads a sequence of bytes from this channel into the given buffer.
+ *
+ *
This method initiates an operation to read a sequence of bytes from
+ * this channel into the given buffer. The method returns a {@link Future}
+ * representing the pending result of the operation. The result of the
+ * operation, obtained by invoking the {@code Future} 's {@link
+ * Future#get() get} method, is the number of bytes read or {@code -1} if
+ * all bytes have been read and the channel has reached end-of-stream.
+ *
+ *
This method initiates a read operation to read up to r bytes
+ * from the channel, where r is the number of bytes remaining in the
+ * buffer, that is, {@code dst.remaining()} at the time that the read is
+ * attempted. Where r is 0, the read operation completes immediately
+ * with a result of {@code 0} without initiating an I/O operation.
+ *
+ *
Suppose that a byte sequence of length n is read, where
+ * 0 < n <= r.
+ * This byte sequence will be transferred into the buffer so that the first
+ * byte in the sequence is at index p and the last byte is at index
+ * p + n - 1,
+ * where p is the buffer's position at the moment the read is
+ * performed. Upon completion the buffer's position will be equal to
+ * p + n; its limit will not have changed.
+ *
+ *
Buffers are not safe for use by multiple concurrent threads so care
+ * should be taken to not to access the buffer until the operaton has completed.
+ *
+ *
This method may be invoked at any time. Some channel types may not
+ * allow more than one read to be outstanding at any given time. If a thread
+ * initiates a read operation before a previous read operation has
+ * completed then a {@link ReadPendingException} will be thrown.
+ *
+ *
The handler parameter is used to specify a {@link
+ * CompletionHandler}. When the read operation completes the handler's
+ * {@link CompletionHandler#completed completed} method is executed.
+ *
+ *
+ * @param dst
+ * The buffer into which bytes are to be transferred
+ * @param attachment
+ * The object to attach to the I/O operation; can be {@code null}
+ * @param handler
+ * The completion handler object; can be {@code null}
+ *
+ * @return A Future representing the result of the operation
+ *
+ * @throws IllegalArgumentException
+ * If the buffer is read-only
+ * @throws ReadPendingException
+ * If the channel does not allow more than one read to be outstanding
+ * and a previous read has not completed
+ */
+ Future read(ByteBuffer dst,
+ A attachment,
+ CompletionHandler handler);
+
+ /**
+ * Reads a sequence of bytes from this channel into the given buffer.
+ *
+ * An invocation of this method of the form c.read(dst)
+ * behaves in exactly the same manner as the invocation
+ *
+ * c.read(dst, null, null);
+ *
+ * @param dst
+ * The buffer into which bytes are to be transferred
+ *
+ * @return A Future representing the result of the operation
+ *
+ * @throws IllegalArgumentException
+ * If the buffer is read-only
+ * @throws ReadPendingException
+ * If the channel does not allow more than one read to be outstanding
+ * and a previous read has not completed
+ */
+ Future read(ByteBuffer dst);
+
+ /**
+ * Writes a sequence of bytes to this channel from the given buffer.
+ *
+ * This method initiates an operation to write a sequence of bytes to
+ * this channel from the given buffer. This method returns a {@link
+ * Future} representing the pending result of the operation. The result
+ * of the operation, obtained by invoking the Future's {@link
+ * Future#get() get} method, is the number of bytes written, possibly zero.
+ *
+ *
This method initiates a write operation to write up to r bytes
+ * to the channel, where r is the number of bytes remaining in the
+ * buffer, that is, {@code src.remaining()} at the moment the write is
+ * attempted. Where r is 0, the write operation completes immediately
+ * with a result of {@code 0} without initiating an I/O operation.
+ *
+ *
Suppose that a byte sequence of length n is written, where
+ * 0 < n <= r.
+ * This byte sequence will be transferred from the buffer starting at index
+ * p, where p is the buffer's position at the moment the
+ * write is performed; the index of the last byte written will be
+ * p + n - 1.
+ * Upon completion the buffer's position will be equal to
+ * p + n; its limit will not have changed.
+ *
+ *
Buffers are not safe for use by multiple concurrent threads so care
+ * should be taken to not to access the buffer until the operaton has completed.
+ *
+ *
This method may be invoked at any time. Some channel types may not
+ * allow more than one write to be outstanding at any given time. If a thread
+ * initiates a write operation before a previous write operation has
+ * completed then a {@link WritePendingException} will be thrown.
+ *
+ *
The handler parameter is used to specify a {@link
+ * CompletionHandler}. When the write operation completes the handler's
+ * {@link CompletionHandler#completed completed} method is executed.
+ *
+ * @param src
+ * The buffer from which bytes are to be retrieved
+ * @param attachment
+ * The object to attach to the I/O operation; can be {@code null}
+ * @param handler
+ * The completion handler object; can be {@code null}
+ *
+ * @return A Future representing the result of the operation
+ *
+ * @throws WritePendingException
+ * If the channel does not allow more than one write to be outstanding
+ * and a previous write has not completed
+ */
+ Future write(ByteBuffer src,
+ A attachment,
+ CompletionHandler handler);
+
+ /**
+ * Writes a sequence of bytes to this channel from the given buffer.
+ *
+ * An invocation of this method of the form c.write(src)
+ * behaves in exactly the same manner as the invocation
+ *
+ * c.write(src, null, null);
+ *
+ * @param src
+ * The buffer from which bytes are to be retrieved
+ *
+ * @return A Future representing the result of the operation
+ *
+ * @throws WritePendingException
+ * If the channel does not allow more than one write to be outstanding
+ * and a previous write has not completed
+ */
+ Future write(ByteBuffer src);
+}
diff --git a/jdk/src/share/classes/java/nio/channels/AsynchronousChannel.java b/jdk/src/share/classes/java/nio/channels/AsynchronousChannel.java
new file mode 100644
index 00000000000..f3e4ffe4ea5
--- /dev/null
+++ b/jdk/src/share/classes/java/nio/channels/AsynchronousChannel.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.nio.channels;
+
+import java.io.IOException;
+import java.util.concurrent.Future; // javadoc
+
+/**
+ * A channel that supports asynchronous I/O operations. Asynchronous I/O
+ * operations will usually take one of two forms:
+ *
+ *
+ * {@link Future}<V> operation(...)
+ * Future<V> operation(... A attachment, {@link CompletionHandler}<V,? super A> handler)
+ *
+ *
+ * where operation is the name of the I/O operation (read or write for
+ * example), V is the result type of the I/O operation, and A is
+ * the type of an object attached to the I/O operation to provide context when
+ * consuming the result. The attachment is important for cases where a
+ * state-less {@code CompletionHandler} is used to consume the result
+ * of many I/O operations.
+ *
+ * In the first form, the methods defined by the {@link Future Future}
+ * interface may be used to check if the operation has completed, wait for its
+ * completion, and to retrieve the result. In the second form, a {@link
+ * CompletionHandler} is invoked to consume the result of the I/O operation when
+ * it completes, fails, or is cancelled.
+ *
+ *
A channel that implements this interface is asynchronously
+ * closeable: If an I/O operation is outstanding on the channel and the
+ * channel's {@link #close close} method is invoked, then the I/O operation
+ * fails with the exception {@link AsynchronousCloseException}.
+ *
+ *
Asynchronous channels are safe for use by multiple concurrent threads.
+ * Some channel implementations may support concurrent reading and writing, but
+ * may not allow more than one read and one write operation to be outstanding at
+ * any given time.
+ *
+ *
Cancellation
+ *
+ * The {@code Future} interface defines the {@link Future#cancel cancel}
+ * method to cancel execution of a task.
+ *
+ *
Where the {@code cancel} method is invoked with the {@code
+ * mayInterruptIfRunning} parameter set to {@code true} then the I/O operation
+ * may be interrupted by closing the channel. This will cause any other I/O
+ * operations outstanding on the channel to complete with the exception {@link
+ * AsynchronousCloseException}.
+ *
+ *
If a {@code CompletionHandler} is specified when initiating an I/O
+ * operation, and the {@code cancel} method is invoked to cancel the I/O
+ * operation before it completes, then the {@code CompletionHandler}'s {@link
+ * CompletionHandler#cancelled cancelled} method is invoked.
+ *
+ *
If an implementation of this interface supports a means to cancel I/O
+ * operations, and where cancellation may leave the channel, or the entity to
+ * which it is connected, in an inconsistent state, then the channel is put into
+ * an implementation specific error state that prevents further
+ * attempts to initiate I/O operations on the channel. For example, if a read
+ * operation is cancelled but the implementation cannot guarantee that bytes
+ * have not been read from the channel then it puts the channel into error state
+ * state; further attempts to initiate a {@code read} operation causes an
+ * unspecified runtime exception to be thrown.
+ *
+ *
Where the {@code cancel} method is invoked to cancel read or write
+ * operations then it recommended that all buffers used in the I/O operations be
+ * discarded or care taken to ensure that the buffers are not accessed while the
+ * channel remains open.
+ *
+ * @since 1.7
+ */
+
+public interface AsynchronousChannel
+ extends Channel
+{
+ /**
+ * Closes this channel.
+ *
+ *
Any outstanding asynchronous operations upon this channel will
+ * complete with the exception {@link AsynchronousCloseException}. After a
+ * channel is closed then further attempts to initiate asynchronous I/O
+ * operations complete immediately with cause {@link ClosedChannelException}.
+ *
+ *
This method otherwise behaves exactly as specified by the {@link
+ * Channel} interface.
+ *
+ * @throws IOException
+ * If an I/O error occurs
+ */
+ @Override
+ void close() throws IOException;
+}
diff --git a/jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java b/jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java
new file mode 100644
index 00000000000..1199e16b51f
--- /dev/null
+++ b/jdk/src/share/classes/java/nio/channels/AsynchronousChannelGroup.java
@@ -0,0 +1,344 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.nio.channels;
+
+import java.nio.channels.spi.AsynchronousChannelProvider;
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A grouping of asynchronous channels for the purpose of resource sharing.
+ *
+ *
An asynchronous channel group encapsulates the mechanics required to
+ * handle the completion of I/O operations initiated by {@link AsynchronousChannel
+ * asynchronous channels} that are bound to the group. A group has an associated
+ * thread pool to which tasks are submitted to handle I/O events and dispatch to
+ * {@link CompletionHandler completion-handlers} that consume the result of
+ * asynchronous operations performed on channels in the group. In addition to
+ * handling I/O events, the pooled threads may also execute other tasks required
+ * to support the execution of asynchronous I/O operations.
+ *
+ *
An asynchronous channel group is created by invoking the {@link
+ * #withFixedThreadPool withFixedThreadPool} or {@link #withCachedThreadPool
+ * withCachedThreadPool} methods defined here. Channels are bound to a group by
+ * specifying the group when constructing the channel. The associated thread
+ * pool is owned by the group; termination of the group results in the
+ * shutdown of the associated thread pool.
+ *
+ *
In addition to groups created explicitly, the Java virtual machine
+ * maintains a system-wide default group that is constructed
+ * automatically. Asynchronous channels that do not specify a group at
+ * construction time are bound to the default group. The default group has an
+ * associated thread pool that creates new threads as needed. The default group
+ * may be configured by means of system properties defined in the table below.
+ * Where the {@link java.util.concurrent.ThreadFactory ThreadFactory} for the
+ * default group is not configured then the pooled threads of the default group
+ * are {@link Thread#isDaemon daemon} threads.
+ *
+ *
+ *
+ * System property |
+ * Description |
+ *
+ *
+ *
+ * {@code java.nio.channels.DefaultThreadPool.threadFactory} |
+ * The value of this property is taken to be the fully-qualified name
+ * of a concrete {@link java.util.concurrent.ThreadFactory ThreadFactory}
+ * class. The class is loaded using the system class loader and instantiated.
+ * The factory's {@link java.util.concurrent.ThreadFactory#newThread
+ * newThread} method is invoked to create each thread for the default
+ * group's thread pool. If the process to load and instantiate the value
+ * of the property fails then an unspecified error is thrown during the
+ * construction of the default group. |
+ *
+ *
+ * {@code java.nio.channels.DefaultThreadPool.initialSize} |
+ * The value of the {@code initialSize} parameter for the default
+ * group (see {@link #withCachedThreadPool withCachedThreadPool}).
+ * The value of the property is taken to be the {@code String}
+ * representation of an {@code Integer} that is the initial size parameter.
+ * If the value cannot be parsed as an {@code Integer} it causes an
+ * unspecified error to be thrown during the construction of the default
+ * group. |
+ *
+ *
+ *
+ * Threading
+ *
+ * The completion handler for an I/O operation initiated on a channel bound
+ * to a group is guaranteed to be invoked by one of the pooled threads in the
+ * group. This ensures that the completion handler is run by a thread with the
+ * expected identity.
+ *
+ *
Where an I/O operation completes immediately, and the initiating thread
+ * is one of the pooled threads in the group then the completion handler may
+ * be invoked directly by the initiating thread. To avoid stack overflow, an
+ * implementation may impose a limit as to the number of activations on the
+ * thread stack. Some I/O operations may prohibit invoking the completion
+ * handler directly by the initiating thread (see {@link
+ * AsynchronousServerSocketChannel#accept(Object,CompletionHandler) accept}).
+ *
+ * Shutdown and Termination
+ *
+ *
The {@link #shutdown() shutdown} method is used to initiate an orderly
+ * shutdown of a group. An orderly shutdown marks the group as shutdown;
+ * further attempts to construct a channel that binds to the group will throw
+ * {@link ShutdownChannelGroupException}. Whether or not a group is shutdown can
+ * be tested using the {@link #isShutdown() isShutdown} method. Once shutdown,
+ * the group terminates when all asynchronous channels that are bound to
+ * the group are closed, all actively executing completion handlers have run to
+ * completion, and resources used by the group are released. No attempt is made
+ * to stop or interrupt threads that are executing completion handlers. The
+ * {@link #isTerminated() isTerminated} method is used to test if the group has
+ * terminated, and the {@link #awaitTermination awaitTermination} method can be
+ * used to block until the group has terminated.
+ *
+ *
The {@link #shutdownNow() shutdownNow} method can be used to initiate a
+ * forceful shutdown of the group. In addition to the actions performed
+ * by an orderly shutdown, the {@code shutdownNow} method closes all open channels
+ * in the group as if by invoking the {@link AsynchronousChannel#close close}
+ * method.
+ *
+ * @since 1.7
+ *
+ * @see AsynchronousSocketChannel#open(AsynchronousChannelGroup)
+ * @see AsynchronousServerSocketChannel#open(AsynchronousChannelGroup)
+ */
+
+public abstract class AsynchronousChannelGroup {
+ private final AsynchronousChannelProvider provider;
+
+ /**
+ * Initialize a new instance of this class.
+ *
+ * @param provider
+ * The asynchronous channel provider for this group
+ */
+ protected AsynchronousChannelGroup(AsynchronousChannelProvider provider) {
+ this.provider = provider;
+ }
+
+ /**
+ * Returns the provider that created this channel group.
+ *
+ * @return The provider that created this channel group
+ */
+ public final AsynchronousChannelProvider provider() {
+ return provider;
+ }
+
+ /**
+ * Creates an asynchronous channel group with a fixed thread pool.
+ *
+ *
The resulting asynchronous channel group reuses a fixed number of
+ * threads. At any point, at most {@code nThreads} threads will be active
+ * processing tasks that are submitted to handle I/O events and dispatch
+ * completion results for operations initiated on asynchronous channels in
+ * the group.
+ *
+ *
The group is created by invoking the {@link
+ * AsynchronousChannelProvider#openAsynchronousChannelGroup(int,ThreadFactory)
+ * openAsynchronousChannelGroup(int,ThreadFactory)} method of the system-wide
+ * default {@link AsynchronousChannelProvider} object.
+ *
+ * @param nThreads
+ * The number of threads in the pool
+ * @param threadFactory
+ * The factory to use when creating new threads
+ *
+ * @return A new asynchronous channel group
+ *
+ * @throws IllegalArgumentException
+ * If {@code nThreads <= 0}
+ * @throws IOException
+ * If an I/O error occurs
+ */
+ public static AsynchronousChannelGroup withFixedThreadPool(int nThreads,
+ ThreadFactory threadFactory)
+ throws IOException
+ {
+ return AsynchronousChannelProvider.provider()
+ .openAsynchronousChannelGroup(nThreads, threadFactory);
+ }
+
+ /**
+ * Creates an asynchronous channel group with a given thread pool that
+ * creates new threads as needed.
+ *
+ *
The {@code executor} parameter is an {@code ExecutorService} that
+ * creates new threads as needed to execute tasks that are submitted to
+ * handle I/O events and dispatch completion results for operations initiated
+ * on asynchronous channels in the group. It may reuse previously constructed
+ * threads when they are available.
+ *
+ *
The {@code initialSize} parameter may be used by the implementation
+ * as a hint as to the initial number of tasks it may submit. For
+ * example, it may be used to indictae the initial number of threads that
+ * wait on I/O events.
+ *
+ *
The executor is intended to be used exclusively by the resulting
+ * asynchronous channel group. Termination of the group results in the
+ * orderly {@link ExecutorService#shutdown shutdown} of the executor
+ * service. Shutting down the executor service by other means results in
+ * unspecified behavior.
+ *
+ *
The group is created by invoking the {@link
+ * AsynchronousChannelProvider#openAsynchronousChannelGroup(ExecutorService,int)
+ * openAsynchronousChannelGroup(ExecutorService,int)} method of the system-wide
+ * default {@link AsynchronousChannelProvider} object.
+ *
+ * @param executor
+ * The thread pool for the resulting group
+ * @param initialSize
+ * A value {@code >=0} or a negative value for implementation
+ * specific default
+ *
+ * @return A new asynchronous channel group
+ *
+ * @throws IOException
+ * If an I/O error occurs
+ *
+ * @see java.util.concurrent.Executors#newCachedThreadPool
+ */
+ public static AsynchronousChannelGroup withCachedThreadPool(ExecutorService executor,
+ int initialSize)
+ throws IOException
+ {
+ return AsynchronousChannelProvider.provider()
+ .openAsynchronousChannelGroup(executor, initialSize);
+ }
+
+ /**
+ * Creates an asynchronous channel group with a given thread pool.
+ *
+ *
The {@code executor} parameter is an {@code ExecutorService} that
+ * executes tasks submitted to dispatch completion results for operations
+ * initiated on asynchronous channels in the group.
+ *
+ *
Care should be taken when configuring the executor service. It
+ * should support direct handoff or unbounded queuing of
+ * submitted tasks, and the thread that invokes the {@link
+ * ExecutorService#execute execute} method should never invoke the task
+ * directly. An implementation may mandate additional constraints.
+ *
+ *
The executor is intended to be used exclusively by the resulting
+ * asynchronous channel group. Termination of the group results in the
+ * orderly {@link ExecutorService#shutdown shutdown} of the executor
+ * service. Shutting down the executor service by other means results in
+ * unspecified behavior.
+ *
+ *
The group is created by invoking the {@link
+ * AsynchronousChannelProvider#openAsynchronousChannelGroup(ExecutorService,int)
+ * openAsynchronousChannelGroup(ExecutorService,int)} method of the system-wide
+ * default {@link AsynchronousChannelProvider} object with an {@code
+ * initialSize} of {@code 0}.
+ *
+ * @param executor
+ * The thread pool for the resulting group
+ *
+ * @return A new asynchronous channel group
+ *
+ * @throws IOException
+ * If an I/O error occurs
+ */
+ public static AsynchronousChannelGroup withThreadPool(ExecutorService executor)
+ throws IOException
+ {
+ return AsynchronousChannelProvider.provider()
+ .openAsynchronousChannelGroup(executor, 0);
+ }
+
+ /**
+ * Tells whether or not this asynchronous channel group is shutdown.
+ *
+ * @return {@code true} if this asynchronous channel group is shutdown or
+ * has been marked for shutdown.
+ */
+ public abstract boolean isShutdown();
+
+ /**
+ * Tells whether or not this group has terminated.
+ *
+ *
Where this method returns {@code true}, then the associated thread
+ * pool has also {@link ExecutorService#isTerminated terminated}.
+ *
+ * @return {@code true} if this group has terminated
+ */
+ public abstract boolean isTerminated();
+
+ /**
+ * Initiates an orderly shutdown of the group.
+ *
+ *
This method marks the group as shutdown. Further attempts to construct
+ * channel that binds to this group will throw {@link ShutdownChannelGroupException}.
+ * The group terminates when all asynchronous channels in the group are
+ * closed, all actively executing completion handlers have run to completion,
+ * and all resources have been released. This method has no effect if the
+ * group is already shutdown.
+ */
+ public abstract void shutdown();
+
+ /**
+ * Shuts down the group and closes all open channels in the group.
+ *
+ *
In addition to the actions performed by the {@link #shutdown() shutdown}
+ * method, this method invokes the {@link AsynchronousChannel#close close}
+ * method on all open channels in the group. This method does not attempt to
+ * stop or interrupt threads that are executing completion handlers. The
+ * group terminates when all actively executing completion handlers have run
+ * to completion and all resources have been released. This method may be
+ * invoked at any time. If some other thread has already invoked it, then
+ * another invocation will block until the first invocation is complete,
+ * after which it will return without effect.
+ *
+ * @throws IOException
+ * If an I/O error occurs
+ */
+ public abstract void shutdownNow() throws IOException;
+
+ /**
+ * Awaits termination of the group.
+
+ *
This method blocks until the group has terminated, or the timeout
+ * occurs, or the current thread is interrupted, whichever happens first.
+ *
+ * @param timeout
+ * The maximum time to wait, or zero or less to not wait
+ * @param unit
+ * The time unit of the timeout argument
+ *
+ * @return {@code true} if the group has terminated; {@code false} if the
+ * timeout elapsed before termination
+ *
+ * @throws InterruptedException
+ * If interrupted while waiting
+ */
+ public abstract boolean awaitTermination(long timeout, TimeUnit unit)
+ throws InterruptedException;
+}
diff --git a/jdk/src/share/classes/java/nio/channels/AsynchronousDatagramChannel.java b/jdk/src/share/classes/java/nio/channels/AsynchronousDatagramChannel.java
new file mode 100644
index 00000000000..6a9d9f09715
--- /dev/null
+++ b/jdk/src/share/classes/java/nio/channels/AsynchronousDatagramChannel.java
@@ -0,0 +1,718 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.nio.channels;
+
+import java.nio.channels.spi.*;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.Future;
+import java.io.IOException;
+import java.net.SocketOption;
+import java.net.SocketAddress;
+import java.net.ProtocolFamily;
+import java.nio.ByteBuffer;
+
+/**
+ * An asynchronous channel for datagram-oriented sockets.
+ *
+ *
An asynchronous datagram channel is created by invoking one of the {@link
+ * #open open} methods defined by this class. It is not possible to create a channel
+ * for an arbitrary, pre-existing datagram socket. A newly-created asynchronous
+ * datagram channel is open but not connected. It need not be connected in order
+ * for the {@link #send send} and {@link #receive receive} methods to be used.
+ * A datagram channel may be connected, by invoking its {@link #connect connect}
+ * method, in order to avoid the overhead of the security checks that are otherwise
+ * performed as part of every send and receive operation when a security manager
+ * is set. The channel must be connected in order to use the {@link #read read}
+ * and {@link #write write} methods, since those methods do not accept or return
+ * socket addresses. Once connected, an asynchronous datagram channel remains
+ * connected until it is disconnected or closed.
+ *
+ *
Socket options are configured using the {@link #setOption(SocketOption,Object)
+ * setOption} method. An asynchronous datagram channel to an Internet Protocol
+ * (IP) socket supports the following options:
+ *
+ *
+ *
+ * Option Name |
+ * Description |
+ *
+ *
+ * {@link java.net.StandardSocketOption#SO_SNDBUF SO_SNDBUF} |
+ * The size of the socket send buffer |
+ *
+ *
+ * {@link java.net.StandardSocketOption#SO_RCVBUF SO_RCVBUF} |
+ * The size of the socket receive buffer |
+ *
+ *
+ * {@link java.net.StandardSocketOption#SO_REUSEADDR SO_REUSEADDR} |
+ * Re-use address |
+ *
+ *
+ * {@link java.net.StandardSocketOption#SO_BROADCAST SO_BROADCAST} |
+ * Allow transmission of broadcast datagrams |
+ *
+ *
+ * {@link java.net.StandardSocketOption#IP_TOS IP_TOS} |
+ * The Type of Service (ToS) octet in the Internet Protocol (IP) header |
+ *
+ *
+ * {@link java.net.StandardSocketOption#IP_MULTICAST_IF IP_MULTICAST_IF} |
+ * The network interface for Internet Protocol (IP) multicast datagrams |
+ *
+ *
+ * {@link java.net.StandardSocketOption#IP_MULTICAST_TTL
+ * IP_MULTICAST_TTL} |
+ * The time-to-live for Internet Protocol (IP) multicast
+ * datagrams |
+ *
+ *
+ * {@link java.net.StandardSocketOption#IP_MULTICAST_LOOP
+ * IP_MULTICAST_LOOP} |
+ * Loopback for Internet Protocol (IP) multicast datagrams |
+ *
+ *
+ *
+ * Additional (implementation specific) options may also be supported.
+ *
+ * Asynchronous datagram channels allow more than one read/receive and
+ * write/send to be oustanding at any given time.
+ *
+ *
Usage Example:
+ *
+ * final AsynchronousDatagramChannel dc = AsynchronousDatagramChannel.open()
+ * .bind(new InetSocketAddress(4000));
+ *
+ * // print the source address of all packets that we receive
+ * dc.receive(buffer, buffer, new CompletionHandler<SocketAddress,ByteBuffer>() {
+ * public void completed(SocketAddress sa, ByteBuffer buffer) {
+ * try {
+ * System.out.println(sa);
+ *
+ * buffer.clear();
+ * dc.receive(buffer, buffer, this);
+ * } catch (...) { ... }
+ * }
+ * public void failed(Throwable exc, ByteBuffer buffer) {
+ * ...
+ * }
+ * public void cancelled(ByteBuffer buffer) {
+ * ...
+ * }
+ * });
+ *
+ *
+ * @since 1.7
+ */
+
+public abstract class AsynchronousDatagramChannel
+ implements AsynchronousByteChannel, MulticastChannel
+{
+ private final AsynchronousChannelProvider provider;
+
+ /**
+ * Initializes a new instance of this class.
+ */
+ protected AsynchronousDatagramChannel(AsynchronousChannelProvider provider) {
+ this.provider = provider;
+ }
+
+ /**
+ * Returns the provider that created this channel.
+ */
+ public final AsynchronousChannelProvider provider() {
+ return provider;
+ }
+
+ /**
+ * Opens an asynchronous datagram channel.
+ *
+ * The new channel is created by invoking the {@link
+ * java.nio.channels.spi.AsynchronousChannelProvider#openAsynchronousDatagramChannel
+ * openAsynchronousDatagramChannel} method on the {@link
+ * java.nio.channels.spi.AsynchronousChannelProvider} object that created
+ * the given group (or the default provider where {@code group} is {@code
+ * null}).
+ *
+ *
The {@code family} parameter is used to specify the {@link ProtocolFamily}.
+ * If the datagram channel is to be used for Internet Protocol {@link
+ * MulticastChannel multicasting} then this parameter should correspond to
+ * the address type of the multicast groups that this channel will join.
+ *
+ * @param family
+ * The protocol family, or {@code null} to use the default protocol
+ * family
+ * @param group
+ * The group to which the newly constructed channel should be bound,
+ * or {@code null} for the default group
+ *
+ * @return A new asynchronous datagram channel
+ *
+ * @throws UnsupportedOperationException
+ * If the specified protocol family is not supported. For example,
+ * suppose the parameter is specified as {@link
+ * java.net.StandardProtocolFamily#INET6 INET6} but IPv6 is not
+ * enabled on the platform.
+ * @throws ShutdownChannelGroupException
+ * The specified group is shutdown
+ * @throws IOException
+ * If an I/O error occurs
+ */
+ public static AsynchronousDatagramChannel open(ProtocolFamily family,
+ AsynchronousChannelGroup group)
+ throws IOException
+ {
+ AsynchronousChannelProvider provider = (group == null) ?
+ AsynchronousChannelProvider.provider() : group.provider();
+ return provider.openAsynchronousDatagramChannel(family, group);
+ }
+
+ /**
+ * Opens an asynchronous datagram channel.
+ *
+ *
This method returns an asynchronous datagram channel that is
+ * bound to the default group. This method is equivalent to evaluating
+ * the expression:
+ *
+ * open((ProtocolFamily)null, (AsynchronousChannelGroup)null);
+ *
+ *
+ * @return A new asynchronous datagram channel
+ *
+ * @throws IOException
+ * If an I/O error occurs
+ */
+ public static AsynchronousDatagramChannel open()
+ throws IOException
+ {
+ return open(null, null);
+ }
+
+ // -- Socket-specific operations --
+
+ /**
+ * @throws AlreadyBoundException {@inheritDoc}
+ * @throws UnsupportedAddressTypeException {@inheritDoc}
+ * @throws ClosedChannelException {@inheritDoc}
+ * @throws IOException {@inheritDoc}
+ * @throws SecurityException
+ * If a security manager has been installed and its {@link
+ * SecurityManager#checkListen checkListen} method denies the
+ * operation
+ */
+ @Override
+ public abstract AsynchronousDatagramChannel bind(SocketAddress local)
+ throws IOException;
+
+ /**
+ * @throws IllegalArgumentException {@inheritDoc}
+ * @throws ClosedChannelException {@inheritDoc}
+ * @throws IOException {@inheritDoc}
+ */
+ @Override
+ public abstract AsynchronousDatagramChannel setOption(SocketOption name, T value)
+ throws IOException;
+
+ /**
+ * Returns the remote address to which this channel is connected.
+ *
+ * Where the channel is connected to an Internet Protocol socket address
+ * then the return value from this method is of type {@link
+ * java.net.InetSocketAddress}.
+ *
+ * @return The remote address; {@code null} if the channel's socket is not
+ * connected
+ *
+ * @throws ClosedChannelException
+ * If the channel is closed
+ * @throws IOException
+ * If an I/O error occurs
+ */
+ public abstract SocketAddress getRemoteAddress() throws IOException;
+
+ /**
+ * Connects this channel's socket.
+ *
+ *
The channel's socket is configured so that it only receives
+ * datagrams from, and sends datagrams to, the given remote peer
+ * address. Once connected, datagrams may not be received from or sent to
+ * any other address. A datagram socket remains connected until it is
+ * explicitly disconnected or until it is closed.
+ *
+ *
This method performs exactly the same security checks as the {@link
+ * java.net.DatagramSocket#connect connect} method of the {@link
+ * java.net.DatagramSocket} class. That is, if a security manager has been
+ * installed then this method verifies that its {@link
+ * java.lang.SecurityManager#checkAccept checkAccept} and {@link
+ * java.lang.SecurityManager#checkConnect checkConnect} methods permit
+ * datagrams to be received from and sent to, respectively, the given
+ * remote address.
+ *
+ *
This method may be invoked at any time. Whether it has any effect
+ * on outstanding read or write operations is implementation specific and
+ * therefore not specified.
+ *
+ * @param remote
+ * The remote address to which this channel is to be connected
+ *
+ * @return This datagram channel
+ *
+ * @throws ClosedChannelException
+ * If this channel is closed
+ *
+ * @throws SecurityException
+ * If a security manager has been installed
+ * and it does not permit access to the given remote address
+ *
+ * @throws IOException
+ * If some other I/O error occurs
+ */
+ public abstract AsynchronousDatagramChannel connect(SocketAddress remote)
+ throws IOException;
+
+ /**
+ * Disconnects this channel's socket.
+ *
+ *
The channel's socket is configured so that it can receive datagrams
+ * from, and sends datagrams to, any remote address so long as the security
+ * manager, if installed, permits it.
+ *
+ *
This method may be invoked at any time. Whether it has any effect
+ * on outstanding read or write operations is implementation specific and
+ * therefore not specified.
+ *
+ * @return This datagram channel
+ *
+ * @throws IOException
+ * If some other I/O error occurs
+ */
+ public abstract AsynchronousDatagramChannel disconnect() throws IOException;
+
+ /**
+ * Receives a datagram via this channel.
+ *
+ *
This method initiates the receiving of a datagram, returning a
+ * {@code Future} representing the pending result of the operation.
+ * The {@code Future}'s {@link Future#get() get} method returns
+ * the source address of the datagram upon successful completion.
+ *
+ *
The datagram is transferred into the given byte buffer starting at
+ * its current position, as if by a regular {@link AsynchronousByteChannel#read
+ * read} operation. If there are fewer bytes remaining in the buffer
+ * than are required to hold the datagram then the remainder of the datagram
+ * is silently discarded.
+ *
+ *
If a timeout is specified and the timeout elapses before the operation
+ * completes then the operation completes with the exception {@link
+ * InterruptedByTimeoutException}. When a timeout elapses then the state of
+ * the {@link ByteBuffer} is not defined. The buffers should be discarded or
+ * at least care must be taken to ensure that the buffer is not accessed
+ * while the channel remains open.
+ *
+ *
When a security manager has been installed and the channel is not
+ * connected, then it verifies that the source's address and port number are
+ * permitted by the security manager's {@link SecurityManager#checkAccept
+ * checkAccept} method. The permission check is performed with privileges that
+ * are restricted by the calling context of this method. If the permission
+ * check fails then the operation completes with a {@link SecurityException}.
+ * The overhead of this security check can be avoided by first connecting the
+ * socket via the {@link #connect connect} method.
+ *
+ * @param dst
+ * The buffer into which the datagram is to be transferred
+ * @param timeout
+ * The timeout, or {@code 0L} for no timeout
+ * @param unit
+ * The time unit of the {@code timeout} argument
+ * @param attachment
+ * The object to attach to the I/O operation; can be {@code null}
+ * @param handler
+ * The handler for consuming the result; can be {@code null}
+ *
+ * @return a {@code Future} object representing the pending result
+ *
+ * @throws IllegalArgumentException
+ * If the timeout is negative or the buffer is read-only
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ public abstract Future receive(ByteBuffer dst,
+ long timeout,
+ TimeUnit unit,
+ A attachment,
+ CompletionHandler handler);
+
+ /**
+ * Receives a datagram via this channel.
+ *
+ * This method initiates the receiving of a datagram, returning a
+ * {@code Future} representing the pending result of the operation.
+ * The {@code Future}'s {@link Future#get() get} method returns
+ * the source address of the datagram upon successful completion.
+ *
+ *
This method is equivalent to invoking {@link
+ * #receive(ByteBuffer,long,TimeUnit,Object,CompletionHandler)} with a
+ * timeout of {@code 0L}.
+ *
+ * @param dst
+ * The buffer into which the datagram is to be transferred
+ * @param attachment
+ * The object to attach to the I/O operation; can be {@code null}
+ * @param handler
+ * The handler for consuming the result; can be {@code null}
+ *
+ * @return a {@code Future} object representing the pending result
+ *
+ * @throws IllegalArgumentException
+ * If the buffer is read-only
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ public final Future receive(ByteBuffer dst,
+ A attachment,
+ CompletionHandler handler)
+ {
+ return receive(dst, 0L, TimeUnit.MILLISECONDS, attachment, handler);
+ }
+
+ /**
+ * Receives a datagram via this channel.
+ *
+ * This method initiates the receiving of a datagram, returning a
+ * {@code Future} representing the pending result of the operation.
+ * The {@code Future}'s {@link Future#get() get} method returns
+ * the source address of the datagram upon successful completion.
+ *
+ *
This method is equivalent to invoking {@link
+ * #receive(ByteBuffer,long,TimeUnit,Object,CompletionHandler)} with a
+ * timeout of {@code 0L}, and an attachment and completion handler
+ * of {@code null}.
+ *
+ * @param dst
+ * The buffer into which the datagram is to be transferred
+ *
+ * @return a {@code Future} object representing the pending result
+ *
+ * @throws IllegalArgumentException
+ * If the buffer is read-only
+ */
+ public final Future receive(ByteBuffer dst) {
+ return receive(dst, 0L, TimeUnit.MILLISECONDS, null, null);
+ }
+
+ /**
+ * Sends a datagram via this channel.
+ *
+ * This method initiates sending of a datagram, returning a
+ * {@code Future} representing the pending result of the operation.
+ * The operation sends the remaining bytes in the given buffer as a single
+ * datagram to the given target address. The result of the operation, obtained
+ * by invoking the {@code Future}'s {@link Future#get() get}
+ * method, is the number of bytes sent.
+ *
+ *
The datagram is transferred from the byte buffer as if by a regular
+ * {@link AsynchronousByteChannel#write write} operation.
+ *
+ *
If a timeout is specified and the timeout elapses before the operation
+ * completes then the operation completes with the exception {@link
+ * InterruptedByTimeoutException}. When a timeout elapses then the state of
+ * the {@link ByteBuffer} is not defined. The buffers should be discarded or
+ * at least care must be taken to ensure that the buffer is not accessed
+ * while the channel remains open.
+ *
+ *
If there is a security manager installed and the the channel is not
+ * connected then this method verifies that the target address and port number
+ * are permitted by the security manager's {@link SecurityManager#checkConnect
+ * checkConnect} method. The overhead of this security check can be avoided
+ * by first connecting the socket via the {@link #connect connect} method.
+ *
+ * @param src
+ * The buffer containing the datagram to be sent
+ * @param target
+ * The address to which the datagram is to be sent
+ * @param timeout
+ * The timeout, or {@code 0L} for no timeout
+ * @param unit
+ * The time unit of the {@code timeout} argument
+ * @param attachment
+ * The object to attach to the I/O operation; can be {@code null}
+ * @param handler
+ * The handler for consuming the result; can be {@code null}
+ *
+ * @return a {@code Future} object representing the pending result
+ *
+ * @throws UnresolvedAddressException
+ * If the given remote address is not fully resolved
+ * @throws UnsupportedAddressTypeException
+ * If the type of the given remote address is not supported
+ * @throws IllegalArgumentException
+ * If the timeout is negative, or if the channel's socket is
+ * connected to an address that is not equal to {@code target}
+ * @throws SecurityException
+ * If a security manager has been installed and it does not permit
+ * datagrams to be sent to the given address
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ public abstract Future send(ByteBuffer src,
+ SocketAddress target,
+ long timeout,
+ TimeUnit unit,
+ A attachment,
+ CompletionHandler handler);
+
+ /**
+ * Sends a datagram via this channel.
+ *
+ * This method initiates sending of a datagram, returning a
+ * {@code Future} representing the pending result of the operation.
+ * The operation sends the remaining bytes in the given buffer as a single
+ * datagram to the given target address. The result of the operation, obtained
+ * by invoking the {@code Future}'s {@link Future#get() get}
+ * method, is the number of bytes sent.
+ *
+ *
This method is equivalent to invoking {@link
+ * #send(ByteBuffer,SocketAddress,long,TimeUnit,Object,CompletionHandler)}
+ * with a timeout of {@code 0L}.
+ *
+ * @param src
+ * The buffer containing the datagram to be sent
+ * @param target
+ * The address to which the datagram is to be sent
+ * @param attachment
+ * The object to attach to the I/O operation; can be {@code null}
+ * @param handler
+ * The handler for consuming the result; can be {@code null}
+ *
+ * @return a {@code Future} object representing the pending result
+ *
+ * @throws UnresolvedAddressException
+ * If the given remote address is not fully resolved
+ * @throws UnsupportedAddressTypeException
+ * If the type of the given remote address is not supported
+ * @throws IllegalArgumentException
+ * If the channel's socket is connected and is connected to an
+ * address that is not equal to {@code target}
+ * @throws SecurityException
+ * If a security manager has been installed and it does not permit
+ * datagrams to be sent to the given address
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ public final Future send(ByteBuffer src,
+ SocketAddress target,
+ A attachment,
+ CompletionHandler handler)
+ {
+ return send(src, target, 0L, TimeUnit.MILLISECONDS, attachment, handler);
+ }
+
+ /**
+ * Sends a datagram via this channel.
+ *
+ * This method initiates sending of a datagram, returning a
+ * {@code Future} representing the pending result of the operation.
+ * The operation sends the remaining bytes in the given buffer as a single
+ * datagram to the given target address. The result of the operation, obtained
+ * by invoking the {@code Future}'s {@link Future#get() get}
+ * method, is the number of bytes sent.
+ *
+ *
This method is equivalent to invoking {@link
+ * #send(ByteBuffer,SocketAddress,long,TimeUnit,Object,CompletionHandler)}
+ * with a timeout of {@code 0L} and an attachment and completion handler
+ * of {@code null}.
+ *
+ * @param src
+ * The buffer containing the datagram to be sent
+ * @param target
+ * The address to which the datagram is to be sent
+ *
+ * @return a {@code Future} object representing the pending result
+ *
+ * @throws UnresolvedAddressException
+ * If the given remote address is not fully resolved
+ * @throws UnsupportedAddressTypeException
+ * If the type of the given remote address is not supported
+ * @throws IllegalArgumentException
+ * If the channel's socket is connected and is connected to an
+ * address that is not equal to {@code target}
+ * @throws SecurityException
+ * If a security manager has been installed and it does not permit
+ * datagrams to be sent to the given address
+ */
+ public final Future send(ByteBuffer src, SocketAddress target) {
+ return send(src, target, 0L, TimeUnit.MILLISECONDS, null, null);
+ }
+
+ /**
+ * Receives a datagram via this channel.
+ *
+ * This method initiates the receiving of a datagram, returning a
+ * {@code Future} representing the pending result of the operation.
+ * The {@code Future}'s {@link Future#get() get} method returns
+ * the number of bytes transferred upon successful completion.
+ *
+ *
This method may only be invoked if this channel is connected, and it
+ * only accepts datagrams from the peer that the channel is connected too.
+ * The datagram is transferred into the given byte buffer starting at
+ * its current position and exactly as specified in the {@link
+ * AsynchronousByteChannel} interface. If there are fewer bytes
+ * remaining in the buffer than are required to hold the datagram then the
+ * remainder of the datagram is silently discarded.
+ *
+ *
If a timeout is specified and the timeout elapses before the operation
+ * completes then the operation completes with the exception {@link
+ * InterruptedByTimeoutException}. When a timeout elapses then the state of
+ * the {@link ByteBuffer} is not defined. The buffers should be discarded or
+ * at least care must be taken to ensure that the buffer is not accessed
+ * while the channel remains open.
+ *
+ * @param dst
+ * The buffer into which the datagram is to be transferred
+ * @param timeout
+ * The timeout, or {@code 0L} for no timeout
+ * @param unit
+ * The time unit of the {@code timeout} argument
+ * @param attachment
+ * The object to attach to the I/O operation; can be {@code null}
+ * @param handler
+ * The handler for consuming the result; can be {@code null}
+ *
+ * @return a {@code Future} object representing the pending result
+ *
+ * @throws IllegalArgumentException
+ * If the timeout is negative or buffer is read-only
+ * @throws NotYetConnectedException
+ * If this channel is not connected
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ public abstract Future read(ByteBuffer dst,
+ long timeout,
+ TimeUnit unit,
+ A attachment,
+ CompletionHandler handler);
+
+ /**
+ * @throws NotYetConnectedException
+ * If this channel is not connected
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ @Override
+ public final Future read(ByteBuffer dst,
+ A attachment,
+ CompletionHandler handler)
+ {
+ return read(dst, 0L, TimeUnit.MILLISECONDS, attachment, handler);
+ }
+
+ /**
+ * @throws NotYetConnectedException
+ * If this channel is not connected
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ @Override
+ public final Future read(ByteBuffer dst) {
+ return read(dst, 0L, TimeUnit.MILLISECONDS, null, null);
+ }
+
+ /**
+ * Writes a datagram to this channel.
+ *
+ * This method initiates sending of a datagram, returning a
+ * {@code Future} representing the pending result of the operation.
+ * The operation sends the remaining bytes in the given buffer as a single
+ * datagram. The result of the operation, obtained by invoking the
+ * {@code Future}'s {@link Future#get() get} method, is the
+ * number of bytes sent.
+ *
+ *
The datagram is transferred from the byte buffer as if by a regular
+ * {@link AsynchronousByteChannel#write write} operation.
+ *
+ *
This method may only be invoked if this channel is connected,
+ * in which case it sends datagrams directly to the socket's peer. Otherwise
+ * it behaves exactly as specified in the {@link
+ * AsynchronousByteChannel} interface.
+ *
+ *
If a timeout is specified and the timeout elapses before the operation
+ * completes then the operation completes with the exception {@link
+ * InterruptedByTimeoutException}. When a timeout elapses then the state of
+ * the {@link ByteBuffer} is not defined. The buffers should be discarded or
+ * at least care must be taken to ensure that the buffer is not accessed
+ * while the channel remains open.
+ *
+ * @param src
+ * The buffer containing the datagram to be sent
+ * @param timeout
+ * The timeout, or {@code 0L} for no timeout
+ * @param unit
+ * The time unit of the {@code timeout} argument
+ * @param attachment
+ * The object to attach to the I/O operation; can be {@code null}
+ * @param handler
+ * The handler for consuming the result; can be {@code null}
+ *
+ * @return a {@code Future} object representing the pending result
+ *
+ * @throws IllegalArgumentException
+ * If the timeout is negative
+ * @throws NotYetConnectedException
+ * If this channel is not connected
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ public abstract Future write(ByteBuffer src,
+ long timeout,
+ TimeUnit unit,
+ A attachment,
+ CompletionHandler handler);
+ /**
+ * @throws NotYetConnectedException
+ * If this channel is not connected
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ @Override
+ public final Future write(ByteBuffer src,
+ A attachment,
+ CompletionHandler handler)
+ {
+ return write(src, 0L, TimeUnit.MILLISECONDS, attachment, handler);
+ }
+
+ /**
+ * @throws NotYetConnectedException
+ * If this channel is not connected
+ * @throws ShutdownChannelGroupException
+ * If a handler is specified, and the channel group is shutdown
+ */
+ @Override
+ public final Future write(ByteBuffer src) {
+ return write(src, 0L, TimeUnit.MILLISECONDS, null, null);
+ }
+}
diff --git a/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java b/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java
new file mode 100644
index 00000000000..a9bff5f16d4
--- /dev/null
+++ b/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java
@@ -0,0 +1,774 @@
+/*
+ * Copyright 2007-2009 Sun Microsystems, Inc. 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. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.nio.channels;
+
+import java.nio.file.*;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.spi.*;
+import java.nio.ByteBuffer;
+import java.io.IOException;
+import java.util.concurrent.Future;
+import java.util.concurrent.ExecutorService;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * An asynchronous channel for reading, writing, and manipulating a file.
+ *
+ * An asynchronous file channel is created when a file is opened by invoking
+ * one of the {@link #open open} methods defined by this class. The file contains
+ * a variable-length sequence of bytes that can be read and written and whose
+ * current size can be {@link #size() queried}. The size of the file increases
+ * when bytes are written beyond its current size; the size of the file decreases
+ * when it is {@link #truncate truncated}.
+ *
+ *
An asynchronous file channel does not have a current position
+ * within the file. Instead, the file position is specified to each read and
+ * write operation.
+ *
+ *
In addition to read and write operations, this class defines the
+ * following operations:
+ *
+ *
+ *
+ * Updates made to a file may be {@link #force