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

Merge

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