mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8230043: Lazily load libverify
8230140: Remove unused mutex and monitor declarations Reviewed-by: hseigel, erikj, alanb, dholmes
This commit is contained in:
parent
204ed44122
commit
fba19ffbb2
12 changed files with 74 additions and 152 deletions
|
@ -35,12 +35,9 @@
|
|||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "jvm.h"
|
||||
#include "check_classname.h"
|
||||
#include "java_lang_Class.h"
|
||||
|
||||
/* defined in libverify.so/verify.dll (src file common/check_format.c) */
|
||||
extern jboolean VerifyClassname(char *utf_name, jboolean arrayAllowed);
|
||||
extern jboolean VerifyFixClassname(char *utf_name);
|
||||
|
||||
#define OBJ "Ljava/lang/Object;"
|
||||
#define CLS "Ljava/lang/Class;"
|
||||
#define CPL "Ljdk/internal/reflect/ConstantPool;"
|
||||
|
@ -123,14 +120,14 @@ Java_java_lang_Class_forName0(JNIEnv *env, jclass this, jstring classname,
|
|||
}
|
||||
(*env)->GetStringUTFRegion(env, classname, 0, unicode_len, clname);
|
||||
|
||||
if (VerifyFixClassname(clname) == JNI_TRUE) {
|
||||
if (verifyFixClassname(clname) == JNI_TRUE) {
|
||||
/* slashes present in clname, use name b4 translation for exception */
|
||||
(*env)->GetStringUTFRegion(env, classname, 0, unicode_len, clname);
|
||||
JNU_ThrowClassNotFoundException(env, clname);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!VerifyClassname(clname, JNI_TRUE)) { /* expects slashed name */
|
||||
if (!verifyClassname(clname, JNI_TRUE)) { /* expects slashed name */
|
||||
JNU_ThrowClassNotFoundException(env, clname);
|
||||
goto done;
|
||||
}
|
||||
|
|
|
@ -30,14 +30,11 @@
|
|||
#include "jni_util.h"
|
||||
#include "jlong.h"
|
||||
#include "jvm.h"
|
||||
#include "check_classname.h"
|
||||
#include "java_lang_ClassLoader.h"
|
||||
#include "java_lang_ClassLoader_NativeLibrary.h"
|
||||
#include <string.h>
|
||||
|
||||
/* defined in libverify.so/verify.dll (src file common/check_format.c) */
|
||||
extern jboolean VerifyClassname(char *utf_name, jboolean arrayAllowed);
|
||||
extern jboolean VerifyFixClassname(char *utf_name);
|
||||
|
||||
static JNINativeMethod methods[] = {
|
||||
{"retrieveDirectives", "()Ljava/lang/AssertionStatusDirectives;", (void *)&JVM_AssertionStatusDirectives}
|
||||
};
|
||||
|
@ -120,7 +117,7 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env,
|
|||
if (utfName == NULL) {
|
||||
goto free_body;
|
||||
}
|
||||
VerifyFixClassname(utfName);
|
||||
fixClassname(utfName);
|
||||
} else {
|
||||
utfName = NULL;
|
||||
}
|
||||
|
@ -185,7 +182,7 @@ Java_java_lang_ClassLoader_defineClass2(JNIEnv *env,
|
|||
JNU_ThrowOutOfMemoryError(env, NULL);
|
||||
return result;
|
||||
}
|
||||
VerifyFixClassname(utfName);
|
||||
fixClassname(utfName);
|
||||
} else {
|
||||
utfName = NULL;
|
||||
}
|
||||
|
@ -231,9 +228,9 @@ Java_java_lang_ClassLoader_findBootstrapClass(JNIEnv *env, jobject loader,
|
|||
JNU_ThrowOutOfMemoryError(env, NULL);
|
||||
return NULL;
|
||||
}
|
||||
VerifyFixClassname(clname);
|
||||
fixClassname(clname);
|
||||
|
||||
if (!VerifyClassname(clname, JNI_TRUE)) { /* expects slashed name */
|
||||
if (!verifyClassname(clname, JNI_TRUE)) { /* expects slashed name */
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "jni.h"
|
||||
#include "jvm.h"
|
||||
#include "check_classname.h"
|
||||
|
||||
typedef unsigned short unicode;
|
||||
|
||||
|
@ -223,16 +224,13 @@ skip_over_field_signature(char *name, jboolean void_okay,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Used in java/lang/Class.c */
|
||||
/* Determine if the specified name is legal
|
||||
* UTF name for a classname.
|
||||
*
|
||||
* Note that this routine expects the internal form of qualified classes:
|
||||
* the dots should have been replaced by slashes.
|
||||
*/
|
||||
JNIEXPORT jboolean
|
||||
VerifyClassname(char *name, jboolean allowArrayClass)
|
||||
jboolean verifyClassname(char *name, jboolean allowArrayClass)
|
||||
{
|
||||
size_t s = strlen(name);
|
||||
assert(s <= UINT_MAX);
|
||||
|
@ -254,10 +252,9 @@ VerifyClassname(char *name, jboolean allowArrayClass)
|
|||
}
|
||||
|
||||
/*
|
||||
* Translates '.' to '/'. Returns JNI_TRUE is any / were present.
|
||||
* Translates '.' to '/'. Returns JNI_TRUE if any / were present.
|
||||
*/
|
||||
JNIEXPORT jboolean
|
||||
VerifyFixClassname(char *name)
|
||||
jboolean verifyFixClassname(char *name)
|
||||
{
|
||||
char *p = name;
|
||||
jboolean slashesFound = JNI_FALSE;
|
||||
|
@ -276,3 +273,20 @@ VerifyFixClassname(char *name)
|
|||
|
||||
return slashesFound && valid != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Translates '.' to '/'.
|
||||
*/
|
||||
void fixClassname(char *name)
|
||||
{
|
||||
char *p = name;
|
||||
int valid = 1;
|
||||
|
||||
while (valid != 0 && *p != '\0') {
|
||||
if (*p == '.') {
|
||||
*p++ = '/';
|
||||
} else {
|
||||
next_utf2unicode(&p, &valid);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -23,37 +23,12 @@
|
|||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* The real verifier now lives in libverifier.so/verifier.dll.
|
||||
*
|
||||
* This dummy exists so that HotSpot will run with the new
|
||||
* libjava.so/java.dll which is where is it accustomed to finding the
|
||||
* verifier.
|
||||
*/
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
struct struct_class_size_info;
|
||||
typedef struct struct_class_size_info class_size_info;
|
||||
/*
|
||||
* Class name checking methods
|
||||
*/
|
||||
|
||||
|
||||
JNIIMPORT jboolean
|
||||
VerifyClass(JNIEnv *env, jclass cb, char *buffer, jint len);
|
||||
|
||||
JNIIMPORT jboolean
|
||||
VerifyClassForMajorVersion(JNIEnv *env, jclass cb, char *buffer, jint len,
|
||||
jint major_version);
|
||||
|
||||
JNIEXPORT jboolean
|
||||
VerifyClassCodes(JNIEnv *env, jclass cb, char *buffer, jint len)
|
||||
{
|
||||
return VerifyClass(env, cb, buffer, len);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean
|
||||
VerifyClassCodesForMajorVersion(JNIEnv *env, jclass cb, char *buffer,
|
||||
jint len, jint major_version)
|
||||
{
|
||||
return VerifyClassForMajorVersion(env, cb, buffer, len, major_version);
|
||||
}
|
||||
jboolean verifyClassname(char *name, jboolean allowArrayClass);
|
||||
jboolean verifyFixClassname(char *name);
|
||||
void fixClassname(char *name);
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -30,9 +30,6 @@
|
|||
/*
|
||||
Exported function:
|
||||
|
||||
jboolean
|
||||
VerifyClass(JNIEnv *env, jclass cb, char *message_buffer,
|
||||
jint buffer_length)
|
||||
jboolean
|
||||
VerifyClassForMajorVersion(JNIEnv *env, jclass cb, char *message_buffer,
|
||||
jint buffer_length, jint major_version)
|
||||
|
@ -910,20 +907,6 @@ VerifyClassForMajorVersion(JNIEnv *env, jclass cb, char *buffer, jint len,
|
|||
return result;
|
||||
}
|
||||
|
||||
#define OLD_FORMAT_MAX_MAJOR_VERSION 48
|
||||
|
||||
JNIEXPORT jboolean
|
||||
VerifyClass(JNIEnv *env, jclass cb, char *buffer, jint len)
|
||||
{
|
||||
static int warned = 0;
|
||||
if (!warned) {
|
||||
jio_fprintf(stdout, "Warning! An old version of jvm is used. This is not supported.\n");
|
||||
warned = 1;
|
||||
}
|
||||
return VerifyClassForMajorVersion(env, cb, buffer, len,
|
||||
OLD_FORMAT_MAX_MAJOR_VERSION);
|
||||
}
|
||||
|
||||
static void
|
||||
verify_field(context_type *context, jclass cb, int field_index)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue