Compare commits

..

1 Commits

Author SHA1 Message Date
Vitaly Provodin
9182819b00 update exclude list on results of 21.37 test runs 2023-03-18 14:26:49 +04:00
44 changed files with 249 additions and 1466 deletions

View File

@@ -42,7 +42,7 @@ JBR_API_GENSRC_FILES := $(foreach f, $(call FindFiles, $(JBR_API_SRC_DIR)), \
$(JBR_API_GENSRC_DIR)/$(call RelativePath, $f, $(JBR_API_SRC_DIR)))
ifeq ($(JBR_API_JBR_VERSION),)
JBR_API_JBR_VERSION := DEVELOPMENT
JBR_API_JBR_VERSION := <DEVELOPMENT>
JBR_API_FAIL_ON_HASH_MISMATCH := false
else
.PHONY: $(JBR_API_VERSION_PROPERTIES)
@@ -90,4 +90,4 @@ ifneq ($(JBR_API_CONF_FILE),)
$(ECHO) "SOURCES_JAR=$(JBR_API_OUTPUT_DIR)/jbr-api-sources.jar" >> $(JBR_API_CONF_FILE)
jbr-api: $(JBR_API_CONF_FILE)
.PHONY: $(JBR_API_CONF_FILE)
endif
endif

View File

@@ -113,9 +113,7 @@ void ciObjectFactory::initialize() {
// compiler thread that initializes the initial ciObjectFactory which
// creates the shared ciObjects that all later ciObjectFactories use.
Arena* arena = new (mtCompiler) Arena(mtCompiler);
if (AllowEnhancedClassRedefinition) {
ciObjectFactory::_initial_arena = arena;
}
ciObjectFactory::_initial_arena = arena;
ciEnv initial(arena);
ciEnv* env = ciEnv::current();
env->_factory->init_shared_objects();

View File

@@ -4,7 +4,7 @@
*
* 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.
* published by the Free Software Foundation) replace old_class by new class in dictionary.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or

View File

@@ -716,10 +716,37 @@ void VM_EnhancedRedefineClasses::reinitializeJDKClasses() {
for (int i = 0; i < _new_classes->length(); i++) {
InstanceKlass* cur = _new_classes->at(i);
if (cur == vmClasses::ClassLoader_klass()) {
// ClassLoader.addClass method is cached in Universe, we must redefine
Universe::reinitialize_loader_addClass_method(JavaThread::current());
log_trace(redefine, class, obsolete, metadata)("Reinitialize ClassLoade addClass method cache.");
if ((cur->name()->starts_with("java/") || cur->name()->starts_with("jdk/") || cur->name()->starts_with("sun/"))
&& cur->name()->index_of_at(0, "$$", (int) strlen("$$")) == -1) { // skip dynamic proxies
if (cur == vmClasses::ClassLoader_klass()) {
// ClassLoader.addClass method is cached in Universe, we must redefine
Universe::reinitialize_loader_addClass_method(JavaThread::current());
log_trace(redefine, class, obsolete, metadata)("Reinitialize ClassLoade addClass method cache.");
}
// naive assumptions that only JDK classes has native static "registerNative" and "initIDs" methods
int end;
Symbol* signature = vmSymbols::registerNatives_method_name();
int midx = cur->find_method_by_name(signature, &end);
if (midx == -1) {
signature = vmSymbols::initIDs_method_name();
midx = cur->find_method_by_name(signature, &end);
}
Method* m = nullptr;
if (midx != -1) {
m = cur->methods()->at(midx);
}
if (m != nullptr && m->is_static() && m->is_native()) {
// call static registerNative if present
JavaValue result(T_VOID);
JavaCalls::call_static(&result,
cur,
signature,
vmSymbols::void_method_signature(),
JavaThread::current());
log_trace(redefine, class, obsolete, metadata)("Reregister natives of JDK class %s", cur->external_name());
}
}
}
}
@@ -1693,7 +1720,7 @@ void VM_EnhancedRedefineClasses::check_methods_and_mark_as_obsolete() {
// removed.
// It expects only to be used during the VM_EnhancedRedefineClasses op (a safepoint).
//
// This class is used after the new methods have been installed in "new_class".
// This class is used after the new methods have been installed in "the_class".
//
// So, for example, the following must be handled. Where 'm' is a method and
// a number followed by an underscore is a prefix.
@@ -1709,7 +1736,7 @@ void VM_EnhancedRedefineClasses::check_methods_and_mark_as_obsolete() {
//
class TransferNativeFunctionRegistration {
private:
InstanceKlass* new_class;
InstanceKlass* the_class;
int prefix_count;
char** prefixes;
@@ -1724,7 +1751,7 @@ class TransferNativeFunctionRegistration {
Symbol* signature) {
TempNewSymbol name_symbol = SymbolTable::probe(name_str, (int)name_len);
if (name_symbol != nullptr) {
Method* method = new_class->lookup_method(name_symbol, signature);
Method* method = the_class->lookup_method(name_symbol, signature);
if (method != nullptr) {
// Even if prefixed, intermediate methods must exist.
if (method->is_native()) {
@@ -1787,10 +1814,10 @@ class TransferNativeFunctionRegistration {
public:
// Construct a native method transfer processor for this class.
TransferNativeFunctionRegistration(InstanceKlass* _new_class) {
TransferNativeFunctionRegistration(InstanceKlass* _the_class) {
assert(SafepointSynchronize::is_at_safepoint(), "sanity check");
new_class = _new_class;
the_class = _the_class;
prefixes = JvmtiExport::get_all_native_method_prefixes(&prefix_count);
}
@@ -1814,8 +1841,8 @@ class TransferNativeFunctionRegistration {
};
// Don't lose the association between a native method and its JNI function.
void VM_EnhancedRedefineClasses::transfer_old_native_function_registrations(InstanceKlass* new_class) {
TransferNativeFunctionRegistration transfer(new_class);
void VM_EnhancedRedefineClasses::transfer_old_native_function_registrations(InstanceKlass* the_class) {
TransferNativeFunctionRegistration transfer(the_class);
transfer.transfer_registrations(_deleted_methods, _deleted_methods_length);
transfer.transfer_registrations(_matching_old_methods, _matching_methods_length);
}
@@ -1954,7 +1981,7 @@ void VM_EnhancedRedefineClasses::redefine_single_class(Thread *current, Instance
_any_class_has_resolved_methods = the_class->has_resolved_methods() || _any_class_has_resolved_methods;
transfer_old_native_function_registrations(new_class);
transfer_old_native_function_registrations(the_class);
// JSR-292 support

View File

@@ -135,7 +135,7 @@ class VM_EnhancedRedefineClasses: public VM_GC_Operation {
// marking methods as old and/or obsolete
void check_methods_and_mark_as_obsolete();
void transfer_old_native_function_registrations(InstanceKlass* new_class);
void transfer_old_native_function_registrations(InstanceKlass* the_class);
void redefine_single_class(Thread* current, InstanceKlass* new_class_oop);

View File

@@ -262,23 +262,6 @@ void JNIHandles::print_on(outputStream* st) {
st->flush();
}
// Called while generating crash log, possibly not at safepoint
void JNIHandles::print_on_unsafe(outputStream* st) {
st->print_cr("JNI global refs: " SIZE_FORMAT ", weak refs: " SIZE_FORMAT,
global_handles()->allocation_count(),
weak_global_handles()->allocation_count());
st->cr();
st->flush();
}
void JNIHandles::print_memory_usage_on(outputStream *st) {
st->print_cr("JNI global refs memory usage: " SIZE_FORMAT ", weak refs: " SIZE_FORMAT,
global_handles()->total_memory_usage(),
weak_global_handles()->total_memory_usage());
st->cr();
st->flush();
}
void JNIHandles::print() { print_on(tty); }
class VerifyJNIHandles: public OopClosure {

View File

@@ -110,8 +110,6 @@ public:
// Debugging
static void print_on(outputStream* st);
static void print_on_unsafe(outputStream* st);
static void print_memory_usage_on(outputStream* st);
static void print();
static void verify();
// The category predicates all require handle != nullptr.

View File

@@ -25,7 +25,6 @@
#include "precompiled.hpp"
#include "classfile/classLoaderDataGraph.hpp"
#include "classfile/vmSymbols.hpp"
#include "classfile/symbolTable.hpp"
#include "code/codeCache.hpp"
#include "compiler/compileBroker.hpp"
#include "gc/shared/collectedHeap.hpp"
@@ -38,7 +37,6 @@
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "oops/symbol.hpp"
#include "oops/symbolHandle.hpp"
#include "runtime/arguments.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/frame.inline.hpp"
@@ -51,7 +49,6 @@
#include "runtime/threadSMR.inline.hpp"
#include "runtime/vmOperations.hpp"
#include "services/threadService.hpp"
#include "javaCalls.hpp"
#define VM_OP_NAME_INITIALIZE(name) #name,
@@ -161,37 +158,6 @@ void VM_ZombieAll::doit() {
#endif // !PRODUCT
// Prints out additional information supplied by the application
// through the use of JBR API. The data in the form of a String
// are obtained from Throwable.$$jb$getAdditionalInfoForJstack()
// and, not not null, are included into the output.
void VM_PrintThreads::print_additional_info() {
JavaThread *THREAD = JavaThread::current();
HandleMark hm(THREAD);
ResourceMark rm;
InstanceKlass *klass = vmClasses::Throwable_klass();
if (klass != NULL) {
TempNewSymbol method_name = SymbolTable::new_symbol("$$jb$getAdditionalInfoForJstack");
Symbol *signature = vmSymbols::void_string_signature();
Method *method = klass->find_method(method_name, signature);
if (method != NULL) {
JavaValue result(T_OBJECT);
JavaCalls::call_static(&result, klass,
method_name, signature, THREAD);
oop dump_oop = result.get_oop();
if (dump_oop != NULL) {
// convert Java String to utf8 string
char *s = java_lang_String::as_utf8_string(dump_oop);
_out->cr();
_out->print_raw_cr(s);
_out->cr();
}
}
}
}
bool VM_PrintThreads::doit_prologue() {
// Get Heap_lock if concurrent locks will be dumped
if (_print_concurrent_locks) {
@@ -204,7 +170,6 @@ void VM_PrintThreads::doit() {
Threads::print_on(_out, true, false, _print_concurrent_locks, _print_extended_info);
if (_print_jni_handle_info) {
JNIHandles::print_on(_out);
JNIHandles::print_memory_usage_on(_out);
}
}
@@ -213,13 +178,6 @@ void VM_PrintThreads::doit_epilogue() {
// Release Heap_lock
Heap_lock->unlock();
}
// We should be on the "signal handler" thread, which is a JavaThread
if (Thread::current()->is_Java_thread()) {
// .. but best play it safe as we're going to need to make
// Java calls on the current thread.
print_additional_info();
}
}
void VM_PrintMetadata::doit() {

View File

@@ -154,9 +154,6 @@ class VM_PrintThreads: public VM_Operation {
void doit();
bool doit_prologue();
void doit_epilogue();
private:
void print_additional_info();
};
class VM_PrintMetadata : public VM_Operation {

View File

@@ -43,7 +43,6 @@
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/javaThread.inline.hpp"
#include "runtime/jniHandles.hpp"
#include "runtime/init.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/osThread.hpp"
@@ -1077,11 +1076,6 @@ void VMError::report(outputStream* st, bool _verbose) {
STEP_IF("Native Memory Tracking", _verbose)
MemTracker::error_report(st);
STEP("JNI global references")
st->print_cr("JNI global refs:");
JNIHandles::print_on_unsafe(st);
JNIHandles::print_memory_usage_on(st);
STEP_IF("printing system", _verbose)
st->cr();
st->print_cr("--------------- S Y S T E M ---------------");

View File

@@ -36,8 +36,6 @@ public class JBRApiModule {
static {
JBRApi.registerModule(MethodHandles.lookup(), JBRApiModule.class.getModule()::addExports)
.service("com.jetbrains.JBR$ServiceApi")
.withStatic("getService", "getService", "com.jetbrains.internal.JBRApi")
.service("com.jetbrains.Jstack")
.withStatic("includeInfoFrom", "$$jb$additionalInfoForJstack", "java.lang.Throwable");
.withStatic("getService", "getService", "com.jetbrains.internal.JBRApi");
}
}

View File

@@ -1130,20 +1130,4 @@ public class Throwable implements Serializable {
else
return suppressedExceptions.toArray(EMPTY_THROWABLE_ARRAY);
}
private static volatile java.util.function.Supplier<String> $$jb$additionalInfoSupplier = null;
// JBR API internals
private static void $$jb$additionalInfoForJstack(java.util.function.Supplier<String> supplier) {
$$jb$additionalInfoSupplier = supplier;
}
// NB: this is invoked from the VM
private static String $$jb$getAdditionalInfoForJstack() {
final java.util.function.Supplier<String> supplier = $$jb$additionalInfoSupplier;
if (supplier != null) {
return supplier.get();
}
return null;
}
}

View File

@@ -160,19 +160,13 @@ public final class UnixDomainSocketAddress extends SocketAddress {
* @throws NullPointerException if path is {@code null}
*/
public static UnixDomainSocketAddress of(Path path) {
final FileSystem fs = path.getFileSystem();
final FileSystem defaultFS = sun.nio.fs.DefaultFileSystemProvider.theFileSystem();
if (fs != defaultFS || fs.getClass().getModule() != Object.class.getModule()) {
try {
// Check if we'll be able to create a socket from this Path later on by
// testing for the presence of a method identical to
// AbstractFileSystemProvider.getSunPathForSocketFile()
fs.provider().getClass().getMethod("getSunPathForSocketFile", Path.class);
} catch (NoSuchMethodException | SecurityException e) {
throw new IllegalArgumentException();
}
FileSystem fs = path.getFileSystem();
if (fs != FileSystems.getDefault()) {
throw new IllegalArgumentException();
}
if (fs.getClass().getModule() != Object.class.getModule()) {
throw new IllegalArgumentException();
}
return new UnixDomainSocketAddress(path);
}

View File

@@ -99,22 +99,8 @@ class UnixDomainSockets {
}
static byte[] getPathBytes(Path path) {
java.nio.file.FileSystem fs = path.getFileSystem();
FileSystemProvider provider = fs.provider();
if (fs == sun.nio.fs.DefaultFileSystemProvider.theFileSystem()) {
return ((AbstractFileSystemProvider) provider).getSunPathForSocketFile(path);
} else {
try {
java.lang.reflect.Method method = provider.getClass().getMethod("getSunPathForSocketFile", Path.class);
Object result = method.invoke(provider, path);
return (byte[]) result;
} catch (NoSuchMethodException | SecurityException e) {
// This should've been verified when UnixDomainSocketAddress was created
throw new Error("Can't find getSunPathForSocketFile(Path) in the non-default file system provider " + provider.getClass());
} catch (java.lang.reflect.InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException("Can't invoke getSunPathForSocketFile(Path) from a non-default file system provider", e);
}
}
FileSystemProvider provider = FileSystems.getDefault().provider();
return ((AbstractFileSystemProvider) provider).getSunPathForSocketFile(path);
}
static FileDescriptor socket() throws IOException {
@@ -150,11 +136,13 @@ class UnixDomainSockets {
int rnd = random.nextInt(Integer.MAX_VALUE);
try {
final Path path = Path.of(dir, "socket_" + rnd);
if (path.getFileSystem().provider() != sun.nio.fs.DefaultFileSystemProvider.instance()) {
throw new UnsupportedOperationException(
"Unix Domain Sockets not supported on non-default file system");
}
return UnixDomainSocketAddress.of(path);
} catch (InvalidPathException e) {
throw new BindException("Invalid temporary directory");
} catch (IllegalArgumentException e) {
throw new UnsupportedOperationException("Unix Domain Sockets not supported on non-default file system without method getSunPathForSocketFile(Path)");
}
}

View File

@@ -75,6 +75,7 @@ BOOL isDisplaySyncEnabled() {
self.framebufferOnly = YES;
self.nextDrawableCount = 0;
self.opaque = YES;
self.presentsWithTransaction = YES;
return self;
}
@@ -132,7 +133,6 @@ BOOL isDisplaySyncEnabled() {
destinationOrigin:MTLOriginMake(0, 0, 0)];
[blitEncoder endEncoding];
[commandBuf presentDrawable:mtlDrawable];
__block MTLLayer* layer = self;
[layer retain];
[commandBuf addCompletedHandler:^(id <MTLCommandBuffer> commandBuf) {
@@ -141,6 +141,8 @@ BOOL isDisplaySyncEnabled() {
}];
[commandBuf commit];
[commandBuf waitUntilScheduled];
[mtlDrawable present];
}
}

View File

@@ -231,9 +231,7 @@ public abstract class SunToolkit extends Toolkit
* }
*/
@SuppressWarnings("removal")
private static final ReentrantLock AWT_LOCK = new ReentrantLock(
AccessController.doPrivileged(new GetBooleanAction("awt.lock.fair")));
private static final ReentrantLock AWT_LOCK = new ReentrantLock();
private static final Condition AWT_LOCK_COND = AWT_LOCK.newCondition();
public interface AwtLockListener {

View File

@@ -307,8 +307,8 @@ public class XBaseWindow {
return 1;
}
protected int scaleUp(int i) {
return i;
protected int scaleUp(int x) {
return x;
}
protected int scaleUpX(int x) {
return x;
@@ -317,8 +317,8 @@ public class XBaseWindow {
return y;
}
protected int scaleDown(int i) {
return i;
protected int scaleDown(int x) {
return x;
}
protected int scaleDownX(int x) {
return x;

View File

@@ -50,14 +50,11 @@ abstract class XDecoratedPeer extends XWindowPeer {
// reparented - indicates that WM has adopted the top-level.
boolean configure_seen;
boolean insets_corrected;
// Set to true after reconfigureContentWindow is called for the first time.
// Before this, content window may not be in sync with insets.
private boolean content_reconfigured;
XIconWindow iconWindow;
volatile WindowDimensions dimensions;
XContentWindow content;
private volatile Insets currentInsets; // Device-space
volatile Insets currentInsets;
XFocusProxyWindow focusProxy;
static final Map<Class<?>,Insets> lastKnownInsets =
Collections.synchronizedMap(new HashMap<>());
@@ -308,6 +305,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
insLog.finer("FRAME_EXTENTS: {0}", wm_set_insets);
}
if (wm_set_insets != null) {
wm_set_insets = copyAndScaleDown(wm_set_insets);
}
return wm_set_insets;
}
@@ -344,7 +344,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
wm_set_insets = null;
Insets in = getWMSetInsets(XAtom.get(ev.get_atom()));
if (isReparented() && (!isMapped() || getMWMDecorTitleProperty().isPresent()) &&
in != null && !copyAndScaleDown(in).equals(dimensions.getInsets())) {
in != null && !in.equals(dimensions.getInsets())) {
handleCorrectInsets(in);
}
} else {
@@ -359,7 +359,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
if (!isEmbedded() && !isTargetUndecorated()) {
lastKnownInsets.put(getClass(), in);
}
if (!copyAndScaleDown(in).equals(dimensions.getInsets())) {
if (!in.equals(dimensions.getInsets())) {
if (insets_corrected || isMaximized()) {
currentInsets = in;
insets_corrected = true;
@@ -444,7 +444,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
}
// If these insets are equal to our current insets - no actions are necessary
Insets dimInsets = dimensions.getInsets();
if (copyAndScaleDown(correctWM).equals(dimInsets)) {
if (correctWM.equals(dimInsets)) {
insLog.finer("Insets are the same as estimated - no additional reshapes necessary");
no_reparent_artifacts = true;
insets_corrected = true;
@@ -453,6 +453,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
}
} else {
correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
if (correctWM != null) {
correctWM = copyAndScaleDown(correctWM);
}
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
if (correctWM != null) {
@@ -525,11 +528,14 @@ abstract class XDecoratedPeer extends XWindowPeer {
} else {
if (!isNull(currentInsets)) {
/* insets were set on wdata by System Properties */
return currentInsets;
return copy(currentInsets);
} else {
Insets res = getWMSetInsets(null);
if (res == null) {
res = XWM.getWM().guessInsets(this);
if (res != null) {
res = copyAndScaleDown(res);
}
}
return res;
}
@@ -541,20 +547,15 @@ abstract class XDecoratedPeer extends XWindowPeer {
currentInsets = copy(guessed);
}
@Override
Insets getRealUnscaledInsets() {
private Insets getRealInsets() {
if (isNull(currentInsets)) {
applyGuessedInsets();
}
return currentInsets;
}
Insets getRealInsets() {
return copyAndScaleDown(getRealUnscaledInsets());
}
public Insets getInsets() {
Insets in = getRealInsets();
Insets in = copy(getRealInsets());
in.top += getMenuBarHeight();
if (insLog.isLoggable(PlatformLogger.Level.FINEST)) {
insLog.finest("Get insets returns {0}", in);
@@ -695,7 +696,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
break;
case SET_CLIENT_SIZE: {
// Sets client rect size. Width and height contain insets.
Insets in = getRealInsets();
Insets in = currentInsets;
width -= in.left+in.right;
height -= in.top+in.bottom;
dims.setClientSize(width, height);
@@ -739,7 +740,6 @@ abstract class XDecoratedPeer extends XWindowPeer {
return;
}
content.setContentBounds(dims);
content_reconfigured = true;
}
private XEvent pendingConfigureEvent;
@@ -839,7 +839,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
}
}
if (correctWM != null) {
handleCorrectInsets(correctWM);
handleCorrectInsets(copyAndScaleDown(correctWM));
} else {
//Only one attempt to correct insets is made (to lower risk)
//if insets are still not available we simply set the flag
@@ -849,23 +849,23 @@ abstract class XDecoratedPeer extends XWindowPeer {
updateChildrenSizes();
WindowLocation newLocation = getNewLocation(xe);
Dimension newDimension = new Dimension(xe.get_width(), xe.get_height());
boolean xinerama = XToolkit.localEnv.runningXinerama();
Point newLocation = getNewLocation(xe, currentInsets.left, currentInsets.top);
WindowDimensions newDimensions =
new WindowDimensions(newLocation,
new Dimension(scaleDown(xe.get_width()),
scaleDown(xe.get_height())),
copy(currentInsets), true);
SunToolkit.executeOnEventHandlerThread(target, () -> {
Point newUserLocation = newLocation.getUserLocation();
WindowDimensions newDimensions = new WindowDimensions(newUserLocation,
new Dimension(scaleDown(newDimension.width), scaleDown(newDimension.height)), getRealInsets(), true);
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
insLog.finer("Insets are {0}, new dimensions {1}",
currentInsets, newDimensions);
}
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
insLog.finer("Insets are {0}, new dimensions {1}",
getRealInsets(), newDimensions);
}
checkIfOnNewScreen(newDimensions.getBounds(), () -> {
Point oldLocation = getLocation();
dimensions = newDimensions;
if (!newUserLocation.equals(oldLocation)) {
if (!newLocation.equals(oldLocation)) {
handleMoved(newDimensions);
}
reconfigureContentWindow(newDimensions);
@@ -873,20 +873,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
repositionSecurityWarning();
if (xinerama) {
checkIfOnNewScreen(new Rectangle(newLocation.getDeviceLocation(), newDimension));
}
});
}
@Override
WindowLocation queryXLocation() {
XContentWindow c = content;
boolean client = c == null || !content_reconfigured;
return new WindowLocation(XlibUtil.translateCoordinates(client ? window : c.getWindow(),
XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()), 0, 0), client);
}
private void checkShellRectSize(Rectangle shellRect) {
shellRect.width = Math.max(MIN_SIZE, shellRect.width);
shellRect.height = Math.max(MIN_SIZE, shellRect.height);
@@ -1412,28 +1401,13 @@ abstract class XDecoratedPeer extends XWindowPeer {
return getMWMDecorTitleProperty().orElse(true);
}
@Override
void syncBounds() {
Rectangle r = target.getBounds();
if (syncSizeOnly && dimensions != null) {
dimensions.setSize(r.width, r.height);
dimensions.setInsets(getRealInsets());
xSetSize(r.width, r.height);
} else {
dimensions = new WindowDimensions(r, getRealInsets(), false);
xSetBounds(r.x, r.y, r.width, r.height);
}
reconfigureContentWindow(dimensions);
doValidateSurface();
layout();
}
@Override
public boolean updateGraphicsData(GraphicsConfiguration gc) {
boolean ret = super.updateGraphicsData(gc);
if (content != null) {
content.initGraphicsConfiguration();
content.syncBounds();
}
boolean ret = super.updateGraphicsData(gc);
updateMinimumSize();
return ret;
}

View File

@@ -142,21 +142,22 @@ public class XEmbeddedFramePeer extends XFramePeer {
xembedLog.fine(xe.toString());
}
WindowLocation newLocation = getNewLocation(xe);
Dimension newDimension = new Dimension(xe.get_width(), xe.get_height());
boolean xinerama = XToolkit.localEnv.runningXinerama();
// fix for 5063031
// if we use super.handleConfigureNotifyEvent() we would get wrong
// size and position because embedded frame really is NOT a decorated one
SunToolkit.executeOnEventHandlerThread(target, () -> {
Point newUserLocation = newLocation.getUserLocation();
checkIfOnNewScreen(toGlobal(new Rectangle(
scaleDown(xe.get_x()),
scaleDown(xe.get_y()),
scaleDown(xe.get_width()),
scaleDown(xe.get_height()))), () -> {
Rectangle oldBounds = getBounds();
synchronized (getStateLock()) {
x = newUserLocation.x;
y = newUserLocation.y;
width = scaleDown(newDimension.width);
height = scaleDown(newDimension.height);
x = scaleDown(xe.get_x());
y = scaleDown(xe.get_y());
width = scaleDown(xe.get_width());
height = scaleDown(xe.get_height());
dimensions.setClientSize(width, height);
dimensions.setLocation(x, y);
@@ -167,9 +168,6 @@ public class XEmbeddedFramePeer extends XFramePeer {
}
reconfigureContentWindow(dimensions);
if (xinerama) {
checkIfOnNewScreen(new Rectangle(newLocation.getDeviceLocation(), newDimension));
}
});
}

View File

@@ -1143,8 +1143,12 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
* insets are calculated using _NET_WORKAREA property of the root window.
* <p>
* Note that _NET_WORKAREA is a rectangular area and it does not work
* well in the Xinerama mode, so we assume that only 0th screen has insets.
* Below is an example when _NET_WORKAREA produces wrong result.
* well in the Xinerama mode.
* <p>
* We will trust the part of this rectangular area only if it starts at the
* requested graphics configuration. Below is an example when the
* _NET_WORKAREA intersects with the requested graphics configuration but
* produces wrong result.
*
* //<-x1,y1///////
* // // ////////////////
@@ -1162,25 +1166,20 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
if (np == null || !(gd instanceof X11GraphicsDevice) || !np.active()) {
return super.getScreenInsets(gc);
}
X11GraphicsDevice x11gd = (X11GraphicsDevice) gd;
int screenNum = x11gd.getScreen();
if (localEnv.runningXinerama() && screenNum != 0) {
// We cannot estimate insets for non-default screen,
// there are often none.
return new Insets(0, 0, 0, 0);
}
XToolkit.awtLock();
try {
Rectangle workArea = getWorkArea(XlibUtil.getRootWindow(screenNum));
X11GraphicsDevice x11gd = (X11GraphicsDevice) gd;
long root = XlibUtil.getRootWindow(x11gd.getScreen());
Rectangle workArea = getWorkArea(root);
Rectangle screen = gc.getBounds();
if (workArea != null) {
workArea.x = x11gd.scaleDownX(workArea.x);
workArea.y = x11gd.scaleDownY(workArea.y);
workArea.width = x11gd.scaleDown(workArea.width);
workArea.height = x11gd.scaleDown(workArea.height);
workArea = workArea.intersection(screen);
if (!workArea.isEmpty()) {
if (screen.contains(workArea.getLocation())) {
workArea = workArea.intersection(screen);
int top = workArea.y - screen.y;
int left = workArea.x - screen.x;
int bottom = screen.height - workArea.height - top;

View File

@@ -1072,7 +1072,9 @@ final class XWM
try {
Rectangle shellBounds;
if (getWMID() != UNITY_COMPIZ_WM) {
shellBounds = window.getBounds();
shellBounds = window.getShellBounds();
shellBounds.translate(-window.currentInsets.left,
-window.currentInsets.top);
} else {
shellBounds = window.getDimensions().getScreenBounds();
}

View File

@@ -1740,8 +1740,8 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
}
@Override
protected int scaleUp(int i) {
return graphicsConfig.scaleUp(i);
protected int scaleUp(int x) {
return graphicsConfig.scaleUp(x);
}
@Override
protected int scaleUpX(int x) {
@@ -1753,8 +1753,8 @@ class XWindow extends XBaseWindow implements X11ComponentPeer {
}
@Override
protected int scaleDown(int i) {
return graphicsConfig.scaleDown(i);
protected int scaleDown(int x) {
return graphicsConfig.scaleDown(x);
}
@Override
protected int scaleDownX(int x) {

View File

@@ -39,6 +39,7 @@ import sun.awt.AWTAccessor.ComponentAccessor;
import sun.awt.DisplayChangedListener;
import sun.awt.IconInfo;
import sun.awt.SunToolkit;
import sun.awt.X11GraphicsConfig;
import sun.awt.X11GraphicsDevice;
import sun.awt.X11GraphicsEnvironment;
import sun.java2d.pipe.Region;
@@ -99,8 +100,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
private Long desktopId; // guarded by AWT lock
private boolean desktopIdInvalid; // guarded by AWT lock
transient boolean syncSizeOnly; // Force syncBounds() to sync only size, not location.
/*
* Focus related flags
*/
@@ -529,10 +528,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
}
Insets getRealUnscaledInsets() {
return new Insets(0, 0, 0, 0);
}
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}
@@ -657,69 +652,83 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
/* Xinerama
* called to check if we've been moved onto a different screen
* Based on checkNewXineramaScreen() in awt_GraphicsEnv.c
* newBounds are specified in device space.
*/
public boolean checkIfOnNewScreen(Rectangle newBounds) {
public void checkIfOnNewScreen(Rectangle newBounds, Runnable next) {
if (!XToolkit.localEnv.runningXinerama()) {
if (next != null) next.run();
return;
}
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("XWindowPeer: Check if we've been moved to a new screen since we're running in Xinerama mode");
}
// Remap new bounds to native unscaled coordinates
newBounds.x = scaleUpX(newBounds.x);
newBounds.y = scaleUpY(newBounds.y);
newBounds.width = scaleUp(newBounds.width);
newBounds.height = scaleUp(newBounds.height);
int largestIntersection = 0;
int curScreenNum = ((X11GraphicsDevice)getGraphicsConfiguration().getDevice()).getScreen();
int newScreenNum = curScreenNum;
GraphicsDevice[] gds = XToolkit.localEnv.getScreenDevices();
GraphicsConfiguration newGC = null;
for (int i = 0; i < gds.length; i++) {
X11GraphicsDevice device = (X11GraphicsDevice) gds[i];
Rectangle screenBounds = gds[i].getDefaultConfiguration().getBounds();
// Rescale screen size to native unscaled coordinates
screenBounds.width = device.scaleUp(screenBounds.width);
screenBounds.height = device.scaleUp(screenBounds.height);
XToolkit.awtUnlock();
try {
for (int i = 0; i < gds.length; i++) {
X11GraphicsDevice device = (X11GraphicsDevice) gds[i];
Rectangle screenBounds = gds[i].getDefaultConfiguration().getBounds();
// Rescale screen size to native unscaled coordinates
screenBounds.width = device.scaleUp(screenBounds.width);
screenBounds.height = device.scaleUp(screenBounds.height);
Rectangle intersection = screenBounds.intersection(newBounds);
if (!intersection.isEmpty()) {
int area = intersection.width * intersection.height;
if (area > largestIntersection) {
largestIntersection = area;
newScreenNum = i;
newGC = gds[i].getDefaultConfiguration();
if (intersection.equals(newBounds)) break;
Rectangle intersection = screenBounds.intersection(newBounds);
if (!intersection.isEmpty()) {
int area = intersection.width * intersection.height;
if (area > largestIntersection) {
largestIntersection = area;
newScreenNum = i;
newGC = gds[i].getDefaultConfiguration();
if (intersection.equals(newBounds)) break;
}
}
}
}
// Ensure that after window will be moved to another monitor and (probably)
// resized as a result, majority of its area will stay on the new monitor
if (newScreenNum != curScreenNum) {
X11GraphicsDevice device = (X11GraphicsDevice) gds[newScreenNum];
Rectangle screenBounds = newGC.getBounds();
// Rescale screen size to native unscaled coordinates
screenBounds.width = device.scaleUp(screenBounds.width);
screenBounds.height = device.scaleUp(screenBounds.height);
// Rescale window to new screen's scale
newBounds.width = newBounds.width * device.getScaleFactor() / graphicsConfig.getScale();
newBounds.height = newBounds.height * device.getScaleFactor() / graphicsConfig.getScale();
// Ensure that after window will be moved to another monitor and (probably)
// resized as a result, majority of its area will stay on the new monitor
if (newScreenNum != curScreenNum) {
X11GraphicsDevice device = (X11GraphicsDevice) gds[newScreenNum];
Rectangle screenBounds = newGC.getBounds();
// Rescale screen size to native unscaled coordinates
screenBounds.width = device.scaleUp(screenBounds.width);
screenBounds.height = device.scaleUp(screenBounds.height);
// Rescale window to new screen's scale
newBounds.width = newBounds.width * device.getScaleFactor() / graphicsConfig.getScale();
newBounds.height = newBounds.height * device.getScaleFactor() / graphicsConfig.getScale();
Rectangle intersection = screenBounds.intersection(newBounds);
if (intersection.isEmpty() ||
intersection.width * intersection.height <= newBounds.width * newBounds.height / 2) {
newScreenNum = curScreenNum; // Don't move to new screen
Rectangle intersection = screenBounds.intersection(newBounds);
if (intersection.isEmpty() ||
intersection.width * intersection.height < newBounds.width * newBounds.height / 2) {
newScreenNum = curScreenNum; // Don't move to new screen
}
}
} finally {
XToolkit.awtLock();
}
if (newScreenNum != curScreenNum) {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("XWindowPeer: Moved to a new screen");
}
var gc = newGC;
var device = (X11GraphicsDevice) gc.getDevice();
var acc = AWTAccessor.getComponentAccessor();
syncSizeOnly = true;
acc.setSize(target, device.scaleDown(newBounds.width), device.scaleDown(newBounds.height));
acc.setGraphicsConfiguration(target, gc);
syncSizeOnly = false;
return true;
graphicsConfig = (X11GraphicsConfig) newGC;
final GraphicsConfiguration ngc = newGC;
SunToolkit.executeOnEventHandlerThread(target, () -> {
AWTAccessor.getComponentAccessor().setGraphicsConfiguration(target, ngc);
if (next != null) next.run();
});
} else {
if (next != null) next.run();
}
return false;
}
/**
@@ -752,68 +761,28 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
public void paletteChanged() {
}
void xSetSize(int width, int height) {
if (getWindow() == 0) {
insLog.warning("Attempt to resize uncreated window");
throw new IllegalStateException("Attempt to resize uncreated window");
}
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
insLog.fine("Setting size on " + this + " to " + width + "x" + height);
}
width = Math.max(MIN_SIZE, width);
height = Math.max(MIN_SIZE, height);
XToolkit.awtLock();
try {
XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getWindow(),
scaleUp(width), scaleUp(height));
} finally {
XToolkit.awtUnlock();
}
private Point queryXLocation()
{
Point p = XlibUtil.translateCoordinates(getContentWindow(), XlibWrapper
.RootWindow(XToolkit.getDisplay(),
getScreenNumber()),
0, 0);
p.x = scaleDownX(p.x);
p.y = scaleDownY(p.y);
return p;
}
class WindowLocation {
private final Point location; // Device space
private final boolean client;
WindowLocation(Point location, boolean client) {
this.location = location;
this.client = client;
}
Point getDeviceLocation() {
if (location == null) {
Point l = AWTAccessor.getComponentAccessor().getLocation(target);
l.x = scaleUpX(l.x);
l.y = scaleUpY(l.y);
return l;
} else if (client) {
Insets insets = getRealUnscaledInsets();
return new Point(location.x - insets.left, location.y - insets.top);
} else {
return location;
}
}
Point getUserLocation() {
if (location == null) {
return AWTAccessor.getComponentAccessor().getLocation(target);
} else if (client) {
Insets insets = getRealUnscaledInsets();
return new Point(scaleDownX(location.x - insets.left), scaleDownY(location.y - insets.top));
} else {
return new Point(scaleDownX(location.x), scaleDownY(location.y));
}
}
}
protected Point getNewLocation(XConfigureEvent xe, int leftInset, int topInset) {
// Bounds of the window
Rectangle targetBounds = AWTAccessor.getComponentAccessor().getBounds(target);
WindowLocation queryXLocation() {
return new WindowLocation(XlibUtil.translateCoordinates(getContentWindow(),
XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()), 0, 0), false);
}
WindowLocation getNewLocation(XConfigureEvent xe) {
int runningWM = XWM.getWMID();
Point newLocation = targetBounds.getLocation();
if (xe.get_send_event() ||
(ENABLE_REPARENTING_CHECK ? (runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) : !isReparented())) {
// Location, Client size + insets
return new WindowLocation(new Point(xe.get_x(), xe.get_y()), true);
newLocation = new Point(scaleDownX(xe.get_x()) - leftInset,
scaleDownY(xe.get_y()) - topInset);
} else {
// ICCCM 4.1.5 states that a real ConfigureNotify will be sent when
// a window is resized but the client can not tell if the window was
@@ -830,15 +799,20 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
case XWM.UNITY_COMPIZ_WM:
case XWM.AWESOME_WM:
{
WindowLocation xlocation = queryXLocation();
Point xlocation = queryXLocation();
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("New X location: {0} ({1})", xlocation.location, xlocation.client ? "client" : "bounds");
log.fine("New X location: {0}", xlocation);
}
return xlocation;
if (xlocation != null) {
newLocation = xlocation;
}
break;
}
default:
break;
}
}
return new WindowLocation(null, false);
return newLocation;
}
/*
@@ -853,18 +827,18 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
insLog.fine(xe.toString());
}
WindowLocation newLocation = getNewLocation(xe);
Dimension newDimension = new Dimension(xe.get_width(), xe.get_height());
boolean xinerama = XToolkit.localEnv.runningXinerama();
Rectangle oldBounds = getBounds();
SunToolkit.executeOnEventHandlerThread(target, () -> {
Point newUserLocation = newLocation.getUserLocation();
Rectangle oldBounds = getBounds();
x = scaleDownX(xe.get_x());
y = scaleDownY(xe.get_y());
width = scaleDown(xe.get_width());
height = scaleDown(xe.get_height());
x = newUserLocation.x;
y = newUserLocation.y;
width = scaleDown(newDimension.width);
height = scaleDown(newDimension.height);
checkIfOnNewScreen(new Rectangle(
scaleDownX(xe.get_x()),
scaleDownY(xe.get_y()),
scaleDown(xe.get_width()),
scaleDown(xe.get_height())), () -> {
if (!getBounds().getSize().equals(oldBounds.getSize())) {
AWTAccessor.getComponentAccessor().setSize(target, width, height);
@@ -876,9 +850,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
repositionSecurityWarning();
if (xinerama) {
checkIfOnNewScreen(new Rectangle(newLocation.getDeviceLocation(), newDimension));
}
});
}
@@ -1731,9 +1702,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
modalBlocker = d;
if (isReparented() ||
ENABLE_REPARENTING_CHECK && XWM.isNonReparentingWM() ||
!ENABLE_REPARENTING_CHECK && isMapped()) {
if (isReparented() || ENABLE_REPARENTING_CHECK && XWM.isNonReparentingWM()) {
addToTransientFors(blockerPeer, javaToplevels);
} else {
delayedModalBlocking = true;
@@ -1744,9 +1713,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
}
modalBlocker = null;
if (isReparented() ||
ENABLE_REPARENTING_CHECK && XWM.isNonReparentingWM() ||
!ENABLE_REPARENTING_CHECK && isMapped()) {
if (isReparented() || ENABLE_REPARENTING_CHECK && XWM.isNonReparentingWM()) {
if (FULL_MODAL_TRANSIENTS_CHAIN || haveCommonAncestor(target, d)) {
removeFromTransientFors();
}
@@ -2615,29 +2582,6 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
return false;
}
@Override
void syncBounds() {
Rectangle r = target.getBounds();
width = r.width;
height = r.height;
if (syncSizeOnly) {
xSetSize(width, height);
} else {
x = r.x;
y = r.y;
xSetBounds(x, y, width, height);
}
doValidateSurface();
layout();
}
@Override
public boolean updateGraphicsData(GraphicsConfiguration gc) {
if (super.updateGraphicsData(gc)) return true;
repositionSecurityWarning();
return false;
}
static boolean haveCommonAncestor(Component c1, Component c2) {
return getRootOwner(c1) == getRootOwner(c2);
}

View File

@@ -271,8 +271,8 @@ public class X11GraphicsConfig extends GraphicsConfiguration
return getDevice().getScaleFactor();
}
public int scaleUp(int i) {
return getDevice().scaleUp(i);
public int scaleUp(int x) {
return getDevice().scaleUp(x);
}
public int scaleUpX(int x) {
return getDevice().scaleUpX(x);
@@ -281,8 +281,8 @@ public class X11GraphicsConfig extends GraphicsConfiguration
return getDevice().scaleUpY(y);
}
public int scaleDown(int i) {
return getDevice().scaleDown(i);
public int scaleDown(int x) {
return getDevice().scaleDown(x);
}
public int scaleDownX(int x) {
return getDevice().scaleDownX(x);

View File

@@ -129,8 +129,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
return TYPE_RASTER_SCREEN;
}
public int scaleUp(int i) {
return Region.clipRound(i * (double)getScaleFactor());
public int scaleUp(int x) {
return Region.clipRound(x * (double)getScaleFactor());
}
public int scaleUpX(int x) {
int s = getBoundsCached().x;
@@ -141,8 +141,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
return Region.clipRound(s + (y - s) * (double)getScaleFactor());
}
public int scaleDown(int i) {
return Region.clipRound(i / (double)getScaleFactor());
public int scaleDown(int x) {
return Region.clipRound(x / (double)getScaleFactor());
}
public int scaleDownX(int x) {
int s = getBoundsCached().x;

View File

@@ -143,32 +143,6 @@ static void* get_schema_value(char *name, char *key) {
return NULL;
}
// When monitor framebuffer scaling enabled, compositor scales down monitor resolutions according to their scales,
// so that we're working in logical, not device pixels, just like in macOS. This approach is used for implementing
// fractional scaling, so basically this function tells you whether fractional scaling is enabled or not.
int isMonitorFramebufferScalingEnabled() {
int result = 0;
void* features = get_schema_value("org.gnome.mutter", "experimental-features");
if (features) {
if (fp_g_variant_is_of_type(features, "as")) {
int numFeatures = fp_g_variant_n_children(features);
for (int i = 0; i < numFeatures; i++) {
void* feature = fp_g_variant_get_child_value(features, i);
if (feature) {
char* name = fp_g_variant_get_string(feature, NULL);
if (name && strcmp(name, "scale-monitor-framebuffer") == 0) {
result = 1;
}
fp_g_variant_unref(feature);
if (result) break;
}
}
}
fp_g_variant_unref(features);
}
return result;
}
static double getDesktopScale(char *output_name) {
double result = -1;

View File

@@ -30,7 +30,6 @@
double getNativeScaleFactor(char *output_name, double default_value);
double getScaleEnvVar(const char* var_name, double default_value);
int isMonitorFramebufferScalingEnabled();
#endif

View File

@@ -802,28 +802,24 @@ Java_sun_awt_X11GraphicsEnvironment_updateWaylandMonitorScaling(JNIEnv *env, jcl
if (!usingXinerama || !wlLibHandle) return;
struct UpdateWaylandMonitorsData monData;
monData.currentWaylandMonitor = -1;
monData.currentWaylandScale = 1;
monData.waylandMonitorScales = NULL;
if (!isMonitorFramebufferScalingEnabled()) {
monData.xinInfo = (*XineramaQueryScreens)(awt_display, &monData.xinScreens);
if (monData.xinInfo == NULL) return;
wl_display* display = wl_display_connect(NULL);
if (display == NULL) return;
monData.waylandMonitorScales = calloc(monData.xinScreens, sizeof(int32_t));
monData.xinInfo = (*XineramaQueryScreens)(awt_display, &monData.xinScreens);
if (monData.xinInfo == NULL) return;
wl_display* display = wl_display_connect(NULL);
if (display == NULL) return;
monData.waylandMonitorScales = calloc(monData.xinScreens, sizeof(int32_t));
wl_registry* registry = wl_proxy_marshal_constructor(display, 1, wl_registry_interface, NULL); // wl_display_get_registry
wl_proxy_add_listener(registry, (void (**)(void)) &wlRegistryListener, &monData); // wl_registry_add_listener
wl_display_roundtrip(display); // Get globals (wl_outputs)
wl_display_roundtrip(display); // Get outputs info
wl_registry* registry = wl_proxy_marshal_constructor(display, 1, wl_registry_interface, NULL); // wl_display_get_registry
wl_proxy_add_listener(registry, (void (**)(void)) &wlRegistryListener, &monData); // wl_registry_add_listener
wl_display_roundtrip(display); // Get globals (wl_outputs)
wl_display_roundtrip(display); // Get outputs info
wl_display_disconnect(display);
XFree(monData.xinInfo);
}
XFree(monData.xinInfo);
int32_t* oldScales = waylandMonitorScales;
waylandMonitorScales = monData.waylandMonitorScales;
free(oldScales);
wl_display_disconnect(display);
}
/*

View File

@@ -386,20 +386,6 @@ void AwtWindow::RepositionSecurityWarning(JNIEnv *env)
MsgRouting AwtWindow::WmWindowPosChanged(LPARAM windowPos) {
WINDOWPOS * wp = (WINDOWPOS *)windowPos;
// There's no good way to detect partial maximization (e.g. Aero Snap),
// but by inspecting SWP_* flags we can guess it and reset
// prevScaleRec to neutralize the CheckWindowDPIChange logic.
// Here are the flags, observed on Windows 11 for reference:
// Restore/maximize: SWP_NOZORDER | SWP_DRAWFRAME
// Partial Aero Snap: SWP_NOZORDER | SWP_NOREPOSITION
// DPI change (new screen): SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS
if (!(wp->flags & (SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE)) &&
prevScaleRec.screen != -1 && prevScaleRec.screen != m_screenNum) {
prevScaleRec.screen = -1;
prevScaleRec.scaleX = -1.0f;
prevScaleRec.scaleY = -1.0f;
}
// Reposition the warning window
if (IsUntrusted() && warningWindow != NULL) {
if (wp->flags & SWP_HIDEWINDOW) {
@@ -2344,7 +2330,7 @@ void AwtWindow::CheckWindowDPIChange() {
if (prevScaleRec.screen != -1 && prevScaleRec.screen != m_screenNum) {
Devices::InstanceAccess devices;
AwtWin32GraphicsDevice *device = devices->GetDevice(m_screenNum);
if (device) {
if (device && !::IsZoomed(GetHWnd())) {
if (prevScaleRec.scaleX != device->GetScaleX()
|| prevScaleRec.scaleY != device->GetScaleY()) {
RECT rect;

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2023 JetBrains s.r.o.
* 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.jetbrains;
import java.util.function.Supplier;
public interface Jstack {
/**
* Specifies a supplier of additional information to be included into
* the output of {@code jstack}. The String supplied will be included
* as-is with no header surrounded only with line breaks.
*
* {@code infoSupplier} will be invoked on an unspecified thread that
* must not be left blocked for a long time.
*
* Only one supplier is allowed, so subsequent calls to
* {@code includeInfoFrom} will overwrite the previously specified supplier.
*
* @param infoSupplier a supplier of {@code String} values to be
* included into jstack's output. If {@code null},
* then the previously registered supplier is removed
* (if any) and no extra info will be included.
*/
void includeInfoFrom(Supplier<String> infoSupplier);
}

View File

@@ -6,9 +6,9 @@
# 2. When only new API is added, or some existing API was @Deprecated - increment MINOR, reset PATCH to 0
# 3. For major backwards incompatible API changes - increment MAJOR, reset MINOR and PATCH to 0
VERSION = 0.0.12
VERSION = 0.0.11
# Hash is used to track changes to jetbrains.api, so you would not forget to update version when needed.
# When you make any changes, "make jbr-api" will fail and ask you to update hash and version number here.
HASH = 2C7C5F48509A9C542CBE202930B871
HASH = 8FEFE261B473A778A5BC77FBC83D32

View File

@@ -1,76 +0,0 @@
/*
* Copyright 2023 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @test
* @summary Verifies that the HotSpot crash log includes information
* about the number of JNI references and their associated
* memory consumption.
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @run main JNIRefsInCrashLog
*/
import jdk.internal.misc.Unsafe;
import jdk.test.lib.Asserts;
import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import java.util.ArrayList;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.nio.file.Files;
public class JNIRefsInCrashLog {
static final String HS_ERR_FILE_NAME = "hs_err_42.txt";
static final Unsafe unsafe = Unsafe.getUnsafe();
public static void main(String args[]) throws Exception {
if (args.length > 0 && args[0].equals("--test")) {
unsafe.putAddress(0, 42);
} else {
generateAndVerifyCrashLogContents();
}
}
public static void generateAndVerifyCrashLogContents() throws Exception {
ArrayList<String> opts = new ArrayList<>();
opts.add("--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED");
opts.add("-XX:-CreateCoredumpOnCrash");
opts.add("-XX:ErrorFile=./" + HS_ERR_FILE_NAME);
opts.add(JNIRefsInCrashLog.class.getName());
opts.add("--test");
ProcessBuilder pb = ProcessTools.createTestJvm(opts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain(HS_ERR_FILE_NAME);
final Path hsErrPath = Paths.get(HS_ERR_FILE_NAME);
if (!Files.exists(hsErrPath)) {
throw new RuntimeException(HS_ERR_FILE_NAME + " file missing");
}
final String hsErrorFile = new String(Files.readAllBytes(hsErrPath));
System.out.println(hsErrorFile);
if (!hsErrorFile.contains("JNI global refs memory usage:")) {
throw new RuntimeException("JNI global refs memory usage missing from " + HS_ERR_FILE_NAME);
}
}
}

View File

@@ -1,63 +0,0 @@
/*
* Copyright 2023 JetBrains s.r.o.
* 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
* @summary Verifies that jstack includes information on memory
* consumed by JNI global/weak references
* @library /test/lib
* @run main/othervm JNIRefsInJstack
*/
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.Platform;
import java.io.IOException;
public class JNIRefsInJstack {
public static void main(String[] args) {
long pid = ProcessHandle.current().pid();
final OutputAnalyzer jstackOutput = runJstack(pid);
jstackOutput.shouldHaveExitValue(0)
.shouldContain("JNI global refs memory usage:");
}
static OutputAnalyzer runJstack(long pid) {
try {
final String JSTACK = JDKToolFinder.getTestJDKTool("jstack");
final ProcessBuilder pb = new ProcessBuilder(JSTACK, String.valueOf(pid));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.outputTo(System.out);
output.shouldHaveExitValue(0);
return output;
} catch (IOException e) {
throw new RuntimeException("Launching jstack failed", e);
}
}
}

View File

@@ -38,7 +38,7 @@ import java.util.Objects;
public class JBRApiTest {
public static void main(String[] args) throws Exception {
if (!JBR.getApiVersion().matches("\\w+\\.\\d+\\.\\d+\\.\\d+")) throw new Error("Invalid JBR API version: " + JBR.getApiVersion());
if (!JBR.getApiVersion().matches("\\w+\\.\\d+\\.\\d+\\.\\d+")) throw new Error("Invalid JBR API version");
if (!JBR.isAvailable()) throw new Error("JBR API is not available");
checkMetadata();
testServices();

View File

@@ -1,59 +0,0 @@
/*
* Copyright 2023 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @test
* @summary Verifies that jstack includes whatever the supplier
* provided to Jstack.includeInfoFrom() returns.
* @library /test/lib
* @run shell build.sh
* @run main JstackTest
*/
import com.jetbrains.JBR;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.Platform;
import java.io.IOException;
public class JstackTest {
final static String MAGIC_STRING = "Additional info:\nthis appears in jstack's output";
public static void main(String[] args) {
JBR.getJstack().includeInfoFrom( () -> MAGIC_STRING );
long pid = ProcessHandle.current().pid();
final OutputAnalyzer jstackOutput = runJstack(pid);
jstackOutput
.shouldHaveExitValue(0)
.shouldContain(MAGIC_STRING);
}
static OutputAnalyzer runJstack(long pid) {
try {
final String JSTACK = JDKToolFinder.getTestJDKTool("jstack");
final ProcessBuilder pb = new ProcessBuilder(JSTACK, String.valueOf(pid));
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.outputTo(System.out);
output.shouldHaveExitValue(0);
return output;
} catch (IOException e) {
throw new RuntimeException("Launching jstack failed", e);
}
}
}

View File

@@ -155,8 +155,8 @@ public class HitTestNonClientArea {
robot.delay(300);
robot.mouseMove(initialX, initialY);
}
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
robot.waitForIdle();
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
Point newLocation = window.getLocationOnScreen();
passed = initialLocation.x < newLocation.x && initialLocation.y < newLocation.y;

View File

@@ -132,7 +132,7 @@ public class MaximizeWindowTest {
private static void doubleClickToTitleBar(Window window, WindowDecorations.CustomTitleBar titleBar) throws AWTException {
int leftX = window.getInsets().left + (int) titleBar.getLeftInset();
int rightX = window.getBounds().width - window.getInsets().right - (int) titleBar.getRightInset();
int x = window.getLocationOnScreen().x + leftX + (rightX - leftX) / 2;
int x = window.getLocationOnScreen().x + (rightX - leftX) / 2;
int topY = window.getInsets().top;
int bottomY = (int) TestUtils.TITLE_BAR_HEIGHT;
int y = window.getLocationOnScreen().y + (bottomY - topY) / 2;

View File

@@ -1,86 +0,0 @@
/*
* Copyright 2023 JetBrains s.r.o.
* 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 javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* @test
* @summary Regression test for JBR-5458 Exception at dialog closing
* @key headful
*/
public class UndecoratedDialogInTransientsChain {
private static Robot robot;
private static JFrame frame;
public static void main(String[] args) throws Exception {
robot = new Robot();
try {
SwingUtilities.invokeLater(UndecoratedDialogInTransientsChain::initUI);
robot.delay(1000);
clickAtCenter();
robot.delay(2000);
clickAtCenter();
robot.delay(1000);
if (frame.isDisplayable()) {
throw new IllegalStateException("Frame should have been closed");
}
} finally {
SwingUtilities.invokeAndWait(UndecoratedDialogInTransientsChain::disposeUI);
}
}
private static void initUI() {
frame = new JFrame("UndecoratedDialogInTransientsChain");
JButton b1 = new JButton("Close");
b1.addActionListener(e -> frame.dispose());
frame.add(b1);
frame.setBounds(200, 200, 400, 400);
frame.setVisible(true);
JDialog d = new JDialog(frame, "Dialog", true);
JButton b2 = new JButton("Close");
b2.addActionListener(e -> {
JDialog d2 = new JDialog(frame);
d2.setUndecorated(true);
d2.setVisible(true);
robot.delay(1000); // wait for the window to be realized natively
d2.dispose();
d.dispose();
});
d.add(b2);
d.setBounds(300, 300, 200, 200);
d.setVisible(true);
}
private static void disposeUI() {
if (frame != null) frame.dispose();
}
private static void clickAtCenter() {
robot.mouseMove(400, 400);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}
}

View File

@@ -1,481 +0,0 @@
/*
* Copyright (c) 2008, 2023, 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.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.nio.file.spi.FileSystemProvider;
import java.nio.channels.FileChannel;
import java.nio.channels.SeekableByteChannel;
import java.net.URI;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class TestProvider extends FileSystemProvider {
private final FileSystemProvider defaultProvider;
private final TestFileSystem theFileSystem;
public TestProvider(FileSystemProvider defaultProvider) {
this.defaultProvider = defaultProvider;
FileSystem fs = defaultProvider.getFileSystem(URI.create("file:/"));
this.theFileSystem = new TestFileSystem(fs, this);
}
FileSystemProvider defaultProvider() {
return defaultProvider;
}
@Override
public String getScheme() {
return "file";
}
@Override
public FileSystem newFileSystem(URI uri, Map<String,?> env) throws IOException {
return defaultProvider.newFileSystem(uri, env);
}
@Override
public FileSystem getFileSystem(URI uri) {
return theFileSystem;
}
@Override
public Path getPath(URI uri) {
Path path = defaultProvider.getPath(uri);
return theFileSystem.wrap(path);
}
@Override
public void setAttribute(Path file, String attribute, Object value,
LinkOption... options)
throws IOException
{
throw new RuntimeException("not implemented");
}
@Override
public Map<String,Object> readAttributes(Path file, String attributes,
LinkOption... options)
throws IOException
{
Path delegate = theFileSystem.unwrap(file);
return defaultProvider.readAttributes(delegate, attributes, options);
}
@Override
public <A extends BasicFileAttributes> A readAttributes(Path file,
Class<A> type,
LinkOption... options)
throws IOException
{
Path delegate = theFileSystem.unwrap(file);
return defaultProvider.readAttributes(delegate, type, options);
}
@Override
public <V extends FileAttributeView> V getFileAttributeView(Path file,
Class<V> type,
LinkOption... options)
{
Path delegate = theFileSystem.unwrap(file);
return defaultProvider.getFileAttributeView(delegate, type, options);
}
@Override
public void delete(Path file) throws IOException {
Path delegate = theFileSystem.unwrap(file);
defaultProvider.delete(delegate);
}
@Override
public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
throws IOException
{
throw new RuntimeException("not implemented");
}
@Override
public void createLink(Path link, Path existing) throws IOException {
throw new RuntimeException("not implemented");
}
@Override
public Path readSymbolicLink(Path link) throws IOException {
Path delegate = theFileSystem.unwrap(link);
Path target = defaultProvider.readSymbolicLink(delegate);
return theFileSystem.wrap(target);
}
@Override
public void copy(Path source, Path target, CopyOption... options)
throws IOException
{
throw new RuntimeException("not implemented");
}
@Override
public void move(Path source, Path target, CopyOption... options)
throws IOException
{
throw new RuntimeException("not implemented");
}
@Override
public DirectoryStream<Path> newDirectoryStream(Path dir,
DirectoryStream.Filter<? super Path> filter)
throws IOException
{
throw new RuntimeException("not implemented");
}
@Override
public void createDirectory(Path dir, FileAttribute<?>... attrs)
throws IOException
{
Path delegate = theFileSystem.unwrap(dir);
defaultProvider.createDirectory(delegate, attrs);
}
@Override
public SeekableByteChannel newByteChannel(Path file,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
throws IOException
{
Path delegate = theFileSystem.unwrap(file);
return defaultProvider.newByteChannel(delegate, options, attrs);
}
@Override
public FileChannel newFileChannel(Path file,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
throws IOException
{
Path delegate = theFileSystem.unwrap(file);
return defaultProvider.newFileChannel(delegate, options, attrs);
}
@Override
public boolean isHidden(Path file) throws IOException {
throw new ReadOnlyFileSystemException();
}
@Override
public FileStore getFileStore(Path file) throws IOException {
throw new RuntimeException("not implemented");
}
@Override
public boolean isSameFile(Path file, Path other) throws IOException {
throw new RuntimeException("not implemented");
}
@Override
public void checkAccess(Path file, AccessMode... modes)
throws IOException
{
throw new RuntimeException("not implemented");
}
static class TestFileSystem extends FileSystem {
private final FileSystem delegate;
private final TestProvider provider;
TestFileSystem(FileSystem delegate, TestProvider provider) {
this.delegate = delegate;
this.provider = provider;
}
Path wrap(Path path) {
return (path != null) ? new TestPath(this, path) : null;
}
Path unwrap(Path wrapper) {
if (wrapper == null)
throw new NullPointerException();
if (!(wrapper instanceof TestPath))
throw new ProviderMismatchException();
return ((TestPath)wrapper).unwrap();
}
@Override
public FileSystemProvider provider() {
return provider;
}
@Override
public void close() throws IOException {
throw new RuntimeException("not implemented");
}
@Override
public boolean isOpen() {
return true;
}
@Override
public boolean isReadOnly() {
return false;
}
@Override
public String getSeparator() {
return delegate.getSeparator();
}
@Override
public Iterable<Path> getRootDirectories() {
throw new RuntimeException("not implemented");
}
@Override
public Iterable<FileStore> getFileStores() {
throw new RuntimeException("not implemented");
}
@Override
public Set<String> supportedFileAttributeViews() {
return delegate.supportedFileAttributeViews();
}
@Override
public Path getPath(String first, String... more) {
Path path = delegate.getPath(first, more);
return wrap(path);
}
@Override
public PathMatcher getPathMatcher(String syntaxAndPattern) {
return delegate.getPathMatcher(syntaxAndPattern);
}
@Override
public UserPrincipalLookupService getUserPrincipalLookupService() {
return delegate.getUserPrincipalLookupService();
}
@Override
public WatchService newWatchService() throws IOException {
throw new UnsupportedOperationException();
}
}
static class TestPath implements Path {
private final TestFileSystem fs;
private final Path delegate;
TestPath(TestFileSystem fs, Path delegate) {
this.fs = fs;
this.delegate = delegate;
}
Path unwrap() {
return delegate;
}
@Override
public FileSystem getFileSystem() {
return fs;
}
@Override
public boolean isAbsolute() {
return delegate.isAbsolute();
}
@Override
public Path getRoot() {
return fs.wrap(delegate.getRoot());
}
@Override
public Path getParent() {
return fs.wrap(delegate.getParent());
}
@Override
public int getNameCount() {
return delegate.getNameCount();
}
@Override
public Path getFileName() {
return fs.wrap(delegate.getFileName());
}
@Override
public Path getName(int index) {
return fs.wrap(delegate.getName(index));
}
@Override
public Path subpath(int beginIndex, int endIndex) {
return fs.wrap(delegate.subpath(beginIndex, endIndex));
}
@Override
public boolean startsWith(Path other) {
return delegate.startsWith(fs.unwrap(other));
}
@Override
public boolean startsWith(String other) {
return delegate.startsWith(other);
}
@Override
public boolean endsWith(Path other) {
return delegate.endsWith(fs.unwrap(other));
}
@Override
public boolean endsWith(String other) {
return delegate.endsWith(other);
}
@Override
public Path normalize() {
return fs.wrap(delegate.normalize());
}
@Override
public Path resolve(Path other) {
return fs.wrap(delegate.resolve(fs.unwrap(other)));
}
@Override
public Path resolve(String other) {
return fs.wrap(delegate.resolve(other));
}
@Override
public Path resolveSibling(Path other) {
return fs.wrap(delegate.resolveSibling(fs.unwrap(other)));
}
@Override
public Path resolveSibling(String other) {
return fs.wrap(delegate.resolveSibling(other));
}
@Override
public Path relativize(Path other) {
return fs.wrap(delegate.relativize(fs.unwrap(other)));
}
@Override
public boolean equals(Object other) {
if (!(other instanceof TestPath))
return false;
return delegate.equals(fs.unwrap((TestPath) other));
}
@Override
public int hashCode() {
return delegate.hashCode();
}
@Override
public String toString() {
return delegate.toString();
}
@Override
public URI toUri() {
String ssp = delegate.toUri().getSchemeSpecificPart();
return URI.create(fs.provider().getScheme() + ":" + ssp);
}
@Override
public Path toAbsolutePath() {
return fs.wrap(delegate.toAbsolutePath());
}
@Override
public Path toRealPath(LinkOption... options) throws IOException {
return fs.wrap(delegate.toRealPath(options));
}
@Override
public File toFile() {
return new File(toString());
}
@Override
public Iterator<Path> iterator() {
final Iterator<Path> itr = delegate.iterator();
return new Iterator<Path>() {
@Override
public boolean hasNext() {
return itr.hasNext();
}
@Override
public Path next() {
return fs.wrap(itr.next());
}
@Override
public void remove() {
itr.remove();
}
};
}
@Override
public int compareTo(Path other) {
return delegate.compareTo(fs.unwrap(other));
}
@Override
public WatchKey register(WatchService watcher,
WatchEvent.Kind<?>[] events,
WatchEvent.Modifier... modifiers)
{
throw new UnsupportedOperationException();
}
@Override
public WatchKey register(WatchService watcher,
WatchEvent.Kind<?>... events)
{
throw new UnsupportedOperationException();
}
}
private static final byte[] EMPTY_PATH = new byte[0];
public byte[] getSunPathForSocketFile(Path path) {
if (path.getNameCount() == 0) {
return EMPTY_PATH;
}
return path.toString().getBytes(StandardCharsets.UTF_8);
}
}

View File

@@ -1,64 +0,0 @@
/*
* Copyright (c) 2023, JetBrains s.r.o.
* 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
* @summary Verifies that Unix domain sockets work with a non-default
* file system provider that implements
* @library /test/lib
* @build TestProvider
* @run main/othervm -Djava.nio.file.spi.DefaultFileSystemProvider=TestProvider UnixSocketWithCustomProvider
*/
import java.io.IOException;
import java.net.StandardProtocolFamily;
import java.net.UnixDomainSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.spi.FileSystemProvider;
public class UnixSocketWithCustomProvider {
public static void main(String[] args) {
FileSystemProvider provider = FileSystems.getDefault().provider();
if (!provider.getClass().getName().equals("TestProvider")) {
throw new Error("Test must be run with non-default file system");
}
Path socketPath = Path.of("socket");
UnixDomainSocketAddress socketAddress = UnixDomainSocketAddress.of(socketPath);
try (ServerSocketChannel serverCh = ServerSocketChannel.open(StandardProtocolFamily.UNIX)) {
serverCh.bind(socketAddress);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
Files.deleteIfExists(socketPath);
} catch (IOException ignore) {
}
}
}
}

View File

@@ -12,7 +12,6 @@ import java.awt.event.MouseListener;
/*
* @test
* @key headful
* @requires (os.family == "windows" | os.family == "mac")
* @summary JBR-4875 The test drag&drops a frame which contains an instance of JComboBox and checks that ComboBoxPopup
* does not become detached from its' control. The test performs checking for both cases when
* <code>apple.awt.transparentTitleBar</code> is not set and it is set to <code>true</code>.

View File

@@ -1,135 +0,0 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.PriorityQueue;
/**
* @test
* @summary Measure typing latency in JTextArea with various conditions (count of already added symbols)
* The test adds initial size of text in the JTextArea by specified <code>jtreg.test.initialSize</code> property.
* After that robot types predefined amount of english symbols in the beginning of the text in JTextArea.
* Amount of symbols is defined in <code>jtreg.test.sampleSize</code> property.
* @run main/othervm -Djtreg.test.initialSize=0 -Djtreg.test.sampleSize=100 TypingLatencyTest
* @run main/othervm -Djtreg.test.initialSize=1000 -Djtreg.test.sampleSize=50 TypingLatencyTest
* @run main/othervm -Djtreg.test.initialSize=5000 -Djtreg.test.sampleSize=50 TypingLatencyTest
* @run main/othervm -Djtreg.test.initialSize=10000 -Djtreg.test.sampleSize=50 TypingLatencyTest
* @run main/othervm -Djtreg.test.initialSize=30000 -Djtreg.test.sampleSize=50 TypingLatencyTest
*/
public class TypingLatencyTest {
private static final DecimalFormat df = new DecimalFormat("0.00");
private static JFrame window;
private static JTextArea textArea;
private static Robot robot;
public static void main(String... args) throws Exception {
int initialSize = 0;
String initialSizeValue = System.getProperty("jtreg.test.initialSize");
if (initialSizeValue != null && !initialSizeValue.isBlank()) {
initialSize = Integer.parseInt(initialSizeValue);
}
int sampleSize = 0;
String sampleSizeValue = System.getProperty("jtreg.test.sampleSize");
if (sampleSizeValue != null && !sampleSizeValue.isBlank()) {
sampleSize = Integer.parseInt(sampleSizeValue);
}
System.out.println("Run test with: initialSize = " + initialSize + " sampleSize = " + sampleSize);
try {
robot = new Robot();
SwingUtilities.invokeAndWait(TypingLatencyTest::createUI);
robot.waitForIdle();
boolean passed = typeAndMeasureLatency(initialSize, sampleSize);
if (!passed) {
throw new RuntimeException("TEST FAILED: Typing latency is too high.");
}
} finally {
SwingUtilities.invokeAndWait(() -> {
if (window != null) {
window.dispose();
}
});
}
}
private static void createUI() {
window = new JFrame();
window.setBounds(0, 0, 800, 600);
JPanel panel = new JPanel();
textArea = new JTextArea();
textArea.setColumns(60);
textArea.setLineWrap(true);
textArea.setRows(30);
panel.add(textArea);
window.setContentPane(panel);
window.setVisible(true);
}
private static boolean typeAndMeasureLatency(int initialTextSize, int sampleSize) {
window.requestFocus();
textArea.requestFocus();
robot.waitForIdle();
textArea.append(generateText(initialTextSize));
long before, after, diff;
int code;
long min = Long.MAX_VALUE;
long max = Long.MIN_VALUE;
double average = 0;
PriorityQueue<Long> small = new PriorityQueue<>(Collections.reverseOrder());
PriorityQueue<Long> large = new PriorityQueue<>();
boolean even = true;
for (int i = 0; i < sampleSize; i++) {
code = KeyEvent.getExtendedKeyCodeForChar(97 + Math.round(25 * (float) Math.random()));
before = System.nanoTime();
robot.keyPress(code);
robot.keyRelease(code);
robot.waitForIdle();
after = System.nanoTime();
diff = after - before;
if (even) {
large.offer(diff);
small.offer(large.poll());
} else {
small.offer(diff);
large.offer(small.poll());
}
even = !even;
min = Math.min(min, diff);
max = Math.max(max, diff);
average = ((average * i) + diff) / (i + 1);
}
double median = even ? (small.peek() + large.peek()) / 2.0 : small.peek();
System.out.println("Symbols added: " + sampleSize);
System.out.println("min (ms): " + df.format((min / 1_000_000.0)));
System.out.println("max (ms): " + df.format((max / 1_000_000.0)));
System.out.println("average (ms): " + df.format((average / 1_000_000.0)));
System.out.println("median (ms): " + df.format((median / 1_000_000.0)));
return median < 500_000_000;
}
private static String generateText(int size) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; i++) {
sb.append((char) (97 + Math.round(25 * (float) Math.random())));
}
return sb.toString();
}
}

View File

@@ -133,7 +133,7 @@ java/awt/dnd/DropTargetEnterExitTest/ExtraDragEnterTest.java 8029680 generic-all
java/awt/dnd/URIListBetweenJVMsTest/URIListBetweenJVMsTest.java 8171510,JBR-881 macosx-all,linux-all
javax/swing/dnd/7171812/bug7171812.java 8041447,8253184 macosx-all,windows-all
java/awt/Focus/ChoiceFocus/ChoiceFocus.java 8169103 windows-all,macosx-all
java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618 macosx-all
java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618,JBR-814 macosx-all,linux-all
java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java 6986252,JBR-5178 windows-all
java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java 8194753 linux-all,macosx-all
java/awt/Focus/NoAutotransferToDisabledCompTest/NoAutotransferToDisabledCompTest.java 7152980 macosx-all
@@ -266,6 +266,7 @@ java/awt/image/multiresolution/MultiResolutionJOptionPaneIconTest.java 8253184 w
java/awt/print/Headless/HeadlessPrinterJob.java 8196088 windows-all
sun/awt/datatransfer/SuplementaryCharactersTransferTest.java 8011371 generic-all
sun/awt/shell/ShellFolderMemoryLeak.java 8197794 windows-all
sun/java2d/DirectX/OpaqueImageToSurfaceBlitTest/OpaqueImageToSurfaceBlitTest.java JBR-5393 windows-aarch64
sun/java2d/DirectX/OverriddenInsetsTest/OverriddenInsetsTest.java 8196102 generic-all
sun/java2d/DirectX/RenderingToCachedGraphicsTest/RenderingToCachedGraphicsTest.java 8196180,8252812 windows-all,macosx-all,linux-all
java/awt/Graphics2D/CopyAreaOOB.java JBR-5354 macosx-all,windows-all
@@ -845,6 +846,7 @@ javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all
javax/swing/JEditorPane/8195095/ImageViewTest.java 8253184 windows-all
javax/swing/JRadioButton/4314194/bug4314194.java 8298153 linux-all
javax/swing/JRootPane/4670486/bug4670486.java 8042381,8197552 macosx-all,windows-all
javax/swing/JRootPane/DefaultButtonTest.java 8285635 windows-all,linux-all
javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java JBR-5210 windows-all
javax/swing/text/html/StyleSheet/bug4936917.java JBR-899 windows-all
javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java 8253184 windows-all
@@ -1067,6 +1069,7 @@ java/awt/Frame/LayoutOnMaximizeTest/LayoutOnMaximizeTest.java JBR-4880 windows-a
java/awt/Frame/MiscUndecorated/UndecoratedInitiallyIconified.java JBR-4880 windows-all
java/awt/FullScreen/FullscreenWindowProps/FullscreenWindowProps.java JBR-4275,JBR-4880 linux-all,windows-all
java/awt/FullScreen/SetFSWindow/FSFrame.java 8253184 windows-all
java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java JBR-4880 windows-all
java/awt/grab/GrabOnUnfocusableToplevel/GrabOnUnfocusableToplevel.java JBR-4880 windows-all
java/awt/grab/MenuDragEvents/MenuDragEvents.java JBR-4880 windows-all
java/awt/image/multiresolution/MenuMultiresolutionIconTest.java JBR-4880,8253184 windows-all

View File

@@ -1,6 +1,6 @@
# cannotbe run against jbr which does not contain some jbrsdk's utilities required for test executions
javax/imageio/stream/StreamCloserLeak/run_test.sh NO_BUG generic_all
javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh NO_BUG generic_all
javax/imageio/stream/StreamCloserLeak/run_test.sh nobug generic-all
javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh nobug generic-all
#
# intermittently failed, they were muted in regular runs with the option "unmute manually"