From e98645932d0d7765988f21b09d6d121202281e02 Mon Sep 17 00:00:00 2001 From: Ambarish Rapte Date: Tue, 11 Feb 2020 10:17:09 +0000 Subject: [PATCH 1/4] 8227619: Potential memory leak in javafx.scene.control.ListView Reviewed-by: kcr, aghaisas --- .../SelectedItemsReadOnlyObservableList.java | 9 ++++--- .../javafx/scene/control/ListViewTest.java | 27 ++++++++++++++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/SelectedItemsReadOnlyObservableList.java b/modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/SelectedItemsReadOnlyObservableList.java index 775cdd23bb3..46578e53e24 100644 --- a/modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/SelectedItemsReadOnlyObservableList.java +++ b/modules/javafx.controls/src/main/java/com/sun/javafx/scene/control/SelectedItemsReadOnlyObservableList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2020, 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 @@ -27,6 +27,7 @@ import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import javafx.collections.ObservableListBase; +import javafx.collections.WeakListChangeListener; import java.lang.ref.WeakReference; import java.util.ArrayList; @@ -46,6 +47,8 @@ public abstract class SelectedItemsReadOnlyObservableList extends ObservableL itemsListChanged = true; itemsListChange = c; }; + private final WeakListChangeListener weakItemsListListener = + new WeakListChangeListener(itemsListListener); private final Supplier modelSizeSupplier; @@ -120,11 +123,11 @@ public int size() { // Used by ListView and TableView to allow for improved handling. public void setItemsList(ObservableList itemsList) { if (this.itemsList != null) { - this.itemsList.removeListener(itemsListListener); + this.itemsList.removeListener(weakItemsListListener); } this.itemsList = itemsList; if (itemsList != null) { - itemsList.addListener(itemsListListener); + itemsList.addListener(weakItemsListListener); } } diff --git a/modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java b/modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java index 3a7c935de90..41cab9af1e0 100644 --- a/modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java +++ b/modules/javafx.controls/src/test/java/test/javafx/scene/control/ListViewTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, 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 @@ -28,6 +28,7 @@ import com.sun.javafx.scene.control.VirtualScrollBar; import com.sun.javafx.scene.control.behavior.ListCellBehavior; import com.sun.javafx.tk.Toolkit; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -1975,4 +1976,28 @@ public void testEventIndicesOnSelectRange() { assertEquals("List item at index 1 should be selected", 1, (int) sm.getSelectedIndices().get(0)); assertEquals("List item at index 2 should be selected", 2, (int) sm.getSelectedIndices().get(1)); } + + @Test + public void testListViewLeak() { + ObservableList items = FXCollections.observableArrayList(); + WeakReference> listViewRef = new WeakReference<>(new ListView<>(items)); + attemptGC(listViewRef, 10); + assertNull("ListView has a leak.", listViewRef.get()); + } + + private void attemptGC(WeakReference> weakRef, int n) { + for (int i = 0; i < n; i++) { + System.gc(); + System.runFinalization(); + + if (weakRef.get() == null) { + break; + } + try { + Thread.sleep(50); + } catch (InterruptedException e) { + fail("InterruptedException occurred during Thread.sleep()"); + } + } + } } From b5e65ecc68ca550571e6b59911089c79855df6e3 Mon Sep 17 00:00:00 2001 From: Kevin Rushforth Date: Tue, 18 Feb 2020 14:41:22 +0000 Subject: [PATCH 2/4] 8238434: Ensemble: Update version of Lucene to 7.7.2 Reviewed-by: aghaisas --- apps/samples/.classpath | 6 +++--- apps/samples/Ensemble8/UPDATING-lucene.txt | 4 ++-- apps/samples/Ensemble8/build.gradle | 6 +++--- apps/samples/Ensemble8/legal/lucene.md | 2 +- apps/samples/Ensemble8/nbproject/project.properties | 2 +- build.gradle | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/samples/.classpath b/apps/samples/.classpath index e49553418f3..97be698c806 100644 --- a/apps/samples/.classpath +++ b/apps/samples/.classpath @@ -12,9 +12,9 @@ - - - + + + diff --git a/apps/samples/Ensemble8/UPDATING-lucene.txt b/apps/samples/Ensemble8/UPDATING-lucene.txt index b8058d9eefb..cac11016285 100644 --- a/apps/samples/Ensemble8/UPDATING-lucene.txt +++ b/apps/samples/Ensemble8/UPDATING-lucene.txt @@ -13,10 +13,10 @@ To update to a new version of Lucene: gradle clean gradle sdk apps -NOTE: if upgrading to a new major version there are usually compilation errors that need to be fixed. +NOTE: if upgrading to a new major version there are usually compilation or runtime errors that need to be fixed. -3. Regenerate the index files: +3. Regenerate the index files. This step can be skipped if only the "bugfix" number (the third digit) of the release changes: $ cd apps/samples/Ensemble8 $ rm -rf src/generated/resources/ensemble/search/index diff --git a/apps/samples/Ensemble8/build.gradle b/apps/samples/Ensemble8/build.gradle index cb5223f69db..95514b8bd39 100644 --- a/apps/samples/Ensemble8/build.gradle +++ b/apps/samples/Ensemble8/build.gradle @@ -4,9 +4,9 @@ apply plugin:'application' def mainClassName = "ensemble.EnsembleApp" def FileCollection apachecp = files( - "./lib/lucene-core-7.7.1.jar", - "./lib/lucene-grouping-7.7.1.jar", - "./lib/lucene-queryparser-7.7.1.jar") + "./lib/lucene-core-7.7.2.jar", + "./lib/lucene-grouping-7.7.2.jar", + "./lib/lucene-queryparser-7.7.2.jar") sourceSets { main { diff --git a/apps/samples/Ensemble8/legal/lucene.md b/apps/samples/Ensemble8/legal/lucene.md index a6693e4ea01..a0526414e2f 100644 --- a/apps/samples/Ensemble8/legal/lucene.md +++ b/apps/samples/Ensemble8/legal/lucene.md @@ -1,4 +1,4 @@ -## Apache Lucene v7.7.1 +## Apache Lucene v7.7.2 ### Apache Lucene Notice ``` diff --git a/apps/samples/Ensemble8/nbproject/project.properties b/apps/samples/Ensemble8/nbproject/project.properties index 809aaa323db..8e212f81069 100644 --- a/apps/samples/Ensemble8/nbproject/project.properties +++ b/apps/samples/Ensemble8/nbproject/project.properties @@ -31,7 +31,7 @@ dist.jar=${dist.dir}/Ensemble8.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= -lucene.version=7.7.1 +lucene.version=7.7.2 file.reference.lucene-core.jar=lib/lucene-core-${lucene.version}.jar file.reference.lucene-grouping.jar=lib/lucene-grouping-${lucene.version}.jar file.reference.lucene-queryparser.jar=lib/lucene-queryparser-${lucene.version}.jar diff --git a/build.gradle b/build.gradle index 310d9bfefad..99ce4e76073 100644 --- a/build.gradle +++ b/build.gradle @@ -4148,7 +4148,7 @@ project(":apps") { // The apps build is Ant based, we will exec ant from gradle. // Download the Lucene libraries needed for the Ensemble8 app - def luceneVersion = "7.7.1" + def luceneVersion = "7.7.2" getConfigurations().create("lucene"); dependencies { lucene group: "org.apache.lucene", name: "lucene-core", version: luceneVersion From 35a01cafb6ca0327819d8076c281545c421484bd Mon Sep 17 00:00:00 2001 From: Nir Lisker Date: Wed, 19 Feb 2020 14:35:56 +0000 Subject: [PATCH 3/4] 8228867: Fix mistakes in FX API docs Reviewed-by: jvos, kcr --- .../src/main/java/javafx/collections/FXCollections.java | 4 ++-- .../src/main/java/javafx/animation/Animation.java | 4 ++-- .../src/main/java/javafx/application/Platform.java | 4 ++-- modules/javafx.graphics/src/main/java/javafx/scene/Node.java | 4 ++-- modules/javafx.graphics/src/main/native-glass/win/OleUtils.h | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/javafx.base/src/main/java/javafx/collections/FXCollections.java b/modules/javafx.base/src/main/java/javafx/collections/FXCollections.java index 152f354b9ac..039b8bb12bb 100644 --- a/modules/javafx.base/src/main/java/javafx/collections/FXCollections.java +++ b/modules/javafx.base/src/main/java/javafx/collections/FXCollections.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2020, 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 @@ -576,7 +576,7 @@ public static boolean replaceAll(ObservableList list, T oldVal, T newVal) } /** - * Reverse the order in the list + * Reverses the order in the list. * Fires only one change notification on the list. * @param list the list to be reversed * @see Collections#reverse(java.util.List) diff --git a/modules/javafx.graphics/src/main/java/javafx/animation/Animation.java b/modules/javafx.graphics/src/main/java/javafx/animation/Animation.java index 309f3306985..c2463425a14 100644 --- a/modules/javafx.graphics/src/main/java/javafx/animation/Animation.java +++ b/modules/javafx.graphics/src/main/java/javafx/animation/Animation.java @@ -417,7 +417,7 @@ public final ReadOnlyObjectProperty cycleDurationProperty() { /** * Read-only variable to indicate the total duration of this - * {@code Animation}, including repeats. A {@code Animation} with a {@code cycleCount} + * {@code Animation}, including repeats. An {@code Animation} with a {@code cycleCount} * of {@code Animation.INDEFINITE} will have a {@code totalDuration} of * {@code Duration.INDEFINITE}. * @@ -961,7 +961,7 @@ public void playFromStart() { /** * Stops the animation and resets the play head to its initial position. If - * the animation is not currently running, this method has no effect. + * the animation is already stopped, this method has no effect. *

* Note:

    *
  • {@code stop()} is an asynchronous call, the {@code Animation} may not stop diff --git a/modules/javafx.graphics/src/main/java/javafx/application/Platform.java b/modules/javafx.graphics/src/main/java/javafx/application/Platform.java index 4d01d386c1d..579bb39e5f8 100644 --- a/modules/javafx.graphics/src/main/java/javafx/application/Platform.java +++ b/modules/javafx.graphics/src/main/java/javafx/application/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2020, 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 @@ -175,7 +175,7 @@ public static void requestNextPulse() { /** * Returns true if the calling thread is the JavaFX Application Thread. - * Use this call the ensure that a given task is being executed + * Use this call to ensure that a given task is being executed * (or not being executed) on the JavaFX Application Thread. * * @return true if running on the JavaFX Application Thread diff --git a/modules/javafx.graphics/src/main/java/javafx/scene/Node.java b/modules/javafx.graphics/src/main/java/javafx/scene/Node.java index 8cfe6ce706f..0b1e0c2ba0b 100644 --- a/modules/javafx.graphics/src/main/java/javafx/scene/Node.java +++ b/modules/javafx.graphics/src/main/java/javafx/scene/Node.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2020, 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 @@ -1566,7 +1566,7 @@ public final Node getClip() { } /** - * Specifies a {@code Node} to use to define the the clipping shape for this + * Specifies a {@code Node} to use to define the clipping shape for this * Node. This clipping Node is not a child of this {@code Node} in the scene * graph sense. Rather, it is used to define the clip for this {@code Node}. *

    diff --git a/modules/javafx.graphics/src/main/native-glass/win/OleUtils.h b/modules/javafx.graphics/src/main/native-glass/win/OleUtils.h index 3f29a4623bb..b9f4de4140d 100644 --- a/modules/javafx.graphics/src/main/native-glass/win/OleUtils.h +++ b/modules/javafx.graphics/src/main/native-glass/win/OleUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2020, 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 @@ -227,7 +227,7 @@ inline HRESULT checkJavaException(JNIEnv *env) s_jcidThrowable_getMessage )); if(jsMessage){ - STRACE1(_T("Java Messsge:%s"), (LPCWSTR)JString(env, jsMessage) ); + STRACE1(_T("Java Message:%s"), (LPCWSTR)JString(env, jsMessage) ); } env->ExceptionDescribe(); } From d8e7f850f6c046f827d0a89c5404e41edf705d7e Mon Sep 17 00:00:00 2001 From: Arun Joseph Date: Thu, 20 Feb 2020 05:33:04 +0000 Subject: [PATCH 4/4] 8239454: LLIntData : invalid opcode returned for 16 and 32 bit wide instructions Reviewed-by: ghb, kcr --- .../src/main/native/Source/JavaScriptCore/llint/LLIntData.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/javafx.web/src/main/native/Source/JavaScriptCore/llint/LLIntData.h b/modules/javafx.web/src/main/native/Source/JavaScriptCore/llint/LLIntData.h index 402f67c9b9d..844475fde7f 100644 --- a/modules/javafx.web/src/main/native/Source/JavaScriptCore/llint/LLIntData.h +++ b/modules/javafx.web/src/main/native/Source/JavaScriptCore/llint/LLIntData.h @@ -105,7 +105,7 @@ inline Opcode getOpcodeWide16(OpcodeID id) #if ENABLE(COMPUTED_GOTO_OPCODES) return g_opcodeMapWide16[id]; #else - return static_cast(id - numOpcodeIDs); + return static_cast(id + numOpcodeIDs); #endif } @@ -114,7 +114,7 @@ inline Opcode getOpcodeWide32(OpcodeID id) #if ENABLE(COMPUTED_GOTO_OPCODES) return g_opcodeMapWide32[id]; #else - return static_cast(id - numOpcodeIDs); + return static_cast(id + numOpcodeIDs*2); #endif }