Skip to content

Commit

Permalink
Automatic merge of master into concise-method-declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
duke committed Dec 31, 2020
2 parents 806e524 + f5ee356 commit cd1e10f
Show file tree
Hide file tree
Showing 349 changed files with 1,242 additions and 3,521 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
*/
package sun.security.provider.certpath;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.net.URL;
import java.net.HttpURLConnection;
import java.net.URLEncoder;
import java.security.cert.CertificateException;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertPathValidatorException.BasicReason;
import java.security.cert.CRLReason;
import java.security.cert.Extension;
import java.security.cert.TrustAnchor;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.Date;
import java.util.List;
Expand All @@ -46,6 +46,7 @@
import sun.security.action.GetIntegerAction;
import sun.security.util.Debug;
import sun.security.util.Event;
import sun.security.util.IOUtils;
import sun.security.validator.Validator;
import sun.security.x509.AccessDescription;
import sun.security.x509.AuthorityInfoAccessExtension;
Expand Down Expand Up @@ -224,71 +225,61 @@ public static byte[] getOCSPBytes(List<CertId> certIds, URI responderURI,
OCSPRequest request = new OCSPRequest(certIds, extensions);
byte[] bytes = request.encodeBytes();

InputStream in = null;
OutputStream out = null;
byte[] response = null;
if (debug != null) {
debug.println("connecting to OCSP service at: " + responderURI);
}
Event.report(Event.ReporterCategory.CRLCHECK, "event.ocsp.check",
responderURI.toString());

URL url;
HttpURLConnection con = null;
try {
URL url = responderURI.toURL();
if (debug != null) {
debug.println("connecting to OCSP service at: " + url);
String encodedGetReq = responderURI.toString() + "/" +
URLEncoder.encode(Base64.getEncoder().encodeToString(bytes),
"UTF-8");

if (encodedGetReq.length() <= 255) {
url = new URL(encodedGetReq);
con = (HttpURLConnection)url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("GET");
} else {
url = responderURI.toURL();
con = (HttpURLConnection)url.openConnection();
con.setConnectTimeout(CONNECT_TIMEOUT);
con.setReadTimeout(CONNECT_TIMEOUT);
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty
("Content-type", "application/ocsp-request");
con.setRequestProperty
("Content-length", String.valueOf(bytes.length));
OutputStream out = con.getOutputStream();
out.write(bytes);
out.flush();
}

Event.report(Event.ReporterCategory.CRLCHECK, "event.ocsp.check", url.toString());
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setConnectTimeout(CONNECT_TIMEOUT);
con.setReadTimeout(CONNECT_TIMEOUT);
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty
("Content-type", "application/ocsp-request");
con.setRequestProperty
("Content-length", String.valueOf(bytes.length));
out = con.getOutputStream();
out.write(bytes);
out.flush();
// Check the response
if (debug != null &&
con.getResponseCode() != HttpURLConnection.HTTP_OK) {
debug.println("Received HTTP error: " + con.getResponseCode()
+ " - " + con.getResponseMessage());
}
in = con.getInputStream();

int contentLength = con.getContentLength();
if (contentLength == -1) {
contentLength = Integer.MAX_VALUE;
}
response = new byte[contentLength > 2048 ? 2048 : contentLength];
int total = 0;
while (total < contentLength) {
int count = in.read(response, total, response.length - total);
if (count < 0)
break;

total += count;
if (total >= response.length && total < contentLength) {
response = Arrays.copyOf(response, total * 2);
}
}
response = Arrays.copyOf(response, total);

return IOUtils.readExactlyNBytes(con.getInputStream(),
contentLength);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ioe) {
throw ioe;
}
}
if (out != null) {
try {
out.close();
} catch (IOException ioe) {
throw ioe;
}
if (con != null) {
con.disconnect();
}
}
return response;
}

/**
Expand Down
14 changes: 4 additions & 10 deletions src/java.desktop/macosx/classes/apple/laf/JRSUIUtils.java
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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));
}
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -1816,18 +1816,22 @@ public void close() {
names.dispose();
names = null;

FatalError fatalError = null;
for (Closeable c: closeables) {
try {
c.close();
} catch (IOException e) {
// When javac uses JDK 7 as a baseline, this code would be
// better written to set any/all exceptions from all the
// Closeables as suppressed exceptions on the FatalError
// that is thrown.
JCDiagnostic msg = diagFactory.fragment(Fragments.FatalErrCantClose);
throw new FatalError(msg, e);
if (fatalError == null) {
JCDiagnostic msg = diagFactory.fragment(Fragments.FatalErrCantClose);
fatalError = new FatalError(msg, e);
} else {
fatalError.addSuppressed(e);
}
}
}
if (fatalError != null) {
throw fatalError;
}
closeables = List.nil();
}
}
Expand Down
Loading

0 comments on commit cd1e10f

Please sign in to comment.