--- a/make/autoconf/flags-cflags.m4 Wed Jun 20 11:52:31 2018 +0100
+++ b/make/autoconf/flags-cflags.m4 Wed Jun 20 12:20:29 2018 +0100
@@ -232,7 +232,7 @@
C_O_FLAG_NORM="-xO2 -Wu,-O2~yz"
elif test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then
C_O_FLAG_HIGHEST="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0 \
- -xprefetch=auto,explicit -xchip=ultra $CC_HIGHEST"
+ -xprefetch=auto,explicit $CC_HIGHEST"
C_O_FLAG_HI="-xO4 -Wc,-Qrm-s -Wc,-Qiselect-T0"
C_O_FLAG_NORM="-xO2 -Wc,-Qrm-s -Wc,-Qiselect-T0"
fi
--- a/make/hotspot/lib/JvmOverrideFiles.gmk Wed Jun 20 11:52:31 2018 +0100
+++ b/make/hotspot/lib/JvmOverrideFiles.gmk Wed Jun 20 12:20:29 2018 +0100
@@ -74,6 +74,8 @@
else ifeq ($(OPENJDK_TARGET_OS), solaris)
ifneq ($(DEBUG_LEVEL), slowdebug)
+ # dev studio 12.6 workaround
+ BUILD_LIBJVM_arguments.cpp_OPTIMIZATION := LOW
# Workaround for a bug in dtrace. If ciEnv::post_compiled_method_load_event()
# is inlined, the resulting dtrace object file needs a reference to this
# function, whose symbol name is too long for dtrace. So disable inlining
--- a/make/scripts/compare_exceptions.sh.incl Wed Jun 20 11:52:31 2018 +0100
+++ b/make/scripts/compare_exceptions.sh.incl Wed Jun 20 12:20:29 2018 +0100
@@ -179,7 +179,6 @@
./lib/libsplashscreen.so
./lib/libsunec.so
./lib/libsunwjdga.so
- ./lib/libt2k.so
./lib/libunpack.so
./lib/libverify.so
./lib/libzip.so
@@ -290,7 +289,6 @@
./lib/libsplashscreen.so
./lib/libsunec.so
./lib/libsunwjdga.so
- ./lib/libt2k.so
./lib/libunpack.so
./lib/libverify.so
./lib/libzip.so
--- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp Wed Jun 20 12:20:29 2018 +0100
@@ -2354,15 +2354,6 @@
ushll(Vd, Ta, Vn, Tb, shift);
}
- void uzp1(FloatRegister Vd, FloatRegister Vn, FloatRegister Vm, SIMD_Arrangement T, int op = 0){
- starti;
- f(0, 31), f((T & 0x1), 30), f(0b001110, 29, 24), f((T >> 1), 23, 22), f(0, 21);
- rf(Vm, 16), f(0, 15), f(op, 14), f(0b0110, 13, 10), rf(Vn, 5), rf(Vd, 0);
- }
- void uzp2(FloatRegister Vd, FloatRegister Vn, FloatRegister Vm, SIMD_Arrangement T){
- uzp1(Vd, Vn, Vm, T, 1);
- }
-
// Move from general purpose register
// mov Vd.T[index], Rn
void mov(FloatRegister Vd, SIMD_Arrangement T, int index, Register Xn) {
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -3352,12 +3352,12 @@
pmull2(v19, T8H, v0, v4, T16B);
pmull2(v17, T8H, v0, v6, T16B);
- uzp1(v24, v20, v22, T8H);
- uzp2(v25, v20, v22, T8H);
+ uzp1(v24, T8H, v20, v22);
+ uzp2(v25, T8H, v20, v22);
eor(v20, T16B, v24, v25);
- uzp1(v26, v16, v18, T8H);
- uzp2(v27, v16, v18, T8H);
+ uzp1(v26, T8H, v16, v18);
+ uzp2(v27, T8H, v16, v18);
eor(v16, T16B, v26, v27);
ushll2(v22, T4S, v20, T8H, 8);
@@ -3371,8 +3371,8 @@
eor(v20, T16B, v21, v20);
eor(v16, T16B, v17, v16);
- uzp1(v17, v16, v20, T2D);
- uzp2(v21, v16, v20, T2D);
+ uzp1(v17, T2D, v16, v20);
+ uzp2(v21, T2D, v16, v20);
eor(v17, T16B, v17, v21);
ushll2(v20, T2D, v17, T4S, 16);
@@ -3381,8 +3381,8 @@
eor(v20, T16B, v20, v22);
eor(v16, T16B, v16, v18);
- uzp1(v17, v20, v16, T2D);
- uzp2(v21, v20, v16, T2D);
+ uzp1(v17, T2D, v20, v16);
+ uzp2(v21, T2D, v20, v16);
eor(v28, T16B, v17, v21);
pmull(v22, T8H, v1, v5, T8B);
@@ -3397,12 +3397,12 @@
ld1(v0, v1, T2D, post(buf, 32));
- uzp1(v24, v20, v22, T8H);
- uzp2(v25, v20, v22, T8H);
+ uzp1(v24, T8H, v20, v22);
+ uzp2(v25, T8H, v20, v22);
eor(v20, T16B, v24, v25);
- uzp1(v26, v16, v18, T8H);
- uzp2(v27, v16, v18, T8H);
+ uzp1(v26, T8H, v16, v18);
+ uzp2(v27, T8H, v16, v18);
eor(v16, T16B, v26, v27);
ushll2(v22, T4S, v20, T8H, 8);
@@ -3416,8 +3416,8 @@
eor(v20, T16B, v21, v20);
eor(v16, T16B, v17, v16);
- uzp1(v17, v16, v20, T2D);
- uzp2(v21, v16, v20, T2D);
+ uzp1(v17, T2D, v16, v20);
+ uzp2(v21, T2D, v16, v20);
eor(v16, T16B, v17, v21);
ushll2(v20, T2D, v16, T4S, 16);
@@ -3426,8 +3426,8 @@
eor(v20, T16B, v22, v20);
eor(v16, T16B, v16, v18);
- uzp1(v17, v20, v16, T2D);
- uzp2(v21, v20, v16, T2D);
+ uzp1(v17, T2D, v20, v16);
+ uzp2(v21, T2D, v20, v16);
eor(v20, T16B, v17, v21);
shl(v16, T2D, v28, 1);
--- a/src/hotspot/cpu/arm/macroAssembler_arm.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/cpu/arm/macroAssembler_arm.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -3023,8 +3023,8 @@
mov(Rscratch, SP);
sub(Rscratch, Rmark, Rscratch);
ands(Rscratch, Rscratch, imm);
- b(done, ne); // exit with failure
- str(Rscratch, Address(Rbox, BasicLock::displaced_header_offset_in_bytes())); // set to zero
+ // set to zero if recursive lock, set to non zero otherwise (see discussion in JDK-8153107)
+ str(Rscratch, Address(Rbox, BasicLock::displaced_header_offset_in_bytes()));
b(done);
#else
@@ -3034,7 +3034,8 @@
sub(Rscratch, Rmark, SP, eq);
movs(Rscratch, AsmOperand(Rscratch, lsr, exact_log2(os::vm_page_size())), eq);
// If still 'eq' then recursive locking OK
- str(Rscratch, Address(Rbox, BasicLock::displaced_header_offset_in_bytes()), eq); // set to zero
+ // set to zero if recursive lock, set to non zero otherwise (see discussion in JDK-8153107)
+ str(Rscratch, Address(Rbox, BasicLock::displaced_header_offset_in_bytes()));
b(done);
#endif
--- a/src/hotspot/os/aix/os_aix.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/os/aix/os_aix.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -3737,16 +3737,6 @@
return buf[0] == 'y' || buf[0] == 'Y';
}
-int os::stat(const char *path, struct stat *sbuf) {
- char pathbuf[MAX_PATH];
- if (strlen(path) > MAX_PATH - 1) {
- errno = ENAMETOOLONG;
- return -1;
- }
- os::native_path(strcpy(pathbuf, path));
- return ::stat(pathbuf, sbuf);
-}
-
// Is a (classpath) directory empty?
bool os::dir_is_empty(const char* path) {
DIR *dir = NULL;
--- a/src/hotspot/os/aix/os_aix.inline.hpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/os/aix/os_aix.inline.hpp Wed Jun 20 12:20:29 2018 +0100
@@ -93,10 +93,6 @@
return ::fsync(fd);
}
-inline char* os::native_path(char *path) {
- return path;
-}
-
inline int os::ftruncate(int fd, jlong length) {
return ::ftruncate64(fd, length);
}
--- a/src/hotspot/os/bsd/os_bsd.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/os/bsd/os_bsd.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -3489,16 +3489,6 @@
return buf[0] == 'y' || buf[0] == 'Y';
}
-int os::stat(const char *path, struct stat *sbuf) {
- char pathbuf[MAX_PATH];
- if (strlen(path) > MAX_PATH - 1) {
- errno = ENAMETOOLONG;
- return -1;
- }
- os::native_path(strcpy(pathbuf, path));
- return ::stat(pathbuf, sbuf);
-}
-
static inline struct timespec get_mtime(const char* filename) {
struct stat st;
int ret = os::stat(filename, &st);
--- a/src/hotspot/os/bsd/os_bsd.inline.hpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/os/bsd/os_bsd.inline.hpp Wed Jun 20 12:20:29 2018 +0100
@@ -96,10 +96,6 @@
return ::fsync(fd);
}
-inline char* os::native_path(char *path) {
- return path;
-}
-
inline int os::ftruncate(int fd, jlong length) {
return ::ftruncate(fd, length);
}
--- a/src/hotspot/os/linux/os_linux.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/os/linux/os_linux.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -5378,16 +5378,6 @@
return buf[0] == 'y' || buf[0] == 'Y';
}
-int os::stat(const char *path, struct stat *sbuf) {
- char pathbuf[MAX_PATH];
- if (strlen(path) > MAX_PATH - 1) {
- errno = ENAMETOOLONG;
- return -1;
- }
- os::native_path(strcpy(pathbuf, path));
- return ::stat(pathbuf, sbuf);
-}
-
// Is a (classpath) directory empty?
bool os::dir_is_empty(const char* path) {
DIR *dir = NULL;
--- a/src/hotspot/os/linux/os_linux.inline.hpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/os/linux/os_linux.inline.hpp Wed Jun 20 12:20:29 2018 +0100
@@ -88,10 +88,6 @@
return ::fsync(fd);
}
-inline char* os::native_path(char *path) {
- return path;
-}
-
inline int os::ftruncate(int fd, jlong length) {
return ::ftruncate64(fd, length);
}
--- a/src/hotspot/os/posix/os_posix.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/os/posix/os_posix.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -1334,6 +1334,13 @@
}
+int os::stat(const char *path, struct stat *sbuf) {
+ return ::stat(path, sbuf);
+}
+
+char * os::native_path(char *path) {
+ return path;
+}
// Check minimum allowable stack sizes for thread creation and to initialize
// the java system classes, including StackOverflowError - depends on page
--- a/src/hotspot/os/solaris/os_solaris.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/os/solaris/os_solaris.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -1667,16 +1667,6 @@
return (void*)::dlopen(NULL, RTLD_LAZY);
}
-int os::stat(const char *path, struct stat *sbuf) {
- char pathbuf[MAX_PATH];
- if (strlen(path) > MAX_PATH - 1) {
- errno = ENAMETOOLONG;
- return -1;
- }
- os::native_path(strcpy(pathbuf, path));
- return ::stat(pathbuf, sbuf);
-}
-
static inline time_t get_mtime(const char* filename) {
struct stat st;
int ret = os::stat(filename, &st);
@@ -4474,10 +4464,6 @@
return (jlong) ::lseek64(fd, offset, whence);
}
-char * os::native_path(char *path) {
- return path;
-}
-
int os::ftruncate(int fd, jlong length) {
return ::ftruncate64(fd, length);
}
--- a/src/hotspot/share/gc/z/zArguments.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/share/gc/z/zArguments.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -91,6 +91,10 @@
FLAG_SET_DEFAULT(VerifyDuringStartup, false);
FLAG_SET_DEFAULT(VerifyBeforeExit, false);
+ // Verification before heap iteration not (yet) supported, for the
+ // same reason we need fixup_partial_loads
+ FLAG_SET_DEFAULT(VerifyBeforeIteration, false);
+
// Verification of stacks not (yet) supported, for the same reason
// we need fixup_partial_loads
DEBUG_ONLY(FLAG_SET_DEFAULT(VerifyStack, false));
--- a/src/hotspot/share/gc/z/zServiceability.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/share/gc/z/zServiceability.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -138,6 +138,7 @@
ZServiceabilityManagerStatsTracer::ZServiceabilityManagerStatsTracer(bool is_gc_begin, bool is_gc_end) :
_stats(ZHeap::heap()->serviceability_memory_manager(),
ZCollectedHeap::heap()->gc_cause() /* cause */,
+ true /* allMemoryPoolsAffected */,
is_gc_begin /* recordGCBeginTime */,
is_gc_begin /* recordPreGCUsage */,
true /* recordPeakUsage */,
--- a/src/hotspot/share/jfr/leakprofiler/leakProfiler.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/share/jfr/leakprofiler/leakProfiler.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -42,6 +42,11 @@
static volatile jbyte suspended = 0;
bool LeakProfiler::start(jint sample_count) {
+ if (UseZGC) {
+ log_warning(jfr)("LeakProfiler is currently not supported in combination with ZGC");
+ return false;
+ }
+
if (_object_sampler != NULL) {
// already started
return true;
--- a/src/hotspot/share/jfr/recorder/jfrRecorder.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/share/jfr/recorder/jfrRecorder.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -87,10 +87,28 @@
static JfrStartFlightRecordingDCmd* _startup_recording = NULL;
+static void release_startup_recording() {
+ if (_startup_recording != NULL) {
+ delete _startup_recording;
+ _startup_recording = NULL;
+ }
+}
+
+static void teardown_startup_support() {
+ release_startup_recording();
+ JfrOptionSet::release_startup_recordings();
+}
+
+
// Parsing options here to detect errors as soon as possible
-static bool parse_startup_recording(TRAPS) {
- assert(StartFlightRecording != NULL, "invariant");
- CmdLine cmdline(StartFlightRecording, strlen(StartFlightRecording), true);
+static bool parse_recording_options(const char* options, TRAPS) {
+ assert(options != NULL, "invariant");
+ if (_startup_recording != NULL) {
+ delete _startup_recording;
+ }
+ CmdLine cmdline(options, strlen(options), true);
+ _startup_recording = new (ResourceObj::C_HEAP, mtTracing) JfrStartFlightRecordingDCmd(tty, true);
+ assert(_startup_recording != NULL, "invariant");
_startup_recording->parse(&cmdline, ',', THREAD);
if (HAS_PENDING_EXCEPTION) {
java_lang_Throwable::print(PENDING_EXCEPTION, tty);
@@ -100,31 +118,61 @@
return true;
}
-static bool initialize_startup_recording(TRAPS) {
- if (StartFlightRecording != NULL) {
- _startup_recording = new (ResourceObj::C_HEAP, mtTracing) JfrStartFlightRecordingDCmd(tty, true);
- return _startup_recording != NULL && parse_startup_recording(THREAD);
+static bool validate_recording_options(TRAPS) {
+ const GrowableArray<const char*>* startup_options = JfrOptionSet::startup_recordings();
+ if (startup_options == NULL) {
+ return true;
+ }
+ const int length = startup_options->length();
+ assert(length >= 1, "invariant");
+ for (int i = 0; i < length; ++i) {
+ if (!parse_recording_options(startup_options->at(i), THREAD)) {
+ return false;
+ }
}
return true;
}
-static bool startup_recording(TRAPS) {
- if (_startup_recording == NULL) {
- return true;
- }
- log_trace(jfr, system)("Starting up Jfr startup recording");
+static bool launch_recording(TRAPS) {
+ assert(_startup_recording != NULL, "invariant");
+ log_trace(jfr, system)("Starting a recording");
_startup_recording->execute(DCmd_Source_Internal, Thread::current());
- delete _startup_recording;
- _startup_recording = NULL;
if (HAS_PENDING_EXCEPTION) {
- log_debug(jfr, system)("Exception while starting Jfr startup recording");
+ log_debug(jfr, system)("Exception while starting a recording");
CLEAR_PENDING_EXCEPTION;
return false;
}
- log_trace(jfr, system)("Finished starting Jfr startup recording");
+ log_trace(jfr, system)("Finished starting a recording");
return true;
}
+static bool launch_recordings(const GrowableArray<const char*>* startup_options, TRAPS) {
+ assert(startup_options != NULL, "invariant");
+ const int length = startup_options->length();
+ assert(length >= 1, "invariant");
+ if (length == 1) {
+ // already parsed and ready, launch it
+ return launch_recording(THREAD);
+ }
+ for (int i = 0; i < length; ++i) {
+ parse_recording_options(startup_options->at(i), THREAD);
+ if (!launch_recording(THREAD)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+static bool startup_recordings(TRAPS) {
+ const GrowableArray<const char*>* startup_options = JfrOptionSet::startup_recordings();
+ if (startup_options == NULL) {
+ return true;
+ }
+ const bool ret = launch_recordings(startup_options, THREAD);
+ teardown_startup_support();
+ return ret;
+}
+
static void log_jdk_jfr_module_resolution_error(TRAPS) {
LogTarget(Error, jfr, system) lt_error;
LogTargetHandle handle(lt_error);
@@ -141,7 +189,7 @@
if (!register_jfr_dcmds()) {
return false;
}
- if (!initialize_startup_recording(thread)) {
+ if (!validate_recording_options(thread)) {
return false;
}
if (in_graph) {
@@ -159,7 +207,7 @@
log_jdk_jfr_module_resolution_error(thread);
return false;
}
- return startup_recording(thread);
+ return startup_recordings(thread);
}
static bool _created = false;
--- a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -34,6 +34,7 @@
#include "runtime/thread.inline.hpp"
#include "services/diagnosticArgument.hpp"
#include "services/diagnosticFramework.hpp"
+#include "utilities/growableArray.hpp"
#include "utilities/ostream.hpp"
struct ObsoleteOption {
@@ -664,42 +665,51 @@
return true;
}
-/*
-
-to support starting multiple startup recordings
-
-static const char* start_flight_recording_option_original = NULL;
-static const char* flight_recorder_option_original = NULL;
-
-static void copy_option_string(const JavaVMOption* option, const char** addr) {
- assert(option != NULL, "invariant");
- assert(option->optionString != NULL, "invariant");
- const size_t length = strlen(option->optionString);
- *addr = JfrCHeapObj::new_array<char>(length + 1);
- assert(*addr != NULL, "invarinat");
- strncpy((char*)*addr, option->optionString, length + 1);
- assert(strncmp(*addr, option->optionString, length + 1) == 0, "invariant");
-}
-
-copy_option_string(*option, &start_flight_recording_option_original);
-copy_option_string(*option, &flight_recorder_option_original);
-*/
+static GrowableArray<const char*>* startup_recording_array = NULL;
bool JfrOptionSet::parse_start_flight_recording_option(const JavaVMOption** option, char* tail) {
assert(option != NULL, "invariant");
assert(tail != NULL, "invariant");
assert((*option)->optionString != NULL, "invariant");
assert(strncmp((*option)->optionString, "-XX:StartFlightRecording", 24) == 0, "invariant");
+ const char* param_string = NULL;
if (*tail == '\0') {
// Add dummy dumponexit=false so -XX:StartFlightRecording can be used without a parameter.
// The existing option->optionString points to stack memory so no need to deallocate.
const_cast<JavaVMOption*>(*option)->optionString = (char*)"-XX:StartFlightRecording=dumponexit=false";
+ param_string = (*option)->optionString + 25;
} else {
*tail = '='; // ":" -> "="
+ param_string = tail + 1;
}
+ assert(param_string != NULL, "invariant");
+ const size_t param_length = strlen(param_string);
+
+ if (startup_recording_array == NULL) {
+ startup_recording_array = new (ResourceObj::C_HEAP, mtTracing) GrowableArray<const char*>(8, true, mtTracing);
+ }
+ assert(startup_recording_array != NULL, "invariant");
+ char* startup_options = NEW_C_HEAP_ARRAY(char, param_length + 1, mtTracing);
+ strncpy(startup_options, param_string, strlen(param_string) + 1);
+ assert(strncmp(param_string, startup_options, param_length) == 0, "invariant");
+ startup_recording_array->append(startup_options);
return false;
}
+const GrowableArray<const char*>* JfrOptionSet::startup_recordings() {
+ return startup_recording_array;
+}
+
+void JfrOptionSet::release_startup_recordings() {
+ if (startup_recording_array != NULL) {
+ for (int i = 0; i < startup_recording_array->length(); ++i) {
+ FREE_C_HEAP_ARRAY(char, startup_recording_array->at(i));
+ }
+ }
+ delete startup_recording_array;
+ DEBUG_ONLY(startup_recording_array = NULL;)
+}
+
bool JfrOptionSet::parse_flight_recorder_option(const JavaVMOption** option, char* tail) {
assert(option != NULL, "invariant");
assert(tail != NULL, "invariant");
--- a/src/hotspot/share/jfr/recorder/service/jfrOptionSet.hpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/share/jfr/recorder/service/jfrOptionSet.hpp Wed Jun 20 12:20:29 2018 +0100
@@ -29,6 +29,9 @@
#include "memory/allocation.hpp"
#include "utilities/exceptions.hpp"
+template <typename>
+class GrowableArray;
+
//
// Command-line options and defaults
//
@@ -78,6 +81,8 @@
static bool parse_start_flight_recording_option(const JavaVMOption** option, char* tail);
static bool parse_flight_recorder_option(const JavaVMOption** option, char* tail);
+ static const GrowableArray<const char*>* startup_recordings();
+ static void release_startup_recordings();
};
#endif // SHARE_VM_JFR_RECORDER_SERVICE_JFROPTIONSET_HPP
--- a/src/hotspot/share/runtime/os.hpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/share/runtime/os.hpp Wed Jun 20 12:20:29 2018 +0100
@@ -558,6 +558,9 @@
static FILE* fopen(const char* path, const char* mode);
static int close(int fd);
static jlong lseek(int fd, jlong offset, int whence);
+ // This function, on Windows, canonicalizes a given path (see os_windows.cpp for details).
+ // On Posix, this function is a noop: it does not change anything and just returns
+ // the input pointer.
static char* native_path(char *path);
static int ftruncate(int fd, jlong length);
static int fsync(int fd);
--- a/src/hotspot/share/runtime/sharedRuntime.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -1989,11 +1989,7 @@
// Handles the uncommon case in locking, i.e., contention or an inflated lock.
JRT_BLOCK_ENTRY(void, SharedRuntime::complete_monitor_locking_C(oopDesc* _obj, BasicLock* lock, JavaThread* thread))
- // Disable ObjectSynchronizer::quick_enter() in default config
- // on AARCH64 and ARM until JDK-8153107 is resolved.
- if (ARM_ONLY((SyncFlags & 256) != 0 &&)
- AARCH64_ONLY((SyncFlags & 256) != 0 &&)
- !SafepointSynchronize::is_synchronizing()) {
+ if (!SafepointSynchronize::is_synchronizing()) {
// Only try quick_enter() if we're not trying to reach a safepoint
// so that the calling thread reaches the safepoint more quickly.
if (ObjectSynchronizer::quick_enter(_obj, thread, lock)) return;
--- a/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java Wed Jun 20 12:20:29 2018 +0100
@@ -114,6 +114,9 @@
* Used by RSASignature and RSACipher.
*/
public static RSAKey toRSAKey(Key key) throws InvalidKeyException {
+ if (key == null) {
+ throw new InvalidKeyException("Key must not be null");
+ }
if ((key instanceof RSAPrivateKeyImpl) ||
(key instanceof RSAPrivateCrtKeyImpl) ||
(key instanceof RSAPublicKeyImpl)) {
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java Wed Jun 20 12:20:29 2018 +0100
@@ -74,10 +74,17 @@
// This is used to create a CImage from a Image
public static CImage createFromImage(final Image image) {
- return getCreator().createFromImage(image);
+ return getCreator().createFromImage(image, null);
+ }
+
+ // This is used to create a CImage from a Image
+ public static CImage createFromImage(final Image image, CTrayIcon.IconObserver observer) {
+ return getCreator().createFromImage(image, observer);
}
public static class Creator {
+ CTrayIcon.IconObserver observer;
+
Creator() { }
// This is used to create a CImage with an NSImage pointer. It MUST be a CFRetained
@@ -124,7 +131,7 @@
return createImageUsingNativeSize(nativeCreateNSImageFromImageName(name));
}
- private static int[] imageToArray(Image image, boolean prepareImage) {
+ private static int[] imageToArray(Image image, boolean prepareImage, CTrayIcon.IconObserver observer) {
if (image == null) return null;
if (prepareImage && !(image instanceof BufferedImage)) {
@@ -153,14 +160,14 @@
BufferedImage bimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
Graphics2D g2 = bimg.createGraphics();
g2.setComposite(AlphaComposite.Src);
- g2.drawImage(image, 0, 0, null);
+ g2.drawImage(image, 0, 0, observer);
g2.dispose();
return ((DataBufferInt)bimg.getRaster().getDataBuffer()).getData();
}
public byte[] getPlatformImageBytes(final Image image) {
- int[] buffer = imageToArray(image, false);
+ int[] buffer = imageToArray(image, false, null);
if (buffer == null) {
return null;
@@ -178,22 +185,27 @@
// This is used to create a CImage from a Image
public CImage createFromImage(final Image image) {
- return createFromImage(image, true);
+ return createFromImage(image, true, null);
+ }
+
+ // This is used to create a CImage from a Image
+ public CImage createFromImage(final Image image, CTrayIcon.IconObserver observer) {
+ return createFromImage(image, true, observer);
}
public CImage createFromImageImmediately(final Image image) {
- return createFromImage(image, false);
+ return createFromImage(image, false, null);
}
// This is used to create a CImage from a Image
- private CImage createFromImage(final Image image, final boolean prepareImage) {
+ private CImage createFromImage(final Image image, final boolean prepareImage, CTrayIcon.IconObserver observer) {
if (image instanceof MultiResolutionImage) {
List<Image> resolutionVariants
= ((MultiResolutionImage) image).getResolutionVariants();
return createFromImages(resolutionVariants, prepareImage);
}
- int[] buffer = imageToArray(image, prepareImage);
+ int[] buffer = imageToArray(image, prepareImage, observer);
if (buffer == null) {
return null;
}
@@ -218,7 +230,7 @@
num = 0;
for (final Image img : images) {
- buffers[num] = imageToArray(img, prepareImage);
+ buffers[num] = imageToArray(img, prepareImage, null);
if (buffers[num] == null) {
// Unable to process the image
continue;
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Wed Jun 20 12:20:29 2018 +0100
@@ -43,6 +43,7 @@
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
import java.awt.peer.TrayIconPeer;
import javax.swing.Icon;
@@ -61,6 +62,7 @@
// Component target. Because TrayIcon isn't Component's subclass,
// we use this dummy frame instead
private final Frame dummyFrame;
+ IconObserver observer = new IconObserver();
// A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events
// on MOUSE_RELEASE. Click events are only generated if there were no drag
@@ -143,7 +145,7 @@
CImage cimage = null;
if (icon != null) {
BufferedImage image = scaleIcon(icon, 0.75);
- cimage = CImage.getCreator().createFromImage(image);
+ cimage = CImage.getCreator().createFromImage(image, null);
}
if (cimage != null) {
cimage.execute(imagePtr -> {
@@ -184,9 +186,14 @@
@Override
public void updateImage() {
+
Image image = target.getImage();
- if (image == null) return;
+ if (image != null) {
+ updateNativeImage(image);
+ }
+ }
+ void updateNativeImage(Image image) {
MediaTracker tracker = new MediaTracker(new Button(""));
tracker.addImage(image, 0);
try {
@@ -199,7 +206,7 @@
return;
}
- CImage cimage = CImage.getCreator().createFromImage(image);
+ CImage cimage = CImage.getCreator().createFromImage(image, observer);
boolean imageAutoSize = target.isImageAutoSize();
cimage.execute(imagePtr -> {
execute(ptr -> {
@@ -346,5 +353,25 @@
return UIManager.getIcon("OptionPane.informationIcon");
}
}
+
+ class IconObserver implements ImageObserver {
+ @Override
+ public boolean imageUpdate(Image image, int flags, int x, int y, int width, int height) {
+ if (image != target.getImage()) // if the image has been changed
+ {
+ return false;
+ }
+ if ((flags & (ImageObserver.FRAMEBITS | ImageObserver.ALLBITS |
+ ImageObserver.WIDTH | ImageObserver.HEIGHT)) != 0)
+ {
+ SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
+ public void run() {
+ updateNativeImage(image);
+ }
+ });
+ }
+ return (flags & ImageObserver.ALLBITS) == 0;
+ }
+ }
}
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m Wed Jun 20 12:20:29 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, 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
@@ -325,15 +325,15 @@
}
JavaComponentAccessibility *child = [self createWithParent:parent accessible:jchild role:childJavaRole index:childIndex withEnv:env withView:parent->fView];
-
+
(*env)->DeleteLocalRef(env, jchild);
(*env)->DeleteLocalRef(env, jchildJavaRole);
-
+
[children addObject:child];
childIndex++;
}
(*env)->DeleteLocalRef(env, jchildrenAndRoles);
-
+
return children;
}
@@ -646,6 +646,9 @@
}
// The above set of attributes is immutable per role, but some objects, if
// they are the child of a list, need to add the selected and index attributes.
+ if ([self accessibilityIsIgnored]) {
+ return names;
+ }
id myParent = [self accessibilityParentAttribute];
if ([myParent isKindOfClass:[JavaComponentAccessibility class]]) {
NSString *parentRole = [(JavaComponentAccessibility *)myParent javaRole];
@@ -1060,7 +1063,7 @@
sjc_CAccessibility,
"requestSelection",
"(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V" );
-
+
if ([(NSNumber*)value boolValue]) {
JNIEnv* env = [ThreadUtilities getJNIEnv];
JNFCallStaticVoidMethod(env, jm_requestSelection, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
@@ -1167,7 +1170,7 @@
// Need to handle popupmenus differently.
//
// At least for now don't handle combo box menus.
- // This may change when later fixing issues which currently
+ // This may change when later fixing issues which currently
// exist for combo boxes, but for now the following is only
// for JPopupMenus, not for combobox menus.
id parent = [self parent];
@@ -1349,7 +1352,7 @@
NSWindow* hostWindow = [[self->fView window] retain];
jobject focused = JNFCallStaticObjectMethod(env, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop)
[hostWindow release];
-
+
if (focused != NULL) {
if (JNFIsInstanceOf(env, focused, &sjc_Accessible)) {
value = [JavaComponentAccessibility createWithAccessible:focused withEnv:env withView:fView];
--- a/src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java Wed Jun 20 12:20:29 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MetaEventListener;
@@ -76,6 +78,7 @@
private Sequencer sequencer = null;
private Sequence sequence = null;
private boolean sequencerloop = false;
+ private volatile boolean success;
/**
* used for determining how many samples is the
@@ -91,12 +94,31 @@
//private final static long CLIP_THRESHOLD = 1;
private static final int STREAM_BUFFER_SIZE = 1024;
- public JavaSoundAudioClip(InputStream in) throws IOException {
+ public static JavaSoundAudioClip create(final URLConnection uc) {
+ JavaSoundAudioClip clip = new JavaSoundAudioClip();
+ try {
+ clip.init(uc.getInputStream());
+ } catch (final Exception ignored) {
+ // AudioClip will be no-op if some exception will occurred
+ }
+ return clip;
+ }
+
+ public static JavaSoundAudioClip create(final URL url) {
+ JavaSoundAudioClip clip = new JavaSoundAudioClip();
+ try {
+ clip.init(url.openStream());
+ } catch (final Exception ignored) {
+ // AudioClip will be no-op if some exception will occurred
+ }
+ return clip;
+ }
+
+ private void init(InputStream in) throws IOException {
if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.<init>");
BufferedInputStream bis = new BufferedInputStream(in, STREAM_BUFFER_SIZE);
bis.mark(STREAM_BUFFER_SIZE);
- boolean success = false;
try {
AudioInputStream as = AudioSystem.getAudioInputStream(bis);
// load the stream data into memory
@@ -120,18 +142,21 @@
success = false;
}
}
- if (!success) {
- throw new IOException("Unable to create AudioClip from input stream");
- }
}
@Override
public synchronized void play() {
+ if (!success) {
+ return;
+ }
startImpl(false);
}
@Override
public synchronized void loop() {
+ if (!success) {
+ return;
+ }
startImpl(true);
}
@@ -206,6 +231,9 @@
@Override
public synchronized void stop() {
+ if (!success) {
+ return;
+ }
if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip->stop()");
lastPlayCall = 0;
--- a/src/java.desktop/share/classes/java/applet/Applet.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/java/applet/Applet.java Wed Jun 20 12:20:29 2018 +0100
@@ -42,6 +42,8 @@
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
+import com.sun.media.sound.JavaSoundAudioClip;
+
/**
* An applet is a small program that is intended not to be run on
* its own, but rather to be embedded inside another application.
@@ -322,7 +324,7 @@
* @since 1.2
*/
public static final AudioClip newAudioClip(URL url) {
- return new sun.applet.AppletAudioClip(url);
+ return JavaSoundAudioClip.create(url);
}
/**
--- a/src/java.desktop/share/classes/javax/swing/SwingWorker.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/javax/swing/SwingWorker.java Wed Jun 20 12:20:29 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -22,21 +22,30 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package javax.swing;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.lang.ref.WeakReference;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.beans.PropertyChangeEvent;
import java.util.List;
-import java.util.concurrent.*;
-import java.util.concurrent.locks.*;
-
-import java.awt.event.*;
-
-import javax.swing.SwingUtilities;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RunnableFuture;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import sun.awt.AppContext;
import sun.swing.AccumulativeRunnable;
@@ -597,6 +606,8 @@
* //the dialog will be visible until the SwingWorker is done
* dialog.setVisible(true);
* </pre>
+ *
+ * @throws CancellationException {@inheritDoc}
*/
public final T get() throws InterruptedException, ExecutionException {
return future.get();
@@ -606,6 +617,8 @@
* {@inheritDoc}
* <p>
* Please refer to {@link #get} for more details.
+ *
+ * @throws CancellationException {@inheritDoc}
*/
public final T get(long timeout, TimeUnit unit) throws InterruptedException,
ExecutionException, TimeoutException {
--- a/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java Wed Jun 20 12:20:29 2018 +0100
@@ -364,8 +364,9 @@
this, p0);
} else {
p = p0 + Utilities.getTabbedTextOffset(segment, metrics,
- tabBase, tabBase + currentWidth,
- this, p0, false);
+ (float)tabBase,
+ (float)(tabBase + currentWidth),
+ this, p0, false);
}
SegmentCache.releaseSharedSegment(segment);
return p;
@@ -847,8 +848,8 @@
Segment segment = SegmentCache.getSharedSegment();
loadText(segment, p0, p1);
int n = Utilities.getTabbedTextOffset(segment, metrics,
- alloc.x, x,
- WrappedPlainView.this, p0);
+ (float)alloc.x, (float)x,
+ WrappedPlainView.this, p0, false);
SegmentCache.releaseSharedSegment(segment);
return Math.min(p0 + n, p1 - 1);
}
--- a/src/java.desktop/share/classes/module-info.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/module-info.java Wed Jun 20 12:20:29 2018 +0100
@@ -108,7 +108,12 @@
// qualified exports may be inserted at build time
// see make/GensrcModuleInfo.gmk
exports sun.awt to
- jdk.accessibility;
+ jdk.accessibility,
+ jdk.unsupported.desktop;
+
+ exports java.awt.dnd.peer to jdk.unsupported.desktop;
+ exports sun.awt.dnd to jdk.unsupported.desktop;
+ exports sun.swing to jdk.unsupported.desktop;
opens javax.swing.plaf.basic to
jdk.jconsole;
@@ -131,6 +136,8 @@
uses javax.sound.sampled.spi.FormatConversionProvider;
uses javax.sound.sampled.spi.MixerProvider;
+ uses sun.swing.InteropProvider;
+
provides sun.datatransfer.DesktopDatatransferService with
sun.awt.datatransfer.DesktopDatatransferServiceImpl;
--- a/src/java.desktop/share/classes/sun/applet/AppletAudioClip.java Wed Jun 20 11:52:31 2018 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 1995, 2003, 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 sun.applet;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import java.applet.AudioClip;
-
-import com.sun.media.sound.JavaSoundAudioClip;
-
-
-/**
- * Applet audio clip;
- *
- * @author Arthur van Hoff, Kara Kytle
- */
-
-@SuppressWarnings("deprecation")
-public class AppletAudioClip implements AudioClip {
-
- // url that this AudioClip is based on
- private URL url = null;
-
- // the audio clip implementation
- private AudioClip audioClip = null;
-
- boolean DEBUG = false /*true*/;
-
- /**
- * Constructs an AppletAudioClip from an URL.
- */
- public AppletAudioClip(URL url) {
-
- // store the url
- this.url = url;
-
- try {
- // create a stream from the url, and use it
- // in the clip.
- InputStream in = url.openStream();
- createAppletAudioClip(in);
-
- } catch (IOException e) {
- /* just quell it */
- if (DEBUG) {
- System.err.println("IOException creating AppletAudioClip" + e);
- }
- }
- }
-
- /**
- * Constructs an AppletAudioClip from a URLConnection.
- */
- public AppletAudioClip(URLConnection uc) {
-
- try {
- // create a stream from the url, and use it
- // in the clip.
- createAppletAudioClip(uc.getInputStream());
-
- } catch (IOException e) {
- /* just quell it */
- if (DEBUG) {
- System.err.println("IOException creating AppletAudioClip" + e);
- }
- }
- }
-
-
- /**
- * For constructing directly from Jar entries, or any other
- * raw Audio data. Note that the data provided must include the format
- * header.
- */
- public AppletAudioClip(byte [] data) {
-
- try {
-
- // construct a stream from the byte array
- InputStream in = new ByteArrayInputStream(data);
-
- createAppletAudioClip(in);
-
- } catch (IOException e) {
- /* just quell it */
- if (DEBUG) {
- System.err.println("IOException creating AppletAudioClip " + e);
- }
- }
- }
-
-
- /*
- * Does the real work of creating an AppletAudioClip from an InputStream.
- * This function is used by both constructors.
- */
- void createAppletAudioClip(InputStream in) throws IOException {
-
- try {
- audioClip = new JavaSoundAudioClip(in);
- } catch (Exception e3) {
- // no matter what happened, we throw an IOException to avoid changing the interfaces....
- throw new IOException("Failed to construct the AudioClip: " + e3);
- }
- }
-
-
- public synchronized void play() {
-
- if (audioClip != null)
- audioClip.play();
- }
-
-
- public synchronized void loop() {
-
- if (audioClip != null)
- audioClip.loop();
- }
-
- public synchronized void stop() {
-
- if (audioClip != null)
- audioClip.stop();
- }
-}
--- a/src/java.desktop/share/classes/sun/awt/www/content/audio/aiff.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/awt/www/content/audio/aiff.java Wed Jun 20 12:20:29 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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,21 +23,21 @@
* questions.
*/
-/**
- * Basic .aiff audio handler.
- * @author Jeff Nisewanger
- */
package sun.awt.www.content.audio;
-import java.net.*;
import java.io.IOException;
-import sun.applet.AppletAudioClip;
+import java.net.ContentHandler;
+import java.net.URLConnection;
+
+import com.sun.media.sound.JavaSoundAudioClip;
/**
- * Returns an AppletAudioClip object.
+ * Basic .aiff audio handler returns an JavaSoundAudioClip object.
+ *
+ * @author Jeff Nisewanger
*/
public class aiff extends ContentHandler {
public Object getContent(URLConnection uc) throws IOException {
- return new AppletAudioClip(uc);
+ return JavaSoundAudioClip.create(uc);
}
}
--- a/src/java.desktop/share/classes/sun/awt/www/content/audio/basic.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/awt/www/content/audio/basic.java Wed Jun 20 12:20:29 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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,23 +23,24 @@
* questions.
*/
-/**
- * Basic .au and .snd audio handler.
- * @author Jeff Nisewanger
- */
package sun.awt.www.content.audio;
-import java.net.*;
import java.io.IOException;
-import sun.applet.AppletAudioClip;
+import java.net.ContentHandler;
+import java.net.URLConnection;
+
+import com.sun.media.sound.JavaSoundAudioClip;
/**
- * Returns an AppletAudioClip object.
+ * Basic .au and .snd audio handler returns an JavaSoundAudioClip object.
+ * <p>
* This provides backwards compatibility with the behavior
* of ClassLoader.getResource().getContent() on JDK1.1.
+ *
+ * @author Jeff Nisewanger
*/
public class basic extends ContentHandler {
public Object getContent(URLConnection uc) throws IOException {
- return new AppletAudioClip(uc);
+ return JavaSoundAudioClip.create(uc);
}
}
--- a/src/java.desktop/share/classes/sun/awt/www/content/audio/wav.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/awt/www/content/audio/wav.java Wed Jun 20 12:20:29 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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,21 +23,21 @@
* questions.
*/
-/**
- * Basic .wav audio handler.
- * @author Jeff Nisewanger
- */
package sun.awt.www.content.audio;
-import java.net.*;
import java.io.IOException;
-import sun.applet.AppletAudioClip;
+import java.net.ContentHandler;
+import java.net.URLConnection;
+
+import com.sun.media.sound.JavaSoundAudioClip;
/**
- * Returns an AppletAudioClip object.
+ * Basic .wav audio handler returns an JavaSoundAudioClip object.
+ *
+ * @author Jeff Nisewanger
*/
public class wav extends ContentHandler {
public Object getContent(URLConnection uc) throws IOException {
- return new AppletAudioClip(uc);
+ return JavaSoundAudioClip.create(uc);
}
}
--- a/src/java.desktop/share/classes/sun/awt/www/content/audio/x_aiff.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/awt/www/content/audio/x_aiff.java Wed Jun 20 12:20:29 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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,21 +23,21 @@
* questions.
*/
-/**
- * Basic .aiff audio handler.
- * @author Jeff Nisewanger
- */
package sun.awt.www.content.audio;
-import java.net.*;
import java.io.IOException;
-import sun.applet.AppletAudioClip;
+import java.net.ContentHandler;
+import java.net.URLConnection;
+
+import com.sun.media.sound.JavaSoundAudioClip;
/**
- * Returns an AppletAudioClip object.
+ * Basic .aiff audio handler returns an JavaSoundAudioClip object.
+ *
+ * @author Jeff Nisewanger
*/
public class x_aiff extends ContentHandler {
public Object getContent(URLConnection uc) throws IOException {
- return new AppletAudioClip(uc);
+ return JavaSoundAudioClip.create(uc);
}
}
--- a/src/java.desktop/share/classes/sun/awt/www/content/audio/x_wav.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/awt/www/content/audio/x_wav.java Wed Jun 20 12:20:29 2018 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2018, 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,21 +23,21 @@
* questions.
*/
-/**
- * Basic .wav audio handler.
- * @author Jeff Nisewanger
- */
package sun.awt.www.content.audio;
-import java.net.*;
import java.io.IOException;
-import sun.applet.AppletAudioClip;
+import java.net.ContentHandler;
+import java.net.URLConnection;
+
+import com.sun.media.sound.JavaSoundAudioClip;
/**
- * Returns an AppletAudioClip object.
+ * Basic .wav audio handler returns an JavaSoundAudioClip object.
+ *
+ * @author Jeff Nisewanger
*/
public class x_wav extends ContentHandler {
public Object getContent(URLConnection uc) throws IOException {
- return new AppletAudioClip(uc);
+ return JavaSoundAudioClip.create(uc);
}
}
--- a/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/font/CompositeGlyphMapper.java Wed Jun 20 12:20:29 2018 +0100
@@ -28,7 +28,7 @@
/* remember that the API requires a Font use a
* consistent glyph id. for a code point, and this is a
* problem if a particular strike uses native scaler sometimes
- * and T2K others. That needs to be dealt with somewhere, but
+ * and the JDK scaler others. That needs to be dealt with somewhere, but
* here we can just always get the same glyph code without
* needing a strike.
*
--- a/src/java.desktop/share/classes/sun/font/FontManagerNativeLibrary.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/font/FontManagerNativeLibrary.java Wed Jun 20 12:20:29 2018 +0100
@@ -50,9 +50,6 @@
To avoid link error we have to load freetype explicitly
before we load fontmanager.
- Note that we do not need to do this for T2K because
- fontmanager.dll does not depend on t2k.dll.
-
NB: consider moving freetype wrapper part to separate
shared library in order to avoid dependency. */
System.loadLibrary("freetype");
--- a/src/java.desktop/share/classes/sun/font/FontScaler.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/font/FontScaler.java Wed Jun 20 12:20:29 2018 +0100
@@ -29,7 +29,6 @@
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.lang.ref.WeakReference;
-import java.lang.reflect.Constructor;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
@@ -82,51 +81,16 @@
public abstract class FontScaler implements DisposerRecord {
private static FontScaler nullScaler = null;
- private static Constructor<? extends FontScaler> scalerConstructor = null;
//Find preferred font scaler
//
//NB: we can allow property based preferences
// (theoretically logic can be font type specific)
- static {
- Class<? extends FontScaler> scalerClass = null;
- Class<?>[] arglst = new Class<?>[] {Font2D.class, int.class,
- boolean.class, int.class};
-
- try {
- @SuppressWarnings("unchecked")
- Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
- ((!FontUtilities.useT2K && !FontUtilities.useLegacy) ?
- Class.forName("sun.font.FreetypeFontScaler") :
- Class.forName("sun.font.T2KFontScaler"));
- scalerClass = tmp;
- } catch (ClassNotFoundException e) {
- try {
- @SuppressWarnings("unchecked")
- Class<? extends FontScaler> tmp = (Class<? extends FontScaler>)
- Class.forName("sun.font.FreetypeFontScaler");
- scalerClass = tmp;
- } catch (ClassNotFoundException e1) {
- scalerClass = NullFontScaler.class;
- }
- } finally {
- if (FontUtilities.debugFonts()) {
- System.out.println("Scaler class="+scalerClass);
- }
- }
-
- //NB: rewrite using factory? constructor is ugly way
- try {
- scalerConstructor = scalerClass.getConstructor(arglst);
- } catch (NoSuchMethodException e) {
- //should not happen
- }
- }
/* This is the only place to instantiate new FontScaler.
* Therefore this is very convinient place to register
- * scaler with Disposer as well as trigger deregistring bad font
- * in case when scaler reports this.
+ * scaler with Disposer as well as trigger deregistering a bad font
+ * when the scaler reports this.
*/
public static FontScaler getScaler(Font2D font,
int indexInCollection,
@@ -135,14 +99,13 @@
FontScaler scaler = null;
try {
- Object args[] = new Object[] {font, indexInCollection,
- supportsCJK, filesize};
- scaler = scalerConstructor.newInstance(args);
+ scaler = new FreetypeFontScaler(font, indexInCollection,
+ supportsCJK, filesize);
Disposer.addObjectRecord(font, scaler);
} catch (Throwable e) {
- scaler = nullScaler;
+ scaler = getNullScaler();
- //if we can not instantiate scaler assume bad font
+ //if we can not instantiate scaler assume a bad font
//NB: technically it could be also because of internal scaler
// error but here we are assuming scaler is ok.
FontManager fm = FontManagerFactory.getInstance();
--- a/src/java.desktop/share/classes/sun/font/FontUtilities.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/font/FontUtilities.java Wed Jun 20 12:20:29 2018 +0100
@@ -52,10 +52,6 @@
public static boolean useJDKScaler;
- public static boolean useT2K;
- // useLegacy is a short-term debugging transition aid.
- public static boolean useLegacy;
-
public static boolean isWindows;
private static boolean debugFonts = false;
@@ -76,33 +72,16 @@
isMacOSX = osName.contains("OS X"); // TODO: MacOSX
- /* Support a value of "t2k" as meaning use the JDK internal
- * scaler over the platform scaler whether or not t2k is
- * actually available.
- * This can be considered transitional support for some
- * level of compatibility, as in it avoids the native scaler
- * as before but cannot guarantee rendering equivalence
- * with T2K.
- * It will also use t2k instead of freetype if t2k is
- * available - this is the same as before.
- * The new value of "jdk" means even if t2k is available,
- * the decision as to whether to use that or freetype is
- * not affected by this setting.
+ /* If set to "jdk", use the JDK's scaler rather than
+ * the platform one. This may be a no-op on platforms where
+ * JDK has been configured so that it always relies on the
+ * platform scaler. The principal case where it has an
+ * effect is that on Windows, 2D will never use GDI.
*/
String scalerStr = System.getProperty("sun.java2d.font.scaler");
if (scalerStr != null) {
- useT2K = "t2k".equals(scalerStr);
- if (useT2K) {
- System.out.println("WARNING: t2k will be removed in JDK 11.");
- }
- useLegacy = "legacy".equals(scalerStr);
- if (useLegacy) {
- System.out.println("WARNING: legacy behavior will be removed in JDK 11.");
- }
- useJDKScaler = useT2K || "jdk".equals(scalerStr);
+ useJDKScaler = "jdk".equals(scalerStr);
} else {
- useT2K = false;
- useLegacy = false;
useJDKScaler = false;
}
isWindows = osName.startsWith("Windows");
--- a/src/java.desktop/share/classes/sun/font/SunFontManager.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/classes/sun/font/SunFontManager.java Wed Jun 20 12:20:29 2018 +0100
@@ -132,10 +132,9 @@
public static final int FONTFORMAT_NONE = -1;
public static final int FONTFORMAT_TRUETYPE = 0;
public static final int FONTFORMAT_TYPE1 = 1;
- public static final int FONTFORMAT_T2K = 2;
- public static final int FONTFORMAT_TTC = 3;
- public static final int FONTFORMAT_COMPOSITE = 4;
- public static final int FONTFORMAT_NATIVE = 5;
+ public static final int FONTFORMAT_TTC = 2;
+ public static final int FONTFORMAT_COMPOSITE = 3;
+ public static final int FONTFORMAT_NATIVE = 4;
/* Pool of 20 font file channels chosen because some UTF-8 locale
* composite fonts can use up to 16 platform fonts (including the
@@ -353,7 +352,7 @@
* handle two fonts of the same name, so the JRE one
* must be the first one registered. Pass "true" to
* registerFonts method as on-screen these JRE fonts
- * always go through the T2K rasteriser.
+ * always go through the JDK rasteriser.
*/
if (FontUtilities.isLinux) {
/* Linux font configuration uses these fonts */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.desktop/share/classes/sun/swing/InteropProvider.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2018, 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 sun.swing;
+
+public interface InteropProvider {
+}
--- a/src/java.desktop/share/native/common/font/fontscalerdefs.h Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/native/common/font/fontscalerdefs.h Wed Jun 20 12:20:29 2018 +0100
@@ -32,13 +32,6 @@
extern "C" {
#endif
-#define kPosInfinity16 (32767)
-#define kNegInfinity16 (-32768)
-
-#define kPosInfinity32 (0x7fffffff)
-#define kNegInfinity32 (0x80000000)
-
-
#ifdef _LP64
typedef unsigned int UInt32;
typedef int Int32;
@@ -65,27 +58,6 @@
#endif
#endif
-#define kPosInfinity32 (0x7fffffff)
-#define kNegInfinity32 (0x80000000)
-
-#define F26Dot6ToFixed(n) ((n) << 10)
-#define F26Dot6ToScalar(n) (((t2kScalar)(n)) / (t2kScalar)64)
-
- /* t2kFixed is the same as F16Dot16 format although T2K also uses 26.6 */
-typedef Int32 t2kFixed;
-typedef float t2kScalar;
-
-#define t2kIntToFixed(x) ((t2kFixed)(x) << 16)
-#define t2kFixedToInt(x) ((x) >> 16)
-
-#define t2kFixedRound(x) (((x) + 0x8000) >> 16)
-#define t2kFixed1 t2kIntToFixed(1)
-
-#define t2kFloatToFixed(f) (t2kFixed)((f) * (float)(t2kFixed1))
-#define t2kFixedToFloat(x) ((x) / (float)(65536))
-
-#define t2kScalarAverage(a, b) (((a) + (b)) / (t2kScalar)(2))
-
/* managed: 1 means the glyph has a hardware cached
* copy, and its freeing is managed by the usual
* 2D disposer code.
--- a/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/native/libfontmanager/freetypeScaler.c Wed Jun 20 12:20:29 2018 +0100
@@ -364,6 +364,19 @@
context->doBold = (boldness != 1.0);
context->doItalize = (italic != 0);
+ /* freetype is very keen to use embedded bitmaps, even if it knows
+ * there is a rotation or you asked for antialiasing.
+ * In the rendering path we will check useSBits and disable
+ * bitmaps unless it is set. And here we set it only if none
+ * of the conditions invalidate using it.
+ * Note that we allow embedded bitmaps for the LCD case.
+ */
+ if ((aa != TEXT_AA_ON) && (fm != TEXT_FM_ON) &&
+ !context->doBold && !context->doItalize &&
+ (context->transform.yx == 0) && (context->transform.xy == 0))
+ {
+ context->useSbits = 1;
+ }
return ptr_to_jlong(context);
}
@@ -685,9 +698,8 @@
return ptr_to_jlong(getNullGlyphImage());
}
- /* if algorithmic styling is required then we do not request bitmap */
- if (context->doBold || context->doItalize) {
- renderFlags = FT_LOAD_DEFAULT;
+ if (!context->useSbits) {
+ renderFlags |= FT_LOAD_NO_BITMAP;
}
/* NB: in case of non identity transform
--- a/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face.cc Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-face.cc Wed Jun 20 12:20:29 2018 +0100
@@ -117,9 +117,6 @@
return closure;
}
-#ifdef __SUNPRO_CC
-extern "C" {
-#endif
static void
_hb_face_for_data_closure_destroy (void *data)
{
@@ -128,9 +125,6 @@
hb_blob_destroy (closure->blob);
free (closure);
}
-#ifdef __SUNPRO_CC
-}
-#endif
static hb_blob_t *
_hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data)
@@ -496,7 +490,7 @@
unsigned int *table_count, /* IN/OUT */
hb_tag_t *table_tags /* OUT */)
{
- if (face->destroy != _hb_face_for_data_closure_destroy)
+ if (face->destroy != (hb_destroy_func_t) _hb_face_for_data_closure_destroy)
{
if (table_count)
*table_count = 0;
--- a/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-private.hh Wed Jun 20 12:20:29 2018 +0100
@@ -139,7 +139,7 @@
#define HB_FUNC __func__
#endif
-#ifdef __SUNPRO_CC
+#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
/* https://github.com/harfbuzz/harfbuzz/issues/630 */
#define __restrict
#endif
--- a/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp Wed Jun 20 11:52:31 2018 +0100
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp Wed Jun 20 12:20:29 2018 +0100
@@ -3853,6 +3853,8 @@
MsgRouting AwtComponent::WmForwardChar(WCHAR character, LPARAM lParam,
BOOL synthetic)
{
+ deadKeyActive = FALSE;
+
// just post WM_CHAR with unicode key value
DefWindowProc(WM_CHAR, (WPARAM)character, lParam);
return mrConsume;
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Jun 20 12:20:29 2018 +0100
@@ -3842,7 +3842,7 @@
@Override
JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
- return diags.create(dkind, log.currentSource(), pos, "illegal.ref.to.var.type", name);
+ return diags.create(dkind, log.currentSource(), pos, "illegal.ref.to.var.type");
}
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Jun 20 12:20:29 2018 +0100
@@ -751,7 +751,7 @@
public JCExpression unannotatedType(boolean allowVar) {
JCExpression result = term(TYPE);
- if (!allowVar && isRestrictedLocalVarTypeName(result)) {
+ if (!allowVar && isRestrictedLocalVarTypeName(result, true)) {
syntaxError(result.pos, Errors.VarNotAllowedHere);
}
@@ -1688,7 +1688,7 @@
LambdaClassifier lambdaClassifier = new LambdaClassifier();
for (JCVariableDecl param: params) {
if (param.vartype != null &&
- isRestrictedLocalVarTypeName(param.vartype) &&
+ isRestrictedLocalVarTypeName(param.vartype, false) &&
param.vartype.hasTag(TYPEARRAY)) {
log.error(DiagnosticFlag.SYNTAX, param.pos, Errors.VarNotAllowedArray);
}
@@ -1701,7 +1701,7 @@
log.error(DiagnosticFlag.SYNTAX, pos, Errors.InvalidLambdaParameterDeclaration(lambdaClassifier.diagFragment));
}
for (JCVariableDecl param: params) {
- if (param.vartype != null && isRestrictedLocalVarTypeName(param.vartype)) {
+ if (param.vartype != null && isRestrictedLocalVarTypeName(param.vartype, true)) {
param.startPos = TreeInfo.getStartPos(param.vartype);
param.vartype = null;
}
@@ -1738,7 +1738,7 @@
void addParameter(JCVariableDecl param) {
if (param.vartype != null && param.name != names.empty) {
- if (isRestrictedLocalVarTypeName(param.vartype)) {
+ if (isRestrictedLocalVarTypeName(param.vartype, false)) {
reduce(LambdaParameterKind.VAR);
} else {
reduce(LambdaParameterKind.EXPLICIT);
@@ -3021,13 +3021,9 @@
T vdefs,
boolean localDecl)
{
- JCVariableDecl head = variableDeclaratorRest(pos, mods, type, name, reqInit, dc, localDecl);
- boolean implicit = Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source) && head.vartype == null;
+ JCVariableDecl head = variableDeclaratorRest(pos, mods, type, name, reqInit, dc, localDecl, false);
vdefs.append(head);
while (token.kind == COMMA) {
- if (implicit) {
- reportSyntaxError(pos, Errors.VarNotAllowedCompound);
- }
// All but last of multiple declarators subsume a comma
storeEnd((JCTree)vdefs.last(), token.endPos);
nextToken();
@@ -3040,7 +3036,7 @@
* ConstantDeclarator = Ident ConstantDeclaratorRest
*/
JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, Comment dc, boolean localDecl) {
- return variableDeclaratorRest(token.pos, mods, type, ident(), reqInit, dc, localDecl);
+ return variableDeclaratorRest(token.pos, mods, type, ident(), reqInit, dc, localDecl, true);
}
/** VariableDeclaratorRest = BracketsOpt ["=" VariableInitializer]
@@ -3050,7 +3046,7 @@
* @param dc The documentation comment for the variable declarations, or null.
*/
JCVariableDecl variableDeclaratorRest(int pos, JCModifiers mods, JCExpression type, Name name,
- boolean reqInit, Comment dc, boolean localDecl) {
+ boolean reqInit, Comment dc, boolean localDecl, boolean compound) {
type = bracketsOpt(type);
JCExpression init = null;
if (token.kind == EQ) {
@@ -3060,10 +3056,13 @@
else if (reqInit) syntaxError(token.pos, Errors.Expected(EQ));
JCTree elemType = TreeInfo.innermostType(type, true);
int startPos = Position.NOPOS;
- if (Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source) && elemType.hasTag(IDENT)) {
+ if (elemType.hasTag(IDENT)) {
Name typeName = ((JCIdent)elemType).name;
- if (isRestrictedLocalVarTypeName(typeName)) {
- if (type.hasTag(TYPEARRAY)) {
+ if (isRestrictedLocalVarTypeName(typeName, pos, !compound && localDecl)) {
+ if (compound) {
+ //error - 'var' in compound local var decl
+ reportSyntaxError(pos, Errors.VarNotAllowedCompound);
+ } else if (type.hasTag(TYPEARRAY)) {
//error - 'var' and arrays
reportSyntaxError(pos, Errors.VarNotAllowedArray);
} else {
@@ -3082,19 +3081,26 @@
return result;
}
- boolean isRestrictedLocalVarTypeName(JCExpression e) {
+ boolean isRestrictedLocalVarTypeName(JCExpression e, boolean shouldWarn) {
switch (e.getTag()) {
case IDENT:
- return isRestrictedLocalVarTypeName(((JCIdent)e).name);
+ return isRestrictedLocalVarTypeName(((JCIdent)e).name, e.pos, shouldWarn);
case TYPEARRAY:
- return isRestrictedLocalVarTypeName(((JCArrayTypeTree)e).elemtype);
+ return isRestrictedLocalVarTypeName(((JCArrayTypeTree)e).elemtype, shouldWarn);
default:
return false;
}
}
- boolean isRestrictedLocalVarTypeName(Name name) {
- return Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source) && name == names.var;
+ boolean isRestrictedLocalVarTypeName(Name name, int pos, boolean shouldWarn) {
+ if (name == names.var) {
+ if (Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source)) {
+ return true;
+ } else if (shouldWarn) {
+ log.warning(pos, Warnings.VarNotAllowed);
+ }
+ }
+ return false;
}
/** VariableDeclaratorId = Ident BracketsOpt
@@ -3179,12 +3185,12 @@
if (token.kind == FINAL || token.kind == MONKEYS_AT) {
JCModifiers mods = optFinal(Flags.FINAL);
JCExpression t = parseType(true);
- return variableDeclaratorRest(token.pos, mods, t, ident(), true, null, true);
+ return variableDeclaratorRest(token.pos, mods, t, ident(), true, null, true, false);
}
JCExpression t = term(EXPR | TYPE);
if ((lastmode & TYPE) != 0 && LAX_IDENTIFIER.accepts(token.kind)) {
JCModifiers mods = toP(F.at(startPos).Modifiers(Flags.FINAL));
- return variableDeclaratorRest(token.pos, mods, t, ident(), true, null, true);
+ return variableDeclaratorRest(token.pos, mods, t, ident(), true, null, true, false);
} else {
checkSourceLevel(Feature.EFFECTIVELY_FINAL_VARIABLES_IN_TRY_WITH_RESOURCES);
if (!t.hasTag(IDENT) && !t.hasTag(SELECT)) {
@@ -3485,12 +3491,8 @@
Name typeName() {
int pos = token.pos;
Name name = ident();
- if (name == names.var) {
- if (Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source)) {
- reportSyntaxError(pos, Errors.VarNotAllowed(name));
- } else {
- log.warning(pos, Warnings.VarNotAllowed);
- }
+ if (isRestrictedLocalVarTypeName(name, pos, true)) {
+ reportSyntaxError(pos, Errors.VarNotAllowed);
}
return name;
}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jun 20 11:52:31 2018 +0100
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Jun 20 12:20:29 2018 +0100
@@ -1216,17 +1216,15 @@
compiler.err.undef.label=\
undefined label: {0}
-# 0: name (type)
compiler.err.illegal.ref.to.var.type=\
- illegal reference to restricted type ''{0}''
-
-# 0: name
+ illegal reference to restricted type ''var''
+
compiler.err.var.not.allowed=\
- ''{0}'' not allowed here\n\
- as of release 10, ''{0}'' is a restricted local variable type and cannot be used for type declarations
+ ''var'' not allowed here\n\
+ as of release 10, ''var'' is a restricted local variable type and cannot be used for type declarations
compiler.warn.var.not.allowed=\
- as of release 10, ''var'' is a restricted local variable type and cannot be used for type declarations
+ as of release 10, ''var'' is a restricted local variable type and cannot be used for type declarations or as the element type of an array
# 0: name (variable), 1: message segment
compiler.err.cant.infer.local.var.type=\
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java Wed Jun 20 12:20:29 2018 +0100
@@ -164,12 +164,12 @@
* @param te TypeElement whose members will be added to the indexmap.
*/
protected void putMembersInIndexMap(TypeElement te) {
- adjustIndexMap(utils.getAnnotationFields(te));
- adjustIndexMap(utils.getFields(te));
VisibleMemberTable vmt = configuration.getVisibleMemberTable(te);
+ adjustIndexMap(vmt.getMembers(ANNOTATION_TYPE_FIELDS));
+ adjustIndexMap(vmt.getMembers(FIELDS));
adjustIndexMap(vmt.getMembers(METHODS));
- adjustIndexMap(utils.getConstructors(te));
- adjustIndexMap(utils.getEnumConstants(te));
+ adjustIndexMap(vmt.getMembers(CONSTRUCTORS));
+ adjustIndexMap(vmt.getMembers(ENUM_CONSTANTS));
}
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java Wed Jun 20 11:52:31 2018 +0100
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberTable.java Wed Jun 20 12:20:29 2018 +0100
@@ -676,7 +676,6 @@
addMember(e, Kind.METHODS);
break;
case CONSTRUCTOR:
- if (!utils.isEnum(te))
addMember(e, Kind.CONSTRUCTORS);
break;
case ENUM_CONSTANT:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/DispatcherWrapper.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2018, 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.swing.interop;
+
+import java.awt.SecondaryLoop;
+import java.awt.EventQueue;
+import sun.awt.FwDispatcher;
+import sun.awt.AWTAccessor;
+
+/**
+ * This class provides a wrapper over inner class DispatcherProxy
+ * which implements jdk internal sun.awt.FwDispatcher interface
+ * and provides APIs to be used by FX swing interop to access and use
+ * FwDispatcher APIs.
+ *
+ * @since 11
+ */
+public abstract class DispatcherWrapper {
+ private DispatcherProxy fwd;
+
+ public DispatcherWrapper() {
+ fwd = new DispatcherProxy();
+ }
+
+ public abstract boolean isDispatchThread();
+
+ public abstract void scheduleDispatch(Runnable r);
+
+ public abstract SecondaryLoop createSecondaryLoop();
+
+ public static void setFwDispatcher(EventQueue eventQueue, DispatcherWrapper dispatcher) {
+ AWTAccessor.getEventQueueAccessor().setFwDispatcher(eventQueue, dispatcher.fwd);
+ }
+
+ private class DispatcherProxy implements FwDispatcher {
+
+ @Override
+ public boolean isDispatchThread() {
+ return DispatcherWrapper.this.isDispatchThread();
+ }
+
+ @Override
+ public void scheduleDispatch(Runnable r) {
+ DispatcherWrapper.this.scheduleDispatch(r);
+ }
+
+ @Override
+ public SecondaryLoop createSecondaryLoop() {
+ return DispatcherWrapper.this.createSecondaryLoop();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/DragSourceContextWrapper.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2018, 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.swing.interop;
+
+import java.awt.Cursor;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.DragSourceContext;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
+import java.util.Map;
+import sun.awt.dnd.SunDragSourceContextPeer;
+
+/**
+ * This class provides a wrapper over inner DragSourceContextPeerProxy class
+ * which extends jdk internal sun.awt.dnd.SunDragSourceContextPeer class
+ * and provides APIs to be used by FX swing interop to access and use
+ * DragSourceContextPeer APIs.
+ *
+ * @since 11
+ */
+public abstract class DragSourceContextWrapper {
+ private DragSourceContextPeerProxy dsp;
+
+ public DragSourceContextWrapper(DragGestureEvent e) {
+ dsp = new DragSourceContextPeerProxy(e);
+ }
+
+ DragSourceContextPeer getPeer() {
+ return dsp;
+ }
+
+ public static int convertModifiersToDropAction(int modifiers,
+ int supportedActions) {
+ return DragSourceContextPeerProxy.
+ convertModifiersToDropAction(modifiers, supportedActions);
+ }
+
+ protected abstract void setNativeCursor(Cursor c, int cType);
+
+ protected abstract void startDrag(Transferable trans, long[] formats,
+ Map<Long, DataFlavor> formatMap);
+
+ public abstract void startSecondaryEventLoop();
+
+ public abstract void quitSecondaryEventLoop();
+
+ public void dragDropFinished(final boolean success,
+ final int operations,
+ final int x, final int y) {
+ dsp.dragDropFinishedCall(success, operations, x, y);
+ }
+
+ public DragSourceContext getDragSourceContext() {
+ return dsp.getDragSourceContextCall();
+ }
+
+ private class DragSourceContextPeerProxy extends SunDragSourceContextPeer {
+
+ public DragSourceContextPeerProxy(DragGestureEvent e) {
+ super(e);
+ }
+
+ protected void startDrag(Transferable trans, long[] formats,
+ Map<Long, DataFlavor> formatMap) {
+ DragSourceContextWrapper.this.startDrag(trans, formats, formatMap);
+ }
+
+ protected void setNativeCursor(long nativeCtxt, Cursor c, int cType) {
+ DragSourceContextWrapper.this.setNativeCursor(c, cType);
+ }
+
+ public void startSecondaryEventLoop() {
+ DragSourceContextWrapper.this.startSecondaryEventLoop();
+ }
+
+ public void quitSecondaryEventLoop() {
+ DragSourceContextWrapper.this.quitSecondaryEventLoop();
+ }
+
+ protected void dragDropFinishedCall(final boolean success,
+ final int operations,
+ final int x, final int y) {
+ dragDropFinished(success, operations, x, y);
+ }
+
+ protected DragSourceContext getDragSourceContextCall() {
+ return getDragSourceContext();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/DropTargetContextWrapper.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2018, 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.swing.interop;
+
+import java.awt.dnd.peer.DropTargetContextPeer;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.DropTargetContext;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.Transferable;
+import sun.awt.AWTAccessor;
+
+/**
+ * This class provides a wrapper over inner class DropTargetContextPeerProxy
+ * which implements jdk internal java.awt.dnd.peer.DropTargetContextPeer interface
+ * and provides APIs to be used by FX swing interop to access and use
+ * DropTargetContextPeer APIs.
+ *
+ * @since 11
+ */
+public abstract class DropTargetContextWrapper {
+
+ private DropTargetContextPeerProxy dcp;
+ public DropTargetContextWrapper() {
+ dcp = new DropTargetContextPeerProxy();
+ }
+
+ public void setDropTargetContext(DropTargetContext dtc,
+ DropTargetContextWrapper dtcpw) {
+ AWTAccessor.getDropTargetContextAccessor().
+ setDropTargetContextPeer(dtc, dtcpw.dcp);
+ }
+
+ public void reset(DropTargetContext dtc) {
+ AWTAccessor.getDropTargetContextAccessor().reset(dtc);
+ }
+
+ public abstract void setTargetActions(int actions);
+
+ public abstract int getTargetActions();
+
+ public abstract DropTarget getDropTarget();
+
+ public abstract DataFlavor[] getTransferDataFlavors();
+
+ public abstract Transferable getTransferable() throws InvalidDnDOperationException;
+
+ public abstract boolean isTransferableJVMLocal();
+
+ public abstract void acceptDrag(int dragAction);
+
+ public abstract void rejectDrag();
+
+ public abstract void acceptDrop(int dropAction);
+
+ public abstract void rejectDrop();
+
+ public abstract void dropComplete(boolean success);
+
+ private class DropTargetContextPeerProxy implements DropTargetContextPeer {
+
+ public void setTargetActions(int actions) {
+ DropTargetContextWrapper.this.setTargetActions(actions);
+ }
+
+ public int getTargetActions() {
+ return DropTargetContextWrapper.this.getTargetActions();
+ }
+
+ public DropTarget getDropTarget() {
+ return DropTargetContextWrapper.this.getDropTarget();
+ }
+
+ public DataFlavor[] getTransferDataFlavors() {
+ return DropTargetContextWrapper.this.getTransferDataFlavors();
+ }
+
+ public Transferable getTransferable()
+ throws InvalidDnDOperationException {
+ return DropTargetContextWrapper.this.getTransferable();
+ }
+
+ public boolean isTransferableJVMLocal() {
+ return DropTargetContextWrapper.this.isTransferableJVMLocal();
+ }
+
+ public void acceptDrag(int dragAction) {
+ DropTargetContextWrapper.this.acceptDrag(dragAction);
+ }
+
+ public void rejectDrag() {
+ DropTargetContextWrapper.this.rejectDrag();
+ }
+
+ public void acceptDrop(int dropAction) {
+ DropTargetContextWrapper.this.acceptDrop(dropAction);
+ }
+
+ public void rejectDrop() {
+ DropTargetContextWrapper.this.rejectDrop();
+ }
+
+ public void dropComplete(boolean success) {
+ DropTargetContextWrapper.this.dropComplete(success);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/LightweightContentWrapper.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2018, 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.swing.interop;
+
+import java.awt.Component;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.InvalidDnDOperationException;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.dnd.DropTarget;
+import javax.swing.JComponent;
+import sun.swing.LightweightContent;
+
+/**
+ * This class provides a wrapper over inner LightweightContentProxy class
+ * which implements jdk internal sun.swing.LightweightContent interface
+ * and provides APIs to be used by FX swing interop to access and use
+ * LightweightContent APIs.
+ *
+ * @since 11
+ */
+public abstract class LightweightContentWrapper {
+ private LightweightContentProxy lwCnt;
+
+ public LightweightContentWrapper() {
+ lwCnt = new LightweightContentProxy();
+ }
+
+ LightweightContentProxy getContent() {
+ return lwCnt;
+ }
+
+ public abstract void imageBufferReset(int[] data, int x, int y, int width,
+ int height, int linestride);
+
+ public abstract void imageBufferReset(int[] data, int x, int y, int width,
+ int height,
+ int linestride, double scaleX,
+ double scaleY);
+
+ public abstract JComponent getComponent();
+
+ public abstract void paintLock();
+
+ public abstract void paintUnlock();
+
+ public abstract void imageReshaped(int x, int y, int width, int height);
+
+ public abstract void imageUpdated(int dirtyX, int dirtyY,int dirtyWidth,
+ int dirtyHeight);
+
+ public abstract void focusGrabbed();
+
+ public abstract void focusUngrabbed();
+
+ public abstract void preferredSizeChanged(int width, int height);
+
+ public abstract void maximumSizeChanged(int width, int height);
+
+ public abstract void minimumSizeChanged(int width, int height);
+
+ public abstract <T extends DragGestureRecognizer> T createDragGestureRecognizer(
+ Class<T> abstractRecognizerClass,
+ DragSource ds, Component c, int srcActions,
+ DragGestureListener dgl);
+
+ public abstract DragSourceContextWrapper createDragSourceContext(DragGestureEvent dge)
+ throws InvalidDnDOperationException;
+
+ public abstract void addDropTarget(DropTarget dt);
+
+ public abstract void removeDropTarget(DropTarget dt);
+
+ private class LightweightContentProxy implements LightweightContent {
+
+ public JComponent getComponent() {
+ return LightweightContentWrapper.this.getComponent();
+ }
+
+ public void paintLock() {
+ LightweightContentWrapper.this.paintLock();
+ }
+
+ public void paintUnlock() {
+ LightweightContentWrapper.this.paintUnlock();
+ }
+
+ public void imageBufferReset(int[] data, int x, int y, int width,
+ int height, int linestride) {
+ LightweightContentWrapper.this.imageBufferReset(data, x, y, width,
+ height, linestride);
+ }
+
+ public void imageBufferReset(int[] data, int x, int y, int width,
+ int height, int linestride, double scaleX,
+ double scaleY) {
+ LightweightContentWrapper.this.imageBufferReset(data, x, y, width,
+ height, linestride, scaleX, scaleY);
+ }
+
+ public void imageReshaped(int x, int y, int width, int height) {
+ LightweightContentWrapper.this.imageReshaped(x, y, width, height);
+ }
+
+ public void imageUpdated(int dirtyX, int dirtyY,int dirtyWidth, int dirtyHeight) {
+ LightweightContentWrapper.this.imageUpdated(dirtyX, dirtyY, dirtyWidth, dirtyHeight);
+ }
+
+ public void focusGrabbed() {
+ LightweightContentWrapper.this.focusGrabbed();
+ }
+
+ public void focusUngrabbed() {
+ LightweightContentWrapper.this.focusUngrabbed();
+ }
+
+ public void preferredSizeChanged(int width, int height) {
+ LightweightContentWrapper.this.preferredSizeChanged(width, height);
+ }
+
+ public void maximumSizeChanged(int width, int height) {
+ LightweightContentWrapper.this.maximumSizeChanged(width, height);
+ }
+
+ public void minimumSizeChanged(int width, int height) {
+ LightweightContentWrapper.this.minimumSizeChanged(width, height);
+ }
+
+ public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
+ Class<T> abstractRecognizerClass,
+ DragSource ds, Component c, int srcActions,
+ DragGestureListener dgl) {
+ return LightweightContentWrapper.this.createDragGestureRecognizer(
+ abstractRecognizerClass, ds, c, srcActions, dgl);
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge)
+ throws InvalidDnDOperationException {
+ DragSourceContextWrapper peerWrapper =
+ LightweightContentWrapper.this.createDragSourceContext(dge);
+ return peerWrapper.getPeer();
+ }
+
+ public void addDropTarget(DropTarget dt) {
+ LightweightContentWrapper.this.addDropTarget(dt);
+ }
+
+ public void removeDropTarget(DropTarget dt) {
+ LightweightContentWrapper.this.removeDropTarget(dt);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/LightweightFrameWrapper.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2018, 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.swing.interop;
+
+import java.awt.AWTEvent;
+import java.awt.Container;
+import java.awt.Component;
+import java.awt.event.WindowFocusListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.KeyEvent;
+import sun.awt.LightweightFrame;
+import sun.awt.UngrabEvent;
+import sun.awt.AWTAccessor;
+import sun.swing.JLightweightFrame;
+
+/**
+ * This class wraps sun.swing.JLightweightFrame and implements
+ * APIs to be used by FX swing interop to access and use JLightweightFrame APIs.
+ *
+ * @since 11
+ */
+public class LightweightFrameWrapper {
+
+ JLightweightFrame lwFrame;
+
+ public LightweightFrameWrapper() {
+ lwFrame = new JLightweightFrame();
+ }
+
+ private JLightweightFrame getLightweightFrame() {
+ return lwFrame;
+ }
+
+ public void notifyDisplayChanged(final int scaleFactor) {
+ if (lwFrame != null) {
+ lwFrame.notifyDisplayChanged(scaleFactor, scaleFactor);
+ }
+ }
+
+ /**
+ * {@code overrideNativeWindowHandle()} is package private but
+ * part of the interface of this class. It supports providing a
+ * foreign native window handle (i.e. an FX window handle) to AWT,
+ * and as such is intended to be called via JNI code,
+ * not by Java code, so it is not public.
+ */
+ void overrideNativeWindowHandle(long handle, Runnable closeWindow) {
+ if (lwFrame != null) {
+ lwFrame.overrideNativeWindowHandle(handle, closeWindow);
+ }
+ }
+
+ public void setHostBounds(int x, int y, int w, int h) {
+ if (lwFrame != null) {
+ lwFrame.setHostBounds(x, y, w, h);
+ }
+ }
+
+ public void dispose() {
+ if (lwFrame != null) {
+ lwFrame.dispose();
+ }
+ }
+
+ public void addWindowFocusListener(WindowFocusListener listener) {
+ if (lwFrame != null) {
+ lwFrame.addWindowFocusListener(listener);
+ }
+ }
+
+ public void setVisible(boolean visible) {
+ if (lwFrame != null) {
+ lwFrame.setVisible(visible);
+ }
+ }
+
+ public void setBounds(int x, int y, int w, int h) {
+ if (lwFrame != null) {
+ lwFrame.setBounds(x, y, w, h);
+ }
+ }
+
+ public void setContent(final LightweightContentWrapper lwCntWrapper) {
+ if (lwFrame != null) {
+ lwFrame.setContent(lwCntWrapper.getContent());
+ }
+ }
+
+ public void emulateActivation(boolean activate) {
+ if (lwFrame != null) {
+ lwFrame.emulateActivation(activate);
+ }
+ }
+
+ public MouseEvent createMouseEvent(LightweightFrameWrapper lwFrame,
+ int swingID, long swingWhen, int swingModifiers,
+ int relX, int relY, int absX, int absY,
+ int clickCount, boolean swingPopupTrigger,
+ int swingButton) {
+ return new java.awt.event.MouseEvent(lwFrame.getLightweightFrame(),
+ swingID, swingWhen,
+ swingModifiers,
+ relX, relY, absX, absY, clickCount,
+ swingPopupTrigger, swingButton);
+ }
+
+ public MouseWheelEvent createMouseWheelEvent(LightweightFrameWrapper lwFrame,
+ int swingModifiers, int x, int y, int wheelRotation) {
+ return new MouseWheelEvent(lwFrame.getLightweightFrame(),
+ java.awt.event.MouseEvent.MOUSE_WHEEL,
+ System.currentTimeMillis(),
+ swingModifiers, x, y, 0, 0, 0, false,
+ MouseWheelEvent.WHEEL_UNIT_SCROLL, 1,
+ wheelRotation);
+ }
+
+ public KeyEvent createKeyEvent(LightweightFrameWrapper lwFrame,
+ int swingID, long swingWhen,
+ int swingModifiers,
+ int swingKeyCode, char swingChar) {
+ return new java.awt.event.KeyEvent(lwFrame.getLightweightFrame(),
+ swingID, swingWhen, swingModifiers, swingKeyCode,
+ swingChar);
+ }
+
+ public AWTEvent createUngrabEvent(LightweightFrameWrapper lwFrame) {
+ return new UngrabEvent(lwFrame.getLightweightFrame());
+ }
+
+ public Component findComponentAt(LightweightFrameWrapper cont, int x, int y, boolean ignoreEnabled) {
+ Container lwframe = cont.getLightweightFrame();
+ return AWTAccessor.getContainerAccessor().findComponentAt(lwframe, x, y, ignoreEnabled);
+ }
+
+ public boolean isCompEqual(Component c, LightweightFrameWrapper lwFrame) {
+ return c != lwFrame.getLightweightFrame();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/SwingInterOpUtils.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2018, 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.swing.interop;
+
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.AWTEvent;
+import sun.awt.SunToolkit;
+import sun.awt.AppContext;
+import sun.awt.UngrabEvent;
+
+/**
+ * This class provides static utility methods to be used by FX swing interop
+ * to access and use jdk internal classes like SunToolkit, AppContext
+ * and UngrabEvent.
+ *
+ * @since 11
+ */
+public class SwingInterOpUtils {
+
+ public static void postEvent(Object target, java.awt.AWTEvent e) {
+ AppContext context = SunToolkit.targetToAppContext(target);
+ if (context != null) {
+ SunToolkit.postEvent(context, e);
+ }
+ }
+
+ public static void grab(Toolkit toolkit, Window window) {
+ if (toolkit instanceof SunToolkit) {
+ ((SunToolkit)toolkit).grab(window);
+ }
+ }
+
+ public static void ungrab(Toolkit toolkit, Window window) {
+ if (toolkit instanceof SunToolkit) {
+ ((SunToolkit)toolkit).ungrab(window);
+ }
+ }
+
+ public static boolean isUngrabEvent(AWTEvent e) {
+ return e instanceof UngrabEvent;
+ }
+
+ public static final int GRAB_EVENT_MASK = SunToolkit.GRAB_EVENT_MASK;
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/jdk/swing/interop/internal/InteropProviderImpl.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018, 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.swing.interop.internal;
+
+import sun.swing.InteropProvider;
+
+/**
+ * @since 11
+ */
+public class InteropProviderImpl implements InteropProvider {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.unsupported.desktop/share/classes/module-info.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+/**
+ * This module is intended for use only by the javafx.swing module
+ * for the purpose of FX/Swing interop
+ *
+ * @since 11
+ */
+module jdk.unsupported.desktop {
+
+ requires transitive java.desktop;
+
+ exports jdk.swing.interop;
+
+ provides sun.swing.InteropProvider
+ with jdk.swing.interop.internal.InteropProviderImpl;
+
+}
+
--- a/test/hotspot/jtreg/ProblemList.txt Wed Jun 20 11:52:31 2018 +0100
+++ b/test/hotspot/jtreg/ProblemList.txt Wed Jun 20 12:20:29 2018 +0100
@@ -136,6 +136,7 @@
vmTestbase/nsk/jvmti/ThreadStart/threadstart001/TestDescription.java 8016181 generic-all
vmTestbase/nsk/jvmti/ThreadStart/threadstart003/TestDescription.java 8034084 generic-all
vmTestbase/nsk/jvmti/scenarios/extension/EX03/ex03t001/TestDescription.java 8173658 generic-all
+vmTestbase/nsk/jvmti/scenarios/hotswap/HS102/hs102t002/TestDescription.java 8204506,8203350 generic-all
vmTestbase/nsk/jvmti/scenarios/hotswap/HS204/hs204t001/hs204t001.java 6813266 generic-all
vmTestbase/nsk/jvmti/scenarios/sampling/SP06/sp06t003/TestDescription.java 8051349 generic-all
vmTestbase/nsk/jvmti/AttachOnDemand/attach034/TestDescription.java 8042145 generic-all
--- a/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayStoreException/ArrayStoreExceptionTest.java Wed Jun 20 11:52:31 2018 +0100
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayStoreException/ArrayStoreExceptionTest.java Wed Jun 20 12:20:29 2018 +0100
@@ -63,18 +63,6 @@
}
}
- static native void doNativeArrayStore2(Object src, Object dst, int index);
-
- static void testNativeASMessages2(Object array, Object elem, int index, String message)
- throws Exception {
- try {
- doNativeArrayStore2(array, elem, index);
- Asserts.fail("Expected ArrayStoreException not thrown");
- } catch (ArrayIndexOutOfBoundsException e) {
- Asserts.assertEquals(e.getMessage(), message);
- }
- }
-
public static void main(String[] args) throws Exception {
try {
boolean[] za1 = new boolean[3];
@@ -193,8 +181,6 @@
testNativeASMessages(ia4, "This is not a date", 2,
"type mismatch: can not store java.lang.String to int[2][][]");
- testNativeASMessages2("This is not an array", "This is not a date", 2, "2");
-
} catch (java.lang.RuntimeException e) {
throw e;
} catch (Exception e) {
--- a/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayStoreException/libArrayStoreExceptionTest.c Wed Jun 20 11:52:31 2018 +0100
+++ b/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayStoreException/libArrayStoreExceptionTest.c Wed Jun 20 12:20:29 2018 +0100
@@ -30,8 +30,3 @@
(*env)->SetObjectArrayElement(env, array, index, element);
}
-JNIEXPORT void JNICALL
- Java_ArrayStoreExceptionTest_doNativeArrayStore2(JNIEnv *env, jclass klass,
- jobject array, jobject element, jint index) {
- (*env)->SetObjectArrayElement(env, (jobjectArray)array, index, element);
-}
--- a/test/jdk/ProblemList.txt Wed Jun 20 11:52:31 2018 +0100
+++ b/test/jdk/ProblemList.txt Wed Jun 20 12:20:29 2018 +0100
@@ -804,7 +804,6 @@
javax/swing/text/Utilities/8142966/SwingFontMetricsTest.java 8202663 windows-all
javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java 202880 linux-all
javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765 macosx-all,linux-all
-javax/swing/plaf/nimbus/8057791/bug8057791.java 8202877 macosx-all
javax/swing/Popup/TaskbarPositionTest.java 8065097 macosx-all,linux-all
java/awt/im/memoryleak/InputContextMemoryLeakTest.java 8023814 linux-all,solaris-all
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/FontClass/GlyphRotationTest.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2018, 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 8204929
+ * @summary test rotation of font with embedded bitmaps
+ * @run main GlyphRotationTest
+ */
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import javax.imageio.ImageIO;
+
+public class GlyphRotationTest {
+
+ public static final String fontName = "MS UI Gothic";
+ public static Font font;
+ public static final int SZ = 50;
+
+ public static void main(String[] args) {
+ font = new Font(fontName, Font.PLAIN, 15);
+ if (!font.getFamily(java.util.Locale.ENGLISH).equals(fontName)) {
+ return;
+ }
+ BufferedImage bi = new BufferedImage(SZ,SZ,BufferedImage.TYPE_INT_RGB);
+ Graphics2D g2d = bi.createGraphics();
+ g2d.setColor(Color.white);
+ g2d.fillRect(0, 0, SZ, SZ);
+ g2d.setColor(Color.black);
+ g2d.setFont(font);
+ g2d.drawString("1", SZ/2, SZ/2);
+ int pixCnt1 = countPixels(bi);
+ AffineTransform at = AffineTransform.getRotateInstance(Math.PI/2);
+ font = font.deriveFont(Font.PLAIN, at);
+ g2d.setFont(font);
+ g2d.drawString("1", SZ/2, SZ/2);
+ int pixCnt2 = countPixels(bi);
+ if (args.length > 0) {
+ try {
+ ImageIO.write(bi, "png", new java.io.File("im.png"));
+ } catch (Exception e) {}
+ }
+ if (pixCnt1 == pixCnt2) {
+ String msg = "cnt 1 = " + pixCnt1 + " cnt 2 = " + pixCnt2;
+ throw new RuntimeException(msg);
+ }
+ }
+
+ static int countPixels(BufferedImage bi) {
+ int cnt = 0;
+ int w = bi.getWidth(null);
+ int h = bi.getHeight(null);
+ for (int i=0; i<w; i++) {
+ for (int j=0; j<w; j++) {
+ int rgb = bi.getRGB(i, j) & 0xFFFFFF;
+ if (rgb == 0) {
+ cnt++;
+ }
+ }
+ }
+ return cnt;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/accessibility/SlowPanelIteration/SlowPanelIteration.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+/**
+ * @test
+ * @key headful
+ * @bug 8202768
+ * @summary we should not hang when lots of panels are used
+ */
+public final class SlowPanelIteration {
+
+ private static JFrame frame;
+ private static Point center = new Point();
+ private static volatile CountDownLatch go;
+
+ public static void main(final String[] args) throws Exception {
+ Robot r = new Robot();
+ // accessibility tool will need time to react to our clicks
+ r.setAutoDelay(200);
+ try {
+ EventQueue.invokeAndWait(SlowPanelIteration::showUI);
+ for (int i = 0; i < 10; ++i) {
+ go = new CountDownLatch(1);
+ r.mouseMove(center.x, center.y);
+ r.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ if (!go.await(10, TimeUnit.SECONDS)) {
+ throw new RuntimeException("Too slow operation");
+ }
+ }
+ } finally {
+ EventQueue.invokeAndWait(SlowPanelIteration::dispose);
+ }
+ }
+
+ private static void showUI() {
+ frame = new JFrame();
+ frame.setSize(new Dimension(400, 400));
+ frame.setLocationRelativeTo(null);
+
+ final Container content = frame.getContentPane();
+ content.setLayout(new BorderLayout(0, 0));
+ Container lastPanel = content;
+ for (int i = 0; i < 500; i++) {
+ final JPanel p = new JPanel();
+ p.setLayout(new BorderLayout(0, 0));
+ lastPanel.add(p);
+ lastPanel.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ System.out.println("click");
+ go.countDown();
+ }
+ });
+ lastPanel = p;
+ }
+
+ lastPanel.setBackground(Color.GREEN);
+ frame.setVisible(true);
+
+ Point loc = frame.getLocationOnScreen();
+ center.x = loc.x + frame.getWidth() / 2;
+ center.y = loc.y + frame.getHeight() / 2;
+ }
+
+ private static void dispose() {
+ if (frame != null) {
+ frame.dispose();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/sound/sampled/Clip/AudioContentHandlers.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+import java.applet.AudioClip;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+
+import static javax.sound.sampled.AudioFileFormat.Type.AIFC;
+import static javax.sound.sampled.AudioFileFormat.Type.AIFF;
+import static javax.sound.sampled.AudioFileFormat.Type.AU;
+import static javax.sound.sampled.AudioFileFormat.Type.SND;
+import static javax.sound.sampled.AudioFileFormat.Type.WAVE;
+
+/**
+ * @test
+ * @bug 8204454
+ * @summary URL.getContent() should return AudioClip for supported formats
+ * @run main/othervm -mx128m AudioContentHandlers
+ */
+public final class AudioContentHandlers {
+
+ private static final List<AudioFormat> formats = new ArrayList<>();
+
+ private static final AudioFormat.Encoding[] encodings =
+ {AudioFormat.Encoding.ALAW, AudioFormat.Encoding.ULAW,
+ AudioFormat.Encoding.PCM_SIGNED,
+ AudioFormat.Encoding.PCM_UNSIGNED,
+ AudioFormat.Encoding.PCM_FLOAT};
+
+ private static final AudioFileFormat.Type[] types =
+ {WAVE, AU, AIFF, AIFC, SND};
+
+ static {
+ for (final AudioFormat.Encoding enc : encodings) {
+ formats.add(new AudioFormat(enc, 44100, 8, 1, 1, 44100, true));
+ formats.add(new AudioFormat(enc, 44100, 8, 1, 1, 44100, false));
+ }
+ }
+
+ public static void main(final String[] args) throws Exception {
+ for (final AudioFileFormat.Type type : types) {
+ for (final AudioFormat format : formats) {
+ File file = new File("audio." + type.getExtension());
+ try {
+ AudioSystem.write(getStream(format), type, file);
+ } catch (IOException | IllegalArgumentException ignored) {
+ continue;
+ }
+ AudioClip content;
+ try {
+ content = (AudioClip) file.toURL().getContent();
+ // We need to generate OOM because the stream in AudioClip
+ // will be closed in finalize().
+ generateOOME();
+ } finally {
+ Files.delete(file.toPath());
+ }
+ if (content == null) {
+ throw new RuntimeException("Content is null");
+ }
+ }
+ }
+ }
+
+ private static AudioInputStream getStream(final AudioFormat format) {
+ final InputStream in = new ByteArrayInputStream(new byte[100]);
+ return new AudioInputStream(in, format, 10);
+ }
+
+ private static void generateOOME() throws Exception {
+ List<Object> leak = new LinkedList<>();
+ try {
+ while (true) {
+ leak.add(new byte[1024 * 1024]);
+ }
+ } catch (OutOfMemoryError ignored) {
+ }
+ // Give the GC a chance at that weakref in case of slow systems
+ Thread.sleep(2000);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/SwingWorker/6608234/CheckCancellationException.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.CountDownLatch;
+
+import javax.swing.SwingWorker;
+
+/**
+ * @test
+ * @bug 6608234
+ */
+public final class CheckCancellationException {
+
+ private static final CountDownLatch go = new CountDownLatch(1);
+
+ public static void main(final String[] args) throws Exception {
+ SwingWorker<?, ?> worker = new SwingWorker() {
+ protected Void doInBackground() {
+ go.countDown();
+ while (!Thread.interrupted()) ;
+ return null;
+ }
+ };
+ worker.execute();
+ go.await();
+ worker.cancel(true);
+ try {
+ worker.get();
+ } catch (final CancellationException expected) {
+ // expected exception
+ return;
+ }
+ throw new RuntimeException("CancellationException was not thrown");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/swing/text/Caret/TestCaretPosition.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2018, 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 8199441
+ * @key headful
+ * @summary Verifies caret position in multiline line-wrapped text component
+ * in hidpi mode should be in sync with mouse press position.
+ * @run main/othervm -Dsun.java2d.uiScale=1.5 TestCaretPosition
+ */
+
+import javax.swing.JTextArea;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Caret;
+import java.awt.Font;
+import java.awt.BorderLayout;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.geom.Rectangle2D;
+
+public class TestCaretPosition {
+ private static JTextArea jTextArea1;
+ private static JFrame f;
+
+ private static void createUI() {
+ jTextArea1 = new JTextArea(5, 80);
+ f = new JFrame();
+ jTextArea1.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
+
+ fillTextArea(jTextArea1);
+ jTextArea1.setLineWrap(true);
+ jTextArea1.addMouseListener(new MouseListener() {
+ @Override
+ public void mouseClicked(MouseEvent e) {}
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ try {
+ Caret caret = jTextArea1.getCaret();
+ Rectangle2D rect = jTextArea1.modelToView2D(caret.getDot());
+
+ if (Math.abs(e.getPoint().x - rect.getX()) > 5) {
+ System.out.println("mouse point " + e.getPoint());
+ System.out.println("caret position " + rect);
+ throw new RuntimeException(" Wrong caret position");
+ }
+ } catch (BadLocationException ex) {}
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e) {}
+
+ @Override
+ public void mouseEntered(MouseEvent e) {}
+
+ @Override
+ public void mouseExited(MouseEvent e) {}
+ });
+ f.add(new JScrollPane(jTextArea1), BorderLayout.CENTER);
+ f.pack();
+ f.setVisible(true);
+ }
+
+ public static void main(String args[]) throws Exception {
+ try {
+
+ SwingUtilities.invokeAndWait(() -> createUI());
+
+ Point p = jTextArea1.getLocationOnScreen();
+ Robot robot = new Robot();
+ robot.setAutoDelay(200);
+ robot.mouseMove(p.x+ 480, p.y+6);
+ robot.waitForIdle();
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.waitForIdle();
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.waitForIdle();
+ } finally {
+ SwingUtilities.invokeAndWait(() -> f.dispose());
+ }
+ }
+
+ private static void fillTextArea(JTextArea area) {
+ StringBuilder buf = new StringBuilder();
+
+ for (int i = 0; i < 3; i++) {
+ StringBuilder row = new StringBuilder();
+ for (int j = 0; j < 50; j++) {
+ row.append(j);
+ if (j % 5 == 0) {
+ row.append(" ");
+ }
+ }
+ buf.append(row).append(System.lineSeparator());
+ }
+ area.setText(buf.toString());
+ area.setCaretPosition(0);
+ }
+}
--- a/test/jdk/jdk/jfr/jvm/TestLogOutput.java Wed Jun 20 11:52:31 2018 +0100
+++ b/test/jdk/jdk/jfr/jvm/TestLogOutput.java Wed Jun 20 12:20:29 2018 +0100
@@ -42,7 +42,7 @@
public static void main(String[] args) throws Exception {
final String fileName = "jfr_trace.txt";
final List<String>findWhat = new ArrayList<>();
- findWhat.add("Starting up Jfr startup recording");
+ findWhat.add("Starting a recording");
findWhat.add("Flight Recorder initialized");
boolean passed = false;
List<String> matches = new ArrayList<String>(findWhat);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2018, 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.jfr.startupargs;
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+/*
+ * @test
+ * @key jfr
+ *
+ * @library /test/lib
+ *
+ * @run main jdk.jfr.startupargs.TestMultipleStartupRecordings
+ */
+public class TestMultipleStartupRecordings {
+
+ private static final String START_FLIGHT_RECORDING = "-XX:StartFlightRecording";
+ private static final String FLIGHT_RECORDER_OPTIONS = "-XX:FlightRecorderOptions";
+
+ static class MainClass {
+ public static void main(String[] args) {
+ }
+ }
+
+ private static void test(ProcessBuilder pb, String... expectedOutputs) throws Exception {
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ for (String s : expectedOutputs) {
+ output.shouldContain(s);
+ }
+ }
+
+ private static void launchUnary(String options) throws Exception {
+ String recording1 = START_FLIGHT_RECORDING + (options != null ? options : "");
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, recording1, MainClass.class.getName());
+ test(pb, "Started recording 1");
+ }
+
+ private static void launchBinary(String options1, String options2) throws Exception {
+ String recording1 = START_FLIGHT_RECORDING + (options1 != null ? options1 : "");
+ String recording2 = START_FLIGHT_RECORDING + (options2 != null ? options2 : "");
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, recording1, recording2, MainClass.class.getName());
+ test(pb, "Started recording 1", "Started recording 2");
+ }
+
+ private static void launchTernary(String options1, String options2, String options3) throws Exception {
+ String recording1 = START_FLIGHT_RECORDING + (options1 != null ? options1 : "");
+ String recording2 = START_FLIGHT_RECORDING + (options2 != null ? options2 : "");
+ String recording3 = START_FLIGHT_RECORDING + (options3 != null ? options3 : "");
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, recording1, recording2, recording3, MainClass.class.getName());
+ test(pb, "Started recording 1", "Started recording 2", "Started recording 3");
+ }
+
+ private static void testDefault() throws Exception {
+ System.out.println("testDefault");
+ launchUnary(null);
+ launchBinary(null, null);
+ launchTernary(null, null, null);
+ }
+
+ private static void testColonDelimited() throws Exception {
+ launchBinary(":name=myrecording1,filename=myrecording1.jfr", ":filename=myrecording2.jfr,name=myrecording2");
+ }
+
+ private static void testMixed() throws Exception {
+ launchTernary(":maxage=2d,maxsize=5GB", "=dumponexit=true,maxage=10m,", ":name=myrecording,maxage=10m,filename=myrecording.jfr,disk=false");
+ }
+
+ private static void testWithFlightRecorderOptions() throws Exception {
+ System.out.println("testWithFlightRecorderOptions");
+ String flightRecorderOptions = FLIGHT_RECORDER_OPTIONS + "=maxchunksize=8m";
+ String recording1 = START_FLIGHT_RECORDING + "=filename=recording1.jfr";
+ String recording2 = START_FLIGHT_RECORDING + "=name=myrecording,filename=recording2.jfr";
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flightRecorderOptions, recording1, recording2, MainClass.class.getName());
+ test(pb, "Started recording 1", "Started recording 2");
+ }
+
+ public static void main(String[] args) throws Exception {
+ testDefault();
+ testColonDelimited();
+ testMixed();
+ testWithFlightRecorderOptions();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/SwingSet/src/GridBagLayoutDemoTest.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+import org.jtregext.GuiTestListener;
+import com.sun.swingset3.demos.gridbaglayout.GridBagLayoutDemo;
+import static com.sun.swingset3.demos.gridbaglayout.GridBagLayoutDemo.*;
+import static com.sun.swingset3.demos.gridbaglayout.Calculator.*;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Point;
+import javax.swing.JButton;
+import javax.swing.UIManager;
+import org.testng.annotations.Test;
+import org.netbeans.jemmy.ClassReference;
+import org.netbeans.jemmy.operators.JFrameOperator;
+import org.netbeans.jemmy.operators.JButtonOperator;
+import org.netbeans.jemmy.operators.JTextFieldOperator;
+import org.testng.annotations.Listeners;
+import static org.jemmy2ext.JemmyExt.EXACT_STRING_COMPARATOR;
+import static org.jemmy2ext.JemmyExt.getUIValue;
+/*
+ * @test
+ * @key headful
+ * @summary Verifies SwingSet3 GridBagLayoutDemo by checking the relative
+ * location of all the components before and after resizing the frame,
+ * interacting with all the controls and checking this interaction on the
+ * text field display.
+ *
+ * @library /sanity/client/lib/jemmy/src
+ * @library /sanity/client/lib/Extensions/src
+ * @library /sanity/client/lib/SwingSet3/src
+ * @modules java.desktop
+ * java.logging
+ * @build com.sun.swingset3.demos.gridbaglayout.GridBagLayoutDemo
+ * @run testng GridBagLayoutDemoTest
+ */
+
+@Listeners(GuiTestListener.class)
+public class GridBagLayoutDemoTest {
+
+ private JTextFieldOperator tfScreen;
+ private JButtonOperator buttonZero;
+ private JButtonOperator buttonOne;
+ private JButtonOperator buttonTwo;
+ private JButtonOperator buttonThree;
+ private JButtonOperator buttonFour;
+ private JButtonOperator buttonFive;
+ private JButtonOperator buttonSix;
+ private JButtonOperator buttonSeven;
+ private JButtonOperator buttonEight;
+ private JButtonOperator buttonNine;
+ private JButtonOperator buttonPlus;
+ private JButtonOperator buttonMinus;
+ private JButtonOperator buttonMultiply;
+ private JButtonOperator buttonDivide;
+ private JButtonOperator buttonComma;
+ private JButtonOperator buttonSqrt;
+ private JButtonOperator buttonReciprocal;
+ private JButtonOperator buttonToggleSign;
+ private JButtonOperator buttonEquals;
+ private JButtonOperator backspaceButton;
+ private JButtonOperator resetButton;
+ private JFrameOperator mainFrame;
+
+ @Test(dataProvider = "availableLookAndFeels", dataProviderClass = TestHelpers.class)
+ public void test(String lookAndFeel) throws Exception {
+ initializeUIComponents(lookAndFeel);
+ // Check that the relative location of buttons is as expected.
+ checkRelativeLocations();
+ // Interact with buttons and check the result on the display.
+ checkInteractionOnDisplay();
+ // Change the location and check that the relative location of buttons is same as before.
+ checkChangeLocation();
+ // Change the size and check that the relative location of buttons is same as before.
+ checkChangeSize();
+ }
+
+ private double x(Component component) {
+ return component.getLocation().getX();
+ }
+
+ private double y(Component component) {
+ return component.getLocation().getY();
+ }
+
+ private void checkRight(JButtonOperator currentButton, JButtonOperator rightButton) {
+ // Check that x coordinate of right button is greater than that of right
+ // end of current button
+ currentButton.waitStateOnQueue(button -> x(button) + button.getWidth() < x(rightButton.getSource()));
+ // Check that the y coordinate of the button is same as the button to
+ // the right
+ currentButton.waitStateOnQueue(button -> y(button) == y(rightButton.getSource()));
+ // Check that the height of the button is same as the button to the
+ // right
+ currentButton.waitStateOnQueue(button -> button.getHeight() == rightButton.getHeight());
+ }
+
+ private void checkBelow(JButtonOperator currentButton, JButtonOperator buttonBelow) {
+ // Check that y coordinate of button below is greater than that of
+ // bottom end of current button
+ currentButton.waitStateOnQueue(button -> y(button) + button.getHeight() < y(buttonBelow.getSource()));
+ // Check that the x coordinate of the button is same as the button below
+ currentButton.waitStateOnQueue(button -> x(button) == x(buttonBelow.getSource()));
+ // Check that the width of the button is same as the button below
+ currentButton.waitStateOnQueue(button -> button.getWidth() == buttonBelow.getWidth());
+ }
+
+ private void checkRelativeLocations() {
+ // Check relative location of button 7
+ checkRight(buttonSeven, buttonEight);
+ checkBelow(buttonSeven, buttonFour);
+
+ // Check relative location of button 8
+ checkRight(buttonEight, buttonNine);
+ checkBelow(buttonEight, buttonFive);
+
+ // Check relative location of button 9
+ checkRight(buttonNine, buttonDivide);
+ checkBelow(buttonNine, buttonSix);
+
+ // Check relative location of Division button
+ checkRight(buttonDivide, buttonReciprocal);
+ checkBelow(buttonDivide, buttonMultiply);
+
+ // Check relative location of Reciprocal and Sqrt buttons
+ checkBelow(buttonReciprocal, buttonSqrt);
+
+ // Check relative location of button 4
+ checkRight(buttonFour, buttonFive);
+ checkBelow(buttonFour, buttonOne);
+
+ // Check relative location of button 5
+ checkRight(buttonFive, buttonSix);
+ checkBelow(buttonFive, buttonTwo);
+
+ // Check relative location of button 6
+ checkRight(buttonSix, buttonMultiply);
+ checkBelow(buttonSix, buttonThree);
+
+ // Check relative location of Multiply button
+ checkRight(buttonMultiply, buttonSqrt);
+ checkBelow(buttonMultiply, buttonMinus);
+
+ // Check relative location of button 1
+ checkRight(buttonOne, buttonTwo);
+ checkBelow(buttonOne, buttonZero);
+
+ // Check relative location of button 2
+ checkRight(buttonTwo, buttonThree);
+ checkBelow(buttonTwo, buttonToggleSign);
+
+ // Check relative location of button 3
+ checkRight(buttonThree, buttonMinus);
+ checkBelow(buttonThree, buttonComma);
+
+ // Check relative location of Minus button
+ checkBelow(buttonMinus, buttonPlus);
+
+ // Check relative location of button 0
+ checkRight(buttonZero, buttonToggleSign);
+
+ // Check relative location of Sign Toggle Button
+ checkRight(buttonToggleSign, buttonComma);
+
+ // Check relative location of Comma button
+ checkRight(buttonComma, buttonPlus);
+
+ // Check relative location of plus and Equals buttons
+ checkRight(buttonPlus, buttonEquals);
+
+ // Check relative location of JPanel containing Backspace and Reset
+ // buttons
+ Point parentLocation = getUIValue(backspaceButton, (JButton button) -> button.getParent().getLocation());
+ // Check that the y coordinate of bottom of the screen is
+ // less than that of parent of backspace button
+ tfScreen.waitStateOnQueue(screen -> y(screen) + screen.getHeight() < parentLocation.getY());
+ // Check that the y coordinate of the button 7 is greater
+ // than that of parent of backspace
+ buttonSeven.waitStateOnQueue(button -> parentLocation.getY() < y(button));
+ // Check that the y coordinate of reciprocal button is greater
+ // than that of parent of backspace
+ buttonReciprocal.waitStateOnQueue(button -> parentLocation.getY() < y(button));
+ // Check that x coordinate of screen is same as that of parent of
+ // backspace
+ tfScreen.waitStateOnQueue(screen -> x(screen) == parentLocation.getX());
+ // Check that x coordinate of button 7 is same as that of parent of
+ // backspace
+ buttonSeven.waitStateOnQueue(button -> x(button) == parentLocation.getX());
+
+ // Check relative location of Backspace button
+ // Check that the x coordinate of right of backspace button
+ // is less than that of reset button
+ backspaceButton.waitStateOnQueue(button -> x(button) + button.getWidth() < x(resetButton.getSource()));
+ // Check that the height of backspace button is same as that of reset
+ // button
+ backspaceButton.waitStateOnQueue(button -> button.getHeight() == resetButton.getHeight());
+ // Check that the y coordinate bottom of backspace button is less that
+ // that of button 7
+ backspaceButton.waitStateOnQueue(
+ button -> parentLocation.getY() + button.getParent().getHeight() < y(buttonSeven.getSource()));
+
+ // Check that the x coordinate of reset button is greater than that
+ // of right of backspace button
+ resetButton.waitStateOnQueue(button -> x(backspaceButton.getSource()) + backspaceButton.getWidth() < x(button));
+
+ // Check that the height of reset button is same as that of backspace
+ // button
+ resetButton.waitStateOnQueue(button -> backspaceButton.getHeight() == button.getHeight());
+
+ // Check that the y coordinate of bottom of reset button is less
+ // than that of divide button.
+ resetButton.waitStateOnQueue(
+ button -> parentLocation.getY() + button.getParent().getHeight() < y(buttonDivide.getSource()));
+
+ // Check that the y coordinate of top of screen is lower
+ // than that of parent of backspace button
+ tfScreen.waitStateOnQueue(screen -> y(screen) + screen.getHeight() < parentLocation.getY());
+ }
+
+ private void checkInteractionOnDisplay() {
+ // Check buttons: 1,2,+,=,C
+ buttonOne.push();
+ tfScreen.waitText("1");
+ buttonPlus.push();
+ tfScreen.waitText("1");
+ buttonTwo.push();
+ tfScreen.waitText("2");
+ buttonEquals.push();
+ tfScreen.waitText("3");
+ resetButton.push();
+ tfScreen.waitText("0");
+
+ // Check buttons: 3,4,-
+ buttonFour.push();
+ tfScreen.waitText("4");
+ buttonMinus.push();
+ tfScreen.waitText("4");
+ buttonThree.push();
+ tfScreen.waitText("3");
+ buttonEquals.push();
+ tfScreen.waitText("1");
+ reset();
+
+ // Check buttons: 5,6,*
+ buttonFive.push();
+ tfScreen.waitText("5");
+ buttonMultiply.push();
+ tfScreen.waitText("5");
+ buttonSix.push();
+ tfScreen.waitText("6");
+ buttonEquals.push();
+ tfScreen.waitText("30");
+ reset();
+
+ // Check buttons: 8,9,/
+ buttonNine.push();
+ buttonNine.push();
+ tfScreen.waitText("99");
+ buttonDivide.push();
+ tfScreen.waitText("99");
+ buttonEight.push();
+ tfScreen.waitText("8");
+ buttonEquals.push();
+ tfScreen.waitText("12.375");
+ reset();
+
+ // Check buttons: 7,0,[+/-],Backspace
+ buttonSeven.push();
+ tfScreen.waitText("7");
+ buttonZero.push();
+ tfScreen.waitText("70");
+ buttonToggleSign.push();
+ tfScreen.waitText("-70");
+ buttonToggleSign.push();
+ tfScreen.waitText("70");
+ backspaceButton.push();
+ tfScreen.waitText("7");
+ reset();
+
+ // Check Sqrt Button
+ buttonFour.push();
+ buttonNine.push();
+ tfScreen.waitText("49");
+ buttonSqrt.push();
+ tfScreen.waitText("7");
+ reset();
+
+ // Check Reciprocal Button
+ buttonFour.push();
+ tfScreen.waitText("4");
+ buttonReciprocal.push();
+ tfScreen.waitText("0.25");
+ reset();
+
+ // Check Comma button
+ buttonFour.push();
+ buttonComma.push();
+ tfScreen.waitText("4,");
+ }
+
+ private void reset() {
+ resetButton.push();
+ tfScreen.waitText("0");
+ }
+
+ private void initializeUIComponents(String lookAndFeel) throws Exception {
+ UIManager.setLookAndFeel(lookAndFeel);
+ new ClassReference(GridBagLayoutDemo.class.getCanonicalName()).startApplication();
+ mainFrame = new JFrameOperator(GRID_BAG_LAYOUT_DEMO_TITLE);
+ mainFrame.setComparator(EXACT_STRING_COMPARATOR);
+ buttonZero = new JButtonOperator(mainFrame, ZERO_BUTTON_TITLE);
+ buttonOne = new JButtonOperator(mainFrame, ONE_BUTTON_TITLE);
+ buttonTwo = new JButtonOperator(mainFrame, TWO_BUTTON_TITLE);
+ buttonThree = new JButtonOperator(mainFrame, THREE_BUTTON_TITLE);
+ buttonFour = new JButtonOperator(mainFrame, FOUR_BUTTON_TITLE);
+ buttonFive = new JButtonOperator(mainFrame, FIVE_BUTTON_TITLE);
+ buttonSix = new JButtonOperator(mainFrame, SIX_BUTTON_TITLE);
+ buttonSeven = new JButtonOperator(mainFrame, SEVEN_BUTTON_TITLE);
+ buttonEight = new JButtonOperator(mainFrame, EIGHT_BUTTON_TITLE);
+ buttonNine = new JButtonOperator(mainFrame, NINE_BUTTON_TITLE);
+ buttonPlus = new JButtonOperator(mainFrame, PLUS_BUTTON_TITLE);
+ buttonMinus = new JButtonOperator(mainFrame, MINUS_BUTTON_TITLE);
+ buttonMultiply = new JButtonOperator(mainFrame, MULTIPLY_BUTTON_TITLE);
+ buttonDivide = new JButtonOperator(mainFrame, DIVIDE_BUTTON_TITLE);
+ buttonComma = new JButtonOperator(mainFrame, ",");
+ buttonSqrt = new JButtonOperator(mainFrame, SQRT_BUTTON_TITLE);
+ buttonReciprocal = new JButtonOperator(mainFrame, INVERSE_BUTTON_TITLE);
+ buttonToggleSign = new JButtonOperator(mainFrame, SWAPSIGN_BUTTON_TITLE);
+ buttonEquals = new JButtonOperator(mainFrame, EQUALS_BUTTON_TITLE);
+ resetButton = new JButtonOperator(mainFrame, C_BUTTON_TITLE);
+ backspaceButton = new JButtonOperator(mainFrame, BACKSPACE_BUTTON_TITLE);
+ tfScreen = new JTextFieldOperator(mainFrame, 0);
+ }
+
+ private void checkChangeLocation() {
+ Point startingPoint = new Point(100, 100);
+ mainFrame.setLocation(startingPoint);
+ mainFrame.waitComponentLocation(startingPoint);
+ checkRelativeLocations();
+ }
+
+ private void checkChangeSize() {
+ Dimension newSize = new Dimension((int) mainFrame.getToolkit().getScreenSize().getWidth() / 2,
+ (int) mainFrame.getToolkit().getScreenSize().getHeight() / 2);
+ mainFrame.setSize(newSize);
+ mainFrame.waitComponentSize(newSize);
+ checkRelativeLocations();
+ }
+}
--- a/test/jdk/sanity/client/SwingSet/src/TestHelpers.java Wed Jun 20 11:52:31 2018 +0100
+++ b/test/jdk/sanity/client/SwingSet/src/TestHelpers.java Wed Jun 20 12:20:29 2018 +0100
@@ -1,17 +1,40 @@
-
import java.awt.Dimension;
import java.awt.Point;
-
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+import java.nio.file.Path;
+import javax.swing.UIManager;
import org.netbeans.jemmy.operators.ComponentOperator;
+import org.testng.annotations.DataProvider;
public class TestHelpers {
+ /**
+ * A DataProvider having the class name of all the available look and feels
+ *
+ * @return a 2d Object array containing the class name of all the available
+ * look and feels
+ */
+ @DataProvider(name = "availableLookAndFeels")
+ public static Object[][] provideAvailableLookAndFeels() {
+ UIManager.LookAndFeelInfo LookAndFeelInfos[]
+ = UIManager.getInstalledLookAndFeels();
+ Object[][] lookAndFeels = new Object[LookAndFeelInfos.length][1];
+ for (int i = 0; i < LookAndFeelInfos.length; i++) {
+ lookAndFeels[i][0] = LookAndFeelInfos[i].getClassName();
+ }
+ return lookAndFeels;
+ }
+
public static void checkChangeLocation(ComponentOperator component,
Point finalLocation) {
Point initialLocation = component.getLocation();
component.setLocation(finalLocation);
component.waitComponentLocation(finalLocation);
component.setLocation(initialLocation);
+ component.waitComponentLocation(initialLocation);
}
public static void checkChangeSize(ComponentOperator component,
@@ -20,5 +43,7 @@
component.setSize(dimensionFinal);
component.waitComponentSize(dimensionFinal);
component.setSize(dimensionInitial);
+ component.waitComponentSize(dimensionInitial);
}
+
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/gridbaglayout/Calculator.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,469 @@
+/*
+ * Copyright (c) 2007, 2018, 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.sun.swingset3.demos.gridbaglayout;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import javax.swing.*;
+
+/**
+ * Calculator
+ *
+ * @author Pavel Porvatov
+ */
+public class Calculator extends JComponent {
+
+ private static final String ZERO = "0";
+
+ private static final char DECIMAL_SEPARATOR = ',';
+
+ private final JTextField tfScreen = new JTextField();
+
+ private enum State {
+
+ INPUT_X,
+ INPUT_X_FINISHED,
+ INPUT_Y,
+ INPUT_Y_FINISHED
+ }
+
+ private enum Operator {
+
+ ADDITION,
+ SUBTRACTION,
+ MULTIPLICATION,
+ DIVISION,
+ SQRT,
+ INVERSE,
+ EQUALS
+ }
+
+ private final Map<Character, Operator> keyMapping = new HashMap<Character, Operator>();
+
+ private String operand_x;
+
+ private Operator operator;
+
+ private State state;
+
+ public static final String ZERO_BUTTON_TITLE = "0";
+ public static final String ONE_BUTTON_TITLE = "1";
+ public static final String TWO_BUTTON_TITLE = "2";
+ public static final String THREE_BUTTON_TITLE = "3";
+ public static final String FOUR_BUTTON_TITLE = "4";
+ public static final String FIVE_BUTTON_TITLE = "5";
+ public static final String SIX_BUTTON_TITLE = "6";
+ public static final String SEVEN_BUTTON_TITLE = "7";
+ public static final String EIGHT_BUTTON_TITLE = "8";
+ public static final String NINE_BUTTON_TITLE = "9";
+ public static final String PLUS_BUTTON_TITLE = "+";
+ public static final String MINUS_BUTTON_TITLE = "-";
+ public static final String DIVIDE_BUTTON_TITLE = "/";
+ public static final String MULTIPLY_BUTTON_TITLE = "*";
+ public static final String BACKSPACE_BUTTON_TITLE = "Backspace";
+ public static final String C_BUTTON_TITLE = "C";
+ public static final String EQUALS_BUTTON_TITLE = "=";
+ public static final String SWAPSIGN_BUTTON_TITLE = "+/-";
+ public static final String INVERSE_BUTTON_TITLE = "1/x";
+ public static final String SQRT_BUTTON_TITLE = "sqrt";
+ public static final String COMMA_BUTTON_TITLE = ",";
+
+ private static DecimalFormatSymbols decimalFormatSymbols;
+ private static DecimalFormat decimalFormat;
+
+ public Calculator() {
+ keyMapping.put('/', Operator.DIVISION);
+ keyMapping.put('*', Operator.MULTIPLICATION);
+ keyMapping.put('+', Operator.ADDITION);
+ keyMapping.put('-', Operator.SUBTRACTION);
+ keyMapping.put('\n', Operator.EQUALS);
+
+ decimalFormatSymbols = new DecimalFormatSymbols(Locale.US);
+ decimalFormatSymbols.setDecimalSeparator('.');
+ decimalFormat = new DecimalFormat("##0.###", decimalFormatSymbols);
+
+ initUI();
+
+ addKeyListener(new KeyAdapter() {
+ public void keyTyped(KeyEvent e) {
+ char c = e.getKeyChar();
+
+ if (Character.isDigit(c)) {
+ doProcessChar(c);
+ } else if (c == '.' || c == ',') {
+ doProcessChar(DECIMAL_SEPARATOR);
+ } else {
+ Operator operator = keyMapping.get(c);
+
+ if (operator != null) {
+ doProcessOperator(operator);
+ }
+ }
+ }
+
+ public void keyPressed(KeyEvent e) {
+ switch (e.getKeyCode()) {
+ case KeyEvent.VK_BACK_SPACE:
+ doProcessBackspace();
+
+ break;
+
+ case KeyEvent.VK_DELETE:
+ doReset();
+ }
+ }
+ });
+
+ doReset();
+ }
+
+ private void initUI() {
+ tfScreen.setHorizontalAlignment(JTextField.RIGHT);
+
+ JButton btnBackspace = new JButton(BACKSPACE_BUTTON_TITLE);
+
+ btnBackspace.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ doProcessBackspace();
+ }
+ });
+
+ JButton btnReset = new JButton(C_BUTTON_TITLE);
+
+ btnReset.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ doReset();
+ }
+ });
+
+ JPanel pnGridPanel = new JPanel(new GridLayout(1, 2, 8, 8));
+
+ pnGridPanel.add(btnBackspace);
+ pnGridPanel.add(btnReset);
+
+ setLayout(new GridBagLayout());
+
+ JButton btnSwapSign = new SquareButton(SWAPSIGN_BUTTON_TITLE);
+
+ btnSwapSign.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ doSwapSign();
+ }
+ });
+
+ addComp(tfScreen, 0, 0, 5, 1);
+ addComp(pnGridPanel, 0, 1, 5, 1);
+
+ addComp(new CharButton(SEVEN_BUTTON_TITLE.charAt(0)), 0, 2, 1, 1);
+ addComp(new CharButton(EIGHT_BUTTON_TITLE.charAt(0)), 1, 2, 1, 1);
+ addComp(new CharButton(NINE_BUTTON_TITLE.charAt(0)), 2, 2, 1, 1);
+ addComp(new OperatorButton(Operator.DIVISION, DIVIDE_BUTTON_TITLE), 3, 2, 1, 1);
+ addComp(new OperatorButton(Operator.INVERSE, INVERSE_BUTTON_TITLE), 4, 2, 1, 1);
+
+ addComp(new CharButton(FOUR_BUTTON_TITLE.charAt(0)), 0, 3, 1, 1);
+ addComp(new CharButton(FIVE_BUTTON_TITLE.charAt(0)), 1, 3, 1, 1);
+ addComp(new CharButton(SIX_BUTTON_TITLE.charAt(0)), 2, 3, 1, 1);
+ addComp(new OperatorButton(Operator.MULTIPLICATION, MULTIPLY_BUTTON_TITLE), 3, 3, 1, 1);
+ addComp(new OperatorButton(Operator.SQRT, SQRT_BUTTON_TITLE), 4, 3, 1, 1);
+
+ addComp(new CharButton(ONE_BUTTON_TITLE.charAt(0)), 0, 4, 1, 1);
+ addComp(new CharButton(TWO_BUTTON_TITLE.charAt(0)), 1, 4, 1, 1);
+ addComp(new CharButton(THREE_BUTTON_TITLE.charAt(0)), 2, 4, 1, 1);
+ addComp(new OperatorButton(Operator.SUBTRACTION, MINUS_BUTTON_TITLE), 3, 4, 1, 1);
+
+ addComp(new CharButton(ZERO_BUTTON_TITLE.charAt(0)), 0, 5, 1, 1);
+ addComp(btnSwapSign, 1, 5, 1, 1);
+ addComp(new CharButton(COMMA_BUTTON_TITLE.charAt(0)), 2, 5, 1, 1);
+ addComp(new OperatorButton(Operator.ADDITION, PLUS_BUTTON_TITLE), 3, 5, 1, 1);
+ addComp(new OperatorButton(Operator.EQUALS, EQUALS_BUTTON_TITLE), 4, 5, 1, 1);
+
+ // Set focusable false
+ resetFocusable(this);
+
+ setFocusable(true);
+ }
+
+ private static void resetFocusable(Component component) {
+ component.setFocusable(false);
+
+ if (component instanceof Container) {
+ for (Component c : ((Container) component).getComponents()) {
+ resetFocusable(c);
+ }
+ }
+ }
+
+ private void doReset() {
+ synchronized (this) {
+ operand_x = null;
+ operator = null;
+ state = State.INPUT_X;
+ }
+ tfScreen.setText(ZERO);
+ }
+
+ private void doProcessChar(char c) {
+ String text = tfScreen.getText();
+
+ String newValue;
+
+ synchronized (this) {
+ if (state == State.INPUT_X || state == State.INPUT_Y) {
+ newValue = attachChar(text, c);
+
+ if (stringToValue(newValue) == null) {
+ return;
+ }
+ } else {
+ newValue = attachChar("0", c);
+
+ if (stringToValue(newValue) == null) {
+ return;
+ }
+
+ if (operator == null) {
+ operand_x = null;
+ state = State.INPUT_X;
+ } else {
+ operand_x = text;
+ state = State.INPUT_Y;
+ }
+ }
+ }
+ tfScreen.setText(newValue);
+ }
+
+ private static String attachChar(String s, char c) {
+ if (Character.isDigit(c)) {
+ if (s.equals(ZERO)) {
+ return Character.toString(c);
+ }
+
+ if (s.equals("-" + ZERO)) {
+ return "-" + Character.toString(c);
+ }
+
+ return s + Character.toString(c);
+ } else {
+ return s + Character.toString(c);
+ }
+ }
+
+ private void doSwapSign() {
+ String text = tfScreen.getText();
+
+ tfScreen.setText(text.startsWith("-") ? text.substring(1) : "-" + text);
+ }
+
+ private void doProcessBackspace() {
+ String text = tfScreen.getText();
+
+ if (text.length() > 0) {
+ text = text.substring(0, text.length() - 1);
+ }
+
+ if (text.length() == 0 || text.equals("-")) {
+ text = ZERO;
+ }
+
+ if (stringToValue(text) != null) {
+ tfScreen.setText(text);
+ }
+ }
+
+ private void doProcessOperator(Operator operator) {
+ double y = stringToValue(tfScreen.getText());
+
+ // Process unary operators
+ boolean isUnary;
+
+ switch (operator) {
+ case SQRT:
+ tfScreen.setText(valueToString(Math.sqrt(y)));
+
+ isUnary = true;
+
+ break;
+
+ case INVERSE:
+ tfScreen.setText(valueToString(1 / y));
+
+ isUnary = true;
+
+ break;
+
+ default:
+ isUnary = false;
+ }
+
+ synchronized (this) {
+ if (isUnary) {
+ if (state == State.INPUT_X) {
+ state = State.INPUT_X_FINISHED;
+ }
+
+ if (state == State.INPUT_Y) {
+ state = State.INPUT_Y_FINISHED;
+ }
+
+ return;
+ }
+
+ // Process binary operators
+ if (state == State.INPUT_Y || state == State.INPUT_Y_FINISHED) {
+ double x = stringToValue(operand_x);
+ double result;
+
+ switch (this.operator) {
+ case ADDITION:
+ result = x + y;
+
+ break;
+
+ case SUBTRACTION:
+ result = x - y;
+
+ break;
+
+ case MULTIPLICATION:
+ result = x * y;
+
+ break;
+
+ case DIVISION:
+ result = x / y;
+
+ break;
+
+ default:
+ throw new IllegalStateException("Unsupported operation " + operator);
+ }
+
+ tfScreen.setText(valueToString(result));
+ }
+
+ this.operator = operator == Operator.EQUALS ? null : operator;
+ operand_x = null;
+
+ state = State.INPUT_X_FINISHED;
+ }
+ }
+
+ private static Double stringToValue(String value) {
+ try {
+ return new Double(value.replace(DECIMAL_SEPARATOR, '.'));
+ } catch (NumberFormatException e) {
+ // Continue convertion
+ }
+
+ if (value.endsWith(String.valueOf(DECIMAL_SEPARATOR))) {
+ try {
+ // Try convert uncompleted value
+ return new Double(value.substring(0, value.length() - 1));
+ } catch (NumberFormatException e) {
+ // Continue convertion
+ }
+ }
+
+ return null;
+ }
+
+ private static String valueToString(Double value) {
+ if (value == null) {
+ return ZERO;
+ } else {
+ String result = decimalFormat.format(value);
+
+ if (result.endsWith(".0")) {
+ result = result.substring(0, result.length() - 2);
+ }
+
+ if (result.equals("-0")) {
+ result = ZERO;
+ }
+
+ return result;
+ }
+ }
+
+ private void addComp(Component comp, int gridx, int gridy,
+ int gridwidth, int gridheight) {
+ add(comp, new GridBagConstraints(gridx, gridy, gridwidth, gridheight,
+ 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
+ new Insets(4, 4, 4, 4), 0, 0));
+ }
+
+ private static class SquareButton extends JButton {
+
+ private SquareButton(String text) {
+ super(text);
+
+ setMargin(new Insets(2, 0, 2, 0));
+ }
+
+ public Dimension getMinimumSize() {
+ Dimension result = super.getMinimumSize();
+
+ if (result.width < result.height) {
+ result.width = result.height;
+ }
+
+ return result;
+ }
+
+ public Dimension getPreferredSize() {
+ return getMinimumSize();
+ }
+ }
+
+ private class CharButton extends SquareButton {
+
+ private CharButton(final char c) {
+ super(String.valueOf(c));
+
+ addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ doProcessChar(c);
+ }
+ });
+ }
+ }
+
+ private class OperatorButton extends SquareButton {
+
+ private OperatorButton(final Operator operator, String text) {
+ super(text);
+
+ addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ doProcessOperator(operator);
+ }
+ });
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/gridbaglayout/GridBagLayoutDemo.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2007, 2018, 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.sun.swingset3.demos.gridbaglayout;
+
+import java.awt.*;
+import javax.swing.*;
+
+import com.sun.swingset3.demos.JGridPanel;
+import com.sun.swingset3.demos.ResourceManager;
+import com.sun.swingset3.DemoProperties;
+
+/**
+ * GridBagLayout Demo
+ *
+ * @author Pavel Porvatov
+ */
+@DemoProperties(
+ value = "GridBagLayout Demo",
+ category = "Containers",
+ description = "Demonstrates GridBagLayout, a layout which allows to arrange components in containers.",
+ sourceFiles = {
+ "com/sun/swingset3/demos/gridbaglayout/GridBagLayoutDemo.java",
+ "com/sun/swingset3/demos/gridbaglayout/Calculator.java",
+ "com/sun/swingset3/demos/JGridPanel.java",
+ "com/sun/swingset3/demos/ResourceManager.java",
+ "com/sun/swingset3/demos/gridbaglayout/resources/GridBagLayoutDemo.properties",
+ "com/sun/swingset3/demos/gridbaglayout/resources/images/GridBagLayoutDemo.gif"
+ }
+)
+public class GridBagLayoutDemo extends JPanel {
+
+ private final ResourceManager resourceManager = new ResourceManager(this.getClass());
+
+ private final JLabel lbCaption = new JLabel("<html>"
+ + resourceManager.getString("GridBagLayoutDemo.caption.text") + "</html>");
+
+ private final Calculator calculator = new Calculator();
+
+ public static final String GRID_BAG_LAYOUT_DEMO_TITLE = GridBagLayoutDemo.class
+ .getAnnotation(DemoProperties.class).value();
+
+ /**
+ * main method allows us to run as a standalone demo.
+ */
+ public static void main(String[] args) {
+ JFrame frame = new JFrame(GRID_BAG_LAYOUT_DEMO_TITLE);
+
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.getContentPane().add(new GridBagLayoutDemo());
+ frame.setPreferredSize(new Dimension(800, 600));
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+
+ public GridBagLayoutDemo() {
+ setLayout(new BorderLayout());
+
+ initUI();
+ }
+
+ private void initUI() {
+ JGridPanel pnContent = new JGridPanel(1, 0, 2);
+
+ pnContent.setBorderEqual(10);
+
+ pnContent.cell(lbCaption, JGridPanel.Layout.FILL).
+ cell().
+ cell(calculator, JGridPanel.Layout.CENTER, JGridPanel.Layout.FIRST).
+ cell();
+
+ add(pnContent);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/gridbaglayout/resources/GridBagLayoutDemo.properties Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,4 @@
+### GridBagLayout Demo ###
+
+GridBagLayoutDemo.caption.text = This calculator uses the GridBagLayout layout manager to arrange components. \
+ GridBagLayout is very useful when you need to place components in a grid of rows and columns.
Binary file test/jdk/sanity/client/lib/SwingSet3/src/com/sun/swingset3/demos/gridbaglayout/resources/images/GridBagLayoutDemo.gif has changed
--- a/test/jdk/sun/tools/jstatd/JstatGCUtilParser.java Wed Jun 20 11:52:31 2018 +0100
+++ b/test/jdk/sun/tools/jstatd/JstatGCUtilParser.java Wed Jun 20 12:20:29 2018 +0100
@@ -25,16 +25,14 @@
import jdk.testlibrary.Utils;
import static jdk.testlibrary.Asserts.*;
+import java.text.NumberFormat;
/**
* The helper class for parsing following output from command 'jstat -gcutil':
*
- * S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
- * 100.00 0.00 64.68 13.17 73.39 33.46 2 0.003 1 0.156 0.158
- * 100.00 0.00 76.54 13.17 73.39 33.46 2 0.003 1 0.156 0.158
- * 100.00 0.00 83.49 13.17 73.39 33.46 2 0.003 1 0.156 0.158
- * 100.00 0.00 84.53 13.17 73.39 33.46 2 0.003 1 0.156 0.158
- * 100.00 0.00 85.57 13.17 73.39 33.46 2 0.003 1 0.156 0.158
+ * S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT
+ * 0.00 0.00 86.67 0.00 - - 0 0.000 0 0.000 0 0.000 0.000
+ * 0.00 0.00 86.67 0.00 - - 0 0.000 0 0.000 0 0.000 0.000
*
* It will be verified that numerical values have defined types and are reasonable,
* for example percentage should fit within 0-100 interval.
@@ -50,7 +48,7 @@
S1(GcStatisticsType.PERCENTAGE),
E(GcStatisticsType.PERCENTAGE),
O(GcStatisticsType.PERCENTAGE),
- M(GcStatisticsType.PERCENTAGE),
+ M(GcStatisticsType.PERCENTAGE_OR_DASH),
CCS(GcStatisticsType.PERCENTAGE_OR_DASH),
YGC(GcStatisticsType.INTEGER),
YGCT(GcStatisticsType.DOUBLE),
@@ -97,18 +95,18 @@
GcStatisticsType type = values()[i].getType();
String value = valueArray[i].trim();
if (type.equals(GcStatisticsType.INTEGER)) {
- Integer.parseInt(value);
+ NumberFormat.getInstance().parse(value).intValue();
break;
}
if (type.equals(GcStatisticsType.DOUBLE)) {
- Double.parseDouble(value);
+ NumberFormat.getInstance().parse(value).doubleValue();
break;
}
if (type.equals(GcStatisticsType.PERCENTAGE_OR_DASH) &&
value.equals("-")) {
break;
}
- double percentage = Double.parseDouble(value);
+ double percentage = NumberFormat.getInstance().parse(value).doubleValue();
assertTrue(0 <= percentage && percentage <= 100,
"Not a percentage: " + value);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/jdk/javadoc/doclet/testEnumConstructor/TestEnumConstructor.java Wed Jun 20 12:20:29 2018 +0100
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2018, 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 8202624
+ * @summary javadoc generates references to enum constructors, which are not documented
+ * @library /tools/lib ../lib
+ * @modules jdk.javadoc/jdk.javadoc.internal.tool
+ * @build JavadocTester
+ * @run main TestEnumConstructor
+ */
+
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import toolbox.ToolBox;
+
+public class TestEnumConstructor extends JavadocTester {
+
+ final ToolBox tb;
+
+ public static void main(String... args) throws Exception {
+ TestEnumConstructor tester = new TestEnumConstructor();
+ tester.runTests(m -> new Object[]{Paths.get(m.getName())});
+ }
+
+ TestEnumConstructor() {
+ tb = new ToolBox();
+ }
+
+ @Test
+ void test1(Path base) throws Exception {
+ Path srcDir = base.resolve("src");
+ createEnum(srcDir);
+
+ Path outDir = base.resolve("out");
+ javadoc("-d", outDir.toString(),
+ "-private",
+ "-sourcepath", srcDir.toString(),
+ "pkg");
+
+ checkExit(Exit.OK);
+ checkOrder("pkg/TestEnum.html",
+ "Constructor Summary",
+ "Modifier", "Constructor",
+ "private", "<a href=\"#%3Cinit%3E(int)\">TestEnum</a></span>​(int val)");
+ checkOutput("index-all.html", true,
+ "<a href=\"pkg/TestEnum.html#%3Cinit%3E(int)\">TestEnum(int)</a>");
+
+ }
+
+ @Test
+ void test2(Path base) throws Exception {
+ Path srcDir = base.resolve("src");
+ createEnum(srcDir);
+
+ Path outDir = base.resolve("out");
+ javadoc("-d", outDir.toString(),
+ "-package",
+ "-sourcepath", srcDir.toString(),
+ "pkg");
+
+ checkExit(Exit.OK);
+ checkOutput("pkg/TestEnum.html", false, "Constructor Summary");
+ checkOutput("index-all.html", false,
+ "<a href=\"pkg/TestEnum.html#%3Cinit%3E(int)\">TestEnum(int)</a>");
+ }
+
+ void createEnum(Path srcDir) throws Exception {
+ tb.writeJavaFiles(srcDir,
+ "package pkg;\n"
+ + "public enum TestEnum{\n"
+ + "CONST1(100),CONST2(50),CONST3(10);\n"
+ + "private int val;\n"
+ + "TestEnum(int val){this.val=val;}\n"
+ + "}");
+ }
+}
--- a/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java Wed Jun 20 11:52:31 2018 +0100
+++ b/test/langtools/jdk/javadoc/doclet/testHtmlVersion/TestHtmlVersion.java Wed Jun 20 12:20:29 2018 +0100
@@ -24,6 +24,7 @@
/*
* @test
* @bug 8072945 8081854 8141492 8148985 8150188 4649116 8173707 8151743 8169819 8183037 8182765 8196202
+ * 8202624
* @summary Test the version of HTML generated by the javadoc tool.
* @author bpatel
* @library ../lib
@@ -41,7 +42,6 @@
@Test
void test1() {
- setAutomaticCheckLinks(false); // @ignore JDK-8202624
javadoc("-d", "out-1",
"-private",
"-linksource",
@@ -49,7 +49,6 @@
"-sourcepath", testSrc,
"-use",
"pkg", "pkg1", "pkg2", "pkg3");
- setAutomaticCheckLinks(true); // @ignore JDK-8202624
checkExit(Exit.OK);
html5Output();
@@ -58,7 +57,6 @@
@Test
void test2() {
- setAutomaticCheckLinks(false); // @ignore JDK-8202624
javadoc("-d", "out-2",
"-html4",
"-private",
@@ -67,7 +65,6 @@
"-sourcepath", testSrc,
"-use",
"pkg", "pkg1", "pkg2", "pkg3");
- setAutomaticCheckLinks(true); // @ignore JDK-8202624
checkExit(Exit.OK);
html4Output();
@@ -76,7 +73,6 @@
@Test
void test3() {
- setAutomaticCheckLinks(false); // @ignore JDK-8202624
javadoc("-d", "out-3",
"-html4",
"-private",
@@ -85,7 +81,6 @@
"-sourcepath", testSrc,
"-use",
"pkg", "pkg1", "pkg2", "pkg3");
- setAutomaticCheckLinks(true); // @ignore JDK-8202624
checkExit(Exit.OK);
html4Output();
--- a/test/langtools/tools/javac/lvti/ParserTest.out Wed Jun 20 11:52:31 2018 +0100
+++ b/test/langtools/tools/javac/lvti/ParserTest.out Wed Jun 20 12:20:29 2018 +0100
@@ -1,9 +1,9 @@
-ParserTest.java:14:18: compiler.err.var.not.allowed: var
-ParserTest.java:16:22: compiler.err.var.not.allowed: var
-ParserTest.java:20:19: compiler.err.var.not.allowed: var
-ParserTest.java:24:14: compiler.err.var.not.allowed: var
-ParserTest.java:28:20: compiler.err.var.not.allowed: var
-ParserTest.java:36:27: compiler.err.var.not.allowed: var
+ParserTest.java:14:18: compiler.err.var.not.allowed
+ParserTest.java:16:22: compiler.err.var.not.allowed
+ParserTest.java:20:19: compiler.err.var.not.allowed
+ParserTest.java:24:14: compiler.err.var.not.allowed
+ParserTest.java:28:20: compiler.err.var.not.allowed
+ParserTest.java:36:27: compiler.err.var.not.allowed
ParserTest.java:38:5: compiler.err.var.not.allowed.here
ParserTest.java:41:15: compiler.err.var.not.allowed.array
ParserTest.java:42:13: compiler.err.var.not.allowed.array
@@ -11,7 +11,7 @@
ParserTest.java:44:13: compiler.err.var.not.allowed.array
ParserTest.java:45:15: compiler.err.var.not.allowed.array
ParserTest.java:46:13: compiler.err.var.not.allowed.array
-ParserTest.java:49:13: compiler.err.var.not.allowed.compound
+ParserTest.java:49:24: compiler.err.var.not.allowed.compound
ParserTest.java:54:5: compiler.err.var.not.allowed.here
ParserTest.java:58:16: compiler.err.var.not.allowed.here
ParserTest.java:59:14: compiler.err.var.not.allowed.here
--- a/test/langtools/tools/javac/lvti/ParserTest9.out Wed Jun 20 11:52:31 2018 +0100
+++ b/test/langtools/tools/javac/lvti/ParserTest9.out Wed Jun 20 12:20:29 2018 +0100
@@ -4,4 +4,28 @@
ParserTest.java:24:14: compiler.warn.var.not.allowed
ParserTest.java:28:20: compiler.warn.var.not.allowed
ParserTest.java:36:27: compiler.warn.var.not.allowed
-6 warnings
+ParserTest.java:38:5: compiler.warn.var.not.allowed
+ParserTest.java:41:15: compiler.warn.var.not.allowed
+ParserTest.java:42:13: compiler.warn.var.not.allowed
+ParserTest.java:43:17: compiler.warn.var.not.allowed
+ParserTest.java:44:13: compiler.warn.var.not.allowed
+ParserTest.java:45:15: compiler.warn.var.not.allowed
+ParserTest.java:46:13: compiler.warn.var.not.allowed
+ParserTest.java:47:23: compiler.warn.var.not.allowed
+ParserTest.java:48:13: compiler.warn.var.not.allowed
+ParserTest.java:49:13: compiler.warn.var.not.allowed
+ParserTest.java:50:23: compiler.warn.var.not.allowed
+ParserTest.java:51:23: compiler.warn.var.not.allowed
+ParserTest.java:54:5: compiler.warn.var.not.allowed
+ParserTest.java:58:16: compiler.warn.var.not.allowed
+ParserTest.java:59:14: compiler.warn.var.not.allowed
+ParserTest.java:60:24: compiler.warn.var.not.allowed
+ParserTest.java:61:22: compiler.warn.var.not.allowed
+ParserTest.java:63:22: compiler.warn.var.not.allowed
+ParserTest.java:63:40: compiler.warn.var.not.allowed
+ParserTest.java:64:18: compiler.warn.var.not.allowed
+ParserTest.java:68:35: compiler.warn.var.not.allowed
+ParserTest.java:69:22: compiler.warn.var.not.allowed
+ParserTest.java:73:24: compiler.warn.var.not.allowed
+ParserTest.java:74:18: compiler.warn.var.not.allowed
+30 warnings
--- a/test/langtools/tools/javac/lvti/badTypeReference/BadTypeReference.out Wed Jun 20 11:52:31 2018 +0100
+++ b/test/langtools/tools/javac/lvti/badTypeReference/BadTypeReference.out Wed Jun 20 12:20:29 2018 +0100
@@ -1,3 +1,3 @@
-BadTypeReference.java:39:9: compiler.err.illegal.ref.to.var.type: var
-BadTypeReference.java:40:21: compiler.err.illegal.ref.to.var.type: var
+BadTypeReference.java:39:9: compiler.err.illegal.ref.to.var.type
+BadTypeReference.java:40:21: compiler.err.illegal.ref.to.var.type
2 errors