Merge
This commit is contained in:
commit
de2123c419
@ -385,3 +385,4 @@ d7f519b004254b19e384131d9f0d0e40e31a0fd3 jdk-9+137
|
||||
a5815c6098a241d3a1df64d22b84b3524e4a77df jdk-9+140
|
||||
f64afae7f1a5608e438585bbf0bc23785e69cba0 jdk-9+141
|
||||
2b3e5caafe3594ea507c37675c4d3086f415dc64 jdk-9+142
|
||||
1fc62b1c629fb80fdaa639d3b59452a184f0d705 jdk-9+143
|
||||
|
@ -280,7 +280,7 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
|
||||
else
|
||||
# Default works for linux, might work on other platforms as well.
|
||||
SHARED_LIBRARY_FLAGS='-shared'
|
||||
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
|
||||
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
|
||||
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
|
||||
SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
|
||||
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
|
||||
@ -305,7 +305,7 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
|
||||
# Default works for linux, might work on other platforms as well.
|
||||
PICFLAG='-fPIC'
|
||||
SHARED_LIBRARY_FLAGS='-shared'
|
||||
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN[$]1'
|
||||
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN[$]1'
|
||||
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
|
||||
SET_SHARED_LIBRARY_NAME='-Wl,-soname=[$]1'
|
||||
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
|
||||
@ -315,7 +315,7 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
|
||||
C_FLAG_REORDER='-xF'
|
||||
CXX_FLAG_REORDER='-xF'
|
||||
SHARED_LIBRARY_FLAGS="-G"
|
||||
SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN[$]1'
|
||||
SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN[$]1'
|
||||
SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
|
||||
SET_SHARED_LIBRARY_NAME='-h [$]1'
|
||||
SET_SHARED_LIBRARY_MAPFILE='-M[$]1'
|
||||
|
@ -5093,7 +5093,7 @@ VS_SDK_PLATFORM_NAME_2013=
|
||||
#CUSTOM_AUTOCONF_INCLUDE
|
||||
|
||||
# Do not change or remove the following line, it is needed for consistency checks:
|
||||
DATE_WHEN_GENERATED=1478079760
|
||||
DATE_WHEN_GENERATED=1478524503
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -49070,7 +49070,7 @@ $as_echo "$ac_cv_c_bigendian" >&6; }
|
||||
else
|
||||
# Default works for linux, might work on other platforms as well.
|
||||
SHARED_LIBRARY_FLAGS='-shared'
|
||||
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN$1'
|
||||
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1'
|
||||
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
|
||||
SET_SHARED_LIBRARY_NAME='-Wl,-soname=$1'
|
||||
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1'
|
||||
@ -49095,7 +49095,7 @@ $as_echo "$ac_cv_c_bigendian" >&6; }
|
||||
# Default works for linux, might work on other platforms as well.
|
||||
PICFLAG='-fPIC'
|
||||
SHARED_LIBRARY_FLAGS='-shared'
|
||||
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$$$ORIGIN$1'
|
||||
SET_EXECUTABLE_ORIGIN='-Wl,-rpath,\$$ORIGIN$1'
|
||||
SET_SHARED_LIBRARY_ORIGIN="-Wl,-z,origin $SET_EXECUTABLE_ORIGIN"
|
||||
SET_SHARED_LIBRARY_NAME='-Wl,-soname=$1'
|
||||
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1'
|
||||
@ -49105,7 +49105,7 @@ $as_echo "$ac_cv_c_bigendian" >&6; }
|
||||
C_FLAG_REORDER='-xF'
|
||||
CXX_FLAG_REORDER='-xF'
|
||||
SHARED_LIBRARY_FLAGS="-G"
|
||||
SET_EXECUTABLE_ORIGIN='-R\$$$$ORIGIN$1'
|
||||
SET_EXECUTABLE_ORIGIN='-R\$$ORIGIN$1'
|
||||
SET_SHARED_LIBRARY_ORIGIN="$SET_EXECUTABLE_ORIGIN"
|
||||
SET_SHARED_LIBRARY_NAME='-h $1'
|
||||
SET_SHARED_LIBRARY_MAPFILE='-M$1'
|
||||
|
@ -788,6 +788,7 @@ SYMBOLS_IMAGE_SUBDIR:=symbols
|
||||
SYMBOLS_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(SYMBOLS_IMAGE_SUBDIR)
|
||||
|
||||
# Interim image
|
||||
INTERIM_JMODS_DIR := $(SUPPORT_OUTPUTDIR)/interim-jmods
|
||||
INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image
|
||||
|
||||
# Docs image
|
||||
|
@ -385,3 +385,4 @@ aa053a3faf266c12b4fd5272da431a3e08e4a3e3 jdk-9+136
|
||||
9f3fc931bc230f44f2a58d75f7f6360af98bb113 jdk-9+140
|
||||
b32f998da32b488ec7c4e9dbb3c750841b48e74d jdk-9+141
|
||||
408c9c621938ca028e20bced0459f815de47eba8 jdk-9+142
|
||||
6211236ef15ec796806357608b1dd1b70c258ece jdk-9+143
|
||||
|
@ -545,3 +545,4 @@ fc0956308c7a586267c5dd35dff74f773aa9c3eb jdk-9+138
|
||||
fec31089c2ef5a12dd64f401b0bf2e00f56ee0d0 jdk-9+140
|
||||
160a00bc6ed0af1fdf8418fc65e6bddbbc0c536d jdk-9+141
|
||||
7b48d63dfd6b8e2657288de3d7b1f153dee02d7e jdk-9+142
|
||||
d87d5d430c42342f0320ca7f5cbe0cbd1f9d62ba jdk-9+143
|
||||
|
@ -125,7 +125,6 @@ JVM_GetPrimitiveArrayElement
|
||||
JVM_GetProtectionDomain
|
||||
JVM_GetSimpleBinaryName
|
||||
JVM_GetStackAccessControlContext
|
||||
JVM_GetStackTraceElements
|
||||
JVM_GetSystemPackage
|
||||
JVM_GetSystemPackages
|
||||
JVM_GetTemporaryDirectory
|
||||
@ -135,6 +134,8 @@ JVM_HasReferencePendingList
|
||||
JVM_HoldsLock
|
||||
JVM_IHashCode
|
||||
JVM_InitProperties
|
||||
JVM_InitStackTraceElement
|
||||
JVM_InitStackTraceElementArray
|
||||
JVM_InternString
|
||||
JVM_Interrupt
|
||||
JVM_InvokeMethod
|
||||
@ -178,7 +179,6 @@ JVM_StartThread
|
||||
JVM_StopThread
|
||||
JVM_SupportsCX8
|
||||
JVM_SuspendThread
|
||||
JVM_ToStackTraceElement
|
||||
JVM_TotalMemory
|
||||
JVM_UnloadLibrary
|
||||
JVM_WaitForReferencePendingList
|
||||
|
@ -2175,6 +2175,14 @@ void java_lang_StackTraceElement::fill_in(Handle element,
|
||||
const char* str = holder->external_name();
|
||||
oop classname = StringTable::intern((char*) str, CHECK);
|
||||
java_lang_StackTraceElement::set_declaringClass(element(), classname);
|
||||
java_lang_StackTraceElement::set_declaringClassObject(element(), holder->java_mirror());
|
||||
|
||||
oop loader = holder->class_loader();
|
||||
if (loader != NULL) {
|
||||
oop loader_name = java_lang_ClassLoader::name(loader);
|
||||
if (loader_name != NULL)
|
||||
java_lang_StackTraceElement::set_classLoaderName(element(), loader_name);
|
||||
}
|
||||
|
||||
// The method can be NULL if the requested class version is gone
|
||||
Symbol* sym = !method.is_null() ? method->name() : holder->constants()->symbol_at(cpref);
|
||||
@ -3433,6 +3441,7 @@ oop java_security_AccessControlContext::create(objArrayHandle context, bool isPr
|
||||
bool java_lang_ClassLoader::offsets_computed = false;
|
||||
int java_lang_ClassLoader::_loader_data_offset = -1;
|
||||
int java_lang_ClassLoader::parallelCapable_offset = -1;
|
||||
int java_lang_ClassLoader::name_offset = -1;
|
||||
int java_lang_ClassLoader::unnamedModule_offset = -1;
|
||||
|
||||
ClassLoaderData** java_lang_ClassLoader::loader_data_addr(oop loader) {
|
||||
@ -3453,6 +3462,9 @@ void java_lang_ClassLoader::compute_offsets() {
|
||||
compute_optional_offset(parallelCapable_offset,
|
||||
k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature());
|
||||
|
||||
compute_offset(name_offset,
|
||||
k1, vmSymbols::name_name(), vmSymbols::string_signature());
|
||||
|
||||
compute_offset(unnamedModule_offset,
|
||||
k1, vmSymbols::unnamedModule_name(), vmSymbols::module_signature());
|
||||
|
||||
@ -3464,6 +3476,11 @@ oop java_lang_ClassLoader::parent(oop loader) {
|
||||
return loader->obj_field(parent_offset);
|
||||
}
|
||||
|
||||
oop java_lang_ClassLoader::name(oop loader) {
|
||||
assert(is_instance(loader), "loader must be oop");
|
||||
return loader->obj_field(name_offset);
|
||||
}
|
||||
|
||||
bool java_lang_ClassLoader::isAncestor(oop loader, oop cl) {
|
||||
assert(is_instance(loader), "loader must be oop");
|
||||
assert(cl == NULL || is_instance(cl), "cl argument must be oop");
|
||||
@ -3619,12 +3636,14 @@ int java_lang_System::static_in_offset;
|
||||
int java_lang_System::static_out_offset;
|
||||
int java_lang_System::static_err_offset;
|
||||
int java_lang_System::static_security_offset;
|
||||
int java_lang_StackTraceElement::declaringClass_offset;
|
||||
int java_lang_StackTraceElement::methodName_offset;
|
||||
int java_lang_StackTraceElement::fileName_offset;
|
||||
int java_lang_StackTraceElement::lineNumber_offset;
|
||||
int java_lang_StackTraceElement::moduleName_offset;
|
||||
int java_lang_StackTraceElement::moduleVersion_offset;
|
||||
int java_lang_StackTraceElement::classLoaderName_offset;
|
||||
int java_lang_StackTraceElement::declaringClass_offset;
|
||||
int java_lang_StackTraceElement::classOrLoaderModuleClassName_offset;
|
||||
int java_lang_StackFrameInfo::_declaringClass_offset;
|
||||
int java_lang_StackFrameInfo::_memberName_offset;
|
||||
int java_lang_StackFrameInfo::_bci_offset;
|
||||
@ -3669,6 +3688,14 @@ void java_lang_StackTraceElement::set_moduleVersion(oop element, oop value) {
|
||||
element->obj_field_put(moduleVersion_offset, value);
|
||||
}
|
||||
|
||||
void java_lang_StackTraceElement::set_classLoaderName(oop element, oop value) {
|
||||
element->obj_field_put(classLoaderName_offset, value);
|
||||
}
|
||||
|
||||
void java_lang_StackTraceElement::set_declaringClassObject(oop element, oop value) {
|
||||
element->obj_field_put(classOrLoaderModuleClassName_offset, value);
|
||||
}
|
||||
|
||||
// Support for java_lang_StackFrameInfo
|
||||
void java_lang_StackFrameInfo::set_declaringClass(oop element, oop value) {
|
||||
element->obj_field_put(_declaringClass_offset, value);
|
||||
@ -3784,6 +3811,8 @@ void JavaClasses::compute_hard_coded_offsets() {
|
||||
java_lang_System::static_security_offset = java_lang_System::hc_static_security_offset * x;
|
||||
|
||||
// java_lang_StackTraceElement
|
||||
java_lang_StackTraceElement::classOrLoaderModuleClassName_offset= java_lang_StackTraceElement::hc_classOrLoaderModuleClassName_offset* x + header;
|
||||
java_lang_StackTraceElement::classLoaderName_offset = java_lang_StackTraceElement::hc_classLoaderName_offset * x + header;
|
||||
java_lang_StackTraceElement::moduleName_offset = java_lang_StackTraceElement::hc_moduleName_offset * x + header;
|
||||
java_lang_StackTraceElement::moduleVersion_offset = java_lang_StackTraceElement::hc_moduleVersion_offset * x + header;
|
||||
java_lang_StackTraceElement::declaringClass_offset = java_lang_StackTraceElement::hc_declaringClass_offset * x + header;
|
||||
@ -3985,10 +4014,14 @@ void JavaClasses::check_offsets() {
|
||||
|
||||
// java.lang.StackTraceElement
|
||||
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, declaringClass, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, methodName, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, fileName, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, lineNumber, "I");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, classOrLoaderModuleClassName, "Ljava/lang/Object;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, classLoaderName, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, moduleName, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, moduleVersion, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, declaringClass, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, methodName, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, fileName, "Ljava/lang/String;");
|
||||
CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, lineNumber, "I");
|
||||
|
||||
// java.lang.ref.Reference
|
||||
|
||||
|
@ -1225,6 +1225,7 @@ class java_lang_ClassLoader : AllStatic {
|
||||
static bool offsets_computed;
|
||||
static int parent_offset;
|
||||
static int parallelCapable_offset;
|
||||
static int name_offset;
|
||||
static int unnamedModule_offset;
|
||||
|
||||
public:
|
||||
@ -1234,6 +1235,7 @@ class java_lang_ClassLoader : AllStatic {
|
||||
static ClassLoaderData* loader_data(oop loader);
|
||||
|
||||
static oop parent(oop loader);
|
||||
static oop name(oop loader);
|
||||
static bool isAncestor(oop loader, oop cl);
|
||||
|
||||
// Support for parallelCapable field
|
||||
@ -1291,14 +1293,18 @@ class java_lang_System : AllStatic {
|
||||
class java_lang_StackTraceElement: AllStatic {
|
||||
private:
|
||||
enum {
|
||||
hc_moduleName_offset = 0,
|
||||
hc_moduleVersion_offset = 1,
|
||||
hc_declaringClass_offset = 2,
|
||||
hc_methodName_offset = 3,
|
||||
hc_fileName_offset = 4,
|
||||
hc_lineNumber_offset = 5
|
||||
hc_classOrLoaderModuleClassName_offset = 0,
|
||||
hc_classLoaderName_offset = 1,
|
||||
hc_moduleName_offset = 2,
|
||||
hc_moduleVersion_offset = 3,
|
||||
hc_declaringClass_offset = 4,
|
||||
hc_methodName_offset = 5,
|
||||
hc_fileName_offset = 6,
|
||||
hc_lineNumber_offset = 7
|
||||
};
|
||||
|
||||
static int classOrLoaderModuleClassName_offset;
|
||||
static int classLoaderName_offset;
|
||||
static int moduleName_offset;
|
||||
static int moduleVersion_offset;
|
||||
static int declaringClass_offset;
|
||||
@ -1307,12 +1313,14 @@ class java_lang_StackTraceElement: AllStatic {
|
||||
static int lineNumber_offset;
|
||||
|
||||
// Setters
|
||||
static void set_classLoaderName(oop element, oop value);
|
||||
static void set_moduleName(oop element, oop value);
|
||||
static void set_moduleVersion(oop element, oop value);
|
||||
static void set_declaringClass(oop element, oop value);
|
||||
static void set_methodName(oop element, oop value);
|
||||
static void set_fileName(oop element, oop value);
|
||||
static void set_lineNumber(oop element, int value);
|
||||
static void set_declaringClassObject(oop element, oop value);
|
||||
|
||||
public:
|
||||
// Create an instance of StackTraceElement
|
||||
|
@ -503,16 +503,27 @@ JVM_ENTRY(void, JVM_FillInStackTrace(JNIEnv *env, jobject receiver))
|
||||
JVM_END
|
||||
|
||||
|
||||
JVM_ENTRY(void, JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray stackTrace))
|
||||
JVMWrapper("JVM_GetStackTraceElements");
|
||||
// java.lang.StackTraceElement //////////////////////////////////////////////
|
||||
|
||||
|
||||
JVM_ENTRY(void, JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable))
|
||||
JVMWrapper("JVM_InitStackTraceElementArray");
|
||||
Handle exception(THREAD, JNIHandles::resolve(throwable));
|
||||
objArrayOop st = objArrayOop(JNIHandles::resolve(stackTrace));
|
||||
objArrayOop st = objArrayOop(JNIHandles::resolve(elements));
|
||||
objArrayHandle stack_trace(THREAD, st);
|
||||
// Fill in the allocated stack trace
|
||||
java_lang_Throwable::get_stack_trace_elements(exception, stack_trace, CHECK);
|
||||
JVM_END
|
||||
|
||||
|
||||
JVM_ENTRY(void, JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo))
|
||||
JVMWrapper("JVM_InitStackTraceElement");
|
||||
Handle stack_frame_info(THREAD, JNIHandles::resolve_non_null(stackFrameInfo));
|
||||
Handle stack_trace_element(THREAD, JNIHandles::resolve_non_null(element));
|
||||
java_lang_StackFrameInfo::to_stack_trace_element(stack_frame_info, stack_trace_element, THREAD);
|
||||
JVM_END
|
||||
|
||||
|
||||
// java.lang.StackWalker //////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@ -566,13 +577,6 @@ JVM_ENTRY(jint, JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode,
|
||||
start_index, frames_array_h, THREAD);
|
||||
JVM_END
|
||||
|
||||
JVM_ENTRY(void, JVM_ToStackTraceElement(JNIEnv *env, jobject frame, jobject stack))
|
||||
JVMWrapper("JVM_ToStackTraceElement");
|
||||
Handle stack_frame_info(THREAD, JNIHandles::resolve_non_null(frame));
|
||||
Handle stack_trace_element(THREAD, JNIHandles::resolve_non_null(stack));
|
||||
java_lang_StackFrameInfo::to_stack_trace_element(stack_frame_info, stack_trace_element, THREAD);
|
||||
JVM_END
|
||||
|
||||
// java.lang.Object ///////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -189,8 +189,14 @@ JVM_GetVmArguments(JNIEnv *env);
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
|
||||
|
||||
/*
|
||||
* java.lang.StackTraceElement
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements);
|
||||
JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
|
||||
|
||||
/*
|
||||
* java.lang.StackWalker
|
||||
@ -212,9 +218,6 @@ JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
|
||||
jint frame_count, jint start_index,
|
||||
jobjectArray frames);
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_ToStackTraceElement(JNIEnv* env, jobject frame, jobject stackElement);
|
||||
|
||||
/*
|
||||
* java.lang.Thread
|
||||
*/
|
||||
|
@ -385,3 +385,4 @@ a8d5fe567ae72b4931040e59dd4478363f9004f5 jdk-9+137
|
||||
8d100cb9b04819b5bd09f33c7fd5b8628d1a456f jdk-9+140
|
||||
037c095ba0c345edbeaaab52fda913a76c3930c0 jdk-9+141
|
||||
bdafa0cc34a97a2f8db4847a4efd34b407943591 jdk-9+142
|
||||
ce81d03ad7320dca3d673374c1a33bc0efd9136a jdk-9+143
|
||||
|
@ -385,3 +385,4 @@ e72df94364e3686e7d62059ce0d6b187b82da713 jdk-9+137
|
||||
e93b7ea559759f036c9f69fd2ddaf47bb4e98385 jdk-9+140
|
||||
8d752af5f61d41f226adf2cda72a20faa9ad620a jdk-9+141
|
||||
6ce43dd8e954b452f330dd7a412df5107f7e1923 jdk-9+142
|
||||
8dbc8594f9d5149bf1c22221272284609408227a jdk-9+143
|
||||
|
@ -140,7 +140,6 @@ SUNWprivate_1.1 {
|
||||
Java_java_lang_Double_doubleToRawLongBits;
|
||||
Java_java_lang_Float_intBitsToFloat;
|
||||
Java_java_lang_Float_floatToRawIntBits;
|
||||
Java_java_lang_StackFrameInfo_toStackTraceElement0;
|
||||
Java_java_lang_StackStreamFactory_checkStackWalkModes;
|
||||
Java_java_lang_StackStreamFactory_00024AbstractStackWalker_callStackWalk;
|
||||
Java_java_lang_StackStreamFactory_00024AbstractStackWalker_fetchStackFrames;
|
||||
@ -215,6 +214,8 @@ SUNWprivate_1.1 {
|
||||
Java_java_lang_SecurityManager_currentLoadedClass0;
|
||||
Java_java_lang_SecurityManager_getClassContext;
|
||||
Java_java_lang_Shutdown_halt0;
|
||||
Java_java_lang_StackTraceElement_initStackTraceElement;
|
||||
Java_java_lang_StackTraceElement_initStackTraceElements;
|
||||
Java_java_lang_String_intern;
|
||||
Java_java_lang_StringCoding_err;
|
||||
Java_java_lang_StringUTF16_isBigEndian;
|
||||
@ -227,7 +228,6 @@ SUNWprivate_1.1 {
|
||||
Java_java_lang_System_setOut0;
|
||||
Java_java_lang_Thread_registerNatives;
|
||||
Java_java_lang_Throwable_fillInStackTrace;
|
||||
Java_java_lang_Throwable_getStackTraceElements;
|
||||
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2;
|
||||
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedAction_2Ljava_security_AccessControlContext_2;
|
||||
Java_java_security_AccessController_doPrivileged__Ljava_security_PrivilegedExceptionAction_2;
|
||||
|
@ -78,7 +78,7 @@ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_Pri
|
||||
text: .text%JNU_GetEnv;
|
||||
text: .text%Java_java_io_UnixFileSystem_checkAccess;
|
||||
text: .text%Java_java_lang_reflect_Array_newArray;
|
||||
text: .text%Java_java_lang_Throwable_getStackTraceElements;
|
||||
text: .text%Java_java_lang_StackTraceElement_initStackTraceElements;
|
||||
text: .text%throwFileNotFoundException;
|
||||
text: .text%JNU_NotifyAll;
|
||||
# Test LoadFrame
|
||||
|
@ -74,7 +74,7 @@ text: .text%Java_java_security_AccessController_doPrivileged__Ljava_security_Pri
|
||||
text: .text%JNU_GetEnv;
|
||||
text: .text%Java_java_io_UnixFileSystem_checkAccess;
|
||||
text: .text%Java_java_lang_reflect_Array_newArray;
|
||||
text: .text%Java_java_lang_Throwable_getStackTraceElements;
|
||||
text: .text%Java_java_lang_StackTraceElement_initStackTraceElements;
|
||||
text: .text%throwFileNotFoundException: OUTPUTDIR/io_util.o;
|
||||
text: .text%JNU_NotifyAll;
|
||||
# Test LoadFrame
|
||||
|
@ -78,7 +78,7 @@ text: .text%Java_java_io_UnixFileSystem_checkAccess;
|
||||
text: .text%Java_sun_reflect_NativeMethodAccessorImpl_invoke0;
|
||||
text: .text%Java_java_io_FileInputStream_available;
|
||||
text: .text%Java_java_lang_reflect_Array_newArray;
|
||||
text: .text%Java_java_lang_Throwable_getStackTraceElements;
|
||||
text: .text%Java_java_lang_StackTraceElement_initStackTraceElements;
|
||||
text: .text%Java_java_lang_System_identityHashCode;
|
||||
text: .text%JNU_NotifyAll;
|
||||
# Test LoadFrame
|
||||
|
@ -33,7 +33,7 @@ include RmicCommon.gmk
|
||||
#
|
||||
|
||||
$(eval $(call SetupRMICompilation,RMI_12, \
|
||||
CLASSES := sun.rmi.server.Activation$$$$ActivationSystemImpl \
|
||||
CLASSES := sun.rmi.server.Activation$$ActivationSystemImpl \
|
||||
java.rmi.activation.ActivationGroup, \
|
||||
CLASSES_DIR := $(CLASSES_DIR)/java.rmi, \
|
||||
STUB_CLASSES_DIR := $(STUB_CLASSES_DIR)/java.rmi, \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2016, 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
|
||||
@ -1907,16 +1907,10 @@ public class File
|
||||
throws IOException
|
||||
{
|
||||
long n = random.nextLong();
|
||||
if (n == Long.MIN_VALUE) {
|
||||
n = 0; // corner case
|
||||
} else {
|
||||
n = Math.abs(n);
|
||||
}
|
||||
|
||||
// Use only the file name from the supplied prefix
|
||||
prefix = (new File(prefix)).getName();
|
||||
|
||||
String name = prefix + Long.toString(n) + suffix;
|
||||
String name = prefix + Long.toUnsignedString(n) + suffix;
|
||||
File f = new File(dir, name);
|
||||
if (!name.equals(f.getName()) || f.isInvalid()) {
|
||||
if (System.getSecurityManager() != null)
|
||||
|
@ -485,7 +485,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* can be replaced by
|
||||
*
|
||||
* <pre>{@code
|
||||
* clazz.getConstructor().newInstance()
|
||||
* clazz.getDeclaredConstructor().newInstance()
|
||||
* }</pre>
|
||||
*
|
||||
* The latter sequence of calls is inferred to be able to throw
|
||||
|
@ -222,6 +222,9 @@ public abstract class ClassLoader {
|
||||
// must be added *after* it.
|
||||
private final ClassLoader parent;
|
||||
|
||||
// class loader name
|
||||
private final String name;
|
||||
|
||||
// the unnamed module for this ClassLoader
|
||||
private final Module unnamedModule;
|
||||
|
||||
@ -331,6 +334,14 @@ public abstract class ClassLoader {
|
||||
}
|
||||
|
||||
private static Void checkCreateClassLoader() {
|
||||
return checkCreateClassLoader(null);
|
||||
}
|
||||
|
||||
private static Void checkCreateClassLoader(String name) {
|
||||
if (name != null && name.isEmpty()) {
|
||||
throw new IllegalArgumentException("name must be non-empty or null");
|
||||
}
|
||||
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
@ -338,7 +349,8 @@ public abstract class ClassLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ClassLoader(Void unused, ClassLoader parent) {
|
||||
private ClassLoader(Void unused, String name, ClassLoader parent) {
|
||||
this.name = name;
|
||||
this.parent = parent;
|
||||
this.unnamedModule
|
||||
= SharedSecrets.getJavaLangReflectModuleAccess()
|
||||
@ -355,6 +367,27 @@ public abstract class ClassLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new class loader of the specified name and using the
|
||||
* specified parent class loader for delegation.
|
||||
*
|
||||
* @param name class loader name; or {@code null} if not named
|
||||
* @param parent the parent class loader
|
||||
*
|
||||
* @throws IllegalArgumentException if the given name is empty.
|
||||
*
|
||||
* @throws SecurityException
|
||||
* If a security manager exists and its
|
||||
* {@link SecurityManager#checkCreateClassLoader()}
|
||||
* method doesn't allow creation of a new class loader.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
protected ClassLoader(String name, ClassLoader parent) {
|
||||
this(checkCreateClassLoader(name), name, parent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new class loader using the specified parent class loader for
|
||||
* delegation.
|
||||
@ -375,9 +408,10 @@ public abstract class ClassLoader {
|
||||
* @since 1.2
|
||||
*/
|
||||
protected ClassLoader(ClassLoader parent) {
|
||||
this(checkCreateClassLoader(), parent);
|
||||
this(checkCreateClassLoader(), null, parent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new class loader using the <tt>ClassLoader</tt> returned by
|
||||
* the method {@link #getSystemClassLoader()
|
||||
@ -394,7 +428,31 @@ public abstract class ClassLoader {
|
||||
* of a new class loader.
|
||||
*/
|
||||
protected ClassLoader() {
|
||||
this(checkCreateClassLoader(), getSystemClassLoader());
|
||||
this(checkCreateClassLoader(), null, getSystemClassLoader());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the name of this class loader or {@code null} if
|
||||
* this class loader is not named.
|
||||
*
|
||||
* @apiNote This method is non-final for compatibility. If this
|
||||
* method is overridden, this method must return the same name
|
||||
* as specified when this class loader was instantiated.
|
||||
*
|
||||
* @return name of this class loader; or {@code null} if
|
||||
* this class loader is not named.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
// package-private used by StackTraceElement to avoid
|
||||
// calling the overrideable getName method
|
||||
final String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
// -- Class --
|
||||
@ -1628,6 +1686,9 @@ public abstract class ClassLoader {
|
||||
* <a href="#builtinLoaders">platform classes</a> are visible to
|
||||
* the platform class loader.
|
||||
*
|
||||
* @implNote The name of the builtin platform class loader is
|
||||
* {@code "platform"}.
|
||||
*
|
||||
* @return The platform {@code ClassLoader}.
|
||||
*
|
||||
* @throws SecurityException
|
||||
@ -1681,7 +1742,8 @@ public abstract class ClassLoader {
|
||||
* this method during startup should take care not to cache the return
|
||||
* value until the system is fully initialized.
|
||||
*
|
||||
* <p> The class path used by the built-in system class loader is determined
|
||||
* <p> The name of the built-in system class loader is {@code "app"}.
|
||||
* The class path used by the built-in system class loader is determined
|
||||
* by the system property "{@code java.class.path}" during early
|
||||
* initialization of the VM. If the system property is not defined,
|
||||
* or its value is an empty string, then there is no class path
|
||||
|
@ -112,11 +112,6 @@ class StackFrameInfo implements StackFrame {
|
||||
return toStackTraceElement().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in the fields of the given StackTraceElement
|
||||
*/
|
||||
private native void toStackTraceElement0(StackTraceElement ste);
|
||||
|
||||
@Override
|
||||
public StackTraceElement toStackTraceElement() {
|
||||
StackTraceElement s = ste;
|
||||
@ -124,9 +119,7 @@ class StackFrameInfo implements StackFrame {
|
||||
synchronized (this) {
|
||||
s = ste;
|
||||
if (s == null) {
|
||||
s = new StackTraceElement();
|
||||
toStackTraceElement0(s);
|
||||
ste = s;
|
||||
ste = s = StackTraceElement.of(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,18 @@
|
||||
|
||||
package java.lang;
|
||||
|
||||
import jdk.internal.loader.BuiltinClassLoader;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.module.ModuleHashes;
|
||||
|
||||
import java.lang.module.ModuleDescriptor.Version;
|
||||
import java.lang.reflect.Layer;
|
||||
import java.lang.reflect.Module;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* An element in a stack trace, as returned by {@link
|
||||
@ -40,7 +51,15 @@ import java.util.Objects;
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
public final class StackTraceElement implements java.io.Serializable {
|
||||
// Normally initialized by VM (public constructor added in 1.5)
|
||||
// This field is set to the compacted String representation used
|
||||
// by StackTraceElement::toString and stored in serial form.
|
||||
//
|
||||
// This field is of Object type. VM initially sets this field to
|
||||
// the Class object of the declaring class to build the compacted string.
|
||||
private Object classOrLoaderModuleClassName;
|
||||
|
||||
// Normally initialized by VM
|
||||
private String classLoaderName;
|
||||
private String moduleName;
|
||||
private String moduleVersion;
|
||||
private String declaringClass;
|
||||
@ -72,19 +91,22 @@ public final class StackTraceElement implements java.io.Serializable {
|
||||
*/
|
||||
public StackTraceElement(String declaringClass, String methodName,
|
||||
String fileName, int lineNumber) {
|
||||
this(null, null, declaringClass, methodName, fileName, lineNumber);
|
||||
this(null, null, null, declaringClass, methodName, fileName, lineNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a stack trace element representing the specified execution
|
||||
* point.
|
||||
*
|
||||
* @param classLoaderName the class loader name if the class loader of
|
||||
* the class containing the execution point represented by
|
||||
* the stack trace is named; otherwise {@code null}
|
||||
* @param moduleName the module name if the class containing the
|
||||
* execution point represented by the stack trace is in a named
|
||||
* module; can be {@code null}
|
||||
* module; otherwise {@code null}
|
||||
* @param moduleVersion the module version if the class containing the
|
||||
* execution point represented by the stack trace is in a named
|
||||
* module that has a version; can be {@code null}
|
||||
* module that has a version; otherwise {@code null}
|
||||
* @param declaringClass the fully qualified name of the class containing
|
||||
* the execution point represented by the stack trace element
|
||||
* @param methodName the name of the method containing the execution point
|
||||
@ -97,26 +119,30 @@ public final class StackTraceElement implements java.io.Serializable {
|
||||
* a negative number if this information is unavailable. A value
|
||||
* of -2 indicates that the method containing the execution point
|
||||
* is a native method
|
||||
*
|
||||
* @throws NullPointerException if {@code declaringClass} is {@code null}
|
||||
* or {@code methodName} is {@code null}
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public StackTraceElement(String moduleName, String moduleVersion,
|
||||
public StackTraceElement(String classLoaderName,
|
||||
String moduleName, String moduleVersion,
|
||||
String declaringClass, String methodName,
|
||||
String fileName, int lineNumber) {
|
||||
this.moduleName = moduleName;
|
||||
this.moduleVersion = moduleVersion;
|
||||
this.declaringClass = Objects.requireNonNull(declaringClass, "Declaring class is null");
|
||||
this.methodName = Objects.requireNonNull(methodName, "Method name is null");
|
||||
this.fileName = fileName;
|
||||
this.lineNumber = lineNumber;
|
||||
this.classLoaderName = classLoaderName;
|
||||
this.moduleName = moduleName;
|
||||
this.moduleVersion = moduleVersion;
|
||||
this.declaringClass = Objects.requireNonNull(declaringClass, "Declaring class is null");
|
||||
this.methodName = Objects.requireNonNull(methodName, "Method name is null");
|
||||
this.fileName = fileName;
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates an empty stack frame element to be filled in by Throwable.
|
||||
/*
|
||||
* Private constructor for the factory methods to create StackTraceElement
|
||||
* for Throwable and StackFrameInfo
|
||||
*/
|
||||
StackTraceElement() { }
|
||||
private StackTraceElement() {}
|
||||
|
||||
/**
|
||||
* Returns the name of the source file containing the execution point
|
||||
@ -177,6 +203,21 @@ public final class StackTraceElement implements java.io.Serializable {
|
||||
return moduleVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the class loader of the class containing the
|
||||
* execution point represented by this stack trace element.
|
||||
*
|
||||
* @return the name of the class loader of the class containing the execution
|
||||
* point represented by this stack trace element; {@code null}
|
||||
* if the class loader is not named.
|
||||
*
|
||||
* @since 9
|
||||
* @see java.lang.ClassLoader#getName()
|
||||
*/
|
||||
public String getClassLoaderName() {
|
||||
return classLoaderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fully qualified name of the class containing the
|
||||
* execution point represented by this stack trace element.
|
||||
@ -220,38 +261,83 @@ public final class StackTraceElement implements java.io.Serializable {
|
||||
* examples may be regarded as typical:
|
||||
* <ul>
|
||||
* <li>
|
||||
* {@code "MyClass.mash(my.module@9.0/MyClass.java:101)"} - Here,
|
||||
* {@code "MyClass"} is the <i>fully-qualified name</i> of the class
|
||||
* containing the execution point represented by this stack trace element,
|
||||
* {@code "mash"} is the name of the method containing the execution
|
||||
* point, {@code "my.module"} is the module name, {@code "9.0"} is the
|
||||
* module version, and {@code "101"} is the line number of the source
|
||||
* line containing the execution point.
|
||||
* "{@code com.foo.loader/foo@9.0/com.foo.Main.run(Main.java:101)}"
|
||||
* - See the description below.
|
||||
* </li>
|
||||
* <li>
|
||||
* {@code "MyClass.mash(my.module@9.0/MyClass.java)"} - As above, but the
|
||||
* line number is unavailable.
|
||||
* "{@code com.foo.loader/foo@9.0/com.foo.Main.run(Main.java)}"
|
||||
* - The line number is unavailable.
|
||||
* </li>
|
||||
* <li>
|
||||
* {@code "MyClass.mash(my.module@9.0/Unknown Source)"} - As above, but
|
||||
* neither the file name nor the line number are available.
|
||||
* "{@code com.foo.loader/foo@9.0/com.foo.Main.run(Unknown Source)}"
|
||||
* - Neither the file name nor the line number is available.
|
||||
* </li>
|
||||
* <li>
|
||||
* {@code "MyClass.mash(my.module@9.0/Native Method)"} - As above, but
|
||||
* neither the file name nor the line number are available, and the
|
||||
* method containing the execution point is known to be a native method.
|
||||
* "{@code com.foo.loader/foo@9.0/com.foo.Main.run(Native Method)}"
|
||||
* - The method containing the execution point is a native method.
|
||||
* </li>
|
||||
* <li>
|
||||
* "{@code com.foo.loader//com.foo.bar.App.run(App.java:12)}"
|
||||
* - The class of the execution point is defined in the unnamed module of
|
||||
* the class loader named {@code com.foo.loader}.
|
||||
* </li>
|
||||
* <li>
|
||||
* "{@code acme@2.1/org.acme.Lib.test(Lib.java:80)}"
|
||||
* - The class of the execution point is defined in {@code acme} module
|
||||
* loaded by by a built-in class loader such as the application class loader.
|
||||
* </li>
|
||||
* <li>
|
||||
* "{@code MyClass.mash(MyClass.java:9)}"
|
||||
* - {@code MyClass} class is on the application class path.
|
||||
* </li>
|
||||
* </ul>
|
||||
* If the execution point is not in a named module, {@code "my.module@9.0/"}
|
||||
* will be omitted from the above.
|
||||
*
|
||||
* <p> The first example shows a stack trace element consisting of
|
||||
* three elements, each separated by {@code "/"} followed with
|
||||
* the source file name and the line number of the source line
|
||||
* containing the execution point.
|
||||
*
|
||||
* The first element "{@code com.foo.loader}" is
|
||||
* the name of the class loader. The second element "{@code foo@9.0}"
|
||||
* is the module name and version. The third element is the method
|
||||
* containing the execution point; "{@code com.foo.Main"}" is the
|
||||
* fully-qualified class name and "{@code run}" is the name of the method.
|
||||
* "{@code Main.java}" is the source file name and "{@code 101}" is
|
||||
* the line number.
|
||||
*
|
||||
* <p> If a class is defined in an <em>unnamed module</em>
|
||||
* then the second element is omitted as shown in
|
||||
* "{@code com.foo.loader//com.foo.bar.App.run(App.java:12)}".
|
||||
*
|
||||
* If the class loader is a <a href="ClassLoader.html#builtinLoaders">
|
||||
* built-in class loader</a> or is not named then the first element
|
||||
* and its following {@code "/"} are omitted as shown in
|
||||
* "{@code acme@2.1/org.acme.Lib.test(Lib.java:80)}".
|
||||
* If the first element is omitted and the module is an unnamed module,
|
||||
* the second element and its following {@code "/"} are also omitted
|
||||
* as shown in "{@code MyClass.mash(MyClass.java:9)}".
|
||||
*
|
||||
* @see Throwable#printStackTrace()
|
||||
*/
|
||||
public String toString() {
|
||||
String mid = "";
|
||||
if (moduleName != null) {
|
||||
mid = moduleName;
|
||||
if (moduleVersion != null)
|
||||
mid += "@" + moduleVersion;
|
||||
mid += "/";
|
||||
String s = buildLoaderModuleClassName();
|
||||
if (s == null) {
|
||||
// all elements will be included
|
||||
s = "";
|
||||
if (classLoaderName != null && !classLoaderName.isEmpty()) {
|
||||
s += classLoaderName + "/";
|
||||
}
|
||||
if (moduleName != null && !moduleName.isEmpty()) {
|
||||
s += moduleName;
|
||||
|
||||
if (moduleVersion != null && !moduleVersion.isEmpty()) {
|
||||
s += "@" + moduleVersion;
|
||||
}
|
||||
}
|
||||
s = s.isEmpty() ? declaringClass : s + "/" + declaringClass;
|
||||
}
|
||||
return getClassName() + "." + methodName + "(" + mid +
|
||||
|
||||
return s + "." + methodName + "(" +
|
||||
(isNativeMethod() ? "Native Method)" :
|
||||
(fileName != null && lineNumber >= 0 ?
|
||||
fileName + ":" + lineNumber + ")" :
|
||||
@ -264,12 +350,14 @@ public final class StackTraceElement implements java.io.Serializable {
|
||||
* point as this instance. Two stack trace elements {@code a} and
|
||||
* {@code b} are equal if and only if:
|
||||
* <pre>{@code
|
||||
* equals(a.getFileName(), b.getFileName()) &&
|
||||
* a.getLineNumber() == b.getLineNumber()) &&
|
||||
* equals(a.getClassLoaderName(), b.getClassLoaderName()) &&
|
||||
* equals(a.getModuleName(), b.getModuleName()) &&
|
||||
* equals(a.getModuleVersion(), b.getModuleVersion()) &&
|
||||
* equals(a.getClassName(), b.getClassName()) &&
|
||||
* equals(a.getMethodName(), b.getMethodName())
|
||||
* equals(a.getFileName(), b.getFileName()) &&
|
||||
* a.getLineNumber() == b.getLineNumber()
|
||||
*
|
||||
* }</pre>
|
||||
* where {@code equals} has the semantics of {@link
|
||||
* java.util.Objects#equals(Object, Object) Objects.equals}.
|
||||
@ -285,9 +373,10 @@ public final class StackTraceElement implements java.io.Serializable {
|
||||
if (!(obj instanceof StackTraceElement))
|
||||
return false;
|
||||
StackTraceElement e = (StackTraceElement)obj;
|
||||
return e.declaringClass.equals(declaringClass) &&
|
||||
return Objects.equals(classLoaderName, e.classLoaderName) &&
|
||||
Objects.equals(moduleName, e.moduleName) &&
|
||||
Objects.equals(moduleVersion, e.moduleVersion) &&
|
||||
e.declaringClass.equals(declaringClass) &&
|
||||
e.lineNumber == lineNumber &&
|
||||
Objects.equals(methodName, e.methodName) &&
|
||||
Objects.equals(fileName, e.fileName);
|
||||
@ -298,6 +387,7 @@ public final class StackTraceElement implements java.io.Serializable {
|
||||
*/
|
||||
public int hashCode() {
|
||||
int result = 31*declaringClass.hashCode() + methodName.hashCode();
|
||||
result = 31*result + Objects.hashCode(classLoaderName);
|
||||
result = 31*result + Objects.hashCode(moduleName);
|
||||
result = 31*result + Objects.hashCode(moduleVersion);
|
||||
result = 31*result + Objects.hashCode(fileName);
|
||||
@ -305,5 +395,157 @@ public final class StackTraceElement implements java.io.Serializable {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build the compacted String representation to be returned by
|
||||
* toString method from the declaring Class object.
|
||||
*/
|
||||
synchronized String buildLoaderModuleClassName() {
|
||||
if (classOrLoaderModuleClassName == null)
|
||||
return null;
|
||||
|
||||
if (classOrLoaderModuleClassName instanceof Class) {
|
||||
Class<?> cls = (Class<?>)classOrLoaderModuleClassName;
|
||||
classOrLoaderModuleClassName = toLoaderModuleClassName(cls);
|
||||
}
|
||||
return (String)classOrLoaderModuleClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <loader>/<module>/<fully-qualified-classname> string
|
||||
* representation of the given class.
|
||||
* <p>
|
||||
* If the module is a non-upgradeable JDK module then omit
|
||||
* its version string.
|
||||
* <p>
|
||||
* If the loader has no name, or if the loader is one of the built-in
|
||||
* loaders (`boot`, `platform`, or `app`) then drop the first element
|
||||
* (`<loader>/`).
|
||||
* <p>
|
||||
* If the first element has been dropped and the module is unnamed
|
||||
* then drop the second element (`<module>/`).
|
||||
* <p>
|
||||
* If the first element is not dropped and the module is unnamed
|
||||
* then drop `<module>`.
|
||||
*/
|
||||
private static String toLoaderModuleClassName(Class<?> cls) {
|
||||
ClassLoader loader = cls.getClassLoader0();
|
||||
Module m = cls.getModule();
|
||||
|
||||
// First element - class loader name
|
||||
// Call package-private ClassLoader::name method
|
||||
String s = "";
|
||||
if (loader != null && loader.name() != null &&
|
||||
!(loader instanceof BuiltinClassLoader)) {
|
||||
s = loader.name() + "/";
|
||||
}
|
||||
|
||||
// Second element - module name and version
|
||||
if (m != null && m.isNamed()) {
|
||||
s += m.getName();
|
||||
// Include version if it is a user module or upgradeable module
|
||||
//
|
||||
// If it is JDK non-upgradeable module which is recorded
|
||||
// in the hashes in java.base, omit the version.
|
||||
if (!isHashedInJavaBase(m)) {
|
||||
Optional<Version> ov = m.getDescriptor().version();
|
||||
if (ov.isPresent()) {
|
||||
String version = "@" + ov.get().toString();
|
||||
s += version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fully-qualified class name
|
||||
return s.isEmpty() ? cls.getName() : s + "/" + cls.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the module is hashed with java.base.
|
||||
* <p>
|
||||
* This method returns false when running on the exploded image
|
||||
* since JDK modules are not hashed. They have no Version attribute
|
||||
* and so "@<version>" part will be omitted anyway.
|
||||
*/
|
||||
private static boolean isHashedInJavaBase(Module m) {
|
||||
// return true if module system is not initialized as the code
|
||||
// must be in java.base
|
||||
if (!VM.isModuleSystemInited())
|
||||
return true;
|
||||
|
||||
return Layer.boot() == m.getLayer() && HashedModules.contains(m);
|
||||
}
|
||||
|
||||
/*
|
||||
* Finds JDK non-upgradeable modules, i.e. the modules that are
|
||||
* included in the hashes in java.base.
|
||||
*/
|
||||
private static class HashedModules {
|
||||
static Set<String> HASHED_MODULES = hashedModules();
|
||||
|
||||
static Set<String> hashedModules() {
|
||||
Module javaBase = Layer.boot().findModule("java.base").get();
|
||||
Optional<ModuleHashes> ohashes =
|
||||
SharedSecrets.getJavaLangModuleAccess()
|
||||
.hashes(javaBase.getDescriptor());
|
||||
|
||||
if (ohashes.isPresent()) {
|
||||
Set<String> names = new HashSet<>(ohashes.get().names());
|
||||
names.add("java.base");
|
||||
return names;
|
||||
}
|
||||
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
static boolean contains(Module m) {
|
||||
return HASHED_MODULES.contains(m.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Returns an array of StackTraceElements of the given depth
|
||||
* filled from the backtrace of a given Throwable.
|
||||
*/
|
||||
static StackTraceElement[] of(Throwable x, int depth) {
|
||||
StackTraceElement[] stackTrace = new StackTraceElement[depth];
|
||||
for (int i = 0; i < depth; i++) {
|
||||
stackTrace[i] = new StackTraceElement();
|
||||
}
|
||||
|
||||
// VM to fill in StackTraceElement
|
||||
initStackTraceElements(stackTrace, x);
|
||||
|
||||
// ensure the proper StackTraceElement initialization
|
||||
for (StackTraceElement ste : stackTrace) {
|
||||
ste.buildLoaderModuleClassName();
|
||||
}
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a StackTraceElement from a given StackFrameInfo.
|
||||
*/
|
||||
static StackTraceElement of(StackFrameInfo sfi) {
|
||||
StackTraceElement ste = new StackTraceElement();
|
||||
initStackTraceElement(ste, sfi);
|
||||
|
||||
ste.buildLoaderModuleClassName();
|
||||
return ste;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the given stack trace elements with the backtrace
|
||||
* of the given Throwable.
|
||||
*/
|
||||
private static native void initStackTraceElements(StackTraceElement[] elements,
|
||||
Throwable x);
|
||||
/*
|
||||
* Sets the given stack trace element with the given StackFrameInfo
|
||||
*/
|
||||
private static native void initStackTraceElement(StackTraceElement element,
|
||||
StackFrameInfo sfi);
|
||||
|
||||
private static final long serialVersionUID = 6992337162326171013L;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
*/
|
||||
|
||||
package java.lang;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@ -826,11 +825,7 @@ public class Throwable implements Serializable {
|
||||
// backtrace if this is the first call to this method
|
||||
if (stackTrace == UNASSIGNED_STACK ||
|
||||
(stackTrace == null && backtrace != null) /* Out of protocol state */) {
|
||||
stackTrace = new StackTraceElement[depth];
|
||||
for (int i = 0; i < depth; i++) {
|
||||
stackTrace[i] = new StackTraceElement();
|
||||
}
|
||||
getStackTraceElements(stackTrace);
|
||||
stackTrace = StackTraceElement.of(this, depth);
|
||||
} else if (stackTrace == null) {
|
||||
return UNASSIGNED_STACK;
|
||||
}
|
||||
@ -881,13 +876,6 @@ public class Throwable implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the stack trace elements.
|
||||
* @param elements
|
||||
* @throws IndexOutOfBoundsException if {@code elements.length != depth }
|
||||
*/
|
||||
private native void getStackTraceElements(StackTraceElement[] elements);
|
||||
|
||||
/**
|
||||
* Reads a {@code Throwable} from a stream, enforcing
|
||||
* well-formedness constraints on fields. Null entries and
|
||||
|
@ -110,19 +110,19 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
}
|
||||
ucp = new URLClassPath(urls);
|
||||
this.ucp = new URLClassPath(urls);
|
||||
this.acc = AccessController.getContext();
|
||||
}
|
||||
|
||||
URLClassLoader(URL[] urls, ClassLoader parent,
|
||||
URLClassLoader(String name, URL[] urls, ClassLoader parent,
|
||||
AccessControlContext acc) {
|
||||
super(parent);
|
||||
super(name, parent);
|
||||
// this is to make the stack depth consistent with 1.1
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
}
|
||||
ucp = new URLClassPath(urls);
|
||||
this.ucp = new URLClassPath(urls);
|
||||
this.acc = acc;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
}
|
||||
ucp = new URLClassPath(urls);
|
||||
this.ucp = new URLClassPath(urls);
|
||||
this.acc = AccessController.getContext();
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
}
|
||||
ucp = new URLClassPath(urls);
|
||||
this.ucp = new URLClassPath(urls);
|
||||
this.acc = acc;
|
||||
}
|
||||
|
||||
@ -198,8 +198,76 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
}
|
||||
ucp = new URLClassPath(urls, factory);
|
||||
acc = AccessController.getContext();
|
||||
this.ucp = new URLClassPath(urls, factory);
|
||||
this.acc = AccessController.getContext();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new named {@code URLClassLoader} for the specified URLs.
|
||||
* The URLs will be searched in the order specified for classes
|
||||
* and resources after first searching in the specified parent class loader.
|
||||
* Any URL that ends with a '/' is assumed to refer to a directory.
|
||||
* Otherwise, the URL is assumed to refer to a JAR file which will be
|
||||
* downloaded and opened as needed.
|
||||
*
|
||||
* @param name class loader name; or {@code null} if not named
|
||||
* @param urls the URLs from which to load classes and resources
|
||||
* @param parent the parent class loader for delegation
|
||||
*
|
||||
* @throws IllegalArgumentException if the given name is empty.
|
||||
* @throws NullPointerException if {@code urls} is {@code null}.
|
||||
*
|
||||
* @throws SecurityException if a security manager exists and its
|
||||
* {@link SecurityManager#checkCreateClassLoader()} method doesn't
|
||||
* allow creation of a class loader.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public URLClassLoader(String name,
|
||||
URL[] urls,
|
||||
ClassLoader parent) {
|
||||
super(name, parent);
|
||||
// this is to make the stack depth consistent with 1.1
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
}
|
||||
this.ucp = new URLClassPath(urls);
|
||||
this.acc = AccessController.getContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new named {@code URLClassLoader} for the specified URLs,
|
||||
* parent class loader, and URLStreamHandlerFactory.
|
||||
* The parent argument will be used as the parent class loader for delegation.
|
||||
* The factory argument will be used as the stream handler factory to
|
||||
* obtain protocol handlers when creating new jar URLs.
|
||||
*
|
||||
* @param name class loader name; or {@code null} if not named
|
||||
* @param urls the URLs from which to load classes and resources
|
||||
* @param parent the parent class loader for delegation
|
||||
* @param factory the URLStreamHandlerFactory to use when creating URLs
|
||||
*
|
||||
* @throws IllegalArgumentException if the given name is empty.
|
||||
* @throws NullPointerException if {@code urls} is {@code null}.
|
||||
*
|
||||
* @throws SecurityException if a security manager exists and its
|
||||
* {@code checkCreateClassLoader} method doesn't allow
|
||||
* creation of a class loader.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public URLClassLoader(String name, URL[] urls, ClassLoader parent,
|
||||
URLStreamHandlerFactory factory) {
|
||||
super(name, parent);
|
||||
// this is to make the stack depth consistent with 1.1
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
}
|
||||
this.ucp = new URLClassPath(urls, factory);
|
||||
this.acc = AccessController.getContext();
|
||||
}
|
||||
|
||||
/* A map (used as a set) to keep track of closeable local resources
|
||||
@ -735,7 +803,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
URLClassLoader ucl = AccessController.doPrivileged(
|
||||
new PrivilegedAction<>() {
|
||||
public URLClassLoader run() {
|
||||
return new FactoryURLClassLoader(urls, parent, acc);
|
||||
return new FactoryURLClassLoader(null, urls, parent, acc);
|
||||
}
|
||||
});
|
||||
return ucl;
|
||||
@ -785,9 +853,9 @@ final class FactoryURLClassLoader extends URLClassLoader {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
FactoryURLClassLoader(URL[] urls, ClassLoader parent,
|
||||
FactoryURLClassLoader(String name, URL[] urls, ClassLoader parent,
|
||||
AccessControlContext acc) {
|
||||
super(urls, parent, acc);
|
||||
super(name, urls, parent, acc);
|
||||
}
|
||||
|
||||
FactoryURLClassLoader(URL[] urls, AccessControlContext acc) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2016, 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
|
||||
@ -55,8 +55,8 @@ class TempFileHelper {
|
||||
private static final SecureRandom random = new SecureRandom();
|
||||
private static Path generatePath(String prefix, String suffix, Path dir) {
|
||||
long n = random.nextLong();
|
||||
n = (n == Long.MIN_VALUE) ? 0 : Math.abs(n);
|
||||
Path name = dir.getFileSystem().getPath(prefix + Long.toString(n) + suffix);
|
||||
String s = prefix + Long.toUnsignedString(n) + suffix;
|
||||
Path name = dir.getFileSystem().getPath(s);
|
||||
// the generated name should be a simple file name
|
||||
if (name.getParent() != null)
|
||||
throw new IllegalArgumentException("Invalid prefix or suffix");
|
||||
|
@ -25,8 +25,6 @@
|
||||
|
||||
package java.security;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -113,6 +111,30 @@ public class SecureClassLoader extends ClassLoader {
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code SecureClassLoader} of the specified name and
|
||||
* using the specified parent class loader for delegation.
|
||||
*
|
||||
* @param name class loader name; or {@code null} if not named
|
||||
* @param parent the parent class loader
|
||||
*
|
||||
* @throws IllegalArgumentException if the given name is empty.
|
||||
*
|
||||
* @throws SecurityException if a security manager exists and its
|
||||
* {@link SecurityManager#checkCreateClassLoader()} method
|
||||
* doesn't allow creation of a class loader.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
protected SecureClassLoader(String name, ClassLoader parent) {
|
||||
super(name, parent);
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
security.checkCreateClassLoader();
|
||||
}
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array of bytes into an instance of class Class,
|
||||
* with an optional CodeSource. Before the
|
||||
|
@ -53,7 +53,8 @@ class ImmutableCollections {
|
||||
*/
|
||||
static final int SALT;
|
||||
static {
|
||||
SALT = new Random().nextInt();
|
||||
long nt = System.nanoTime();
|
||||
SALT = (int)((nt >>> 32) ^ nt);
|
||||
}
|
||||
|
||||
/** No instances. */
|
||||
@ -63,7 +64,7 @@ class ImmutableCollections {
|
||||
* The reciprocal of load factor. Given a number of elements
|
||||
* to store, multiply by this factor to get the table size.
|
||||
*/
|
||||
static final double EXPAND_FACTOR = 2.0;
|
||||
static final int EXPAND_FACTOR = 2;
|
||||
|
||||
static UnsupportedOperationException uoe() { return new UnsupportedOperationException(); }
|
||||
|
||||
@ -84,7 +85,14 @@ class ImmutableCollections {
|
||||
}
|
||||
|
||||
static final class List0<E> extends AbstractImmutableList<E> {
|
||||
List0() { }
|
||||
private static final List0<?> INSTANCE = new List0<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static <T> List0<T> instance() {
|
||||
return (List0<T>) INSTANCE;
|
||||
}
|
||||
|
||||
private List0() { }
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
@ -214,7 +222,14 @@ class ImmutableCollections {
|
||||
}
|
||||
|
||||
static final class Set0<E> extends AbstractImmutableSet<E> {
|
||||
Set0() { }
|
||||
private static final Set0<?> INSTANCE = new Set0<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static <T> Set0<T> instance() {
|
||||
return (Set0<T>) INSTANCE;
|
||||
}
|
||||
|
||||
private Set0() { }
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
@ -351,7 +366,7 @@ class ImmutableCollections {
|
||||
SetN(E... input) {
|
||||
size = input.length; // implicit nullcheck of input
|
||||
|
||||
elements = (E[])new Object[(int)Math.ceil(EXPAND_FACTOR * input.length)];
|
||||
elements = (E[])new Object[EXPAND_FACTOR * input.length];
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
E e = Objects.requireNonNull(input[i]);
|
||||
int idx = probe(e);
|
||||
@ -450,7 +465,14 @@ class ImmutableCollections {
|
||||
}
|
||||
|
||||
static final class Map0<K,V> extends AbstractImmutableMap<K,V> {
|
||||
Map0() { }
|
||||
private static final Map0<?,?> INSTANCE = new Map0<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static <K,V> Map0<K,V> instance() {
|
||||
return (Map0<K,V>) INSTANCE;
|
||||
}
|
||||
|
||||
private Map0() { }
|
||||
|
||||
@Override
|
||||
public Set<Map.Entry<K,V>> entrySet() {
|
||||
@ -529,7 +551,7 @@ class ImmutableCollections {
|
||||
}
|
||||
size = input.length >> 1;
|
||||
|
||||
int len = (int)Math.ceil(EXPAND_FACTOR * input.length);
|
||||
int len = EXPAND_FACTOR * input.length;
|
||||
len = (len + 1) & ~1; // ensure table is even length
|
||||
table = new Object[len];
|
||||
|
||||
@ -789,7 +811,7 @@ final class CollSer implements Serializable {
|
||||
return Set.of(array);
|
||||
case IMM_MAP:
|
||||
if (array.length == 0) {
|
||||
return new ImmutableCollections.Map0<>();
|
||||
return ImmutableCollections.Map0.instance();
|
||||
} else if (array.length == 2) {
|
||||
return new ImmutableCollections.Map1<>(array[0], array[1]);
|
||||
} else {
|
||||
|
@ -786,7 +786,7 @@ public interface List<E> extends Collection<E> {
|
||||
* @since 9
|
||||
*/
|
||||
static <E> List<E> of() {
|
||||
return new ImmutableCollections.List0<>();
|
||||
return ImmutableCollections.List0.instance();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1030,7 +1030,7 @@ public interface List<E> extends Collection<E> {
|
||||
Objects.requireNonNull(elements);
|
||||
switch (elements.length) {
|
||||
case 0:
|
||||
return new ImmutableCollections.List0<>();
|
||||
return ImmutableCollections.List0.instance();
|
||||
case 1:
|
||||
return new ImmutableCollections.List1<>(elements[0]);
|
||||
case 2:
|
||||
|
@ -1286,7 +1286,7 @@ public interface Map<K, V> {
|
||||
* @since 9
|
||||
*/
|
||||
static <K, V> Map<K, V> of() {
|
||||
return new ImmutableCollections.Map0<>();
|
||||
return ImmutableCollections.Map0.instance();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1604,7 +1604,7 @@ public interface Map<K, V> {
|
||||
static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
|
||||
Objects.requireNonNull(entries);
|
||||
if (entries.length == 0) {
|
||||
return new ImmutableCollections.Map0<>();
|
||||
return ImmutableCollections.Map0.instance();
|
||||
} else if (entries.length == 1) {
|
||||
return new ImmutableCollections.Map1<>(entries[0].getKey(),
|
||||
entries[0].getValue());
|
||||
|
@ -448,7 +448,7 @@ public interface Set<E> extends Collection<E> {
|
||||
* @since 9
|
||||
*/
|
||||
static <E> Set<E> of() {
|
||||
return new ImmutableCollections.Set0<>();
|
||||
return ImmutableCollections.Set0.instance();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -692,7 +692,7 @@ public interface Set<E> extends Collection<E> {
|
||||
Objects.requireNonNull(elements);
|
||||
switch (elements.length) {
|
||||
case 0:
|
||||
return new ImmutableCollections.Set0<>();
|
||||
return ImmutableCollections.Set0.instance();
|
||||
case 1:
|
||||
return new ImmutableCollections.Set1<>(elements[0]);
|
||||
case 2:
|
||||
|
@ -145,9 +145,9 @@ public class BuiltinClassLoader
|
||||
/**
|
||||
* Create a new instance.
|
||||
*/
|
||||
BuiltinClassLoader(BuiltinClassLoader parent, URLClassPath ucp) {
|
||||
BuiltinClassLoader(String name, BuiltinClassLoader parent, URLClassPath ucp) {
|
||||
// ensure getParent() returns null when the parent is the boot loader
|
||||
super(parent == null || parent == ClassLoaders.bootLoader() ? null : parent);
|
||||
super(name, parent == null || parent == ClassLoaders.bootLoader() ? null : parent);
|
||||
|
||||
this.parent = parent;
|
||||
this.ucp = ucp;
|
||||
|
@ -118,7 +118,7 @@ public class ClassLoaders {
|
||||
*/
|
||||
private static class BootClassLoader extends BuiltinClassLoader {
|
||||
BootClassLoader(URLClassPath bcp) {
|
||||
super(null, bcp);
|
||||
super(null, null, bcp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -138,7 +138,7 @@ public class ClassLoaders {
|
||||
}
|
||||
|
||||
PlatformClassLoader(BootClassLoader parent) {
|
||||
super(parent, null);
|
||||
super("platform", parent, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +165,7 @@ public class ClassLoaders {
|
||||
final URLClassPath ucp;
|
||||
|
||||
AppClassLoader(PlatformClassLoader parent, URLClassPath ucp) {
|
||||
super(parent, ucp);
|
||||
super("app", parent, ucp);
|
||||
this.ucp = ucp;
|
||||
}
|
||||
|
||||
|
@ -253,20 +253,20 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
|
||||
}
|
||||
|
||||
private static String toSourceString(char c) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("'");
|
||||
StringBuilder sb = new StringBuilder(4);
|
||||
sb.append('\'');
|
||||
if (c == '\'')
|
||||
sb.append("\\'");
|
||||
else
|
||||
sb.append(c);
|
||||
sb.append("'");
|
||||
return sb.toString();
|
||||
return sb.append('\'')
|
||||
.toString();
|
||||
}
|
||||
|
||||
private static String toSourceString(long ell) {
|
||||
return (Math.abs(ell) <= Integer.MAX_VALUE) ?
|
||||
String.valueOf(ell) :
|
||||
(String.valueOf(ell) + "L");
|
||||
String str = String.valueOf(ell);
|
||||
return (ell < Integer.MIN_VALUE || ell > Integer.MAX_VALUE)
|
||||
? (str + 'L') : str;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -278,10 +278,7 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
|
||||
sb.append('"');
|
||||
// Escape embedded quote characters, if present, but don't do
|
||||
// anything more heroic.
|
||||
if (s.indexOf('"') != -1) {
|
||||
s = s.replace("\"", "\\\"");
|
||||
}
|
||||
sb.append(s);
|
||||
sb.append(s.replace("\"", "\\\""));
|
||||
sb.append('"');
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -1715,12 +1715,17 @@ public final class SSLEngineImpl extends SSLEngine {
|
||||
|
||||
synchronized void fatal(byte description, String diagnostic)
|
||||
throws SSLException {
|
||||
fatal(description, diagnostic, null);
|
||||
fatal(description, diagnostic, null, false);
|
||||
}
|
||||
|
||||
synchronized void fatal(byte description, Throwable cause)
|
||||
throws SSLException {
|
||||
fatal(description, null, cause);
|
||||
fatal(description, null, cause, false);
|
||||
}
|
||||
|
||||
synchronized void fatal(byte description, String diagnostic,
|
||||
Throwable cause) throws SSLException {
|
||||
fatal(description, diagnostic, cause, false);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1732,12 +1737,12 @@ public final class SSLEngineImpl extends SSLEngine {
|
||||
* levels which then call here. This code needs to determine
|
||||
* if one of the lower levels has already started the process.
|
||||
*
|
||||
* We won't worry about Error's, if we have one of those,
|
||||
* We won't worry about Errors, if we have one of those,
|
||||
* we're in worse trouble. Note: the networking code doesn't
|
||||
* deal with Errors either.
|
||||
*/
|
||||
synchronized void fatal(byte description, String diagnostic,
|
||||
Throwable cause) throws SSLException {
|
||||
Throwable cause, boolean recvFatalAlert) throws SSLException {
|
||||
|
||||
/*
|
||||
* If we have no further information, make a general-purpose
|
||||
@ -1798,10 +1803,11 @@ public final class SSLEngineImpl extends SSLEngine {
|
||||
}
|
||||
|
||||
/*
|
||||
* If we haven't even started handshaking yet, no need
|
||||
* to generate the fatal close alert.
|
||||
* If we haven't even started handshaking yet, or we are the
|
||||
* recipient of a fatal alert, no need to generate a fatal close
|
||||
* alert.
|
||||
*/
|
||||
if (oldState != cs_START) {
|
||||
if (oldState != cs_START && !recvFatalAlert) {
|
||||
sendAlert(Alerts.alert_fatal, description);
|
||||
}
|
||||
|
||||
@ -1841,10 +1847,6 @@ public final class SSLEngineImpl extends SSLEngine {
|
||||
byte level = fragment.get();
|
||||
byte description = fragment.get();
|
||||
|
||||
if (description == -1) { // check for short message
|
||||
fatal(Alerts.alert_illegal_parameter, "Short alert message");
|
||||
}
|
||||
|
||||
if (debug != null && (Debug.isOn("record") ||
|
||||
Debug.isOn("handshake"))) {
|
||||
synchronized (System.out) {
|
||||
@ -1862,7 +1864,9 @@ public final class SSLEngineImpl extends SSLEngine {
|
||||
}
|
||||
|
||||
if (level == Alerts.alert_warning) {
|
||||
if (description == Alerts.alert_close_notify) {
|
||||
if (description == -1) { // check for short message
|
||||
fatal(Alerts.alert_illegal_parameter, "Short alert message");
|
||||
} else if (description == Alerts.alert_close_notify) {
|
||||
if (connectionState == cs_HANDSHAKE) {
|
||||
fatal(Alerts.alert_unexpected_message,
|
||||
"Received close_notify during handshake");
|
||||
@ -1885,10 +1889,14 @@ public final class SSLEngineImpl extends SSLEngine {
|
||||
} else { // fatal or unknown level
|
||||
String reason = "Received fatal alert: "
|
||||
+ Alerts.alertDescription(description);
|
||||
if (closeReason == null) {
|
||||
closeReason = Alerts.getSSLException(description, reason);
|
||||
}
|
||||
fatal(Alerts.alert_unexpected_message, reason);
|
||||
|
||||
// The inbound and outbound queues will be closed as part of
|
||||
// the call to fatal. The handhaker to needs to be set to null
|
||||
// so subsequent calls to getHandshakeStatus will return
|
||||
// NOT_HANDSHAKING.
|
||||
handshaker = null;
|
||||
Throwable cause = Alerts.getSSLException(description, reason);
|
||||
fatal(description, null, cause, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,14 +165,24 @@ JVM_FindLibraryEntry(void *handle, const char *name);
|
||||
JNIEXPORT jboolean JNICALL
|
||||
JVM_IsSupportedJNIVersion(jint version);
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
JVM_GetVmArguments(JNIEnv *env);
|
||||
|
||||
|
||||
/*
|
||||
* java.lang.Throwable
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_FillInStackTrace(JNIEnv *env, jobject throwable);
|
||||
|
||||
/*
|
||||
* java.lang.StackTraceElement
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_GetStackTraceElements(JNIEnv *env, jobject throwable, jobjectArray elements);
|
||||
JVM_InitStackTraceElementArray(JNIEnv *env, jobjectArray elements, jobject throwable);
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_InitStackTraceElement(JNIEnv* env, jobject element, jobject stackFrameInfo);
|
||||
|
||||
/*
|
||||
* java.lang.StackWalker
|
||||
@ -194,12 +204,6 @@ JVM_MoreStackWalk(JNIEnv *env, jobject stackStream, jlong mode, jlong anchor,
|
||||
jint frame_count, jint start_index,
|
||||
jobjectArray frames);
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
JVM_ToStackTraceElement(JNIEnv* env, jobject frame, jobject stackElement);
|
||||
|
||||
JNIEXPORT jobjectArray JNICALL
|
||||
JVM_GetVmArguments(JNIEnv *env);
|
||||
|
||||
/*
|
||||
* java.lang.Thread
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 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,25 +23,21 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Implementation of class StackFrameInfo
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "jni.h"
|
||||
#include "jvm.h"
|
||||
|
||||
#include "java_lang_StackFrameInfo.h"
|
||||
#include "java_lang_StackTraceElement.h"
|
||||
|
||||
|
||||
/*
|
||||
* Class: java_lang_StackFrameInfo
|
||||
* Method: toStackTraceElement0
|
||||
* Signature: (Ljava/lang/StackTraceElement;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_java_lang_StackFrameInfo_toStackTraceElement0
|
||||
(JNIEnv *env, jobject stackframeinfo, jobject stacktraceinfo) {
|
||||
JVM_ToStackTraceElement(env, stackframeinfo, stacktraceinfo);
|
||||
JNIEXPORT void JNICALL Java_java_lang_StackTraceElement_initStackTraceElement
|
||||
(JNIEnv *env, jobject dummy, jobject element, jobject stackframeinfo) {
|
||||
JVM_InitStackTraceElement(env, element, stackframeinfo);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_java_lang_StackTraceElement_initStackTraceElements
|
||||
(JNIEnv *env, jobject dummy, jobjectArray elements, jobject throwable)
|
||||
{
|
||||
JVM_InitStackTraceElementArray(env, elements, throwable);
|
||||
}
|
@ -49,10 +49,3 @@ Java_java_lang_Throwable_fillInStackTrace(JNIEnv *env, jobject throwable, jint d
|
||||
JVM_FillInStackTrace(env, throwable);
|
||||
return throwable;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_java_lang_Throwable_getStackTraceElements(JNIEnv *env,
|
||||
jobject throwable, jobjectArray elements)
|
||||
{
|
||||
JVM_GetStackTraceElements(env, throwable, elements);
|
||||
}
|
||||
|
@ -74,8 +74,13 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
|
||||
this.fGraphicsStatesInt = this.fGraphicsStates.asIntBuffer();
|
||||
this.fGraphicsStatesFloat = this.fGraphicsStates.asFloatBuffer();
|
||||
this.fGraphicsStatesLong = this.fGraphicsStates.asLongBuffer();
|
||||
this.fGraphicsStatesObject = new Object[6]; // clip coordinates + clip types + texture paint image + stroke dash
|
||||
// array + font + font paint
|
||||
this.fGraphicsStatesObject = new Object[8]; // clip coordinates +
|
||||
// clip types +
|
||||
// texture paint image +
|
||||
// stroke dash array +
|
||||
// font + font paint +
|
||||
// linear/radial gradient color +
|
||||
// linear/radial gradient fractions
|
||||
|
||||
// NOTE: All access to the DrawingQueue comes through this OSXSurfaceData instance. Therefore
|
||||
// every instance method of OSXSurfaceData that accesses the fDrawingQueue is synchronized.
|
||||
@ -292,10 +297,10 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
|
||||
@Native static final int kHintsFractionalMetricsIndex = 46;
|
||||
@Native static final int kHintsRenderingIndex = 47;
|
||||
@Native static final int kHintsInterpolationIndex = 48;
|
||||
// live resizing info
|
||||
@Native static final int kCanDrawDuringLiveResizeIndex = 49;
|
||||
//gradient info
|
||||
@Native static final int kRadiusIndex = 49;
|
||||
|
||||
@Native static final int kSizeOfParameters = kCanDrawDuringLiveResizeIndex + 1;
|
||||
@Native static final int kSizeOfParameters = kRadiusIndex + 1;
|
||||
|
||||
// for objectParameters
|
||||
@Native static final int kClipCoordinatesIndex = 0;
|
||||
@ -304,6 +309,8 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
|
||||
@Native static final int kStrokeDashArrayIndex = 3;
|
||||
@Native static final int kFontIndex = 4;
|
||||
@Native static final int kFontPaintIndex = 5;
|
||||
@Native static final int kColorArrayIndex = 6;
|
||||
@Native static final int kFractionsArrayIndex = 7;
|
||||
|
||||
// possible state changes
|
||||
@Native static final int kBoundsChangedBit = 1 << 0;
|
||||
@ -329,6 +336,8 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
|
||||
@Native static final int kColorSystem = 1;
|
||||
@Native static final int kColorGradient = 2;
|
||||
@Native static final int kColorTexture = 3;
|
||||
@Native static final int kColorLinearGradient = 4;
|
||||
@Native static final int kColorRadialGradient = 5;
|
||||
|
||||
// possible gradient color states
|
||||
@Native static final int kColorNonCyclic = 0;
|
||||
@ -522,6 +531,28 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
|
||||
int lastPaintIndex = 0;
|
||||
BufferedImage texturePaintImage = null;
|
||||
|
||||
void setGradientViaRasterPath(SunGraphics2D sg2d) {
|
||||
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint) || ((this.fChangeFlag & kBoundsChangedBit) != 0)) {
|
||||
PaintContext context = sg2d.paint.createContext(sg2d.getDeviceColorModel(), userBounds, userBounds, sIdentityMatrix, sg2d.getRenderingHints());
|
||||
WritableRaster raster = (WritableRaster) (context.getRaster(userBounds.x, userBounds.y, userBounds.width, userBounds.height));
|
||||
ColorModel cm = context.getColorModel();
|
||||
texturePaintImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null);
|
||||
|
||||
this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture);
|
||||
this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth());
|
||||
this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight());
|
||||
this.fGraphicsStatesFloat.put(kColortxIndex, (float) userBounds.getX());
|
||||
this.fGraphicsStatesFloat.put(kColortyIndex, (float) userBounds.getY());
|
||||
this.fGraphicsStatesFloat.put(kColorsxIndex, 1.0f);
|
||||
this.fGraphicsStatesFloat.put(kColorsyIndex, 1.0f);
|
||||
this.fGraphicsStatesObject[kTextureImageIndex] = OSXOffScreenSurfaceData.createNewSurface(texturePaintImage);
|
||||
|
||||
this.fChangeFlag = (this.fChangeFlag | kColorChangedBit);
|
||||
} else {
|
||||
this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit);
|
||||
}
|
||||
}
|
||||
|
||||
void setupPaint(SunGraphics2D sg2d, int x, int y, int w, int h) {
|
||||
if (sg2d.paint instanceof SystemColor) {
|
||||
SystemColor color = (SystemColor) sg2d.paint;
|
||||
@ -567,6 +598,75 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
|
||||
} else {
|
||||
this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit);
|
||||
}
|
||||
} else if (sg2d.paint instanceof LinearGradientPaint) {
|
||||
LinearGradientPaint color = (LinearGradientPaint) sg2d.paint;
|
||||
if (color.getCycleMethod() == LinearGradientPaint.CycleMethod.NO_CYCLE) {
|
||||
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorLinearGradient) || (lastPaint != sg2d.paint)) {
|
||||
|
||||
this.fGraphicsStatesInt.put(kColorStateIndex, kColorLinearGradient);
|
||||
int numColor = color.getColors().length;
|
||||
int colorArray[] = new int[numColor];
|
||||
for (int i = 0; i < numColor; i++) {
|
||||
colorArray[i] = color.getColors()[i].getRGB();
|
||||
}
|
||||
this.fGraphicsStatesObject[kColorArrayIndex] = colorArray;
|
||||
|
||||
int numFractions = color.getFractions().length;
|
||||
float fractionArray[] = new float[numFractions];
|
||||
for (int i = 0; i < numFractions; i++) {
|
||||
fractionArray[i] = color.getFractions()[i];
|
||||
}
|
||||
this.fGraphicsStatesObject[kFractionsArrayIndex] = color.getFractions();
|
||||
|
||||
Point2D p = color.getStartPoint();
|
||||
this.fGraphicsStatesFloat.put(kColorx1Index, (float) p.getX());
|
||||
this.fGraphicsStatesFloat.put(kColory1Index, (float) p.getY());
|
||||
p = color.getEndPoint();
|
||||
this.fGraphicsStatesFloat.put(kColorx2Index, (float) p.getX());
|
||||
this.fGraphicsStatesFloat.put(kColory2Index, (float) p.getY());
|
||||
|
||||
this.fChangeFlag = (this.fChangeFlag | kColorChangedBit);
|
||||
} else {
|
||||
this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit);
|
||||
}
|
||||
} else {
|
||||
setGradientViaRasterPath(sg2d);
|
||||
}
|
||||
} else if (sg2d.paint instanceof RadialGradientPaint) {
|
||||
RadialGradientPaint color = (RadialGradientPaint) sg2d.paint;
|
||||
if (color.getCycleMethod() == RadialGradientPaint.CycleMethod.NO_CYCLE) {
|
||||
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorRadialGradient) || (lastPaint != sg2d.paint)) {
|
||||
|
||||
this.fGraphicsStatesInt.put(kColorStateIndex, kColorRadialGradient);
|
||||
int numColor = color.getColors().length;
|
||||
int colorArray[] = new int[numColor];
|
||||
for (int i = 0; i < numColor; i++) {
|
||||
colorArray[i] = color.getColors()[i].getRGB();
|
||||
}
|
||||
this.fGraphicsStatesObject[kColorArrayIndex] = colorArray;
|
||||
|
||||
int numStops = color.getFractions().length;
|
||||
float stopsArray[] = new float[numStops];
|
||||
for (int i = 0; i < numStops; i++) {
|
||||
stopsArray[i] = color.getFractions()[i];
|
||||
}
|
||||
this.fGraphicsStatesObject[kFractionsArrayIndex] = color.getFractions();
|
||||
|
||||
Point2D p = color.getFocusPoint();
|
||||
this.fGraphicsStatesFloat.put(kColorx1Index, (float) p.getX());
|
||||
this.fGraphicsStatesFloat.put(kColory1Index, (float) p.getY());
|
||||
p = color.getCenterPoint();
|
||||
this.fGraphicsStatesFloat.put(kColorx2Index, (float) p.getX());
|
||||
this.fGraphicsStatesFloat.put(kColory2Index, (float) p.getY());
|
||||
this.fGraphicsStatesFloat.put(kRadiusIndex, color.getRadius());
|
||||
|
||||
this.fChangeFlag = (this.fChangeFlag | kColorChangedBit);
|
||||
} else {
|
||||
this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit);
|
||||
}
|
||||
} else {
|
||||
setGradientViaRasterPath(sg2d);
|
||||
}
|
||||
} else if (sg2d.paint instanceof TexturePaint) {
|
||||
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint)) {
|
||||
TexturePaint color = (TexturePaint) sg2d.paint;
|
||||
@ -587,27 +687,7 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
|
||||
this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit);
|
||||
}
|
||||
} else {
|
||||
if ((this.fGraphicsStatesInt.get(kColorStateIndex) != kColorTexture) || (lastPaint != sg2d.paint) || ((this.fChangeFlag & kBoundsChangedBit) != 0)) {
|
||||
PaintContext context = sg2d.paint.createContext(sg2d.getDeviceColorModel(), userBounds, userBounds, sIdentityMatrix, sg2d.getRenderingHints());
|
||||
WritableRaster raster = (WritableRaster) (context.getRaster(userBounds.x, userBounds.y, userBounds.width, userBounds.height));
|
||||
ColorModel cm = context.getColorModel();
|
||||
texturePaintImage = new BufferedImage(cm, raster, cm.isAlphaPremultiplied(), null);
|
||||
|
||||
this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture);
|
||||
this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth());
|
||||
this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight());
|
||||
this.fGraphicsStatesFloat.put(kColortxIndex, (float) userBounds.getX());
|
||||
this.fGraphicsStatesFloat.put(kColortyIndex, (float) userBounds.getY());
|
||||
this.fGraphicsStatesFloat.put(kColorsxIndex, 1.0f);
|
||||
this.fGraphicsStatesFloat.put(kColorsyIndex, 1.0f);
|
||||
this.fGraphicsStatesObject[kTextureImageIndex] = sun.awt.image.BufImgSurfaceData.createData(texturePaintImage);
|
||||
|
||||
context.dispose();
|
||||
|
||||
this.fChangeFlag = (this.fChangeFlag | kColorChangedBit);
|
||||
} else {
|
||||
this.fChangeFlag = (this.fChangeFlag & kColorNotChangedBit);
|
||||
}
|
||||
setGradientViaRasterPath(sg2d);
|
||||
}
|
||||
lastPaint = sg2d.paint;
|
||||
}
|
||||
|
@ -178,12 +178,6 @@ public final class CPrinterJob extends RasterPrinterJob {
|
||||
return;
|
||||
}
|
||||
|
||||
// See if this has an NSPrintInfo in it.
|
||||
NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
|
||||
if (nsPrintInfo != null) {
|
||||
fNSPrintInfo = nsPrintInfo.getValue();
|
||||
}
|
||||
|
||||
PageRanges pageRangesAttr = (PageRanges)attributes.get(PageRanges.class);
|
||||
if (isSupportedValue(pageRangesAttr, attributes)) {
|
||||
SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
|
||||
@ -563,8 +557,11 @@ public final class CPrinterJob extends RasterPrinterJob {
|
||||
|
||||
@Override
|
||||
protected void finalize() {
|
||||
if (fNSPrintInfo != -1) {
|
||||
dispose(fNSPrintInfo);
|
||||
synchronized (fNSPrintInfoLock) {
|
||||
if (fNSPrintInfo != -1) {
|
||||
dispose(fNSPrintInfo);
|
||||
}
|
||||
fNSPrintInfo = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@ enum SDRenderType
|
||||
SD_Fill,
|
||||
SD_EOFill,
|
||||
SD_Shade,
|
||||
SD_LinearGradient,
|
||||
SD_RadialGradient,
|
||||
SD_Pattern,
|
||||
SD_Image,
|
||||
SD_Text,
|
||||
@ -65,6 +67,17 @@ struct _stateShadingInfo
|
||||
};
|
||||
typedef struct _stateShadingInfo StateShadingInfo;
|
||||
|
||||
struct _stateGradientInfo
|
||||
{
|
||||
CGPoint start;
|
||||
CGPoint end;
|
||||
CGFloat radius;
|
||||
CGFloat* colordata;
|
||||
CGFloat* fractionsdata;
|
||||
jint fractionsLength;
|
||||
};
|
||||
typedef struct _stateGradientInfo StateGradientInfo;
|
||||
|
||||
struct _statePatternInfo
|
||||
{
|
||||
CGFloat tx;
|
||||
@ -122,6 +135,7 @@ struct _QuartzSDOps
|
||||
// its callees.
|
||||
|
||||
StateShadingInfo* shadingInfo; // tracks shading and its parameters
|
||||
StateGradientInfo* gradientInfo; // tracks gradient and its parameters
|
||||
StatePatternInfo* patternInfo; // tracks pattern and its parameters
|
||||
StateGraphicsInfo graphicsStateInfo; // tracks other graphics state
|
||||
|
||||
|
@ -268,9 +268,105 @@ PRINT(" gradientPaintReleaseFunction")
|
||||
free(info);
|
||||
}
|
||||
|
||||
static inline void contextQuartzLinearGradientPath(QuartzSDOps* qsdo)
|
||||
{
|
||||
|
||||
PRINT(" contextQuartzLinearGradientPath");
|
||||
|
||||
CGContextRef cgRef = qsdo->cgRef;
|
||||
StateGradientInfo *gradientInfo = qsdo->gradientInfo;
|
||||
|
||||
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
|
||||
size_t num_locations = gradientInfo->fractionsLength;
|
||||
CGFloat *locations = (CGFloat *) malloc(sizeof(CGFloat) * num_locations);
|
||||
int i = 0;
|
||||
size_t component_size = num_locations * 4;
|
||||
CGFloat components[component_size];
|
||||
CGGradientRef gradient = NULL;
|
||||
|
||||
for (int i = 0; i < num_locations; i++) {
|
||||
locations[i] = gradientInfo->fractionsdata[i];
|
||||
//fprintf(stderr, "locations[%d] %f\n", i, locations[i]);
|
||||
}
|
||||
for (i = 0; i < component_size; i++) {
|
||||
components[i] = gradientInfo->colordata[i];
|
||||
//fprintf(stderr, "components[%d] %f, gradientInfo->colordata[%d] %f\n",
|
||||
// i, components[i], i, gradientInfo->colordata[i]);
|
||||
}
|
||||
CGContextSaveGState(cgRef);
|
||||
gradient = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations);
|
||||
//fprintf(stderr, "gradientInfo->start.x %f, gradientInfo->start.y %f\n",
|
||||
// gradientInfo->start.x, gradientInfo->start.y);
|
||||
//fprintf(stderr, "gradientInfo->end.x %f, gradientInfo->end.y %f\n",
|
||||
// gradientInfo->end.x, gradientInfo->end.y);
|
||||
if (qsdo->isEvenOddFill) {
|
||||
CGContextEOClip(cgRef);
|
||||
} else {
|
||||
CGContextClip(cgRef);
|
||||
}
|
||||
CGContextDrawLinearGradient(cgRef, gradient, gradientInfo->start, gradientInfo->end, kCGGradientDrawsAfterEndLocation);
|
||||
|
||||
CGContextRestoreGState(cgRef);
|
||||
CGColorSpaceRelease(colorspace);
|
||||
CGGradientRelease(gradient);
|
||||
free(locations);
|
||||
free(gradientInfo->colordata);
|
||||
free(gradientInfo->fractionsdata);
|
||||
}
|
||||
|
||||
static inline void contextQuartzRadialGradientPath(QuartzSDOps* qsdo)
|
||||
{
|
||||
|
||||
PRINT(" contextQuartzRadialGradientPath");
|
||||
|
||||
CGContextRef cgRef = qsdo->cgRef;
|
||||
StateGradientInfo *gradientInfo = qsdo->gradientInfo;
|
||||
|
||||
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
|
||||
size_t num_locations = gradientInfo->fractionsLength;
|
||||
CGFloat *locations = (CGFloat *) malloc(sizeof(CGFloat) * num_locations);
|
||||
int i = 0;
|
||||
size_t component_size = num_locations * 4;
|
||||
CGFloat components[component_size];
|
||||
CGGradientRef gradient = NULL;
|
||||
CGFloat startRadius = gradientInfo->radius;
|
||||
CGFloat endRadius = gradientInfo->radius;
|
||||
|
||||
for (int i = 0; i < num_locations; i++) {
|
||||
locations[i] = gradientInfo->fractionsdata[i];
|
||||
//fprintf(stderr, "locations[%d] %f\n", i, locations[i]);
|
||||
}
|
||||
for (i = 0; i < component_size; i++) {
|
||||
components[i] = gradientInfo->colordata[i];
|
||||
//fprintf(stderr, "components[%d] %f, gradientInfo->colordata[%d] %f\n",
|
||||
// i, components[i], i, gradientInfo->colordata[i]);
|
||||
}
|
||||
CGContextSaveGState(cgRef);
|
||||
gradient = CGGradientCreateWithColorComponents(colorspace, components, locations, num_locations);
|
||||
//fprintf(stderr, "gradientInfo->start.x %f, gradientInfo->start.y %f\n",
|
||||
// gradientInfo->start.x, gradientInfo->start.y);
|
||||
//fprintf(stderr, "gradientInfo->end.x %f, gradientInfo->end.y %f\n",
|
||||
// gradientInfo->end.x, gradientInfo->end.y);
|
||||
if (qsdo->isEvenOddFill) {
|
||||
CGContextEOClip(cgRef);
|
||||
} else {
|
||||
CGContextClip(cgRef);
|
||||
}
|
||||
//fprintf(stderr, "gradientInfo->startRadius %f, gradientInfo->endRadius %f\n",startRadius,endRadius);
|
||||
CGContextDrawRadialGradient(cgRef, gradient, gradientInfo->start, 0, gradientInfo->end, endRadius, kCGGradientDrawsAfterEndLocation);
|
||||
|
||||
CGContextRestoreGState(cgRef);
|
||||
CGColorSpaceRelease(colorspace);
|
||||
CGGradientRelease(gradient);
|
||||
free(locations);
|
||||
free(gradientInfo->colordata);
|
||||
free(gradientInfo->fractionsdata);
|
||||
}
|
||||
|
||||
static inline void contextGradientPath(QuartzSDOps* qsdo)
|
||||
{
|
||||
PRINT(" ContextGradientPath")
|
||||
|
||||
CGContextRef cgRef = qsdo->cgRef;
|
||||
StateShadingInfo* shadingInfo = qsdo->shadingInfo;
|
||||
|
||||
@ -827,6 +923,81 @@ PRINT(" SetUpCGContext")
|
||||
qsdo->renderType = renderType;
|
||||
}
|
||||
|
||||
void setupGradient(JNIEnv *env, QuartzSDOps* qsdo, jfloat* javaFloatGraphicsStates)
|
||||
{
|
||||
static const CGFloat kColorConversionMultiplier = 1.0f/255.0f;
|
||||
qsdo->gradientInfo = (StateGradientInfo*)malloc(sizeof(StateGradientInfo));
|
||||
if (qsdo->gradientInfo == NULL)
|
||||
{
|
||||
[JNFException raise:env as:kOutOfMemoryError reason:"Failed to malloc memory for gradient paint"];
|
||||
}
|
||||
|
||||
qsdo->graphicsStateInfo.simpleStroke = NO;
|
||||
qsdo->graphicsStateInfo.simpleColor = NO;
|
||||
|
||||
qsdo->gradientInfo->start.x = javaFloatGraphicsStates[sun_java2d_OSXSurfaceData_kColorx1Index];
|
||||
qsdo->gradientInfo->start.y = javaFloatGraphicsStates[sun_java2d_OSXSurfaceData_kColory1Index];
|
||||
qsdo->gradientInfo->end.x = javaFloatGraphicsStates[sun_java2d_OSXSurfaceData_kColorx2Index];
|
||||
qsdo->gradientInfo->end.y = javaFloatGraphicsStates[sun_java2d_OSXSurfaceData_kColory2Index];
|
||||
|
||||
jobject colorArray = ((*env)->GetObjectArrayElement(env, qsdo->javaGraphicsStatesObjects, sun_java2d_OSXSurfaceData_kColorArrayIndex));
|
||||
if (colorArray != NULL)
|
||||
{
|
||||
jint length = (*env)->GetArrayLength(env, colorArray);
|
||||
//fprintf(stderr, "length %d\n", length);
|
||||
|
||||
jint* jcolorData = (jint*)(*env)->GetPrimitiveArrayCritical(env, colorArray, NULL);
|
||||
CGFloat* colors= (CGFloat*)calloc(0, sizeof(CGFloat)*length);
|
||||
if (jcolorData != NULL)
|
||||
{
|
||||
jint i;
|
||||
for (i=0; i<length; i++)
|
||||
{
|
||||
colors[i] = (CGFloat)jcolorData[i];
|
||||
}
|
||||
}
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, colorArray, jcolorData, 0);
|
||||
qsdo->gradientInfo->colordata = (CGFloat*)calloc(0, sizeof(CGFloat)*4*length);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
jint c1 = colors[i];
|
||||
//fprintf(stderr, "c1 %x\n", c1);
|
||||
qsdo->gradientInfo->colordata[i*4] = ((c1>>16)&0xff)*kColorConversionMultiplier;
|
||||
//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4, qsdo->gradientInfo->colordata[i*4]);
|
||||
|
||||
qsdo->gradientInfo->colordata[i*4+1] = ((c1>>8)&0xff)*kColorConversionMultiplier;
|
||||
//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+1, qsdo->gradientInfo->colordata[i*4+1]);
|
||||
|
||||
qsdo->gradientInfo->colordata[i*4+2] = ((c1>>0)&0xff)*kColorConversionMultiplier;
|
||||
//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+2, qsdo->gradientInfo->colordata[i*4+2]);
|
||||
|
||||
qsdo->gradientInfo->colordata[i*4+3] = ((c1>>24)&0xff)*kColorConversionMultiplier;
|
||||
//fprintf(stderr, "qsdo->gradientInfo->colordata[%d] %f\n", i*4+3, qsdo->gradientInfo->colordata[i*4+3]);
|
||||
}
|
||||
free(colors);
|
||||
}
|
||||
jobject fractionsArray = ((*env)->GetObjectArrayElement(env, qsdo->javaGraphicsStatesObjects, sun_java2d_OSXSurfaceData_kFractionsArrayIndex));
|
||||
if (fractionsArray != NULL)
|
||||
{
|
||||
jint length = (*env)->GetArrayLength(env, fractionsArray);
|
||||
//fprintf(stderr, "fractions length %d\n", length);
|
||||
qsdo->gradientInfo->fractionsLength = length;
|
||||
|
||||
jfloat* jfractionsData = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, fractionsArray, NULL);
|
||||
if (jfractionsData != NULL)
|
||||
{
|
||||
qsdo->gradientInfo->fractionsdata = (CGFloat *)malloc(sizeof(CGFloat) *length);
|
||||
jint i;
|
||||
for (i=0; i<length; i++)
|
||||
{
|
||||
qsdo->gradientInfo->fractionsdata[i] = jfractionsData[i];
|
||||
//fprintf(stderr, "jfrationsData[%d] %f, qsdo->gradientInfo->fractionsdata[%d] = %f\n", i, jfractionsData[i], i, qsdo->gradientInfo->fractionsdata[i]);
|
||||
}
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, fractionsArray, jfractionsData, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDRenderType SetUpPaint(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType)
|
||||
{
|
||||
CGContextRef cgRef = qsdo->cgRef;
|
||||
@ -898,6 +1069,21 @@ SDRenderType SetUpPaint(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType)
|
||||
|
||||
break;
|
||||
}
|
||||
case sun_java2d_OSXSurfaceData_kColorLinearGradient:
|
||||
{
|
||||
renderType = SD_LinearGradient;
|
||||
setupGradient(env, qsdo, javaFloatGraphicsStates);
|
||||
break;
|
||||
}
|
||||
|
||||
case sun_java2d_OSXSurfaceData_kColorRadialGradient:
|
||||
{
|
||||
renderType = SD_RadialGradient;
|
||||
setupGradient(env, qsdo, javaFloatGraphicsStates);
|
||||
qsdo->gradientInfo->radius = javaFloatGraphicsStates[sun_java2d_OSXSurfaceData_kRadiusIndex];
|
||||
break;
|
||||
}
|
||||
|
||||
case sun_java2d_OSXSurfaceData_kColorTexture:
|
||||
{
|
||||
qsdo->patternInfo = (StatePatternInfo*)malloc(sizeof(StatePatternInfo));
|
||||
@ -1076,11 +1262,24 @@ PRINT(" CompleteCGContext")
|
||||
}
|
||||
break;
|
||||
|
||||
case SD_LinearGradient:
|
||||
if (CGContextIsPathEmpty(qsdo->cgRef) == 0)
|
||||
{
|
||||
contextQuartzLinearGradientPath(qsdo);
|
||||
}
|
||||
break;
|
||||
|
||||
case SD_RadialGradient:
|
||||
if (CGContextIsPathEmpty(qsdo->cgRef) == 0)
|
||||
{
|
||||
contextQuartzRadialGradientPath(qsdo);
|
||||
}
|
||||
break;
|
||||
|
||||
case SD_Pattern:
|
||||
if (CGContextIsPathEmpty(qsdo->cgRef) == 0)
|
||||
{
|
||||
//TODO:BG
|
||||
//contextTexturePath(env, qsdo);
|
||||
contextTexturePath(env, qsdo);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1111,4 +1310,8 @@ PRINT(" CompleteCGContext")
|
||||
gradientPaintReleaseFunction(qsdo->shadingInfo);
|
||||
qsdo->shadingInfo = NULL;
|
||||
}
|
||||
if (qsdo->gradientInfo != NULL) {
|
||||
gradientPaintReleaseFunction(qsdo->gradientInfo);
|
||||
qsdo->gradientInfo = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2000, 2016, 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
|
||||
@ -58,6 +58,25 @@ image format plug-ins:
|
||||
<th> </th> <th>Reading</th> <th>Writing</th>
|
||||
<th>Notes</th> <th>Metadata</th>
|
||||
</tr>
|
||||
<!-- BMP plugin -->
|
||||
<tr>
|
||||
<td><a href="https://msdn.microsoft.com/en-us/library/dd183391.aspx">BMP</a></td>
|
||||
<td align='center'>yes</td>
|
||||
<td align='center'>yes</td>
|
||||
<td align='center'>none</td>
|
||||
<td align='center'><a href='metadata/doc-files/bmp_metadata.html'>
|
||||
BMP metadata format</a></td>
|
||||
</tr>
|
||||
<!-- GIF plugin -->
|
||||
<tr>
|
||||
<td><a href="http://www.w3.org/Graphics/GIF/spec-gif89a.txt">GIF</a></td>
|
||||
<td align='center'>yes</td>
|
||||
<td align='center'>yes</td>
|
||||
<td align='center'><a href="#gif_plugin_notes">
|
||||
GIF plug-in notes</a></td>
|
||||
<td align='center'><a href='metadata/doc-files/gif_metadata.html'>
|
||||
GIF metadata format</a></td>
|
||||
</tr>
|
||||
<!-- JPEG plugin -->
|
||||
<tr>
|
||||
<td> <a href="http://www.jpeg.org">JPEG</a></td>
|
||||
@ -76,14 +95,15 @@ image format plug-ins:
|
||||
<td align='center'><a href='metadata/doc-files/png_metadata.html'>
|
||||
PNG metadata format</a></td>
|
||||
</tr>
|
||||
<!-- BMP plugin -->
|
||||
<!-- TIFF plugin -->
|
||||
<tr>
|
||||
<td>BMP</td>
|
||||
<td><a href="https://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf">TIFF</a></td>
|
||||
<td align='center'>yes</td>
|
||||
<td align='center'>yes</td>
|
||||
<td align='center'>none</td>
|
||||
<td align='center'><a href='metadata/doc-files/bmp_metadata.html'>
|
||||
BMP metadata format</a></td>
|
||||
<td align='center'><a href='metadata/doc-files/tiff_metadata.html#Reading'>
|
||||
TIFF plug-in notes</td>
|
||||
<td align='center'><a href='metadata/doc-files/tiff_metadata.html#StreamMetadata'>
|
||||
TIFF metadata format</a></td>
|
||||
</tr>
|
||||
<!-- WBMP plugin -->
|
||||
<tr>
|
||||
@ -94,16 +114,6 @@ image format plug-ins:
|
||||
<td align='center'><a href='metadata/doc-files/wbmp_metadata.html'>
|
||||
WBMP metadata format</a></td>
|
||||
</tr>
|
||||
<!-- GIF plugin -->
|
||||
<tr>
|
||||
<td><a href="http://www.w3.org/Graphics/GIF/spec-gif89a.txt">GIF</a></td>
|
||||
<td align='center'>yes</td>
|
||||
<td align='center'>yes</td>
|
||||
<td align='center'><a href="#gif_plugin_notes">
|
||||
GIF plug-in notes</a></td>
|
||||
<td align='center'><a href='metadata/doc-files/gif_metadata.html'>
|
||||
GIF metadata format</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<BR>
|
||||
|
@ -55,9 +55,7 @@ public final class ExifGPSTagSet extends TIFFTagSet {
|
||||
*
|
||||
* @see #TAG_GPS_VERSION_ID
|
||||
*/
|
||||
public static final String GPS_VERSION_2_2 =
|
||||
new String(new byte[] { '2', '2', '0', '0' },
|
||||
StandardCharsets.US_ASCII);
|
||||
public static final String GPS_VERSION_2_2 = "2200";
|
||||
|
||||
/**
|
||||
* A tag indicating the North or South latitude (type ASCII, count = 2).
|
||||
|
@ -71,9 +71,7 @@ public final class ExifTIFFTagSet extends TIFFTagSet {
|
||||
*
|
||||
* @see #TAG_EXIF_VERSION
|
||||
*/
|
||||
public static final String EXIF_VERSION_2_1 =
|
||||
new String(new byte[] { '0', '2', '1', '0' },
|
||||
StandardCharsets.US_ASCII);
|
||||
public static final String EXIF_VERSION_2_1 = "0210";
|
||||
|
||||
/**
|
||||
* A value to be used with the "ExifVersion" tag to indicate Exif version
|
||||
@ -82,9 +80,7 @@ public final class ExifTIFFTagSet extends TIFFTagSet {
|
||||
*
|
||||
* @see #TAG_EXIF_VERSION
|
||||
*/
|
||||
public static final String EXIF_VERSION_2_2 =
|
||||
new String(new byte[] { '0', '2', '2', '0' },
|
||||
StandardCharsets.US_ASCII);
|
||||
public static final String EXIF_VERSION_2_2 = "0220";
|
||||
|
||||
/**
|
||||
* A tag indicating the FlashPix version number (type UNDEFINED,
|
||||
|
@ -261,7 +261,7 @@ import com.sun.imageio.plugins.tiff.TIFFIFD;
|
||||
* @see TIFFDirectory
|
||||
* @see TIFFTag
|
||||
*/
|
||||
public class TIFFField implements Cloneable {
|
||||
public final class TIFFField implements Cloneable {
|
||||
|
||||
private static final String[] typeNames = {
|
||||
null,
|
||||
|
@ -48,7 +48,7 @@ import javax.imageio.ImageReadParam;
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public class TIFFImageReadParam extends ImageReadParam {
|
||||
public final class TIFFImageReadParam extends ImageReadParam {
|
||||
|
||||
private List<TIFFTagSet> allowedTagSets = new ArrayList<TIFFTagSet>(4);
|
||||
|
||||
|
@ -320,28 +320,6 @@ public class JRootPane extends JComponent implements Accessible {
|
||||
* a UI-specific action like pressing the <b>Enter</b> key occurs.
|
||||
*/
|
||||
protected JButton defaultButton;
|
||||
/**
|
||||
* As of Java 2 platform v1.3 this unusable field is no longer used.
|
||||
* To override the default button you should replace the <code>Action</code>
|
||||
* in the <code>JRootPane</code>'s <code>ActionMap</code>. Please refer to
|
||||
* the key bindings specification for further details.
|
||||
*
|
||||
* @deprecated As of Java 2 platform v1.3.
|
||||
* @see #defaultButton
|
||||
*/
|
||||
@Deprecated
|
||||
protected DefaultAction defaultPressAction;
|
||||
/**
|
||||
* As of Java 2 platform v1.3 this unusable field is no longer used.
|
||||
* To override the default button you should replace the <code>Action</code>
|
||||
* in the <code>JRootPane</code>'s <code>ActionMap</code>. Please refer to
|
||||
* the key bindings specification for further details.
|
||||
*
|
||||
* @deprecated As of Java 2 platform v1.3.
|
||||
* @see #defaultButton
|
||||
*/
|
||||
@Deprecated
|
||||
protected DefaultAction defaultReleaseAction;
|
||||
|
||||
/**
|
||||
* Whether or not true double buffering should be used. This is typically
|
||||
@ -829,35 +807,6 @@ public class JRootPane extends JComponent implements Accessible {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
static class DefaultAction extends AbstractAction {
|
||||
JButton owner;
|
||||
JRootPane root;
|
||||
boolean press;
|
||||
DefaultAction(JRootPane root, boolean press) {
|
||||
this.root = root;
|
||||
this.press = press;
|
||||
}
|
||||
public void setOwner(JButton owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (owner != null && SwingUtilities.getRootPane(owner) == root) {
|
||||
ButtonModel model = owner.getModel();
|
||||
if (press) {
|
||||
model.setArmed(true);
|
||||
model.setPressed(true);
|
||||
} else {
|
||||
model.setPressed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean isEnabled() {
|
||||
return owner.getModel().isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overridden to enforce the position of the glass component as
|
||||
* the zero child.
|
||||
|
@ -739,7 +739,7 @@ public class MetalBorders {
|
||||
/**
|
||||
* The instance of {@code MetalBumps}.
|
||||
*/
|
||||
protected MetalBumps bumps = new MetalBumps( 10, 10,
|
||||
private MetalBumps bumps = new MetalBumps( 10, 10,
|
||||
MetalLookAndFeel.getControlHighlight(),
|
||||
MetalLookAndFeel.getControlDarkShadow(),
|
||||
UIManager.getColor("ToolBar.background"));
|
||||
|
@ -923,7 +923,7 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
||||
* @param fc a {@code JFileChooser}
|
||||
* @return a new instance of {@code DirectoryComboBoxRenderer}
|
||||
*/
|
||||
protected DirectoryComboBoxRenderer createDirectoryComboBoxRenderer(JFileChooser fc) {
|
||||
private DefaultListCellRenderer createDirectoryComboBoxRenderer(JFileChooser fc) {
|
||||
return new DirectoryComboBoxRenderer();
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class MetalScrollBarUI extends BasicScrollBarUI
|
||||
/**
|
||||
* The metal bumps.
|
||||
*/
|
||||
protected MetalBumps bumps;
|
||||
private MetalBumps bumps;
|
||||
|
||||
/**
|
||||
* The increase button.
|
||||
|
@ -30,6 +30,9 @@ import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.io.*;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.LinkOption;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@ -243,7 +246,8 @@ public abstract class ShellFolder extends File {
|
||||
if (file instanceof ShellFolder) {
|
||||
return (ShellFolder)file;
|
||||
}
|
||||
if (!file.exists()) {
|
||||
|
||||
if (!Files.exists(file.toPath(), LinkOption.NOFOLLOW_LINKS)) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
return shellFolderManager.createShellFolder(file);
|
||||
|
@ -36,8 +36,8 @@ class NullFontScaler extends FontScaler {
|
||||
boolean supportsCJK, int filesize) {}
|
||||
|
||||
StrikeMetrics getFontMetrics(long pScalerContext) {
|
||||
return new StrikeMetrics(0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
|
||||
0xf0,0xf0,0xf0,0xf0);
|
||||
return new StrikeMetrics(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
float getGlyphAdvance(long pScalerContext, int glyphCode) {
|
||||
@ -71,7 +71,7 @@ class NullFontScaler extends FontScaler {
|
||||
return getNullScalerContext();
|
||||
}
|
||||
|
||||
void invalidateScalerContext(long ppScalerContext) {
|
||||
void invalidateScalerContext(long pScalerContext) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
|
@ -219,6 +219,38 @@ public class GTKKeybindings {
|
||||
"KP_UP", "selectPrevious"
|
||||
|
||||
}),
|
||||
"Desktop.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[] {
|
||||
"ctrl F5", "restore",
|
||||
"ctrl F4", "close",
|
||||
"ctrl F7", "move",
|
||||
"ctrl F8", "resize",
|
||||
"RIGHT", "right",
|
||||
"KP_RIGHT", "right",
|
||||
"shift RIGHT", "shrinkRight",
|
||||
"shift KP_RIGHT", "shrinkRight",
|
||||
"LEFT", "left",
|
||||
"KP_LEFT", "left",
|
||||
"shift LEFT", "shrinkLeft",
|
||||
"shift KP_LEFT", "shrinkLeft",
|
||||
"UP", "up",
|
||||
"KP_UP", "up",
|
||||
"shift UP", "shrinkUp",
|
||||
"shift KP_UP", "shrinkUp",
|
||||
"DOWN", "down",
|
||||
"KP_DOWN", "down",
|
||||
"shift DOWN", "shrinkDown",
|
||||
"shift KP_DOWN", "shrinkDown",
|
||||
"ESCAPE", "escape",
|
||||
"ctrl F9", "minimize",
|
||||
"ctrl F10", "maximize",
|
||||
"ctrl F6", "selectNextFrame",
|
||||
"ctrl TAB", "selectNextFrame",
|
||||
"ctrl alt F6", "selectNextFrame",
|
||||
"shift ctrl alt F6", "selectPreviousFrame",
|
||||
"ctrl F12", "navigateNext",
|
||||
"shift ctrl F12", "navigatePrevious"
|
||||
}),
|
||||
"EditorPane.focusInputMap", multilineInputMap,
|
||||
"FileChooser.ancestorInputMap",
|
||||
new UIDefaults.LazyInputMap(new Object[]{
|
||||
|
@ -58,7 +58,8 @@ public class StackTraceElementCompositeData extends LazyCompositeData {
|
||||
getString(cd, FILE_NAME),
|
||||
getInt(cd, LINE_NUMBER));
|
||||
} else {
|
||||
return new StackTraceElement(getString(cd, MODULE_NAME),
|
||||
return new StackTraceElement(getString(cd, CLASS_LOADER_NAME),
|
||||
getString(cd, MODULE_NAME),
|
||||
getString(cd, MODULE_VERSION),
|
||||
getString(cd, CLASS_NAME),
|
||||
getString(cd, METHOD_NAME),
|
||||
@ -76,13 +77,14 @@ public class StackTraceElementCompositeData extends LazyCompositeData {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// stackTraceElementItemNames!
|
||||
final Object[] stackTraceElementItemValues = {
|
||||
ste.getClassLoaderName(),
|
||||
ste.getModuleName(),
|
||||
ste.getModuleVersion(),
|
||||
ste.getClassName(),
|
||||
ste.getMethodName(),
|
||||
ste.getFileName(),
|
||||
ste.getLineNumber(),
|
||||
ste.isNativeMethod(),
|
||||
ste.getModuleName(),
|
||||
ste.getModuleVersion(),
|
||||
};
|
||||
try {
|
||||
return new CompositeDataSupport(stackTraceElementCompositeType,
|
||||
@ -95,25 +97,29 @@ public class StackTraceElementCompositeData extends LazyCompositeData {
|
||||
}
|
||||
|
||||
// Attribute names
|
||||
private static final String CLASS_NAME = "className";
|
||||
private static final String METHOD_NAME = "methodName";
|
||||
private static final String FILE_NAME = "fileName";
|
||||
private static final String LINE_NUMBER = "lineNumber";
|
||||
private static final String NATIVE_METHOD = "nativeMethod";
|
||||
private static final String MODULE_NAME = "moduleName";
|
||||
private static final String MODULE_VERSION = "moduleVersion";
|
||||
private static final String CLASS_LOADER_NAME = "classLoaderName";
|
||||
private static final String MODULE_NAME = "moduleName";
|
||||
private static final String MODULE_VERSION = "moduleVersion";
|
||||
private static final String CLASS_NAME = "className";
|
||||
private static final String METHOD_NAME = "methodName";
|
||||
private static final String FILE_NAME = "fileName";
|
||||
private static final String LINE_NUMBER = "lineNumber";
|
||||
private static final String NATIVE_METHOD = "nativeMethod";
|
||||
|
||||
|
||||
private static final String[] stackTraceElementItemNames = {
|
||||
CLASS_LOADER_NAME,
|
||||
MODULE_NAME,
|
||||
MODULE_VERSION,
|
||||
CLASS_NAME,
|
||||
METHOD_NAME,
|
||||
FILE_NAME,
|
||||
LINE_NUMBER,
|
||||
NATIVE_METHOD,
|
||||
MODULE_NAME,
|
||||
MODULE_VERSION,
|
||||
};
|
||||
|
||||
private static final String[] stackTraceElementV9ItemNames = {
|
||||
CLASS_LOADER_NAME,
|
||||
MODULE_NAME,
|
||||
MODULE_VERSION,
|
||||
};
|
||||
|
@ -102,6 +102,11 @@ public class TCPTransport extends Transport {
|
||||
AccessController.doPrivileged((PrivilegedAction<Long>) () ->
|
||||
Long.getLong("sun.rmi.transport.tcp.threadKeepAliveTime", 60000));
|
||||
|
||||
/** enable multiplexing protocol */
|
||||
private static final boolean enableMultiplexProtocol = // default false
|
||||
AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
|
||||
Boolean.getBoolean("sun.rmi.transport.tcp.enableMultiplexProtocol"));
|
||||
|
||||
/** thread pool for connection handlers */
|
||||
private static final ExecutorService connectionThreadPool =
|
||||
new ThreadPoolExecutor(0, maxConnectionThreads,
|
||||
@ -796,6 +801,19 @@ public class TCPTransport extends Transport {
|
||||
break;
|
||||
|
||||
case TransportConstants.MultiplexProtocol:
|
||||
|
||||
if (!enableMultiplexProtocol) {
|
||||
if (tcpLog.isLoggable(Log.VERBOSE)) {
|
||||
tcpLog.log(Log.VERBOSE, "(port " + port +
|
||||
") rejecting multiplex protocol");
|
||||
}
|
||||
|
||||
// If MultiplexProtocol is disabled, send NACK immediately.
|
||||
out.writeByte(TransportConstants.ProtocolNack);
|
||||
out.flush();
|
||||
break;
|
||||
}
|
||||
|
||||
if (tcpLog.isLoggable(Log.VERBOSE)) {
|
||||
tcpLog.log(Log.VERBOSE, "(port " + port +
|
||||
") accepting multiplex protocol");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, 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
|
||||
@ -295,7 +295,7 @@ public interface CallableStatement extends PreparedStatement {
|
||||
* or <code>getBigDecimal(String parameterName)</code>
|
||||
* @see #setBigDecimal
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
BigDecimal getBigDecimal(int parameterIndex, int scale)
|
||||
throws SQLException;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, 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
|
||||
@ -58,7 +58,7 @@ public class Date extends java.util.Date {
|
||||
* @param day 1 to 31
|
||||
* @deprecated instead use the constructor <code>Date(long date)</code>
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public Date(int year, int month, int day) {
|
||||
super(year, month, day);
|
||||
}
|
||||
@ -199,7 +199,7 @@ public class Date extends java.util.Date {
|
||||
* @exception java.lang.IllegalArgumentException if this method is invoked
|
||||
* @see #setHours
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public int getHours() {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -212,7 +212,7 @@ public class Date extends java.util.Date {
|
||||
* @exception java.lang.IllegalArgumentException if this method is invoked
|
||||
* @see #setMinutes
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public int getMinutes() {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -225,7 +225,7 @@ public class Date extends java.util.Date {
|
||||
* @exception java.lang.IllegalArgumentException if this method is invoked
|
||||
* @see #setSeconds
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public int getSeconds() {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -238,7 +238,7 @@ public class Date extends java.util.Date {
|
||||
* @exception java.lang.IllegalArgumentException if this method is invoked
|
||||
* @see #getHours
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public void setHours(int i) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -251,7 +251,7 @@ public class Date extends java.util.Date {
|
||||
* @exception java.lang.IllegalArgumentException if this method is invoked
|
||||
* @see #getMinutes
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public void setMinutes(int i) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -264,7 +264,7 @@ public class Date extends java.util.Date {
|
||||
* @exception java.lang.IllegalArgumentException if this method is invoked
|
||||
* @see #getSeconds
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public void setSeconds(int i) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, 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
|
||||
@ -515,7 +515,7 @@ public class DriverManager {
|
||||
* @see SecurityManager#checkPermission
|
||||
* @see #getLogStream
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public static void setLogStream(java.io.PrintStream out) {
|
||||
|
||||
SecurityManager sec = System.getSecurityManager();
|
||||
@ -538,7 +538,7 @@ public class DriverManager {
|
||||
* @deprecated Use {@code getLogWriter}
|
||||
* @see #setLogStream
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public static java.io.PrintStream getLogStream() {
|
||||
return logStream;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, 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
|
||||
@ -344,7 +344,7 @@ public interface PreparedStatement extends Statement {
|
||||
* this method
|
||||
* @deprecated Use {@code setCharacterStream}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
void setUnicodeStream(int parameterIndex, java.io.InputStream x,
|
||||
int length) throws SQLException;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, 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
|
||||
@ -358,7 +358,7 @@ public interface ResultSet extends Wrapper, AutoCloseable {
|
||||
* @deprecated Use {@code getBigDecimal(int columnIndex)}
|
||||
* or {@code getBigDecimal(String columnLabel)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException;
|
||||
|
||||
/**
|
||||
@ -478,7 +478,7 @@ public interface ResultSet extends Wrapper, AutoCloseable {
|
||||
* @deprecated use <code>getCharacterStream</code> in place of
|
||||
* <code>getUnicodeStream</code>
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
java.io.InputStream getUnicodeStream(int columnIndex) throws SQLException;
|
||||
|
||||
/**
|
||||
@ -646,7 +646,7 @@ public interface ResultSet extends Wrapper, AutoCloseable {
|
||||
* @deprecated Use {@code getBigDecimal(int columnIndex)}
|
||||
* or {@code getBigDecimal(String columnLabel)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException;
|
||||
|
||||
/**
|
||||
@ -764,7 +764,7 @@ public interface ResultSet extends Wrapper, AutoCloseable {
|
||||
* this method
|
||||
* @deprecated use <code>getCharacterStream</code> instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
java.io.InputStream getUnicodeStream(String columnLabel) throws SQLException;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, 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
|
||||
@ -60,7 +60,7 @@ public class Time extends java.util.Date {
|
||||
* @deprecated Use the constructor that takes a milliseconds value
|
||||
* in place of this constructor
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public Time(int hour, int minute, int second) {
|
||||
super(70, 0, 1, hour, minute, second);
|
||||
}
|
||||
@ -146,7 +146,7 @@ public class Time extends java.util.Date {
|
||||
* method is invoked
|
||||
* @see #setYear
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public int getYear() {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -160,7 +160,7 @@ public class Time extends java.util.Date {
|
||||
* method is invoked
|
||||
* @see #setMonth
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public int getMonth() {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -173,7 +173,7 @@ public class Time extends java.util.Date {
|
||||
* @exception java.lang.IllegalArgumentException if this
|
||||
* method is invoked
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public int getDay() {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -187,7 +187,7 @@ public class Time extends java.util.Date {
|
||||
* method is invoked
|
||||
* @see #setDate
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public int getDate() {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -201,7 +201,7 @@ public class Time extends java.util.Date {
|
||||
* method is invoked
|
||||
* @see #getYear
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public void setYear(int i) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -215,7 +215,7 @@ public class Time extends java.util.Date {
|
||||
* method is invoked
|
||||
* @see #getMonth
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public void setMonth(int i) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
@ -229,7 +229,7 @@ public class Time extends java.util.Date {
|
||||
* method is invoked
|
||||
* @see #getDate
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public void setDate(int i) {
|
||||
throw new java.lang.IllegalArgumentException();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, 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
|
||||
@ -88,7 +88,7 @@ public class Timestamp extends java.util.Date {
|
||||
* @deprecated instead use the constructor {@code Timestamp(long millis)}
|
||||
* @exception IllegalArgumentException if the nano argument is out of bounds
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(since="1.2")
|
||||
public Timestamp(int year, int month, int date,
|
||||
int hour, int minute, int second, int nano) {
|
||||
super(year, month, date, hour, minute, second);
|
||||
|
149
jdk/src/jdk.editpad/share/classes/jdk/editpad/EditPad.java
Normal file
149
jdk/src/jdk.editpad/share/classes/jdk/editpad/EditPad.java
Normal file
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.editpad;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.Consumer;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
/**
|
||||
* A minimal Swing editor as a fallback when the user does not specify an
|
||||
* external editor.
|
||||
*/
|
||||
class EditPad implements Runnable {
|
||||
|
||||
private static final String L10N_RB_NAME = "jdk.editpad.resources.l10n";
|
||||
private ResourceBundle rb = null;
|
||||
private final String windowLabel;
|
||||
private final Consumer<String> errorHandler;
|
||||
private final String initialText;
|
||||
private final Runnable closeMark;
|
||||
private final Consumer<String> saveHandler;
|
||||
|
||||
/**
|
||||
* Create an Edit Pad minimal editor.
|
||||
*
|
||||
* @param windowLabel the label string for the Edit Pad window
|
||||
* @param errorHandler a handler for unexpected errors
|
||||
* @param initialText the source to load in the Edit Pad
|
||||
* @param closeMark a Runnable that is run when Edit Pad closes
|
||||
* @param saveHandler a handler for changed source (sent the full source)
|
||||
*/
|
||||
EditPad(String windowLabel, Consumer<String> errorHandler, String initialText,
|
||||
Runnable closeMark, Consumer<String> saveHandler) {
|
||||
this.windowLabel = windowLabel;
|
||||
this.errorHandler = errorHandler;
|
||||
this.initialText = initialText;
|
||||
this.closeMark = closeMark;
|
||||
this.saveHandler = saveHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JFrame jframe = new JFrame(windowLabel == null
|
||||
? getResourceString("editpad.name")
|
||||
: windowLabel);
|
||||
Runnable closer = () -> {
|
||||
jframe.setVisible(false);
|
||||
jframe.dispose();
|
||||
closeMark.run();
|
||||
};
|
||||
jframe.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
closer.run();
|
||||
}
|
||||
});
|
||||
jframe.setLocationRelativeTo(null);
|
||||
jframe.setLayout(new BorderLayout());
|
||||
JTextArea textArea = new JTextArea(initialText);
|
||||
textArea.setFont(new Font("monospaced", Font.PLAIN, 13));
|
||||
jframe.add(new JScrollPane(textArea), BorderLayout.CENTER);
|
||||
jframe.add(buttons(closer, textArea), BorderLayout.SOUTH);
|
||||
|
||||
jframe.setSize(800, 600);
|
||||
jframe.setVisible(true);
|
||||
}
|
||||
|
||||
private JPanel buttons(Runnable closer, JTextArea textArea) {
|
||||
FlowLayout flow = new FlowLayout();
|
||||
flow.setHgap(35);
|
||||
JPanel buttons = new JPanel(flow);
|
||||
addButton(buttons, "editpad.cancel", KeyEvent.VK_C, e -> {
|
||||
closer.run();
|
||||
});
|
||||
addButton(buttons, "editpad.accept", KeyEvent.VK_A, e -> {
|
||||
saveHandler.accept(textArea.getText());
|
||||
});
|
||||
addButton(buttons, "editpad.exit", KeyEvent.VK_X, e -> {
|
||||
saveHandler.accept(textArea.getText());
|
||||
closer.run();
|
||||
});
|
||||
return buttons;
|
||||
}
|
||||
|
||||
private void addButton(JPanel buttons, String rkey, int mnemonic, ActionListener action) {
|
||||
JButton but = new JButton(getResourceString(rkey));
|
||||
but.setMnemonic(mnemonic);
|
||||
buttons.add(but);
|
||||
but.addActionListener(action);
|
||||
}
|
||||
|
||||
private String getResourceString(String key) {
|
||||
if (rb == null) {
|
||||
try {
|
||||
rb = ResourceBundle.getBundle(L10N_RB_NAME);
|
||||
} catch (MissingResourceException mre) {
|
||||
error("Cannot find ResourceBundle: %s", L10N_RB_NAME);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
String s;
|
||||
try {
|
||||
s = rb.getString(key);
|
||||
} catch (MissingResourceException mre) {
|
||||
error("Missing resource: %s in %s", key, L10N_RB_NAME);
|
||||
return "";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private void error(String fmt, Object... args) {
|
||||
errorHandler.accept(String.format(fmt, args));
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.editpad;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.function.Consumer;
|
||||
import javax.swing.SwingUtilities;
|
||||
import jdk.internal.editor.spi.BuildInEditorProvider;
|
||||
|
||||
/**
|
||||
* Defines the provider of an Edit Pad implementation.
|
||||
*
|
||||
* @author Robert Field
|
||||
*/
|
||||
public class EditPadProvider implements BuildInEditorProvider {
|
||||
|
||||
/**
|
||||
* @return the rank of a provider, greater is better.
|
||||
*/
|
||||
@Override
|
||||
public int rank() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Edit Pad minimal editor.
|
||||
*
|
||||
* @param windowLabel the label string for the Edit Pad window, or null,
|
||||
* for default window label
|
||||
* @param initialText the source to load in the Edit Pad
|
||||
* @param saveHandler a handler for changed source (can be sent the full source)
|
||||
* @param errorHandler a handler for unexpected errors
|
||||
*/
|
||||
@Override
|
||||
public void edit(String windowLabel, String initialText,
|
||||
Consumer<String> saveHandler, Consumer<String> errorHandler) {
|
||||
CountDownLatch closeLock = new CountDownLatch(1);
|
||||
SwingUtilities.invokeLater(
|
||||
new EditPad(windowLabel, errorHandler, initialText, closeLock::countDown, saveHandler));
|
||||
do {
|
||||
try {
|
||||
closeLock.await();
|
||||
break;
|
||||
} catch (InterruptedException ex) {
|
||||
// ignore and loop
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
#
|
||||
# Copyright (c) 2016, 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
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
editpad.name = Edit Pad
|
||||
editpad.cancel = Cancel
|
||||
editpad.accept = Accept
|
||||
editpad.exit = Exit
|
34
jdk/src/jdk.editpad/share/classes/module-info.java
Normal file
34
jdk/src/jdk.editpad/share/classes/module-info.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the edit pad service.
|
||||
*/
|
||||
module jdk.editpad {
|
||||
requires jdk.internal.ed;
|
||||
requires java.desktop;
|
||||
provides jdk.internal.editor.spi.BuildInEditorProvider
|
||||
with jdk.editpad.EditPadProvider;
|
||||
}
|
192
jdk/src/jdk.internal.ed/share/classes/jdk/internal/editor/external/ExternalEditor.java
vendored
Normal file
192
jdk/src/jdk.internal.ed/share/classes/jdk/internal/editor/external/ExternalEditor.java
vendored
Normal file
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.internal.editor.external;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.ClosedWatchServiceException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.WatchKey;
|
||||
import java.nio.file.WatchService;
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
|
||||
import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
|
||||
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
|
||||
|
||||
/**
|
||||
* Wrapper for controlling an external editor.
|
||||
*/
|
||||
public class ExternalEditor {
|
||||
private final Consumer<String> errorHandler;
|
||||
private final Consumer<String> saveHandler;
|
||||
private final boolean wait;
|
||||
|
||||
private final Runnable suspendInteractiveInput;
|
||||
private final Runnable resumeInteractiveInput;
|
||||
private final Runnable promptForNewLineToEndWait;
|
||||
|
||||
private WatchService watcher;
|
||||
private Thread watchedThread;
|
||||
private Path dir;
|
||||
private Path tmpfile;
|
||||
|
||||
/**
|
||||
* Launch an external editor.
|
||||
*
|
||||
* @param cmd the command to launch (with parameters)
|
||||
* @param initialText initial text in the editor buffer
|
||||
* @param errorHandler handler for error messages
|
||||
* @param saveHandler handler sent the buffer contents on save
|
||||
* @param suspendInteractiveInput a callback to suspend caller (shell) input
|
||||
* @param resumeInteractiveInput a callback to resume caller input
|
||||
* @param wait true, if editor process termination cannot be used to
|
||||
* determine when done
|
||||
* @param promptForNewLineToEndWait a callback to prompt for newline if
|
||||
* wait==true
|
||||
*/
|
||||
public static void edit(String[] cmd, String initialText,
|
||||
Consumer<String> errorHandler,
|
||||
Consumer<String> saveHandler,
|
||||
Runnable suspendInteractiveInput,
|
||||
Runnable resumeInteractiveInput,
|
||||
boolean wait,
|
||||
Runnable promptForNewLineToEndWait) {
|
||||
ExternalEditor ed = new ExternalEditor(errorHandler, saveHandler, suspendInteractiveInput,
|
||||
resumeInteractiveInput, wait, promptForNewLineToEndWait);
|
||||
ed.edit(cmd, initialText);
|
||||
}
|
||||
|
||||
ExternalEditor(Consumer<String> errorHandler,
|
||||
Consumer<String> saveHandler,
|
||||
Runnable suspendInteractiveInput,
|
||||
Runnable resumeInteractiveInput,
|
||||
boolean wait,
|
||||
Runnable promptForNewLineToEndWait) {
|
||||
this.errorHandler = errorHandler;
|
||||
this.saveHandler = saveHandler;
|
||||
this.wait = wait;
|
||||
this.suspendInteractiveInput = suspendInteractiveInput;
|
||||
this.resumeInteractiveInput = resumeInteractiveInput;
|
||||
this.promptForNewLineToEndWait = promptForNewLineToEndWait;
|
||||
}
|
||||
|
||||
private void edit(String[] cmd, String initialText) {
|
||||
try {
|
||||
setupWatch(initialText);
|
||||
launch(cmd);
|
||||
} catch (IOException ex) {
|
||||
errorHandler.accept(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a WatchService and registers the given directory
|
||||
*/
|
||||
private void setupWatch(String initialText) throws IOException {
|
||||
this.watcher = FileSystems.getDefault().newWatchService();
|
||||
this.dir = Files.createTempDirectory("extedit");
|
||||
this.tmpfile = Files.createTempFile(dir, null, ".java");
|
||||
Files.write(tmpfile, initialText.getBytes(Charset.forName("UTF-8")));
|
||||
dir.register(watcher,
|
||||
ENTRY_CREATE,
|
||||
ENTRY_DELETE,
|
||||
ENTRY_MODIFY);
|
||||
watchedThread = new Thread(() -> {
|
||||
for (;;) {
|
||||
WatchKey key;
|
||||
try {
|
||||
key = watcher.take();
|
||||
} catch (ClosedWatchServiceException ex) {
|
||||
// The watch service has been closed, we are done
|
||||
break;
|
||||
} catch (InterruptedException ex) {
|
||||
// tolerate an interrupt
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!key.pollEvents().isEmpty()) {
|
||||
saveFile();
|
||||
}
|
||||
|
||||
boolean valid = key.reset();
|
||||
if (!valid) {
|
||||
// The watch service has been closed, we are done
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
watchedThread.start();
|
||||
}
|
||||
|
||||
private void launch(String[] cmd) throws IOException {
|
||||
String[] params = Arrays.copyOf(cmd, cmd.length + 1);
|
||||
params[cmd.length] = tmpfile.toString();
|
||||
ProcessBuilder pb = new ProcessBuilder(params);
|
||||
pb = pb.inheritIO();
|
||||
|
||||
try {
|
||||
suspendInteractiveInput.run();
|
||||
Process process = pb.start();
|
||||
// wait to exit edit mode in one of these ways...
|
||||
if (wait) {
|
||||
// -wait option -- ignore process exit, wait for carriage-return
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
promptForNewLineToEndWait.run();
|
||||
scanner.nextLine();
|
||||
} else {
|
||||
// wait for process to exit
|
||||
process.waitFor();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
errorHandler.accept("process IO failure: " + ex.getMessage());
|
||||
} catch (InterruptedException ex) {
|
||||
errorHandler.accept("process interrupt: " + ex.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
watcher.close();
|
||||
watchedThread.join(); //so that saveFile() is finished.
|
||||
saveFile();
|
||||
} catch (InterruptedException ex) {
|
||||
errorHandler.accept("process interrupt: " + ex.getMessage());
|
||||
} finally {
|
||||
resumeInteractiveInput.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFile() {
|
||||
try {
|
||||
saveHandler.accept(Files.lines(tmpfile).collect(Collectors.joining("\n", "", "\n")));
|
||||
} catch (IOException ex) {
|
||||
errorHandler.accept("Failure in read edit file: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 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,42 +23,29 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.lwawt.macosx;
|
||||
package jdk.internal.editor.spi;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import java.io.*;
|
||||
import javax.print.attribute.*;
|
||||
/**
|
||||
* Defines the provider of a built-in editor.
|
||||
*/
|
||||
public interface BuildInEditorProvider {
|
||||
|
||||
@SuppressWarnings("serial") // JDK implementation class
|
||||
public final class NSPrintInfo implements PrintJobAttribute, PrintRequestAttribute, Serializable, Cloneable {
|
||||
/**
|
||||
* @return the rank of a provider, greater is better.
|
||||
*/
|
||||
int rank();
|
||||
|
||||
private long fNSPrintInfo;
|
||||
|
||||
public NSPrintInfo(long nsPrintInfo) {
|
||||
fNSPrintInfo = nsPrintInfo;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return fNSPrintInfo;
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
return (object != null && object instanceof NSPrintInfo && fNSPrintInfo == ((NSPrintInfo)object).fNSPrintInfo);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (int)fNSPrintInfo;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + fNSPrintInfo;
|
||||
}
|
||||
|
||||
public Class<? extends Attribute> getCategory() {
|
||||
return NSPrintInfo.class;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "nsPrintInfo";
|
||||
}
|
||||
/**
|
||||
* Create a simple built-in editor.
|
||||
*
|
||||
* @param windowLabel the label string for the Edit Pad window, or null,
|
||||
* for default window label
|
||||
* @param initialText the source to load in the Edit Pad
|
||||
* @param saveHandler a handler for changed source (can be sent the full source)
|
||||
* @param errorHandler a handler for unexpected errors
|
||||
*/
|
||||
void edit(String windowLabel, String initialText,
|
||||
Consumer<String> saveHandler, Consumer<String> errorHandler);
|
||||
}
|
34
jdk/src/jdk.internal.ed/share/classes/module-info.java
Normal file
34
jdk/src/jdk.internal.ed/share/classes/module-info.java
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal editor support for JDK tools. Includes the Service Provider
|
||||
* Interface to built-in editors.
|
||||
*/
|
||||
module jdk.internal.ed {
|
||||
|
||||
exports jdk.internal.editor.spi to jdk.editpad, jdk.jshell, jdk.scripting.nashorn.shell;
|
||||
exports jdk.internal.editor.external to jdk.jshell, jdk.scripting.nashorn.shell;
|
||||
}
|
@ -359,9 +359,9 @@ class JImageTask {
|
||||
if (name.endsWith(".class") && !name.endsWith("module-info.class")) {
|
||||
try {
|
||||
byte[] bytes = reader.getResource(location);
|
||||
ClassReader cr =new ClassReader(bytes);
|
||||
ClassReader cr = new ClassReader(bytes);
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, ClassReader.EXPAND_FRAMES);
|
||||
cr.accept(cn, 0);
|
||||
} catch (Exception ex) {
|
||||
log.println("Error(s) in Class: " + name);
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import java.lang.module.ModuleFinder;
|
||||
import java.lang.module.ModuleReference;
|
||||
import java.lang.module.ResolutionException;
|
||||
import java.lang.module.ResolvedModule;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URI;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.file.Files;
|
||||
@ -41,6 +40,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import jdk.tools.jlink.internal.TaskHelper.BadArgs;
|
||||
import static jdk.tools.jlink.internal.TaskHelper.JLINK_BUNDLE;
|
||||
@ -62,20 +62,8 @@ import jdk.internal.misc.SharedSecrets;
|
||||
public class JlinkTask {
|
||||
static final boolean DEBUG = Boolean.getBoolean("jlink.debug");
|
||||
|
||||
private static <T extends Throwable> void fail(Class<T> type,
|
||||
String format,
|
||||
Object... args) throws T {
|
||||
String msg = new Formatter().format(format, args).toString();
|
||||
try {
|
||||
T t = type.getConstructor(String.class).newInstance(msg);
|
||||
throw t;
|
||||
} catch (InstantiationException |
|
||||
InvocationTargetException |
|
||||
NoSuchMethodException |
|
||||
IllegalAccessException e) {
|
||||
throw new InternalError("Unable to create an instance of " + type, e);
|
||||
}
|
||||
}
|
||||
// jlink API ignores by default. Remove when signing is implemented.
|
||||
static final boolean IGNORE_SIGNING_DEFAULT = true;
|
||||
|
||||
private static final TaskHelper taskHelper
|
||||
= new TaskHelper(JLINK_BUNDLE);
|
||||
@ -143,7 +131,10 @@ public class JlinkTask {
|
||||
}, "--save-opts"),
|
||||
new Option<JlinkTask>(false, (task, opt, arg) -> {
|
||||
task.options.fullVersion = true;
|
||||
}, true, "--full-version"),};
|
||||
}, true, "--full-version"),
|
||||
new Option<JlinkTask>(false, (task, opt, arg) -> {
|
||||
task.options.ignoreSigning = true;
|
||||
}, true, "--ignore-signing-information"),};
|
||||
|
||||
private static final String PROGNAME = "jlink";
|
||||
private final OptionsValues options = new OptionsValues();
|
||||
@ -160,7 +151,8 @@ public class JlinkTask {
|
||||
/**
|
||||
* Result codes.
|
||||
*/
|
||||
static final int EXIT_OK = 0, // Completed with no errors.
|
||||
static final int
|
||||
EXIT_OK = 0, // Completed with no errors.
|
||||
EXIT_ERROR = 1, // Completed but reported errors.
|
||||
EXIT_CMDERR = 2, // Bad command-line arguments
|
||||
EXIT_SYSERR = 3, // System error or resource exhaustion.
|
||||
@ -171,12 +163,13 @@ public class JlinkTask {
|
||||
String saveoptsfile;
|
||||
boolean version;
|
||||
boolean fullVersion;
|
||||
List<Path> modulePath = new ArrayList<>();
|
||||
Set<String> limitMods = new HashSet<>();
|
||||
Set<String> addMods = new HashSet<>();
|
||||
final List<Path> modulePath = new ArrayList<>();
|
||||
final Set<String> limitMods = new HashSet<>();
|
||||
final Set<String> addMods = new HashSet<>();
|
||||
Path output;
|
||||
Path packagedModulesPath;
|
||||
ByteOrder endian = ByteOrder.nativeOrder();
|
||||
boolean ignoreSigning = false;
|
||||
}
|
||||
|
||||
int run(String[] args) {
|
||||
@ -199,7 +192,7 @@ public class JlinkTask {
|
||||
return EXIT_OK;
|
||||
}
|
||||
if (taskHelper.getExistingImage() == null) {
|
||||
if (options.modulePath == null || options.modulePath.isEmpty()) {
|
||||
if (options.modulePath.isEmpty()) {
|
||||
throw taskHelper.newBadArgs("err.modulepath.must.be.specified").showUsage(true);
|
||||
}
|
||||
createImage();
|
||||
@ -248,20 +241,25 @@ public class JlinkTask {
|
||||
plugins = plugins == null ? new PluginsConfiguration() : plugins;
|
||||
|
||||
if (config.getModulepaths().isEmpty()) {
|
||||
throw new Exception("Empty module paths");
|
||||
throw new IllegalArgumentException("Empty module paths");
|
||||
}
|
||||
|
||||
ModuleFinder finder = newModuleFinder(config.getModulepaths(),
|
||||
config.getLimitmods(),
|
||||
config.getModules());
|
||||
|
||||
if (config.getModules().isEmpty()) {
|
||||
throw new IllegalArgumentException("No modules to add");
|
||||
}
|
||||
|
||||
// First create the image provider
|
||||
ImageProvider imageProvider
|
||||
= createImageProvider(finder,
|
||||
checkAddMods(config.getModules()),
|
||||
config.getLimitmods(),
|
||||
config.getByteOrder(),
|
||||
null);
|
||||
ImageProvider imageProvider =
|
||||
createImageProvider(finder,
|
||||
config.getModules(),
|
||||
config.getLimitmods(),
|
||||
config.getByteOrder(),
|
||||
null,
|
||||
IGNORE_SIGNING_DEFAULT);
|
||||
|
||||
// Then create the Plugin Stack
|
||||
ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(plugins);
|
||||
@ -299,19 +297,17 @@ public class JlinkTask {
|
||||
}
|
||||
ModuleFinder finder
|
||||
= newModuleFinder(options.modulePath, options.limitMods, options.addMods);
|
||||
try {
|
||||
options.addMods = checkAddMods(options.addMods);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
if (options.addMods.isEmpty()) {
|
||||
throw taskHelper.newBadArgs("err.mods.must.be.specified", "--add-modules")
|
||||
.showUsage(true);
|
||||
}
|
||||
// First create the image provider
|
||||
ImageProvider imageProvider
|
||||
= createImageProvider(finder,
|
||||
ImageProvider imageProvider = createImageProvider(finder,
|
||||
options.addMods,
|
||||
options.limitMods,
|
||||
options.endian,
|
||||
options.packagedModulesPath);
|
||||
options.packagedModulesPath,
|
||||
options.ignoreSigning);
|
||||
|
||||
// Then create the Plugin Stack
|
||||
ImagePluginStack stack = ImagePluginConfiguration.
|
||||
@ -321,13 +317,6 @@ public class JlinkTask {
|
||||
stack.operate(imageProvider);
|
||||
}
|
||||
|
||||
private static Set<String> checkAddMods(Set<String> addMods) {
|
||||
if (addMods.isEmpty()) {
|
||||
throw new IllegalArgumentException("no modules to add");
|
||||
}
|
||||
return addMods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a module finder to find the observable modules specified in
|
||||
* the --module-path and --limit-modules options
|
||||
@ -343,7 +332,7 @@ public class JlinkTask {
|
||||
return finder;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns a module finder of the given module path that limits
|
||||
* the observable modules to those in the transitive closure of
|
||||
* the modules specified in {@code limitMods} plus other modules
|
||||
@ -376,7 +365,8 @@ public class JlinkTask {
|
||||
Set<String> addMods,
|
||||
Set<String> limitMods,
|
||||
ByteOrder order,
|
||||
Path retainModulesPath)
|
||||
Path retainModulesPath,
|
||||
boolean ignoreSigning)
|
||||
throws IOException
|
||||
{
|
||||
if (addMods.isEmpty()) {
|
||||
@ -390,10 +380,10 @@ public class JlinkTask {
|
||||
|
||||
Map<String, Path> mods = cf.modules().stream()
|
||||
.collect(Collectors.toMap(ResolvedModule::name, JlinkTask::toPathLocation));
|
||||
return new ImageHelper(cf, mods, order, retainModulesPath);
|
||||
return new ImageHelper(cf, mods, order, retainModulesPath, ignoreSigning);
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns a ModuleFinder that limits observability to the given root
|
||||
* modules, their transitive dependences, plus a set of other modules.
|
||||
*/
|
||||
@ -477,36 +467,57 @@ public class JlinkTask {
|
||||
}
|
||||
|
||||
private static class ImageHelper implements ImageProvider {
|
||||
|
||||
final Set<Archive> archives;
|
||||
final ByteOrder order;
|
||||
final Path packagedModulesPath;
|
||||
final boolean ignoreSigning;
|
||||
final Set<Archive> archives;
|
||||
|
||||
ImageHelper(Configuration cf,
|
||||
Map<String, Path> modsPaths,
|
||||
ByteOrder order,
|
||||
Path packagedModulesPath) throws IOException {
|
||||
archives = modsPaths.entrySet().stream()
|
||||
.map(e -> newArchive(e.getKey(), e.getValue()))
|
||||
.collect(Collectors.toSet());
|
||||
Path packagedModulesPath,
|
||||
boolean ignoreSigning) throws IOException {
|
||||
this.order = order;
|
||||
this.packagedModulesPath = packagedModulesPath;
|
||||
this.ignoreSigning = ignoreSigning;
|
||||
this.archives = modsPaths.entrySet().stream()
|
||||
.map(e -> newArchive(e.getKey(), e.getValue()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private Archive newArchive(String module, Path path) {
|
||||
if (path.toString().endsWith(".jmod")) {
|
||||
return new JmodArchive(module, path);
|
||||
} else if (path.toString().endsWith(".jar")) {
|
||||
return new ModularJarArchive(module, path);
|
||||
ModularJarArchive modularJarArchive = new ModularJarArchive(module, path);
|
||||
|
||||
Stream<Archive.Entry> signatures = modularJarArchive.entries().filter((entry) -> {
|
||||
String name = entry.name().toUpperCase(Locale.ENGLISH);
|
||||
|
||||
return name.startsWith("META-INF/") && name.indexOf('/', 9) == -1 && (
|
||||
name.endsWith(".SF") ||
|
||||
name.endsWith(".DSA") ||
|
||||
name.endsWith(".RSA") ||
|
||||
name.endsWith(".EC") ||
|
||||
name.startsWith("META-INF/SIG-")
|
||||
);
|
||||
});
|
||||
|
||||
if (signatures.count() != 0) {
|
||||
if (ignoreSigning) {
|
||||
System.err.println(taskHelper.getMessage("warn.signing", path));
|
||||
} else {
|
||||
throw new IllegalArgumentException(taskHelper.getMessage("err.signing", path));
|
||||
}
|
||||
}
|
||||
|
||||
return modularJarArchive;
|
||||
} else if (Files.isDirectory(path)) {
|
||||
return new DirArchive(path);
|
||||
} else {
|
||||
fail(RuntimeException.class,
|
||||
"Selected module %s (%s) not in jmod or modular jar format",
|
||||
module,
|
||||
path);
|
||||
throw new IllegalArgumentException(
|
||||
taskHelper.getMessage("err.not.modular.format", module, path));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -212,7 +212,7 @@ public final class TaskHelper {
|
||||
mainOptions.add(new PlugOption(true, (task, opt, arg) -> {
|
||||
Path path = Paths.get(arg);
|
||||
if (!Files.exists(path) || !Files.isDirectory(path)) {
|
||||
throw newBadArgs("err.existing.image.must.exist");
|
||||
throw newBadArgs("err.image.must.exist");
|
||||
}
|
||||
existingImage = path.toAbsolutePath();
|
||||
}, true, POST_PROCESS));
|
||||
|
@ -62,6 +62,9 @@ main.opt.endian=\
|
||||
main.opt.save-opts=\
|
||||
\ --save-opts <filename> Save jlink options in the given file
|
||||
|
||||
main.opt.ignore-signing-information=\
|
||||
\ --ignore-signing-information Ignore signing information in modular JARs
|
||||
|
||||
main.msg.bug=\
|
||||
An exception has occurred in jlink. \
|
||||
Please file a bug at the Java Bug Database (http://bugreport.java.com/bugreport/) \
|
||||
@ -88,7 +91,7 @@ err.modulepath.must.be.specified:--module-path must be specified
|
||||
err.mods.must.be.specified:no modules specified to {0}
|
||||
err.path.not.found=path not found: {0}
|
||||
err.path.not.valid=invalid path: {0}
|
||||
err.existing.image.must.exist=existing image doesn't exists or is not a directory
|
||||
err.image.must.exist=image does not exist or is not a directory
|
||||
err.existing.image.invalid=existing image is not valid
|
||||
err.file.not.found=cannot find file: {0}
|
||||
err.file.error=cannot access file: {0}
|
||||
@ -104,5 +107,9 @@ err.option.unsupported={0} not supported: {1}
|
||||
err.config.defaults=property {0} is missing from configuration
|
||||
err.config.defaults.value=wrong value in defaults property: {0}
|
||||
err.bom.generation=bom file generation failed: {0}
|
||||
warn.invalid.arg=Invalid classname or pathname not exist: {0}
|
||||
err.not.modular.format=selected module {0} ({1}) not in jmod or modular JAR format
|
||||
err.signing=signed modular JAR {0} is currently not supported,\
|
||||
\ use --ignore-signing-information to suppress error
|
||||
warn.signing=signed modular JAR {0} is currently not supported
|
||||
warn.invalid.arg=invalid classname or pathname not exist: {0}
|
||||
warn.split.package=package {0} defined in {1} {2}
|
||||
|
@ -47,6 +47,7 @@ import java.lang.module.ResolutionException;
|
||||
import java.lang.module.ResolvedModule;
|
||||
import java.net.URI;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.FileVisitOption;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.InvalidPathException;
|
||||
@ -633,7 +634,8 @@ public class JmodTask {
|
||||
void processSection(JmodOutputStream out, Section section, Path top)
|
||||
throws IOException
|
||||
{
|
||||
Files.walkFileTree(top, new SimpleFileVisitor<Path>() {
|
||||
Files.walkFileTree(top, Set.of(FileVisitOption.FOLLOW_LINKS),
|
||||
Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
|
||||
throws IOException
|
||||
|
@ -184,6 +184,8 @@ java/nio/file/WatchService/Basic.java 7158947 solaris-
|
||||
java/nio/file/WatchService/MayFlies.java 7158947 solaris-all Solaris 11
|
||||
java/nio/file/WatchService/LotsOfEvents.java 7158947 solaris-all Solaris 11
|
||||
|
||||
sun/nio/cs/OLD/TestIBMDB.java 8167525 generic-all
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_rmi
|
||||
@ -217,6 +219,13 @@ sun/security/ssl/SSLSocketImpl/AsyncSSLSocketClose.java 8161232 macosx-a
|
||||
############################################################################
|
||||
|
||||
# jdk_sound
|
||||
javax/sound/sampled/DirectAudio/bug6372428.java 8055097 generic-all
|
||||
javax/sound/sampled/Clip/bug5070081.java 8055097 generic-all
|
||||
javax/sound/sampled/DataLine/LongFramePosition.java 8055097 generic-all
|
||||
|
||||
javax/sound/sampled/Clip/Drain/ClipDrain.java 7062792 generic-all
|
||||
|
||||
javax/sound/sampled/Mixers/DisabledAssertionCrash.java 7067310 generic-all
|
||||
|
||||
javax/sound/sampled/Clip/OpenNonIntegralNumberOfSampleframes.java 8168881 generic-all
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
* @bug 8035105
|
||||
* @summary DNS resource record parsing
|
||||
* @modules jdk.naming.dns/com.sun.jndi.dns
|
||||
* @compile --add-modules jdk.naming.dns Parser.java
|
||||
*/
|
||||
|
||||
import com.sun.jndi.dns.ResourceRecord;
|
||||
|
@ -28,7 +28,7 @@
|
||||
* @modules jdk.naming.rmi/com.sun.jndi.rmi.registry java.rmi/sun.rmi.registry
|
||||
* java.rmi/sun.rmi.server java.rmi/sun.rmi.transport java.rmi/sun.rmi.transport.tcp
|
||||
* @library ../../../../../../java/rmi/testlibrary
|
||||
* @build TestLibrary
|
||||
* @compile --add-modules jdk.naming.rmi ContextWithNullProperties.java
|
||||
* @run main ContextWithNullProperties
|
||||
*/
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
@bug 8017487
|
||||
@bug 8017487 8167988
|
||||
@summary filechooser in Windows-Libraries folder: columns are mixed up
|
||||
@author Semyon Sadetsky
|
||||
@modules java.desktop/sun.awt.shell
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2016, 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,8 +23,8 @@
|
||||
|
||||
/*
|
||||
@test
|
||||
@bug 6565779
|
||||
@library ../../../regtesthelpers
|
||||
@bug 6565779 8168292
|
||||
@library ../../regtesthelpers
|
||||
@compile DragEventSource.java
|
||||
@summary Exception if source of some event is TrayIcon
|
||||
@author Andrei Dmitriev: area=awt.tray
|
||||
@ -38,9 +38,19 @@
|
||||
* instance as source.
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.Button;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.FileDialog;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Image;
|
||||
import java.awt.Panel;
|
||||
import java.awt.SystemTray;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.TrayIcon;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class DragEventSource
|
||||
{
|
||||
@ -81,11 +91,10 @@ public class DragEventSource
|
||||
|
||||
String[] instructions =
|
||||
{
|
||||
"Use see a Frame with a button in it.",
|
||||
"Press the button. FileDialog should appear.",
|
||||
"Drag the mouse from the Tray icon to FileDialog ",
|
||||
"using left mouse button.",
|
||||
"If exception happens, the test fails.",
|
||||
"Click 'Open file dialog' button. FileDialog should appear.",
|
||||
"Using left mouse button,",
|
||||
"Drag the mouse from the Tray icon to FileDialog.",
|
||||
"If exception is thrown, the test fails.",
|
||||
"Otherwise, pass."
|
||||
};
|
||||
|
||||
|
@ -21,12 +21,19 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/* @bug 8166897
|
||||
/* @test
|
||||
@key headful
|
||||
@bug 8166897
|
||||
@summary Some font overlap in the Optionpane dialog.
|
||||
@run main ChangeWindowResizabiltyTest
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Robot;
|
||||
|
||||
public class ChangeWindowResizabiltyTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @bug 8162796
|
||||
* @summary Verifies if LinearGradientPaint is printed in osx
|
||||
* @run main/manual LinearGradientPrintingTest
|
||||
*/
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.LinearGradientPaint;
|
||||
import java.awt.Shape;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.print.PageFormat;
|
||||
import java.awt.print.Printable;
|
||||
import java.awt.print.PrinterException;
|
||||
import java.awt.print.PrinterJob;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
public class LinearGradientPrintingTest extends Component implements Printable {
|
||||
private static Thread mainThread;
|
||||
private static boolean testPassed;
|
||||
private static boolean testGeneratedInterrupt;
|
||||
private static JFrame f = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//createUI();
|
||||
doTest(LinearGradientPrintingTest::createUI);
|
||||
}
|
||||
});
|
||||
mainThread = Thread.currentThread();
|
||||
try {
|
||||
Thread.sleep(120000);
|
||||
} catch (InterruptedException e) {
|
||||
if (!testPassed && testGeneratedInterrupt) {
|
||||
throw new RuntimeException("LinearGradientPaint did not print");
|
||||
}
|
||||
}
|
||||
if (!testGeneratedInterrupt) {
|
||||
throw new RuntimeException("user has not executed the test");
|
||||
}
|
||||
}
|
||||
|
||||
public static void createUI() {
|
||||
f = new JFrame("LinearGradient Printing Test");
|
||||
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
final LinearGradientPrintingTest gpt = new LinearGradientPrintingTest();
|
||||
Container c = f.getContentPane();
|
||||
c.add(BorderLayout.CENTER, gpt);
|
||||
|
||||
final JButton print = new JButton("Print");
|
||||
print.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PrinterJob job = PrinterJob.getPrinterJob();
|
||||
job.setPrintable(gpt);
|
||||
final boolean doPrint = job.printDialog();
|
||||
if (doPrint) {
|
||||
try {
|
||||
job.print();
|
||||
} catch (PrinterException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
c.add(print, BorderLayout.SOUTH);
|
||||
|
||||
f.pack();
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(500,500);
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
doPaint((Graphics2D)g);
|
||||
}
|
||||
|
||||
public int print( Graphics graphics, PageFormat format, int index ) {
|
||||
Graphics2D g2d = (Graphics2D)graphics;
|
||||
g2d.translate(format.getImageableX(), format.getImageableY());
|
||||
doPaint(g2d);
|
||||
return index == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
|
||||
}
|
||||
|
||||
static final float DIM = 100;
|
||||
public void doPaint(Graphics2D g2d) {
|
||||
|
||||
g2d.translate(DIM*0.2, DIM*0.2);
|
||||
Shape s = new Rectangle2D.Float(0, 0, DIM*2, DIM*2);
|
||||
Point2D.Double p1 = new Point2D.Double(0.0, 0.0);
|
||||
Point2D.Double p2 = new Point2D.Double(DIM/2.0, DIM/2.0);
|
||||
|
||||
// LinearGradientPaint
|
||||
//g2d.translate(DIM*2.2, 0);
|
||||
Color colors[] = { Color.red, Color.blue} ;
|
||||
float fractions[] = { 0.0f, 1.0f };
|
||||
|
||||
LinearGradientPaint lgp =
|
||||
new LinearGradientPaint(p1, p2, fractions, colors,
|
||||
LinearGradientPaint.CycleMethod.NO_CYCLE);
|
||||
g2d.setPaint(lgp);
|
||||
g2d.fill(s);
|
||||
|
||||
g2d.translate(DIM*2.2, 0);
|
||||
Color colors1[] = { Color.red, Color.blue, Color.green, Color.white} ;
|
||||
float fractions1[] = { 0.0f, 0.3f, 0.6f, 1.0f };
|
||||
|
||||
LinearGradientPaint lgp1 =
|
||||
new LinearGradientPaint(p1, p2, fractions1, colors1,
|
||||
LinearGradientPaint.CycleMethod.REFLECT);
|
||||
g2d.setPaint(lgp1);
|
||||
g2d.fill(s);
|
||||
|
||||
g2d.translate(-DIM*2.2, DIM*2.2);
|
||||
Color colors2[] = { Color.red, Color.blue, Color.green, Color.white} ;
|
||||
float fractions2[] = { 0.0f, 0.3f, 0.6f, 1.0f };
|
||||
|
||||
LinearGradientPaint lgp2 =
|
||||
new LinearGradientPaint(p1, p2, fractions2, colors2,
|
||||
LinearGradientPaint.CycleMethod.REPEAT);
|
||||
g2d.setPaint(lgp2);
|
||||
g2d.fill(s);
|
||||
}
|
||||
|
||||
public static synchronized void pass() {
|
||||
testPassed = true;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
|
||||
public static synchronized void fail() {
|
||||
testPassed = false;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
|
||||
private static void doTest(Runnable action) {
|
||||
String description
|
||||
= " A LinearGradientPaint graphics will be shown on console.\n"
|
||||
+ " The same graphics is sent to printer.\n"
|
||||
+ " Please verify if LinearGradientPaint shading is printed.\n"
|
||||
+ " If none is printed, press FAIL else press PASS";
|
||||
|
||||
final JDialog dialog = new JDialog();
|
||||
dialog.setTitle("printSelectionTest");
|
||||
JTextArea textArea = new JTextArea(description);
|
||||
textArea.setEditable(false);
|
||||
final JButton testButton = new JButton("Start Test");
|
||||
final JButton passButton = new JButton("PASS");
|
||||
passButton.setEnabled(false);
|
||||
passButton.addActionListener((e) -> {
|
||||
f.dispose();
|
||||
dialog.dispose();
|
||||
pass();
|
||||
});
|
||||
final JButton failButton = new JButton("FAIL");
|
||||
failButton.setEnabled(false);
|
||||
failButton.addActionListener((e) -> {
|
||||
f.dispose();
|
||||
dialog.dispose();
|
||||
fail();
|
||||
});
|
||||
testButton.addActionListener((e) -> {
|
||||
testButton.setEnabled(false);
|
||||
action.run();
|
||||
passButton.setEnabled(true);
|
||||
failButton.setEnabled(true);
|
||||
});
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
mainPanel.add(textArea, BorderLayout.CENTER);
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout());
|
||||
buttonPanel.add(testButton);
|
||||
buttonPanel.add(passButton);
|
||||
buttonPanel.add(failButton);
|
||||
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||
dialog.add(mainPanel);
|
||||
|
||||
dialog.pack();
|
||||
dialog.setVisible(true);
|
||||
dialog.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.out.println("main dialog closing");
|
||||
testGeneratedInterrupt = false;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,234 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @bug 8162796
|
||||
* @summary Verifies if RadialGradientPaint is printed in osx
|
||||
* @run main/manual RadialGradientPrintingTest
|
||||
*/
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RadialGradientPaint;
|
||||
import java.awt.Shape;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.print.PageFormat;
|
||||
import java.awt.print.Printable;
|
||||
import static java.awt.print.Printable.NO_SUCH_PAGE;
|
||||
import static java.awt.print.Printable.PAGE_EXISTS;
|
||||
import java.awt.print.PrinterException;
|
||||
import java.awt.print.PrinterJob;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
public class RadialGradientPrintingTest extends Component implements Printable {
|
||||
private static Thread mainThread;
|
||||
private static boolean testPassed;
|
||||
private static boolean testGeneratedInterrupt;
|
||||
private static JFrame f = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//createUI();
|
||||
doTest(RadialGradientPrintingTest::createUI);
|
||||
}
|
||||
});
|
||||
mainThread = Thread.currentThread();
|
||||
try {
|
||||
Thread.sleep(120000);
|
||||
} catch (InterruptedException e) {
|
||||
if (!testPassed && testGeneratedInterrupt) {
|
||||
throw new RuntimeException("LinearGradientPaint did not print");
|
||||
}
|
||||
}
|
||||
if (!testGeneratedInterrupt) {
|
||||
throw new RuntimeException("user has not executed the test");
|
||||
}
|
||||
}
|
||||
|
||||
public static void createUI() {
|
||||
f = new JFrame("RadialGradient Printing Test");
|
||||
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
final RadialGradientPrintingTest gpt = new RadialGradientPrintingTest();
|
||||
Container c = f.getContentPane();
|
||||
c.add(BorderLayout.CENTER, gpt);
|
||||
|
||||
final JButton print = new JButton("Print");
|
||||
print.addActionListener(new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PrinterJob job = PrinterJob.getPrinterJob();
|
||||
job.setPrintable(gpt);
|
||||
final boolean doPrint = job.printDialog();
|
||||
if (doPrint) {
|
||||
try {
|
||||
job.print();
|
||||
} catch (PrinterException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
c.add(print, BorderLayout.SOUTH);
|
||||
|
||||
f.pack();
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(500,500);
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
doPaint((Graphics2D)g);
|
||||
}
|
||||
|
||||
public int print( Graphics graphics, PageFormat format, int index ) {
|
||||
Graphics2D g2d = (Graphics2D)graphics;
|
||||
g2d.translate(format.getImageableX(), format.getImageableY());
|
||||
doPaint(g2d);
|
||||
return index == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
|
||||
}
|
||||
|
||||
static final float DIM = 100;
|
||||
public void doPaint(Graphics2D g2d) {
|
||||
|
||||
g2d.translate(DIM*0.2, DIM*0.2);
|
||||
Shape s = new Rectangle2D.Float(0, 0, DIM*2, DIM*2);
|
||||
|
||||
// RadialGradientPaint
|
||||
Point2D centre = new Point2D.Float(DIM/2.0f, DIM/2.0f);
|
||||
float radius = DIM/2.0f;
|
||||
Point2D focus = new Point2D.Float(DIM/3.0f, DIM/3.0f);
|
||||
float stops[] = {0.0f, 1.0f};
|
||||
Color colors[] = { Color.red, Color.white} ;
|
||||
|
||||
RadialGradientPaint rgp =
|
||||
new RadialGradientPaint(centre, radius, focus, stops, colors,
|
||||
RadialGradientPaint.CycleMethod.NO_CYCLE);
|
||||
g2d.setPaint(rgp);
|
||||
g2d.fill(s);
|
||||
|
||||
g2d.translate(DIM*2.2, 0);
|
||||
Color colors1[] = { Color.red, Color.blue, Color.green} ;
|
||||
float stops1[] = {0.0f, 0.5f, 1.0f};
|
||||
RadialGradientPaint rgp1 =
|
||||
new RadialGradientPaint(centre, radius, focus, stops1, colors1,
|
||||
RadialGradientPaint.CycleMethod.REFLECT);
|
||||
g2d.setPaint(rgp1);
|
||||
g2d.fill(s);
|
||||
|
||||
g2d.translate(-DIM*2.2, DIM*2.2);
|
||||
Color colors2[] = { Color.red, Color.blue, Color.green, Color.white} ;
|
||||
float stops2[] = {0.0f, 0.3f, 0.6f, 1.0f};
|
||||
RadialGradientPaint rgp2 =
|
||||
new RadialGradientPaint(centre, radius, focus, stops2, colors2,
|
||||
RadialGradientPaint.CycleMethod.REPEAT);
|
||||
g2d.setPaint(rgp2);
|
||||
g2d.fill(s);
|
||||
|
||||
}
|
||||
|
||||
public static synchronized void pass() {
|
||||
testPassed = true;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
|
||||
public static synchronized void fail() {
|
||||
testPassed = false;
|
||||
testGeneratedInterrupt = true;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
|
||||
private static void doTest(Runnable action) {
|
||||
String description
|
||||
= " A RadialGradientPaint graphics will be shown on console.\n"
|
||||
+ " The same graphics is sent to printer.\n"
|
||||
+ " Please verify if RadialGradientPaint shading is printed.\n"
|
||||
+ " If none is printed, press FAIL else press PASS";
|
||||
|
||||
final JDialog dialog = new JDialog();
|
||||
dialog.setTitle("printSelectionTest");
|
||||
JTextArea textArea = new JTextArea(description);
|
||||
textArea.setEditable(false);
|
||||
final JButton testButton = new JButton("Start Test");
|
||||
final JButton passButton = new JButton("PASS");
|
||||
passButton.setEnabled(false);
|
||||
passButton.addActionListener((e) -> {
|
||||
f.dispose();
|
||||
dialog.dispose();
|
||||
pass();
|
||||
});
|
||||
final JButton failButton = new JButton("FAIL");
|
||||
failButton.setEnabled(false);
|
||||
failButton.addActionListener((e) -> {
|
||||
f.dispose();
|
||||
dialog.dispose();
|
||||
fail();
|
||||
});
|
||||
testButton.addActionListener((e) -> {
|
||||
testButton.setEnabled(false);
|
||||
action.run();
|
||||
passButton.setEnabled(true);
|
||||
failButton.setEnabled(true);
|
||||
});
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
mainPanel.add(textArea, BorderLayout.CENTER);
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout());
|
||||
buttonPanel.add(testButton);
|
||||
buttonPanel.add(passButton);
|
||||
buttonPanel.add(failButton);
|
||||
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||
dialog.add(mainPanel);
|
||||
|
||||
dialog.pack();
|
||||
dialog.setVisible(true);
|
||||
dialog.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.out.println("main dialog closing");
|
||||
testGeneratedInterrupt = false;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -40,7 +40,7 @@ import java.util.Hashtable;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.net.ssl.SSLEngineResult;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
@ -82,8 +82,8 @@ public class SerialFilterTest implements Serializable {
|
||||
Object[][] patterns = new Object[][]{
|
||||
{"java.util.Hashtable"},
|
||||
{"java.util.Hash*"},
|
||||
{"javax.lang.model.*"},
|
||||
{"javax.lang.**"},
|
||||
{"javax.net.ssl.*"},
|
||||
{"javax.net.**"},
|
||||
{"*"},
|
||||
{"maxarray=47"},
|
||||
{"maxdepth=5"},
|
||||
@ -543,20 +543,20 @@ public class SerialFilterTest implements Serializable {
|
||||
static Object genTestObjectWildcard(String pattern, boolean allowed) {
|
||||
if (pattern.endsWith(".**")) {
|
||||
// package hierarchy wildcard
|
||||
if (pattern.startsWith("javax.lang.")) {
|
||||
return SourceVersion.RELEASE_5;
|
||||
if (pattern.startsWith("javax.net.")) {
|
||||
return SSLEngineResult.Status.BUFFER_OVERFLOW;
|
||||
}
|
||||
if (pattern.startsWith("java.")) {
|
||||
return 4;
|
||||
}
|
||||
if (pattern.startsWith("javax.")) {
|
||||
return SourceVersion.RELEASE_6;
|
||||
return SSLEngineResult.Status.BUFFER_UNDERFLOW;
|
||||
}
|
||||
return otherObject;
|
||||
} else if (pattern.endsWith(".*")) {
|
||||
// package wildcard
|
||||
if (pattern.startsWith("javax.lang.model")) {
|
||||
return SourceVersion.RELEASE_6;
|
||||
if (pattern.startsWith("javax.net.ssl")) {
|
||||
return SSLEngineResult.Status.BUFFER_UNDERFLOW;
|
||||
}
|
||||
} else {
|
||||
// class wildcard
|
||||
|
@ -24,8 +24,9 @@
|
||||
/*
|
||||
* @test
|
||||
* @summary Test java.* class defined by the platform class loader
|
||||
* @build jdk.zipfs/java.fake.Fake
|
||||
* @modules jdk.zipfs/java.fake
|
||||
* @build jdk.zipfs/java.fake.Fake
|
||||
* @compile --add-modules jdk.zipfs DefinePlatformClass.java
|
||||
* @run main DefinePlatformClass
|
||||
*/
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2016, 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,43 +23,74 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4712607
|
||||
* @bug 4712607 6479237
|
||||
* @summary Basic test for StackTraceElementPublic constructor
|
||||
* @author Josh Bloch
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.lang.module.ModuleDescriptor;
|
||||
import java.lang.reflect.Module;
|
||||
|
||||
public class PublicConstructor {
|
||||
public static void main(String args[]) {
|
||||
public static void main(String... args) {
|
||||
testConstructor();
|
||||
testConstructorWithModule();
|
||||
}
|
||||
|
||||
static void testConstructor() {
|
||||
StackTraceElement ste = new StackTraceElement("com.acme.Widget",
|
||||
"frobnicate", "Widget.java", 42);
|
||||
"frobnicate",
|
||||
"Widget.java", 42);
|
||||
if (!(ste.getClassName().equals("com.acme.Widget") &&
|
||||
ste.getFileName().equals("Widget.java") &&
|
||||
ste.getMethodName().equals("frobnicate") &&
|
||||
ste.getLineNumber() == 42))
|
||||
ste.getFileName().equals("Widget.java") &&
|
||||
ste.getMethodName().equals("frobnicate") &&
|
||||
ste.getLineNumber() == 42))
|
||||
throw new RuntimeException("1");
|
||||
|
||||
if (ste.isNativeMethod())
|
||||
throw new RuntimeException("2");
|
||||
StackTraceElement ste2
|
||||
= new StackTraceElement("jdk.module",
|
||||
"9.0",
|
||||
"com.acme.Widget",
|
||||
"frobnicate",
|
||||
"Widget.java",
|
||||
42);
|
||||
if (!(ste2.getClassName().equals("com.acme.Widget") &&
|
||||
ste2.getModuleName().equals("jdk.module") &&
|
||||
ste2.getModuleVersion().equals("9.0") &&
|
||||
ste2.getFileName().equals("Widget.java") &&
|
||||
ste2.getMethodName().equals("frobnicate") &&
|
||||
ste2.getLineNumber() == 42))
|
||||
|
||||
assertEquals(ste.toString(),
|
||||
"com.acme.Widget.frobnicate(Widget.java:42)");
|
||||
|
||||
StackTraceElement ste1 = new StackTraceElement("com.acme.Widget",
|
||||
"frobnicate",
|
||||
"Widget.java",
|
||||
-2);
|
||||
if (!ste1.isNativeMethod())
|
||||
throw new RuntimeException("3");
|
||||
if (ste2.isNativeMethod())
|
||||
|
||||
assertEquals(ste1.toString(),
|
||||
"com.acme.Widget.frobnicate(Native Method)");
|
||||
}
|
||||
|
||||
static void testConstructorWithModule() {
|
||||
StackTraceElement ste = new StackTraceElement("app",
|
||||
"jdk.module",
|
||||
"9.0",
|
||||
"com.acme.Widget",
|
||||
"frobnicate",
|
||||
"Widget.java",
|
||||
42);
|
||||
if (!(ste.getClassName().equals("com.acme.Widget") &&
|
||||
ste.getModuleName().equals("jdk.module") &&
|
||||
ste.getModuleVersion().equals("9.0") &&
|
||||
ste.getClassLoaderName().equals("app") &&
|
||||
ste.getFileName().equals("Widget.java") &&
|
||||
ste.getMethodName().equals("frobnicate") &&
|
||||
ste.getLineNumber() == 42))
|
||||
throw new RuntimeException("3");
|
||||
|
||||
if (ste.isNativeMethod())
|
||||
throw new RuntimeException("4");
|
||||
StackTraceElement ste3 = new StackTraceElement("com.acme.Widget",
|
||||
"frobnicate", "Widget.java", -2);
|
||||
if (!ste3.isNativeMethod())
|
||||
throw new RuntimeException("5");
|
||||
|
||||
assertEquals(ste.toString(),
|
||||
"app/jdk.module@9.0/com.acme.Widget.frobnicate(Widget.java:42)");
|
||||
}
|
||||
|
||||
static void assertEquals(String s, String expected) {
|
||||
if (!s.equals(expected)) {
|
||||
throw new RuntimeException("Expected: " + expected + " but found: " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
264
jdk/test/java/lang/StackTraceElement/SerialTest.java
Normal file
264
jdk/test/java/lang/StackTraceElement/SerialTest.java
Normal file
@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6479237
|
||||
* @summary Test the format of StackTraceElement::toString and its serial form
|
||||
* @modules java.logging
|
||||
* java.xml.bind
|
||||
* @run main SerialTest
|
||||
*/
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SerialTest {
|
||||
private static final Path SER_DIR = Paths.get("sers");
|
||||
private static final String JAVA_BASE = "java.base";
|
||||
private static final String JAVA_LOGGING = "java.logging";
|
||||
private static final String JAVA_XML_BIND = "java.xml.bind";
|
||||
|
||||
private static boolean isImage;
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
Files.createDirectories(SER_DIR);
|
||||
|
||||
// detect if exploded image build
|
||||
Path home = Paths.get(System.getProperty("java.home"));
|
||||
isImage = Files.exists(home.resolve("lib").resolve("modules"));
|
||||
|
||||
// test stack trace from built-in loaders
|
||||
try {
|
||||
Logger.getLogger(null);
|
||||
} catch (NullPointerException e) {
|
||||
Arrays.stream(e.getStackTrace())
|
||||
.filter(ste -> ste.getClassName().startsWith("java.util.logging.") ||
|
||||
ste.getClassName().equals("SerialTest"))
|
||||
.forEach(SerialTest::test);
|
||||
}
|
||||
|
||||
// test stack trace with upgradeable module
|
||||
try {
|
||||
new JAXBElement(null, null, null);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Arrays.stream(e.getStackTrace())
|
||||
.filter(ste -> ste.getModuleName() != null)
|
||||
.forEach(SerialTest::test);
|
||||
}
|
||||
|
||||
// test stack trace with class loader name from other class loader
|
||||
Loader loader = new Loader("myloader");
|
||||
Class<?> cls = Class.forName("SerialTest", true, loader);
|
||||
Method method = cls.getMethod("throwException");
|
||||
StackTraceElement ste = (StackTraceElement)method.invoke(null);
|
||||
test(ste, loader);
|
||||
|
||||
// verify the class loader name and in the stack trace
|
||||
if (!cls.getClassLoader().getName().equals("myloader.hacked")) {
|
||||
throw new RuntimeException("Unexpected loader name: " +
|
||||
cls.getClassLoader().getName());
|
||||
}
|
||||
if (!ste.getClassLoaderName().equals("myloader")) {
|
||||
throw new RuntimeException("Unexpected loader name: " +
|
||||
ste.getClassLoaderName());
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(StackTraceElement ste) {
|
||||
test(ste, null);
|
||||
}
|
||||
|
||||
private static void test(StackTraceElement ste, ClassLoader loader) {
|
||||
try {
|
||||
SerialTest serialTest = new SerialTest(ste);
|
||||
StackTraceElement ste2 = serialTest.serialize().deserialize();
|
||||
System.out.println(ste2);
|
||||
// verify StackTraceElement::toString returns the same string
|
||||
if (!ste.equals(ste2) || !ste.toString().equals(ste2.toString())) {
|
||||
throw new RuntimeException(ste + " != " + ste2);
|
||||
}
|
||||
|
||||
String mn = ste.getModuleName();
|
||||
if (mn != null) {
|
||||
switch (mn) {
|
||||
case JAVA_BASE:
|
||||
case JAVA_LOGGING:
|
||||
checkNamedModule(ste, loader, false);
|
||||
break;
|
||||
case JAVA_XML_BIND:
|
||||
// for exploded build, no version is shown
|
||||
checkNamedModule(ste, loader, isImage);
|
||||
break;
|
||||
default: // ignore
|
||||
}
|
||||
} else {
|
||||
checkUnnamedModule(ste, loader);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkUnnamedModule(StackTraceElement ste, ClassLoader loader) {
|
||||
String mn = ste.getModuleName();
|
||||
String s = ste.toString();
|
||||
int i = s.indexOf('/');
|
||||
|
||||
if (mn != null) {
|
||||
throw new RuntimeException("expected null but got " + mn);
|
||||
}
|
||||
|
||||
if (loader != null) {
|
||||
// Expect <loader>//<classname>.<method>(<src>:<ln>)
|
||||
if (i <= 0) {
|
||||
throw new RuntimeException("loader name missing: " + s);
|
||||
}
|
||||
if (!getLoaderName(loader).equals(s.substring(0, i))) {
|
||||
throw new RuntimeException("unexpected loader name: " + s);
|
||||
}
|
||||
int j = s.substring(i+1).indexOf('/');
|
||||
if (j != 0) {
|
||||
throw new RuntimeException("unexpected element for unnamed module: " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Loader::getName is overridden to return some other name
|
||||
*/
|
||||
private static String getLoaderName(ClassLoader loader) {
|
||||
if (loader == null)
|
||||
return "";
|
||||
|
||||
if (loader instanceof Loader) {
|
||||
return ((Loader) loader).name;
|
||||
} else {
|
||||
return loader.getName();
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkNamedModule(StackTraceElement ste,
|
||||
ClassLoader loader,
|
||||
boolean showVersion) {
|
||||
String loaderName = getLoaderName(loader);
|
||||
String mn = ste.getModuleName();
|
||||
String s = ste.toString();
|
||||
int i = s.indexOf('/');
|
||||
|
||||
if (mn == null) {
|
||||
throw new RuntimeException("expected module name: " + s);
|
||||
}
|
||||
|
||||
if (i <= 0) {
|
||||
throw new RuntimeException("module name missing: " + s);
|
||||
}
|
||||
|
||||
// Expect <module>/<classname>.<method>(<src>:<ln>)
|
||||
if (!loaderName.isEmpty()) {
|
||||
throw new IllegalArgumentException(loaderName);
|
||||
}
|
||||
|
||||
// <module>: name@version
|
||||
int j = s.indexOf('@');
|
||||
if ((showVersion && j <= 0) || (!showVersion && j >= 0)) {
|
||||
throw new RuntimeException("unexpected version: " + s);
|
||||
}
|
||||
|
||||
String name = j < 0 ? s.substring(0, i) : s.substring(0, j);
|
||||
if (!name.equals(mn)) {
|
||||
throw new RuntimeException("unexpected module name: " + s);
|
||||
}
|
||||
}
|
||||
|
||||
private final Path ser;
|
||||
private final StackTraceElement ste;
|
||||
SerialTest(StackTraceElement ste) throws IOException {
|
||||
this.ser = Files.createTempFile(SER_DIR, "SerialTest", ".ser");
|
||||
this.ste = ste;
|
||||
}
|
||||
|
||||
private StackTraceElement deserialize() throws IOException {
|
||||
try (InputStream in = Files.newInputStream(ser);
|
||||
BufferedInputStream bis = new BufferedInputStream(in);
|
||||
ObjectInputStream ois = new ObjectInputStream(bis)) {
|
||||
return (StackTraceElement)ois.readObject();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private SerialTest serialize() throws IOException {
|
||||
try (OutputStream out = Files.newOutputStream(ser);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(out);
|
||||
ObjectOutputStream oos = new ObjectOutputStream(bos)) {
|
||||
oos.writeObject(ste);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public static StackTraceElement throwException() {
|
||||
try {
|
||||
Integer.parseInt(null);
|
||||
} catch (NumberFormatException e) {
|
||||
return Arrays.stream(e.getStackTrace())
|
||||
.filter(ste -> ste.getMethodName().equals("throwException"))
|
||||
.findFirst().get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Loader extends URLClassLoader {
|
||||
final String name;
|
||||
Loader(String name) throws MalformedURLException {
|
||||
super(name, new URL[] { testClassesURL() } , null);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private static URL testClassesURL() throws MalformedURLException {
|
||||
Path path = Paths.get(System.getProperty("test.classes"));
|
||||
return path.toUri().toURL();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name + ".hacked";
|
||||
}
|
||||
}
|
||||
}
|
121
jdk/test/java/lang/StackTraceElement/WithClassLoaderName.java
Normal file
121
jdk/test/java/lang/StackTraceElement/WithClassLoaderName.java
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6479237
|
||||
* @summary Basic test StackTraceElement with class loader names
|
||||
* @library lib /lib/testlibrary
|
||||
* @build m1/* WithClassLoaderName
|
||||
* @run main/othervm m1/com.app.Main
|
||||
* @run main/othervm WithClassLoaderName
|
||||
*/
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import com.app.Utils;
|
||||
|
||||
public class WithClassLoaderName {
|
||||
private static final String TEST_SRC = System.getProperty("test.src");
|
||||
private static final String SRC_FILENAME = "WithClassLoaderName.java";
|
||||
|
||||
private static final Path SRC_DIR = Paths.get(TEST_SRC, "src");
|
||||
private static final Path CLASSES_DIR = Paths.get("classes");
|
||||
private static final String THROW_EXCEPTION_CLASS = "p.ThrowException";
|
||||
|
||||
public static void main(String... args) throws Exception {
|
||||
/*
|
||||
* Test the following frames both have the same class loader name "app"
|
||||
* com.app.Test::test
|
||||
* WithClassLoaderName::test
|
||||
*/
|
||||
Utils.verify(WithClassLoaderName.class, "app", "main", SRC_FILENAME);
|
||||
|
||||
/*
|
||||
* Test StackTraceElement for a class loaded by a named URLClassLoader
|
||||
*/
|
||||
compile();
|
||||
testURLClassLoader("myloader");
|
||||
|
||||
// loader name same as application class loader
|
||||
testURLClassLoader("app");
|
||||
}
|
||||
|
||||
private static void compile() throws Exception {
|
||||
boolean rc = CompilerUtils.compile(SRC_DIR, CLASSES_DIR);
|
||||
if (!rc) {
|
||||
throw new RuntimeException("compilation fails");
|
||||
}
|
||||
}
|
||||
|
||||
public static void testURLClassLoader(String loaderName) throws Exception {
|
||||
System.err.println("---- test URLClassLoader name: " + loaderName);
|
||||
|
||||
URL[] urls = new URL[] { CLASSES_DIR.toUri().toURL() };
|
||||
ClassLoader parent = ClassLoader.getSystemClassLoader();
|
||||
URLClassLoader loader = new URLClassLoader(loaderName, urls, parent);
|
||||
|
||||
Class<?> c = Class.forName(THROW_EXCEPTION_CLASS, true, loader);
|
||||
Method method = c.getMethod("throwError");
|
||||
try {
|
||||
// invoke p.ThrowException::throwError
|
||||
method.invoke(null);
|
||||
} catch (InvocationTargetException x) {
|
||||
Throwable e = x.getCause();
|
||||
e.printStackTrace();
|
||||
|
||||
StackTraceElement[] stes = e.getStackTrace();
|
||||
StackWalker.StackFrame[] frames = new StackWalker.StackFrame[] {
|
||||
Utils.makeStackFrame(c, "throwError", "ThrowException.java"),
|
||||
Utils.makeStackFrame(WithClassLoaderName.class, "testURLClassLoader",
|
||||
SRC_FILENAME),
|
||||
Utils.makeStackFrame(WithClassLoaderName.class, "main", SRC_FILENAME),
|
||||
};
|
||||
|
||||
// p.ThrowException.throwError
|
||||
Utils.checkFrame(loaderName, frames[0], stes[0]);
|
||||
// skip reflection frames
|
||||
int i = 1;
|
||||
while (i < stes.length) {
|
||||
String cn = stes[i].getClassName();
|
||||
if (!cn.startsWith("java.lang.reflect.") &&
|
||||
!cn.startsWith("jdk.internal.reflect."))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
// WithClassLoaderName.testURLClassLoader
|
||||
Utils.checkFrame("app", frames[1], stes[i]);
|
||||
|
||||
// WithClassLoaderName.main
|
||||
Utils.checkFrame("app", frames[2], stes[i+1]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.app;
|
||||
|
||||
import java.lang.StackWalker.StackFrame;
|
||||
|
||||
public class Main {
|
||||
public static void main(String... args) throws Exception {
|
||||
StackFrame frame = Utils.makeStackFrame(Main.class, "main", "Main.java");
|
||||
Utils.checkFrame("app", frame, caller());
|
||||
}
|
||||
|
||||
private static StackTraceElement caller() {
|
||||
StackTraceElement[] stes = Thread.currentThread().getStackTrace();
|
||||
return stes[2];
|
||||
}
|
||||
}
|
136
jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java
Normal file
136
jdk/test/java/lang/StackTraceElement/lib/m1/com/app/Utils.java
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.app;
|
||||
|
||||
import java.lang.StackWalker.StackFrame;
|
||||
import java.lang.module.ModuleDescriptor;
|
||||
import java.lang.reflect.Module;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Utils {
|
||||
public static void verify(Class<?> caller, String loaderName,
|
||||
String methodname, String filename) {
|
||||
StackTraceElement[] stes = Thread.currentThread().getStackTrace();
|
||||
StackWalker.StackFrame[] frames = new StackFrame[] {
|
||||
makeStackFrame(Utils.class, "verify", "Utils.java"),
|
||||
makeStackFrame(caller, methodname, filename)
|
||||
};
|
||||
|
||||
checkFrame("app", frames[0], stes[1]);
|
||||
checkFrame(loaderName, frames[1], stes[2]);
|
||||
}
|
||||
|
||||
public static StackFrame makeStackFrame(Class<?> c, String methodname, String filename) {
|
||||
return new StackFrame() {
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return c.getName();
|
||||
}
|
||||
@Override
|
||||
public String getMethodName() {
|
||||
return methodname;
|
||||
}
|
||||
@Override
|
||||
public Class<?> getDeclaringClass() {
|
||||
return c;
|
||||
}
|
||||
@Override
|
||||
public int getByteCodeIndex() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public String getFileName() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLineNumber() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean isNativeMethod() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public StackTraceElement toStackTraceElement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getClassLoaderName(Class<?> c) {
|
||||
ClassLoader loader = c.getClassLoader();
|
||||
String name = "";
|
||||
if (loader == null) {
|
||||
name = "boot";
|
||||
} else if (loader.getName() != null) {
|
||||
name = loader.getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String mid = getClassLoaderName(c);
|
||||
Module module = c.getModule();
|
||||
if (module.isNamed()) {
|
||||
ModuleDescriptor md = module.getDescriptor();
|
||||
mid = md.name();
|
||||
if (md.version().isPresent())
|
||||
mid += "@" + md.version().get().toString();
|
||||
mid += "/";
|
||||
}
|
||||
String fileName = getFileName();
|
||||
int lineNumber = getLineNumber();
|
||||
String sourceinfo = "Unknown Source";
|
||||
if (isNativeMethod()) {
|
||||
sourceinfo = "Native Method";
|
||||
} else if (fileName != null && lineNumber >= 0) {
|
||||
sourceinfo = fileName + ":" + lineNumber;
|
||||
}
|
||||
return String.format("%s/%s.%s(%s)", mid, getClassName(), getMethodName(),
|
||||
sourceinfo);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void checkFrame(String loaderName, StackFrame frame,
|
||||
StackTraceElement ste) {
|
||||
System.err.println("checking " + ste.toString() + " expected: " + frame.toString());
|
||||
Class<?> c = frame.getDeclaringClass();
|
||||
Module module = c.getModule();
|
||||
assertEquals(ste.getModuleName(), module.getName(), "module name");
|
||||
assertEquals(ste.getClassLoaderName(), loaderName, "class loader name");
|
||||
assertEquals(ste.getClassLoaderName(), c.getClassLoader().getName(),
|
||||
"class loader name");
|
||||
assertEquals(ste.getClassName(), c.getName(), "class name");
|
||||
assertEquals(ste.getMethodName(), frame.getMethodName(), "method name");
|
||||
assertEquals(ste.getFileName(), frame.getFileName(), "file name");
|
||||
|
||||
}
|
||||
private static void assertEquals(String actual, String expected, String msg) {
|
||||
if (!Objects.equals(actual, expected))
|
||||
throw new AssertionError("Actual: " + actual + " Excepted: " +
|
||||
expected + " mismatched " + msg);
|
||||
}
|
||||
}
|
26
jdk/test/java/lang/StackTraceElement/lib/m1/module-info.java
Normal file
26
jdk/test/java/lang/StackTraceElement/lib/m1/module-info.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
module m1 {
|
||||
exports com.app;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package p;
|
||||
|
||||
import java.lang.StackWalker.StackFrame;
|
||||
|
||||
public class ThrowException {
|
||||
public static void throwError() {
|
||||
throw new Error("testing");
|
||||
}
|
||||
}
|
@ -71,7 +71,7 @@ public class VerifyStackTrace {
|
||||
"3: VerifyStackTrace$Handle.run(VerifyStackTrace.java:158)\n" +
|
||||
"4: VerifyStackTrace.invoke(VerifyStackTrace.java:188)\n" +
|
||||
"5: VerifyStackTrace$1.run(VerifyStackTrace.java:218)\n" +
|
||||
"6: java.security.AccessController.doPrivileged(java.base/Native Method)\n" +
|
||||
"6: java.base/java.security.AccessController.doPrivileged(Native Method)\n" +
|
||||
"7: VerifyStackTrace.test(VerifyStackTrace.java:227)\n" +
|
||||
"8: VerifyStackTrace.main(VerifyStackTrace.java:182)\n";
|
||||
|
||||
@ -100,12 +100,12 @@ public class VerifyStackTrace {
|
||||
"2: VerifyStackTrace$Handle.execute(VerifyStackTrace.java:147)\n" +
|
||||
"3: VerifyStackTrace$Handle.run(VerifyStackTrace.java:160)\n" +
|
||||
"4: VerifyStackTrace.invoke(VerifyStackTrace.java:190)\n" +
|
||||
"5: jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base/Native Method)\n" +
|
||||
"6: jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base/NativeMethodAccessorImpl.java:62)\n" +
|
||||
"7: jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base/DelegatingMethodAccessorImpl.java:43)\n" +
|
||||
"8: java.lang.reflect.Method.invoke(java.base/Method.java:520)\n" +
|
||||
"5: java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" +
|
||||
"6: java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n" +
|
||||
"7: java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" +
|
||||
"8: java.base/java.lang.reflect.Method.invoke(Method.java:520)\n" +
|
||||
"9: VerifyStackTrace$1.run(VerifyStackTrace.java:220)\n" +
|
||||
"10: java.security.AccessController.doPrivileged(java.base/Native Method)\n" +
|
||||
"10: java.base/java.security.AccessController.doPrivileged(Native Method)\n" +
|
||||
"11: VerifyStackTrace.test(VerifyStackTrace.java:229)\n" +
|
||||
"12: VerifyStackTrace.main(VerifyStackTrace.java:185)\n";
|
||||
|
||||
@ -133,16 +133,16 @@ public class VerifyStackTrace {
|
||||
"1: VerifyStackTrace.lambda$test$1(VerifyStackTrace.java:213)\n" +
|
||||
"2: VerifyStackTrace$$Lambda$1/662441761.run(Unknown Source)\n" +
|
||||
"3: VerifyStackTrace$Handle.execute(VerifyStackTrace.java:149)\n" +
|
||||
"4: java.lang.invoke.LambdaForm$DMH/2008017533.invokeVirtual_LL_V(java.base/LambdaForm$DMH)\n" +
|
||||
"5: java.lang.invoke.LambdaForm$MH/1395089624.invoke_MT(java.base/LambdaForm$MH)\n" +
|
||||
"4: java.base/java.lang.invoke.LambdaForm$DMH/2008017533.invokeVirtual_LL_V(LambdaForm$DMH)\n" +
|
||||
"5: java.base/java.lang.invoke.LambdaForm$MH/1395089624.invoke_MT(LambdaForm$MH)\n" +
|
||||
"6: VerifyStackTrace$Handle.run(VerifyStackTrace.java:162)\n" +
|
||||
"7: VerifyStackTrace.invoke(VerifyStackTrace.java:192)\n" +
|
||||
"8: jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base/Native Method)\n" +
|
||||
"9: jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base/NativeMethodAccessorImpl.java:62)\n" +
|
||||
"10: jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base/DelegatingMethodAccessorImpl.java:43)\n" +
|
||||
"11: java.lang.reflect.Method.invoke(java.base/Method.java:520)\n" +
|
||||
"8: java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" +
|
||||
"9: java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n" +
|
||||
"10: java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" +
|
||||
"11: java.base/java.lang.reflect.Method.invoke(Method.java:520)\n" +
|
||||
"12: VerifyStackTrace$1.run(VerifyStackTrace.java:222)\n" +
|
||||
"13: java.security.AccessController.doPrivileged(java.base/Native Method)\n" +
|
||||
"13: java.base/java.security.AccessController.doPrivileged(Native Method)\n" +
|
||||
"14: VerifyStackTrace.test(VerifyStackTrace.java:231)\n" +
|
||||
"15: VerifyStackTrace.main(VerifyStackTrace.java:188)\n";
|
||||
|
||||
@ -201,8 +201,6 @@ public class VerifyStackTrace {
|
||||
// out before comparing. We also erase the hash-like names of
|
||||
// synthetic frames introduced by lambdas & method handles
|
||||
return produced.replaceAll(":[1-9][0-9]*\\)", ":00)")
|
||||
.replaceAll("-internal/", "/").replaceAll("-ea/", "/")
|
||||
.replaceAll("java.base@(\\d+\\.){0,3}(\\d+)/", "java.base/")
|
||||
.replaceAll("/[0-9]+\\.run", "/xxxxxxxx.run")
|
||||
.replaceAll("/[0-9]+\\.invoke", "/xxxxxxxx.invoke")
|
||||
// LFs may or may not be pre-generated, making frames differ
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8162817
|
||||
* @bug 8162817 8168921
|
||||
* @summary Test of toString on normal annotations
|
||||
*/
|
||||
|
||||
@ -70,6 +70,8 @@ public class AnnotationToStringTest {
|
||||
"d1=1.0/0.0, " +
|
||||
"l0=5, " +
|
||||
"l1=9223372036854775807L, " +
|
||||
"l2=-9223372036854775808L, " +
|
||||
"l3=-2147483648, " +
|
||||
"s0=\"Hello world.\", " +
|
||||
"s1=\"a\\\"b\", " +
|
||||
"class0=Obj[].class)")
|
||||
@ -84,6 +86,8 @@ public class AnnotationToStringTest {
|
||||
d1=2.0/0.0,
|
||||
l0=5,
|
||||
l1=Long.MAX_VALUE,
|
||||
l2=Long.MIN_VALUE,
|
||||
l3=Integer.MIN_VALUE,
|
||||
s0="Hello world.",
|
||||
s1="a\"b",
|
||||
class0=Obj[].class
|
||||
@ -185,8 +189,10 @@ public class AnnotationToStringTest {
|
||||
public int[] f6;
|
||||
|
||||
@ExpectedString(
|
||||
"@LongArray(value={-2147483647, 2147483648L, 9223372036854775807L})")
|
||||
@LongArray(value={-Integer.MAX_VALUE, Integer.MAX_VALUE+1L, Long.MAX_VALUE})
|
||||
"@LongArray(value={-9223372036854775808L, -2147483649L, -2147483648," +
|
||||
" -2147483647, 2147483648L, 9223372036854775807L})")
|
||||
@LongArray(value={Long.MIN_VALUE, Integer.MIN_VALUE-1L, Integer.MIN_VALUE,
|
||||
-Integer.MAX_VALUE, Integer.MAX_VALUE+1L, Long.MAX_VALUE})
|
||||
public long[] f7;
|
||||
|
||||
@ExpectedString(
|
||||
@ -287,6 +293,8 @@ class Obj {}
|
||||
double d1();
|
||||
long l0();
|
||||
long l1();
|
||||
long l2();
|
||||
long l3();
|
||||
String s0();
|
||||
String s1();
|
||||
Class<?> class0();
|
||||
|
@ -337,9 +337,10 @@ public class ThreadInfoCompositeData {
|
||||
};
|
||||
|
||||
private static final String[] steItemNames = {
|
||||
"className",
|
||||
"classLoaderName",
|
||||
"moduleName",
|
||||
"moduleVersion",
|
||||
"className",
|
||||
"methodName",
|
||||
"fileName",
|
||||
"lineNumber",
|
||||
@ -362,9 +363,10 @@ public class ThreadInfoCompositeData {
|
||||
validItemTypes[STACK_TRACE] = new ArrayType(1, steCType);
|
||||
|
||||
final Object[] steValue = {
|
||||
ste[0].getClassName(),
|
||||
ste[0].getClassLoaderName(),
|
||||
ste[0].getModuleName(),
|
||||
ste[0].getModuleVersion(),
|
||||
ste[0].getClassName(),
|
||||
ste[0].getMethodName(),
|
||||
ste[0].getFileName(),
|
||||
new Integer(ste[0].getLineNumber()),
|
||||
|
@ -109,7 +109,7 @@ public class NullURLTest {
|
||||
failures++;
|
||||
}
|
||||
try {
|
||||
loader = new URLClassLoader(null, null, null);
|
||||
loader = new URLClassLoader((URL[])null, null, null);
|
||||
System.err.println("URLClassLoader(null, null, null) did not throw NPE");
|
||||
failures++;
|
||||
} catch (NullPointerException e) {
|
||||
|
@ -22,124 +22,195 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a simple smoke test of the HttpURLPermission mechanism, which
|
||||
* checks for either IOException (due to unknown host) or SecurityException
|
||||
* due to lack of permission to connect
|
||||
* @test
|
||||
* @summary A simple smoke test of the HttpURLPermission mechanism, which checks
|
||||
* for either IOException (due to unknown host) or SecurityException
|
||||
* due to lack of permission to connect
|
||||
* @run main/othervm LookupTest
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import jdk.testlibrary.Utils;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FilePermission;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.NetPermission;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketPermission;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLPermission;
|
||||
import java.security.CodeSource;
|
||||
import java.security.Permission;
|
||||
import java.security.PermissionCollection;
|
||||
import java.security.Permissions;
|
||||
import java.security.Policy;
|
||||
import java.security.ProtectionDomain;
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
|
||||
public class LookupTest {
|
||||
|
||||
static void test(
|
||||
String url, boolean throwsSecException, boolean throwsIOException)
|
||||
{
|
||||
static int port;
|
||||
static volatile ServerSocket serverSocket;
|
||||
|
||||
static void test(String url,
|
||||
boolean throwsSecException,
|
||||
boolean throwsIOException) {
|
||||
ProxySelector.setDefault(null);
|
||||
URL u;
|
||||
InputStream is = null;
|
||||
try {
|
||||
ProxySelector.setDefault(null);
|
||||
URL u = new URL(url);
|
||||
System.err.println ("Connecting to " + u);
|
||||
u = new URL(url);
|
||||
System.err.println("Connecting to " + u);
|
||||
URLConnection urlc = u.openConnection();
|
||||
InputStream is = urlc.getInputStream();
|
||||
is = urlc.getInputStream();
|
||||
} catch (SecurityException e) {
|
||||
if (!throwsSecException) {
|
||||
throw new RuntimeException ("(1) was not expecting ", e);
|
||||
throw new RuntimeException("Unexpected SecurityException:", e);
|
||||
}
|
||||
return;
|
||||
} catch (IOException ioe) {
|
||||
} catch (IOException e) {
|
||||
if (!throwsIOException) {
|
||||
throw new RuntimeException ("(2) was not expecting ", ioe);
|
||||
System.err.println("Unexpected IOException:" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return;
|
||||
} finally {
|
||||
if (is != null) {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Unexpected IOException:" + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (throwsSecException || throwsIOException) {
|
||||
System.err.printf ("was expecting a %s\n", throwsSecException ?
|
||||
"security exception" : "IOException");
|
||||
System.err.printf("was expecting a %s\n", throwsSecException
|
||||
? "security exception" : "IOException");
|
||||
throw new RuntimeException("was expecting an exception");
|
||||
}
|
||||
}
|
||||
|
||||
static int port;
|
||||
static ServerSocket serverSocket;
|
||||
static final String CWD = System.getProperty("user.dir", ".");
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
|
||||
|
||||
String cmd = args[0];
|
||||
if (cmd.equals("-getport")) {
|
||||
port = Utils.getFreePort();
|
||||
System.out.print(port);
|
||||
} else if (cmd.equals("-runtest")) {
|
||||
port = Integer.parseInt(args[1]);
|
||||
String hostsFileName = System.getProperty("user.dir", ".") + "/LookupTestHosts";
|
||||
System.setProperty("jdk.net.hosts.file", hostsFileName);
|
||||
addMappingToHostsFile("allowedAndFound.com", "127.0.0.1", hostsFileName, false);
|
||||
addMappingToHostsFile("notAllowedButFound.com", "99.99.99.99", hostsFileName, true);
|
||||
// name "notAllowedAndNotFound.com" is not in map
|
||||
// name "allowedButNotfound.com" is not in map
|
||||
try {
|
||||
startServer();
|
||||
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
|
||||
test("http://allowedAndFound.com:" + port + "/foo", false, false);
|
||||
|
||||
test("http://notAllowedButFound.com:" + port + "/foo", true, false);
|
||||
|
||||
test("http://allowedButNotfound.com:" + port + "/foo", false, true);
|
||||
|
||||
test("http://notAllowedAndNotFound.com:" + port + "/foo", true, false);
|
||||
} finally {
|
||||
serverSocket.close();
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("Bad invocation: " + cmd);
|
||||
String hostsFileName = CWD + "/LookupTestHosts";
|
||||
System.setProperty("jdk.net.hosts.file", hostsFileName);
|
||||
addMappingToHostsFile("allowedAndFound.com",
|
||||
"127.0.0.1",
|
||||
hostsFileName,
|
||||
false);
|
||||
addMappingToHostsFile("notAllowedButFound.com",
|
||||
"99.99.99.99",
|
||||
hostsFileName,
|
||||
true);
|
||||
// name "notAllowedAndNotFound.com" is not in map
|
||||
// name "allowedButNotfound.com" is not in map
|
||||
Server server = new Server();
|
||||
try {
|
||||
Policy.setPolicy(new LookupTestPolicy());
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
server.start();
|
||||
test("http://allowedAndFound.com:" + port + "/foo", false, false);
|
||||
test("http://notAllowedButFound.com:" + port + "/foo", true, false);
|
||||
test("http://allowedButNotfound.com:" + port + "/foo", false, true);
|
||||
test("http://notAllowedAndNotFound.com:" + port + "/foo", true, false);
|
||||
} finally {
|
||||
server.terminate();
|
||||
}
|
||||
}
|
||||
|
||||
static Thread server;
|
||||
|
||||
static class Server extends Thread {
|
||||
private volatile boolean done;
|
||||
|
||||
public Server() throws IOException {
|
||||
serverSocket = new ServerSocket(0);
|
||||
port = serverSocket.getLocalPort();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
byte[] buf = new byte[1000];
|
||||
try {
|
||||
while (true) {
|
||||
Socket s = serverSocket.accept();
|
||||
InputStream i = s.getInputStream();
|
||||
i.read(buf);
|
||||
OutputStream o = s.getOutputStream();
|
||||
String rsp = "HTTP/1.1 200 Ok\r\n" +
|
||||
"Connection: close\r\nContent-length: 0\r\n\r\n";
|
||||
o.write(rsp.getBytes());
|
||||
o.close();
|
||||
while (!done) {
|
||||
try (Socket s = serverSocket.accept()) {
|
||||
readOneRequest(s.getInputStream());
|
||||
OutputStream o = s.getOutputStream();
|
||||
String rsp = "HTTP/1.1 200 Ok\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"Content-length: 0\r\n\r\n";
|
||||
o.write(rsp.getBytes(US_ASCII));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return;
|
||||
if (!done)
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void startServer() {
|
||||
try {
|
||||
serverSocket = new ServerSocket(port);
|
||||
server = new Server();
|
||||
server.start();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException ("Test failed to initialize", e);
|
||||
void terminate() {
|
||||
done = true;
|
||||
try { serverSocket.close(); }
|
||||
catch (IOException unexpected) { unexpected.printStackTrace(); }
|
||||
}
|
||||
|
||||
static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n' };
|
||||
|
||||
// Read until the end of a HTTP request
|
||||
void readOneRequest(InputStream is) throws IOException {
|
||||
int requestEndCount = 0, r;
|
||||
while ((r = is.read()) != -1) {
|
||||
if (r == requestEnd[requestEndCount]) {
|
||||
requestEndCount++;
|
||||
if (requestEndCount == 4) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
requestEndCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addMappingToHostsFile (String host,
|
||||
String addr,
|
||||
String hostsFileName,
|
||||
boolean append)
|
||||
throws Exception {
|
||||
private static void addMappingToHostsFile(String host,
|
||||
String addr,
|
||||
String hostsFileName,
|
||||
boolean append)
|
||||
throws IOException
|
||||
{
|
||||
String mapping = addr + " " + host;
|
||||
try (PrintWriter hfPWriter = new PrintWriter(new BufferedWriter(
|
||||
new FileWriter(hostsFileName, append)))) {
|
||||
try (FileWriter fr = new FileWriter(hostsFileName, append);
|
||||
PrintWriter hfPWriter = new PrintWriter(new BufferedWriter(fr))) {
|
||||
hfPWriter.println(mapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class LookupTestPolicy extends Policy {
|
||||
final PermissionCollection perms = new Permissions();
|
||||
|
||||
LookupTestPolicy() throws Exception {
|
||||
perms.add(new NetPermission("setProxySelector"));
|
||||
perms.add(new SocketPermission("localhost:1024-", "resolve,accept"));
|
||||
perms.add(new URLPermission("http://allowedAndFound.com:" + port + "/-", "*:*"));
|
||||
perms.add(new URLPermission("http://allowedButNotfound.com:" + port + "/-", "*:*"));
|
||||
perms.add(new FilePermission("<<ALL FILES>>", "read,write,delete"));
|
||||
//perms.add(new PropertyPermission("java.io.tmpdir", "read"));
|
||||
}
|
||||
|
||||
public PermissionCollection getPermissions(ProtectionDomain domain) {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public PermissionCollection getPermissions(CodeSource codesource) {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||
return perms.implies(perm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2013, 2016 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
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @library /lib/testlibrary
|
||||
# @build jdk.testlibrary.*
|
||||
# @compile -XDignore.symbol.file=true LookupTest.java
|
||||
# @run shell/timeout=50 lookup.sh
|
||||
# @key intermittent
|
||||
#
|
||||
|
||||
OS=`uname -s`
|
||||
case ${OS} in
|
||||
Windows_* | CYGWIN*)
|
||||
PS=";"
|
||||
FS="\\"
|
||||
;;
|
||||
*)
|
||||
PS=":"
|
||||
FS="/"
|
||||
;;
|
||||
esac
|
||||
|
||||
port=`${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} LookupTest -getport`
|
||||
|
||||
cat << POLICY > policy
|
||||
grant {
|
||||
permission java.net.URLPermission "http://allowedAndFound.com:${port}/-", "*:*";
|
||||
permission java.net.URLPermission "http://allowedButNotfound.com:${port}/-", "*:*";
|
||||
permission java.net.NetPermission "setProxySelector";
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
|
||||
permission java.util.PropertyPermission "java.io.tmpdir", "read";
|
||||
|
||||
// needed for HttpServer
|
||||
permission "java.net.SocketPermission" "localhost:1024-", "resolve,accept";
|
||||
};
|
||||
POLICY
|
||||
|
||||
${TESTJAVA}/bin/java ${TESTVMOPTS} \
|
||||
-Djava.security.policy=file:./policy \
|
||||
-Dtest.src=${TESTSRC} \
|
||||
-cp ${TESTCLASSPATH}${PS}${TESTSRC} LookupTest -runtest ${port}
|
@ -21,10 +21,11 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 8087112
|
||||
* @modules java.httpclient
|
||||
* java.logging
|
||||
* jdk.httpserver
|
||||
* @library /lib/testlibrary/
|
||||
* @build jdk.testlibrary.SimpleSSLContext ProxyServer
|
||||
@ -35,13 +36,23 @@
|
||||
*/
|
||||
//package javaapplication16;
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
import com.sun.net.httpserver.HttpContext;
|
||||
import com.sun.net.httpserver.HttpHandler;
|
||||
import com.sun.net.httpserver.HttpServer;
|
||||
import com.sun.net.httpserver.HttpsServer;
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
import java.net.http.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
|
@ -21,10 +21,11 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
/*
|
||||
* @test
|
||||
* @bug 8087112
|
||||
* @modules java.httpclient
|
||||
* java.logging
|
||||
* jdk.httpserver
|
||||
* @library /lib/testlibrary/ /
|
||||
* @build jdk.testlibrary.SimpleSSLContext EchoHandler
|
||||
@ -36,7 +37,9 @@
|
||||
|
||||
//package javaapplication16;
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
import com.sun.net.httpserver.HttpsConfigurator;
|
||||
import com.sun.net.httpserver.HttpsParameters;
|
||||
import com.sun.net.httpserver.HttpsServer;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.http.HttpClient;
|
||||
@ -48,9 +51,10 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Random;
|
||||
import java.util.logging.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import javax.net.ssl.*;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import jdk.testlibrary.SimpleSSLContext;
|
||||
|
||||
public class ManyRequests {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user