Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperIRL committed Dec 29, 2020
2 parents 779ee11 + 881bceb commit 07c93fa
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 59 deletions.
14 changes: 4 additions & 10 deletions src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, 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
Expand Down Expand Up @@ -36,10 +36,10 @@ public final class JRSUIUtils {

static boolean isLeopard = isMacOSXLeopard();
static boolean isSnowLeopardOrBelow = isMacOSXSnowLeopardOrBelow();
static boolean isCatalinaOrAbove = isMacOSXCatalinaOrAbove();
static boolean isBigSurOrAbove = isMacOSXBigSurOrAbove();

static boolean isMacOSXCatalinaOrAbove() {
return currentMacOSXVersionMatchesGivenVersionRange(15, true, false, true);
public static boolean isMacOSXBigSurOrAbove() {
return currentMacOSXVersionMatchesGivenVersionRange(16, true, false, true);
}

static boolean isMacOSXLeopard() {
Expand Down Expand Up @@ -79,12 +79,6 @@ static boolean currentMacOSXVersionMatchesGivenVersionRange(
return false;
}

public static class TaskBar {
public static boolean isIconBadgeSupported() {
return !isCatalinaOrAbove;
}
}

public static class TabbedPane {
public static boolean useLegacyTabs() {
return isLeopard;
Expand Down
Expand Up @@ -496,4 +496,8 @@ public static Color getSelectionInactiveBackgroundColorUIResource() {
public static Color getSelectionInactiveForegroundColorUIResource() {
return new SystemColorProxy(LWCToolkit.getAppleColor(LWCToolkit.INACTIVE_SELECTION_FOREGROUND_COLOR));
}

public static Color getSelectedControlColorUIResource() {
return new SystemColorProxy(LWCToolkit.getAppleColor(LWCToolkit.SELECTED_CONTROL_TEXT_COLOR));
}
}
Expand Up @@ -328,6 +328,7 @@ public Object createValue(UIDefaults defaultsTable) {
final ColorUIResource selectedTabTitlePressedColor = new ColorUIResource(240, 240, 240);
final ColorUIResource selectedTabTitleDisabledColor = new ColorUIResource(new Color(1, 1, 1, 0.55f));
final ColorUIResource selectedTabTitleNormalColor = white;
final Color selectedControlTextColor = AquaImageFactory.getSelectedControlColorUIResource();
final ColorUIResource selectedTabTitleShadowDisabledColor = new ColorUIResource(new Color(0, 0, 0, 0.25f));
final ColorUIResource selectedTabTitleShadowNormalColor = mediumTranslucentBlack;
final ColorUIResource nonSelectedTabTitleNormalColor = black;
Expand Down Expand Up @@ -869,7 +870,7 @@ public Object createValue(UIDefaults defaultsTable) {
"TabbedPane.tabsOverlapBorder", Boolean.TRUE,
"TabbedPane.selectedTabTitlePressedColor", selectedTabTitlePressedColor,
"TabbedPane.selectedTabTitleDisabledColor", selectedTabTitleDisabledColor,
"TabbedPane.selectedTabTitleNormalColor", selectedTabTitleNormalColor,
"TabbedPane.selectedTabTitleNormalColor", JRSUIUtils.isMacOSXBigSurOrAbove() ? selectedControlTextColor : selectedTabTitleNormalColor,
"TabbedPane.selectedTabTitleShadowDisabledColor", selectedTabTitleShadowDisabledColor,
"TabbedPane.selectedTabTitleShadowNormalColor", selectedTabTitleShadowNormalColor,
"TabbedPane.nonSelectedTabTitleNormalColor", nonSelectedTabTitleNormalColor,
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, 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
Expand All @@ -25,14 +25,12 @@

package sun.lwawt.macosx;

import com.apple.eawt.Application;
import java.awt.Image;
import java.awt.PopupMenu;
import java.awt.Taskbar.Feature;
import java.awt.peer.TaskbarPeer;

import apple.laf.JRSUIUtils;
import com.apple.eawt.Application;

final public class CTaskbarPeer implements TaskbarPeer {

CTaskbarPeer() {}
Expand All @@ -42,7 +40,6 @@ public boolean isSupported(Feature feature) {
switch(feature) {
case ICON_BADGE_TEXT:
case ICON_BADGE_NUMBER:
return JRSUIUtils.TaskBar.isIconBadgeSupported();
case ICON_IMAGE:
case MENU:
case PROGRESS_VALUE:
Expand Down
Expand Up @@ -204,14 +204,16 @@ public LWCToolkit() {
/*
* System colors with default initial values, overwritten by toolkit if system values differ and are available.
*/
private static final int NUM_APPLE_COLORS = 3;
private static final int NUM_APPLE_COLORS = 4;
public static final int KEYBOARD_FOCUS_COLOR = 0;
public static final int INACTIVE_SELECTION_BACKGROUND_COLOR = 1;
public static final int INACTIVE_SELECTION_FOREGROUND_COLOR = 2;
public static final int SELECTED_CONTROL_TEXT_COLOR = 3;
private static int[] appleColors = {
0xFF808080, // keyboardFocusColor = Color.gray;
0xFFC0C0C0, // secondarySelectedControlColor
0xFF303030, // controlDarkShadowColor
0xFFFFFFFF, // controlTextColor
};

private native void loadNativeColors(final int[] systemColors, final int[] appleColors);
Expand Down
Expand Up @@ -120,6 +120,7 @@ + (void)reloadColors {
appleColors[sun_lwawt_macosx_LWCToolkit_KEYBOARD_FOCUS_COLOR] = [NSColor keyboardFocusIndicatorColor];
appleColors[sun_lwawt_macosx_LWCToolkit_INACTIVE_SELECTION_BACKGROUND_COLOR] = [NSColor secondarySelectedControlColor];
appleColors[sun_lwawt_macosx_LWCToolkit_INACTIVE_SELECTION_FOREGROUND_COLOR] = [NSColor controlDarkShadowColor];
appleColors[sun_lwawt_macosx_LWCToolkit_SELECTED_CONTROL_TEXT_COLOR] = [NSColor controlTextColor];

for (i = 0; i < sun_lwawt_macosx_LWCToolkit_NUM_APPLE_COLORS; i++) {
[appleColors[i] retain];
Expand Down
Expand Up @@ -1656,7 +1656,9 @@ public boolean isCastable(Type t, Type s, Warner warn) {
} else {
result = isCastable.visit(t,s);
}
if (result && (t.tsym.isSealed() || s.tsym.isSealed())) {
if (result && t.hasTag(CLASS) && t.tsym.kind.matches(Kinds.KindSelector.TYP)
&& s.hasTag(CLASS) && s.tsym.kind.matches(Kinds.KindSelector.TYP)
&& (t.tsym.isSealed() || s.tsym.isSealed())) {
return (t.isCompound() || s.isCompound()) ?
false :
!areDisjoint((ClassSymbol)t.tsym, (ClassSymbol)s.tsym);
Expand Down
Expand Up @@ -4,9 +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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* 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
Expand Down
4 changes: 2 additions & 2 deletions test/langtools/tools/javac/lint/JdkInternalAbuseOfVbc.out
@@ -1,6 +1,6 @@
SomeVbc.java:38:13: compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class
SomeVbc.java:15:13: compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class
- compiler.err.warnings.and.werror
SomeVbc.java:49:13: compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class
SomeVbc.java:26:13: compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class
JdkInternalAbuseOfVbc.java:17:13: compiler.warn.attempt.to.synchronize.on.instance.of.value.based.class
1 error
3 warnings
25 changes: 1 addition & 24 deletions test/langtools/tools/javac/lint/SomeVbc.java
@@ -1,27 +1,4 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* /nodynamiccopyright/ */

package java.lang;

Expand Down
Expand Up @@ -4,9 +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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* 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
Expand Down
4 changes: 1 addition & 3 deletions test/langtools/tools/javac/records/RecordMemberTests.java
Expand Up @@ -4,9 +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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* 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
Expand Down
4 changes: 1 addition & 3 deletions test/langtools/tools/javac/records/VarargsRecordsTest.java
Expand Up @@ -4,9 +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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* 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
Expand Down
Expand Up @@ -4,9 +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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* 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
Expand Down
73 changes: 73 additions & 0 deletions test/langtools/tools/javac/sealed/T8258662/T8258662.java
@@ -0,0 +1,73 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8258662
* @summary Types.isCastable crashes when involving sealed interface and type variable.
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* @build toolbox.ToolBox toolbox.JavacTask
* @run main T8258662
*/

import java.util.List;

import toolbox.ToolBox;
import toolbox.TestRunner;
import toolbox.JavacTask;

public class T8258662 extends TestRunner {
private ToolBox tb;

public T8258662() {
super(System.err);
tb = new ToolBox();
}

public static void main(String[] args) throws Exception {
T8258662 t = new T8258662();
t.runTests();
}

@Test
public void testSealedClassIsCastable() throws Exception {
String code = """
class Test8258662 {
sealed interface I<T> {
final class C implements I<Object> { }
}
static <T extends I<Object>> void f(T x) {
if (x instanceof I<Object>) { }
}
}""";
new JavacTask(tb)
.sources(code)
.classpath(".")
.options("--enable-preview", "-source", Integer.toString(Runtime.version().feature()))
.run()
.writeAll();
}

}

1 comment on commit 07c93fa

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.