changeset 3941:be5a4198c468

Merge
author alanb
date Sun, 20 Mar 2011 19:39:11 +0000
parents 8d53286f1fe7 (current diff) 90f84ecff75c (diff)
children 1d0039aea814
files
diffstat 9 files changed, 97 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sat Mar 19 14:21:52 2011 +0000
+++ b/.hgtags	Sun Mar 20 19:39:11 2011 +0000
@@ -108,3 +108,4 @@
 8ac52c85f9e91336dc00b52ef90b42eecf3230b3 jdk7-b131
 6bbc7a4734952ae7604578f270e1566639fa8752 jdk7-b132
 5e5f68a01d12a4432172f384d5201f3a05254493 jdk7-b133
+554adcfb615e63e62af530b1c10fcf7813a75b26 jdk7-b134
--- a/make/common/Demo.gmk	Sat Mar 19 14:21:52 2011 +0000
+++ b/make/common/Demo.gmk	Sun Mar 20 19:39:11 2011 +0000
@@ -118,8 +118,11 @@
 DEMO_ALL_NATIVE_SOURCES += $(filter %.hpp,$(DEMO_ALL_FILES))
 
 # If we have java sources, then define the jar file we will create
+ifndef DEMO_JAR_NAME
+  DEMO_JAR_NAME = $(DEMONAME).jar
+endif
 ifneq ($(strip $(DEMO_JAVA_SOURCES)),)
-  DEMO_JAR            = $(DEMO_DESTDIR)/$(DEMONAME).jar
+  DEMO_JAR            = $(DEMO_DESTDIR)/$(DEMO_JAR_NAME)
 endif
 
 # If we have native sources, define the native library we will create
@@ -252,6 +255,17 @@
 	$(MKDIR) -p $(DEMO_JAR_IMAGE)
 	$(JAVAC_CMD) -d $(DEMO_JAR_IMAGE) -sourcepath $(DEMO_BUILD_SRCDIR) \
 	    @$(DEMO_JAVAC_INPUT)
+  ifeq ($(DEMO_INCL_SRC),true)
+	$(CP) $(DEMO_JAVA_SOURCES:%=$(DEMO_BUILD_SRCDIR)/%) $(DEMO_JAR_IMAGE)
+  endif
+  ifeq ($(DEMO_ONLY_SRC),true)
+	$(RM) -r $(DEMO_JAR_IMAGE)
+	$(MKDIR) -p $(DEMO_JAR_IMAGE)
+	$(CP) -r $(DEMO_BUILD_SRCDIR)/* $(DEMO_JAR_IMAGE)
+    ifneq ($(DEMO_TOPFILES),)
+	$(CP) $(DEMO_ROOT)/$(DEMO_TOPFILES) $(DEMO_JAR_IMAGE)
+    endif
+  endif
 	$(BOOT_JAR_CMD) -cfm $@ $(DEMO_MANIFEST) \
 	     -C $(DEMO_JAR_IMAGE) . \
 	     $(BOOT_JAR_JFLAGS)
@@ -324,9 +338,9 @@
 ifdef DEMO_IS_APPLET
 	@$(ECHO) "Expanding jar file into demos area at $(DEMO_DESTDIR)"
 	( $(CD) $(DEMO_DESTDIR) && \
-	  $(BOOT_JAR_CMD) -xfv $(DEMONAME).jar \
+	  $(BOOT_JAR_CMD) -xfv $(DEMO_JAR_NAME) \
 	     $(BOOT_JAR_JFLAGS) && \
-	  $(RM) -r META-INF $(DEMONAME).jar  && \
+	  $(RM) -r META-INF $(DEMO_JAR_NAME) && \
 	  $(java-vm-cleanup) )
 	@( $(CD) $(DEMO_DESTDIR) && $(java-vm-cleanup) )
 	@$(ECHO) "Expanding source into demos area at $(DEMO_DESTDIR)"
--- a/make/common/shared/Compiler-msvc.gmk	Sat Mar 19 14:21:52 2011 +0000
+++ b/make/common/shared/Compiler-msvc.gmk	Sun Mar 20 19:39:11 2011 +0000
@@ -153,6 +153,9 @@
   ifndef COMPILER_VERSION
     COMPILER_VERSION := $(error COMPILER_VERSION cannot be empty here)
   endif
+  ifneq ($(COMPILER_VERSION),VS2010)
+    COMPILER_VERSION := $(error COMPILER_VERSION must be VS2010)
+  endif
   
   # Shared library generation flag
   SHARED_LIBRARY_FLAG = -LD
--- a/make/common/shared/Platform.gmk	Sat Mar 19 14:21:52 2011 +0000
+++ b/make/common/shared/Platform.gmk	Sun Mar 20 19:39:11 2011 +0000
@@ -148,7 +148,7 @@
   # Suffix for file bundles used in previous release
   BUNDLE_FILE_SUFFIX=.tar
   # How much RAM does this machine have:
-  MB_OF_MEMORY=$(shell /etc/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3)
+  MB_OF_MEMORY=$(shell /usr/sbin/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3)
 endif
 
 # Platform settings specific to Linux
--- a/make/mkdemo/jfc/SwingSet2/Makefile	Sat Mar 19 14:21:52 2011 +0000
+++ b/make/mkdemo/jfc/SwingSet2/Makefile	Sun Mar 20 19:39:11 2011 +0000
@@ -37,6 +37,7 @@
 DEMO_MAINCLASS  = $(DEMONAME)
 DEMO_MANIFEST_ATTR = SplashScreen-Image: resources/images/splash.png
 DEMO_DESTDIR    = $(DEMODIR)/jfc/$(DEMONAME)
+DEMO_INCL_SRC   = true
 
 #
 # Demo jar building rules.
--- a/make/mkdemo/jpda/Makefile	Sat Mar 19 14:21:52 2011 +0000
+++ b/make/mkdemo/jpda/Makefile	Sun Mar 20 19:39:11 2011 +0000
@@ -32,6 +32,8 @@
 DEMO_PKGDIR     = com/sun/tools/example
 DEMO_TOPFILES   = ./com/sun/tools/example/README
 DEMO_DESTDIR    = $(DEMODIR)/jpda
+DEMO_JAR_NAME   = examples.jar
+DEMO_ONLY_SRC   = true
 
 #
 # Demo jar building rules.
--- a/make/tools/manifest.mf	Sat Mar 19 14:21:52 2011 +0000
+++ b/make/tools/manifest.mf	Sun Mar 20 19:39:11 2011 +0000
@@ -1,6 +1,6 @@
 Manifest-Version: 1.0
 Specification-Title: Java Platform API Specification
-Specification-Version: 1.6
+Specification-Version: 1.7
 Specification-Vendor: Oracle
 Implementation-Title: Java Runtime Environment
 Implementation-Version: @@RELEASE@@
--- a/src/share/bin/java.c	Sat Mar 19 14:21:52 2011 +0000
+++ b/src/share/bin/java.c	Sun Mar 20 19:39:11 2011 +0000
@@ -61,6 +61,9 @@
  * interfaces.
  */
 
+/* we always print to stderr */
+#define USE_STDERR JNI_TRUE
+
 static jboolean printVersion = JNI_FALSE; /* print and exit */
 static jboolean showVersion = JNI_FALSE;  /* print but continue */
 static jboolean printUsage = JNI_FALSE;   /* print and exit*/
@@ -1136,36 +1139,18 @@
     return; \
   }
 
-static jstring platformEncoding = NULL;
-static jstring getPlatformEncoding(JNIEnv *env) {
-    if (platformEncoding == NULL) {
-        jstring propname = (*env)->NewStringUTF(env, "sun.jnu.encoding");
-        if (propname) {
-            jclass cls;
-            jmethodID mid;
-            NULL_CHECK0 (cls = FindBootStrapClass(env, "java/lang/System"));
-            NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
-                                   env, cls,
-                                   "getProperty",
-                                   "(Ljava/lang/String;)Ljava/lang/String;"));
-            platformEncoding = (*env)->CallStaticObjectMethod (
-                                    env, cls, mid, propname);
-        }
+static jclass helperClass = NULL;
+
+static jclass
+GetLauncherHelperClass(JNIEnv *env) {
+    if (helperClass == NULL) {
+        NULL_CHECK0(helperClass = FindBootStrapClass(env,
+                "sun/launcher/LauncherHelper"));
     }
-    return platformEncoding;
+    return helperClass;
 }
 
-static jboolean isEncodingSupported(JNIEnv *env, jstring enc) {
-    jclass cls;
-    jmethodID mid;
-    NULL_CHECK0 (cls = FindBootStrapClass(env, "java/nio/charset/Charset"));
-    NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
-                           env, cls,
-                           "isSupported",
-                           "(Ljava/lang/String;)Z"));
-    return (*env)->CallStaticBooleanMethod(env, cls, mid, enc);
-}
-
+static jmethodID makePlatformStringMID = NULL;
 /*
  * Returns a new Java string object for the specified platform string.
  */
@@ -1173,36 +1158,23 @@
 NewPlatformString(JNIEnv *env, char *s)
 {
     int len = (int)JLI_StrLen(s);
-    jclass cls;
-    jmethodID mid;
     jbyteArray ary;
-    jstring enc;
-
+    jclass cls = GetLauncherHelperClass(env);
+    NULL_CHECK0(cls);
     if (s == NULL)
         return 0;
-    enc = getPlatformEncoding(env);
 
     ary = (*env)->NewByteArray(env, len);
     if (ary != 0) {
         jstring str = 0;
         (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
         if (!(*env)->ExceptionOccurred(env)) {
-            NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String"));
-            if (isEncodingSupported(env, enc) == JNI_TRUE) {
-                NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
-                                          "([BLjava/lang/String;)V"));
-                str = (*env)->NewObject(env, cls, mid, ary, enc);
-            } else {
-                /*If the encoding specified in sun.jnu.encoding is not
-                  endorsed by "Charset.isSupported" we have to fall back
-                  to use String(byte[]) explicitly here without specifying
-                  the encoding name, in which the StringCoding class will
-                  pickup the iso-8859-1 as the fallback converter for us.
-                */
-                NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
-                                          "([B)V"));
-                str = (*env)->NewObject(env, cls, mid, ary);
+            if (makePlatformStringMID == NULL) {
+                NULL_CHECK0(makePlatformStringMID = (*env)->GetStaticMethodID(env,
+                        cls, "makePlatformString", "(Z[B)Ljava/lang/String;"));
             }
+            str = (*env)->CallStaticObjectMethod(env, cls,
+                    makePlatformStringMID, USE_STDERR, ary);
             (*env)->DeleteLocalRef(env, ary);
             return str;
         }
@@ -1239,20 +1211,28 @@
 static jclass
 LoadMainClass(JNIEnv *env, int mode, char *name)
 {
-    jclass cls;
     jmethodID mid;
     jstring str;
     jobject result;
     jlong start, end;
-
+    jclass cls = GetLauncherHelperClass(env);
+    NULL_CHECK0(cls);
     if (JLI_IsTraceLauncher()) {
         start = CounterGet();
     }
-    NULL_CHECK0(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
-    NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, "checkAndLoadMain",
-                                          "(ZILjava/lang/String;)Ljava/lang/Class;"));
-    str = (*env)->NewStringUTF(env, name);
-    result = (*env)->CallStaticObjectMethod(env, cls, mid, JNI_TRUE, mode, str);
+    NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
+                "checkAndLoadMain",
+                "(ZILjava/lang/String;)Ljava/lang/Class;"));
+
+    switch (mode) {
+        case LM_CLASS:
+            str = NewPlatformString(env, name);
+            break;
+        default:
+            str = (*env)->NewStringUTF(env, name);
+            break;
+    }
+    result = (*env)->CallStaticObjectMethod(env, cls, mid, USE_STDERR, mode, str);
 
     if (JLI_IsTraceLauncher()) {
         end   = CounterGet();
@@ -1478,15 +1458,15 @@
 static void
 ShowSettings(JNIEnv *env, char *optString)
 {
-    jclass cls;
     jmethodID showSettingsID;
     jstring joptString;
-    NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
+    jclass cls = GetLauncherHelperClass(env);
+    NULL_CHECK(cls);
     NULL_CHECK(showSettingsID = (*env)->GetStaticMethodID(env, cls,
             "showSettings", "(ZLjava/lang/String;JJJZ)V"));
     joptString = (*env)->NewStringUTF(env, optString);
     (*env)->CallStaticVoidMethod(env, cls, showSettingsID,
-                                 JNI_TRUE,
+                                 USE_STDERR,
                                  joptString,
                                  (jlong)initialHeapSize,
                                  (jlong)maxHeapSize,
@@ -1500,18 +1480,15 @@
 static void
 PrintUsage(JNIEnv* env, jboolean doXUsage)
 {
-  jclass cls;
   jmethodID initHelp, vmSelect, vmSynonym, vmErgo, printHelp, printXUsageMessage;
   jstring jprogname, vm1, vm2;
   int i;
-
-  NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
-
-
+  jclass cls = GetLauncherHelperClass(env);
+  NULL_CHECK(cls);
   if (doXUsage) {
     NULL_CHECK(printXUsageMessage = (*env)->GetStaticMethodID(env, cls,
                                         "printXUsageMessage", "(Z)V"));
-    (*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, JNI_TRUE);
+    (*env)->CallStaticVoidMethod(env, cls, printXUsageMessage, USE_STDERR);
   } else {
     NULL_CHECK(initHelp = (*env)->GetStaticMethodID(env, cls,
                                         "initHelpMessage", "(Ljava/lang/String;)V"));
@@ -1570,7 +1547,7 @@
     }
 
     /* Complete the usage message and print to stderr*/
-    (*env)->CallStaticVoidMethod(env, cls, printHelp, JNI_TRUE);
+    (*env)->CallStaticVoidMethod(env, cls, printHelp, USE_STDERR);
   }
   return;
 }
--- a/src/share/classes/sun/launcher/LauncherHelper.java	Sat Mar 19 14:21:52 2011 +0000
+++ b/src/share/classes/sun/launcher/LauncherHelper.java	Sun Mar 20 19:39:11 2011 +0000
@@ -42,10 +42,12 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.nio.charset.Charset;
 import java.util.ResourceBundle;
 import java.text.MessageFormat;
 import java.util.ArrayList;
@@ -471,11 +473,11 @@
         } catch (ClassNotFoundException cnfe) {
             abort(ostream, cnfe, "java.launcher.cls.error1", cn);
         }
-        signatureDiagnostic(ostream, c);
+        getMainMethod(ostream, c);
         return c;
     }
 
-    static void signatureDiagnostic(PrintStream ostream, Class<?> clazz) {
+    static Method getMainMethod(PrintStream ostream, Class<?> clazz) {
         String classname = clazz.getName();
         Method method = null;
         try {
@@ -495,6 +497,31 @@
         if (method.getReturnType() != java.lang.Void.TYPE) {
             abort(ostream, null, "java.launcher.cls.error3", classname);
         }
-        return;
+        return method;
+    }
+
+    private static final String encprop = "sun.jnu.encoding";
+    private static String encoding = null;
+    private static boolean isCharsetSupported = false;
+
+    /*
+     * converts a c or a byte array to a platform specific string,
+     * previously implemented as a native method in the launcher.
+     */
+    static String makePlatformString(boolean printToStderr, byte[] inArray) {
+        final PrintStream ostream = (printToStderr) ? System.err : System.out;
+        if (encoding == null) {
+            encoding = System.getProperty(encprop);
+            isCharsetSupported = Charset.isSupported(encoding);
+        }
+        try {
+            String out = isCharsetSupported
+                    ? new String(inArray, encoding)
+                    : new String(inArray);
+            return out;
+        } catch (UnsupportedEncodingException uee) {
+            abort(ostream, uee, null);
+        }
+        return null; // keep the compiler happy
     }
 }