Mercurial > hg > truffle
comparison src/share/vm/prims/jni.cpp @ 6125:dcfcdd01af4b
7171703: JNI DefineClass crashes client VM when first parameter is NULL
Reviewed-by: acorn, kamg, sspitsyn, dholmes
author | fparain |
---|---|
date | Tue, 05 Jun 2012 06:48:00 -0700 |
parents | 94ec88ca68e2 |
children | e9140bf80b4a |
comparison
equal
deleted
inserted
replaced
6118:e17b61ba7bb3 | 6125:dcfcdd01af4b |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
376 env, (char*) name, loaderRef, (char*) buf, bufLen); | 376 env, (char*) name, loaderRef, (char*) buf, bufLen); |
377 #endif /* USDT2 */ | 377 #endif /* USDT2 */ |
378 jclass cls = NULL; | 378 jclass cls = NULL; |
379 DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); | 379 DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); |
380 | 380 |
381 TempNewSymbol class_name = NULL; | |
381 // Since exceptions can be thrown, class initialization can take place | 382 // Since exceptions can be thrown, class initialization can take place |
382 // if name is NULL no check for class name in .class stream has to be made. | 383 // if name is NULL no check for class name in .class stream has to be made. |
383 if (name != NULL) { | 384 if (name != NULL) { |
384 const int str_len = (int)strlen(name); | 385 const int str_len = (int)strlen(name); |
385 if (str_len > Symbol::max_length()) { | 386 if (str_len > Symbol::max_length()) { |
386 // It's impossible to create this class; the name cannot fit | 387 // It's impossible to create this class; the name cannot fit |
387 // into the constant pool. | 388 // into the constant pool. |
388 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); | 389 THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name); |
389 } | 390 } |
390 } | 391 class_name = SymbolTable::new_symbol(name, CHECK_NULL); |
391 TempNewSymbol class_name = SymbolTable::new_symbol(name, THREAD); | 392 } |
392 | |
393 ResourceMark rm(THREAD); | 393 ResourceMark rm(THREAD); |
394 ClassFileStream st((u1*) buf, bufLen, NULL); | 394 ClassFileStream st((u1*) buf, bufLen, NULL); |
395 Handle class_loader (THREAD, JNIHandles::resolve(loaderRef)); | 395 Handle class_loader (THREAD, JNIHandles::resolve(loaderRef)); |
396 | 396 |
397 if (UsePerfData && !class_loader.is_null()) { | 397 if (UsePerfData && !class_loader.is_null()) { |