mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8174823: Module system implementation refresh (3/2017)
Reviewed-by: sspitsyn, dholmes, lfoltan, mchung
This commit is contained in:
parent
a085f48913
commit
73165d34e4
8 changed files with 49 additions and 25 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2017, 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
|
||||
|
@ -36,8 +36,8 @@
|
|||
#include "utilities/ostream.hpp"
|
||||
|
||||
#define UNNAMED_MODULE "Unnamed Module"
|
||||
#define JAVAPKG "java/"
|
||||
#define JAVAPKG_LEN 5
|
||||
#define JAVAPKG "java"
|
||||
#define JAVAPKG_LEN 4
|
||||
#define JAVA_BASE_NAME "java.base"
|
||||
|
||||
class ModuleClosure;
|
||||
|
|
|
@ -325,7 +325,8 @@ void Modules::define_module(jobject module, jstring version,
|
|||
// Only modules defined to either the boot or platform class loader, can define a "java/" package.
|
||||
if (!h_loader.is_null() &&
|
||||
!SystemDictionary::is_platform_class_loader(h_loader) &&
|
||||
strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0) {
|
||||
(strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0 &&
|
||||
(package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) {
|
||||
const char* class_loader_name = SystemDictionary::loader_name(h_loader());
|
||||
size_t pkg_len = strlen(package_name);
|
||||
char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len);
|
||||
|
@ -748,7 +749,8 @@ void Modules::add_module_package(jobject module, const char* package_name, TRAPS
|
|||
// Only modules defined to either the boot or platform class loader, can define a "java/" package.
|
||||
if (!loader_data->is_the_null_class_loader_data() &&
|
||||
!loader_data->is_platform_class_loader_data() &&
|
||||
strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0) {
|
||||
(strncmp(package_name, JAVAPKG, JAVAPKG_LEN) == 0 &&
|
||||
(package_name[JAVAPKG_LEN] == '/' || package_name[JAVAPKG_LEN] == '\0'))) {
|
||||
const char* class_loader_name = SystemDictionary::loader_name(loader_data);
|
||||
size_t pkg_len = strlen(package_name);
|
||||
char* pkg_name = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, pkg_len);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2017, 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
|
||||
|
@ -561,6 +561,7 @@
|
|||
template(int_StringBuffer_signature, "(I)Ljava/lang/StringBuffer;") \
|
||||
template(char_StringBuffer_signature, "(C)Ljava/lang/StringBuffer;") \
|
||||
template(int_String_signature, "(I)Ljava/lang/String;") \
|
||||
template(boolean_boolean_int_signature, "(ZZ)I") \
|
||||
template(codesource_permissioncollection_signature, "(Ljava/security/CodeSource;Ljava/security/PermissionCollection;)V") \
|
||||
/* signature symbols needed by intrinsics */ \
|
||||
VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, template, VM_ALIAS_IGNORE) \
|
||||
|
|
|
@ -2456,14 +2456,15 @@ Klass* InstanceKlass::compute_enclosing_class_impl(instanceKlassHandle self,
|
|||
void InstanceKlass::check_prohibited_package(Symbol* class_name,
|
||||
Handle class_loader,
|
||||
TRAPS) {
|
||||
ResourceMark rm(THREAD);
|
||||
if (!class_loader.is_null() &&
|
||||
!SystemDictionary::is_platform_class_loader(class_loader) &&
|
||||
class_name != NULL &&
|
||||
strncmp(class_name->as_C_string(), JAVAPKG, JAVAPKG_LEN) == 0) {
|
||||
class_name != NULL) {
|
||||
ResourceMark rm(THREAD);
|
||||
char* name = class_name->as_C_string();
|
||||
if (strncmp(name, JAVAPKG, JAVAPKG_LEN) == 0 && name[JAVAPKG_LEN] == '/') {
|
||||
TempNewSymbol pkg_name = InstanceKlass::package_from_name(class_name, CHECK);
|
||||
assert(pkg_name != NULL, "Error in parsing package name starting with 'java/'");
|
||||
char* name = pkg_name->as_C_string();
|
||||
name = pkg_name->as_C_string();
|
||||
const char* class_loader_name = SystemDictionary::loader_name(class_loader());
|
||||
StringUtils::replace_no_expand(name, "/", ".");
|
||||
const char* msg_text1 = "Class loader (instance of): ";
|
||||
|
@ -2473,6 +2474,7 @@ void InstanceKlass::check_prohibited_package(Symbol* class_name,
|
|||
jio_snprintf(message, len, "%s%s%s%s", msg_text1, class_loader_name, msg_text2, name);
|
||||
THROW_MSG(vmSymbols::java_lang_SecurityException(), message);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2932,6 +2932,10 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
|||
if (res != JNI_OK) {
|
||||
return res;
|
||||
}
|
||||
} else if (match_option(option, "--permit-illegal-access")) {
|
||||
if (!create_property("jdk.module.permitIllegalAccess", "true", ExternalProperty)) {
|
||||
return JNI_ENOMEM;
|
||||
}
|
||||
// -agentlib and -agentpath
|
||||
} else if (match_option(option, "-agentlib:", &tail) ||
|
||||
(is_absolute_path = match_option(option, "-agentpath:", &tail))) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2017, 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
|
||||
|
@ -621,6 +621,13 @@ void vm_notify_during_shutdown(const char* error, const char* message) {
|
|||
}
|
||||
}
|
||||
|
||||
void vm_exit_during_initialization() {
|
||||
vm_notify_during_shutdown(NULL, NULL);
|
||||
|
||||
// Failure during initialization, we don't want to dump core
|
||||
vm_abort(false);
|
||||
}
|
||||
|
||||
void vm_exit_during_initialization(Handle exception) {
|
||||
tty->print_cr("Error occurred during initialization of VM");
|
||||
// If there are exceptions on this thread it must be cleared
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2017, 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
|
||||
|
@ -45,6 +45,7 @@ extern void vm_abort(bool dump_core=true);
|
|||
extern void notify_vm_shutdown();
|
||||
|
||||
// VM exit if error occurs during initialization of VM
|
||||
extern void vm_exit_during_initialization();
|
||||
extern void vm_exit_during_initialization(Handle exception);
|
||||
extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);
|
||||
extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2017, 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
|
||||
|
@ -3409,9 +3409,16 @@ static void call_initPhase2(TRAPS) {
|
|||
Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
|
||||
instanceKlassHandle klass (THREAD, k);
|
||||
|
||||
JavaValue result(T_VOID);
|
||||
JavaValue result(T_INT);
|
||||
JavaCallArguments args;
|
||||
args.push_int(DisplayVMOutputToStderr);
|
||||
args.push_int(log_is_enabled(Debug, init)); // print stack trace if exception thrown
|
||||
JavaCalls::call_static(&result, klass, vmSymbols::initPhase2_name(),
|
||||
vmSymbols::void_method_signature(), CHECK);
|
||||
vmSymbols::boolean_boolean_int_signature(), &args, CHECK);
|
||||
if (result.get_jint() != JNI_OK) {
|
||||
vm_exit_during_initialization(); // no message or exception
|
||||
}
|
||||
|
||||
universe_post_module_init();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue