Microsoft KB Archive/293804

= BUG: Access Violation When You Call com.ms.util.EventLog on Japanese Windows NT-Based Computer =

Article ID: 293804

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Java Virtual Machine

-



This article was previously published under Q293804



SYMPTOMS
When you call com.ms.util.EventLog on a Japanese Microsoft Windows NT-based computer, an access violation may occur.



RESOLUTION
Instead of using com.ms.util.EventLog, use J/Direct to call the EventLog function directly. For example: import com.ms.win32.*;

public class test2 {   public boolean writeToEventLog {       int handle = 0; boolean bRes = false; handle = RegisterEventSource (null, &quot;JDirect Event Log Sample&quot;);

if (handle == 0) {           System.out.println (&quot;Could not register the event source.&quot;); }       else {           short i, j;            i = 0; j = 0;

String str [] = new String[1]; str[0] = &quot;\u30de\u30a4\u30af\u30ed\u30bd\u30d5\u30c8\u306e\u958b\u767a\u8005\u30b5\u30dd\u30fc\u30c8&quot;;

bRes = ReportEvent (handle, i, j, 0, 0, (short)1, 0, str, 0); if (!bRes) {               System.out.print(&quot;ReportEvent returned error code of: &quot;); System.out.println(com.ms.dll.DllLib.getLastWin32Error); }       }

bRes = DeregisterEventSource(handle); return bRes; }

public static void main (String args[]) {       test2 t = new test2; boolean bRes = t.writeToEventLog; System.out.println (bRes?&quot;PASS&quot;:&quot;FAIL&quot;); }

/** @dll.import(&quot;Advapi32&quot;, auto, setLastError) */ public native static int RegisterEventSource(String lnUNCServerName,                                                          String lpSourceName); /** @dll.import(&quot;Advapi32&quot;, auto, setLastError) */ public native static boolean DeregisterEventSource(int hEventLog);

/** @dll.import(&quot;Advapi32&quot;, auto, setLastError) */ public native static boolean ReportEvent(int hEventLog,                                            short wType,                                             short wCategory,                                             int dwEventID,                                             int lpUserSid,                                             short wNumStrings,                                             int dwDataSize,                                             String [] lpStrings,                                             int lpRawData);

}



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
To reproduce this behavior, compile and run the following code on a Japanese Windows NT 4.0 Server: class test {

public static void main(String args[]) {

com.ms.util.EventLog eventLog = new com.ms.util.EventLog(&quot;J/Direct Event Log Sample&quot;); String str = &quot;\u30de\u30a4\u30af\u30ed\u30bd\u30d5\u30c8\u306e\u958b\u767a\u8005\u30b5\u30dd\u30fc\u30c8&quot;; short i, j;   i = 0; j = 0; eventLog.reportEvent(i, j, 0, str); }

