Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4652863

Starting the classic VM on Windows XP with russian language crashes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.3.0_02
    • core-libs

      Name: pa48320 Date: 03/14/2002

      We embed the VM in a C++ program. If we load using the classic\jvm.dll and load sun.awt.windows.WToolkit.class, the VM crashes with the message:
      FATAL ERROR in native method: Leaving arrays locked on native method return
      at java.lang.Class.newInstance0(Native Method)
      at java.lang.Class.newInstance(Class.java:237)
      at sun.io.Converters.newConverter(Converters.java:120)
      at sun.io.Converters.newDefaultConverter(Converters.java:215)
      at sun.io.ByteToCharConverter.getDefault(ByteToCharConverter.java:55)
      at java.lang.String.<init>(String.java:460)
      at sun.awt.font.NativeFontWrapper.registerFonts(Native Method)
      at sun.java2d.SunGraphicsEnvironment.registerFontFile(SunGraphicsEnvironment.java:492)
      at sun.java2d.SunGraphicsEnvironment.initTerminalNames(SunGraphicsEnvironment.java:761)
      at sun.java2d.SunGraphicsEnvironment.initCompositeFonts(SunGraphicsEnvironment.java:623)
      at sun.java2d.SunGraphicsEnvironment$1.run(SunGraphicsEnvironment.java:95)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.java2d.SunGraphicsEnvironment.<init>(SunGraphicsEnvironment.java:75)
      at sun.awt.Win32GraphicsEnvironment.<init>(Win32GraphicsEnvironment.java:38)
      at java.lang.Class.newInstance0(Native Method)
      at java.lang.Class.newInstance(Class.java:237)
      at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:58)
      at sun.awt.windows.WToolkit.resetGC(WToolkit.java:87)
      at sun.awt.windows.WToolkit.<clinit>(WToolkit.java:77)

      This does not happen if we load the hotspot VM.

      The following MFC code shows the problem: call it with -loc <1.3.1 location> -classic
      // testFontVM.cpp : Defines the entry point for the console application.
      //

      #include "stdafx.h"
      #include "jni.h"

      void JNICALL ExitVM( jint code )
      {
      //if (fileHandle != INVALID_HANDLE_VALUE)
      // CloseHandle(fileHandle);

      // if (pLogFile) delete pLogFile;

      //fileHandle = NULL;
      //pLogFile = NULL;

      _exit(code);
      }

      void JNICALL AbortVM()
      {
      // if (fileHandle != INVALID_HANDLE_VALUE)
      // CloseHandle(fileHandle);

      // if (pLogFile) delete pLogFile;

      // fileHandle = NULL;
      // pLogFile = NULL;

      _exit(0);
      }

      jint JNICALL PrintVM( FILE* fp, const char* format, va_list args)
      {
      // char buf[1024];
      // int i = vsprintf(buf, format, args);
      // CString error = buf;
      // fprintf(stderr, buf);
      // if ((i > 1) && (buf[0] == ' ') && (buf[1] == NULL))
      // {
      // TRACE1("%s\n", buf);
      // }
      // else
      // {
      // TRACE1("%s", buf);
      // }
      // return i;
      return 0;
      }

      int main(int argc, char* argv[])
      {
      // get JRE location
      CString jreLocation = "c:\\jdk1.3.1_01\\jre\\bin";
      CString jreType = "hotspot";
      JavaVMInitArgs VMArgs;
      JavaVMOption* properties = NULL;
      CStringArray options;
      BOOL locSet = false;

      VMArgs.version = JNI_VERSION_1_2;
      VMArgs.nOptions = 0;
      VMArgs.options = NULL;

      if (argc > 0)
      {
      int i;
      for(i=0;i<argc;++i)
      {
      CString arg = argv[i];
      if (arg.Compare("-loc") == 0)
      {
      locSet = true;
      jreLocation = argv[++i];
      }
      else if (arg.Compare("-classic") == 0)
      jreType = "classic";
      else if ((arg[0] == '-') && (arg[1] == 'D'))
      options.Add(arg);
      else if ((arg[0] == '-') && (arg[1] == 'X'))
      options.Add(arg);
      }
      }

      if (!locSet)
      {
      HKEY key;
      DWORD dwType;
      BOOL goodValue = FALSE;
      if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Javasoft\\Java Runtime Environment\\1.3",
      0, KEY_READ, &key) == ERROR_SUCCESS)
      {
      ULONG len;
      LONG lResult = RegQueryValueEx(key, "RuntimeLib", NULL, &dwType, NULL, &len);
      if (lResult == ERROR_SUCCESS)
      {
      lResult = RegQueryValueEx(key, "RuntimeLib", NULL, &dwType,
      (LPBYTE)jreLocation.GetBuffer(len/sizeof(TCHAR)), &len);
      jreLocation.ReleaseBuffer();
      goodValue = TRUE;
      }
      RegCloseKey(key);
      }
      }
      else
      {
      jreLocation +="\\"+jreType+"\\jvm.dll";
      }


      properties = new JavaVMOption[options.GetSize()+3];
      VMArgs.nOptions = options.GetSize()+3;
      VMArgs.options = properties;
      int i;
      for(i=0;i<options.GetSize();++i)
      {
      CString arg = options.GetAt(i);
      properties[i].optionString = new TCHAR[arg.GetLength()+1];
      strcpy(properties[i].optionString, arg.GetBuffer(1));
      //properties[i].optionString = args.GetAt(i).GetBuffer(1);
      }
      properties[i].optionString = "vfprintf";
      properties[i].extraInfo = PrintVM;
      ++i;
      properties[i].optionString = "exit";
      properties[i].extraInfo = ExitVM;
      ++i;
      properties[i].optionString = "abort";
      properties[i].extraInfo = AbortVM;

      JNIEnv* ee;
      JavaVM* vm;
      // load jvm.dll
      HINSTANCE javai = NULL;
      javai = LoadLibraryEx(jreLocation, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);


      // CreateJavaVM
      typedef jint (JNICALL *cjVM)(JavaVM**, JNIEnv **, void *);
      cjVM JNI_cjVM = (cjVM)GetProcAddress(javai, "JNI_CreateJavaVM");
      jint retCode = (*JNI_cjVM)(&vm, &ee, (void*)&VMArgs);

      /******************************************************************************************
      * put test code here
      ******************************************************************************************/
      jclass jClass = ee->FindClass("sun/awt/windows/WToolkit");


      /*
           * Detach the current thread so that it appears to have exited when
           * the application's main method exits.
           */
          if ((vm)->DetachCurrentThread() != 0)
      {
      fprintf(stderr, "Could not detach main thread.\n");
          }
          (vm)->DestroyJavaVM();

      if (properties)
      {
      for(i=0;i<options.GetSize();++i)
      {
      delete properties[i].optionString;
      }
      delete properties;
      }
      return 0;
      }

      ======================================================================</TEXTAREA>
      </td>
                          </tr>
                          <TR>
                            <TD colspan="2" bgcolor="#BFBFBF"> </td>
                          </tr>

      <a name="comments"></a>
                          <!-- COMMENTS -->
                          <TR>
                            <TD bgcolor="#BFBFBF" align="left" valign="bottom" height="24">
      <img src="/bugz/images/dot.gif" width="10">Comments
      </td>
                            <TD bgcolor="#BFBFBF" align="left" valign="bottom" height="24">
      <!-- BEGIN:TBR Mohan
        <A href="javascript:doDateStampSubmit(document.editbug_general, 'comments');"><font size="-1">[ Date Stamp ]</font></A>
      <img src="/bugz/images/dot.gif" width="18">
      END:TBR -->
      <A href="javascript:doFullPageSubmit(document.editbug_general, 'comments');"><font size="-1">[ Full Page ]</font></a>
      <img src="/bugz/images/dot.gif" width="22">
      <FONT size="-1" color="darkblue">--- Enter SUN Proprietary data here ---</font>
      </td>
                          </tr>

                          <TR>
                            <TD bgcolor="#BFBFBF" colspan="2" nowrap align="left">
      <img src="/bugz/images/dot.gif" width="5">
                              <TEXTAREA rows="6" cols="95" wrap="virtual" name="comments" align="left" bgcolor="white">

      Name: pa48320 Date: 03/14/2002

      (company - SAS Institute , email - ###@###.###)

      ======================================================================
      ###@###.### 2004-01-15

            ilittlesunw Ian Little (Inactive)
            pallenba Peter Allenbach (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: