changeset 22:edda4e091e4e

6538484: JAF fails in Turkish locale 6699090: Avoid NPE if parse fails in isMimeTypeEqual, do a string comparison instead Summary: Patch converted from TeamWare or webrev data Reviewed-by: darcy
author ohair
date Fri, 30 Jan 2009 17:10:34 -0800
parents 041d6eb25b82
children 541f26c646e7
files src/share/classes/com/sun/activation/registries/MailcapFile.java src/share/classes/javax/activation/ActivationDataFlavor.java src/share/classes/javax/activation/MailcapCommandMap.java src/share/classes/javax/activation/MimeType.java src/share/classes/javax/activation/MimeTypeParameterList.java test/Makefile test/TEST.ROOT test/com/sun/activation/registries/MailcapTokenizer/66990894/bug6699084.java test/javax/activation/6538484/bug6538484.java test/javax/activation/ActivationDataFlavor/6699090/bug6699090.java test/javax/activation/DataHandler/6456395/bug6456395.java test/jprt.config test/req.flg
diffstat 13 files changed, 868 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/activation/registries/MailcapFile.java	Fri Jan 30 17:06:04 2009 -0800
+++ b/src/share/classes/com/sun/activation/registries/MailcapFile.java	Fri Jan 30 17:10:34 2009 -0800
@@ -182,7 +182,8 @@
      */
     public String[] getNativeCommands(String mime_type) {
         String[] cmds = null;
-        List v = (List)native_commands.get(mime_type.toLowerCase());
+        List v =
+            (List)native_commands.get(mime_type.toLowerCase(Locale.ENGLISH));
         if (v != null) {
             cmds = new String[v.size()];
             cmds = (String[])v.toArray(cmds);
@@ -301,7 +302,8 @@
             reportParseError(MailcapTokenizer.STRING_TOKEN, currentToken,
                                         tokenizer.getCurrentTokenValue());
         }
-        String primaryType = tokenizer.getCurrentTokenValue().toLowerCase();
+        String primaryType =
+            tokenizer.getCurrentTokenValue().toLowerCase(Locale.ENGLISH);
         String subType = "*";
 
         //      parse the '/' between primary and sub
@@ -322,7 +324,8 @@
                 reportParseError(MailcapTokenizer.STRING_TOKEN,
                             currentToken, tokenizer.getCurrentTokenValue());
             }
-            subType = tokenizer.getCurrentTokenValue().toLowerCase();
+            subType =
+                tokenizer.getCurrentTokenValue().toLowerCase(Locale.ENGLISH);
 
             //  get the next token to simplify the next step
             currentToken = tokenizer.nextToken();
@@ -386,8 +389,8 @@
                     reportParseError(MailcapTokenizer.STRING_TOKEN,
                             currentToken, tokenizer.getCurrentTokenValue());
                 }
-                String paramName =
-                    tokenizer.getCurrentTokenValue().toLowerCase();
+                String paramName = tokenizer.getCurrentTokenValue().
+                                                toLowerCase(Locale.ENGLISH);
 
                 //      parse the '=' which separates the name from the value
                 currentToken = tokenizer.nextToken();
--- a/src/share/classes/javax/activation/ActivationDataFlavor.java	Fri Jan 30 17:06:04 2009 -0800
+++ b/src/share/classes/javax/activation/ActivationDataFlavor.java	Fri Jan 30 17:10:34 2009 -0800
@@ -204,7 +204,10 @@
             if (mimeObject == null)
                 mimeObject = new MimeType(this.mimeType);
             mt = new MimeType(mimeType);
-        } catch (MimeTypeParseException e) {}
+        } catch (MimeTypeParseException e) {
+            // something didn't parse, do a crude comparison
+            return this.mimeType.equalsIgnoreCase(mimeType);
+        }
 
         return mimeObject.match(mt);
     }
--- a/src/share/classes/javax/activation/MailcapCommandMap.java	Fri Jan 30 17:06:04 2009 -0800
+++ b/src/share/classes/javax/activation/MailcapCommandMap.java	Fri Jan 30 17:10:34 2009 -0800
@@ -348,7 +348,7 @@
     public synchronized CommandInfo[] getPreferredCommands(String mimeType) {
         List cmdList = new ArrayList();
         if (mimeType != null)
-            mimeType = mimeType.toLowerCase();
+            mimeType = mimeType.toLowerCase(Locale.ENGLISH);
 
         for (int i = 0; i < DB.length; i++) {
             if (DB[i] == null)
@@ -414,7 +414,7 @@
     public synchronized CommandInfo[] getAllCommands(String mimeType) {
         List cmdList = new ArrayList();
         if (mimeType != null)
-            mimeType = mimeType.toLowerCase();
+            mimeType = mimeType.toLowerCase(Locale.ENGLISH);
 
         for (int i = 0; i < DB.length; i++) {
             if (DB[i] == null)
@@ -468,7 +468,7 @@
     public synchronized CommandInfo getCommand(String mimeType,
                                                         String cmdName) {
         if (mimeType != null)
-            mimeType = mimeType.toLowerCase();
+            mimeType = mimeType.toLowerCase(Locale.ENGLISH);
 
         for (int i = 0; i < DB.length; i++) {
             if (DB[i] == null)
@@ -535,7 +535,7 @@
             LogSupport.log(
                 "MailcapCommandMap: createDataContentHandler for " + mimeType);
         if (mimeType != null)
-            mimeType = mimeType.toLowerCase();
+            mimeType = mimeType.toLowerCase(Locale.ENGLISH);
 
         for (int i = 0; i < DB.length; i++) {
             if (DB[i] == null)
@@ -652,7 +652,7 @@
     public synchronized String[] getNativeCommands(String mimeType) {
         List cmdList = new ArrayList();
         if (mimeType != null)
-            mimeType = mimeType.toLowerCase();
+            mimeType = mimeType.toLowerCase(Locale.ENGLISH);
 
         for (int i = 0; i < DB.length; i++) {
             if (DB[i] == null)
--- a/src/share/classes/javax/activation/MimeType.java	Fri Jan 30 17:06:04 2009 -0800
+++ b/src/share/classes/javax/activation/MimeType.java	Fri Jan 30 17:10:34 2009 -0800
@@ -25,10 +25,8 @@
 
 package javax.activation;
 
-import java.io.ObjectOutput;
-import java.io.ObjectInput;
-import java.io.IOException;
 import java.io.*;
+import java.util.Locale;
 
 /**
  * A Multipurpose Internet Mail Extension (MIME) type, as defined
@@ -77,14 +75,14 @@
     public MimeType(String primary, String sub) throws MimeTypeParseException {
         //    check to see if primary is valid
         if (isValidToken(primary)) {
-            primaryType = primary.toLowerCase();
+            primaryType = primary.toLowerCase(Locale.ENGLISH);
         } else {
             throw new MimeTypeParseException("Primary type is invalid.");
         }
 
         //    check to see if sub is valid
         if (isValidToken(sub)) {
-            subType = sub.toLowerCase();
+            subType = sub.toLowerCase(Locale.ENGLISH);
         } else {
             throw new MimeTypeParseException("Sub type is invalid.");
         }
@@ -108,14 +106,17 @@
             throw new MimeTypeParseException("Unable to find a sub type.");
         } else if ((slashIndex >= 0) && (semIndex < 0)) {
             //    we have a primary and sub type but no parameter list
-            primaryType = rawdata.substring(0, slashIndex).trim().toLowerCase();
-            subType = rawdata.substring(slashIndex + 1).trim().toLowerCase();
+            primaryType = rawdata.substring(0, slashIndex).trim().
+                                                toLowerCase(Locale.ENGLISH);
+            subType = rawdata.substring(slashIndex + 1).trim().
+                                                toLowerCase(Locale.ENGLISH);
             parameters = new MimeTypeParameterList();
         } else if (slashIndex < semIndex) {
             //    we have all three items in the proper sequence
-            primaryType = rawdata.substring(0, slashIndex).trim().toLowerCase();
-            subType = rawdata.substring(slashIndex + 1,
-                                                semIndex).trim().toLowerCase();
+            primaryType = rawdata.substring(0, slashIndex).trim().
+                                                toLowerCase(Locale.ENGLISH);
+            subType = rawdata.substring(slashIndex + 1, semIndex).trim().
+                                                toLowerCase(Locale.ENGLISH);
             parameters = new MimeTypeParameterList(rawdata.substring(semIndex));
         } else {
             // we have a ';' lexically before a '/' which means we
@@ -154,7 +155,7 @@
         //    check to see if primary is valid
         if (!isValidToken(primaryType))
             throw new MimeTypeParseException("Primary type is invalid.");
-        primaryType = primary.toLowerCase();
+        primaryType = primary.toLowerCase(Locale.ENGLISH);
     }
 
     /**
@@ -177,7 +178,7 @@
         //    check to see if sub is valid
         if (!isValidToken(subType))
             throw new MimeTypeParseException("Sub type is invalid.");
-        subType = sub.toLowerCase();
+        subType = sub.toLowerCase(Locale.ENGLISH);
     }
 
     /**
--- a/src/share/classes/javax/activation/MimeTypeParameterList.java	Fri Jan 30 17:06:04 2009 -0800
+++ b/src/share/classes/javax/activation/MimeTypeParameterList.java	Fri Jan 30 17:10:34 2009 -0800
@@ -27,6 +27,7 @@
 
 import java.util.Hashtable;
 import java.util.Enumeration;
+import java.util.Locale;
 
 /**
  * A parameter list of a MimeType
@@ -105,7 +106,8 @@
             while ((i < length) && isTokenChar(parameterList.charAt(i)))
                 i++;
 
-            name = parameterList.substring(lastIndex, i).toLowerCase();
+            name = parameterList.substring(lastIndex, i).
+                                                toLowerCase(Locale.ENGLISH);
 
             //    now parse the '=' that separates the name from the value
             i = skipWhiteSpace(parameterList, i);
@@ -202,7 +204,7 @@
      * @return          the parameter's value
      */
     public String get(String name) {
-        return (String)parameters.get(name.trim().toLowerCase());
+        return (String)parameters.get(name.trim().toLowerCase(Locale.ENGLISH));
     }
 
     /**
@@ -213,7 +215,7 @@
      * @param value     the parameter's value
      */
     public void set(String name, String value) {
-        parameters.put(name.trim().toLowerCase(), value);
+        parameters.put(name.trim().toLowerCase(Locale.ENGLISH), value);
     }
 
     /**
@@ -222,7 +224,7 @@
      * @param name      the parameter name
      */
     public void remove(String name) {
-        parameters.remove(name.trim().toLowerCase());
+        parameters.remove(name.trim().toLowerCase(Locale.ENGLISH));
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/Makefile	Fri Jan 30 17:10:34 2009 -0800
@@ -0,0 +1,110 @@
+#
+# Makefile to run jtreg
+#
+
+# Get OS/ARCH specifics
+OSNAME = $(shell uname -s)
+ifeq ($(OSNAME), SunOS)
+  PLATFORM = solaris
+  JCT_PLATFORM = solaris
+  ARCH = $(shell uname -p)
+  ifeq ($(ARCH), i386)
+    ARCH=i586
+  endif
+endif
+ifeq ($(OSNAME), Linux)
+  PLATFORM = linux
+  JCT_PLATFORM = linux
+  ARCH = $(shell uname -m)
+  ifeq ($(ARCH), i386)
+    ARCH=i586
+  endif
+endif
+ifeq ($(OSNAME), Windows_NT)
+  PLATFORM = windows
+  JCT_PLATFORM = win32
+  ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64)
+    ARCH=ia64
+  else
+    ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),AMD64)
+      ARCH=x64
+    else
+      ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),EM64T)
+        ARCH=x64
+      else
+        ARCH=i586
+      endif
+    endif
+  endif
+endif
+
+# Root of this test area (important to use full paths in some places)
+TEST_ROOT := $(shell pwd)
+
+# Default bundle of all test results (passed or not)
+JPRT_ARCHIVE_BUNDLE=$(TEST_ROOT)/JPRT_ARCHIVE_BUNDLE.zip
+
+# Default home for JTREG
+ifeq ($(PLATFORM), windows)
+  JT_HOME = J:/svc/jct-tools3.2.2_02
+  JTREG_KEY_OPTION=-k:!ignore
+else
+  JT_HOME = /java/svc/jct-tools3.2.2_02
+  JTREG_KEY_OPTION=-k:\!ignore
+endif
+
+# Default JTREG to run
+JTREG = $(JT_HOME)/$(JCT_PLATFORM)/bin/jtreg
+
+# Default JDK to test
+JAVA_HOME = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)
+
+# The test directories to run
+DEFAULT_TESTDIRS = demo/jvmti/gctest demo/jvmti/hprof
+TESTDIRS = $(DEFAULT_TESTDIRS)
+
+# Root of all test results
+JTREG_OUTPUT_DIR = $(TEST_ROOT)/o_$(PLATFORM)-$(ARCH)
+
+# Export this setting and pass it in.
+#JAVA_TOOL_OPTIONS = -Djava.awt.headless=true
+#export JAVA_TOOL_OPTIONS
+
+# Default make rule
+all: clean check tests $(JPRT_ARCHIVE_BUNDLE)
+	@echo "Testing completed successfully"
+
+# Chaeck to make sure these directories exist
+check: $(JT_HOME) $(JAVA_HOME) $(JTREG)
+
+# Run the tests
+tests: FRC
+	@echo "Using export JAVA_TOOL_OPTIONS=$(JAVA_TOOL_OPTIONS)"
+	@rm -f -r $(JTREG_OUTPUT_DIR)
+	@mkdir -p $(JTREG_OUTPUT_DIR)
+	$(JTREG) -a -v:fail,error \
+          $(JTREG_KEY_OPTION) \
+          -r:$(JTREG_OUTPUT_DIR)/JTreport \
+          -w:$(JTREG_OUTPUT_DIR)/JTwork \
+          -jdk:$(JAVA_HOME) \
+          $(JAVA_TOOL_OPTIONS:%=-vmoption:%) \
+          $(JAVA_ARGS:%=-vmoption:%) \
+          $(TESTDIRS)
+
+# Bundle up the results
+$(JPRT_ARCHIVE_BUNDLE): FRC
+	@rm -f $@
+	@mkdir -p $(@D)
+	( cd $(JTREG_OUTPUT_DIR) && zip -q -r $@ . )
+
+# Cleanup
+clean:
+	rm -f -r $(JTREG_OUTPUT_DIR)
+	rm -f $(JPRT_ARCHIVE_BUNDLE)
+
+# Used to force a target rules to run
+FRC:
+
+# Phony targets (e.g. these are not filenames)
+.PHONY: all tests clean check
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/TEST.ROOT	Fri Jan 30 17:10:34 2009 -0800
@@ -0,0 +1,6 @@
+# This file identifies the root of the test-suite hierarchy.
+# It also contains test-suite configuration information.
+# DO NOT EDIT without first contacting jdk-regtest@sun.com.
+
+# The list of keywords supported in the entire test suite
+keys=2d dnd i18n
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/activation/registries/MailcapTokenizer/66990894/bug6699084.java	Fri Jan 30 17:10:34 2009 -0800
@@ -0,0 +1,86 @@
+/*
+ * 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 6699084
+ * @summary Ensure changes to nextToken() implementation are invariant.
+ * @author Peter Williams
+ * @compile -XDignore.symbol.file bug6699084.java
+ * @run main bug6699084
+ */
+
+import com.sun.activation.registries.MailcapTokenizer;
+
+public class bug6699084 {
+    
+    public static void main(String[] args) {
+        testMailcapTokenizerNextToken();
+        System.out.println("Test completed.");
+    }
+
+    private static void testMailcapTokenizerNextToken() {
+        String tokenString = "  audio/mpeg; mpg321 -d esd %s >/dev/null 2>&1 </dev/null & ; description=\"MP3 Audio File\"";
+        int [] expectedTokens = { 
+            MailcapTokenizer.STRING_TOKEN,
+            MailcapTokenizer.SLASH_TOKEN,
+            MailcapTokenizer.STRING_TOKEN,
+            MailcapTokenizer.SEMICOLON_TOKEN,
+            MailcapTokenizer.STRING_TOKEN,
+            MailcapTokenizer.SEMICOLON_TOKEN,
+            MailcapTokenizer.STRING_TOKEN,
+            MailcapTokenizer.EQUALS_TOKEN,
+            MailcapTokenizer.STRING_TOKEN,
+            MailcapTokenizer.EOI_TOKEN,
+        };
+        
+        MailcapTokenizer tokenizer = new MailcapTokenizer(tokenString);
+        boolean autoquote = false;
+
+        for(int i = 0; i < expectedTokens.length; i++) {
+            int token = tokenizer.nextToken();
+            if(token != expectedTokens[i]) {
+                throw new RuntimeException("'" + tokenizer.getCurrentTokenValue() + "' parsed as token " + token + 
+                        " (" + MailcapTokenizer.nameForToken(token) + ")" + 
+                        ", expected " + expectedTokens[i] + 
+                        " (" + MailcapTokenizer.nameForToken(expectedTokens[i]) + ")" + 
+                        " at index " + i);
+            }
+            
+            if(token == MailcapTokenizer.SEMICOLON_TOKEN) {
+                if(autoquote) {
+                    autoquote = false;
+                } else {
+                    autoquote = true;
+                    tokenizer.setIsAutoquoting(true);
+                }
+            } else if(token == MailcapTokenizer.EQUALS_TOKEN) {
+                autoquote = true;
+                tokenizer.setIsAutoquoting(true);
+            } else {
+                tokenizer.setIsAutoquoting(false);
+            }
+        }
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/activation/6538484/bug6538484.java	Fri Jan 30 17:10:34 2009 -0800
@@ -0,0 +1,331 @@
+/*
+ * 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 6538484
+ * @summary Check for proper handling of String.toLowerCase in TURKISH locale
+ * @author Peter Williams
+ * @run main bug6538484
+ */
+
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringBufferInputStream;
+import java.util.Locale;
+import javax.activation.CommandInfo;
+import javax.activation.DataContentHandler;
+import javax.activation.DataSource;
+import javax.activation.MailcapCommandMap;
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParameterList;
+import javax.activation.MimeTypeParseException;
+
+import static java.util.Locale.ENGLISH;
+
+public class bug6538484 {
+
+    private static final Locale TURKISH = new Locale("tr");
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws MimeTypeParseException {
+        testMailcapCommandMap(ENGLISH);
+        testMailcapCommandMap(TURKISH);
+        testMimeType(ENGLISH);
+        testMimeType(TURKISH);
+        testMimeTypeParameterList(ENGLISH);
+        testMimeTypeParameterList(TURKISH);
+        System.out.println("Test completed.");
+    }
+
+    private static void testMailcapCommandMap(Locale locale) {
+        String cmdMapString = "# Java Web Start\n"
+                + "application/x-java-jnlp-file; /jre/bin/javaws %s\n"
+                + "# Image command\n"
+                + "image/gif; /usr/sfw/bin/gimp %s;\\\n"
+                + "    x-java-view=com.foo.FancyFooViewer;\\\n"
+                + "    x-java-content-handler=" + 
+                        DummyContentHandler.class.getName() + "\n"
+                + "# Text command\n"
+                + "text/plain; /usr/bin/less %s;\\\n"
+                + "    x-java-fallback-entry=true;\\\n"
+                + "    x-java-view=com.sun.TextViewer\n"
+                ;
+        
+        String preferredMt1 = "image/gif";
+        String preferredMt2 = "IMAGE/GIF";
+        String fallbackMt1 = "text/plain";
+        String fallbackMt2 = "TEXT/PLAIN";
+        String nativeMt1 = "application/x-java-jnlp-file";
+        String nativeMt2 = "APPLICATION/X-JAVA-JNLP-FILE";
+
+        MailcapCommandMap cmdMap = new MailcapCommandMap(new StringBufferInputStream(cmdMapString));
+        
+        testMailcapCommandMapGetPreferredCommands(locale, cmdMap, preferredMt1, 2);
+        testMailcapCommandMapGetPreferredCommands(locale, cmdMap, preferredMt2, 2);
+
+        testMailcapCommandMapGetAllCommands(locale, cmdMap, fallbackMt1, 3);
+        testMailcapCommandMapGetAllCommands(locale, cmdMap, fallbackMt2, 3);
+
+        testMailcapCommandMapGetCommand(locale, cmdMap, preferredMt1, "view");
+        testMailcapCommandMapGetCommand(locale, cmdMap, preferredMt2, "view");
+
+        testMailcapCommandMapCreateDataContentHandler(locale, cmdMap, preferredMt1);
+        testMailcapCommandMapCreateDataContentHandler(locale, cmdMap, preferredMt2);
+                
+        testMailcapCommandMapGetNativeCommands(locale, cmdMap, nativeMt1, 1);
+        testMailcapCommandMapGetNativeCommands(locale, cmdMap, nativeMt2, 1);
+    }
+    
+    private static void testMailcapCommandMapGetPreferredCommands(Locale locale,
+            MailcapCommandMap cmdMap, String mimetype, int expectedCount) {
+        Locale.setDefault(locale);
+        
+        CommandInfo [] result = cmdMap.getPreferredCommands(mimetype);
+        
+        if(result == null || result.length != expectedCount) {
+            throw new RuntimeException("MailcapCommandMap.getPreferredCommands() failed for " + mimetype);
+        }
+    }
+    
+    private static void testMailcapCommandMapGetAllCommands(Locale locale,
+            MailcapCommandMap cmdMap, String mimetype, int expectedCount) {
+        Locale.setDefault(locale);
+        
+        CommandInfo [] result = cmdMap.getAllCommands(mimetype);
+        
+        if(result == null || result.length != expectedCount) {
+            throw new RuntimeException("MailcapCommandMap.getAllCommands() failed for " + mimetype);
+        }
+    }
+    
+    private static void testMailcapCommandMapGetCommand(Locale locale,
+            MailcapCommandMap cmdMap, String mimetype, String command) {
+        Locale.setDefault(locale);
+        
+        CommandInfo result = cmdMap.getCommand(mimetype, command);
+
+        if(result == null) {
+            throw new RuntimeException("MailcapCommandMap.getCommand() failed for " + mimetype);
+        }
+    }
+    
+    private static void testMailcapCommandMapCreateDataContentHandler(Locale locale,
+            MailcapCommandMap cmdMap, String mimetype) {
+        Locale.setDefault(locale);
+        
+        DataContentHandler handler = cmdMap.createDataContentHandler(mimetype);
+
+        if(handler == null) {
+            throw new RuntimeException("MailcapCommandMap.createDataContentHandler() failed for " + mimetype);
+        }
+    }
+    
+    private static void testMailcapCommandMapGetNativeCommands(Locale locale,
+            MailcapCommandMap cmdMap, String mimetype, int expectedCount) {
+        Locale.setDefault(locale);
+        
+        String [] result = cmdMap.getNativeCommands(mimetype);
+
+        if(result == null || result.length != expectedCount) {
+            throw new RuntimeException("MailcapCommandMap.getNativeCommands() failed for " + mimetype);
+        }
+    }
+    
+    public static class DummyContentHandler implements DataContentHandler {
+
+        public DataFlavor[] getTransferDataFlavors() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Object getTransferData(DataFlavor arg0, DataSource arg1) throws UnsupportedFlavorException, IOException {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Object getContent(DataSource arg0) throws IOException {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public void writeTo(Object arg0, String arg1, OutputStream arg2) throws IOException {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+        
+    }
+    
+    private static void testMimeType(Locale locale) throws MimeTypeParseException {
+        String t1 = "image";
+        String t2 = "IMAGE";
+        String s1 = "plain";
+        String s2 = "PLAIN";
+        
+        String expectedPrimaryType = t1;
+        String expectedSubType = s1;
+        String expectedBaseType = expectedPrimaryType + "/" + expectedSubType;
+
+        // MimeType(expr)
+        testMimeTypeCtor(locale, t1 + "/" + s1, expectedBaseType);
+        testMimeTypeCtor(locale, t1 + "/" + s2, expectedBaseType);
+        testMimeTypeCtor(locale, t2 + "/" + s1, expectedBaseType);
+        testMimeTypeCtor(locale, t2 + "/" + s2, expectedBaseType);
+        
+        // MimeType(type, subtype)
+        testMimeTypeCtor(locale, t1, s1, expectedBaseType);
+        testMimeTypeCtor(locale, t1, s2, expectedBaseType);
+        testMimeTypeCtor(locale, t2, s1, expectedBaseType);
+        testMimeTypeCtor(locale, t2, s2, expectedBaseType);
+        
+        // MimeType.setPrimaryType()
+        MimeType mt = new MimeType(expectedBaseType);
+        testMimeTypeSetPrimaryType(locale, mt, t1, expectedPrimaryType);
+        testMimeTypeSetPrimaryType(locale, mt, t2, expectedPrimaryType);
+        
+        // MimeType.setSubType()
+        mt = new MimeType(expectedBaseType);
+        testMimeTypeSetSubType(locale, mt, s1, expectedSubType);
+        testMimeTypeSetSubType(locale, mt, s2, expectedSubType);
+    }
+
+    private static void testMimeTypeCtor(Locale locale, String parse, String expectedBaseType) throws MimeTypeParseException {
+        Locale.setDefault(locale);
+        MimeType mt = new MimeType(parse);
+        
+        if(!mt.getBaseType().equals(expectedBaseType)) {
+            throw new RuntimeException("Mimetype case conversion failed for " + mt.getBaseType());
+        }
+    }
+
+    private static void testMimeTypeCtor(Locale locale, String type, String subtype, String expectedBaseType) throws MimeTypeParseException {
+        Locale.setDefault(locale);
+        MimeType mt = new MimeType(type, subtype);
+        
+        if(!mt.getBaseType().equals(expectedBaseType)) {
+            throw new RuntimeException("Mimetype case conversion failed for " + mt.getBaseType());
+        }
+    }
+
+    private static void testMimeTypeSetPrimaryType(Locale locale, MimeType mt, String type, String expectedType) throws MimeTypeParseException {
+        Locale.setDefault(locale);
+        
+        mt.setPrimaryType(type);
+        
+        if(!mt.getPrimaryType().equals(expectedType)) {
+            throw new RuntimeException("MimeType.setPrimaryType() failed for " + mt.getPrimaryType());
+        }
+    }
+
+    private static void testMimeTypeSetSubType(Locale locale, MimeType mt, String subtype, String expectedSubType) throws MimeTypeParseException {
+        Locale.setDefault(locale);
+        
+        mt.setSubType(subtype);
+        
+        if(!mt.getSubType().equals(expectedSubType)) {
+            throw new RuntimeException("MimeType.getSubType() failed for " + mt.getSubType());
+        }
+    }
+
+    private static void testMimeTypeParameterList(Locale locale) throws MimeTypeParseException {
+        String expectedValue = "foo";
+        String n1 = "field";
+        String n2 = "FIELD";
+        String p1 = ";" + n1 + "=" + expectedValue;
+        String p2 = ";" + n2 + "=" + expectedValue;
+
+        String expectedName = n1;
+        String expectedParams = ";" + expectedName + "=" + expectedValue;
+        
+        // MimeTypeParameterList(expr);
+        testMimeTypeParameterListCtor(locale, p1, expectedName);
+        testMimeTypeParameterListCtor(locale, p2, expectedName);
+        
+        // MimeTypeParameterList.get(name)
+        testMimeTypeParameterListGet(locale, n1, expectedName, expectedParams);
+        testMimeTypeParameterListGet(locale, n2, expectedName, expectedParams);
+        
+        // MimeTypeParameterList.set(name)
+        testMimeTypeParameterListSet(locale, n1, expectedName, expectedParams);
+        testMimeTypeParameterListSet(locale, n2, expectedName, expectedParams);
+        
+        // MimeTypeParameterList.remove(name)
+        testMimeTypeParameterListRemove(locale, n1, expectedName, expectedParams);
+        testMimeTypeParameterListRemove(locale, n2, expectedName, expectedParams);
+    }
+    
+    private static void testMimeTypeParameterListCtor(Locale locale, String params, String expectedName) throws MimeTypeParseException {
+        Locale.setDefault(locale);
+        
+        MimeTypeParameterList mtpl = new MimeTypeParameterList(params);
+        
+        if(mtpl.get(expectedName) == null) {
+            throw new RuntimeException("MimeTypeParameterList case conversion failed for " + mtpl.toString());
+        }
+    }
+
+    private static void testMimeTypeParameterListGet(Locale locale, String name, String properName, String properParams) throws MimeTypeParseException {
+        Locale.setDefault(locale);
+
+        MimeTypeParameterList mtpl = new MimeTypeParameterList(properParams);
+        String v1 = mtpl.get(name);
+        String v2 = mtpl.get(properName);
+
+        if(v1 == null) {
+            if(v2 != null) {
+                throw new RuntimeException("MimeTypeParameterList.get() failed for " + name);
+            }
+        } else if(!v1.equals(v2)) {
+            throw new RuntimeException("MimeTypeParameterList.get() failed for " + mtpl.toString());
+        }
+    }
+    
+    private static void testMimeTypeParameterListSet(Locale locale, String name, String properName, String properParams) throws MimeTypeParseException {
+        Locale.setDefault(locale);
+
+        MimeTypeParameterList mtpl = new MimeTypeParameterList(properParams);
+        String expectedValue = "bar";
+        mtpl.set(name, expectedValue);
+        String newValue = mtpl.get(properName);
+        
+        if(!expectedValue.equals(newValue)) {
+            throw new RuntimeException("MimeTypeParameterList.set() failed to change " + name + " in " + mtpl.toString());
+        }
+    }
+    
+    private static void testMimeTypeParameterListRemove(Locale locale, String name, String properName, String properParams) throws MimeTypeParseException {
+        Locale.setDefault(locale);
+
+        MimeTypeParameterList mtpl = new MimeTypeParameterList(properParams);
+        String oldvalue = mtpl.get(properName);
+        mtpl.remove(name);
+        String newvalue = mtpl.get(properName);
+
+        if(oldvalue == null) {
+            throw new NullPointerException("Broken test for MimeTypeParameterList.remove()" + mtpl.toString());
+        } else if(oldvalue.equals(newvalue)) {
+            throw new RuntimeException("MimeTypeParameterList.remove() failed for " + name + " in " + mtpl);
+        }
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/activation/ActivationDataFlavor/6699090/bug6699090.java	Fri Jan 30 17:10:34 2009 -0800
@@ -0,0 +1,56 @@
+/*
+ * 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 6699090
+ * @summary Fixed NPE in isMimeTypeEqual if parsing of mimetype failed.
+ * @author Peter Williams
+ * @run main bug6699090
+ */
+
+import javax.activation.ActivationDataFlavor;
+
+public class bug6699090 {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) {
+        testIsMimeTypeEqual();
+        System.out.println("Test completed.");
+    }
+
+    private static void testIsMimeTypeEqual() {
+        // this one will parse
+        String goodMimeType = "text/plain";
+        ActivationDataFlavor adf = new ActivationDataFlavor(goodMimeType, "Plain Text");
+        adf.isMimeTypeEqual(goodMimeType);
+        
+        // this one will not
+        String badMimeType = "text";
+        adf.isMimeTypeEqual(badMimeType);
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/activation/DataHandler/6456395/bug6456395.java	Fri Jan 30 17:10:34 2009 -0800
@@ -0,0 +1,83 @@
+/*
+ * 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 6456395
+ * @summary Special case byte[] and String in writeTo
+ * @author Peter Williams
+ * @run main bug6456395
+ */
+
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.IOException;
+import javax.activation.CommandInfo;
+import javax.activation.CommandMap;
+import javax.activation.DataContentHandler;
+import javax.activation.DataHandler;
+
+public class bug6456395 {
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String[] args) throws ClassNotFoundException, UnsupportedFlavorException, IOException {
+        testDataHandlerWriteTo();
+        System.out.println("Test completed.");
+    }
+
+    private static void testDataHandlerWriteTo() throws ClassNotFoundException, UnsupportedFlavorException, IOException {
+        // test String data
+        String textMimeType = "text/plain";
+        String stringData = "The quick brown fox jumped over the lazy dogs.\n";
+        DataHandler dh = new DataHandler(stringData, textMimeType);
+        dh.setCommandMap(createDummyCommandMap());
+        dh.writeTo(System.out);
+        
+        // test byte [] data
+        String byteMimeType = "text/ascii";
+        byte [] byteData = stringData.getBytes();
+        dh = new DataHandler(byteData, byteMimeType);
+        dh.setCommandMap(createDummyCommandMap());
+        dh.writeTo(System.out);
+    }
+    
+    // Use empty command map to avoid reading .mailcap if it exists on test system.
+    private static CommandMap createDummyCommandMap() {
+        return new CommandMap() {
+            public CommandInfo[] getPreferredCommands(String mimeType) {
+                return new CommandInfo [0];
+            }
+            public CommandInfo[] getAllCommands(String mimeType) {
+                return new CommandInfo [0];
+            }
+            public CommandInfo getCommand(String mimeType, String cmdName) {
+                return null;
+            }
+            public DataContentHandler createDataContentHandler(String mimeType) {
+                return null;
+            }
+        };
+    }
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jprt.config	Fri Jan 30 17:10:34 2009 -0800
@@ -0,0 +1,159 @@
+#!echo "This is not a shell script"
+#############################################################################
+# Copyright 2006-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.
+#############################################################################
+#
+# JPRT shell configuration for testing.
+#
+# Input environment variables:
+#    Windows Only:
+#      PATH
+#      ROOTDIR
+#
+# Output variable settings:
+#    make    Full path to GNU make
+#
+# Output environment variables:
+#    PATH
+#
+#############################################################################
+
+#############################################################################
+# Error
+error() # message
+{
+  echo "ERROR: $1"
+  exit 6
+}
+# Directory must exist
+dirMustExist() # dir name
+{
+  if [ ! -d "$1" ] ; then
+    error "Directory for $2 does not exist: $1"
+  fi
+}
+# File must exist
+fileMustExist() # dir name
+{
+  if [ ! -f "$1" ] ; then
+    error "File for $2 does not exist: $1"
+  fi
+}
+#############################################################################
+
+# Should be set by JPRT as the 3 basic inputs
+slashjava="${ALT_SLASH_JAVA}"
+if [ "${slashjava}" = "" ] ; then
+  slashjava=/java
+fi
+
+# Check input
+dirMustExist "${slashjava}"  ALT_SLASH_JAVA
+
+# Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise.
+osname=`uname -s`
+if [ "${osname}" = SunOS ] ; then
+   
+    # SOLARIS: Sparc or X86
+    osarch=`uname -p`
+    if [ "${osarch}" = sparc ] ; then
+	solaris_arch=sparc
+    else
+	solaris_arch=i386
+    fi
+
+    # Add basic solaris system paths
+    path4sdk=/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin
+
+    # Find GNU make
+    make=/usr/sfw/bin/gmake
+    if [ ! -f ${make} ] ; then
+	make=/opt/sfw/bin/gmake
+	if [ ! -f ${make} ] ; then
+	    make=${slashjava}/devtools/${solaris_arch}/bin/gnumake
+        fi 
+    fi
+    fileMustExist "${make}" make
+
+    # File creation mask
+    umask 002
+
+elif [ "${osname}" = Linux ] ; then
+   
+    # Add basic paths
+    path4sdk=/usr/bin:/bin:/usr/sbin:/sbin
+
+    # Find GNU make
+    make=/usr/bin/make
+    fileMustExist "${make}" make
+
+    umask 002
+
+else
+
+    # Windows: Differs on CYGWIN vs. MKS.
+   
+    # We need to determine if we are running a CYGWIN shell or an MKS shell
+    #    (if uname isn't available, then it will be unix_toolset=unknown)
+    unix_toolset=unknown
+    if [ "`uname -a | fgrep Cygwin`" = "" -a -d "${ROOTDIR}" ] ; then
+        # We kind of assume ROOTDIR is where MKS is and it's ok
+        unix_toolset=MKS
+        mkshome=`dosname -s "${ROOTDIR}"`
+        # Most unix utilities are in the mksnt directory of ROOTDIR
+        unixcommand_path="${mkshome}/mksnt"
+        path4sdk="${unixcommand_path}"
+	devtools_path="${slashjava}/devtools/win32/bin"
+	path4sdk="${devtools_path};${path4sdk}"
+        # Find GNU make
+        make="${devtools_path}/gnumake.exe"
+        fileMustExist "${make}" make
+    elif [ "`uname -a | fgrep Cygwin`" != "" -a -f /bin/cygpath ] ; then
+        # For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist
+        unix_toolset=CYGWIN
+        # Most unix utilities are in the /usr/bin
+        unixcommand_path="/usr/bin"
+        path4sdk="${unixcommand_path}"
+        # Find GNU make
+        make="${unixcommand_path}/make.exe"
+        fileMustExist "${make}" make
+    else
+      echo "WARNING: Cannot figure out if this is MKS or CYGWIN"
+    fi
+
+    
+    # For windows, it's hard to know where the system is, so we just add this
+    #    to PATH.
+    slash_path="`echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g'`"
+    path4sdk="${slash_path};${PATH}"
+    
+    # Convert path4sdk to cygwin style
+    if [ "${unix_toolset}" = CYGWIN ] ; then
+	path4sdk="`/usr/bin/cygpath -p ${path4sdk}`"
+    fi
+
+fi
+
+# Export PATH setting
+PATH="${path4sdk}"
+export PATH
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/req.flg	Fri Jan 30 17:10:34 2009 -0800
@@ -0,0 +1,1 @@
+echo_file test/TEST.ROOT