Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message on duplicate class definition #11276

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runtime/j9vm/j7vmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2597,7 +2597,7 @@ jvmDefineClassHelper(JNIEnv *env, jobject classLoaderObject,
if (vmFuncs->hashClassTableAt(classLoader, utf8Name, utf8Length) != NULL) {
/* Bad, we have already defined this class - fail */
threadEnv->monitor_exit(vm->classTableMutex);
vmFuncs->setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGLINKAGEERROR, (UDATA *)*(j9object_t*)className);
vmFuncs->setCurrentExceptionNLSWithArgs(currentThread, J9NLS_JCL_DUPLICATE_CLASS_DEFINITION, J9VMCONSTANTPOOL_JAVALANGLINKAGEERROR, utf8Length, utf8Name);
goto done;
}

Expand Down
5 changes: 2 additions & 3 deletions runtime/jcl/common/jcldefine.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include "j9consts.h"
#include "jclprots.h"
#include "j9protos.h"


#include "j9jclnls.h"

jclass
defineClassCommon(JNIEnv *env, jobject classLoaderObject,
Expand Down Expand Up @@ -144,7 +143,7 @@ defineClassCommon(JNIEnv *env, jobject classLoaderObject,
/* Bad, we have already defined this class - fail */
omrthread_monitor_exit(vm->classTableMutex);
if (J9_ARE_NO_BITS_SET(*options, J9_FINDCLASS_FLAG_NAME_IS_INVALID)) {
vmFuncs->setCurrentException(currentThread, J9VMCONSTANTPOOL_JAVALANGLINKAGEERROR, (UDATA *)*(j9object_t*)className);
vmFuncs->setCurrentExceptionNLSWithArgs(currentThread, J9NLS_JCL_DUPLICATE_CLASS_DEFINITION, J9VMCONSTANTPOOL_JAVALANGLINKAGEERROR, utf8Length, utf8Name);
}
goto done;
}
Expand Down
8 changes: 8 additions & 0 deletions runtime/nls/j9cl/j9jcl.nls
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,11 @@ J9NLS_JCL_NEST_MEMBER_CLAIMS_DIFFERENT_NEST_HOST.system_action=The JVM will thro
J9NLS_JCL_NEST_MEMBER_CLAIMS_DIFFERENT_NEST_HOST.user_response=Contact the provider of the classfile for a corrected version.
# END NON-TRANSLATABLE

J9NLS_JCL_DUPLICATE_CLASS_DEFINITION=A duplicate class definition for %2$.*1$s is found
# START NON-TRANSLATABLE
J9NLS_JCL_DUPLICATE_CLASS_DEFINITION.sample_input_1=3
J9NLS_JCL_DUPLICATE_CLASS_DEFINITION.sample_input_2=Foo
J9NLS_JCL_DUPLICATE_CLASS_DEFINITION.explanation=A duplicated class definition is found.
J9NLS_JCL_DUPLICATE_CLASS_DEFINITION.system_action=The JVM will throw a LinkageError.
J9NLS_JCL_DUPLICATE_CLASS_DEFINITION.user_response=Ensure there is no duplicate definition for the class in the message and try again.
# END NON-TRANSLATABLE
2 changes: 1 addition & 1 deletion runtime/vm/exceptionsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ setCurrentExceptionNLSWithArgs(J9VMThread * vmThread, U_32 nlsModule, U_32 nlsID
nlsMsgFormat = omrnls_lookup_message(J9NLS_DO_NOT_PRINT_MESSAGE_TAG | J9NLS_DO_NOT_APPEND_NEWLINE,
nlsModule,
nlsID,
"");
NULL);
DanHeidinga marked this conversation as resolved.
Show resolved Hide resolved

va_start(stringArgList, exceptionIndex);
msgCharLength = j9str_vprintf(NULL, 0, nlsMsgFormat, stringArgList);
Expand Down