JDK-4642283 : Cannot load classes which have Japanese (SJIS) encoded class names
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 1.3.0,1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_2000
  • CPU: generic,x86
  • Submitted: 2002-02-23
  • Updated: 2003-10-21
  • Resolved: 2003-10-21
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
If a class has a Japanese (SJIS encoding) class name, it cannot be loaded by the loader.  Here is how to reproduce:

1. On Windows 2000, open "Regional Option" in the Control Panel
2. Select "Japanese" in "Your locale(location)" pull down.
3. Unzip the attached archive into some directory.
4. Run the batch file, with a path to the JDK directory, e.g.,
    "nihongo x:\jdk1.4\win"
5. It fails to load the Japanese class with the following error message:

Exception in thread "main" java.lang.NoClassDefFoundError: ??????

I attached a screen shot (nihongo.jpg) for your convenience.

###@###.### 2002-02-22

Comments
SUGGESTED FIX Suggested fix would be converting <char* classname> to utf8 in <src/share/bin/java.c>, see below. --- java.c Fri Oct 4 17:34:42 2002 *** 1,7 **** /* ! * @(#)java.c 1.99 02/07/26 * * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ --- 1,7 ---- /* ! * @(#)java.c 1.100 02/10/04 * * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ *** 112,121 **** --- 112,122 ---- JavaVM *vm = 0; JNIEnv *env = 0; char *jarfile = 0; char *classname = 0; char *s = 0; + jstring mainClassName; jclass mainClass; jmethodID mainID; jobjectArray mainArgs; int ret; InvocationFunctions ifn; *** 281,291 **** /* Temporary fix for utf-16le encoding. Init encoding flag */ InitEncodingFlag(env); /* Get the application's main class */ if (jarfile != 0) { ! jstring mainClassName = GetMainClassName(env, jarfile); if ((*env)->ExceptionOccurred(env)) { (*env)->ExceptionDescribe(env); goto leave; } if (mainClassName == NULL) { --- 282,292 ---- /* Temporary fix for utf-16le encoding. Init encoding flag */ InitEncodingFlag(env); /* Get the application's main class */ if (jarfile != 0) { ! mainClassName = GetMainClassName(env, jarfile); if ((*env)->ExceptionOccurred(env)) { (*env)->ExceptionDescribe(env); goto leave; } if (mainClassName == NULL) { *** 299,309 **** --- 300,321 ---- goto leave; } mainClass = LoadClass(env, classname); (*env)->ReleaseStringUTFChars(env, mainClassName, classname); } else { + mainClassName = NewPlatformString(env, classname); + if (mainClassName == NULL) { + fprintf(stderr, "Failed to load Main Class: %s\n", classname); + goto leave; + } + classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0); + if (classname == NULL) { + (*env)->ExceptionDescribe(env); + goto leave; + } mainClass = LoadClass(env, classname); + (*env)->ReleaseStringUTFChars(env, mainClassName, classname); } if (mainClass == NULL) { (*env)->ExceptionDescribe(env); status = 4; goto leave;
11-06-2004

EVALUATION The problem is in java.exe ###@###.### 2002-05-23 The problem is indeed in <java> launcher. We do not convert <char* classname> we receive from the command line to utf8 format. Error java.lang.NoClassDefFoundError is produced by the vm as a result of trying to compare the name of the main class received from the command line with the one it gets from .class file. ###@###.### 2002-10-08 Closing as dup of 4761384. ###@###.### 2003-10-21
08-10-2002