提交 14947fe9 编写于 作者: A asaha

Merge

......@@ -72,8 +72,7 @@ class _AppDockIconHandler {
public void setDockIconImage(final Image image) {
try {
final CImage cImage = getCImageCreator().createFromImage(image);
final long nsImagePtr = getNSImagePtrFrom(cImage);
nativeSetDockIconImage(nsImagePtr);
cImage.execute(_AppDockIconHandler::nativeSetDockIconImage);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
......@@ -102,16 +101,4 @@ class _AppDockIconHandler {
throw new RuntimeException(e);
}
}
static long getNSImagePtrFrom(final CImage cImage) {
if (cImage == null) return 0;
try {
final Field cImagePtrField = CFRetainedResource.class.getDeclaredField("ptr");
cImagePtrField.setAccessible(true);
return cImagePtrField.getLong(cImage);
} catch (final Throwable e) {
throw new RuntimeException(e);
}
}
}
......@@ -108,7 +108,7 @@ public class CGLLayer extends CFRetainedResource {
OGLRenderQueue rq = OGLRenderQueue.getInstance();
rq.lock();
try {
validate(getPointer(), cglsd);
execute(ptr -> validate(ptr, cglsd));
} finally {
rq.unlock();
}
......@@ -124,7 +124,7 @@ public class CGLLayer extends CFRetainedResource {
private void setScale(final int _scale) {
if (scale != _scale) {
scale = _scale;
nativeSetScale(getPointer(), scale);
execute(ptr -> nativeSetScale(ptr, scale));
}
}
......@@ -138,7 +138,7 @@ public class CGLLayer extends CFRetainedResource {
OGLRenderQueue rq = OGLRenderQueue.getInstance();
rq.lock();
try {
blitTexture(getPointer());
execute(ptr -> blitTexture(ptr));
} finally {
rq.unlock();
}
......
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -25,6 +25,10 @@
package sun.lwawt.macosx;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Safely holds and disposes of native AppKit resources, using the
* correct AppKit threading and Objective-C GC semantics.
......@@ -36,6 +40,10 @@ public class CFRetainedResource {
// TODO this pointer should be private and accessed via CFNativeAction class
protected volatile long ptr;
private final ReadWriteLock lock = new ReentrantReadWriteLock();
private final Lock writeLock = lock.writeLock();
private final Lock readLock = lock.readLock();
/**
* @param ptr CFRetained native object pointer
* @param disposeOnAppKitThread is the object needs to be CFReleased on the main thread
......@@ -50,21 +58,31 @@ public class CFRetainedResource {
* @param ptr CFRetained native object pointer
*/
protected void setPtr(final long ptr) {
synchronized (this) {
if (this.ptr != 0) dispose();
writeLock.lock();
try {
if (this.ptr != 0) {
dispose();
}
this.ptr = ptr;
} finally {
writeLock.unlock();
}
}
/**
* Manually CFReleases the native resource
* Manually CFReleases the native resource.
*/
protected void dispose() {
long oldPtr = 0L;
synchronized (this) {
if (ptr == 0) return;
writeLock.lock();
try {
if (ptr == 0) {
return;
}
oldPtr = ptr;
ptr = 0;
} finally {
writeLock.unlock();
}
nativeCFRelease(oldPtr, disposeOnAppKitThread); // perform outside of the synchronized block
......@@ -109,9 +127,14 @@ public class CFRetainedResource {
*
* @param action The native operation
*/
public final synchronized void execute(final CFNativeAction action) {
if (ptr != 0) {
action.run(ptr);
public final void execute(final CFNativeAction action) {
readLock.lock();
try {
if (ptr != 0) {
action.run(ptr);
}
} finally {
readLock.unlock();
}
}
......@@ -127,9 +150,14 @@ public class CFRetainedResource {
* @return result of the native operation, usually the native pointer to
* some other data
*/
final synchronized long executeGet(final CFNativeActionGet action) {
if (ptr != 0) {
return action.run(ptr);
final long executeGet(final CFNativeActionGet action) {
readLock.lock();
try {
if (ptr != 0) {
return action.run(ptr);
}
} finally {
readLock.unlock();
}
return 0;
}
......
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -33,6 +33,7 @@ import java.util.Arrays;
import java.util.List;
import sun.awt.image.MultiResolutionImage;
import sun.awt.image.MultiResolutionCachedImage;
import java.util.concurrent.atomic.AtomicReference;
import sun.awt.image.SunWritableRaster;
......@@ -235,15 +236,26 @@ public class CImage extends CFRetainedResource {
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
if (ptr == 0) return null;
if (ptr == 0) {
return null;
}
final Dimension2D size = nativeGetNSImageSize(ptr);
AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
execute(ptr -> {
sizeRef.set(nativeGetNSImageSize(ptr));
});
final Dimension2D size = sizeRef.get();
if (size == null) {
return null;
}
final int w = (int)size.getWidth();
final int h = (int)size.getHeight();
Dimension2D[] sizes
= nativeGetNSImageRepresentationSizes(ptr,
size.getWidth(), size.getHeight());
AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
execute(ptr -> {
repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
size.getHeight()));
});
Dimension2D[] sizes = repRef.get();
return sizes == null || sizes.length < 2 ?
new MultiResolutionCachedImage(w, h, (width, height)
......@@ -256,18 +268,18 @@ public class CImage extends CFRetainedResource {
final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
final int[] buffer = SunWritableRaster.stealData(dbi, 0);
nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight);
execute(ptr->nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight));
SunWritableRaster.markDirty(dbi);
return bimg;
}
/** If nsImagePtr != 0 then scale this NSImage. @return *this* */
CImage resize(final double w, final double h) {
if (ptr != 0) nativeSetNSImageSize(ptr, w, h);
execute(ptr -> nativeSetNSImageSize(ptr, w, h));
return this;
}
void resizeRepresentations(double w, double h) {
if (ptr != 0) nativeResizeNSImageRepresentations(ptr, w, h);
execute(ptr -> nativeResizeNSImageRepresentations(ptr, w, h));
}
}
......@@ -113,7 +113,13 @@ public class CMenuItem extends CMenuComponent implements MenuItemPeer {
*/
public final void setImage(final java.awt.Image img) {
CImage cimg = CImage.getCreator().createFromImage(img);
execute(ptr -> nativeSetImage(ptr, cimg == null ? 0L : cimg.ptr));
execute(ptr -> {
if (cimg == null) {
nativeSetImage(ptr, 0L);
} else {
cimg.execute(imgPtr -> nativeSetImage(ptr, imgPtr));
}
});
}
/**
......
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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
......@@ -44,6 +44,9 @@ class CPlatformComponent extends CFRetainedResource
super(0, true);
}
/**
* Used by JAWT.
*/
public long getPointer() {
return ptr;
}
......@@ -61,7 +64,7 @@ class CPlatformComponent extends CFRetainedResource
// translates values from the coordinate system of the top-level window
// to the coordinate system of the content view
final Insets insets = platformWindow.getPeer().getInsets();
nativeSetBounds(getPointer(), x - insets.left, y - insets.top, w, h);
execute(ptr->nativeSetBounds(ptr, x - insets.left, y - insets.top, w, h));
}
@Override
......
......@@ -107,11 +107,6 @@ public class CPlatformLWWindow extends CPlatformWindow {
public void updateIconImages() {
}
@Override
public long getNSWindowPtr() {
return 0;
}
@Override
public SurfaceData getSurfaceData() {
return null;
......
/*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2016, 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,9 @@ package sun.lwawt.macosx;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsEnvironment;
......@@ -83,7 +86,7 @@ public class CPlatformView extends CFRetainedResource {
* Cocoa coordinates).
*/
public void setBounds(int x, int y, int width, int height) {
CWrapper.NSView.setFrame(ptr, x, y, width, height);
execute(ptr->CWrapper.NSView.setFrame(ptr, x, y, width, height));
}
// REMIND: CGLSurfaceData expects top-level's size
......@@ -96,7 +99,7 @@ public class CPlatformView extends CFRetainedResource {
}
public void setToolTip(String msg) {
CWrapper.NSView.setToolTip(ptr, msg);
execute(ptr -> CWrapper.NSView.setToolTip(ptr, msg));
}
// ----------------------------------------------------------------------
......@@ -147,18 +150,25 @@ public class CPlatformView extends CFRetainedResource {
}
public void setAutoResizable(boolean toResize) {
nativeSetAutoResizable(this.getAWTView(), toResize);
execute(ptr -> nativeSetAutoResizable(ptr, toResize));
}
public boolean isUnderMouse() {
return nativeIsViewUnderMouse(getAWTView());
AtomicBoolean ref = new AtomicBoolean();
execute(ptr -> {
ref.set(nativeIsViewUnderMouse(ptr));
});
return ref.get();
}
public GraphicsDevice getGraphicsDevice() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
int displayID = nativeGetNSViewDisplayID(getAWTView());
GraphicsDevice gd = cge.getScreenDevice(displayID);
AtomicInteger ref = new AtomicInteger();
execute(ptr -> {
ref.set(nativeGetNSViewDisplayID(ptr));
});
GraphicsDevice gd = cge.getScreenDevice(ref.get());
if (gd == null) {
// this could possibly happen during device removal
// use the default screen device in this case
......@@ -168,8 +178,15 @@ public class CPlatformView extends CFRetainedResource {
}
public Point getLocationOnScreen() {
Rectangle r = nativeGetLocationOnScreen(this.getAWTView()).getBounds();
return new Point(r.x, r.y);
AtomicReference<Rectangle> ref = new AtomicReference<>();
execute(ptr -> {
ref.set(nativeGetLocationOnScreen(ptr).getBounds());
});
Rectangle r = ref.get();
if (r != null) {
return new Point(r.x, r.y);
}
return new Point(0, 0);
}
// ----------------------------------------------------------------------
......
......@@ -36,6 +36,7 @@ import java.awt.image.BufferedImage;
import java.awt.peer.TrayIconPeer;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.concurrent.atomic.AtomicReference;
public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
private TrayIcon target;
......@@ -88,10 +89,6 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
return nativeCreate();
}
private long getModel() {
return ptr;
}
private native long nativeCreate();
//invocation from the AWTTrayIcon.m
......@@ -154,7 +151,7 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
@Override
public void setToolTip(String tooltip) {
nativeSetToolTip(getModel(), tooltip);
execute(ptr -> nativeSetToolTip(ptr, tooltip));
}
//adds tooltip to the NSStatusBar's NSButton.
......@@ -183,7 +180,12 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
}
CImage cimage = CImage.getCreator().createFromImage(image);
setNativeImage(getModel(), cimage.ptr, target.isImageAutoSize());
boolean imageAutoSize = target.isImageAutoSize();
cimage.execute(imagePtr -> {
execute(ptr -> {
setNativeImage(ptr, imagePtr, imageAutoSize);
});
});
}
private native void setNativeImage(final long model, final long nsimage, final boolean autosize);
......@@ -363,7 +365,14 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
private void showMessageDialog() {
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
Point2D iconLoc = nativeGetIconLocation(getModel());
AtomicReference<Point2D> ref = new AtomicReference<>();
execute(ptr -> {
ref.set(nativeGetIconLocation(ptr));
});
Point2D iconLoc = ref.get();
if (iconLoc == null) {
return;
}
int dialogY = (int)iconLoc.getY();
int dialogX = (int)iconLoc.getX();
......
......@@ -74,13 +74,13 @@ public class CViewPlatformEmbeddedFrame implements PlatformWindow {
@Override
public void dispose() {
CWrapper.NSView.removeFromSuperview(view.getAWTView());
view.execute(CWrapper.NSView::removeFromSuperview);
view.dispose();
}
@Override
public void setVisible(boolean visible) {
CWrapper.NSView.setHidden(view.getAWTView(), !visible);
view.execute(ptr -> CWrapper.NSView.setHidden(ptr, !visible));
}
@Override
......
......@@ -219,14 +219,14 @@ public final class CWarningWindow extends CPlatformWindow
@Override
public void setVisible(boolean visible) {
synchronized (lock) {
final long nsWindowPtr = getNSWindowPtr();
// Actually show or hide the window
if (visible) {
CWrapper.NSWindow.orderFront(nsWindowPtr);
} else {
CWrapper.NSWindow.orderOut(nsWindowPtr);
}
execute(ptr -> {
// Actually show or hide the window
if (visible) {
CWrapper.NSWindow.orderFront(ptr);
} else {
CWrapper.NSWindow.orderOut(ptr);
}
});
this.visible = visible;
......@@ -234,8 +234,13 @@ public final class CWarningWindow extends CPlatformWindow
if (visible) {
// Order myself above my parent
if (owner != null && owner.isVisible()) {
CWrapper.NSWindow.orderWindow(nsWindowPtr,
CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr());
owner.execute(ownerPtr -> {
execute(ptr -> {
CWrapper.NSWindow.orderWindow(ptr,
CWrapper.NSWindow.NSWindowAbove,
ownerPtr);
});
});
// do not allow security warning to be obscured by other windows
applyWindowLevel(ownerWindow);
......
......@@ -41,6 +41,8 @@
CALayer *windowLayer;
}
@property (retain) CALayer *windowLayer;
- (id) initWithWindowLayer: (CALayer *)windowLayer;
- (void) setBounds: (CGRect)rect;
......
......@@ -38,11 +38,15 @@
self = [super init];
if (self == nil) return self;
windowLayer = aWindowLayer;
self.windowLayer = aWindowLayer;
return self;
}
- (void) dealloc {
self.windowLayer = nil;
[super dealloc];
}
- (CALayer *) layer {
return layer;
......
/*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2016, 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,11 +28,7 @@ package sun.misc;
import java.io.File;
import java.io.IOException;
import java.io.FilePermission;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.MalformedURLException;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.net.*;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
......@@ -213,8 +209,16 @@ public class Launcher {
URL[] urls = super.getURLs();
File prevDir = null;
for (int i = 0; i < urls.length; i++) {
// Get the ext directory from the URL
File dir = new File(urls[i].getPath()).getParentFile();
// Get the ext directory from the URL; convert to
// URI first, so the URL will be decoded.
URI uri;
try {
uri = urls[i].toURI();
} catch (URISyntaxException ue) {
// skip this URL if cannot convert it to URI
continue;
}
File dir = new File(uri).getParentFile();
if (dir != null && !dir.equals(prevDir)) {
// Look in architecture-specific subdirectory first
// Read from the saved system properties to avoid deadlock
......
/*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2016, 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
......@@ -98,7 +98,15 @@ public class HttpClient extends NetworkClient {
// from previous releases.
private static boolean retryPostProp = true;
/* Value of the system property jdk.ntlm.cache;
if false, then NTLM connections will not be cached.
The default value is 'true'. */
private static final boolean cacheNTLMProp;
volatile boolean keepingAlive = false; /* this is a keep-alive connection */
volatile boolean disableKeepAlive;/* keep-alive has been disabled for this
connection - this will be used when
recomputing the value of keepingAlive */
int keepAliveConnections = -1; /* number of keep-alives left */
/**Idle timeout value, in milliseconds. Zero means infinity,
......@@ -149,6 +157,9 @@ public class HttpClient extends NetworkClient {
String retryPost = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.net.http.retryPost"));
String cacheNTLM = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("jdk.ntlm.cache"));
if (keepAlive != null) {
keepAliveProp = Boolean.valueOf(keepAlive).booleanValue();
} else {
......@@ -157,9 +168,15 @@ public class HttpClient extends NetworkClient {
if (retryPost != null) {
retryPostProp = Boolean.valueOf(retryPost).booleanValue();
} else
retryPostProp = true;
} else {
retryPostProp = true;
}
if (cacheNTLM != null) {
cacheNTLMProp = Boolean.parseBoolean(cacheNTLM);
} else {
cacheNTLMProp = true;
}
}
/**
......@@ -708,6 +725,7 @@ public class HttpClient extends NetworkClient {
nread += r;
}
String keep=null;
String authenticate=null;
ret = b[0] == 'H' && b[1] == 'T'
&& b[2] == 'T' && b[3] == 'P' && b[4] == '/' &&
b[5] == '1' && b[6] == '.';
......@@ -736,17 +754,37 @@ public class HttpClient extends NetworkClient {
*/
if (usingProxy) { // not likely a proxy will return this
keep = responses.findValue("Proxy-Connection");
authenticate = responses.findValue("Proxy-Authenticate");
}
if (keep == null) {
keep = responses.findValue("Connection");
authenticate = responses.findValue("WWW-Authenticate");
}
// 'disableKeepAlive' starts with the value false.
// It can transition from false to true, but once true
// it stays true.
// If cacheNTLMProp is false, and disableKeepAlive is false,
// then we need to examine the response headers to figure out
// whether we are doing NTLM authentication. If we do NTLM,
// and cacheNTLMProp is false, than we can't keep this connection
// alive: we will switch disableKeepAlive to true.
boolean canKeepAlive = !disableKeepAlive;
if (canKeepAlive && cacheNTLMProp == false && authenticate != null) {
authenticate = authenticate.toLowerCase(Locale.US);
canKeepAlive = !authenticate.startsWith("ntlm ");
}
disableKeepAlive |= !canKeepAlive;
if (keep != null && keep.toLowerCase(Locale.US).equals("keep-alive")) {
/* some servers, notably Apache1.1, send something like:
* "Keep-Alive: timeout=15, max=1" which we should respect.
*/
HeaderParser p = new HeaderParser(
if (disableKeepAlive) {
keepAliveConnections = 1;
} else {
HeaderParser p = new HeaderParser(
responses.findValue("Keep-Alive"));
if (p != null) {
/* default should be larger in case of proxy */
keepAliveConnections = p.findInt("max", usingProxy?50:5);
keepAliveTimeout = p.findInt("timeout", usingProxy?60:5);
......@@ -756,7 +794,7 @@ public class HttpClient extends NetworkClient {
* We're talking 1.1 or later. Keep persistent until
* the server says to close.
*/
if (keep != null) {
if (keep != null || disableKeepAlive) {
/*
* The only Connection token we understand is close.
* Paranoia: if there is any Connection header then
......@@ -838,7 +876,7 @@ public class HttpClient extends NetworkClient {
keepAliveConnections = 1;
keepingAlive = false;
} else {
keepingAlive = true;
keepingAlive = !disableKeepAlive;
}
failedOnce = false;
} else {
......@@ -871,7 +909,7 @@ public class HttpClient extends NetworkClient {
(cl >= 0 ||
code == HttpURLConnection.HTTP_NOT_MODIFIED ||
code == HttpURLConnection.HTTP_NO_CONTENT)) {
keepingAlive = true;
keepingAlive = !disableKeepAlive;
failedOnce = false;
} else if (keepingAlive) {
/* Previously we were keeping alive, and now we're not. Remove
......
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2016, 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
......@@ -64,8 +64,7 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
* repeatedly, via the Authenticator. Default is false, which means that this
* behavior is switched off.
*/
static boolean serializeAuth;
static final boolean serializeAuth;
static {
serializeAuth = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
......@@ -105,6 +104,16 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
public String getProtocolScheme() {
return protocol;
}
/**
* Whether we should cache this instance in the AuthCache.
* This method returns {@code true} by default.
* Subclasses may override this method to add
* additional restrictions.
* @return {@code true} by default.
*/
protected boolean useAuthCache() {
return true;
}
/**
* requests is used to ensure that interaction with the
......@@ -341,9 +350,11 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
*/
void addToCache() {
String key = cacheKey(true);
cache.put(key, this);
if (supportsPreemptiveAuthorization()) {
cache.put(cacheKey(false), this);
if (useAuthCache()) {
cache.put(key, this);
if (supportsPreemptiveAuthorization()) {
cache.put(cacheKey(false), this);
}
}
endAuthRequest(key);
}
......
/*
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2016, 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
......@@ -280,13 +280,14 @@ final class CardImpl extends Card {
}
public String toString() {
return "PC/SC card in " + terminal.getName()
return "PC/SC card in " + terminal.name
+ ", protocol " + getProtocol() + ", state " + state;
}
protected void finalize() throws Throwable {
try {
if (state == State.OK) {
state = State.DISCONNECTED;
SCardDisconnect(cardId, SCARD_LEAVE_CARD);
}
} finally {
......
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2016, 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
......@@ -74,11 +74,15 @@ public class NTLMAuthentication extends AuthenticationInfo {
private String hostname;
private static String defaultDomain; /* Domain to use if not specified by user */
private static final boolean ntlmCache; /* Whether cache is enabled for NTLM */
static {
defaultDomain = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("http.auth.ntlm.domain", ""));
};
String ntlmCacheProp = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("jdk.ntlm.cache", "true"));
ntlmCache = Boolean.parseBoolean(ntlmCacheProp);
}
public static boolean supportsTransparentAuth () {
return false;
......@@ -167,6 +171,11 @@ public class NTLMAuthentication extends AuthenticationInfo {
init (pw);
}
@Override
protected boolean useAuthCache() {
return ntlmCache && super.useAuthCache();
}
/**
* @return true if this authentication supports preemptive authorization
*/
......@@ -243,4 +252,3 @@ public class NTLMAuthentication extends AuthenticationInfo {
return result;
}
}
/*
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2016, 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
......@@ -50,11 +50,15 @@ public class NTLMAuthentication extends AuthenticationInfo {
private String hostname;
private static String defaultDomain; /* Domain to use if not specified by user */
private static final boolean ntlmCache; /* Whether cache is enabled for NTLM */
static {
defaultDomain = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("http.auth.ntlm.domain",
"domain"));
String ntlmCacheProp = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("jdk.ntlm.cache", "true"));
ntlmCache = Boolean.parseBoolean(ntlmCacheProp);
};
private void init0() {
......@@ -130,6 +134,11 @@ public class NTLMAuthentication extends AuthenticationInfo {
init (pw);
}
@Override
protected boolean useAuthCache() {
return ntlmCache && super.useAuthCache();
}
/**
* @return true if this authentication supports preemptive authorization
*/
......
......@@ -57,15 +57,6 @@ typedef AwtObject* PDATA;
} \
}
#define JNI_CHECK_PEER_GOTO(peer, where) { \
JNI_CHECK_NULL_GOTO(peer, "peer", where); \
pData = JNI_GET_PDATA(peer); \
if (pData == NULL) { \
THROW_NULL_PDATA_IF_NOT_DESTROYED(peer); \
goto where; \
} \
}
#define JNI_CHECK_NULL_RETURN(obj, msg) { \
if (obj == NULL) { \
env->ExceptionClear(); \
......@@ -74,15 +65,6 @@ typedef AwtObject* PDATA;
} \
}
#define JNI_CHECK_PEER_RETURN(peer) { \
JNI_CHECK_NULL_RETURN(peer, "peer"); \
pData = JNI_GET_PDATA(peer); \
if (pData == NULL) { \
THROW_NULL_PDATA_IF_NOT_DESTROYED(peer); \
return; \
} \
}
#define JNI_CHECK_PEER_CREATION_RETURN(peer) { \
if (peer == NULL ) { \
return; \
......@@ -109,6 +91,33 @@ typedef AwtObject* PDATA;
} \
}
/**
* This macros must be used under SyncCall or on the Toolkit thread.
*/
#define JNI_CHECK_PEER_GOTO(peer, where) { \
JNI_CHECK_NULL_GOTO(peer, "peer", where); \
pData = JNI_GET_PDATA(peer); \
if (pData == NULL) { \
THROW_NULL_PDATA_IF_NOT_DESTROYED(peer); \
goto where; \
} \
}
/**
* This macros must be used under SyncCall or on the Toolkit thread.
*/
#define JNI_CHECK_PEER_RETURN(peer) { \
JNI_CHECK_NULL_RETURN(peer, "peer"); \
pData = JNI_GET_PDATA(peer); \
if (pData == NULL) { \
THROW_NULL_PDATA_IF_NOT_DESTROYED(peer); \
return; \
} \
}
/**
* This macros must be used under SyncCall or on the Toolkit thread.
*/
#define JNI_CHECK_PEER_RETURN_NULL(peer) { \
JNI_CHECK_NULL_RETURN_NULL(peer, "peer"); \
pData = JNI_GET_PDATA(peer); \
......@@ -118,6 +127,9 @@ typedef AwtObject* PDATA;
} \
}
/**
* This macros must be used under SyncCall or on the Toolkit thread.
*/
#define JNI_CHECK_PEER_RETURN_VAL(peer, val) { \
JNI_CHECK_NULL_RETURN_VAL(peer, "peer", val); \
pData = JNI_GET_PDATA(peer); \
......
......@@ -65,6 +65,7 @@ LPCTSTR AwtButton::GetClassName() {
/* Create a new AwtButton object and window. */
AwtButton* AwtButton::Create(jobject self, jobject parent)
{
DASSERT(AwtToolkit::IsMainThread());
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
/* the result */
......@@ -88,7 +89,6 @@ AwtButton* AwtButton::Create(jobject self, jobject parent)
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtCanvas*)pData;
JNI_CHECK_NULL_GOTO(awtParent, "awtParent", done);
target = env->GetObjectField(self, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "target", done);
......@@ -374,9 +374,6 @@ Java_sun_awt_windows_WButtonPeer_setLabel(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(self);
SetLabelStruct *sls = new SetLabelStruct;
sls->button = env->NewGlobalRef(self);
sls->label = (label != NULL) ? (jstring)env->NewGlobalRef(label) : NULL;
......@@ -398,14 +395,9 @@ Java_sun_awt_windows_WButtonPeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(
self, parent, (AwtToolkit::ComponentFactory)AwtButton::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -59,6 +59,7 @@ LPCTSTR AwtCanvas::GetClassName() {
*/
AwtCanvas* AwtCanvas::Create(jobject self, jobject hParent)
{
DASSERT(AwtToolkit::IsMainThread());
TRY;
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
......@@ -74,12 +75,11 @@ AwtCanvas* AwtCanvas::Create(jobject self, jobject hParent)
return NULL;
}
PDATA pData;
AwtComponent* parent;
JNI_CHECK_NULL_GOTO(hParent, "null hParent", done);
parent = (AwtComponent*)JNI_GET_PDATA(hParent);
JNI_CHECK_NULL_GOTO(parent, "null parent", done);
JNI_CHECK_PEER_GOTO(hParent, done);
parent = (AwtCanvas*)pData;
target = env->GetObjectField(self, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
......@@ -236,12 +236,9 @@ Java_sun_awt_windows_WCanvasPeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtCanvas::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -70,6 +70,7 @@ LPCTSTR AwtCheckbox::GetClassName() {
AwtCheckbox* AwtCheckbox::Create(jobject peer, jobject parent)
{
DASSERT(AwtToolkit::IsMainThread());
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jstring label = NULL;
......@@ -81,11 +82,10 @@ AwtCheckbox* AwtCheckbox::Create(jobject peer, jobject parent)
return NULL;
}
PDATA pData;
AwtComponent* awtParent;
JNI_CHECK_NULL_GOTO(parent, "null parent", done);
awtParent = (AwtComponent*)JNI_GET_PDATA(parent);
JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtCanvas*)pData;
target = env->GetObjectField(peer, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
......@@ -667,11 +667,10 @@ Java_sun_awt_windows_WCheckboxPeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtCheckbox::Create);
PDATA pData;
JNI_CHECK_PEER_CREATION_RETURN(self);
#ifdef DEBUG
......
......@@ -104,7 +104,7 @@ void AwtChoice::Dispose() {
}
AwtChoice* AwtChoice::Create(jobject peer, jobject parent) {
DASSERT(AwtToolkit::IsMainThread());
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject target = NULL;
......@@ -115,12 +115,10 @@ AwtChoice* AwtChoice::Create(jobject peer, jobject parent) {
if (env->EnsureLocalCapacity(1) < 0) {
return NULL;
}
PDATA pData;
AwtCanvas* awtParent;
JNI_CHECK_NULL_GOTO(parent, "null parent", done);
awtParent = (AwtCanvas*)JNI_GET_PDATA(parent);
JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtCanvas*)pData;
target = env->GetObjectField(peer, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
......@@ -829,12 +827,9 @@ Java_sun_awt_windows_WChoicePeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtChoice::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -150,6 +150,11 @@ struct SetFocusStruct {
jobject component;
jboolean doSetFocus;
};
// Struct for _SetParent function
struct SetParentStruct {
jobject component;
jobject parentComp;
};
/************************************************************************/
//////////////////////////////////////////////////////////////////////////
......@@ -261,9 +266,6 @@ AwtComponent::~AwtComponent()
{
DASSERT(AwtToolkit::IsMainThread());
/* Disconnect all links. */
UnlinkObjects();
/*
* All the messages for this component are processed, native
* resources are freed, and Java object is not connected to
......@@ -275,6 +277,8 @@ AwtComponent::~AwtComponent()
void AwtComponent::Dispose()
{
DASSERT(AwtToolkit::IsMainThread());
// NOTE: in case the component/toplevel was focused, Java should
// have already taken care of proper transferring it or clearing.
......@@ -293,8 +297,10 @@ void AwtComponent::Dispose()
/* Release global ref to input method */
SetInputMethod(NULL, TRUE);
if (m_childList != NULL)
if (m_childList != NULL) {
delete m_childList;
m_childList = NULL;
}
DestroyDropTarget();
ReleaseDragCapture(0);
......@@ -317,6 +323,9 @@ void AwtComponent::Dispose()
m_brushBackground = NULL;
}
/* Disconnect all links. */
UnlinkObjects();
if (m_bPauseDestroy) {
// AwtComponent::WmNcDestroy could be released now
m_bPauseDestroy = FALSE;
......@@ -6114,21 +6123,36 @@ ret:
return result;
}
void AwtComponent::SetParent(void * param) {
void AwtComponent::_SetParent(void * param)
{
if (AwtToolkit::IsMainThread()) {
AwtComponent** comps = (AwtComponent**)param;
if ((comps[0] != NULL) && (comps[1] != NULL)) {
HWND selfWnd = comps[0]->GetHWnd();
HWND parentWnd = comps[1]->GetHWnd();
if (::IsWindow(selfWnd) && ::IsWindow(parentWnd)) {
// Shouldn't trigger native focus change
// (only the proxy may be the native focus owner).
::SetParent(selfWnd, parentWnd);
}
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
SetParentStruct *data = (SetParentStruct*) param;
jobject self = data->component;
jobject parent = data->parentComp;
AwtComponent *awtComponent = NULL;
AwtComponent *awtParent = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
awtComponent = (AwtComponent *)pData;
JNI_CHECK_PEER_GOTO(parent, ret);
awtParent = (AwtComponent *)pData;
HWND selfWnd = awtComponent->GetHWnd();
HWND parentWnd = awtParent->GetHWnd();
if (::IsWindow(selfWnd) && ::IsWindow(parentWnd)) {
// Shouldn't trigger native focus change
// (only the proxy may be the native focus owner).
::SetParent(selfWnd, parentWnd);
}
delete[] comps;
ret:
env->DeleteGlobalRef(self);
env->DeleteGlobalRef(parent);
delete data;
} else {
AwtToolkit::GetInstance().InvokeFunction(AwtComponent::SetParent, param);
AwtToolkit::GetInstance().InvokeFunction(AwtComponent::_SetParent, param);
}
}
......@@ -6955,15 +6979,12 @@ JNIEXPORT void JNICALL
Java_sun_awt_windows_WComponentPeer_pSetParent(JNIEnv* env, jobject self, jobject parent) {
TRY;
typedef AwtComponent* PComponent;
AwtComponent** comps = new PComponent[2];
AwtComponent* comp = (AwtComponent*)JNI_GET_PDATA(self);
AwtComponent* parentComp = (AwtComponent*)JNI_GET_PDATA(parent);
comps[0] = comp;
comps[1] = parentComp;
SetParentStruct * data = new SetParentStruct;
data->component = env->NewGlobalRef(self);
data->parentComp = env->NewGlobalRef(parent);
AwtToolkit::GetInstance().SyncCall(AwtComponent::SetParent, comps);
// comps is deleted in SetParent
AwtToolkit::GetInstance().SyncCall(AwtComponent::_SetParent, data);
// global refs and data are deleted in SetParent
CATCH_BAD_ALLOC;
}
......
......@@ -665,6 +665,7 @@ public:
static void _RemoveNativeDropTarget(void *param);
static jintArray _CreatePrintedPixels(void *param);
static jboolean _NativeHandlesWheelScrolling(void *param);
static void _SetParent(void * param);
static void _SetRectangularShape(void *param);
static void _SetZOrder(void *param);
......
......@@ -112,12 +112,13 @@ AwtDialog* AwtDialog::Create(jobject peer, jobject parent)
PDATA pData;
AwtWindow* awtParent = NULL;
HWND hwndParent = NULL;
target = env->GetObjectField(peer, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
if (parent != NULL) {
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtWindow *)(JNI_GET_PDATA(parent));
awtParent = (AwtWindow *)pData;
hwndParent = awtParent->GetHWnd();
} else {
// There is no way to prevent a parentless dialog from showing on
......@@ -784,11 +785,9 @@ Java_sun_awt_windows_WDialogPeer_createAwtDialog(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtDialog::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -1578,12 +1578,12 @@ void AwtFrame::_NotifyModalBlocked(void *param)
PDATA pData;
pData = JNI_GET_PDATA(peer);
JNI_CHECK_PEER_GOTO(peer, ret);
AwtFrame *f = (AwtFrame *)pData;
// dialog here may be NULL, for example, if the blocker is a native dialog
// however, we need to install/unistall modal hooks anyway
pData = JNI_GET_PDATA(blockerPeer);
JNI_CHECK_PEER_GOTO(blockerPeer, ret);
AwtDialog *d = (AwtDialog *)pData;
if ((f != NULL) && ::IsWindow(f->GetHWnd()))
......@@ -1635,7 +1635,7 @@ void AwtFrame::_NotifyModalBlocked(void *param)
}
}
}
ret:
env->DeleteGlobalRef(self);
env->DeleteGlobalRef(peer);
env->DeleteGlobalRef(blockerPeer);
......@@ -1807,8 +1807,6 @@ Java_sun_awt_windows_WFramePeer_createAwtFrame(JNIEnv *env, jobject self,
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtFrame::Create);
PDATA pData;
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......@@ -1922,8 +1920,6 @@ Java_sun_awt_windows_WEmbeddedFramePeer_create(JNIEnv *env, jobject self,
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtFrame::Create);
PDATA pData;
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -80,7 +80,7 @@ AwtLabel* AwtLabel::Create(jobject labelPeer, jobject parent)
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtCanvas*)pData;
JNI_CHECK_NULL_GOTO(awtParent, "awtParent", done);
target = env->GetObjectField(labelPeer, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "target", done);
......@@ -392,12 +392,9 @@ Java_sun_awt_windows_WLabelPeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtLabel::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -89,10 +89,9 @@ AwtList* AwtList::Create(jobject peer, jobject parent)
PDATA pData;
AwtCanvas* awtParent;
JNI_CHECK_PEER_GOTO(parent, done);
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtCanvas*)pData;
JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
/* target is Hjava_awt_List * */
target = env->GetObjectField(peer, AwtObject::targetID);
......@@ -928,9 +927,6 @@ Java_sun_awt_windows_WListPeer_deselect(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(self);
SelectElementStruct *ses = new SelectElementStruct;
ses->list = env->NewGlobalRef(self);
ses->index = pos;
......@@ -994,11 +990,8 @@ Java_sun_awt_windows_WListPeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)AwtList::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -96,10 +96,9 @@ AwtScrollPane* AwtScrollPane::Create(jobject self, jobject parent)
PDATA pData;
AwtComponent* awtParent;
JNI_CHECK_PEER_GOTO(parent, done);
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtComponent*)pData;
JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
target = env->GetObjectField(self, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
......@@ -679,11 +678,10 @@ Java_sun_awt_windows_WScrollPanePeer_create(JNIEnv *env, jobject self,
DTRACE_PRINTLN2("%x: WScrollPanePeer.create(%x)", self, parent);
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtScrollPane::Create);
PDATA pData;
JNI_CHECK_PEER_CREATION_RETURN(self);
((AwtScrollPane*)pData)->VerifyState();
......
......@@ -38,7 +38,11 @@ struct SetValuesStruct {
jint value;
jint visible;
jint min, max;
};
// struct for _SetLineIncrement()/_SetPageIncrement() methods
struct SetIncrementStruct {
jobject scrollbar;
jint increment;
};
/************************************************************************
* AwtScrollbar fields
......@@ -108,10 +112,9 @@ AwtScrollbar::Create(jobject peer, jobject parent)
PDATA pData;
AwtCanvas* awtParent;
JNI_CHECK_PEER_GOTO(parent, done);
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtCanvas*)pData;
JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
target = env->GetObjectField(peer, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
......@@ -471,6 +474,52 @@ ret:
delete svs;
}
void AwtScrollbar::_SetLineIncrement(void *param)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
SetIncrementStruct *sis = (SetIncrementStruct *)param;
jobject self = sis->scrollbar;
jint increment = sis->increment;
AwtScrollbar *sb = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
sb = (AwtScrollbar *)pData;
if (::IsWindow(sb->GetHWnd()))
{
sb->SetLineIncrement(increment);
}
ret:
env->DeleteGlobalRef(self);
delete sis;
}
void AwtScrollbar::_SetPageIncrement(void *param)
{
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
SetIncrementStruct *sis = (SetIncrementStruct *)param;
jobject self = sis->scrollbar;
jint increment = sis->increment;
AwtScrollbar *sb = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
sb = (AwtScrollbar *)pData;
if (::IsWindow(sb->GetHWnd()))
{
sb->SetPageIncrement(increment);
}
ret:
env->DeleteGlobalRef(self);
delete sis;
}
/************************************************************************
* Scrollbar native methods
*/
......@@ -546,10 +595,12 @@ Java_sun_awt_windows_WScrollbarPeer_setLineIncrement(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(self);
AwtScrollbar* c = (AwtScrollbar*)pData;
c->SetLineIncrement(increment);
SetIncrementStruct *sis = new SetIncrementStruct;
sis->scrollbar = env->NewGlobalRef(self);
sis->increment = increment;
AwtToolkit::GetInstance().SyncCall(AwtScrollbar::_SetLineIncrement, sis);
// global ref and svs are deleted in _SetValues
CATCH_BAD_ALLOC;
}
......@@ -565,10 +616,12 @@ Java_sun_awt_windows_WScrollbarPeer_setPageIncrement(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(self);
AwtScrollbar* c = (AwtScrollbar*)pData;
c->SetPageIncrement(increment);
SetIncrementStruct *sis = new SetIncrementStruct;
sis->scrollbar = env->NewGlobalRef(self);
sis->increment = increment;
AwtToolkit::GetInstance().SyncCall(AwtScrollbar::_SetPageIncrement, sis);
// global ref and svs are deleted in _SetValues
CATCH_BAD_ALLOC;
}
......@@ -584,12 +637,9 @@ Java_sun_awt_windows_WScrollbarPeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtScrollbar::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -77,6 +77,8 @@ public:
INLINE virtual BOOL IsScrollbar() { return TRUE; }
static void _SetLineIncrement(void *param);
static void _SetPageIncrement(void *param);
// invoked on Toolkit thread
static void _SetValues(void *param);
......
......@@ -543,12 +543,9 @@ Java_sun_awt_windows_WTextAreaPeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtTextArea::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -95,10 +95,9 @@ AwtTextComponent* AwtTextComponent::Create(jobject peer, jobject parent, BOOL is
PDATA pData;
AwtCanvas* awtParent;
JNI_CHECK_PEER_GOTO(parent, done);
JNI_CHECK_PEER_GOTO(parent, done);
awtParent = (AwtCanvas*)pData;
JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
target = env->GetObjectField(peer, AwtObject::targetID);
JNI_CHECK_NULL_GOTO(target, "null target", done);
......
......@@ -301,12 +301,9 @@ Java_sun_awt_windows_WTextFieldPeer_create(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtTextField::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -3246,12 +3246,9 @@ Java_sun_awt_windows_WWindowPeer_createAwtWindow(JNIEnv *env, jobject self,
{
TRY;
PDATA pData;
// JNI_CHECK_PEER_RETURN(parent);
AwtToolkit::CreateComponent(self, parent,
(AwtToolkit::ComponentFactory)
AwtWindow::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC;
}
......
......@@ -197,21 +197,4 @@ public abstract class Test {
cmd.addAll(Arrays.asList(args));
return ProcessTools.executeCommand(cmd.toArray(new String[cmd.size()]));
}
protected OutputAnalyzer keytool(String... cmd) throws Throwable {
return tool(KEYTOOL, cmd);
}
protected OutputAnalyzer jarsigner(String... cmd) throws Throwable {
return tool(JARSIGNER, cmd);
}
private OutputAnalyzer tool(String tool, String... args) throws Throwable {
List<String> cmd = new ArrayList<>();
cmd.add(tool);
cmd.add("-J-Duser.language=en");
cmd.add("-J-Duser.country=US");
cmd.addAll(Arrays.asList(args));
return ProcessTools.executeCommand(cmd.toArray(new String[cmd.size()]));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册