提交 f5fe845a 编写于 作者: A asaha

Merge

...@@ -678,6 +678,18 @@ d66de7e2f672a1ff6947846818412fa899456972 jdk8u121-b10 ...@@ -678,6 +678,18 @@ d66de7e2f672a1ff6947846818412fa899456972 jdk8u121-b10
ec72a941be0a50ab77f5375cf710bc06e4f118d3 jdk8u121-b11 ec72a941be0a50ab77f5375cf710bc06e4f118d3 jdk8u121-b11
9561afc12df843ef21ecd9d7b3633371e7a2bfc4 jdk8u121-b12 9561afc12df843ef21ecd9d7b3633371e7a2bfc4 jdk8u121-b12
2974746e56192cdd14fc2dd43179bcf28e4faf4a jdk8u121-b13 2974746e56192cdd14fc2dd43179bcf28e4faf4a jdk8u121-b13
032874d46bf95478cb86690b3c91d335c0764b0b jdk8u131-b00
bea5b22daf5ddd941f3bcbf7a4e5fc5244ceb788 jdk8u131-b01
a01d217a232906e82f80e5bc3db4d60c4c74716e jdk8u131-b02
3d2dfed2b420a59c68e5deedd257eb630f88b3da jdk8u131-b03
0f7d02f565658a89b073ee77c296f33148c50da3 jdk8u131-b04
af0e709d28f9124dd2c37069e0bf4c0751248c61 jdk8u131-b05
3c7f99282d1b5e29f7466bf25fb6878bfebfc58a jdk8u131-b06
f5d0aadb4d1ca74eda4e98cc0030f1618ef4c870 jdk8u131-b07
6e362e6002abc39c63fc8ab4bcebf08e273f5a94 jdk8u131-b08
40d00399869d8a28cfecf360234f340e9e0ad3b1 jdk8u131-b09
c0091a673d766ce2e76a945bab6de325fe78dd88 jdk8u131-b10
3ab471c4760a808e39406303ff33a25a542b9c75 jdk8u131-b11
1442bc728814af451e2dd1a6719a64485d27e3a0 jdk8u122-b00 1442bc728814af451e2dd1a6719a64485d27e3a0 jdk8u122-b00
f6030acfa5aec0e64d45adfac69b9e7e5c12bc74 jdk8u122-b01 f6030acfa5aec0e64d45adfac69b9e7e5c12bc74 jdk8u122-b01
6b072c3a6db7ab06804c91aab77431799dfb5d47 jdk8u122-b02 6b072c3a6db7ab06804c91aab77431799dfb5d47 jdk8u122-b02
......
...@@ -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);
}
}
} }
# #
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2011, 2017, 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
...@@ -46,7 +46,7 @@ FileChooser.saveButton.textAndMnemonic=Speichern ...@@ -46,7 +46,7 @@ FileChooser.saveButton.textAndMnemonic=Speichern
FileChooser.openButton.textAndMnemonic=\u00D6ffnen FileChooser.openButton.textAndMnemonic=\u00D6ffnen
FileChooser.saveDialogTitle.textAndMnemonic=Speichern FileChooser.saveDialogTitle.textAndMnemonic=Speichern
FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen FileChooser.openDialogTitle.textAndMnemonic=\u00D6ffnen
FileChooser.updateButton.textAndMnemonic=Updaten FileChooser.updateButton.textAndMnemonic=Aktualisieren
FileChooser.helpButton.textAndMnemonic=Hilfe FileChooser.helpButton.textAndMnemonic=Hilfe
FileChooser.directoryOpenButton.textAndMnemonic=\u00D6ffnen FileChooser.directoryOpenButton.textAndMnemonic=\u00D6ffnen
......
...@@ -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;
......
...@@ -345,7 +345,6 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -345,7 +345,6 @@ AWT_ASSERT_APPKIT_THREAD;
return windowLayers; return windowLayers;
} }
// returns id for the topmost window under mouse // returns id for the topmost window under mouse
+ (NSInteger) getTopmostWindowUnderMouseID { + (NSInteger) getTopmostWindowUnderMouseID {
NSInteger result = -1; NSInteger result = -1;
......
...@@ -38,7 +38,7 @@ FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4 ...@@ -38,7 +38,7 @@ FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
FileChooser.viewMenuButtonToolTipText = \uBCF4\uAE30 \uBA54\uB274 FileChooser.viewMenuButtonToolTipText = \uBCF4\uAE30 \uBA54\uB274
FileChooser.viewMenuButtonAccessibleName = \uBCF4\uAE30 \uBA54\uB274 FileChooser.viewMenuButtonAccessibleName = \uBCF4\uAE30 \uBA54\uB274
FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68 FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
......
# #
# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2005, 2017, 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
...@@ -41,7 +41,7 @@ cachedrowsetimpl.intfail = getInt utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) ...@@ -41,7 +41,7 @@ cachedrowsetimpl.intfail = getInt utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0})
cachedrowsetimpl.longfail = getLong utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1} cachedrowsetimpl.longfail = getLong utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
cachedrowsetimpl.floatfail = getFloat utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1} cachedrowsetimpl.floatfail = getFloat utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
cachedrowsetimpl.doublefail = getDouble utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1} cachedrowsetimpl.doublefail = getDouble utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}
cachedrowsetimpl.dtypemismt = Inkompatibel datatyp cachedrowsetimpl.dtypemismt = Felmatchad datatyp
cachedrowsetimpl.datefail = getDate utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}, ingen konvertering tillg\u00E4nglig cachedrowsetimpl.datefail = getDate utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}, ingen konvertering tillg\u00E4nglig
cachedrowsetimpl.timefail = getTime utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}, ingen konvertering tillg\u00E4nglig cachedrowsetimpl.timefail = getTime utf\u00F6rdes inte f\u00F6r v\u00E4rdet ({0}) i kolumnen {1}, ingen konvertering tillg\u00E4nglig
cachedrowsetimpl.posupdate = Det finns inte st\u00F6d f\u00F6r positionerad uppdatering cachedrowsetimpl.posupdate = Det finns inte st\u00F6d f\u00F6r positionerad uppdatering
......
...@@ -36,7 +36,7 @@ FileChooser.listViewActionLabel.textAndMnemonic=\uBAA9\uB85D ...@@ -36,7 +36,7 @@ FileChooser.listViewActionLabel.textAndMnemonic=\uBAA9\uB85D
FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4 FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4 FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68 FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
......
...@@ -36,7 +36,7 @@ FileChooser.listViewActionLabel.textAndMnemonic=\uBAA9\uB85D ...@@ -36,7 +36,7 @@ FileChooser.listViewActionLabel.textAndMnemonic=\uBAA9\uB85D
FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4 FileChooser.detailsViewButtonToolTip.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4 FileChooser.detailsViewButtonAccessibleName=\uC138\uBD80\uC815\uBCF4
FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4 FileChooser.detailsViewActionLabel.textAndMnemonic=\uC138\uBD80\uC815\uBCF4
FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C \uACE0\uCE68 FileChooser.refreshActionLabel.textAndMnemonic=\uC0C8\uB85C\uACE0\uCE68
FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30 FileChooser.viewMenuLabel.textAndMnemonic=\uBCF4\uAE30
FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984 FileChooser.fileNameHeader.textAndMnemonic=\uC774\uB984
FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30 FileChooser.fileSizeHeader.textAndMnemonic=\uD06C\uAE30
......
...@@ -411,9 +411,9 @@ public class Menu extends MenuItem implements MenuContainer, Accessible { ...@@ -411,9 +411,9 @@ public class Menu extends MenuItem implements MenuContainer, Accessible {
items.removeElementAt(index); items.removeElementAt(index);
MenuPeer peer = (MenuPeer)this.peer; MenuPeer peer = (MenuPeer)this.peer;
if (peer != null) { if (peer != null) {
peer.delItem(index);
mi.removeNotify(); mi.removeNotify();
mi.parent = null; mi.parent = null;
peer.delItem(index);
} }
} }
} }
......
...@@ -222,7 +222,6 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible ...@@ -222,7 +222,6 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
if (m.parent != null) { if (m.parent != null) {
m.parent.remove(m); m.parent.remove(m);
} }
menus.addElement(m);
m.parent = this; m.parent = this;
MenuBarPeer peer = (MenuBarPeer)this.peer; MenuBarPeer peer = (MenuBarPeer)this.peer;
...@@ -230,7 +229,10 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible ...@@ -230,7 +229,10 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
if (m.peer == null) { if (m.peer == null) {
m.addNotify(); m.addNotify();
} }
menus.addElement(m);
peer.addMenu(m); peer.addMenu(m);
} else {
menus.addElement(m);
} }
return m; return m;
} }
...@@ -248,9 +250,9 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible ...@@ -248,9 +250,9 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
menus.removeElementAt(index); menus.removeElementAt(index);
MenuBarPeer peer = (MenuBarPeer)this.peer; MenuBarPeer peer = (MenuBarPeer)this.peer;
if (peer != null) { if (peer != null) {
peer.delMenu(index);
m.removeNotify(); m.removeNotify();
m.parent = null; m.parent = null;
peer.delMenu(index);
} }
if (helpMenu == m) { if (helpMenu == m) {
helpMenu = null; helpMenu = null;
......
...@@ -75,7 +75,7 @@ public abstract class MenuComponent implements java.io.Serializable { ...@@ -75,7 +75,7 @@ public abstract class MenuComponent implements java.io.Serializable {
* @see #setFont(Font) * @see #setFont(Font)
* @see #getFont() * @see #getFont()
*/ */
Font font; volatile Font font;
/** /**
* The menu component's name, which defaults to <code>null</code>. * The menu component's name, which defaults to <code>null</code>.
...@@ -292,11 +292,13 @@ public abstract class MenuComponent implements java.io.Serializable { ...@@ -292,11 +292,13 @@ public abstract class MenuComponent implements java.io.Serializable {
* @see java.awt.font.TextAttribute * @see java.awt.font.TextAttribute
*/ */
public void setFont(Font f) { public void setFont(Font f) {
font = f; synchronized (getTreeLock()) {
//Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font) font = f;
MenuComponentPeer peer = this.peer; //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
if (peer != null) { MenuComponentPeer peer = this.peer;
peer.setFont(f); if (peer != null) {
peer.setFont(f);
}
} }
} }
......
/* /*
* Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2017, 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
...@@ -1774,12 +1774,19 @@ public class ObjectInputStream ...@@ -1774,12 +1774,19 @@ public class ObjectInputStream
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
resolveEx = ex; resolveEx = ex;
} }
skipCustomData();
desc.initProxy(cl, resolveEx, readClassDesc(false)); // Call filterCheck on the class before reading anything else
filterCheck(cl, -1);
skipCustomData();
// Call filterCheck on the definition try {
filterCheck(desc.forClass(), -1); totalObjectRefs++;
depth++;
desc.initProxy(cl, resolveEx, readClassDesc(false));
} finally {
depth--;
}
handles.finish(descHandle); handles.finish(descHandle);
passHandle = descHandle; passHandle = descHandle;
...@@ -1824,12 +1831,19 @@ public class ObjectInputStream ...@@ -1824,12 +1831,19 @@ public class ObjectInputStream
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
resolveEx = ex; resolveEx = ex;
} }
skipCustomData();
desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false)); // Call filterCheck on the class before reading anything else
filterCheck(cl, -1);
skipCustomData();
// Call filterCheck on the definition try {
filterCheck(desc.forClass(), -1); totalObjectRefs++;
depth++;
desc.initNonProxy(readDesc, cl, resolveEx, readClassDesc(false));
} finally {
depth--;
}
handles.finish(descHandle); handles.finish(descHandle);
passHandle = descHandle; passHandle = descHandle;
......
...@@ -342,11 +342,11 @@ class Thread implements Runnable { ...@@ -342,11 +342,11 @@ class Thread implements Runnable {
/** /**
* Initializes a Thread with the current AccessControlContext. * Initializes a Thread with the current AccessControlContext.
* @see #init(ThreadGroup,Runnable,String,long,AccessControlContext) * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean)
*/ */
private void init(ThreadGroup g, Runnable target, String name, private void init(ThreadGroup g, Runnable target, String name,
long stackSize) { long stackSize) {
init(g, target, name, stackSize, null); init(g, target, name, stackSize, null, true);
} }
/** /**
...@@ -359,9 +359,12 @@ class Thread implements Runnable { ...@@ -359,9 +359,12 @@ class Thread implements Runnable {
* zero to indicate that this parameter is to be ignored. * zero to indicate that this parameter is to be ignored.
* @param acc the AccessControlContext to inherit, or * @param acc the AccessControlContext to inherit, or
* AccessController.getContext() if null * AccessController.getContext() if null
* @param inheritThreadLocals if {@code true}, inherit initial values for
* inheritable thread-locals from the constructing thread
*/ */
private void init(ThreadGroup g, Runnable target, String name, private void init(ThreadGroup g, Runnable target, String name,
long stackSize, AccessControlContext acc) { long stackSize, AccessControlContext acc,
boolean inheritThreadLocals) {
if (name == null) { if (name == null) {
throw new NullPointerException("name cannot be null"); throw new NullPointerException("name cannot be null");
} }
...@@ -412,7 +415,7 @@ class Thread implements Runnable { ...@@ -412,7 +415,7 @@ class Thread implements Runnable {
acc != null ? acc : AccessController.getContext(); acc != null ? acc : AccessController.getContext();
this.target = target; this.target = target;
setPriority(priority); setPriority(priority);
if (parent.inheritableThreadLocals != null) if (inheritThreadLocals && parent.inheritableThreadLocals != null)
this.inheritableThreadLocals = this.inheritableThreadLocals =
ThreadLocal.createInheritedMap(parent.inheritableThreadLocals); ThreadLocal.createInheritedMap(parent.inheritableThreadLocals);
/* Stash the specified stack size in case the VM cares */ /* Stash the specified stack size in case the VM cares */
...@@ -466,7 +469,7 @@ class Thread implements Runnable { ...@@ -466,7 +469,7 @@ class Thread implements Runnable {
* This is not a public constructor. * This is not a public constructor.
*/ */
Thread(Runnable target, AccessControlContext acc) { Thread(Runnable target, AccessControlContext acc) {
init(null, target, "Thread-" + nextThreadNum(), 0, acc); init(null, target, "Thread-" + nextThreadNum(), 0, acc, false);
} }
/** /**
......
/* /*
* 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) 2009, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2017, 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
...@@ -517,7 +517,8 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -517,7 +517,8 @@ public class FtpClient extends sun.net.ftp.FtpClient {
* @return <code>true</code> if the command was successful * @return <code>true</code> if the command was successful
* @throws IOException * @throws IOException
*/ */
private boolean issueCommand(String cmd) throws IOException { private boolean issueCommand(String cmd) throws IOException,
sun.net.ftp.FtpProtocolException {
if (!isConnected()) { if (!isConnected()) {
throw new IllegalStateException("Not connected"); throw new IllegalStateException("Not connected");
} }
...@@ -528,6 +529,12 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -528,6 +529,12 @@ public class FtpClient extends sun.net.ftp.FtpClient {
// ignore... // ignore...
} }
} }
if (cmd.indexOf('\n') != -1) {
sun.net.ftp.FtpProtocolException ex
= new sun.net.ftp.FtpProtocolException("Illegal FTP command");
ex.initCause(new IllegalArgumentException("Illegal carriage return"));
throw ex;
}
sendServer(cmd + "\r\n"); sendServer(cmd + "\r\n");
return readReply(); return readReply();
} }
...@@ -1120,7 +1127,10 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -1120,7 +1127,10 @@ public class FtpClient extends sun.net.ftp.FtpClient {
*/ */
public void close() throws IOException { public void close() throws IOException {
if (isConnected()) { if (isConnected()) {
issueCommand("QUIT"); try {
issueCommand("QUIT");
} catch (FtpProtocolException e) {
}
loggedIn = false; loggedIn = false;
} }
disconnect(); disconnect();
...@@ -1898,7 +1908,8 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -1898,7 +1908,8 @@ public class FtpClient extends sun.net.ftp.FtpClient {
return null; return null;
} }
private boolean sendSecurityData(byte[] buf) throws IOException { private boolean sendSecurityData(byte[] buf) throws IOException,
sun.net.ftp.FtpProtocolException {
BASE64Encoder encoder = new BASE64Encoder(); BASE64Encoder encoder = new BASE64Encoder();
String s = encoder.encode(buf); String s = encoder.encode(buf);
return issueCommand("ADAT " + s); return issueCommand("ADAT " + s);
......
/* /*
* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2017, 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
...@@ -43,6 +43,7 @@ import sun.net.TransferProtocolClient; ...@@ -43,6 +43,7 @@ import sun.net.TransferProtocolClient;
public class SmtpClient extends TransferProtocolClient { public class SmtpClient extends TransferProtocolClient {
private static int DEFAULT_SMTP_PORT = 25;
String mailhost; String mailhost;
SmtpPrintStream message; SmtpPrintStream message;
...@@ -74,6 +75,10 @@ public class SmtpClient extends TransferProtocolClient { ...@@ -74,6 +75,10 @@ public class SmtpClient extends TransferProtocolClient {
} }
public void to(String s) throws IOException { public void to(String s) throws IOException {
if (s.indexOf('\n') != -1) {
throw new IOException("Illegal SMTP command",
new IllegalArgumentException("Illegal carriage return"));
}
int st = 0; int st = 0;
int limit = s.length(); int limit = s.length();
int pos = 0; int pos = 0;
...@@ -116,16 +121,21 @@ public class SmtpClient extends TransferProtocolClient { ...@@ -116,16 +121,21 @@ public class SmtpClient extends TransferProtocolClient {
} }
public void from(String s) throws IOException { public void from(String s) throws IOException {
if (s.startsWith("<")) if (s.indexOf('\n') != -1) {
throw new IOException("Illegal SMTP command",
new IllegalArgumentException("Illegal carriage return"));
}
if (s.startsWith("<")) {
issueCommand("mail from: " + s + "\r\n", 250); issueCommand("mail from: " + s + "\r\n", 250);
else } else {
issueCommand("mail from: <" + s + ">\r\n", 250); issueCommand("mail from: <" + s + ">\r\n", 250);
}
} }
/** open a SMTP connection to host <i>host</i>. */ /** open a SMTP connection to host <i>host</i>. */
private void openServer(String host) throws IOException { private void openServer(String host) throws IOException {
mailhost = host; mailhost = host;
openServer(mailhost, 25); openServer(mailhost, DEFAULT_SMTP_PORT);
issueCommand("helo "+InetAddress.getLocalHost().getHostName()+"\r\n", 250); issueCommand("helo "+InetAddress.getLocalHost().getHostName()+"\r\n", 250);
} }
......
/* /*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2017, 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,20 @@ public class HttpClient extends NetworkClient { ...@@ -98,7 +98,20 @@ 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;
/* Value of the system property jdk.spnego.cache;
if false, then connections authentified using the Negotiate/Kerberos
scheme will not be cached.
The default value is 'true'. */
private static final boolean cacheSPNEGOProp;
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 +162,12 @@ public class HttpClient extends NetworkClient { ...@@ -149,6 +162,12 @@ 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"));
String cacheSPNEGO = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("jdk.spnego.cache"));
if (keepAlive != null) { if (keepAlive != null) {
keepAliveProp = Boolean.valueOf(keepAlive).booleanValue(); keepAliveProp = Boolean.valueOf(keepAlive).booleanValue();
} else { } else {
...@@ -157,9 +176,21 @@ public class HttpClient extends NetworkClient { ...@@ -157,9 +176,21 @@ 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;
}
if (cacheSPNEGO != null) {
cacheSPNEGOProp = Boolean.parseBoolean(cacheSPNEGO);
} else {
cacheSPNEGOProp = true;
}
} }
/** /**
...@@ -708,6 +739,7 @@ public class HttpClient extends NetworkClient { ...@@ -708,6 +739,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 +768,44 @@ public class HttpClient extends NetworkClient { ...@@ -736,17 +768,44 @@ 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 || cacheSPNEGOProp == false)
&& authenticate != null) {
authenticate = authenticate.toLowerCase(Locale.US);
if (cacheNTLMProp == false) {
canKeepAlive &= !authenticate.startsWith("ntlm ");
}
if (cacheSPNEGOProp == false) {
canKeepAlive &= !authenticate.startsWith("negotiate ");
canKeepAlive &= !authenticate.startsWith("kerberos ");
}
} }
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 +815,7 @@ public class HttpClient extends NetworkClient { ...@@ -756,7 +815,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 +897,7 @@ public class HttpClient extends NetworkClient { ...@@ -838,7 +897,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 +930,7 @@ public class HttpClient extends NetworkClient { ...@@ -871,7 +930,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
...@@ -893,7 +952,11 @@ public class HttpClient extends NetworkClient { ...@@ -893,7 +952,11 @@ public class HttpClient extends NetworkClient {
pi.setContentType(responses.findValue("content-type")); pi.setContentType(responses.findValue("content-type"));
} }
if (isKeepingAlive()) { // If disableKeepAlive == true, the client will not be returned
// to the cache. But we still need to use a keepalive stream to
// allow the multi-message authentication exchange on the connection
boolean useKeepAliveStream = isKeepingAlive() || disableKeepAlive;
if (useKeepAliveStream) {
// Wrap KeepAliveStream if keep alive is enabled. // Wrap KeepAliveStream if keep alive is enabled.
logFinest("KeepAlive stream used: " + url); logFinest("KeepAlive stream used: " + url);
serverInput = new KeepAliveStream(serverInput, pi, cl, this); serverInput = new KeepAliveStream(serverInput, pi, cl, this);
......
/* /*
* Copyright (c) 1994, 2010, 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
...@@ -298,6 +298,13 @@ public class FtpURLConnection extends URLConnection { ...@@ -298,6 +298,13 @@ public class FtpURLConnection extends URLConnection {
// Just keep throwing for now. // Just keep throwing for now.
throw e; throw e;
} catch (FtpProtocolException fe) { } catch (FtpProtocolException fe) {
if (ftp != null) {
try {
ftp.close();
} catch (IOException ioe) {
fe.addSuppressed(ioe);
}
}
throw new IOException(fe); throw new IOException(fe);
} }
try { try {
...@@ -480,11 +487,34 @@ public class FtpURLConnection extends URLConnection { ...@@ -480,11 +487,34 @@ public class FtpURLConnection extends URLConnection {
msgh.add("content-type", "text/plain"); msgh.add("content-type", "text/plain");
msgh.add("access-type", "directory"); msgh.add("access-type", "directory");
} catch (IOException ex) { } catch (IOException ex) {
throw new FileNotFoundException(fullpath); FileNotFoundException fnfe = new FileNotFoundException(fullpath);
if (ftp != null) {
try {
ftp.close();
} catch (IOException ioe) {
fnfe.addSuppressed(ioe);
}
}
throw fnfe;
} catch (FtpProtocolException ex2) { } catch (FtpProtocolException ex2) {
throw new FileNotFoundException(fullpath); FileNotFoundException fnfe = new FileNotFoundException(fullpath);
if (ftp != null) {
try {
ftp.close();
} catch (IOException ioe) {
fnfe.addSuppressed(ioe);
}
}
throw fnfe;
} }
} catch (FtpProtocolException ftpe) { } catch (FtpProtocolException ftpe) {
if (ftp != null) {
try {
ftp.close();
} catch (IOException ioe) {
ftpe.addSuppressed(ioe);
}
}
throw new IOException(ftpe); throw new IOException(ftpe);
} }
setProperties(msgh); setProperties(msgh);
......
/* /*
* 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, 2017, 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
...@@ -34,6 +34,7 @@ import sun.net.www.HeaderParser; ...@@ -34,6 +34,7 @@ import sun.net.www.HeaderParser;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE; import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
import static sun.net.www.protocol.http.AuthScheme.KERBEROS; import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
import sun.security.action.GetPropertyAction;
/** /**
* NegotiateAuthentication: * NegotiateAuthentication:
...@@ -52,10 +53,18 @@ class NegotiateAuthentication extends AuthenticationInfo { ...@@ -52,10 +53,18 @@ class NegotiateAuthentication extends AuthenticationInfo {
// These maps are used to manage the GSS availability for diffrent // These maps are used to manage the GSS availability for diffrent
// hosts. The key for both maps is the host name. // hosts. The key for both maps is the host name.
// <code>supported</code> is set when isSupported is checked, // <code>supported</code> is set when isSupported is checked,
// if it's true, a cached Negotiator is put into <code>cache</code>. // if it's true, a cached Negotiator is put into <code>cache</code>.
// the cache can be used only once, so after the first use, it's cleaned. // the cache can be used only once, so after the first use, it's cleaned.
static HashMap <String, Boolean> supported = null; static HashMap <String, Boolean> supported = null;
static HashMap <String, Negotiator> cache = null; static ThreadLocal <HashMap <String, Negotiator>> cache = null;
/* Whether cache is enabled for Negotiate/Kerberos */
private static final boolean cacheSPNEGO;
static {
String spnegoCacheProp = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("jdk.spnego.cache", "true"));
cacheSPNEGO = Boolean.parseBoolean(spnegoCacheProp);
}
// The HTTP Negotiate Helper // The HTTP Negotiate Helper
private Negotiator negotiator = null; private Negotiator negotiator = null;
...@@ -118,8 +127,7 @@ class NegotiateAuthentication extends AuthenticationInfo { ...@@ -118,8 +127,7 @@ class NegotiateAuthentication extends AuthenticationInfo {
*/ */
private static synchronized boolean isSupportedImpl(HttpCallerInfo hci) { private static synchronized boolean isSupportedImpl(HttpCallerInfo hci) {
if (supported == null) { if (supported == null) {
supported = new HashMap <String, Boolean>(); supported = new HashMap<>();
cache = new HashMap <String, Negotiator>();
} }
String hostname = hci.host; String hostname = hci.host;
hostname = hostname.toLowerCase(); hostname = hostname.toLowerCase();
...@@ -132,7 +140,15 @@ class NegotiateAuthentication extends AuthenticationInfo { ...@@ -132,7 +140,15 @@ class NegotiateAuthentication extends AuthenticationInfo {
supported.put(hostname, true); supported.put(hostname, true);
// the only place cache.put is called. here we can make sure // the only place cache.put is called. here we can make sure
// the object is valid and the oneToken inside is not null // the object is valid and the oneToken inside is not null
cache.put(hostname, neg); if (cache == null) {
cache = new ThreadLocal<HashMap<String, Negotiator>>() {
@Override
protected HashMap<String, Negotiator> initialValue() {
return new HashMap<>();
}
};
}
cache.get().put(hostname, neg);
return true; return true;
} else { } else {
supported.put(hostname, false); supported.put(hostname, false);
...@@ -140,6 +156,16 @@ class NegotiateAuthentication extends AuthenticationInfo { ...@@ -140,6 +156,16 @@ class NegotiateAuthentication extends AuthenticationInfo {
} }
} }
private static synchronized HashMap<String, Negotiator> getCache() {
if (cache == null) return null;
return cache.get();
}
@Override
protected boolean useAuthCache() {
return super.useAuthCache() && cacheSPNEGO;
}
/** /**
* Not supported. Must use the setHeaders() method * Not supported. Must use the setHeaders() method
*/ */
...@@ -197,12 +223,11 @@ class NegotiateAuthentication extends AuthenticationInfo { ...@@ -197,12 +223,11 @@ class NegotiateAuthentication extends AuthenticationInfo {
*/ */
private byte[] firstToken() throws IOException { private byte[] firstToken() throws IOException {
negotiator = null; negotiator = null;
if (cache != null) { HashMap <String, Negotiator> cachedMap = getCache();
synchronized(cache) { if (cachedMap != null) {
negotiator = cache.get(getHost()); negotiator = cachedMap.get(getHost());
if (negotiator != null) { if (negotiator != null) {
cache.remove(getHost()); // so that it is only used once cachedMap.remove(getHost()); // so that it is only used once
}
} }
} }
if (negotiator == null) { if (negotiator == null) {
......
/* /*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2017, 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
...@@ -134,15 +134,15 @@ public class Resources_ja extends java.util.ListResourceBundle { ...@@ -134,15 +134,15 @@ public class Resources_ja extends java.util.ListResourceBundle {
" X =\u6307\u5B9A\u3057\u305F\u5225\u540D\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u307E\u305B\u3093"}, " X =\u6307\u5B9A\u3057\u305F\u5225\u540D\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u307E\u305B\u3093"},
{"no.manifest.", "\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3002"}, {"no.manifest.", "\u30DE\u30CB\u30D5\u30A7\u30B9\u30C8\u306F\u5B58\u5728\u3057\u307E\u305B\u3093\u3002"},
{".Signature.related.entries.","(\u30B7\u30B0\u30CD\u30C1\u30E3\u95A2\u9023\u30A8\u30F3\u30C8\u30EA)"}, {".Signature.related.entries.","(\u30B7\u30B0\u30CD\u30C1\u30E3\u95A2\u9023\u30A8\u30F3\u30C8\u30EA)"},
{".Unsigned.entries.", "(\u672A\u7F72\u540D\u306E\u30A8\u30F3\u30C8\u30EA)"}, {".Unsigned.entries.", "(\u7F72\u540D\u306A\u3057\u306E\u30A8\u30F3\u30C8\u30EA)"},
{"jar.is.unsigned", {"jar.is.unsigned",
"jar\u306F\u7F72\u540D\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"}, "jar\u306F\u7F72\u540D\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002"},
{"jar.treated.unsigned", {"jar.treated.unsigned",
"\u8B66\u544A: \u7F72\u540D\u304C\u69CB\u6587\u89E3\u6790\u3067\u304D\u306A\u3044\u304B\u691C\u8A3C\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u3053\u306Ejar\u306F\u672A\u7F72\u540D\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\u3002\u8A73\u7D30\u306F\u3001\u30C7\u30D0\u30C3\u30B0\u3092\u6709\u52B9\u306B\u3057\u3066(-J-Djava.security.debug=jar) jarsigner\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, "\u8B66\u544A: \u7F72\u540D\u304C\u69CB\u6587\u89E3\u6790\u3067\u304D\u306A\u3044\u304B\u691C\u8A3C\u3067\u304D\u306A\u3044\u305F\u3081\u3001\u3053\u306Ejar\u306F\u7F72\u540D\u306A\u3057\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\u3002\u8A73\u7D30\u306F\u3001\u30C7\u30D0\u30C3\u30B0\u3092\u6709\u52B9\u306B\u3057\u3066(-J-Djava.security.debug=jar) jarsigner\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"},
{"jar.treated.unsigned.see.weak", {"jar.treated.unsigned.see.weak",
"\u3053\u306Ejar\u306F\u3001\u73FE\u5728\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u5F31\u3044\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u672A\u7F72\u540D\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\u3002\n\n\u8A73\u7D30\u306F\u3001-verbose\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066jarsigner\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}, "\u3053\u306Ejar\u306F\u3001\u73FE\u5728\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u5F31\u3044\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u7F72\u540D\u306A\u3057\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059\u3002\n\n\u8A73\u7D30\u306F\u3001-verbose\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066jarsigner\u3092\u518D\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002"},
{"jar.treated.unsigned.see.weak.verbose", {"jar.treated.unsigned.see.weak.verbose",
"\u8B66\u544A: \u3053\u306Ejar\u306F\u3001\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u30FB\u30D7\u30ED\u30D1\u30C6\u30A3\u306B\u3088\u3063\u3066\u73FE\u5728\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u5F31\u3044\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u672A\u7F72\u540D\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059:"}, "\u8B66\u544A: \u3053\u306Ejar\u306F\u3001\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u30FB\u30D7\u30ED\u30D1\u30C6\u30A3\u306B\u3088\u3063\u3066\u73FE\u5728\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u308B\u5F31\u3044\u30A2\u30EB\u30B4\u30EA\u30BA\u30E0\u3067\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u7F72\u540D\u306A\u3057\u3068\u3057\u3066\u6271\u308F\u308C\u307E\u3059:"},
{"jar.signed.", "jar\u306F\u7F72\u540D\u3055\u308C\u307E\u3057\u305F\u3002"}, {"jar.signed.", "jar\u306F\u7F72\u540D\u3055\u308C\u307E\u3057\u305F\u3002"},
{"jar.signed.with.signer.errors.", "jar\u306F\u7F72\u540D\u3055\u308C\u307E\u3057\u305F - \u7F72\u540D\u8005\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059\u3002"}, {"jar.signed.with.signer.errors.", "jar\u306F\u7F72\u540D\u3055\u308C\u307E\u3057\u305F - \u7F72\u540D\u8005\u30A8\u30E9\u30FC\u304C\u3042\u308A\u307E\u3059\u3002"},
{"jar.verified.", "jar\u304C\u691C\u8A3C\u3055\u308C\u307E\u3057\u305F\u3002"}, {"jar.verified.", "jar\u304C\u691C\u8A3C\u3055\u308C\u307E\u3057\u305F\u3002"},
...@@ -215,7 +215,7 @@ public class Resources_ja extends java.util.ListResourceBundle { ...@@ -215,7 +215,7 @@ public class Resources_ja extends java.util.ListResourceBundle {
{"Warning.", "\u8B66\u544A: "}, {"Warning.", "\u8B66\u544A: "},
{"Error.", "\u30A8\u30E9\u30FC: "}, {"Error.", "\u30A8\u30E9\u30FC: "},
{"This.jar.contains.unsigned.entries.which.have.not.been.integrity.checked.", {"This.jar.contains.unsigned.entries.which.have.not.been.integrity.checked.",
"\u3053\u306Ejar\u306B\u306F\u3001\u6574\u5408\u6027\u30C1\u30A7\u30C3\u30AF\u3092\u3057\u3066\u3044\u306A\u3044\u672A\u7F72\u540D\u306E\u30A8\u30F3\u30C8\u30EA\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059\u3002 "}, "\u3053\u306Ejar\u306B\u306F\u3001\u6574\u5408\u6027\u30C1\u30A7\u30C3\u30AF\u3092\u3057\u3066\u3044\u306A\u3044\u7F72\u540D\u306A\u3057\u306E\u30A8\u30F3\u30C8\u30EA\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059\u3002 "},
{"This.jar.contains.entries.whose.signer.certificate.has.expired.", {"This.jar.contains.entries.whose.signer.certificate.has.expired.",
"\u3053\u306Ejar\u306B\u306F\u3001\u7F72\u540D\u8005\u306E\u8A3C\u660E\u66F8\u304C\u671F\u9650\u5207\u308C\u306E\u30A8\u30F3\u30C8\u30EA\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059\u3002 "}, "\u3053\u306Ejar\u306B\u306F\u3001\u7F72\u540D\u8005\u306E\u8A3C\u660E\u66F8\u304C\u671F\u9650\u5207\u308C\u306E\u30A8\u30F3\u30C8\u30EA\u304C\u542B\u307E\u308C\u3066\u3044\u307E\u3059\u3002 "},
{"This.jar.contains.entries.whose.signer.certificate.will.expire.within.six.months.", {"This.jar.contains.entries.whose.signer.certificate.will.expire.within.six.months.",
......
/* /*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2017, 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
...@@ -142,7 +142,7 @@ public class Resources_zh_CN extends java.util.ListResourceBundle { ...@@ -142,7 +142,7 @@ public class Resources_zh_CN extends java.util.ListResourceBundle {
{"jar.treated.unsigned.see.weak", {"jar.treated.unsigned.see.weak",
"\u7531\u4E8E\u8BE5 jar \u662F\u4F7F\u7528\u76EE\u524D\u5DF2\u7981\u7528\u7684\u5F31\u7B97\u6CD5\u7B7E\u540D\u7684, \u56E0\u6B64\u8BE5 jar \u5C06\u88AB\u89C6\u4E3A\u672A\u7B7E\u540D\u3002\n\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u4F7F\u7528 -verbose \u9009\u9879\u91CD\u65B0\u8FD0\u884C jarsigner\u3002"}, "\u7531\u4E8E\u8BE5 jar \u662F\u4F7F\u7528\u76EE\u524D\u5DF2\u7981\u7528\u7684\u5F31\u7B97\u6CD5\u7B7E\u540D\u7684, \u56E0\u6B64\u8BE5 jar \u5C06\u88AB\u89C6\u4E3A\u672A\u7B7E\u540D\u3002\n\n\u6709\u5173\u8BE6\u7EC6\u4FE1\u606F, \u8BF7\u4F7F\u7528 -verbose \u9009\u9879\u91CD\u65B0\u8FD0\u884C jarsigner\u3002"},
{"jar.treated.unsigned.see.weak.verbose", {"jar.treated.unsigned.see.weak.verbose",
"\u8B66\u544A: \u7531\u4E8E\u8BE5 jar \u662F\u4F7F\u7528\u76EE\u524D\u5DF2\u7531\u5B89\u5168\u5C5E\u6027\u7981\u7528\u7684\u5F31\u7B97\u6CD5\u7B7E\u540D\u7684, \u56E0\u6B64\u8BE5 jar \u5C06\u88AB\u89C6\u4E3A\u672A\u7B7E\u540D:"}, "\u8B66\u544A: \u8BE5 jar \u5C06\u88AB\u89C6\u4E3A\u672A\u7B7E\u540D, \u56E0\u4E3A\u5B83\u662F\u7531\u76EE\u524D\u5B89\u5168\u5C5E\u6027\u7981\u7528\u7684\u5F31\u7B97\u6CD5\u7B7E\u540D\u7684:"},
{"jar.signed.", "jar \u5DF2\u7B7E\u540D\u3002"}, {"jar.signed.", "jar \u5DF2\u7B7E\u540D\u3002"},
{"jar.signed.with.signer.errors.", "jar \u5DF2\u7B7E\u540D, \u4F46\u51FA\u73B0\u7B7E\u540D\u8005\u9519\u8BEF\u3002"}, {"jar.signed.with.signer.errors.", "jar \u5DF2\u7B7E\u540D, \u4F46\u51FA\u73B0\u7B7E\u540D\u8005\u9519\u8BEF\u3002"},
{"jar.verified.", "jar \u5DF2\u9A8C\u8BC1\u3002"}, {"jar.verified.", "jar \u5DF2\u9A8C\u8BC1\u3002"},
......
/* /*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2017, 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
...@@ -68,7 +68,7 @@ public class Resources_sv extends java.util.ListResourceBundle { ...@@ -68,7 +68,7 @@ public class Resources_sv extends java.util.ListResourceBundle {
"Kan inte \u00F6ppna policyfilen: {0}: {1}"}, "Kan inte \u00F6ppna policyfilen: {0}: {1}"},
{"Policy.Tool", "Policyverktyg"}, {"Policy.Tool", "Policyverktyg"},
{"Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.", {"Errors.have.occurred.while.opening.the.policy.configuration.View.the.Warning.Log.for.more.information.",
"Det uppstod ett fel n\u00E4r policykonfigurationen skulle \u00F6ppnas. Se varningsloggen f\u00F6r mer information."}, "Ett fel intr\u00E4ffade n\u00E4r policykonfigurationen skulle \u00F6ppnas. Se varningsloggen f\u00F6r mer information."},
{"Error", "Fel"}, {"Error", "Fel"},
{"OK", "OK"}, {"OK", "OK"},
{"Status", "Status"}, {"Status", "Status"},
...@@ -80,7 +80,7 @@ public class Resources_sv extends java.util.ListResourceBundle { ...@@ -80,7 +80,7 @@ public class Resources_sv extends java.util.ListResourceBundle {
{"Target.Name.", {"Target.Name.",
"M\u00E5l: "}, "M\u00E5l: "},
{"Actions.", {"Actions.",
"Funktioner: "}, "\u00C5tg\u00E4rder: "},
{"OK.to.overwrite.existing.file.filename.", {"OK.to.overwrite.existing.file.filename.",
"Ska den befintliga filen {0} skrivas \u00F6ver?"}, "Ska den befintliga filen {0} skrivas \u00F6ver?"},
{"Cancel", "Avbryt"}, {"Cancel", "Avbryt"},
...@@ -94,10 +94,10 @@ public class Resources_sv extends java.util.ListResourceBundle { ...@@ -94,10 +94,10 @@ public class Resources_sv extends java.util.ListResourceBundle {
{".Edit.Permission", " Re&digera beh\u00F6righet"}, {".Edit.Permission", " Re&digera beh\u00F6righet"},
{"Remove.Permission", "Ta &bort beh\u00F6righet"}, {"Remove.Permission", "Ta &bort beh\u00F6righet"},
{"Done", "Utf\u00F6rd"}, {"Done", "Utf\u00F6rd"},
{"KeyStore.URL.", "KeyStore-&URL:"}, {"KeyStore.URL.", "Nyckellager-&URL:"},
{"KeyStore.Type.", "KeyStore-&typ:"}, {"KeyStore.Type.", "Nyckellager&typ:"},
{"KeyStore.Provider.", "KeyStore-&leverant\u00F6r:"}, {"KeyStore.Provider.", "Nyckellager&leverant\u00F6r:"},
{"KeyStore.Password.URL.", "KeyStore-l\u00F6sen&ords-URL:"}, {"KeyStore.Password.URL.", "L\u00F6sen&ords-URL till nyckellager:"},
{"Principals", "Identitetshavare"}, {"Principals", "Identitetshavare"},
{".Edit.Principal.", " Redigera identitetshavare:"}, {".Edit.Principal.", " Redigera identitetshavare:"},
{".Add.New.Principal.", " L\u00E4gg till ny identitetshavare:"}, {".Add.New.Principal.", " L\u00E4gg till ny identitetshavare:"},
......
/* /*
* Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 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
......
# #
# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1999, 2017, 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
...@@ -30,7 +30,7 @@ error.bad.cflag=f\u00F6r c-flaggan m\u00E5ste manifest- eller indatafiler anges. ...@@ -30,7 +30,7 @@ error.bad.cflag=f\u00F6r c-flaggan m\u00E5ste manifest- eller indatafiler anges.
error.bad.uflag=f\u00F6r u-flaggan m\u00E5ste manifest-, e-flagg- eller indatafiler anges. error.bad.uflag=f\u00F6r u-flaggan m\u00E5ste manifest-, e-flagg- eller indatafiler anges.
error.bad.eflag=e-flaggan och manifest med attributet Main-Class kan inte anges \ntillsammans. error.bad.eflag=e-flaggan och manifest med attributet Main-Class kan inte anges \ntillsammans.
error.nosuch.fileordir={0} : det finns ingen s\u00E5dan fil eller katalog error.nosuch.fileordir={0} : det finns ingen s\u00E5dan fil eller katalog
error.write.file=Det uppstod ett fel vid skrivning till befintlig jar-fil. error.write.file=Ett fel intr\u00E4ffade vid skrivning till befintlig jar-fil.
error.create.dir={0} : kunde inte skapa n\u00E5gon katalog error.create.dir={0} : kunde inte skapa n\u00E5gon katalog
error.incorrect.length=ogiltig l\u00E4ngd vid bearbetning: {0} error.incorrect.length=ogiltig l\u00E4ngd vid bearbetning: {0}
error.create.tempfile=Kunde inte skapa en tillf\u00E4llig fil error.create.tempfile=Kunde inte skapa en tillf\u00E4llig fil
......
...@@ -484,21 +484,21 @@ krb5.kdc.bad.policy = tryLast ...@@ -484,21 +484,21 @@ krb5.kdc.bad.policy = tryLast
# jdkCA # jdkCA
# This constraint prohibits the specified algorithm only if the # This constraint prohibits the specified algorithm only if the
# algorithm is used in a certificate chain that terminates at a marked # algorithm is used in a certificate chain that terminates at a marked
# trust anchor in the lib/security/cacerts keystore. If the jdkCA # trust anchor in the??lib/security/cacerts keystore. If the jdkCA
# constraint is not set, then all chains using the specified algorithm # constraint is not set, then all chains using the??specified algorithm
# are restricted. jdkCA may only be used once in a DisabledAlgorithm # are restricted. jdkCA may only be used once in a DisabledAlgorithm
# expression. # expression.
# Example:  To apply this constraint to SHA-1 certificates, include # Example: ??To apply this constraint to SHA-1 certificates, include
# the following:  "SHA1 jdkCA" # the following: ??"SHA1 jdkCA"
# #
# DenyAfterConstraint: # DenyAfterConstraint:
# denyAfter YYYY-MM-DD # denyAfter YYYY-MM-DD
# This constraint prohibits a certificate with the specified algorithm # This constraint prohibits a certificate with the specified algorithm
# from being used after the date regardless of the certificate's # from being used after the date regardless of the certificate's
# validity.  JAR files that are signed and timestamped before the # validity. ??JAR files that are signed and timestamped before the
# constraint date with certificates containing the disabled algorithm # constraint date with certificates containing the disabled algorithm
# will not be restricted.  The date is processed in the UTC timezone. # will not be restricted. ??The date is processed in the UTC timezone.
# This constraint can only be used once in a DisabledAlgorithm # This??constraint can only be used once in a DisabledAlgorithm
# expression. # expression.
# Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020, # Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020,
# use the following: "RSA keySize == 2048 & denyAfter 2020-02-03" # use the following: "RSA keySize == 2048 & denyAfter 2020-02-03"
......
...@@ -484,21 +484,21 @@ krb5.kdc.bad.policy = tryLast ...@@ -484,21 +484,21 @@ krb5.kdc.bad.policy = tryLast
# jdkCA # jdkCA
# This constraint prohibits the specified algorithm only if the # This constraint prohibits the specified algorithm only if the
# algorithm is used in a certificate chain that terminates at a marked # algorithm is used in a certificate chain that terminates at a marked
# trust anchor in the lib/security/cacerts keystore. If the jdkCA # trust anchor in the??lib/security/cacerts keystore. If the jdkCA
# constraint is not set, then all chains using the specified algorithm # constraint is not set, then all chains using the??specified algorithm
# are restricted. jdkCA may only be used once in a DisabledAlgorithm # are restricted. jdkCA may only be used once in a DisabledAlgorithm
# expression. # expression.
# Example:  To apply this constraint to SHA-1 certificates, include # Example: ??To apply this constraint to SHA-1 certificates, include
# the following:  "SHA1 jdkCA" # the following: ??"SHA1 jdkCA"
# #
# DenyAfterConstraint: # DenyAfterConstraint:
# denyAfter YYYY-MM-DD # denyAfter YYYY-MM-DD
# This constraint prohibits a certificate with the specified algorithm # This constraint prohibits a certificate with the specified algorithm
# from being used after the date regardless of the certificate's # from being used after the date regardless of the certificate's
# validity.  JAR files that are signed and timestamped before the # validity. ??JAR files that are signed and timestamped before the
# constraint date with certificates containing the disabled algorithm # constraint date with certificates containing the disabled algorithm
# will not be restricted.  The date is processed in the UTC timezone. # will not be restricted. ??The date is processed in the UTC timezone.
# This constraint can only be used once in a DisabledAlgorithm # This??constraint can only be used once in a DisabledAlgorithm
# expression. # expression.
# Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020, # Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020,
# use the following: "RSA keySize == 2048 & denyAfter 2020-02-03" # use the following: "RSA keySize == 2048 & denyAfter 2020-02-03"
......
...@@ -487,21 +487,21 @@ krb5.kdc.bad.policy = tryLast ...@@ -487,21 +487,21 @@ krb5.kdc.bad.policy = tryLast
# jdkCA # jdkCA
# This constraint prohibits the specified algorithm only if the # This constraint prohibits the specified algorithm only if the
# algorithm is used in a certificate chain that terminates at a marked # algorithm is used in a certificate chain that terminates at a marked
# trust anchor in the lib/security/cacerts keystore. If the jdkCA # trust anchor in the??lib/security/cacerts keystore. If the jdkCA
# constraint is not set, then all chains using the specified algorithm # constraint is not set, then all chains using the??specified algorithm
# are restricted. jdkCA may only be used once in a DisabledAlgorithm # are restricted. jdkCA may only be used once in a DisabledAlgorithm
# expression. # expression.
# Example:  To apply this constraint to SHA-1 certificates, include # Example: ??To apply this constraint to SHA-1 certificates, include
# the following:  "SHA1 jdkCA" # the following: ??"SHA1 jdkCA"
# #
# DenyAfterConstraint: # DenyAfterConstraint:
# denyAfter YYYY-MM-DD # denyAfter YYYY-MM-DD
# This constraint prohibits a certificate with the specified algorithm # This constraint prohibits a certificate with the specified algorithm
# from being used after the date regardless of the certificate's # from being used after the date regardless of the certificate's
# validity.  JAR files that are signed and timestamped before the # validity. ??JAR files that are signed and timestamped before the
# constraint date with certificates containing the disabled algorithm # constraint date with certificates containing the disabled algorithm
# will not be restricted.  The date is processed in the UTC timezone. # will not be restricted. ??The date is processed in the UTC timezone.
# This constraint can only be used once in a DisabledAlgorithm # This??constraint can only be used once in a DisabledAlgorithm
# expression. # expression.
# Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020, # Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020,
# use the following: "RSA keySize == 2048 & denyAfter 2020-02-03" # use the following: "RSA keySize == 2048 & denyAfter 2020-02-03"
......
...@@ -486,21 +486,21 @@ krb5.kdc.bad.policy = tryLast ...@@ -486,21 +486,21 @@ krb5.kdc.bad.policy = tryLast
# jdkCA # jdkCA
# This constraint prohibits the specified algorithm only if the # This constraint prohibits the specified algorithm only if the
# algorithm is used in a certificate chain that terminates at a marked # algorithm is used in a certificate chain that terminates at a marked
# trust anchor in the lib/security/cacerts keystore. If the jdkCA # trust anchor in the??lib/security/cacerts keystore. If the jdkCA
# constraint is not set, then all chains using the specified algorithm # constraint is not set, then all chains using the??specified algorithm
# are restricted. jdkCA may only be used once in a DisabledAlgorithm # are restricted. jdkCA may only be used once in a DisabledAlgorithm
# expression. # expression.
# Example:  To apply this constraint to SHA-1 certificates, include # Example: ??To apply this constraint to SHA-1 certificates, include
# the following:  "SHA1 jdkCA" # the following: ??"SHA1 jdkCA"
# #
# DenyAfterConstraint: # DenyAfterConstraint:
# denyAfter YYYY-MM-DD # denyAfter YYYY-MM-DD
# This constraint prohibits a certificate with the specified algorithm # This constraint prohibits a certificate with the specified algorithm
# from being used after the date regardless of the certificate's # from being used after the date regardless of the certificate's
# validity.  JAR files that are signed and timestamped before the # validity. ??JAR files that are signed and timestamped before the
# constraint date with certificates containing the disabled algorithm # constraint date with certificates containing the disabled algorithm
# will not be restricted.  The date is processed in the UTC timezone. # will not be restricted. ??The date is processed in the UTC timezone.
# This constraint can only be used once in a DisabledAlgorithm # This??constraint can only be used once in a DisabledAlgorithm
# expression. # expression.
# Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020, # Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020,
# use the following: "RSA keySize == 2048 & denyAfter 2020-02-03" # use the following: "RSA keySize == 2048 & denyAfter 2020-02-03"
......
...@@ -487,21 +487,21 @@ krb5.kdc.bad.policy = tryLast ...@@ -487,21 +487,21 @@ krb5.kdc.bad.policy = tryLast
# jdkCA # jdkCA
# This constraint prohibits the specified algorithm only if the # This constraint prohibits the specified algorithm only if the
# algorithm is used in a certificate chain that terminates at a marked # algorithm is used in a certificate chain that terminates at a marked
# trust anchor in the lib/security/cacerts keystore. If the jdkCA # trust anchor in the??lib/security/cacerts keystore. If the jdkCA
# constraint is not set, then all chains using the specified algorithm # constraint is not set, then all chains using the??specified algorithm
# are restricted. jdkCA may only be used once in a DisabledAlgorithm # are restricted. jdkCA may only be used once in a DisabledAlgorithm
# expression. # expression.
# Example:  To apply this constraint to SHA-1 certificates, include # Example: ??To apply this constraint to SHA-1 certificates, include
# the following:  "SHA1 jdkCA" # the following: ??"SHA1 jdkCA"
# #
# DenyAfterConstraint: # DenyAfterConstraint:
# denyAfter YYYY-MM-DD # denyAfter YYYY-MM-DD
# This constraint prohibits a certificate with the specified algorithm # This constraint prohibits a certificate with the specified algorithm
# from being used after the date regardless of the certificate's # from being used after the date regardless of the certificate's
# validity.  JAR files that are signed and timestamped before the # validity. ??JAR files that are signed and timestamped before the
# constraint date with certificates containing the disabled algorithm # constraint date with certificates containing the disabled algorithm
# will not be restricted.  The date is processed in the UTC timezone. # will not be restricted. ??The date is processed in the UTC timezone.
# This constraint can only be used once in a DisabledAlgorithm # This??constraint can only be used once in a DisabledAlgorithm
# expression. # expression.
# Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020, # Example: To deny usage of RSA 2048 bit certificates after Feb 3 2020,
# use the following: "RSA keySize == 2048 & denyAfter 2020-02-03" # use the following: "RSA keySize == 2048 & denyAfter 2020-02-03"
......
/* /*
* 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;
} }
} }
...@@ -71,7 +71,7 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { ...@@ -71,7 +71,7 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer {
enable(false); enable(false);
} }
public void readShortcutLabel() { private void readShortcutLabel() {
//Fix for 6288578: PIT. Windows: Shortcuts displayed for the menuitems in a popup menu //Fix for 6288578: PIT. Windows: Shortcuts displayed for the menuitems in a popup menu
WMenuPeer ancestor = parent; WMenuPeer ancestor = parent;
while (ancestor != null && !(ancestor instanceof WMenuBarPeer)) { while (ancestor != null && !(ancestor instanceof WMenuBarPeer)) {
...@@ -115,7 +115,7 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer { ...@@ -115,7 +115,7 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer {
readShortcutLabel(); readShortcutLabel();
} }
protected void checkMenuCreation() void checkMenuCreation()
{ {
// fix for 5088782: check if menu peer is created successfully // fix for 5088782: check if menu peer is created successfully
if (pData == 0) if (pData == 0)
......
...@@ -34,16 +34,16 @@ abstract class WObjectPeer { ...@@ -34,16 +34,16 @@ abstract class WObjectPeer {
} }
// The Windows handle for the native widget. // The Windows handle for the native widget.
long pData; volatile long pData;
// if the native peer has been destroyed // if the native peer has been destroyed
boolean destroyed = false; private volatile boolean destroyed;
// The associated AWT object. // The associated AWT object.
Object target; volatile Object target;
private volatile boolean disposed; private volatile boolean disposed;
// set from JNI if any errors in creating the peer occur // set from JNI if any errors in creating the peer occur
protected Error createError = null; volatile Error createError = null;
// used to synchronize the state of this peer // used to synchronize the state of this peer
private final Object stateLock = new Object(); private final Object stateLock = new Object();
......
/* /*
* 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
*/ */
......
/* /*
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 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
...@@ -3772,7 +3772,10 @@ void AwtComponent::OpenCandidateWindow(int x, int y) ...@@ -3772,7 +3772,10 @@ void AwtComponent::OpenCandidateWindow(int x, int y)
HWND hWnd = GetHWnd(); HWND hWnd = GetHWnd();
HWND hTop = GetTopLevelParentForWindow(hWnd); HWND hTop = GetTopLevelParentForWindow(hWnd);
::ClientToScreen(hTop, &p); ::ClientToScreen(hTop, &p);
if (!m_bitsCandType) {
SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
return;
}
for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) { for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
if ( m_bitsCandType & bits ) if ( m_bitsCandType & bits )
SetCandidateWindow(iCandType, x - p.x, y - p.y); SetCandidateWindow(iCandType, x - p.x, y - p.y);
...@@ -3790,7 +3793,7 @@ void AwtComponent::SetCandidateWindow(int iCandType, int x, int y) ...@@ -3790,7 +3793,7 @@ void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
HIMC hIMC = ImmGetContext(hwnd); HIMC hIMC = ImmGetContext(hwnd);
CANDIDATEFORM cf; CANDIDATEFORM cf;
cf.dwIndex = iCandType; cf.dwIndex = iCandType;
cf.dwStyle = CFS_CANDIDATEPOS; cf.dwStyle = CFS_POINT;
cf.ptCurrentPos.x = x; cf.ptCurrentPos.x = x;
cf.ptCurrentPos.y = y; cf.ptCurrentPos.y = y;
...@@ -3822,9 +3825,15 @@ MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam) ...@@ -3822,9 +3825,15 @@ MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam)
MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType) MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType)
{ {
if (!m_useNativeCompWindow && subMsg == IMN_OPENCANDIDATE) { if (!m_useNativeCompWindow) {
m_bitsCandType = bitsCandType; if (subMsg == IMN_OPENCANDIDATE) {
InquireCandidatePosition(); m_bitsCandType = subMsg;
InquireCandidatePosition();
} else if (subMsg == IMN_OPENSTATUSWINDOW ||
subMsg == WM_IME_STARTCOMPOSITION) {
m_bitsCandType = 0;
InquireCandidatePosition();
}
return mrConsume; return mrConsume;
} }
return mrDoDefault; return mrDoDefault;
...@@ -4084,14 +4093,14 @@ HWND AwtComponent::GetProxyFocusOwner() ...@@ -4084,14 +4093,14 @@ HWND AwtComponent::GetProxyFocusOwner()
return (HWND)NULL; return (HWND)NULL;
} }
/* Call DefWindowProc for the focus proxy, if any */ /* Redirects message to the focus proxy, if any */
void AwtComponent::CallProxyDefWindowProc(UINT message, WPARAM wParam, void AwtComponent::CallProxyDefWindowProc(UINT message, WPARAM wParam,
LPARAM lParam, LRESULT &retVal, MsgRouting &mr) LPARAM lParam, LRESULT &retVal, MsgRouting &mr)
{ {
if (mr != mrConsume) { if (mr != mrConsume) {
HWND proxy = GetProxyFocusOwner(); HWND proxy = GetProxyFocusOwner();
if (proxy != NULL && ::IsWindowEnabled(proxy)) { if (proxy != NULL && ::IsWindowEnabled(proxy)) {
retVal = ComCtl32Util::GetInstance().DefWindowProc(NULL, proxy, message, wParam, lParam); retVal = ::DefWindowProc(proxy, message, wParam, lParam);
mr = mrConsume; mr = mrConsume;
} }
} }
...@@ -4170,7 +4179,7 @@ MsgRouting AwtComponent::WmDrawItem(UINT ctrlId, DRAWITEMSTRUCT &drawInfo) ...@@ -4170,7 +4179,7 @@ MsgRouting AwtComponent::WmDrawItem(UINT ctrlId, DRAWITEMSTRUCT &drawInfo)
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (drawInfo.CtlType == ODT_MENU) { if (drawInfo.CtlType == ODT_MENU) {
if (drawInfo.itemData != 0) { if (IsMenu((HMENU)drawInfo.hwndItem) && drawInfo.itemData != 0) {
AwtMenu* menu = (AwtMenu*)(drawInfo.itemData); AwtMenu* menu = (AwtMenu*)(drawInfo.itemData);
menu->DrawItem(drawInfo); menu->DrawItem(drawInfo);
} }
......
...@@ -34,6 +34,13 @@ ...@@ -34,6 +34,13 @@
/* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code. /* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code.
*/ */
/***********************************************************************/
// struct for _DelItem() method
struct DelItemStruct {
jobject menuitem;
jint index;
};
/************************************************************************ /************************************************************************
* AwtMenuItem fields * AwtMenuItem fields
*/ */
...@@ -64,7 +71,6 @@ void AwtMenu::Dispose() ...@@ -64,7 +71,6 @@ void AwtMenu::Dispose()
::DestroyMenu(m_hMenu); ::DestroyMenu(m_hMenu);
m_hMenu = NULL; m_hMenu = NULL;
} }
AwtMenuItem::Dispose(); AwtMenuItem::Dispose();
} }
...@@ -73,7 +79,7 @@ LPCTSTR AwtMenu::GetClassName() { ...@@ -73,7 +79,7 @@ LPCTSTR AwtMenu::GetClassName() {
} }
/* Create a new AwtMenu object and menu. */ /* Create a new AwtMenu object and menu. */
AwtMenu* AwtMenu::Create(jobject self, AwtMenu* parentMenu) AwtMenu* AwtMenu::Create(jobject self, jobject parent)
{ {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
...@@ -85,6 +91,9 @@ AwtMenu* AwtMenu::Create(jobject self, AwtMenu* parentMenu) ...@@ -85,6 +91,9 @@ AwtMenu* AwtMenu::Create(jobject self, AwtMenu* parentMenu)
return NULL; return NULL;
} }
JNI_CHECK_NULL_GOTO(parent, "peer", done);
AwtMenu* parentMenu = (AwtMenu*) JNI_GET_PDATA(parent);
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);
...@@ -119,6 +128,46 @@ done: ...@@ -119,6 +128,46 @@ done:
return menu; return menu;
} }
void AwtMenu::_AddSeparator(void *param)
{
if (AwtToolkit::IsMainThread()) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
jobject self = (jobject)param;
AwtMenu *m = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
m = (AwtMenu *)pData;
m->AddSeparator();
ret:
env->DeleteGlobalRef(self);
} else {
AwtToolkit::GetInstance().InvokeFunction(AwtMenu::_AddSeparator, param);
}
}
void AwtMenu::_DelItem(void *param)
{
if (AwtToolkit::IsMainThread()) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
DelItemStruct *dis = (DelItemStruct*) param;
jobject self = dis->menuitem;
jint index = dis->index;
AwtMenu *m = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
m = (AwtMenu *)pData;
m->DeleteItem(static_cast<UINT>(index));
ret:
env->DeleteGlobalRef(self);
delete dis;
} else {
AwtToolkit::GetInstance().InvokeFunction(AwtMenu::_DelItem, param);
}
}
void AwtMenu::UpdateLayout() void AwtMenu::UpdateLayout()
{ {
UpdateLayout(GetHMenu()); UpdateLayout(GetHMenu());
...@@ -239,6 +288,7 @@ AwtMenuItem* AwtMenu::GetItem(jobject target, jint index) ...@@ -239,6 +288,7 @@ AwtMenuItem* AwtMenu::GetItem(jobject target, jint index)
} }
jobject menuItem = env->CallObjectMethod(target, AwtMenu::getItemMID, jobject menuItem = env->CallObjectMethod(target, AwtMenu::getItemMID,
index); index);
if (!menuItem) return NULL; // menu item was removed concurrently
DASSERT(!safe_ExceptionOccurred(env)); DASSERT(!safe_ExceptionOccurred(env));
jobject wMenuItemPeer = GetPeerForTarget(env, menuItem); jobject wMenuItemPeer = GetPeerForTarget(env, menuItem);
...@@ -264,9 +314,9 @@ void AwtMenu::DrawItems(DRAWITEMSTRUCT& drawInfo) ...@@ -264,9 +314,9 @@ void AwtMenu::DrawItems(DRAWITEMSTRUCT& drawInfo)
} }
/* target is a java.awt.Menu */ /* target is a java.awt.Menu */
jobject target = GetTarget(env); jobject target = GetTarget(env);
if(!target || env->ExceptionCheck()) return;
int nCount = CountItem(target); int nCount = CountItem(target);
for (int i = 0; i < nCount; i++) { for (int i = 0; i < nCount && !env->ExceptionCheck(); i++) {
AwtMenuItem* awtMenuItem = GetItem(target, i); AwtMenuItem* awtMenuItem = GetItem(target, i);
if (awtMenuItem != NULL) { if (awtMenuItem != NULL) {
SendDrawItem(awtMenuItem, drawInfo); SendDrawItem(awtMenuItem, drawInfo);
...@@ -294,8 +344,9 @@ void AwtMenu::MeasureItems(HDC hDC, MEASUREITEMSTRUCT& measureInfo) ...@@ -294,8 +344,9 @@ void AwtMenu::MeasureItems(HDC hDC, MEASUREITEMSTRUCT& measureInfo)
} }
/* target is a java.awt.Menu */ /* target is a java.awt.Menu */
jobject target = GetTarget(env); jobject target = GetTarget(env);
if(!target || env->ExceptionCheck()) return;
int nCount = CountItem(target); int nCount = CountItem(target);
for (int i = 0; i < nCount; i++) { for (int i = 0; i < nCount && !env->ExceptionCheck(); i++) {
AwtMenuItem* awtMenuItem = GetItem(target, i); AwtMenuItem* awtMenuItem = GetItem(target, i);
if (awtMenuItem != NULL) { if (awtMenuItem != NULL) {
SendMeasureItem(awtMenuItem, hDC, measureInfo); SendMeasureItem(awtMenuItem, hDC, measureInfo);
...@@ -321,24 +372,6 @@ BOOL AwtMenu::IsTopMenu() ...@@ -321,24 +372,6 @@ BOOL AwtMenu::IsTopMenu()
return (GetMenuBar() == GetMenuContainer()); return (GetMenuBar() == GetMenuContainer());
} }
LRESULT AwtMenu::WinThreadExecProc(ExecuteArgs * args)
{
switch( args->cmdId ) {
case MENU_ADDSEPARATOR:
this->AddSeparator();
break;
case MENU_DELITEM:
this->DeleteItem(static_cast<UINT>(args->param1));
break;
default:
AwtMenuItem::WinThreadExecProc(args);
break;
}
return 0L;
}
/************************************************************************ /************************************************************************
* WMenuPeer native methods * WMenuPeer native methods
*/ */
...@@ -380,15 +413,14 @@ Java_sun_awt_windows_WMenuPeer_addSeparator(JNIEnv *env, jobject self) ...@@ -380,15 +413,14 @@ Java_sun_awt_windows_WMenuPeer_addSeparator(JNIEnv *env, jobject self)
{ {
TRY; TRY;
PDATA pData; jobject selfGlobalRef = env->NewGlobalRef(self);
JNI_CHECK_PEER_RETURN(self);
AwtObject::WinThreadExec(self, AwtMenu::MENU_ADDSEPARATOR); AwtToolkit::GetInstance().SyncCall(AwtMenu::_AddSeparator, selfGlobalRef);
// selfGlobalRef is deleted in _AddSeparator
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
/* /*
* Class: sun_awt_windows_WMenuPeer * Class: sun_awt_windows_WMenuPeer
* Method: delItem * Method: delItem
...@@ -400,10 +432,12 @@ Java_sun_awt_windows_WMenuPeer_delItem(JNIEnv *env, jobject self, ...@@ -400,10 +432,12 @@ Java_sun_awt_windows_WMenuPeer_delItem(JNIEnv *env, jobject self,
{ {
TRY; TRY;
PDATA pData; DelItemStruct *dis = new DelItemStruct;
JNI_CHECK_PEER_RETURN(self); dis->menuitem = env->NewGlobalRef(self);
dis->index = index;
AwtObject::WinThreadExec(self, AwtMenu::MENU_DELITEM, index); AwtToolkit::GetInstance().SyncCall(AwtMenu::_DelItem, dis);
// global refs and dis are deleted in _DelItem
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
...@@ -419,13 +453,8 @@ Java_sun_awt_windows_WMenuPeer_createMenu(JNIEnv *env, jobject self, ...@@ -419,13 +453,8 @@ Java_sun_awt_windows_WMenuPeer_createMenu(JNIEnv *env, jobject self,
{ {
TRY; TRY;
PDATA pData; AwtToolkit::CreateComponent(self, menuBar,
JNI_CHECK_PEER_RETURN(menuBar); (AwtToolkit::ComponentFactory)AwtMenu::Create);
AwtMenuBar* awtMenuBar = (AwtMenuBar *)pData;
AwtToolkit::CreateComponent(self, awtMenuBar,
(AwtToolkit::ComponentFactory)AwtMenu::Create,FALSE);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
...@@ -441,13 +470,8 @@ Java_sun_awt_windows_WMenuPeer_createSubMenu(JNIEnv *env, jobject self, ...@@ -441,13 +470,8 @@ Java_sun_awt_windows_WMenuPeer_createSubMenu(JNIEnv *env, jobject self,
{ {
TRY; TRY;
PDATA pData; AwtToolkit::CreateComponent(self, menu,
JNI_CHECK_PEER_RETURN(menu); (AwtToolkit::ComponentFactory)AwtMenu::Create);
AwtMenu* awtMenu = (AwtMenu *)pData;
AwtToolkit::CreateComponent(self, awtMenu,
(AwtToolkit::ComponentFactory)AwtMenu::Create,FALSE);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
...@@ -42,13 +42,6 @@ class AwtMenuBar; ...@@ -42,13 +42,6 @@ class AwtMenuBar;
class AwtMenu : public AwtMenuItem { class AwtMenu : public AwtMenuItem {
public: public:
// id's for methods executed on toolkit thread
enum {
MENU_ADDSEPARATOR = MENUITEM_LAST+1,
MENU_DELITEM,
MENU_LAST
};
/* method ids for java.awt.Menu */ /* method ids for java.awt.Menu */
static jmethodID countItemsMID; static jmethodID countItemsMID;
static jmethodID getItemMID; static jmethodID getItemMID;
...@@ -61,7 +54,7 @@ public: ...@@ -61,7 +54,7 @@ public:
virtual LPCTSTR GetClassName(); virtual LPCTSTR GetClassName();
/* Create a new AwtMenu. This must be run on the main thread. */ /* Create a new AwtMenu. This must be run on the main thread. */
static AwtMenu* Create(jobject self, AwtMenu* parentMenu); static AwtMenu* Create(jobject self, jobject parent);
INLINE HMENU GetHMenu() { return m_hMenu; } INLINE HMENU GetHMenu() { return m_hMenu; }
INLINE void SetHMenu(HMENU hMenu) { INLINE void SetHMenu(HMENU hMenu) {
...@@ -94,9 +87,9 @@ public: ...@@ -94,9 +87,9 @@ public:
void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo); void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
void MeasureItems(HDC hDC, MEASUREITEMSTRUCT& measureInfo); void MeasureItems(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
// invoked on Toolkit thread // invoked on Toolkit thread
static void _AddSeparator(void *param);
static void _DelItem(void *param);
static void _CreateMenu(void *param); static void _CreateMenu(void *param);
static void _CreateSubMenu(void *param); static void _CreateSubMenu(void *param);
virtual BOOL IsSeparator() { return FALSE; } virtual BOOL IsSeparator() { return FALSE; }
......
...@@ -29,6 +29,12 @@ ...@@ -29,6 +29,12 @@
/* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code. /* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code.
*/ */
/***********************************************************************/
// struct for _DelItem() method
struct DelItemStruct {
jobject menuitem;
jint index;
};
/***********************************************************************/ /***********************************************************************/
// struct for _AddMenu() method // struct for _AddMenu() method
struct AddMenuStruct { struct AddMenuStruct {
...@@ -130,18 +136,6 @@ HWND AwtMenuBar::GetOwnerHWnd() ...@@ -130,18 +136,6 @@ HWND AwtMenuBar::GetOwnerHWnd()
return myFrame->GetHWnd(); return myFrame->GetHWnd();
} }
void AwtMenuBar::SendDrawItem(AwtMenuItem* awtMenuItem,
DRAWITEMSTRUCT& drawInfo)
{
awtMenuItem->DrawItem(drawInfo);
}
void AwtMenuBar::SendMeasureItem(AwtMenuItem* awtMenuItem,
HDC hDC, MEASUREITEMSTRUCT& measureInfo)
{
awtMenuItem->MeasureItem(hDC, measureInfo);
}
int AwtMenuBar::CountItem(jobject menuBar) int AwtMenuBar::CountItem(jobject menuBar)
{ {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
...@@ -159,13 +153,16 @@ AwtMenuItem* AwtMenuBar::GetItem(jobject target, long index) ...@@ -159,13 +153,16 @@ AwtMenuItem* AwtMenuBar::GetItem(jobject target, long index)
} }
jobject menu = env->CallObjectMethod(target, AwtMenuBar::getMenuMID,index); jobject menu = env->CallObjectMethod(target, AwtMenuBar::getMenuMID,index);
if (!menu) return NULL; // menu item was removed concurrently
DASSERT(!safe_ExceptionOccurred(env)); DASSERT(!safe_ExceptionOccurred(env));
jobject menuItemPeer = GetPeerForTarget(env, menu); jobject menuItemPeer = GetPeerForTarget(env, menu);
PDATA pData; PDATA pData;
JNI_CHECK_PEER_RETURN_NULL(menuItemPeer); AwtMenuItem* awtMenuItem = NULL;
AwtMenuItem* awtMenuItem = (AwtMenuItem*)pData; JNI_CHECK_PEER_GOTO(menuItemPeer, done);
awtMenuItem = (AwtMenuItem*)pData;
done:
env->DeleteLocalRef(menu); env->DeleteLocalRef(menu);
env->DeleteLocalRef(menuItemPeer); env->DeleteLocalRef(menuItemPeer);
...@@ -212,20 +209,6 @@ void AwtMenuBar::RedrawMenuBar() { ...@@ -212,20 +209,6 @@ void AwtMenuBar::RedrawMenuBar() {
VERIFY(::DrawMenuBar(GetOwnerHWnd())); VERIFY(::DrawMenuBar(GetOwnerHWnd()));
} }
LRESULT AwtMenuBar::WinThreadExecProc(ExecuteArgs * args)
{
switch( args->cmdId ) {
case MENUBAR_DELITEM:
this->DeleteItem(static_cast<UINT>(args->param1));
break;
default:
AwtMenu::WinThreadExecProc(args);
break;
}
return 0L;
}
void AwtMenuBar::_AddMenu(void *param) void AwtMenuBar::_AddMenu(void *param)
{ {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
...@@ -254,6 +237,28 @@ ret: ...@@ -254,6 +237,28 @@ ret:
delete ams; delete ams;
} }
void AwtMenuBar::_DelItem(void *param)
{
if (AwtToolkit::IsMainThread()) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
DelItemStruct *dis = (DelItemStruct*) param;
jobject self = dis->menuitem;
jint index = dis->index;
AwtMenuBar *m = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
m = (AwtMenuBar *)pData;
m->DeleteItem(static_cast<UINT>(index));
ret:
env->DeleteGlobalRef(self);
delete dis;
} else {
AwtToolkit::GetInstance().InvokeFunction(AwtMenuBar::_DelItem, param);
}
}
/************************************************************************ /************************************************************************
* MenuBar native methods * MenuBar native methods
*/ */
...@@ -322,9 +327,12 @@ Java_sun_awt_windows_WMenuBarPeer_delMenu(JNIEnv *env, jobject self, ...@@ -322,9 +327,12 @@ Java_sun_awt_windows_WMenuBarPeer_delMenu(JNIEnv *env, jobject self,
{ {
TRY; TRY;
PDATA pData; DelItemStruct *dis = new DelItemStruct;
JNI_CHECK_PEER_RETURN(self); dis->menuitem = env->NewGlobalRef(self);
AwtObject::WinThreadExec(self, AwtMenuBar::MENUBAR_DELITEM, (LPARAM)index); dis->index = index;
AwtToolkit::GetInstance().SyncCall(AwtMenuBar::_DelItem, dis);
// global refs and dis are deleted in _DelItem
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
...@@ -343,9 +351,6 @@ Java_sun_awt_windows_WMenuBarPeer_create(JNIEnv *env, jobject self, ...@@ -343,9 +351,6 @@ Java_sun_awt_windows_WMenuBarPeer_create(JNIEnv *env, jobject self,
AwtToolkit::CreateComponent(self, frame, AwtToolkit::CreateComponent(self, frame,
(AwtToolkit::ComponentFactory) (AwtToolkit::ComponentFactory)
AwtMenuBar::Create); AwtMenuBar::Create);
PDATA pData;
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
...@@ -42,10 +42,6 @@ class AwtFrame; ...@@ -42,10 +42,6 @@ class AwtFrame;
class AwtMenuBar : public AwtMenu { class AwtMenuBar : public AwtMenu {
public: public:
// id's for methods executed on toolkit thread
enum MenuExecIds {
MENUBAR_DELITEM = MENU_LAST+1
};
/* java.awt.MenuBar method ids */ /* java.awt.MenuBar method ids */
static jmethodID getMenuCountMID; static jmethodID getMenuCountMID;
...@@ -73,20 +69,15 @@ public: ...@@ -73,20 +69,15 @@ public:
AwtMenuItem* GetItem(jobject target, long index); AwtMenuItem* GetItem(jobject target, long index);
int CountItem(jobject menuBar); int CountItem(jobject menuBar);
void SendDrawItem(AwtMenuItem* awtMenuItem,
DRAWITEMSTRUCT& drawInfo);
void SendMeasureItem(AwtMenuItem* awtMenuItem,
HDC hDC, MEASUREITEMSTRUCT& measureInfo);
void DrawItem(DRAWITEMSTRUCT& drawInfo); void DrawItem(DRAWITEMSTRUCT& drawInfo);
void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo); void MeasureItem(HDC hDC, MEASUREITEMSTRUCT& measureInfo);
void AddItem(AwtMenuItem* item); void AddItem(AwtMenuItem* item);
void DeleteItem(UINT index); void DeleteItem(UINT index);
virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
// called on Toolkit thread // called on Toolkit thread
static void _AddMenu(void *param); static void _AddMenu(void *param);
static void _DelItem(void *param);
protected: protected:
AwtFrame* m_frame; AwtFrame* m_frame;
}; };
......
...@@ -50,6 +50,16 @@ struct SetLabelStruct { ...@@ -50,6 +50,16 @@ struct SetLabelStruct {
jobject menuitem; jobject menuitem;
jstring label; jstring label;
}; };
// struct for _SetEnable() method
struct SetEnableStruct {
jobject menuitem;
jboolean isEnabled;
};
// struct for _setState() method
struct SetStateStruct {
jobject menuitem;
jboolean isChecked;
};
/************************************************************************ /************************************************************************
* AwtMenuItem fields * AwtMenuItem fields
*/ */
...@@ -104,6 +114,7 @@ void AwtMenuItem::RemoveCmdID() ...@@ -104,6 +114,7 @@ void AwtMenuItem::RemoveCmdID()
{ {
if (m_freeId) { if (m_freeId) {
AwtToolkit::GetInstance().RemoveCmdID( GetID() ); AwtToolkit::GetInstance().RemoveCmdID( GetID() );
m_freeId = FALSE;
} }
} }
void AwtMenuItem::Dispose() void AwtMenuItem::Dispose()
...@@ -112,6 +123,7 @@ void AwtMenuItem::Dispose() ...@@ -112,6 +123,7 @@ void AwtMenuItem::Dispose()
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (m_peerObject != NULL) { if (m_peerObject != NULL) {
JNI_SET_DESTROYED(m_peerObject);
JNI_SET_PDATA(m_peerObject, NULL); JNI_SET_PDATA(m_peerObject, NULL);
env->DeleteGlobalRef(m_peerObject); env->DeleteGlobalRef(m_peerObject);
m_peerObject = NULL; m_peerObject = NULL;
...@@ -205,13 +217,12 @@ AwtMenuItem* AwtMenuItem::Create(jobject peer, jobject menuPeer) ...@@ -205,13 +217,12 @@ AwtMenuItem* AwtMenuItem::Create(jobject peer, jobject menuPeer)
if (env->EnsureLocalCapacity(1) < 0) { if (env->EnsureLocalCapacity(1) < 0) {
return NULL; return NULL;
} }
PDATA pData; JNI_CHECK_NULL_RETURN_NULL(menuPeer, "peer");
JNI_CHECK_PEER_RETURN_NULL(menuPeer);
/* target is a java.awt.MenuItem */ /* target is a java.awt.MenuItem */
target = env->GetObjectField(peer, AwtObject::targetID); target = env->GetObjectField(peer, AwtObject::targetID);
AwtMenu* menu = (AwtMenu *)pData; AwtMenu* menu = (AwtMenu *)JNI_GET_PDATA(menuPeer);
item = new AwtMenuItem(); item = new AwtMenuItem();
jboolean isCheckbox = jboolean isCheckbox =
(jboolean)env->GetBooleanField(peer, AwtMenuItem::isCheckboxID); (jboolean)env->GetBooleanField(peer, AwtMenuItem::isCheckboxID);
...@@ -222,7 +233,9 @@ AwtMenuItem* AwtMenuItem::Create(jobject peer, jobject menuPeer) ...@@ -222,7 +233,9 @@ AwtMenuItem* AwtMenuItem::Create(jobject peer, jobject menuPeer)
item->LinkObjects(env, peer); item->LinkObjects(env, peer);
item->SetMenuContainer(menu); item->SetMenuContainer(menu);
item->SetNewID(); item->SetNewID();
menu->AddItem(item); if (menu != NULL) {
menu->AddItem(item);
}
} catch (...) { } catch (...) {
env->DeleteLocalRef(target); env->DeleteLocalRef(target);
throw; throw;
...@@ -763,30 +776,6 @@ void AwtMenuItem::UpdateContainerLayout() { ...@@ -763,30 +776,6 @@ void AwtMenuItem::UpdateContainerLayout() {
} }
} }
LRESULT AwtMenuItem::WinThreadExecProc(ExecuteArgs * args)
{
switch( args->cmdId ) {
case MENUITEM_ENABLE:
{
BOOL isEnabled = (BOOL)args->param1;
this->Enable(isEnabled);
}
break;
case MENUITEM_SETSTATE:
{
BOOL isChecked = (BOOL)args->param1;
this->SetState(isChecked);
}
break;
default:
AwtObject::WinThreadExecProc(args);
break;
}
return 0L;
}
void AwtMenuItem::_SetLabel(void *param) { void AwtMenuItem::_SetLabel(void *param) {
if (AwtToolkit::IsMainThread()) { if (AwtToolkit::IsMainThread()) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
...@@ -886,6 +875,53 @@ ret: ...@@ -886,6 +875,53 @@ ret:
} }
} }
void AwtMenuItem::_SetEnable(void *param)
{
if (AwtToolkit::IsMainThread()) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
SetEnableStruct *ses = (SetEnableStruct*) param;
jobject self = ses->menuitem;
jboolean isEnabled = ses->isEnabled;
AwtMenuItem *m = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
m = (AwtMenuItem *)pData;
m->Enable(isEnabled);
ret:
env->DeleteGlobalRef(self);
delete ses;
} else {
AwtToolkit::GetInstance().InvokeFunction(AwtMenuItem::_SetEnable, param);
}
}
void AwtMenuItem::_SetState(void *param)
{
if (AwtToolkit::IsMainThread()) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
SetStateStruct *sts = (SetStateStruct*) param;
jobject self = sts->menuitem;
jboolean isChecked = sts->isChecked;
AwtMenuItem *m = NULL;
PDATA pData;
JNI_CHECK_PEER_GOTO(self, ret);
m = (AwtMenuItem *)pData;
m->SetState(isChecked);
ret:
env->DeleteGlobalRef(self);
delete sts;
} else {
AwtToolkit::GetInstance().InvokeFunction(AwtMenuItem::_SetState, param);
}
}
BOOL AwtMenuItem::IsSeparator() { BOOL AwtMenuItem::IsSeparator() {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (env->EnsureLocalCapacity(2) < 0) { if (env->EnsureLocalCapacity(2) < 0) {
...@@ -1049,13 +1085,9 @@ Java_sun_awt_windows_WMenuItemPeer_create(JNIEnv *env, jobject self, ...@@ -1049,13 +1085,9 @@ Java_sun_awt_windows_WMenuItemPeer_create(JNIEnv *env, jobject self,
{ {
TRY; TRY;
JNI_CHECK_NULL_RETURN(menu, "null Menu");
AwtToolkit::CreateComponent(self, menu, AwtToolkit::CreateComponent(self, menu,
(AwtToolkit::ComponentFactory) (AwtToolkit::ComponentFactory)
AwtMenuItem::Create); AwtMenuItem::Create);
PDATA pData;
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
...@@ -1070,9 +1102,12 @@ Java_sun_awt_windows_WMenuItemPeer_enable(JNIEnv *env, jobject self, ...@@ -1070,9 +1102,12 @@ Java_sun_awt_windows_WMenuItemPeer_enable(JNIEnv *env, jobject self,
{ {
TRY; TRY;
PDATA pData; SetEnableStruct *ses = new SetEnableStruct;
JNI_CHECK_PEER_RETURN(self); ses->menuitem = env->NewGlobalRef(self);
AwtObject::WinThreadExec(self, AwtMenuItem::MENUITEM_ENABLE, (LPARAM)on ); ses->isEnabled = on;
AwtToolkit::GetInstance().SyncCall(AwtMenuItem::_SetEnable, ses);
// global refs and ses are deleted in _SetEnable
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
...@@ -1111,9 +1146,12 @@ Java_sun_awt_windows_WCheckboxMenuItemPeer_setState(JNIEnv *env, jobject self, ...@@ -1111,9 +1146,12 @@ Java_sun_awt_windows_WCheckboxMenuItemPeer_setState(JNIEnv *env, jobject self,
{ {
TRY; TRY;
PDATA pData; SetStateStruct *sts = new SetStateStruct;
JNI_CHECK_PEER_RETURN(self); sts->menuitem = env->NewGlobalRef(self);
AwtObject::WinThreadExec(self, AwtMenuItem::MENUITEM_SETSTATE, (LPARAM)on); sts->isChecked = on;
AwtToolkit::GetInstance().SyncCall(AwtMenuItem::_SetState, sts);
// global refs and sts are deleted in _SetState
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
...@@ -45,13 +45,6 @@ class AwtMenu; ...@@ -45,13 +45,6 @@ class AwtMenu;
class AwtMenuItem : public AwtObject { class AwtMenuItem : public AwtObject {
public: public:
// id's for methods executed on toolkit thread
enum {
MENUITEM_ENABLE,
MENUITEM_SETSTATE,
MENUITEM_LAST
};
/* java.awt.MenuComponent fields */ /* java.awt.MenuComponent fields */
static jfieldID fontID; static jfieldID fontID;
static jfieldID appContextID; static jfieldID appContextID;
...@@ -154,13 +147,14 @@ public: ...@@ -154,13 +147,14 @@ public:
*/ */
MsgRouting WmNotify(UINT notifyCode); MsgRouting WmNotify(UINT notifyCode);
virtual LRESULT WinThreadExecProc(ExecuteArgs * args);
virtual BOOL IsDisabledAndPopup() { virtual BOOL IsDisabledAndPopup() {
return FALSE; return FALSE;
} }
virtual BOOL IsSeparator(); virtual BOOL IsSeparator();
// invoked on Toolkit thread // invoked on Toolkit thread
static void _SetState(void *param);
static void _SetEnable(void *param);
static void _SetLabel(void *param); static void _SetLabel(void *param);
static void _UpdateLayout(void *param); static void _UpdateLayout(void *param);
......
/* /*
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 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
...@@ -65,7 +65,7 @@ LPCTSTR AwtPopupMenu::GetClassName() { ...@@ -65,7 +65,7 @@ LPCTSTR AwtPopupMenu::GetClassName() {
} }
/* Create a new AwtPopupMenu object and menu. */ /* Create a new AwtPopupMenu object and menu. */
AwtPopupMenu* AwtPopupMenu::Create(jobject self, AwtComponent* parent) AwtPopupMenu* AwtPopupMenu::Create(jobject self, jobject parent)
{ {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
...@@ -77,6 +77,9 @@ AwtPopupMenu* AwtPopupMenu::Create(jobject self, AwtComponent* parent) ...@@ -77,6 +77,9 @@ AwtPopupMenu* AwtPopupMenu::Create(jobject self, AwtComponent* parent)
return NULL; return NULL;
} }
JNI_CHECK_NULL_GOTO(parent, "peer", done);
AwtComponent* awtParent = (AwtComponent*) JNI_GET_PDATA(parent);
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);
...@@ -94,7 +97,7 @@ AwtPopupMenu* AwtPopupMenu::Create(jobject self, AwtComponent* parent) ...@@ -94,7 +97,7 @@ AwtPopupMenu* AwtPopupMenu::Create(jobject self, AwtComponent* parent)
popupMenu->SetHMenu(hMenu); popupMenu->SetHMenu(hMenu);
popupMenu->LinkObjects(env, self); popupMenu->LinkObjects(env, self);
popupMenu->SetParent(parent); popupMenu->SetParent(awtParent);
} catch (...) { } catch (...) {
env->DeleteLocalRef(target); env->DeleteLocalRef(target);
throw; throw;
...@@ -274,12 +277,8 @@ Java_sun_awt_windows_WPopupMenuPeer_createMenu(JNIEnv *env, jobject self, ...@@ -274,12 +277,8 @@ Java_sun_awt_windows_WPopupMenuPeer_createMenu(JNIEnv *env, jobject self,
{ {
TRY; TRY;
PDATA pData;
JNI_CHECK_PEER_RETURN(parent);
AwtComponent* awtParent = (AwtComponent *)pData;
AwtToolkit::CreateComponent( AwtToolkit::CreateComponent(
self, awtParent, (AwtToolkit::ComponentFactory)AwtPopupMenu::Create, FALSE); self, parent, (AwtToolkit::ComponentFactory)AwtPopupMenu::Create);
JNI_CHECK_PEER_CREATION_RETURN(self);
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
virtual LPCTSTR GetClassName(); virtual LPCTSTR GetClassName();
/* Create a new AwtPopupMenu. This must be run on the main thread. */ /* Create a new AwtPopupMenu. This must be run on the main thread. */
static AwtPopupMenu* Create(jobject self, AwtComponent* parent); static AwtPopupMenu* Create(jobject self, jobject parent);
/* Display the popup modally. */ /* Display the popup modally. */
void Show(JNIEnv *env, jobject event, BOOL isTrayIconPopup); void Show(JNIEnv *env, jobject event, BOOL isTrayIconPopup);
......
...@@ -172,6 +172,9 @@ safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) { ...@@ -172,6 +172,9 @@ safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) {
env->ExceptionClear(); env->ExceptionClear();
// rethrow exception // rethrow exception
env->Throw(xcp); env->Throw(xcp);
// temp solution to reveal all concurrency issues in jtreg and JCK
// we will switch it back to silent mode before the release
env->ExceptionDescribe();
return xcp; return xcp;
} }
} }
......
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 8079595
@summary Resizing dialog which is JWindow parent makes JVM crash
@author Semyon Sadetsky
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
public class ShowChildWhileResizingTest {
private static Window dialog;
private static Timer timer;
private static Point point;
public static void main(String[] args) throws Exception {
dialog = new Frame();
dialog.add(new JPanel());
dialog.setVisible(true);
dialog.setBounds(100, 100, 200, 200);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
final Window dependentWindow = new JWindow(dialog);
JPanel panel = new JPanel();
panel.add(new JButton("button"));
dependentWindow.add(panel);
dependentWindow.setVisible(true);
dependentWindow.setBounds(0, 0, 50, 50);
timer = new Timer(100, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dependentWindow
.setVisible(!dependentWindow.isVisible());
}
});
timer.start();
}
});
Robot robot = new Robot();
robot.setAutoDelay(5);
robot.delay(300);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
point = dialog.getLocationOnScreen();
}
});
robot.mouseMove(point.x + 200 - dialog.getInsets().right/2,
point.y + 200 - dialog.getInsets().bottom/2);
robot.mousePress(InputEvent.BUTTON1_MASK);
for(int i = 0; i < 100; i++) {
robot.mouseMove(point.x + 200 + i, point.y + 200 + i);
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
timer.stop();
dialog.dispose();
System.out.println("ok");
}
}
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2017, 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,10 +33,11 @@ import java.lang.invoke.SerializedLambda; ...@@ -33,10 +33,11 @@ import java.lang.invoke.SerializedLambda;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Set; import java.util.List;
import java.util.concurrent.atomic.LongAdder; import java.util.concurrent.atomic.LongAdder;
import sun.misc.ObjectInputFilter; import sun.misc.ObjectInputFilter;
...@@ -155,26 +156,33 @@ public class SerialFilterTest implements Serializable { ...@@ -155,26 +156,33 @@ public class SerialFilterTest implements Serializable {
Runnable runnable = (Runnable & Serializable) SerialFilterTest::noop; Runnable runnable = (Runnable & Serializable) SerialFilterTest::noop;
Object[][] objects = { Object[][] objects = {
{ null, 0, -1, 0, 0, 0, { null, 0, -1, 0, 0, 0,
new HashSet<>()}, // no callback, no values Arrays.asList()}, // no callback, no values
{ objArray, 3, 7, 8, 2, 55, { objArray, 3, 7, 9, 2, 55,
new HashSet<>(Arrays.asList(objArray.getClass()))}, Arrays.asList(objArray.getClass(), objArray.getClass())},
{ Object[].class, 1, -1, 1, 1, 40, { Object[].class, 1, -1, 1, 1, 38,
new HashSet<>(Arrays.asList(Object[].class))}, Arrays.asList(Object[].class)},
{ new SerialFilterTest(), 1, -1, 1, 1, 37, { new SerialFilterTest(), 1, -1, 1, 1, 35,
new HashSet<>(Arrays.asList(SerialFilterTest.class))}, Arrays.asList(SerialFilterTest.class)},
{ new LongAdder(), 2, -1, 1, 1, 93, { new LongAdder(), 2, -1, 2, 1, 93,
new HashSet<>(Arrays.asList(LongAdder.class, serClass))}, Arrays.asList(serClass, LongAdder.class)},
{ new byte[14], 2, 14, 1, 1, 27, { new byte[14], 2, 14, 2, 1, 27,
new HashSet<>(Arrays.asList(byteArray.getClass()))}, Arrays.asList(byteArray.getClass(), byteArray.getClass())},
{ runnable, 13, 0, 10, 2, 514, { runnable, 13, 0, 13, 2, 514,
new HashSet<>(Arrays.asList(java.lang.invoke.SerializedLambda.class, Arrays.asList(java.lang.invoke.SerializedLambda.class,
objArray.getClass(),
objArray.getClass(),
SerialFilterTest.class, SerialFilterTest.class,
objArray.getClass()))}, java.lang.invoke.SerializedLambda.class)},
{ deepHashSet(10), 48, -1, 49, 11, 619, { deepHashSet(10), 48, -1, 50, 11, 619,
new HashSet<>(Arrays.asList(HashSet.class))}, Arrays.asList(HashSet.class)},
{ proxy.getClass(), 3, -1, 1, 1, 114, { proxy.getClass(), 3, -1, 2, 2, 112,
new HashSet<>(Arrays.asList(Runnable.class, Arrays.asList(Runnable.class,
java.lang.reflect.Proxy.class))}, java.lang.reflect.Proxy.class,
java.lang.reflect.Proxy.class)},
{ new F(), 6, -1, 6, 6, 202,
Arrays.asList(F.class, E.class, D.class,
C.class, B.class, A.class)},
}; };
return objects; return objects;
} }
...@@ -213,11 +221,12 @@ public class SerialFilterTest implements Serializable { ...@@ -213,11 +221,12 @@ public class SerialFilterTest implements Serializable {
@Test(dataProvider="Objects") @Test(dataProvider="Objects")
public static void t1(Object object, public static void t1(Object object,
long count, long maxArray, long maxRefs, long maxDepth, long maxBytes, long count, long maxArray, long maxRefs, long maxDepth, long maxBytes,
Set<Class<?>> classes) throws IOException { List<Class<?>> classes) throws IOException {
byte[] bytes = writeObjects(object); byte[] bytes = writeObjects(object);
Validator validator = new Validator(); Validator validator = new Validator();
validate(bytes, validator); validate(bytes, validator);
System.out.printf("v: %s%n", validator); System.out.printf("v: %s%n", validator);
Assert.assertEquals(validator.count, count, "callback count wrong"); Assert.assertEquals(validator.count, count, "callback count wrong");
Assert.assertEquals(validator.classes, classes, "classes mismatch"); Assert.assertEquals(validator.classes, classes, "classes mismatch");
Assert.assertEquals(validator.maxArray, maxArray, "maxArray mismatch"); Assert.assertEquals(validator.maxArray, maxArray, "maxArray mismatch");
...@@ -411,7 +420,7 @@ public class SerialFilterTest implements Serializable { ...@@ -411,7 +420,7 @@ public class SerialFilterTest implements Serializable {
*/ */
static class Validator implements ObjectInputFilter { static class Validator implements ObjectInputFilter {
long count; // Count of calls to checkInput long count; // Count of calls to checkInput
HashSet<Class<?>> classes = new HashSet<>(); List<Class<?>> classes = new ArrayList<>();
long maxArray = -1; long maxArray = -1;
long maxRefs; long maxRefs;
long maxDepth; long maxDepth;
...@@ -422,16 +431,20 @@ public class SerialFilterTest implements Serializable { ...@@ -422,16 +431,20 @@ public class SerialFilterTest implements Serializable {
@Override @Override
public ObjectInputFilter.Status checkInput(FilterInfo filter) { public ObjectInputFilter.Status checkInput(FilterInfo filter) {
Class<?> serialClass = filter.serialClass();
System.out.printf(" checkInput: class: %s, arrayLen: %d, refs: %d, depth: %d, bytes; %d%n",
serialClass, filter.arrayLength(), filter.references(),
filter.depth(), filter.streamBytes());
count++; count++;
if (filter.serialClass() != null) { if (serialClass != null) {
if (filter.serialClass().getName().contains("$$Lambda$")) { if (serialClass.getName().contains("$$Lambda$")) {
// TBD: proper identification of serialized Lambdas? // TBD: proper identification of serialized Lambdas?
// Fold the serialized Lambda into the SerializedLambda type // Fold the serialized Lambda into the SerializedLambda type
classes.add(SerializedLambda.class); classes.add(SerializedLambda.class);
} else if (Proxy.isProxyClass(filter.serialClass())) { } else if (Proxy.isProxyClass(serialClass)) {
classes.add(Proxy.class); classes.add(Proxy.class);
} else { } else {
classes.add(filter.serialClass()); classes.add(serialClass);
} }
} }
...@@ -591,7 +604,8 @@ public class SerialFilterTest implements Serializable { ...@@ -591,7 +604,8 @@ public class SerialFilterTest implements Serializable {
// a stream of exactly the size requested. // a stream of exactly the size requested.
return genMaxBytesObject(allowed, value); return genMaxBytesObject(allowed, value);
} else if (pattern.startsWith("maxrefs=")) { } else if (pattern.startsWith("maxrefs=")) {
Object[] array = new Object[allowed ? (int)value - 1 : (int)value]; // 4 references to classes in addition to the array contents
Object[] array = new Object[allowed ? (int)value - 4 : (int)value - 3];
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
array[i] = otherObject; array[i] = otherObject;
} }
...@@ -740,4 +754,25 @@ public class SerialFilterTest implements Serializable { ...@@ -740,4 +754,25 @@ public class SerialFilterTest implements Serializable {
return streamBytes; return streamBytes;
} }
} }
// Deeper superclass hierarchy
static class A implements Serializable {
private static final long serialVersionUID = 1L;
};
static class B extends A {
private static final long serialVersionUID = 2L;
}
static class C extends B {
private static final long serialVersionUID = 3L;
}
static class D extends C {
private static final long serialVersionUID = 4L;
}
static class E extends D {
private static final long serialVersionUID = 5L;
}
static class F extends E {
private static final long serialVersionUID = 6L;
}
} }
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @summary Basic test for Thread(ThreadGroup,Runnable,String,long,boolean)
*/
import sun.misc.SharedSecrets;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.PrivilegedAction;
public class ITLConstructor {
static InheritableThreadLocal<Integer> n = new InheritableThreadLocal<Integer>() {
protected Integer initialValue() {
return 0;
}
protected Integer childValue(Integer parentValue) {
return parentValue + 1;
}
};
static final int CHILD_THREAD_COUNT = 10;
public static void main(String args[]) throws Exception {
test();
}
static void test() throws Exception {
// concurrent access to separate indexes is ok
int[] x = new int[CHILD_THREAD_COUNT];
Thread child = createThread(new AnotherRunnable(0, x));
child.start();
child.join(); // waits for *all* threads to complete
// Check results
for(int i=0; i<CHILD_THREAD_COUNT; i++) {
int expectedValue = 1;
if (x[i] != expectedValue)
throw (new Exception("Got x[" + i + "] = " + x[i]
+ ", expected: " + expectedValue));
}
}
static class AnotherRunnable implements Runnable {
final int threadId;
final int[] x;
AnotherRunnable(int threadId, int[] x) {
this.threadId = threadId;
this.x = x;
}
public void run() {
int itlValue = n.get();
if (threadId < CHILD_THREAD_COUNT-1) {
Thread child = createThread(
new AnotherRunnable(threadId+1, x));
child.start();
try {
child.join();
} catch(InterruptedException e) {
throw(new RuntimeException("Interrupted", e));
}
}
x[threadId] = itlValue+1;
}
}
static Thread createThread(final Runnable r) {
final AccessControlContext acc = AccessController.getContext();
// 4290486: doPrivileged is needed to create a thread in
// an environment that restricts "modifyThreadGroup".
return AccessController.doPrivileged(
new PrivilegedAction<Thread>() {
public Thread run() {
return SharedSecrets.getJavaLangAccess()
.newThreadWithAcc(r, acc);
}
}
);
}
}
/*
* Copyright (c) 2007, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* JRobot is a wrapper around java.awt.Robot that provides some convenience
* methods.
* <p>When using jtreg you would include this class via something like:
* <pre>
* @library ../../../regtesthelpers
* @build JRobot
* </pre>
*
*/
import java.awt.AWTException;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.SwingUtilities;
public class JRobot extends java.awt.Robot {
private static int DEFAULT_DELAY = 550;
private static int INTERNAL_DELAY = 250;
private int delay;
private boolean delaysEnabled;
protected JRobot(boolean enableDelays) throws AWTException {
super();
delaysEnabled = enableDelays;
setAutoWaitForIdle(enableDelays);
if (enableDelays) {
setAutoDelay(INTERNAL_DELAY);
setDelay(DEFAULT_DELAY);
}
}
/**
* Return a JRobot. Delays are enabled by default.
* @return a JRobot
*/
public static JRobot getRobot() {
return getRobot(true);
}
/**
* Create a JRobot. The parameter controls whether delays are enabled.
* @param enableDelays controls whether delays are enabled.
* @return a JRobot
*/
public static JRobot getRobot(boolean enableDelays) {
JRobot robot = null;
try {
robot = new JRobot(enableDelays);
} catch (AWTException e) {
System.err.println("Coudn't create Robot, details below");
throw new Error(e);
}
return robot;
}
/**
* Press and release a key.
* @param keycode which key to press. For example, KeyEvent.VK_DOWN
*/
public void hitKey(int keycode) {
keyPress(keycode);
keyRelease(keycode);
delay();
}
/**
* Press and release a key with modifiers.
* @param keys keys to press. Keys are pressed in order they are passed as
* parameters to this method. All keys except the last one are considered
* modifiers. For example, to press Ctrl+Shift+T, call:
* hitKey(KeyEvent.VK_CONTROL, KeyEvent.VK_SHIFT, KeyEvent.VK_T);
*/
public void hitKey(int... keys) {
for (int i = 0; i < keys.length; i++) {
keyPress(keys[i]);
}
for (int i = keys.length - 1; i >= 0; i--) {
keyRelease(keys[i]);
}
delay();
}
/**
* Move mouse cursor to the center of the Component.
* @param c Component the mouse is placed over
*/
public void moveMouseTo(Component c) {
Point p = c.getLocationOnScreen();
Dimension size = c.getSize();
p.x += size.width / 2;
p.y += size.height / 2;
mouseMove(p.x, p.y);
delay();
}
/**
* Move mouse smoothly from (x0, y0) to (x1, y1).
*/
public void glide(int x0, int y0, int x1, int y1) {
float dmax = (float)Math.max(Math.abs(x1 - x0), Math.abs(y1 - y0));
float dx = (x1 - x0) / dmax;
float dy = (y1 - y0) / dmax;
mouseMove(x0, y0);
for (int i=1; i<=dmax; i++) {
mouseMove((int)(x0 + dx*i), (int)(y0 + dy*i));
}
delay();
}
/**
* Perform a mouse click, i.e. press and release mouse button(s).
* @param buttons mouse button(s).
* For example, MouseEvent.BUTTON1_MASK
*/
public void clickMouse(int buttons) {
mousePress(buttons);
mouseRelease(buttons);
delay();
}
/**
* Perform a click with the first mouse button.
*/
public void clickMouse() {
clickMouse(InputEvent.BUTTON1_MASK);
}
/**
* Click in the center of the given Component
* @param c the Component to click on
* @param buttons mouse button(s).
*/
public void clickMouseOn(Component c, int buttons) {
moveMouseTo(c);
clickMouse(buttons);
}
/**
* Click the first mouse button in the center of the given Component
* @param c the Component to click on
*/
public void clickMouseOn(Component c) {
clickMouseOn(c, InputEvent.BUTTON1_MASK);
}
/**
* Return whether delays are enabled
* @return whether delays are enabled
*/
public boolean getDelaysEnabled() {
return delaysEnabled;
}
/**
* Delay execution by delay milliseconds
*/
public void delay() {
delay(delay);
}
/**
* Return the delay amount, in milliseconds
*/
public int getDelay() {
return delay;
}
/**
* Set the delay amount, in milliseconds
*/
public void setDelay(int delay) {
this.delay = delay;
}
/**
* Waits until all events currently on the event queue have been processed.
* Does nothing if called on EDT
*/
public synchronized void waitForIdle() {
if (!EventQueue.isDispatchThread()) {
super.waitForIdle();
}
}
/**
* Calculate the center of the Rectangle passed, and return them
* in a Point object.
* @param r a non-null Rectangle
* @return a new Point object containing coordinates of r's center
*/
public Point centerOf(Rectangle r) {
return new Point(r.x + r.width / 2, r.y + r.height / 2);
}
/**
* Calculate the center of the Rectangle passed, and store it in p.
* @param r a non-null Rectangle
* @param p a non-null Point that receives coordinates of r's center
* @return p
*/
public Point centerOf(Rectangle r, Point p) {
p.x = r.x + r.width / 2;
p.y = r.y + r.height / 2;
return p;
}
/**
* Convert a rectangle from coordinate system of Component c to
* screen coordinate system.
* @param r a non-null Rectangle
* @param c a Component whose coordinate system is used for conversion
*/
public void convertRectToScreen(Rectangle r, Component c) {
Point p = new Point(r.x, r.y);
SwingUtilities.convertPointToScreen(p, c);
r.x = p.x;
r.y = p.y;
}
/**
* Compares two rectangles pixel-by-pixel.
* @param r0 the first area
* @param r1 the second area
* return true if all pixels in the two areas are identical
*/
public boolean compareRects(Rectangle r0, Rectangle r1) {
int xShift = r1.x - r0.x;
int yShift = r1.y - r0.y;
for (int y = r0.y; y < r0.y + r0.height; y++) {
for (int x = r0.x; x < r0.x + r0.width; x++) {
if (!comparePixels(x, y, x + xShift, y + yShift)) {
return false;
}
}
}
return true;
}
/**
* Compares colors of two points on the screen.
* @param p0 the first point
* @param p1 the second point
* return true if the two points have the same color
*/
public boolean comparePixels(Point p0, Point p1) {
return comparePixels(p0.x, p0.y, p1.x, p1.y);
}
/**
* Compares colors of two points on the screen.
* @param x0 the x coordinate of the first point
* @param y0 the y coordinate of the first point
* @param x1 the x coordinate of the second point
* @param y1 the y coordinate of the second point
* return true if the two points have the same color
*/
public boolean comparePixels(int x0, int y0, int x1, int y1) {
return (getPixelColor(x0, y0).equals(getPixelColor(x1, y1)));
}
}
此差异已折叠。
/*
* Copyright (c) 2007, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Test {
int value();
boolean onEDT() default true;
}
\ No newline at end of file
/*
* Copyright (c) 2007, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 6452106 6606443 8161195
@author Peter Zhelezniakov
@library ../../regtesthelpers
@build Test JRobot SwingTestHelper
@run main/timeout=300 LayoutTest
*/
import javax.swing.text.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class LayoutTest extends SwingTestHelper {
JTextPane text;
public static void main(String[] args) throws Throwable {
new LayoutTest().run(args);
}
protected Component createContentPane() {
return text = new JTextPane();
}
@Test(value=10, onEDT=true)
private void onEDT10() {
requestAndWaitForFocus(text);
}
@Test(value=100, onEDT=true)
private void prepare6452106() {
text.setText("This is easily generated on my\nmachine");
Document doc = text.getDocument();
// wrap the long paragraph
Dimension d = text.getPreferredSize();
Dimension size = new Dimension(d.width * 2 / 3, d.height * 5);
window.setSize(size);
// place caret at the end of 2nd line
Element p1 = doc.getDefaultRootElement().getElement(0);
int pos = p1.getEndOffset();
text.setCaretPosition(pos - 1);
}
@Test(value=110, onEDT=false)
private void test6452106() {
robot.setDelay(300);
robot.hitKey(KeyEvent.VK_DELETE);
robot.hitKey(KeyEvent.VK_SPACE);
robot.hitKey(KeyEvent.VK_SPACE);
}
@Test(value=200, onEDT=true)
private void prepare6606443() {
text.setText("This is easily\ngenerated\non my machine");
text.setSelectionStart(15);
text.setSelectionEnd(24);
}
@Test(value=210, onEDT=false)
private void test6606443() {
robot.hitKey(KeyEvent.VK_ENTER);
}
}
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7167293
* @summary FtpURLConnection doesn't close FTP connection when FileNotFoundException is thrown
* @library ../www/ftptest/
* @build FtpServer FtpCommandHandler FtpAuthHandler FtpFileSystemHandler
* @run main FtpURLConnectionLeak
*/
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
public class FtpURLConnectionLeak {
public static void main(String[] args) throws Exception {
FtpServer server = new FtpServer(0);
server.setFileSystemHandler(new CustomFileSystemHandler("/"));
server.setAuthHandler(new MyAuthHandler());
int port = server.getLocalPort();
server.start();
URL url = new URL("ftp://localhost:" + port + "/filedoesNotExist.txt");
for (int i = 0; i < 3; i++) {
try {
InputStream stream = url.openStream();
} catch (FileNotFoundException expectedFirstTimeAround) {
// should always reach this point since the path does not exist
} catch (IOException expected) {
System.out.println("caught expected " + expected);
int times = 1;
do {
// give some time to close the connection...
System.out.println("sleeping... " + times);
Thread.sleep(times * 1000);
} while (server.activeClientsCount() > 0 && times++ < 5);
if (server.activeClientsCount() > 0) {
server.killClients();
throw new RuntimeException("URLConnection didn't close the" +
" FTP connection on FileNotFoundException");
}
} finally {
server.terminate();
}
}
}
static class CustomFileSystemHandler implements FtpFileSystemHandler {
private String currentDir;
public CustomFileSystemHandler(String path) {
currentDir = path;
}
@Override
public boolean cd(String path) {
currentDir = path;
return true;
}
@Override
public boolean cdUp() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String pwd() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean fileExists(String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InputStream getFile(String name) {
return null; //return null so that server will return 550 File not found.
}
@Override
public long getFileSize(String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InputStream listCurrentDir() {
return null;
}
@Override
public OutputStream putFile(String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean removeFile(String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean mkdir(String name) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean rename(String from, String to) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
static class MyAuthHandler implements FtpAuthHandler {
@Override
public int authType() {
return 0;
}
@Override
public boolean authenticate(String user, String password) {
return true;
}
@Override
public boolean authenticate(String user, String password, String account) {
return true;
}
}
}
...@@ -60,7 +60,7 @@ import sun.security.x509.X500Name; ...@@ -60,7 +60,7 @@ import sun.security.x509.X500Name;
/* /*
* @test * @test
* @bug 6543842 6543440 6939248 8009636 8024302 8163304 8169911 8169688 * @bug 6543842 6543440 6939248 8009636 8024302 8163304 8169911 8169688 8171121
* @summary checking response of timestamp * @summary checking response of timestamp
* @modules java.base/sun.security.pkcs * @modules java.base/sun.security.pkcs
* java.base/sun.security.timestamp * java.base/sun.security.timestamp
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册