Merge
This commit is contained in:
commit
967c2d5685
jdk
make
java
javax/crypto
sun
src
macosx
classes/sun/lwawt
LWCanvasPeer.javaLWCheckboxPeer.javaLWComponentPeer.javaLWContainerPeer.javaLWLabelPeer.javaLWListPeer.javaLWPanelPeer.javaLWScrollBarPeer.javaLWTextAreaPeer.javaLWTextComponentPeer.javaLWTextFieldPeer.javaLWToolkit.java
macosx
native
apple/security
sun
share/classes
com/sun/security/auth/module
java
awt
io
lang
Class.javaInheritableThreadLocal.javaInteger.javaPackage.javaStrictMath.javaString.javaSystem.javaThreadGroup.javaThreadLocal.java
management
net
AbstractPlainDatagramSocketImpl.javaAbstractPlainSocketImpl.javaDatagramSocket.javaInet4Address.javaSocketInputStream.javaSocketPermission.javaSocksSocketImpl.javaURLConnection.java
nio
security
sql
text
CollationElementIterator.javaDecimalFormat.javaDigitList.javaFormat.javaNumberFormat.javaRBCollationTables.javaRBTableBuilder.javaSimpleDateFormat.java
util
javax
crypto
management
naming/spi
security/auth/kerberos
sql
@ -213,6 +213,7 @@ JAVA_JAVA_java = \
|
||||
sun/util/locale/provider/DateFormatSymbolsProviderImpl.java \
|
||||
sun/util/locale/provider/DecimalFormatSymbolsProviderImpl.java \
|
||||
sun/util/locale/provider/DictionaryBasedBreakIterator.java \
|
||||
sun/util/locale/provider/FallbackLocaleProviderAdapter.java \
|
||||
sun/util/locale/provider/HostLocaleProviderAdapter.java \
|
||||
sun/util/locale/provider/HostLocaleProviderAdapterImpl.java \
|
||||
sun/util/locale/provider/JRELocaleConstants.java \
|
||||
@ -235,6 +236,7 @@ JAVA_JAVA_java = \
|
||||
java/util/Observer.java \
|
||||
java/util/Properties.java \
|
||||
java/util/InvalidPropertiesFormatException.java \
|
||||
sun/util/spi/XmlPropertiesProvider.java \
|
||||
java/util/PropertyPermission.java \
|
||||
java/util/PropertyResourceBundle.java \
|
||||
java/util/Random.java \
|
||||
|
@ -108,6 +108,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_nio_ch_Net_setInterface6;
|
||||
Java_sun_nio_ch_Net_getInterface6;
|
||||
Java_sun_nio_ch_Net_shutdown;
|
||||
Java_sun_nio_ch_Net_poll;
|
||||
Java_sun_nio_ch_PollArrayWrapper_interrupt;
|
||||
Java_sun_nio_ch_PollArrayWrapper_poll0;
|
||||
Java_sun_nio_ch_ServerSocketChannelImpl_accept0;
|
||||
|
@ -116,6 +116,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_nio_ch_Net_setInterface6;
|
||||
Java_sun_nio_ch_Net_getInterface6;
|
||||
Java_sun_nio_ch_Net_shutdown;
|
||||
Java_sun_nio_ch_Net_poll;
|
||||
Java_sun_nio_ch_PollArrayWrapper_interrupt;
|
||||
Java_sun_nio_ch_PollArrayWrapper_poll0;
|
||||
Java_sun_nio_ch_ServerSocketChannelImpl_accept0;
|
||||
|
@ -104,6 +104,7 @@ SUNWprivate_1.1 {
|
||||
Java_sun_nio_ch_Net_setInterface6;
|
||||
Java_sun_nio_ch_Net_getInterface6;
|
||||
Java_sun_nio_ch_Net_shutdown;
|
||||
Java_sun_nio_ch_Net_poll;
|
||||
Java_sun_nio_ch_PollArrayWrapper_interrupt;
|
||||
Java_sun_nio_ch_PollArrayWrapper_poll0;
|
||||
Java_sun_nio_ch_ServerSocketChannelImpl_accept0;
|
||||
|
@ -158,7 +158,12 @@ include $(BUILDDIR)/common/Classes.gmk
|
||||
#
|
||||
|
||||
ifdef OPENJDK
|
||||
all: build-jar install-jar build-policy install-limited
|
||||
ifdef UNLIMITED_CRYPTO
|
||||
POLICY = install-unlimited
|
||||
else
|
||||
POLICY = install-limited
|
||||
endif
|
||||
all: build-jar install-jar build-policy $(POLICY)
|
||||
else # OPENJDK
|
||||
ifeq ($(strip $(FILES_java)),)
|
||||
all:
|
||||
|
@ -28,6 +28,11 @@ LIBRARY = osxapp
|
||||
PRODUCT = sun
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
GEN_DIR=$(GENSRCDIR)/sun/osxapp
|
||||
ICON_DATA = $(GEN_DIR)/AWTIconData.h
|
||||
|
||||
CLASSES_INIT += $(ICON_DATA)
|
||||
|
||||
#
|
||||
# Files
|
||||
#
|
||||
@ -63,6 +68,7 @@ OTHER_LDLIBS += \
|
||||
-framework QuartzCore
|
||||
|
||||
CPPFLAGS += \
|
||||
-I$(GEN_DIR) \
|
||||
$(call NativeSrcDirList,-I,/native/sun/osxapp)
|
||||
|
||||
|
||||
@ -70,6 +76,34 @@ ifeq ($(MILESTONE), internal)
|
||||
CPPFLAGS += -DINTERNAL_BUILD
|
||||
endif
|
||||
|
||||
clean clobber::
|
||||
TEMPDIR_CLASSES = $(TEMPDIR)/classes
|
||||
|
||||
.PHONY:
|
||||
$(TEMPDIR_CLASSES)/sun/osxapp/ToBin.class: ToBin.java
|
||||
@$(prep-target)
|
||||
$(BOOT_JAVAC_CMD) -d $(TEMPDIR_CLASSES) $<
|
||||
|
||||
ifdef OPENJDK
|
||||
ICONS_PATH_PREFIX=$(PLATFORM_SRC_MACOS)
|
||||
else
|
||||
ICONS_PATH_PREFIX=$(CLOSED_SRC)/macosx
|
||||
endif
|
||||
|
||||
generated.clean:
|
||||
$(RM) -r $(GEN_DIR)/*.h
|
||||
|
||||
ICONPATH=$(ICONS_PATH_PREFIX)/native/sun/osxapp/resource/icons
|
||||
ICON = $(ICONPATH)/JavaApp.icns
|
||||
|
||||
$(GEN_DIR)/AWTIconData.h: $(TEMPDIR_CLASSES)/sun/osxapp/ToBin.class $(ICON)
|
||||
$(prep-target)
|
||||
$(RM) $(ICON_DATA)
|
||||
$(ECHO) "static unsigned char sAWTIconData[] = { " >> $(ICON_DATA); \
|
||||
$(CAT) $(ICON) | \
|
||||
$(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES) -Djava.awt.headless=true \
|
||||
sun.osxapp.ToBin >> $(ICON_DATA); \
|
||||
$(ECHO) "};" >> $(ICON_DATA);
|
||||
|
||||
|
||||
clean clobber:: generated.clean
|
||||
|
||||
.PHONY: generated.clean
|
||||
|
50
jdk/make/sun/osxapp/ToBin.java
Normal file
50
jdk/make/sun/osxapp/ToBin.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 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.
|
||||
*/
|
||||
|
||||
package sun.osxapp;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class ToBin {
|
||||
public static void main(String[] args) throws Exception {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
int nRead;
|
||||
byte[] data = new byte[4096];
|
||||
|
||||
while ((nRead = System.in.read(data, 0, data.length)) != -1) {
|
||||
baos.write(data, 0, nRead);
|
||||
}
|
||||
|
||||
baos.flush();
|
||||
|
||||
byte[] buf = baos.toByteArray();
|
||||
for (int i = 0; i < buf.length; i++) {
|
||||
System.out.print(String.format("0x%1$02X", buf[i]) + ", ");
|
||||
if (i % 20 == 0) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -41,3 +41,20 @@ AUTO_FILES_JAVA_DIRS = sun/util/xml
|
||||
#
|
||||
include $(BUILDDIR)/common/Classes.gmk
|
||||
|
||||
#
|
||||
# Rules for XML properties provider configuration file
|
||||
#
|
||||
SERVICEDIR = $(CLASSBINDIR)/META-INF/services
|
||||
FILES_copy = $(SERVICEDIR)/sun.util.spi.XmlPropertiesProvider
|
||||
|
||||
copy-files: $(FILES_copy)
|
||||
|
||||
$(SERVICEDIR)/%: $(SHARE_SRC)/classes/sun/util/xml/META-INF/services/%
|
||||
$(install-file)
|
||||
|
||||
build: copy-files
|
||||
|
||||
clean::
|
||||
$(RM) $(FILES_copy)
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -26,26 +26,27 @@
|
||||
|
||||
package sun.lwawt;
|
||||
|
||||
import java.awt.AWTException;
|
||||
import java.awt.BufferCapabilities;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.Image;
|
||||
import java.awt.peer.CanvasPeer;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
final class LWCanvasPeer extends LWComponentPeer<Component, JComponent>
|
||||
implements CanvasPeer {
|
||||
class LWCanvasPeer<T extends Component, D extends JComponent>
|
||||
extends LWComponentPeer<T, D> implements CanvasPeer {
|
||||
|
||||
LWCanvasPeer(final Canvas target, PlatformComponent platformComponent) {
|
||||
LWCanvasPeer(final T target, final PlatformComponent platformComponent) {
|
||||
super(target, platformComponent);
|
||||
}
|
||||
|
||||
// ---- PEER METHODS ---- //
|
||||
|
||||
@Override
|
||||
public void createBuffers(int numBuffers, BufferCapabilities caps) {
|
||||
public void createBuffers(int numBuffers, BufferCapabilities caps)
|
||||
throws AWTException {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -67,10 +68,20 @@ final class LWCanvasPeer extends LWComponentPeer<Component, JComponent>
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
||||
public final GraphicsConfiguration getAppropriateGraphicsConfiguration(
|
||||
GraphicsConfiguration gc)
|
||||
{
|
||||
// TODO
|
||||
return gc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Dimension getMinimumSize() {
|
||||
return getBounds().getSize();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -185,6 +185,11 @@ final class LWCheckboxPeer
|
||||
rb.setBounds(0, 0, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return getCurrentButton().getPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transient
|
||||
public Dimension getMinimumSize() {
|
||||
|
@ -123,7 +123,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
// private volatile boolean paintPending;
|
||||
private volatile boolean isLayouting;
|
||||
|
||||
private D delegate = null;
|
||||
private final D delegate;
|
||||
private Container delegateContainer;
|
||||
private Component delegateDropTarget;
|
||||
private final Object dropTargetLock = new Object();
|
||||
@ -133,6 +133,11 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
|
||||
private final PlatformComponent platformComponent;
|
||||
|
||||
/**
|
||||
* Character with reasonable value between the minimum width and maximum.
|
||||
*/
|
||||
static final char WIDE_CHAR = '0';
|
||||
|
||||
private final class DelegateContainer extends Container {
|
||||
{
|
||||
enableEvents(0xFFFFFFFF);
|
||||
@ -267,9 +272,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
}
|
||||
|
||||
protected final D getDelegate() {
|
||||
synchronized (getStateLock()) {
|
||||
return delegate;
|
||||
}
|
||||
return delegate;
|
||||
}
|
||||
|
||||
protected Component getDelegateFocusOwner() {
|
||||
@ -698,26 +701,23 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
}
|
||||
|
||||
@Override
|
||||
public FontMetrics getFontMetrics(Font f) {
|
||||
public FontMetrics getFontMetrics(final Font f) {
|
||||
// Borrow the metrics from the top-level window
|
||||
// return getWindowPeer().getFontMetrics(f);
|
||||
// Obtain the metrics from the offscreen window where this peer is
|
||||
// mostly drawn to.
|
||||
// TODO: check for "use platform metrics" settings
|
||||
Graphics g = getWindowPeer().getGraphics();
|
||||
try {
|
||||
if (g != null) {
|
||||
final Graphics g = getOnscreenGraphics();
|
||||
if (g != null) {
|
||||
try {
|
||||
return g.getFontMetrics(f);
|
||||
} else {
|
||||
synchronized (getDelegateLock()) {
|
||||
return delegateContainer.getFontMetrics(f);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (g != null) {
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
synchronized (getDelegateLock()) {
|
||||
return delegateContainer.getFontMetrics(f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -847,31 +847,46 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be overridden in subclasses to forward the request
|
||||
* to the Swing helper component, if required.
|
||||
* Determines the preferred size of the component. By default forwards the
|
||||
* request to the Swing helper component. Should be overridden in subclasses
|
||||
* if required.
|
||||
*/
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
// It looks like a default implementation for all toolkits
|
||||
return getMinimumSize();
|
||||
final Dimension size;
|
||||
synchronized (getDelegateLock()) {
|
||||
size = getDelegate().getPreferredSize();
|
||||
}
|
||||
return validateSize(size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Should be overridden in subclasses to forward the request
|
||||
* to the Swing helper component.
|
||||
/**
|
||||
* Determines the minimum size of the component. By default forwards the
|
||||
* request to the Swing helper component. Should be overridden in subclasses
|
||||
* if required.
|
||||
*/
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
D delegate = getDelegate();
|
||||
|
||||
if (delegate == null) {
|
||||
// Is it a correct default value?
|
||||
return getBounds().getSize();
|
||||
} else {
|
||||
synchronized (getDelegateLock()) {
|
||||
return delegate.getMinimumSize();
|
||||
}
|
||||
final Dimension size;
|
||||
synchronized (getDelegateLock()) {
|
||||
size = getDelegate().getMinimumSize();
|
||||
}
|
||||
return validateSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* In some situations delegates can return empty minimum/preferred size.
|
||||
* (For example: empty JLabel, etc), but awt components never should be
|
||||
* empty. In the XPeers or WPeers we use some magic constants, but here we
|
||||
* try to use something more useful,
|
||||
*/
|
||||
private Dimension validateSize(final Dimension size) {
|
||||
if (size.width == 0 || size.height == 0) {
|
||||
final FontMetrics fm = getFontMetrics(getFont());
|
||||
size.width = fm.charWidth(WIDE_CHAR);
|
||||
size.height = fm.getHeight();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -41,7 +41,7 @@ import java.util.List;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
abstract class LWContainerPeer<T extends Container, D extends JComponent>
|
||||
extends LWComponentPeer<T, D>
|
||||
extends LWCanvasPeer<T, D>
|
||||
implements ContainerPeer
|
||||
{
|
||||
// List of child peers sorted by z-order from bottom-most
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -26,37 +26,26 @@
|
||||
|
||||
package sun.lwawt;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Label;
|
||||
import java.awt.peer.LabelPeer;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import javax.tools.annotation.GenerateNativeHeader;
|
||||
|
||||
/**
|
||||
* Lightweight implementation of {@link LabelPeer}. Delegates most of the work
|
||||
* to the {@link JLabel}.
|
||||
*/
|
||||
/* No native methods here, but the constants are needed in the supporting JNI code */
|
||||
@GenerateNativeHeader
|
||||
final class LWLabelPeer extends LWComponentPeer<Label, JLabel>
|
||||
implements LabelPeer {
|
||||
|
||||
private static final int TEXT_XPAD = 5;
|
||||
private static final int TEXT_YPAD = 1;
|
||||
|
||||
LWLabelPeer(final Label target, final PlatformComponent platformComponent) {
|
||||
super(target, platformComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JLabel createDelegate() {
|
||||
final JLabel label = new JLabel();
|
||||
label.setVerticalAlignment(SwingConstants.TOP);
|
||||
return label;
|
||||
return new JLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,24 +69,6 @@ final class LWLabelPeer extends LWComponentPeer<Label, JLabel>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
int w = TEXT_XPAD;
|
||||
int h = TEXT_YPAD;
|
||||
final FontMetrics fm = getFontMetrics(getFont());
|
||||
if (fm != null) {
|
||||
final String text;
|
||||
synchronized (getDelegateLock()) {
|
||||
text = getDelegate().getText();
|
||||
}
|
||||
if (text != null) {
|
||||
w += fm.stringWidth(text);
|
||||
}
|
||||
h += fm.getHeight();
|
||||
}
|
||||
return new Dimension(w, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@code Label} alignment constant to the {@code JLabel} constant.
|
||||
* If wrong Label alignment provided returns default alignment.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -32,10 +32,22 @@ import java.awt.event.*;
|
||||
import java.awt.peer.ListPeer;
|
||||
import java.util.Arrays;
|
||||
|
||||
final class LWListPeer
|
||||
extends LWComponentPeer<List, LWListPeer.ScrollableJList>
|
||||
/**
|
||||
* Lightweight implementation of {@link ListPeer}.
|
||||
*/
|
||||
final class LWListPeer extends LWComponentPeer<List, LWListPeer.ScrollableJList>
|
||||
implements ListPeer {
|
||||
|
||||
/**
|
||||
* The default number of visible rows.
|
||||
*/
|
||||
private static final int DEFAULT_VISIBLE_ROWS = 4; // From java.awt.List,
|
||||
|
||||
/**
|
||||
* This text is used for cell bounds calculation.
|
||||
*/
|
||||
private static final String TEXT = "0123456789abcde";
|
||||
|
||||
LWListPeer(final List target, final PlatformComponent platformComponent) {
|
||||
super(target, platformComponent);
|
||||
if (!getTarget().isBackgroundSet()) {
|
||||
@ -134,6 +146,16 @@ final class LWListPeer
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getMinimumSize(DEFAULT_VISIBLE_ROWS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(final int rows) {
|
||||
return getMinimumSize(rows);
|
||||
@ -142,18 +164,28 @@ final class LWListPeer
|
||||
@Override
|
||||
public Dimension getMinimumSize(final int rows) {
|
||||
synchronized (getDelegateLock()) {
|
||||
final int margin = 2;
|
||||
final int space = 1;
|
||||
|
||||
// TODO: count ScrollPane's scrolling elements if any.
|
||||
final FontMetrics fm = getFontMetrics(getFont());
|
||||
final int itemHeight = (fm.getHeight() - fm.getLeading()) + (2 * space);
|
||||
|
||||
return new Dimension(20 + (fm == null ? 10 * 15 : fm.stringWidth("0123456789abcde")),
|
||||
(fm == null ? 10 : itemHeight) * rows + (2 * margin));
|
||||
final Dimension size = getCellSize();
|
||||
size.height *= rows;
|
||||
// Always take vertical scrollbar into account.
|
||||
final JScrollBar vbar = getDelegate().getVerticalScrollBar();
|
||||
size.width += vbar != null ? vbar.getMinimumSize().width : 0;
|
||||
// JScrollPane and JList insets
|
||||
final Insets pi = getDelegate().getInsets();
|
||||
final Insets vi = getDelegate().getView().getInsets();
|
||||
size.width += pi.left + pi.right + vi.left + vi.right;
|
||||
size.height += pi.top + pi.bottom + vi.top + vi.bottom;
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
private Dimension getCellSize() {
|
||||
final JList<String> jList = getDelegate().getView();
|
||||
final ListCellRenderer<? super String> cr = jList.getCellRenderer();
|
||||
final Component cell = cr.getListCellRendererComponent(jList, TEXT, 0,
|
||||
false, false);
|
||||
return cell.getPreferredSize();
|
||||
}
|
||||
|
||||
private void revalidate() {
|
||||
synchronized (getDelegateLock()) {
|
||||
getDelegate().getView().invalidate();
|
||||
@ -165,10 +197,10 @@ final class LWListPeer
|
||||
|
||||
private boolean skipStateChangedEvent;
|
||||
|
||||
private DefaultListModel<Object> model =
|
||||
new DefaultListModel<Object>() {
|
||||
private final DefaultListModel<String> model =
|
||||
new DefaultListModel<String>() {
|
||||
@Override
|
||||
public void add(final int index, final Object element) {
|
||||
public void add(final int index, final String element) {
|
||||
if (index == -1) {
|
||||
addElement(element);
|
||||
} else {
|
||||
@ -181,7 +213,7 @@ final class LWListPeer
|
||||
|
||||
ScrollableJList() {
|
||||
getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
|
||||
final JList<Object> list = new JListDelegate();
|
||||
final JList<String> list = new JListDelegate();
|
||||
list.addListSelectionListener(this);
|
||||
|
||||
getViewport().setView(list);
|
||||
@ -223,11 +255,11 @@ final class LWListPeer
|
||||
}
|
||||
}
|
||||
|
||||
public JList getView() {
|
||||
return (JList) getViewport().getView();
|
||||
public JList<String> getView() {
|
||||
return (JList<String>) getViewport().getView();
|
||||
}
|
||||
|
||||
public DefaultListModel<Object> getModel() {
|
||||
public DefaultListModel<String> getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
@ -254,7 +286,7 @@ final class LWListPeer
|
||||
}
|
||||
}
|
||||
|
||||
private final class JListDelegate extends JList<Object> {
|
||||
private final class JListDelegate extends JList<String> {
|
||||
|
||||
JListDelegate() {
|
||||
super(ScrollableJList.this.model);
|
||||
@ -272,7 +304,7 @@ final class LWListPeer
|
||||
final int index = locationToIndex(e.getPoint());
|
||||
if (0 <= index && index < getModel().getSize()) {
|
||||
LWListPeer.this.postEvent(new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED,
|
||||
getModel().getElementAt(index).toString(), e.getWhen(), e.getModifiers()));
|
||||
getModel().getElementAt(index), e.getWhen(), e.getModifiers()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,10 +313,10 @@ final class LWListPeer
|
||||
protected void processKeyEvent(final KeyEvent e) {
|
||||
super.processKeyEvent(e);
|
||||
if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||
final Object selectedValue = getSelectedValue();
|
||||
final String selectedValue = getSelectedValue();
|
||||
if(selectedValue != null){
|
||||
LWListPeer.this.postEvent(new ActionEvent(getTarget(), ActionEvent.ACTION_PERFORMED,
|
||||
selectedValue.toString(), e.getWhen(), e.getModifiers()));
|
||||
selectedValue, e.getWhen(), e.getModifiers()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
package sun.lwawt;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Panel;
|
||||
import java.awt.peer.PanelPeer;
|
||||
|
||||
@ -43,9 +42,4 @@ final class LWPanelPeer extends LWContainerPeer<Panel, JPanel>
|
||||
public JPanel createDelegate() {
|
||||
return new JPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getBounds().getSize();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@
|
||||
package sun.lwawt;
|
||||
|
||||
import java.awt.Adjustable;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Scrollbar;
|
||||
import java.awt.event.AdjustmentEvent;
|
||||
import java.awt.event.AdjustmentListener;
|
||||
@ -93,13 +92,6 @@ final class LWScrollBarPeer extends LWComponentPeer<Scrollbar, JScrollBar>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
synchronized (getDelegateLock()) {
|
||||
return getDelegate().getPreferredSize();
|
||||
}
|
||||
}
|
||||
|
||||
// Peer also registered as a listener for ComponentDelegate component
|
||||
@Override
|
||||
public void adjustmentValueChanged(final AdjustmentEvent e) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -29,6 +29,7 @@ package sun.lwawt;
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.event.TextEvent;
|
||||
@ -41,11 +42,22 @@ import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
/**
|
||||
* Lightweight implementation of {@link TextAreaPeer}. Delegates most of the
|
||||
* work to the {@link JTextArea} inside JScrollPane.
|
||||
*/
|
||||
final class LWTextAreaPeer
|
||||
extends LWTextComponentPeer<TextArea, LWTextAreaPeer.ScrollableJTextArea>
|
||||
implements TextAreaPeer {
|
||||
|
||||
/**
|
||||
* The default number of visible columns.
|
||||
*/
|
||||
private static final int DEFAULT_COLUMNS = 60;
|
||||
|
||||
/**
|
||||
* The default number of visible rows.
|
||||
*/
|
||||
private static final int DEFAULT_ROWS = 10;
|
||||
|
||||
LWTextAreaPeer(final TextArea target,
|
||||
@ -86,27 +98,42 @@ final class LWTextAreaPeer
|
||||
return getTextComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getMinimumSize(DEFAULT_ROWS, DEFAULT_COLUMNS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize(final int rows, final int columns) {
|
||||
return getPreferredSize(rows, columns);
|
||||
public Dimension getPreferredSize(final int rows, final int columns) {
|
||||
return getMinimumSize(rows, columns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(final int rows, final int columns) {
|
||||
final Dimension size = super.getPreferredSize(rows, columns);
|
||||
public Dimension getMinimumSize(final int rows, final int columns) {
|
||||
final Dimension size = super.getMinimumSize(rows, columns);
|
||||
synchronized (getDelegateLock()) {
|
||||
final JScrollBar vbar = getDelegate().getVerticalScrollBar();
|
||||
final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
|
||||
final int scrollbarW = vbar != null ? vbar.getWidth() : 0;
|
||||
final int scrollbarH = hbar != null ? hbar.getHeight() : 0;
|
||||
return new Dimension(size.width + scrollbarW,
|
||||
size.height + scrollbarH);
|
||||
// JScrollPane insets
|
||||
final Insets pi = getDelegate().getInsets();
|
||||
size.width += pi.left + pi.right;
|
||||
size.height += pi.top + pi.bottom;
|
||||
// Take scrollbars into account.
|
||||
final int vsbPolicy = getDelegate().getVerticalScrollBarPolicy();
|
||||
if (vsbPolicy == ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS) {
|
||||
final JScrollBar vbar = getDelegate().getVerticalScrollBar();
|
||||
size.width += vbar != null ? vbar.getMinimumSize().width : 0;
|
||||
}
|
||||
final int hsbPolicy = getDelegate().getHorizontalScrollBarPolicy();
|
||||
if (hsbPolicy == ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS) {
|
||||
final JScrollBar hbar = getDelegate().getHorizontalScrollBar();
|
||||
size.height += hbar != null ? hbar.getMinimumSize().height : 0;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -48,10 +48,7 @@ abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent
|
||||
extends LWComponentPeer<T, D>
|
||||
implements DocumentListener, TextComponentPeer, InputMethodListener {
|
||||
|
||||
/**
|
||||
* Character with reasonable value between the minimum width and maximum.
|
||||
*/
|
||||
protected static final char WIDE_CHAR = 'w';
|
||||
|
||||
private volatile boolean firstChangeSkipped;
|
||||
|
||||
LWTextComponentPeer(final T target,
|
||||
@ -95,18 +92,16 @@ abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent
|
||||
*/
|
||||
abstract JTextComponent getTextComponent();
|
||||
|
||||
public Dimension getPreferredSize(final int rows, final int columns) {
|
||||
public Dimension getMinimumSize(final int rows, final int columns) {
|
||||
final Insets insets;
|
||||
synchronized (getDelegateLock()) {
|
||||
insets = getDelegate().getInsets();
|
||||
insets = getTextComponent().getInsets();
|
||||
}
|
||||
final int borderHeight = insets.top + insets.bottom;
|
||||
final int borderWidth = insets.left + insets.right;
|
||||
final FontMetrics fm = getFontMetrics(getFont());
|
||||
final int charWidth = (fm != null) ? fm.charWidth(WIDE_CHAR) : 10;
|
||||
final int itemHeight = (fm != null) ? fm.getHeight() : 10;
|
||||
return new Dimension(columns * charWidth + borderWidth,
|
||||
rows * itemHeight + borderHeight);
|
||||
return new Dimension(fm.charWidth(WIDE_CHAR) * columns + borderWidth,
|
||||
fm.getHeight() * rows + borderHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -187,6 +182,7 @@ abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent
|
||||
}
|
||||
}
|
||||
|
||||
//TODO IN XAWT we just return true..
|
||||
@Override
|
||||
public final boolean isFocusable() {
|
||||
return getTarget().isFocusable();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -37,16 +37,10 @@ import java.awt.peer.TextFieldPeer;
|
||||
import javax.swing.JPasswordField;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import javax.tools.annotation.GenerateNativeHeader;
|
||||
|
||||
/* No native methods here, but the constants are needed in the supporting JNI code */
|
||||
@GenerateNativeHeader
|
||||
final class LWTextFieldPeer
|
||||
extends LWTextComponentPeer<TextField, JPasswordField>
|
||||
implements TextFieldPeer, ActionListener {
|
||||
|
||||
private static final int DEFAULT_COLUMNS = 1;
|
||||
|
||||
LWTextFieldPeer(final TextField target,
|
||||
final PlatformComponent platformComponent) {
|
||||
super(target, platformComponent);
|
||||
@ -83,17 +77,12 @@ final class LWTextFieldPeer
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize(final int columns) {
|
||||
return getPreferredSize(1, columns);
|
||||
return getMinimumSize(columns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize(final int columns) {
|
||||
return getPreferredSize(columns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getMinimumSize(DEFAULT_COLUMNS);
|
||||
return getMinimumSize(1, columns);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -310,7 +310,7 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
||||
@Override
|
||||
public CanvasPeer createCanvas(Canvas target) {
|
||||
PlatformComponent platformComponent = createPlatformComponent();
|
||||
LWCanvasPeer peer = new LWCanvasPeer(target, platformComponent);
|
||||
LWCanvasPeer<?, ?> peer = new LWCanvasPeer<>(target, platformComponent);
|
||||
targetCreatedPeer(target, peer);
|
||||
peer.initialize();
|
||||
return peer;
|
||||
|
@ -160,6 +160,9 @@ final class CPlatformResponder {
|
||||
|
||||
if(isDeadChar){
|
||||
testChar = (char) out[2];
|
||||
if(testChar == 0){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
jkeyCode = out[0];
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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
|
||||
@ -337,7 +337,6 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore)
|
||||
// Call back to the Java object to create Java objects corresponding to this security object.
|
||||
jlong nativeKeyRef = ptr_to_jlong(privateKeyRef);
|
||||
JNFCallVoidMethod(env, keyStore, jm_createKeyEntry, alias, creationDate, nativeKeyRef, certRefArray, javaCertArray);
|
||||
break;
|
||||
}
|
||||
} while (searchResult == noErr);
|
||||
|
||||
|
@ -383,6 +383,7 @@ static unichar NsGetDeadKeyChar(unsigned short keyCode)
|
||||
{
|
||||
TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource();
|
||||
CFDataRef uchr = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData);
|
||||
if (uchr == nil) { return; }
|
||||
const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
|
||||
// Carbon modifiers should be used instead of NSEvent modifiers
|
||||
UInt32 modifierKeyState = (GetCurrentEventKeyModifiers() >> 8) & 0xFF;
|
||||
@ -563,18 +564,18 @@ NSUInteger JavaModifiersToNsKeyModifiers(jint javaModifiers, BOOL isExtMods)
|
||||
const struct _nsKeyToJavaModifier* cur;
|
||||
|
||||
for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) {
|
||||
jint mask = isExtMods? cur->javaExtMask : cur->javaMask;
|
||||
jint mask = isExtMods? cur->javaExtMask : cur->javaMask;
|
||||
if ((mask & javaModifiers) != 0) {
|
||||
nsFlags |= cur->nsMask;
|
||||
}
|
||||
}
|
||||
|
||||
// special case
|
||||
jint mask = isExtMods? java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK :
|
||||
jint mask = isExtMods? java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK :
|
||||
java_awt_event_InputEvent_ALT_GRAPH_MASK;
|
||||
|
||||
if ((mask & javaModifiers) != 0) {
|
||||
nsFlags |= NSAlternateKeyMask;
|
||||
nsFlags |= NSAlternateKeyMask;
|
||||
}
|
||||
|
||||
return nsFlags;
|
||||
|
@ -279,7 +279,10 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
return;
|
||||
}
|
||||
|
||||
if (![self hasMarkedText] && fKeyEventsNeeded) {
|
||||
NSString *eventCharacters = [event characters];
|
||||
BOOL isDeadKey = (eventCharacters != nil && [eventCharacters length] == 0);
|
||||
|
||||
if ((![self hasMarkedText] && fKeyEventsNeeded) || isDeadKey) {
|
||||
[self deliverJavaKeyEventHelper: event];
|
||||
}
|
||||
|
||||
|
@ -142,8 +142,11 @@ void JavaCT_DrawGlyphVector
|
||||
// get our baseline transform and font
|
||||
CGContextRef cgRef = qsdo->cgRef;
|
||||
CGAffineTransform ctmText = CGContextGetTextMatrix(cgRef);
|
||||
//CGFontRef cgFont = CGContextGetFont(cgRef);
|
||||
|
||||
/* Save and restore of graphics context is done before the iteration.
|
||||
This seems to work using our test case (see bug ID 7158350) so we are restoring it at
|
||||
the end of the for loop. If we find out that save/restore outside the loop
|
||||
doesn't work on all cases then we will move the Save/Restore inside the loop.*/
|
||||
CGContextSaveGState(cgRef);
|
||||
CGAffineTransform invTx = CGAffineTransformInvert(strike->fTx);
|
||||
|
||||
@ -210,13 +213,9 @@ void JavaCT_DrawGlyphVector
|
||||
pt.x += advances[i].width;
|
||||
pt.y += advances[i].height;
|
||||
|
||||
// reset the font on the context after striking a unicode with CoreText
|
||||
if (uniChar != 0)
|
||||
{
|
||||
// CGContextSetFont(cgRef, cgFont);
|
||||
CGContextSaveGState(cgRef);
|
||||
}
|
||||
}
|
||||
// reset the font on the context after striking a unicode with CoreText
|
||||
CGContextRestoreGState(cgRef);
|
||||
}
|
||||
|
||||
// Using the Quartz Surface Data context, draw a hot-substituted character run
|
||||
|
@ -47,7 +47,10 @@ JNIEXPORT void JNICALL Java_java_awt_CheckboxMenuItem_initIDs
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_java_awt_Choice_initIDs
|
||||
(JNIEnv *env, jclass cls)
|
||||
{
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_java_awt_Color_initIDs
|
||||
(JNIEnv *env, jclass cls)
|
||||
|
@ -33,6 +33,7 @@
|
||||
#import "ThreadUtilities.h"
|
||||
#import "AWT_debug.h"
|
||||
#import "CSystemColors.h"
|
||||
#import "NSApplicationAWT.h"
|
||||
|
||||
#import "sun_lwawt_macosx_LWCToolkit.h"
|
||||
|
||||
@ -47,7 +48,7 @@ static long eventCount;
|
||||
return eventCount;
|
||||
}
|
||||
|
||||
+ (void) eventCountPlusPlus{
|
||||
+ (void) eventCountPlusPlus{
|
||||
eventCount++;
|
||||
}
|
||||
|
||||
@ -79,7 +80,6 @@ static long eventCount;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_LWCToolkit
|
||||
* Method: nativeSyncQueue
|
||||
@ -90,12 +90,22 @@ JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_LWCToolkit_nativeSyncQueue
|
||||
{
|
||||
int currentEventNum = [AWTToolkit getEventCount];
|
||||
|
||||
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}];
|
||||
|
||||
NSApplication* sharedApp = [NSApplication sharedApplication];
|
||||
if ([sharedApp isKindOfClass:[NSApplicationAWT class]]) {
|
||||
NSApplicationAWT* theApp = (NSApplicationAWT*)sharedApp;
|
||||
[theApp postDummyEvent];
|
||||
[theApp waitForDummyEvent];
|
||||
} else {
|
||||
// could happen if we are embedded inside SWT application,
|
||||
// in this case just spin a single empty block through
|
||||
// the event loop to give it a chance to process pending events
|
||||
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){}];
|
||||
}
|
||||
|
||||
if (([AWTToolkit getEventCount] - currentEventNum) != 0) {
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,15 @@
|
||||
@interface NSApplicationAWT : NSApplication {
|
||||
NSString *fApplicationName;
|
||||
NSWindow *eventTransparentWindow;
|
||||
NSTimeInterval dummyEventTimestamp;
|
||||
NSConditionLock* seenDummyEventLock;
|
||||
}
|
||||
|
||||
- (void) finishLaunching;
|
||||
- (void) registerWithProcessManager;
|
||||
- (void) setDockIconWithEnv:(JNIEnv *)env;
|
||||
- (void) postDummyEvent;
|
||||
- (void) waitForDummyEvent;
|
||||
|
||||
+ (void) runAWTLoopWithApp:(NSApplication*)app;
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#import "PropertiesUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "QueuingApplicationDelegate.h"
|
||||
#import "AWTIconData.h"
|
||||
|
||||
|
||||
static BOOL sUsingDefaultNIB = YES;
|
||||
@ -52,6 +53,9 @@ BOOL postEventDuringEventSynthesis = NO;
|
||||
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
fApplicationName = nil;
|
||||
dummyEventTimestamp = 0.0;
|
||||
seenDummyEventLock = nil;
|
||||
|
||||
|
||||
// NSApplication will call _RegisterApplication with the application's bundle, but there may not be one.
|
||||
// So, we need to call it ourselves to ensure the app is set up properly.
|
||||
@ -255,25 +259,26 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
theIconPath = [PropertiesUtilities javaSystemPropertyForKey:@"apple.awt.application.icon" withEnv:env];
|
||||
}
|
||||
|
||||
// If the icon file wasn't specified as an argument and we need to get an icon
|
||||
// we'll use the generic java app icon.
|
||||
NSString *defaultIconPath = [NSString stringWithFormat:@"%@%@", SHARED_FRAMEWORK_BUNDLE, @"/Resources/GenericApp.icns"];
|
||||
if (theIconPath == nil) {
|
||||
// Use the path specified to get the icon image
|
||||
NSImage* iconImage = nil;
|
||||
if (theIconPath != nil) {
|
||||
iconImage = [[NSImage alloc] initWithContentsOfFile:theIconPath];
|
||||
}
|
||||
|
||||
// If no icon file was specified or we failed to get the icon image
|
||||
// and there is no bundle's icon, then use the default icon
|
||||
if (iconImage == nil) {
|
||||
NSString* bundleIcon = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIconFile"];
|
||||
if (bundleIcon == nil) {
|
||||
theIconPath = defaultIconPath;
|
||||
NSData* iconData;
|
||||
iconData = [[NSData alloc] initWithBytesNoCopy: sAWTIconData length: sizeof(sAWTIconData) freeWhenDone: NO];
|
||||
iconImage = [[NSImage alloc] initWithData: iconData];
|
||||
[iconData release];
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the dock icon if we have an icon name.
|
||||
if (theIconPath != nil) {
|
||||
NSImage *iconImage = [[NSImage alloc] initWithContentsOfFile:theIconPath];
|
||||
|
||||
// If we failed for some reason fall back to the default icon.
|
||||
if (iconImage == nil) {
|
||||
iconImage = [[NSImage alloc] initWithContentsOfFile:defaultIconPath];
|
||||
}
|
||||
|
||||
// Set up the dock icon if we have an icon image.
|
||||
if (iconImage != nil) {
|
||||
[NSApp setApplicationIconImage:iconImage];
|
||||
[iconImage release];
|
||||
}
|
||||
@ -328,6 +333,45 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
return event;
|
||||
}
|
||||
|
||||
// NSTimeInterval has microseconds precision
|
||||
#define TS_EQUAL(ts1, ts2) (fabs((ts1) - (ts2)) < 1e-6)
|
||||
|
||||
- (void)sendEvent:(NSEvent *)event
|
||||
{
|
||||
if ([event type] == NSApplicationDefined && TS_EQUAL([event timestamp], dummyEventTimestamp)) {
|
||||
[seenDummyEventLock lockWhenCondition:NO];
|
||||
[seenDummyEventLock unlockWithCondition:YES];
|
||||
} else {
|
||||
[super sendEvent:event];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)postDummyEvent {
|
||||
seenDummyEventLock = [[NSConditionLock alloc] initWithCondition:NO];
|
||||
dummyEventTimestamp = [NSProcessInfo processInfo].systemUptime;
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSEvent* event = [NSEvent otherEventWithType: NSApplicationDefined
|
||||
location: NSMakePoint(0,0)
|
||||
modifierFlags: 0
|
||||
timestamp: dummyEventTimestamp
|
||||
windowNumber: 0
|
||||
context: nil
|
||||
subtype: 0
|
||||
data1: 0
|
||||
data2: 0];
|
||||
[NSApp postEvent: event atStart: NO];
|
||||
[pool drain];
|
||||
}
|
||||
|
||||
- (void)waitForDummyEvent {
|
||||
[seenDummyEventLock lockWhenCondition:YES];
|
||||
[seenDummyEventLock unlock];
|
||||
[seenDummyEventLock release];
|
||||
|
||||
seenDummyEventLock = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
BIN
jdk/src/macosx/native/sun/osxapp/resource/icons/JavaApp.icns
Normal file
BIN
jdk/src/macosx/native/sun/osxapp/resource/icons/JavaApp.icns
Normal file
Binary file not shown.
@ -1064,12 +1064,17 @@ public class Krb5LoginModule implements LoginModule {
|
||||
|
||||
if (storeKey) {
|
||||
if (encKeys == null) {
|
||||
if (!privCredSet.contains(ktab)) {
|
||||
privCredSet.add(ktab);
|
||||
// Compatibility; also add keys to privCredSet
|
||||
for (KerberosKey key: ktab.getKeys(kerbClientPrinc)) {
|
||||
privCredSet.add(new Krb5Util.KeysFromKeyTab(key));
|
||||
if (ktab != null) {
|
||||
if (!privCredSet.contains(ktab)) {
|
||||
privCredSet.add(ktab);
|
||||
// Compatibility; also add keys to privCredSet
|
||||
for (KerberosKey key: ktab.getKeys(kerbClientPrinc)) {
|
||||
privCredSet.add(new Krb5Util.KeysFromKeyTab(key));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
succeeded = false;
|
||||
throw new LoginException("No key to store");
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < kerbKeys.length; i ++) {
|
||||
|
@ -104,7 +104,16 @@ public class Choice extends Component implements ItemSelectable, Accessible {
|
||||
/*
|
||||
* JDK 1.1 serialVersionUID
|
||||
*/
|
||||
private static final long serialVersionUID = -4075310674757313071L;
|
||||
private static final long serialVersionUID = -4075310674757313071L;
|
||||
|
||||
static {
|
||||
/* ensure that the necessary native libraries are loaded */
|
||||
Toolkit.loadLibraries();
|
||||
/* initialize JNI field and method ids */
|
||||
if (!GraphicsEnvironment.isHeadless()) {
|
||||
initIDs();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new choice menu. The menu initially has no items in it.
|
||||
@ -711,6 +720,10 @@ public class Choice extends Component implements ItemSelectable, Accessible {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize JNI field and method IDs
|
||||
*/
|
||||
private static native void initIDs();
|
||||
|
||||
/////////////////
|
||||
// Accessibility support
|
||||
|
@ -76,7 +76,7 @@ import sun.security.util.SecurityConstants;
|
||||
* <P>
|
||||
* Be careful when granting FilePermissions. Think about the implications
|
||||
* of granting read and especially write access to various files and
|
||||
* directories. The "<<ALL FILES>>" permission with write action is
|
||||
* directories. The "<<ALL FILES>>" permission with write action is
|
||||
* especially dangerous. This grants permission to write to the entire
|
||||
* file system. One thing this effectively allows is replacement of the
|
||||
* system binary, including the JVM runtime environment.
|
||||
@ -180,9 +180,7 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
* @param mask the actions mask to use.
|
||||
*
|
||||
*/
|
||||
private void init(int mask)
|
||||
{
|
||||
|
||||
private void init(int mask) {
|
||||
if ((mask & ALL) != mask)
|
||||
throw new IllegalArgumentException("invalid actions mask");
|
||||
|
||||
@ -274,9 +272,7 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
* If actions is <code>null</code>, empty or contains an action
|
||||
* other than the specified possible actions.
|
||||
*/
|
||||
|
||||
public FilePermission(String path, String actions)
|
||||
{
|
||||
public FilePermission(String path, String actions) {
|
||||
super(path);
|
||||
init(getMask(actions));
|
||||
}
|
||||
@ -293,8 +289,7 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
*/
|
||||
|
||||
// package private for use by the FilePermissionCollection add method
|
||||
FilePermission(String path, int mask)
|
||||
{
|
||||
FilePermission(String path, int mask) {
|
||||
super(path);
|
||||
init(mask);
|
||||
}
|
||||
@ -337,7 +332,6 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
* this FilePermission's path also implies that FilePermission's path.
|
||||
*
|
||||
* @param that the FilePermission to check against.
|
||||
* @param exact return immediately if the masks are not equal
|
||||
* @return the effective mask
|
||||
*/
|
||||
boolean impliesIgnoreMask(FilePermission that) {
|
||||
@ -412,7 +406,6 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
|
||||
public int hashCode() {
|
||||
return this.cpath.hashCode();
|
||||
}
|
||||
@ -424,7 +417,6 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
* @return the actions mask.
|
||||
*/
|
||||
private static int getMask(String actions) {
|
||||
|
||||
int mask = NONE;
|
||||
|
||||
// Null action valid?
|
||||
@ -552,7 +544,6 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
*
|
||||
* @return the actions mask.
|
||||
*/
|
||||
|
||||
int getMask() {
|
||||
return mask;
|
||||
}
|
||||
@ -564,8 +555,7 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
*
|
||||
* @return the canonical string representation of the actions.
|
||||
*/
|
||||
private static String getActions(int mask)
|
||||
{
|
||||
private static String getActions(int mask) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean comma = false;
|
||||
|
||||
@ -610,15 +600,13 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
*
|
||||
* @return the canonical string representation of the actions.
|
||||
*/
|
||||
public String getActions()
|
||||
{
|
||||
public String getActions() {
|
||||
if (actions == null)
|
||||
actions = getActions(this.mask);
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a new PermissionCollection object for storing FilePermission
|
||||
* objects.
|
||||
@ -650,7 +638,6 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
* @return a new PermissionCollection object suitable for storing
|
||||
* FilePermissions.
|
||||
*/
|
||||
|
||||
public PermissionCollection newPermissionCollection() {
|
||||
return new FilePermissionCollection();
|
||||
}
|
||||
@ -712,22 +699,20 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
*/
|
||||
|
||||
final class FilePermissionCollection extends PermissionCollection
|
||||
implements Serializable {
|
||||
|
||||
implements Serializable
|
||||
{
|
||||
// Not serialized; see serialization section at end of class
|
||||
private transient List<Permission> perms;
|
||||
|
||||
/**
|
||||
* Create an empty FilePermissions object.
|
||||
*
|
||||
* Create an empty FilePermissionCollection object.
|
||||
*/
|
||||
|
||||
public FilePermissionCollection() {
|
||||
perms = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a permission to the FilePermissions. The key for the hash is
|
||||
* Adds a permission to the FilePermissionCollection. The key for the hash is
|
||||
* permission.path.
|
||||
*
|
||||
* @param permission the Permission object to add.
|
||||
@ -738,9 +723,7 @@ implements Serializable {
|
||||
* @exception SecurityException - if this FilePermissionCollection object
|
||||
* has been marked readonly
|
||||
*/
|
||||
|
||||
public void add(Permission permission)
|
||||
{
|
||||
public void add(Permission permission) {
|
||||
if (! (permission instanceof FilePermission))
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
permission);
|
||||
@ -757,16 +740,14 @@ implements Serializable {
|
||||
* Check and see if this set of permissions implies the permissions
|
||||
* expressed in "permission".
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return true if "permission" is a proper subset of a permission in
|
||||
* the set, false if not.
|
||||
*/
|
||||
|
||||
public boolean implies(Permission permission)
|
||||
{
|
||||
public boolean implies(Permission permission) {
|
||||
if (! (permission instanceof FilePermission))
|
||||
return false;
|
||||
return false;
|
||||
|
||||
FilePermission fp = (FilePermission) permission;
|
||||
|
||||
@ -795,7 +776,6 @@ implements Serializable {
|
||||
*
|
||||
* @return an enumeration of all the FilePermission objects.
|
||||
*/
|
||||
|
||||
public Enumeration<Permission> elements() {
|
||||
// Convert Iterator into Enumeration
|
||||
synchronized (this) {
|
||||
@ -841,8 +821,9 @@ implements Serializable {
|
||||
/*
|
||||
* Reads in a Vector of FilePermissions and saves them in the perms field.
|
||||
*/
|
||||
private void readObject(ObjectInputStream in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
// Don't call defaultReadObject()
|
||||
|
||||
// Read in serialized fields
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2012, 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
|
||||
@ -484,7 +484,7 @@ public class ObjectOutputStream
|
||||
* stream. The state is reset to be the same as a new ObjectOutputStream.
|
||||
* The current point in the stream is marked as reset so the corresponding
|
||||
* ObjectInputStream will be reset at the same point. Objects previously
|
||||
* written to the stream will not be refered to as already being in the
|
||||
* written to the stream will not be referred to as already being in the
|
||||
* stream. They will be written to the stream again.
|
||||
*
|
||||
* @throws IOException if reset() is invoked while serializing an object.
|
||||
|
@ -784,7 +784,7 @@ public class PrintWriter extends Writer {
|
||||
* <tt>null</tt> argument depends on the <a
|
||||
* href="../util/Formatter.html#syntax">conversion</a>.
|
||||
*
|
||||
* @throws IllegalFormatException
|
||||
* @throws java.util.IllegalFormatException
|
||||
* If a format string contains an illegal syntax, a format
|
||||
* specifier that is incompatible with the given arguments,
|
||||
* insufficient arguments given the format string, or other
|
||||
@ -835,7 +835,7 @@ public class PrintWriter extends Writer {
|
||||
* <tt>null</tt> argument depends on the <a
|
||||
* href="../util/Formatter.html#syntax">conversion</a>.
|
||||
*
|
||||
* @throws IllegalFormatException
|
||||
* @throws java.util.IllegalFormatException
|
||||
* If a format string contains an illegal syntax, a format
|
||||
* specifier that is incompatible with the given arguments,
|
||||
* insufficient arguments given the format string, or other
|
||||
@ -879,7 +879,7 @@ public class PrintWriter extends Writer {
|
||||
* <tt>null</tt> argument depends on the <a
|
||||
* href="../util/Formatter.html#syntax">conversion</a>.
|
||||
*
|
||||
* @throws IllegalFormatException
|
||||
* @throws java.util.IllegalFormatException
|
||||
* If a format string contains an illegal syntax, a format
|
||||
* specifier that is incompatible with the given arguments,
|
||||
* insufficient arguments given the format string, or other
|
||||
@ -939,7 +939,7 @@ public class PrintWriter extends Writer {
|
||||
* <tt>null</tt> argument depends on the <a
|
||||
* href="../util/Formatter.html#syntax">conversion</a>.
|
||||
*
|
||||
* @throws IllegalFormatException
|
||||
* @throws java.util.IllegalFormatException
|
||||
* If a format string contains an illegal syntax, a format
|
||||
* specifier that is incompatible with the given arguments,
|
||||
* insufficient arguments given the format string, or other
|
||||
|
@ -91,7 +91,7 @@ public abstract class Reader implements Readable, Closeable {
|
||||
* -1 if this source of characters is at its end
|
||||
* @throws IOException if an I/O error occurs
|
||||
* @throws NullPointerException if target is null
|
||||
* @throws ReadOnlyBufferException if target is a read only buffer
|
||||
* @throws java.nio.ReadOnlyBufferException if target is a read only buffer
|
||||
* @since 1.5
|
||||
*/
|
||||
public int read(java.nio.CharBuffer target) throws IOException {
|
||||
|
@ -2970,7 +2970,7 @@ public final
|
||||
/**
|
||||
* Returns a map from simple name to enum constant. This package-private
|
||||
* method is used internally by Enum to implement
|
||||
* public static <T extends Enum<T>> T valueOf(Class<T>, String)
|
||||
* {@code public static <T extends Enum<T>> T valueOf(Class<T>, String)}
|
||||
* efficiently. Note that the map is returned by this method is
|
||||
* created lazily on first use. Typically it won't ever get created.
|
||||
*/
|
||||
|
@ -76,7 +76,6 @@ public class InheritableThreadLocal<T> extends ThreadLocal<T> {
|
||||
*
|
||||
* @param t the current thread
|
||||
* @param firstValue value for the initial entry of the table.
|
||||
* @param map the map to store.
|
||||
*/
|
||||
void createMap(Thread t, T firstValue) {
|
||||
t.inheritableThreadLocals = new ThreadLocalMap(this, firstValue);
|
||||
|
@ -752,7 +752,7 @@ public final class Integer extends Number implements Comparable<Integer> {
|
||||
* -128 and 127 (inclusive) as required by JLS.
|
||||
*
|
||||
* The cache is initialized on first usage. The size of the cache
|
||||
* may be controlled by the -XX:AutoBoxCacheMax=<size> option.
|
||||
* may be controlled by the {@code -XX:AutoBoxCacheMax=<size>} option.
|
||||
* During VM initialization, java.lang.Integer.IntegerCache.high property
|
||||
* may be set and saved in the private system properties in the
|
||||
* sun.misc.VM class.
|
||||
|
@ -316,7 +316,7 @@ public class Package implements java.lang.reflect.AnnotatedElement {
|
||||
* attributes are defined in the manifests that accompany
|
||||
* the classes.
|
||||
*
|
||||
* @param class the class to get the package of.
|
||||
* @param c the class to get the package of.
|
||||
* @return the package of the class. It may be null if no package
|
||||
* information is available from the archive or codebase. */
|
||||
static Package getPackage(Class<?> c) {
|
||||
@ -411,14 +411,13 @@ public class Package implements java.lang.reflect.AnnotatedElement {
|
||||
/**
|
||||
* Construct a package instance with the specified version
|
||||
* information.
|
||||
* @param pkgName the name of the package
|
||||
* @param name the name of the package
|
||||
* @param spectitle the title of the specification
|
||||
* @param specversion the version of the specification
|
||||
* @param specvendor the organization that maintains the specification
|
||||
* @param impltitle the title of the implementation
|
||||
* @param implversion the version of the implementation
|
||||
* @param implvendor the organization that maintains the implementation
|
||||
* @return a new package for containing the specified information.
|
||||
*/
|
||||
Package(String name,
|
||||
String spectitle, String specversion, String specvendor,
|
||||
|
@ -365,7 +365,7 @@ public final class StrictMath {
|
||||
* @param a the value to be floored or ceiled
|
||||
* @param negativeBoundary result for values in (-1, 0)
|
||||
* @param positiveBoundary result for values in (0, 1)
|
||||
* @param increment value to add when the argument is non-integral
|
||||
* @param sign the sign of the result
|
||||
*/
|
||||
private static double floorOrCeil(double a,
|
||||
double negativeBoundary,
|
||||
@ -811,7 +811,7 @@ public final class StrictMath {
|
||||
* @param value the long value
|
||||
* @return the argument as an int
|
||||
* @throws ArithmeticException if the {@code argument} overflows an int
|
||||
* @see Math#toIntExact(int)
|
||||
* @see Math#toIntExact(long)
|
||||
* @since 1.8
|
||||
*/
|
||||
public static int toIntExact(long value) {
|
||||
|
@ -2782,7 +2782,7 @@ public final class String
|
||||
* <tt>null</tt> argument depends on the <a
|
||||
* href="../util/Formatter.html#syntax">conversion</a>.
|
||||
*
|
||||
* @throws IllegalFormatException
|
||||
* @throws java.util.IllegalFormatException
|
||||
* If a format string contains an illegal syntax, a format
|
||||
* specifier that is incompatible with the given arguments,
|
||||
* insufficient arguments given the format string, or other
|
||||
@ -2826,7 +2826,7 @@ public final class String
|
||||
* <tt>null</tt> argument depends on the <a
|
||||
* href="../util/Formatter.html#syntax">conversion</a>.
|
||||
*
|
||||
* @throws IllegalFormatException
|
||||
* @throws java.util.IllegalFormatException
|
||||
* If a format string contains an illegal syntax, a format
|
||||
* specifier that is incompatible with the given arguments,
|
||||
* insufficient arguments given the format string, or other
|
||||
|
@ -545,7 +545,7 @@ public final class System {
|
||||
* <tr><td><code>java.version</code></td>
|
||||
* <td>Java Runtime Environment version</td></tr>
|
||||
* <tr><td><code>java.vendor</code></td>
|
||||
* <td>Java Runtime Environment vendor</td></tr
|
||||
* <td>Java Runtime Environment vendor</td></tr>
|
||||
* <tr><td><code>java.vendor.url</code></td>
|
||||
* <td>Java vendor URL</td></tr>
|
||||
* <tr><td><code>java.home</code></td>
|
||||
|
@ -918,9 +918,6 @@ class ThreadGroup implements Thread.UncaughtExceptionHandler {
|
||||
*
|
||||
* @param t
|
||||
* the Thread whose start method was invoked
|
||||
*
|
||||
* @param failed
|
||||
* true if the thread could not be started successfully
|
||||
*/
|
||||
void threadStartFailed(Thread t) {
|
||||
synchronized(this) {
|
||||
|
@ -47,8 +47,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
* private static final AtomicInteger nextId = new AtomicInteger(0);
|
||||
*
|
||||
* // Thread local variable containing each thread's ID
|
||||
* private static final ThreadLocal<Integer> threadId =
|
||||
* new ThreadLocal<Integer>() {
|
||||
* private static final ThreadLocal<Integer> threadId =
|
||||
* new ThreadLocal<Integer>() {
|
||||
* @Override protected Integer initialValue() {
|
||||
* return nextId.getAndIncrement();
|
||||
* }
|
||||
@ -222,7 +222,6 @@ public class ThreadLocal<T> {
|
||||
*
|
||||
* @param t the current thread
|
||||
* @param firstValue value for the initial entry of the map
|
||||
* @param map the map to store.
|
||||
*/
|
||||
void createMap(Thread t, T firstValue) {
|
||||
t.threadLocals = new ThreadLocalMap(this, firstValue);
|
||||
|
@ -147,8 +147,9 @@ public class ThreadInfo {
|
||||
* @param waitedCount Number of times waited on a lock
|
||||
* @param waitedTime Approx time waited on a lock
|
||||
* @param stackTrace Thread stack trace
|
||||
* @param lockedMonitors List of locked monitors
|
||||
* @param lockedSynchronizers List of locked synchronizers
|
||||
* @param monitors List of locked monitors
|
||||
* @param stackDepths List of stack depths
|
||||
* @param synchronizers List of locked synchronizers
|
||||
*/
|
||||
private ThreadInfo(Thread t, int state, Object lockObj, Thread lockOwner,
|
||||
long blockedCount, long blockedTime,
|
||||
|
@ -48,11 +48,6 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
protected InetAddress connectedAddress = null;
|
||||
private int connectedPort = -1;
|
||||
|
||||
/* cached socket options */
|
||||
private int multicastInterface = 0;
|
||||
private boolean loopbackMode = true;
|
||||
private int ttl = -1;
|
||||
|
||||
private static final String os = AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("os.name")
|
||||
);
|
||||
@ -104,7 +99,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
/**
|
||||
* Sends a datagram packet. The packet contains the data and the
|
||||
* destination address to send the packet to.
|
||||
* @param packet to be sent.
|
||||
* @param p the packet to be sent.
|
||||
*/
|
||||
protected abstract void send(DatagramPacket p) throws IOException;
|
||||
|
||||
@ -135,13 +130,13 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
|
||||
/**
|
||||
* Peek at the packet to see who it is from.
|
||||
* @param return the address which the packet came from.
|
||||
* @param i the address to populate with the sender address
|
||||
*/
|
||||
protected abstract int peek(InetAddress i) throws IOException;
|
||||
protected abstract int peekData(DatagramPacket p) throws IOException;
|
||||
/**
|
||||
* Receive the datagram packet.
|
||||
* @param Packet Received.
|
||||
* @param p the packet to receive into
|
||||
*/
|
||||
protected synchronized void receive(DatagramPacket p)
|
||||
throws IOException {
|
||||
@ -153,7 +148,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
|
||||
/**
|
||||
* Set the TTL (time-to-live) option.
|
||||
* @param TTL to be set.
|
||||
* @param ttl TTL to be set.
|
||||
*/
|
||||
protected abstract void setTimeToLive(int ttl) throws IOException;
|
||||
|
||||
@ -164,7 +159,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
|
||||
/**
|
||||
* Set the TTL (time-to-live) option.
|
||||
* @param TTL to be set.
|
||||
* @param ttl TTL to be set.
|
||||
*/
|
||||
@Deprecated
|
||||
protected abstract void setTTL(byte ttl) throws IOException;
|
||||
@ -177,7 +172,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
|
||||
/**
|
||||
* Join the multicast group.
|
||||
* @param multicast address to join.
|
||||
* @param inetaddr multicast address to join.
|
||||
*/
|
||||
protected void join(InetAddress inetaddr) throws IOException {
|
||||
join(inetaddr, null);
|
||||
@ -185,14 +180,14 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
|
||||
/**
|
||||
* Leave the multicast group.
|
||||
* @param multicast address to leave.
|
||||
* @param inetaddr multicast address to leave.
|
||||
*/
|
||||
protected void leave(InetAddress inetaddr) throws IOException {
|
||||
leave(inetaddr, null);
|
||||
}
|
||||
/**
|
||||
* Join the multicast group.
|
||||
* @param multicast address to join.
|
||||
* @param mcastaddr multicast address to join.
|
||||
* @param netIf specifies the local interface to receive multicast
|
||||
* datagram packets
|
||||
* @throws IllegalArgumentException if mcastaddr is null or is a
|
||||
@ -212,7 +207,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
|
||||
/**
|
||||
* Leave the multicast group.
|
||||
* @param multicast address to leave.
|
||||
* @param mcastaddr multicast address to leave.
|
||||
* @param netIf specified the local interface to leave the group at
|
||||
* @throws IllegalArgumentException if mcastaddr is null or is a
|
||||
* SocketAddress subclass not supported by this socket
|
||||
|
@ -368,7 +368,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
|
||||
/**
|
||||
* Binds the socket to the specified address of the specified local port.
|
||||
* @param address the address
|
||||
* @param port the port
|
||||
* @param lport the port
|
||||
*/
|
||||
protected synchronized void bind(InetAddress address, int lport)
|
||||
throws IOException
|
||||
|
@ -105,7 +105,7 @@ class DatagramSocket implements java.io.Closeable {
|
||||
* Connects this socket to a remote socket address (IP address + port number).
|
||||
* Binds socket if not already bound.
|
||||
* <p>
|
||||
* @param addr The remote address.
|
||||
* @param address The remote address.
|
||||
* @param port The remote port
|
||||
* @throws SocketException if binding the socket fails.
|
||||
*/
|
||||
|
@ -177,7 +177,6 @@ class Inet4Address extends InetAddress {
|
||||
* a loopback address; or false otherwise.
|
||||
* @since 1.4
|
||||
*/
|
||||
private static final int loopback = 2130706433; /* 127.0.0.1 */
|
||||
public boolean isLoopbackAddress() {
|
||||
/* 127.x.x.x */
|
||||
byte[] byteAddr = getAddress();
|
||||
|
@ -112,7 +112,7 @@ class SocketInputStream extends FileInputStream
|
||||
* <i>length</i> bytes of data.
|
||||
* @param b the buffer into which the data is read
|
||||
* @param off the start offset of the data
|
||||
* @param len the maximum number of bytes read
|
||||
* @param length the maximum number of bytes read
|
||||
* @return the actual number of bytes read, -1 is
|
||||
* returned when the end of the stream is reached.
|
||||
* @exception IOException If an I/O error has occurred.
|
||||
@ -209,7 +209,7 @@ class SocketInputStream extends FileInputStream
|
||||
|
||||
/**
|
||||
* Skips n bytes of input.
|
||||
* @param n the number of bytes to skip
|
||||
* @param numbytes the number of bytes to skip
|
||||
* @return the actual number of bytes skipped.
|
||||
* @exception IOException If an I/O error has occurred.
|
||||
*/
|
||||
|
@ -138,7 +138,7 @@ import sun.security.util.Debug;
|
||||
*/
|
||||
|
||||
public final class SocketPermission extends Permission
|
||||
implements java.io.Serializable
|
||||
implements java.io.Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -7204263841984476862L;
|
||||
|
||||
@ -232,8 +232,7 @@ implements java.io.Serializable
|
||||
trustNameService = tmp.booleanValue();
|
||||
}
|
||||
|
||||
private static synchronized Debug getDebug()
|
||||
{
|
||||
private static synchronized Debug getDebug() {
|
||||
if (!debugInit) {
|
||||
debug = Debug.getInstance("access");
|
||||
debugInit = true;
|
||||
@ -288,8 +287,7 @@ implements java.io.Serializable
|
||||
defaultDeny = true;
|
||||
}
|
||||
|
||||
private static String getHost(String host)
|
||||
{
|
||||
private static String getHost(String host) {
|
||||
if (host.equals("")) {
|
||||
return "localhost";
|
||||
} else {
|
||||
@ -679,8 +677,8 @@ implements java.io.Serializable
|
||||
}
|
||||
|
||||
private boolean authorizedIPv4(String cname, byte[] addr) {
|
||||
String authHost = "";
|
||||
InetAddress auth;
|
||||
String authHost = "";
|
||||
InetAddress auth;
|
||||
|
||||
try {
|
||||
authHost = "auth." +
|
||||
@ -708,8 +706,8 @@ implements java.io.Serializable
|
||||
}
|
||||
|
||||
private boolean authorizedIPv6(String cname, byte[] addr) {
|
||||
String authHost = "";
|
||||
InetAddress auth;
|
||||
String authHost = "";
|
||||
InetAddress auth;
|
||||
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer(39);
|
||||
@ -810,7 +808,6 @@ implements java.io.Serializable
|
||||
* @return true if the specified permission is implied by this object,
|
||||
* false if not.
|
||||
*/
|
||||
|
||||
public boolean implies(Permission p) {
|
||||
int i,j;
|
||||
|
||||
@ -844,12 +841,11 @@ implements java.io.Serializable
|
||||
* to find a match based on the IP addresses in both objects.
|
||||
* <li> Attempt to match on the canonical hostnames of both objects.
|
||||
* </ul>
|
||||
* @param p the incoming permission request
|
||||
* @param that the incoming permission request
|
||||
*
|
||||
* @return true if "permission" is a proper subset of the current object,
|
||||
* false if not.
|
||||
*/
|
||||
|
||||
boolean impliesIgnoreMask(SocketPermission that) {
|
||||
int i,j;
|
||||
|
||||
@ -1229,7 +1225,7 @@ else its the cname?
|
||||
*/
|
||||
|
||||
final class SocketPermissionCollection extends PermissionCollection
|
||||
implements Serializable
|
||||
implements Serializable
|
||||
{
|
||||
// Not serialized; see serialization section at end of class
|
||||
private transient List<SocketPermission> perms;
|
||||
@ -1255,9 +1251,7 @@ implements Serializable
|
||||
* @exception SecurityException - if this SocketPermissionCollection object
|
||||
* has been marked readonly
|
||||
*/
|
||||
|
||||
public void add(Permission permission)
|
||||
{
|
||||
public void add(Permission permission) {
|
||||
if (! (permission instanceof SocketPermission))
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
permission);
|
||||
@ -1276,7 +1270,7 @@ implements Serializable
|
||||
* Check and see if this collection of permissions implies the permissions
|
||||
* expressed in "permission".
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return true if "permission" is a proper subset of a permission in
|
||||
* the collection, false if not.
|
||||
@ -1369,8 +1363,9 @@ implements Serializable
|
||||
/*
|
||||
* Reads in a Vector of SocketPermissions and saves them in the perms field.
|
||||
*/
|
||||
private void readObject(ObjectInputStream in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
// Don't call in.defaultReadObject()
|
||||
|
||||
// Read in serialized fields
|
||||
|
@ -644,7 +644,7 @@ class SocksSocketImpl extends PlainSocketImpl implements SocksConsts {
|
||||
* means "accept incoming connection from", so the SocketAddress is the
|
||||
* the one of the host we do accept connection from.
|
||||
*
|
||||
* @param addr the Socket address of the remote host.
|
||||
* @param saddr the Socket address of the remote host.
|
||||
* @exception IOException if an I/O error occurs when binding this socket.
|
||||
*/
|
||||
protected synchronized void socksBind(InetSocketAddress saddr) throws IOException {
|
||||
|
@ -1241,10 +1241,9 @@ public abstract class URLConnection {
|
||||
|
||||
/**
|
||||
* Gets the Content Handler appropriate for this connection.
|
||||
* @param connection the connection to use.
|
||||
*/
|
||||
synchronized ContentHandler getContentHandler()
|
||||
throws UnknownServiceException
|
||||
throws UnknownServiceException
|
||||
{
|
||||
String contentType = stripOffParameters(getContentType());
|
||||
ContentHandler handler = null;
|
||||
|
@ -741,6 +741,8 @@ public abstract class $Type$Buffer
|
||||
public $Type$Buffer put($Type$Buffer src) {
|
||||
if (src == this)
|
||||
throw new IllegalArgumentException();
|
||||
if (isReadOnly())
|
||||
throw new ReadOnlyBufferException();
|
||||
int n = src.remaining();
|
||||
if (n > remaining())
|
||||
throw new BufferOverflowException();
|
||||
@ -888,6 +890,8 @@ public abstract class $Type$Buffer
|
||||
*/
|
||||
public $Type$Buffer put(String src, int start, int end) {
|
||||
checkBounds(start, end - start, src.length());
|
||||
if (isReadOnly())
|
||||
throw new ReadOnlyBufferException();
|
||||
if (end - start > remaining())
|
||||
throw new BufferOverflowException();
|
||||
for (int i = start; i < end; i++)
|
||||
|
@ -84,7 +84,7 @@ public final class Channels {
|
||||
/**
|
||||
* Write all remaining bytes in buffer to the given channel.
|
||||
*
|
||||
* @throws IllegalBlockingException
|
||||
* @throws IllegalBlockingModeException
|
||||
* If the channel is selectable and configured non-blocking.
|
||||
*/
|
||||
private static void writeFully(WritableByteChannel ch, ByteBuffer bb)
|
||||
|
@ -347,7 +347,7 @@ public abstract class FileSystem
|
||||
* <td><tt>C:\\*</tt>
|
||||
* <td>Matches <tt>C:\foo</tt> and <tt>C:\bar</tt> on the Windows
|
||||
* platform (note that the backslash is escaped; as a string literal in the
|
||||
* Java Language the pattern would be <tt>"C:\\\\*"</tt>) </td>
|
||||
* Java Language the pattern would be <tt>"C:\\\\*"</tt>) </td>
|
||||
* </tr>
|
||||
*
|
||||
* </table>
|
||||
|
@ -510,7 +510,7 @@ public final class Files {
|
||||
* <pre>
|
||||
* DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
|
||||
* public boolean accept(Path file) throws IOException {
|
||||
* return (Files.size(file) > 8192L);
|
||||
* return (Files.size(file) > 8192L);
|
||||
* }
|
||||
* };
|
||||
* Path dir = ...
|
||||
@ -1592,7 +1592,7 @@ public final class Files {
|
||||
* Path path = ...
|
||||
* AclFileAttributeView view = Files.getFileAttributeView(path, AclFileAttributeView.class);
|
||||
* if (view != null) {
|
||||
* List<AclEntry> acl = view.getAcl();
|
||||
* List<AclEntry> acl = view.getAcl();
|
||||
* :
|
||||
* }
|
||||
* </pre>
|
||||
|
@ -522,7 +522,7 @@ public interface Path
|
||||
*
|
||||
* @return a {@code Path} object representing the absolute path
|
||||
*
|
||||
* @throws IOError
|
||||
* @throws java.io.IOError
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, a security manager
|
||||
|
@ -85,7 +85,7 @@ import java.io.IOException;
|
||||
* .build();
|
||||
*
|
||||
* // read ACL, insert ACE, re-write ACL
|
||||
* List<AclEntry> acl = view.getAcl();
|
||||
* List<AclEntry> acl = view.getAcl();
|
||||
* acl.add(0, entry); // insert before any DENY entries
|
||||
* view.setAcl(acl);
|
||||
* </pre>
|
||||
|
@ -310,7 +310,7 @@ public final class FileTime
|
||||
private final long days;
|
||||
|
||||
/**
|
||||
* The excess (in nanoseconds); can be negative if days <= 0.
|
||||
* The excess (in nanoseconds); can be negative if days <= 0.
|
||||
*/
|
||||
private final long excessNanos;
|
||||
|
||||
|
@ -62,9 +62,7 @@ public final class AllPermission extends Permission {
|
||||
/**
|
||||
* Creates a new AllPermission object.
|
||||
*/
|
||||
|
||||
public AllPermission()
|
||||
{
|
||||
public AllPermission() {
|
||||
super("<all permissions>");
|
||||
}
|
||||
|
||||
@ -77,8 +75,7 @@ public final class AllPermission extends Permission {
|
||||
* @param name ignored
|
||||
* @param actions ignored.
|
||||
*/
|
||||
public AllPermission(String name, String actions)
|
||||
{
|
||||
public AllPermission(String name, String actions) {
|
||||
this();
|
||||
}
|
||||
|
||||
@ -120,8 +117,7 @@ public final class AllPermission extends Permission {
|
||||
*
|
||||
* @return the actions.
|
||||
*/
|
||||
public String getActions()
|
||||
{
|
||||
public String getActions() {
|
||||
return "<all actions>";
|
||||
}
|
||||
|
||||
@ -133,7 +129,6 @@ public final class AllPermission extends Permission {
|
||||
* @return a new PermissionCollection object suitable for
|
||||
* storing AllPermissions.
|
||||
*/
|
||||
|
||||
public PermissionCollection newPermissionCollection() {
|
||||
return new AllPermissionCollection();
|
||||
}
|
||||
@ -157,8 +152,8 @@ public final class AllPermission extends Permission {
|
||||
*/
|
||||
|
||||
final class AllPermissionCollection
|
||||
extends PermissionCollection
|
||||
implements java.io.Serializable
|
||||
extends PermissionCollection
|
||||
implements java.io.Serializable
|
||||
{
|
||||
|
||||
// use serialVersionUID from JDK 1.2.2 for interoperability
|
||||
@ -188,8 +183,7 @@ implements java.io.Serializable
|
||||
* has been marked readonly
|
||||
*/
|
||||
|
||||
public void add(Permission permission)
|
||||
{
|
||||
public void add(Permission permission) {
|
||||
if (! (permission instanceof AllPermission))
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
permission);
|
||||
@ -203,13 +197,12 @@ implements java.io.Serializable
|
||||
* Check and see if this set of permissions implies the permissions
|
||||
* expressed in "permission".
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return always returns true.
|
||||
*/
|
||||
|
||||
public boolean implies(Permission permission)
|
||||
{
|
||||
public boolean implies(Permission permission) {
|
||||
return all_allowed; // No sync; staleness OK
|
||||
}
|
||||
|
||||
@ -219,8 +212,7 @@ implements java.io.Serializable
|
||||
*
|
||||
* @return an enumeration of all the AllPermission objects.
|
||||
*/
|
||||
public Enumeration<Permission> elements()
|
||||
{
|
||||
public Enumeration<Permission> elements() {
|
||||
return new Enumeration<Permission>() {
|
||||
private boolean hasMore = all_allowed;
|
||||
|
||||
|
@ -68,7 +68,7 @@ import java.io.IOException;
|
||||
*/
|
||||
|
||||
public abstract class BasicPermission extends Permission
|
||||
implements java.io.Serializable
|
||||
implements java.io.Serializable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 6279438298436773498L;
|
||||
@ -84,10 +84,8 @@ implements java.io.Serializable
|
||||
|
||||
/**
|
||||
* initialize a BasicPermission object. Common to all constructors.
|
||||
*
|
||||
*/
|
||||
private void init(String name)
|
||||
{
|
||||
private void init(String name) {
|
||||
if (name == null)
|
||||
throw new NullPointerException("name can't be null");
|
||||
|
||||
@ -129,9 +127,7 @@ implements java.io.Serializable
|
||||
* @throws NullPointerException if <code>name</code> is <code>null</code>.
|
||||
* @throws IllegalArgumentException if <code>name</code> is empty.
|
||||
*/
|
||||
|
||||
public BasicPermission(String name)
|
||||
{
|
||||
public BasicPermission(String name) {
|
||||
super(name);
|
||||
init(name);
|
||||
}
|
||||
@ -148,8 +144,7 @@ implements java.io.Serializable
|
||||
* @throws NullPointerException if <code>name</code> is <code>null</code>.
|
||||
* @throws IllegalArgumentException if <code>name</code> is empty.
|
||||
*/
|
||||
public BasicPermission(String name, String actions)
|
||||
{
|
||||
public BasicPermission(String name, String actions) {
|
||||
super(name);
|
||||
init(name);
|
||||
}
|
||||
@ -238,8 +233,7 @@ implements java.io.Serializable
|
||||
*
|
||||
* @return the empty string "".
|
||||
*/
|
||||
public String getActions()
|
||||
{
|
||||
public String getActions() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -296,7 +290,6 @@ implements java.io.Serializable
|
||||
*
|
||||
* @see java.security.Permission
|
||||
* @see java.security.Permissions
|
||||
* @see java.security.PermissionsImpl
|
||||
*
|
||||
*
|
||||
* @author Roland Schemers
|
||||
@ -305,8 +298,8 @@ implements java.io.Serializable
|
||||
*/
|
||||
|
||||
final class BasicPermissionCollection
|
||||
extends PermissionCollection
|
||||
implements java.io.Serializable
|
||||
extends PermissionCollection
|
||||
implements java.io.Serializable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 739301742472979399L;
|
||||
@ -360,9 +353,7 @@ implements java.io.Serializable
|
||||
* @exception SecurityException - if this BasicPermissionCollection object
|
||||
* has been marked readonly
|
||||
*/
|
||||
|
||||
public void add(Permission permission)
|
||||
{
|
||||
public void add(Permission permission) {
|
||||
if (! (permission instanceof BasicPermission))
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
permission);
|
||||
@ -398,16 +389,14 @@ implements java.io.Serializable
|
||||
* Check and see if this set of permissions implies the permissions
|
||||
* expressed in "permission".
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return true if "permission" is a proper subset of a permission in
|
||||
* the set, false if not.
|
||||
*/
|
||||
|
||||
public boolean implies(Permission permission)
|
||||
{
|
||||
public boolean implies(Permission permission) {
|
||||
if (! (permission instanceof BasicPermission))
|
||||
return false;
|
||||
return false;
|
||||
|
||||
BasicPermission bp = (BasicPermission) permission;
|
||||
|
||||
@ -468,7 +457,6 @@ implements java.io.Serializable
|
||||
*
|
||||
* @return an enumeration of all the BasicPermission objects.
|
||||
*/
|
||||
|
||||
public Enumeration<Permission> elements() {
|
||||
// Convert Iterator of Map values into an Enumeration
|
||||
synchronized (this) {
|
||||
|
@ -207,7 +207,7 @@ public class CodeSource implements java.io.Serializable {
|
||||
* Returns the code signers associated with this CodeSource.
|
||||
* <p>
|
||||
* If this CodeSource object was created using the
|
||||
* {@link #CodeSource(URL url, Certificate[] certs)}
|
||||
* {@link #CodeSource(URL url, java.security.cert.Certificate[] certs)}
|
||||
* constructor then its certificate chains are extracted and used to
|
||||
* create an array of CodeSigner objects. Note that only X.509 certificates
|
||||
* are examined - all other certificate types are ignored.
|
||||
|
@ -32,6 +32,7 @@ import java.security.cert.CertificateException;
|
||||
import java.util.*;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import javax.security.auth.DestroyFailedException;
|
||||
import javax.security.auth.callback.*;
|
||||
|
||||
/**
|
||||
@ -278,8 +279,7 @@ public class KeyStore {
|
||||
* @exception DestroyFailedException if this method was unable
|
||||
* to clear the password
|
||||
*/
|
||||
public synchronized void destroy()
|
||||
throws javax.security.auth.DestroyFailedException {
|
||||
public synchronized void destroy() throws DestroyFailedException {
|
||||
destroyed = true;
|
||||
if (password != null) {
|
||||
Arrays.fill(password, ' ');
|
||||
|
@ -50,7 +50,7 @@ import java.util.Set;
|
||||
* status of certificates with OCSP and CRLs. By default, OCSP is the
|
||||
* preferred mechanism for checking revocation status, with CRLs as the
|
||||
* fallback mechanism. However, this preference can be switched to CRLs with
|
||||
* the {@link Option.PREFER_CRLS} option.
|
||||
* the {@link Option#PREFER_CRLS PREFER_CRLS} option.
|
||||
*
|
||||
* <p>A {@code PKIXRevocationChecker} is obtained by calling the
|
||||
* {@link CertPathValidator#getRevocationChecker getRevocationChecker} method
|
||||
|
@ -1562,7 +1562,7 @@ public interface CallableStatement extends PreparedStatement {
|
||||
* @param parameterName the name of the parameter
|
||||
* @return the parameter value in full precision. If the value is
|
||||
* SQL <code>NULL</code>, the result is <code>null</code>.
|
||||
* @exception SQLExceptionif parameterName does not correspond to a named
|
||||
* @exception SQLException if parameterName does not correspond to a named
|
||||
* parameter; if a database access error occurs or
|
||||
* this method is called on a closed <code>CallableStatement</code>
|
||||
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
|
||||
|
@ -119,7 +119,7 @@ public final class CollationElementIterator
|
||||
* on the predefined collation rules. If the source string is empty,
|
||||
* NULLORDER will be returned on the calls to next().
|
||||
* @param sourceText the source string.
|
||||
* @param order the collation object.
|
||||
* @param owner the collation object.
|
||||
*/
|
||||
CollationElementIterator(String sourceText, RuleBasedCollator owner) {
|
||||
this.owner = owner;
|
||||
@ -137,7 +137,7 @@ public final class CollationElementIterator
|
||||
* on the predefined collation rules. If the source string is empty,
|
||||
* NULLORDER will be returned on the calls to next().
|
||||
* @param sourceText the source string.
|
||||
* @param order the collation object.
|
||||
* @param owner the collation object.
|
||||
*/
|
||||
CollationElementIterator(CharacterIterator sourceText, RuleBasedCollator owner) {
|
||||
this.owner = owner;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -62,7 +62,7 @@ import java.math.RoundingMode;
|
||||
* derived by placing all the digits of the list to the right of the
|
||||
* decimal point, by 10^exponent.
|
||||
*
|
||||
* @see Locale
|
||||
* @see java.util.Locale
|
||||
* @see Format
|
||||
* @see NumberFormat
|
||||
* @see DecimalFormat
|
||||
|
@ -370,7 +370,7 @@ public abstract class Format implements Serializable, Cloneable {
|
||||
* Delegates should NOT assume that the <code>Format</code> will notify
|
||||
* the delegate of fields in any particular order.
|
||||
*
|
||||
* @see FieldPosition.Delegate
|
||||
* @see FieldPosition#getFieldDelegate
|
||||
* @see CharacterIteratorFieldDelegate
|
||||
*/
|
||||
interface FieldDelegate {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2012, 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
|
||||
@ -286,10 +286,21 @@ public abstract class NumberFormat extends Format {
|
||||
* @see java.text.Format#format
|
||||
*/
|
||||
public final String format(double number) {
|
||||
// Use fast-path for double result if that works
|
||||
String result = fastFormat(number);
|
||||
if (result != null)
|
||||
return result;
|
||||
|
||||
return format(number, new StringBuffer(),
|
||||
DontCareFieldPosition.INSTANCE).toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* fastFormat() is supposed to be implemented in concrete subclasses only.
|
||||
* Default implem always returns null.
|
||||
*/
|
||||
String fastFormat(double number) { return null; }
|
||||
|
||||
/**
|
||||
* Specialization of format.
|
||||
* @exception ArithmeticException if rounding is needed with rounding
|
||||
|
@ -192,13 +192,12 @@ final class RBCollationTables {
|
||||
*
|
||||
* @see CollationElementIterator#getMaxExpansion
|
||||
*/
|
||||
int getMaxExpansion(int order)
|
||||
{
|
||||
int getMaxExpansion(int order) {
|
||||
int result = 1;
|
||||
|
||||
if (expandTable != null) {
|
||||
// Right now this does a linear search through the entire
|
||||
// expandsion table. If a collator had a large number of expansions,
|
||||
// expansion table. If a collator had a large number of expansions,
|
||||
// this could cause a performance problem, but in practise that
|
||||
// rarely happens
|
||||
for (int i = 0; i < expandTable.size(); i++) {
|
||||
@ -215,20 +214,19 @@ final class RBCollationTables {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry of hash table of the expanding string in the collation
|
||||
* table.
|
||||
* @param idx the index of the expanding string value list
|
||||
* Get the entry of hash table of the expanding string in the collation
|
||||
* table.
|
||||
* @param idx the index of the expanding string value list
|
||||
*/
|
||||
final int[] getExpandValueList(int order) {
|
||||
return expandTable.elementAt(order - EXPANDCHARINDEX);
|
||||
final int[] getExpandValueList(int idx) {
|
||||
return expandTable.elementAt(idx - EXPANDCHARINDEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the comarison order of a character from the collation table.
|
||||
* @return the comparison order of a character.
|
||||
* Get the comarison order of a character from the collation table.
|
||||
* @return the comparison order of a character.
|
||||
*/
|
||||
int getUnicodeOrder(int ch)
|
||||
{
|
||||
int getUnicodeOrder(int ch) {
|
||||
return mapping.elementAt(ch);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ final class RBTableBuilder {
|
||||
* This is the main function that actually builds the tables and
|
||||
* stores them back in the RBCollationTables object. It is called
|
||||
* ONLY by the RBCollationTables constructor.
|
||||
* @see java.util.RuleBasedCollator#RuleBasedCollator
|
||||
* @see RuleBasedCollator#RuleBasedCollator
|
||||
* @exception ParseException If the rules format is incorrect.
|
||||
*/
|
||||
|
||||
|
@ -1787,7 +1787,7 @@ public class SimpleDateFormat extends DateFormat {
|
||||
* timeFields. Returns -start (for ParsePosition) if failed.
|
||||
* @param text the time text to be parsed.
|
||||
* @param start where to start parsing.
|
||||
* @param ch the pattern character for the date field text to be parsed.
|
||||
* @param patternCharIndex the index of the pattern character.
|
||||
* @param count the count of a pattern character.
|
||||
* @param obeyCount if true, then the next field directly abuts this one,
|
||||
* and we should use the count to know when to stop parsing.
|
||||
|
@ -1788,7 +1788,6 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
||||
*
|
||||
* @return a bit mask of selected fields
|
||||
* @see #isExternallySet(int)
|
||||
* @see #setInternallySetState(int)
|
||||
*/
|
||||
final int selectFields() {
|
||||
// This implementation has been taken from the GregorianCalendar class.
|
||||
|
@ -665,7 +665,7 @@ public final class Currency implements Serializable {
|
||||
*
|
||||
* @param pattern regex pattern for the properties
|
||||
* @param ctry country code
|
||||
* @param data currency data. This is a comma separated string that
|
||||
* @param curdata currency data. This is a comma separated string that
|
||||
* consists of "three-letter alphabet code", "three-digit numeric code",
|
||||
* and "one-digit (0,1,2, or 3) default fraction digit".
|
||||
* For example, "JPZ,392,0".
|
||||
|
@ -918,7 +918,7 @@ import sun.misc.FormattedFloatingDecimal;
|
||||
* <p> If the {@code '0'} flag is given then the output will be padded
|
||||
* with leading zeros to the field width following any indication of sign.
|
||||
*
|
||||
* <p> If {@code '('}, {@code '+'}, '  ', or {@code ','} flags
|
||||
* <p> If {@code '('}, {@code '+'}, ' ', or {@code ','} flags
|
||||
* are given then a {@link FormatFlagsConversionMismatchException} will be
|
||||
* thrown.
|
||||
*
|
||||
|
@ -1932,7 +1932,7 @@ class JapaneseImperialCalendar extends Calendar {
|
||||
* Computes the fixed date under either the Gregorian or the
|
||||
* Julian calendar, using the given year and the specified calendar fields.
|
||||
*
|
||||
* @param cal the CalendarSystem to be used for the date calculation
|
||||
* @param era era index
|
||||
* @param year the normalized year number, with 0 indicating the
|
||||
* year 1 BCE, -1 indicating 2 BCE, etc.
|
||||
* @param fieldMask the calendar fields to be used for the date calculation
|
||||
@ -2141,7 +2141,7 @@ class JapaneseImperialCalendar extends Calendar {
|
||||
* Returns the length of the specified month in the specified
|
||||
* Gregorian year. The year number must be normalized.
|
||||
*
|
||||
* @see #isLeapYear(int)
|
||||
* @see GregorianCalendar#isLeapYear(int)
|
||||
*/
|
||||
private int monthLength(int month, int gregorianYear) {
|
||||
return CalendarUtils.isGregorianLeapYear(gregorianYear) ?
|
||||
@ -2152,7 +2152,7 @@ class JapaneseImperialCalendar extends Calendar {
|
||||
* Returns the length of the specified month in the year provided
|
||||
* by internalGet(YEAR).
|
||||
*
|
||||
* @see #isLeapYear(int)
|
||||
* @see GregorianCalendar#isLeapYear(int)
|
||||
*/
|
||||
private int monthLength(int month) {
|
||||
assert jdate.isNormalized();
|
||||
|
@ -345,7 +345,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
* the same size, and every member of the given set is contained in
|
||||
* this set.
|
||||
*
|
||||
* @param e object to be compared for equality with this set
|
||||
* @param o object to be compared for equality with this set
|
||||
* @return <tt>true</tt> if the specified object is equal to this set
|
||||
*/
|
||||
public boolean equals(Object o) {
|
||||
|
@ -55,6 +55,7 @@ import sun.util.locale.BaseLocale;
|
||||
import sun.util.locale.InternalLocaleBuilder;
|
||||
import sun.util.locale.LanguageTag;
|
||||
import sun.util.locale.LocaleExtensions;
|
||||
import sun.util.locale.LocaleMatcher;
|
||||
import sun.util.locale.LocaleObjectCache;
|
||||
import sun.util.locale.LocaleSyntaxException;
|
||||
import sun.util.locale.LocaleUtils;
|
||||
@ -71,10 +72,11 @@ import sun.util.resources.OpenListResourceBundle;
|
||||
* according to the customs and conventions of the user's native country,
|
||||
* region, or culture.
|
||||
*
|
||||
* <p> The <code>Locale</code> class implements identifiers
|
||||
* interchangeable with BCP 47 (IETF BCP 47, "Tags for Identifying
|
||||
* Languages"), with support for the LDML (UTS#35, "Unicode Locale
|
||||
* Data Markup Language") BCP 47-compatible extensions for locale data
|
||||
* <p> The {@code Locale} class implements IETF BCP 47 which is composed of
|
||||
* <a href="http://tools.ietf.org/html/rfc4647">RFC 4647 "Matching of Language
|
||||
* Tags"</a> and <a href="http://tools.ietf.org/html/rfc5646">RFC 5646 "Tags
|
||||
* for Identifying Languages"</a> with support for the LDML (UTS#35, "Unicode
|
||||
* Locale Data Markup Language") BCP 47-compatible extensions for locale data
|
||||
* exchange.
|
||||
*
|
||||
* <p> A <code>Locale</code> object logically consists of the fields
|
||||
@ -267,6 +269,77 @@ import sun.util.resources.OpenListResourceBundle;
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
*
|
||||
* <h4><a name="LocaleMatching">Locale Matching</a></h4>
|
||||
*
|
||||
* <p>If an application or a system is internationalized and provides localized
|
||||
* resources for multiple locales, it sometimes needs to find one or more
|
||||
* locales (or language tags) which meet each user's specific preferences. Note
|
||||
* that a term "language tag" is used interchangeably with "locale" in this
|
||||
* locale matching documentation.
|
||||
*
|
||||
* <p>In order to do matching a user's preferred locales to a set of language
|
||||
* tags, <a href="http://tools.ietf.org/html/rfc4647">RFC 4647 Matching of
|
||||
* Language Tags</a> defines two mechanisms: filtering and lookup.
|
||||
* <em>Filtering</em> is used to get all matching locales, whereas
|
||||
* <em>lookup</em> is to choose the best matching locale.
|
||||
* Matching is done case-insensitively. These matching mechanisms are described
|
||||
* in the following sections.
|
||||
*
|
||||
* <p>A user's preference is called a <em>Language Priority List</em> and is
|
||||
* expressed as a list of language ranges. There are syntactically two types of
|
||||
* language ranges: basic and extended. See
|
||||
* {@link Locale.LanguageRange Locale.LanguageRange} for details.
|
||||
*
|
||||
* <h5>Filtering</h5>
|
||||
*
|
||||
* <p>The filtering operation returns all matching language tags. It is defined
|
||||
* in RFC 4647 as follows:
|
||||
* "In filtering, each language range represents the least specific language
|
||||
* tag (that is, the language tag with fewest number of subtags) that is an
|
||||
* acceptable match. All of the language tags in the matching set of tags will
|
||||
* have an equal or greater number of subtags than the language range. Every
|
||||
* non-wildcard subtag in the language range will appear in every one of the
|
||||
* matching language tags."
|
||||
*
|
||||
* <p>There are two types of filtering: filtering for basic language ranges
|
||||
* (called "basic filtering") and filtering for extended language ranges
|
||||
* (called "extended filtering"). They may return different results by what
|
||||
* kind of language ranges are included in the given Language Priority List.
|
||||
* {@link Locale.FilteringMode} is a parameter to specify how filtering should
|
||||
* be done.
|
||||
*
|
||||
* <h5>Lookup</h5>
|
||||
*
|
||||
* <p>The lookup operation returns the best matching language tags. It is
|
||||
* defined in RFC 4647 as follows:
|
||||
* "By contrast with filtering, each language range represents the most
|
||||
* specific tag that is an acceptable match. The first matching tag found,
|
||||
* according to the user's priority, is considered the closest match and is the
|
||||
* item returned."
|
||||
*
|
||||
* <p>For example, if a Language Priority List consists of two language ranges,
|
||||
* {@code "zh-Hant-TW"} and {@code "en-US"}, in prioritized order, lookup
|
||||
* method progressively searches the language tags below in order to find the
|
||||
* best matching language tag.
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* 1. zh-Hant-TW
|
||||
* 2. zh-Hant
|
||||
* 3. zh
|
||||
* 4. en-US
|
||||
* 5. en
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
* If there is a language tag which matches completely to a language range
|
||||
* above, the language tag is returned.
|
||||
*
|
||||
* <p>{@code "*"} is the special language range, and it is ignored in lookup.
|
||||
*
|
||||
* <p>If multiple language tags match as a result of the subtag {@code '*'}
|
||||
* included in a language range, the first matching language tag returned by
|
||||
* an {@link Iterator} over a {@link Collection} of language tags is treated as
|
||||
* the best matching one.
|
||||
*
|
||||
* <h4>Use of Locale</h4>
|
||||
*
|
||||
* <p>Once you've created a <code>Locale</code> you can query it for information
|
||||
@ -1419,7 +1492,7 @@ public final class Locale implements Cloneable, Serializable {
|
||||
* // returns "ja-JP-u-ca-japanese-x-lvariant-JP"
|
||||
* Locale.forLanguageTag("th-TH-x-lvariant-TH").toLanguageTag();
|
||||
* // returns "th-TH-u-nu-thai-x-lvariant-TH"
|
||||
* <pre></ul>
|
||||
* </pre></ul>
|
||||
*
|
||||
* <p>This implements the 'Language-Tag' production of BCP47, and
|
||||
* so supports grandfathered (regular and irregular) as well as
|
||||
@ -2070,7 +2143,7 @@ public final class Locale implements Cloneable, Serializable {
|
||||
* @param in the <code>ObjectInputStream</code> to read
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
* @throws IllformdLocaleException
|
||||
* @throws IllformedLocaleException
|
||||
* @since 1.7
|
||||
*/
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
@ -2574,4 +2647,611 @@ public final class Locale implements Cloneable, Serializable {
|
||||
return Locale.getInstance(baseloc, extensions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This enum provides constants to select a filtering mode for locale
|
||||
* matching. Refer to <a href="http://tools.ietf.org/html/rfc4647">RFC 4647
|
||||
* Matching of Language Tags</a> for details.
|
||||
*
|
||||
* <p>As an example, think of two Language Priority Lists each of which
|
||||
* includes only one language range and a set of following language tags:
|
||||
*
|
||||
* <pre>
|
||||
* de (German)
|
||||
* de-DE (German, Germany)
|
||||
* de-Deva (German, in Devanagari script)
|
||||
* de-Deva-DE (German, in Devanagari script, Germany)
|
||||
* de-DE-1996 (German, Germany, orthography of 1996)
|
||||
* de-Latn-DE (German, in Latin script, Germany)
|
||||
* de-Latn-DE-1996 (German, in Latin script, Germany, orthography of 1996)
|
||||
* </pre>
|
||||
*
|
||||
* The filtering method will behave as follows:
|
||||
*
|
||||
* <table cellpadding=2>
|
||||
* <tr>
|
||||
* <th>Filtering Mode</th>
|
||||
* <th>Language Priority List: {@code "de-DE"}</th>
|
||||
* <th>Language Priority List: {@code "de-*-DE"}</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign=top>
|
||||
* {@link FilteringMode#AUTOSELECT_FILTERING AUTOSELECT_FILTERING}
|
||||
* </td>
|
||||
* <td valign=top>
|
||||
* Performs <em>basic</em> filtering and returns {@code "de-DE"} and
|
||||
* {@code "de-DE-1996"}.
|
||||
* </td>
|
||||
* <td valign=top>
|
||||
* Performs <em>extended</em> filtering and returns {@code "de-DE"},
|
||||
* {@code "de-Deva-DE"}, {@code "de-DE-1996"}, {@code "de-Latn-DE"}, and
|
||||
* {@code "de-Latn-DE-1996"}.
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign=top>
|
||||
* {@link FilteringMode#EXTENDED_FILTERING EXTENDED_FILTERING}
|
||||
* </td>
|
||||
* <td valign=top>
|
||||
* Performs <em>extended</em> filtering and returns {@code "de-DE"},
|
||||
* {@code "de-Deva-DE"}, {@code "de-DE-1996"}, {@code "de-Latn-DE"}, and
|
||||
* {@code "de-Latn-DE-1996"}.
|
||||
* </td>
|
||||
* <td valign=top>Same as above.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign=top>
|
||||
* {@link FilteringMode#IGNORE_EXTENDED_RANGES IGNORE_EXTENDED_RANGES}
|
||||
* </td>
|
||||
* <td valign=top>
|
||||
* Performs <em>basic</em> filtering and returns {@code "de-DE"} and
|
||||
* {@code "de-DE-1996"}.
|
||||
* </td>
|
||||
* <td valign=top>
|
||||
* Performs <em>basic</em> filtering and returns {@code null} because
|
||||
* nothing matches.
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign=top>
|
||||
* {@link FilteringMode#MAP_EXTENDED_RANGES MAP_EXTENDED_RANGES}
|
||||
* </td>
|
||||
* <td valign=top>Same as above.</td>
|
||||
* <td valign=top>
|
||||
* Performs <em>basic</em> filtering and returns {@code "de-DE"} and
|
||||
* {@code "de-DE-1996"} because {@code "de-*-DE"} is mapped to
|
||||
* {@code "de-DE"}.
|
||||
* </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td valign=top>
|
||||
* {@link FilteringMode#REJECT_EXTENDED_RANGES REJECT_EXTENDED_RANGES}
|
||||
* </td>
|
||||
* <td valign=top>Same as above.</td>
|
||||
* <td valign=top>
|
||||
* Throws {@link IllegalArgumentException} because {@code "de-*-DE"} is
|
||||
* not a valid basic language range.
|
||||
* </td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* @see #filter(List, Collection, FilteringMode)
|
||||
* @see #filterTags(List, Collection, FilteringMode)
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static enum FilteringMode {
|
||||
/**
|
||||
* Specifies automatic filtering mode based on the given Language
|
||||
* Priority List consisting of language ranges. If all of the ranges
|
||||
* are basic, basic filtering is selected. Otherwise, extended
|
||||
* filtering is selected.
|
||||
*/
|
||||
AUTOSELECT_FILTERING,
|
||||
|
||||
/**
|
||||
* Specifies extended filtering.
|
||||
*/
|
||||
EXTENDED_FILTERING,
|
||||
|
||||
/**
|
||||
* Specifies basic filtering: Note that any extended language ranges
|
||||
* included in the given Language Priority List are ignored.
|
||||
*/
|
||||
IGNORE_EXTENDED_RANGES,
|
||||
|
||||
/**
|
||||
* Specifies basic filtering: If any extended language ranges are
|
||||
* included in the given Language Priority List, they are mapped to the
|
||||
* basic language range. Specifically, a language range starting with a
|
||||
* subtag {@code "*"} is treated as a language range {@code "*"}. For
|
||||
* example, {@code "*-US"} is treated as {@code "*"}. If {@code "*"} is
|
||||
* not the first subtag, {@code "*"} and extra {@code "-"} are removed.
|
||||
* For example, {@code "ja-*-JP"} is mapped to {@code "ja-JP"}.
|
||||
*/
|
||||
MAP_EXTENDED_RANGES,
|
||||
|
||||
/**
|
||||
* Specifies basic filtering: If any extended language ranges are
|
||||
* included in the given Language Priority List, the list is rejected
|
||||
* and the filtering method throws {@link IllegalArgumentException}.
|
||||
*/
|
||||
REJECT_EXTENDED_RANGES
|
||||
};
|
||||
|
||||
/**
|
||||
* This class expresses a <em>Language Range</em> defined in
|
||||
* <a href="http://tools.ietf.org/html/rfc4647">RFC 4647 Matching of
|
||||
* Language Tags</a>. A language range is an identifier which is used to
|
||||
* select language tag(s) meeting specific requirements by using the
|
||||
* mechanisms described in <a href="Locale.html#LocaleMatching">Locale
|
||||
* Matching</a>. A list which represents a user's preferences and consists
|
||||
* of language ranges is called a <em>Language Priority List</em>.
|
||||
*
|
||||
* <p>There are two types of language ranges: basic and extended. In RFC
|
||||
* 4647, the syntax of language ranges is expressed in
|
||||
* <a href="http://tools.ietf.org/html/rfc4234">ABNF</a> as follows:
|
||||
* <blockquote>
|
||||
* <pre>
|
||||
* basic-language-range = (1*8ALPHA *("-" 1*8alphanum)) / "*"
|
||||
* extended-language-range = (1*8ALPHA / "*")
|
||||
* *("-" (1*8alphanum / "*"))
|
||||
* alphanum = ALPHA / DIGIT
|
||||
* </pre>
|
||||
* </blockquote>
|
||||
* For example, {@code "en"} (English), {@code "ja-JP"} (Japanese, Japan),
|
||||
* {@code "*"} (special language range which matches any language tag) are
|
||||
* basic language ranges, whereas {@code "*-CH"} (any languages,
|
||||
* Switzerland), {@code "es-*"} (Spanish, any regions), and
|
||||
* {@code "zh-Hant-*"} (Traditional Chinese, any regions) are extended
|
||||
* language ranges.
|
||||
*
|
||||
* @see #filter
|
||||
* @see #filterTags
|
||||
* @see #lookup
|
||||
* @see #lookupTag
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static final class LanguageRange {
|
||||
|
||||
/**
|
||||
* A constant holding the maximum value of weight, 1.0, which indicates
|
||||
* that the language range is a good fit for the user.
|
||||
*/
|
||||
public static final double MAX_WEIGHT = 1.0;
|
||||
|
||||
/**
|
||||
* A constant holding the minimum value of weight, 0.0, which indicates
|
||||
* that the language range is not a good fit for the user.
|
||||
*/
|
||||
public static final double MIN_WEIGHT = 0.0;
|
||||
|
||||
private final String range;
|
||||
private final double weight;
|
||||
|
||||
private volatile int hash = 0;
|
||||
|
||||
/**
|
||||
* Constructs a {@code LanguageRange} using the given {@code range}.
|
||||
* Note that no validation is done against the IANA Language Subtag
|
||||
* Registry at time of construction.
|
||||
*
|
||||
* <p>This is equivalent to {@code LanguageRange(range, MAX_WEIGHT)}.
|
||||
*
|
||||
* @param range a language range
|
||||
* @throws NullPointerException if the given {@code range} is
|
||||
* {@code null}
|
||||
*/
|
||||
public LanguageRange(String range) {
|
||||
this(range, MAX_WEIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@code LanguageRange} using the given {@code range} and
|
||||
* {@code weight}. Note that no validation is done against the IANA
|
||||
* Language Subtag Registry at time of construction.
|
||||
*
|
||||
* @param range a language range
|
||||
* @param weight a weight value between {@code MIN_WEIGHT} and
|
||||
* {@code MAX_WEIGHT}
|
||||
* @throws NullPointerException if the given {@code range} is
|
||||
* {@code null}
|
||||
* @throws IllegalArgumentException if the given {@code weight} is less
|
||||
* than {@code MIN_WEIGHT} or greater than {@code MAX_WEIGHT}
|
||||
*/
|
||||
public LanguageRange(String range, double weight) {
|
||||
if (range == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (weight < MIN_WEIGHT || weight > MAX_WEIGHT) {
|
||||
throw new IllegalArgumentException("weight=" + weight);
|
||||
}
|
||||
|
||||
range = range.toLowerCase();
|
||||
|
||||
// Do syntax check.
|
||||
boolean isIllFormed = false;
|
||||
String[] subtags = range.split("-");
|
||||
if (isSubtagIllFormed(subtags[0], true)
|
||||
|| range.endsWith("-")) {
|
||||
isIllFormed = true;
|
||||
} else {
|
||||
for (int i = 1; i < subtags.length; i++) {
|
||||
if (isSubtagIllFormed(subtags[i], false)) {
|
||||
isIllFormed = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isIllFormed) {
|
||||
throw new IllegalArgumentException("range=" + range);
|
||||
}
|
||||
|
||||
this.range = range;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
private static boolean isSubtagIllFormed(String subtag,
|
||||
boolean isFirstSubtag) {
|
||||
if (subtag.equals("") || subtag.length() > 8) {
|
||||
return true;
|
||||
} else if (subtag.equals("*")) {
|
||||
return false;
|
||||
}
|
||||
char[] charArray = subtag.toCharArray();
|
||||
if (isFirstSubtag) { // ALPHA
|
||||
for (char c : charArray) {
|
||||
if (c < 'a' || c > 'z') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else { // ALPHA / DIGIT
|
||||
for (char c : charArray) {
|
||||
if (c < '0' || (c > '9' && c < 'a') || c > 'z') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the language range of this {@code LanguageRange}.
|
||||
*
|
||||
* @return the language range.
|
||||
*/
|
||||
public String getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the weight of this {@code LanguageRange}.
|
||||
*
|
||||
* @return the weight value.
|
||||
*/
|
||||
public double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given {@code ranges} to generate a Language Priority List.
|
||||
*
|
||||
* <p>This method performs a syntactic check for each language range in
|
||||
* the given {@code ranges} but doesn't do validation using the IANA
|
||||
* Language Subtag Registry.
|
||||
*
|
||||
* <p>The {@code ranges} to be given can take one of the following
|
||||
* forms:
|
||||
*
|
||||
* <pre>
|
||||
* "Accept-Language: ja,en;q=0.4" (weighted list with Accept-Language prefix)
|
||||
* "ja,en;q=0.4" (weighted list)
|
||||
* "ja,en" (prioritized list)
|
||||
* </pre>
|
||||
*
|
||||
* In a weighted list, each language range is given a weight value.
|
||||
* The weight value is identical to the "quality value" in
|
||||
* <a href="http://tools.ietf.org/html/rfc2616">RFC 2616</a>, and it
|
||||
* expresses how much the user prefers the language. A weight value is
|
||||
* specified after a corresponding language range followed by
|
||||
* {@code ";q="}, and the default weight value is {@code MAX_WEIGHT}
|
||||
* when it is omitted.
|
||||
*
|
||||
* <p>Unlike a weighted list, language ranges in a prioritized list
|
||||
* are sorted in the descending order based on its priority. The first
|
||||
* language range has the highest priority and meets the user's
|
||||
* preference most.
|
||||
*
|
||||
* <p>In either case, language ranges are sorted in descending order in
|
||||
* the Language Priority List based on priority or weight. If a
|
||||
* language range appears in the given {@code ranges} more than once,
|
||||
* only the first one is included on the Language Priority List.
|
||||
*
|
||||
* <p>The returned list consists of language ranges from the given
|
||||
* {@code ranges} and their equivalents found in the IANA Language
|
||||
* Subtag Registry. For example, if the given {@code ranges} is
|
||||
* {@code "Accept-Language: iw,en-us;q=0.7,en;q=0.3"}, the elements in
|
||||
* the list to be returned are:
|
||||
*
|
||||
* <pre>
|
||||
* <b>Range</b> <b>Weight</b>
|
||||
* "iw" (older tag for Hebrew) 1.0
|
||||
* "he" (new preferred code for Hebrew) 1.0
|
||||
* "en-us" (English, United States) 0.7
|
||||
* "en" (English) 0.3
|
||||
* </pre>
|
||||
*
|
||||
* Two language ranges, {@code "iw"} and {@code "he"}, have the same
|
||||
* highest priority in the list. By adding {@code "he"} to the user's
|
||||
* Language Priority List, locale-matching method can find Hebrew as a
|
||||
* matching locale (or language tag) even if the application or system
|
||||
* offers only {@code "he"} as a supported locale (or language tag).
|
||||
*
|
||||
* @param ranges a list of comma-separated language ranges or a list of
|
||||
* language ranges in the form of the "Accept-Language" header
|
||||
* defined in <a href="http://tools.ietf.org/html/rfc2616">RFC
|
||||
* 2616</a>
|
||||
* @return a Language Priority List consisting of language ranges
|
||||
* included in the given {@code ranges} and their equivalent
|
||||
* language ranges if available. The list is modifiable.
|
||||
* @throws NullPointerException if {@code ranges} is null
|
||||
* @throws IllegalArgumentException if a language range or a weight
|
||||
* found in the given {@code ranges} is ill-formed
|
||||
*/
|
||||
public static List<LanguageRange> parse(String ranges) {
|
||||
return LocaleMatcher.parse(ranges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given {@code ranges} to generate a Language Priority
|
||||
* List, and then customizes the list using the given {@code map}.
|
||||
* This method is equivalent to
|
||||
* {@code mapEquivalents(parse(ranges), map)}.
|
||||
*
|
||||
* @param ranges a list of comma-separated language ranges or a list
|
||||
* of language ranges in the form of the "Accept-Language" header
|
||||
* defined in <a href="http://tools.ietf.org/html/rfc2616">RFC
|
||||
* 2616</a>
|
||||
* @param map a map containing information to customize language ranges
|
||||
* @return a Language Priority List with customization. The list is
|
||||
* @throws NullPointerException if {@code ranges} is null
|
||||
* @throws IllegalArgumentException if a language range or a weight
|
||||
* found in the given {@code ranges} is ill-formed
|
||||
* @see #parse(String)
|
||||
* @see #mapEquivalents
|
||||
*/
|
||||
public static List<LanguageRange> parse(String ranges,
|
||||
Map<String, List<String>> map) {
|
||||
return mapEquivalents(parse(ranges), map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new customized Language Priority List using the given
|
||||
* {@code priorityList} and {@code map}. If the given {@code map} is
|
||||
* empty, this method returns a copy of the given {@code priorityList}.
|
||||
*
|
||||
* <p>In the map, a key represents a language range whereas a value is
|
||||
* a list of equivalents of it. {@code '*'} cannot be used in the map.
|
||||
* Each equivalent language range has the same weight value as its
|
||||
* original language range.
|
||||
*
|
||||
* <pre>
|
||||
* An example of map:
|
||||
* <b>Key</b> <b>Value</b>
|
||||
* "zh" (Chinese) "zh",
|
||||
* "zh-Hans"(Simplified Chinese)
|
||||
* "zh-HK" (Chinese, Hong Kong) "zh-HK"
|
||||
* "zh-TW" (Chinese, Taiwan) "zh-TW"
|
||||
* </pre>
|
||||
*
|
||||
* The customization is performed after modification using the IANA
|
||||
* Language Subtag Registry.
|
||||
*
|
||||
* <p>For example, if a user's Language Priority List consists of five
|
||||
* language ranges ({@code "zh"}, {@code "zh-CN"}, {@code "en"},
|
||||
* {@code "zh-TW"}, and {@code "zh-HK"}), the newly generated Language
|
||||
* Priority List which is customized using the above map example will
|
||||
* consists of {@code "zh"}, {@code "zh-Hans"}, {@code "zh-CN"},
|
||||
* {@code "zh-Hans-CN"}, {@code "en"}, {@code "zh-TW"}, and
|
||||
* {@code "zh-HK"}.
|
||||
*
|
||||
* <p>{@code "zh-HK"} and {@code "zh-TW"} aren't converted to
|
||||
* {@code "zh-Hans-HK"} nor {@code "zh-Hans-TW"} even if they are
|
||||
* included in the Language Priority List. In this example, mapping
|
||||
* is used to clearly distinguish Simplified Chinese and Traditional
|
||||
* Chinese.
|
||||
*
|
||||
* <p>If the {@code "zh"}-to-{@code "zh"} mapping isn't included in the
|
||||
* map, a simple replacement will be performed and the customized list
|
||||
* won't include {@code "zh"} and {@code "zh-CN"}.
|
||||
*
|
||||
* @param priorityList user's Language Priority List
|
||||
* @param map a map containing information to customize language ranges
|
||||
* @return a new Language Priority List with customization. The list is
|
||||
* modifiable.
|
||||
* @throws NullPointerException if {@code priorityList} is {@code null}
|
||||
* @see #parse(String, Map)
|
||||
*/
|
||||
public static List<LanguageRange> mapEquivalents(
|
||||
List<LanguageRange>priorityList,
|
||||
Map<String, List<String>> map) {
|
||||
return LocaleMatcher.mapEquivalents(priorityList, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a hash code value for the object.
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hash == 0) {
|
||||
int result = 17;
|
||||
result = 37*result + range.hashCode();
|
||||
long bitsWeight = Double.doubleToLongBits(weight);
|
||||
result = 37*result + (int)(bitsWeight ^ (bitsWeight >>> 32));
|
||||
hash = result;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this object to the specified object. The result is true if
|
||||
* and only if the argument is not {@code null} and is a
|
||||
* {@code LanguageRange} object that contains the same {@code range}
|
||||
* and {@code weight} values as this object.
|
||||
*
|
||||
* @param obj the object to compare with
|
||||
* @return {@code true} if this object's {@code range} and
|
||||
* {@code weight} are the same as the {@code obj}'s; {@code false}
|
||||
* otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof LanguageRange)) {
|
||||
return false;
|
||||
}
|
||||
LanguageRange other = (LanguageRange)obj;
|
||||
return hash == other.hash
|
||||
&& range.equals(other.range)
|
||||
&& weight == other.weight;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of matching {@code Locale} instances using the filtering
|
||||
* mechanism defined in RFC 4647.
|
||||
*
|
||||
* @param priorityList user's Language Priority List in which each language
|
||||
* tag is sorted in descending order based on priority or weight
|
||||
* @param locales {@code Locale} instances used for matching
|
||||
* @param mode filtering mode
|
||||
* @return a list of {@code Locale} instances for matching language tags
|
||||
* sorted in descending order based on priority or weight, or an empty
|
||||
* list if nothing matches. The list is modifiable.
|
||||
* @throws NullPointerException if {@code priorityList} or {@code locales}
|
||||
* is {@code null}
|
||||
* @throws IllegalArgumentException if one or more extended language ranges
|
||||
* are included in the given list when
|
||||
* {@link FilteringMode#REJECT_EXTENDED_RANGES} is specified
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static List<Locale> filter(List<LanguageRange> priorityList,
|
||||
Collection<Locale> locales,
|
||||
FilteringMode mode) {
|
||||
return LocaleMatcher.filter(priorityList, locales, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of matching {@code Locale} instances using the filtering
|
||||
* mechanism defined in RFC 4647. This is equivalent to
|
||||
* {@link #filter(List, Collection, FilteringMode)} when {@code mode} is
|
||||
* {@link FilteringMode#AUTOSELECT_FILTERING}.
|
||||
*
|
||||
* @param priorityList user's Language Priority List in which each language
|
||||
* tag is sorted in descending order based on priority or weight
|
||||
* @param locales {@code Locale} instances used for matching
|
||||
* @return a list of {@code Locale} instances for matching language tags
|
||||
* sorted in descending order based on priority or weight, or an empty
|
||||
* list if nothing matches. The list is modifiable.
|
||||
* @throws NullPointerException if {@code priorityList} or {@code locales}
|
||||
* is {@code null}
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static List<Locale> filter(List<LanguageRange> priorityList,
|
||||
Collection<Locale> locales) {
|
||||
return filter(priorityList, locales, FilteringMode.AUTOSELECT_FILTERING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of matching languages tags using the basic filtering
|
||||
* mechanism defined in RFC 4647.
|
||||
*
|
||||
* @param priorityList user's Language Priority List in which each language
|
||||
* tag is sorted in descending order based on priority or weight
|
||||
* @param tags language tags
|
||||
* @param mode filtering mode
|
||||
* @return a list of matching language tags sorted in descending order
|
||||
* based on priority or weight, or an empty list if nothing matches.
|
||||
* The list is modifiable.
|
||||
* @throws NullPointerException if {@code priorityList} or {@code tags} is
|
||||
* {@code null}
|
||||
* @throws IllegalArgumentException if one or more extended language ranges
|
||||
* are included in the given list when
|
||||
* {@link FilteringMode#REJECT_EXTENDED_RANGES} is specified
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static List<String> filterTags(List<LanguageRange> priorityList,
|
||||
Collection<String> tags,
|
||||
FilteringMode mode) {
|
||||
return LocaleMatcher.filterTags(priorityList, tags, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of matching languages tags using the basic filtering
|
||||
* mechanism defined in RFC 4647. This is equivalent to
|
||||
* {@link #filterTags(List, Collection, FilteringMode)} when {@code mode}
|
||||
* is {@link FilteringMode#AUTOSELECT_FILTERING}.
|
||||
*
|
||||
* @param priorityList user's Language Priority List in which each language
|
||||
* tag is sorted in descending order based on priority or weight
|
||||
* @param tags language tags
|
||||
* @return a list of matching language tags sorted in descending order
|
||||
* based on priority or weight, or an empty list if nothing matches.
|
||||
* The list is modifiable.
|
||||
* @throws NullPointerException if {@code priorityList} or {@code tags} is
|
||||
* {@code null}
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static List<String> filterTags(List<LanguageRange> priorityList,
|
||||
Collection<String> tags) {
|
||||
return filterTags(priorityList, tags, FilteringMode.AUTOSELECT_FILTERING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code Locale} instance for the best-matching language
|
||||
* tag using the lookup mechanism defined in RFC 4647.
|
||||
*
|
||||
* @param priorityList user's Language Priority List in which each language
|
||||
* tag is sorted in descending order based on priority or weight
|
||||
* @param locales {@code Locale} instances used for matching
|
||||
* @return the best matching <code>Locale</code> instance chosen based on
|
||||
* priority or weight, or {@code null} if nothing matches.
|
||||
* @throws NullPointerException if {@code priorityList} or {@code tags} is
|
||||
* {@code null}
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static Locale lookup(List<LanguageRange> priorityList,
|
||||
Collection<Locale> locales) {
|
||||
return LocaleMatcher.lookup(priorityList, locales);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the best-matching language tag using the lookup mechanism
|
||||
* defined in RFC 4647.
|
||||
*
|
||||
* @param priorityList user's Language Priority List in which each language
|
||||
* tag is sorted in descending order based on priority or weight
|
||||
* @param tags language tangs used for matching
|
||||
* @return the best matching language tag chosen based on priority or
|
||||
* weight, or {@code null} if nothing matches.
|
||||
* @throws NullPointerException if {@code priorityList} or {@code tags} is
|
||||
* {@code null}
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static String lookupTag(List<LanguageRange> priorityList,
|
||||
Collection<String> tags) {
|
||||
return LocaleMatcher.lookupTag(priorityList, tags);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,10 @@ import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.BufferedWriter;
|
||||
import java.lang.reflect.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import sun.util.spi.XmlPropertiesProvider;
|
||||
|
||||
/**
|
||||
* The {@code Properties} class represents a persistent set of
|
||||
@ -866,7 +869,7 @@ class Properties extends Hashtable<Object,Object> {
|
||||
{
|
||||
if (in == null)
|
||||
throw new NullPointerException();
|
||||
XMLUtils.load(this, in);
|
||||
XmlSupport.load(this, in);
|
||||
in.close();
|
||||
}
|
||||
|
||||
@ -934,7 +937,7 @@ class Properties extends Hashtable<Object,Object> {
|
||||
{
|
||||
if (os == null)
|
||||
throw new NullPointerException();
|
||||
XMLUtils.save(this, os, comment, encoding);
|
||||
XmlSupport.save(this, os, comment, encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1113,59 +1116,82 @@ class Properties extends Hashtable<Object,Object> {
|
||||
'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
|
||||
};
|
||||
|
||||
/**
|
||||
* Supporting class for loading/storing properties in XML format.
|
||||
*
|
||||
* <p> The {@code load} and {@code store} methods defined here delegate to a
|
||||
* system-wide {@code XmlPropertiesProvider}. On first invocation of either
|
||||
* method then the system-wide provider is located as follows: </p>
|
||||
*
|
||||
* <ol>
|
||||
* <li> If the system property {@code sun.util.spi.XmlPropertiesProvider}
|
||||
* is defined then it is taken to be the full-qualified name of a concrete
|
||||
* provider class. The class is loaded with the system class loader as the
|
||||
* initiating loader. If it cannot be loaded or instantiated using a zero
|
||||
* argument constructor then an unspecified error is thrown. </li>
|
||||
*
|
||||
* <li> If the system property is not defined then the service-provider
|
||||
* loading facility defined by the {@link ServiceLoader} class is used to
|
||||
* locate a provider with the system class loader as the initiating
|
||||
* loader and {@code sun.util.spi.XmlPropertiesProvider} as the service
|
||||
* type. If this process fails then an unspecified error is thrown. If
|
||||
* there is more than one service provider installed then it is
|
||||
* not specified as to which provider will be used. </li>
|
||||
*
|
||||
* <li> If the provider is not found by the above means then a system
|
||||
* default provider will be instantiated and used. </li>
|
||||
* </ol>
|
||||
*/
|
||||
private static class XmlSupport {
|
||||
|
||||
private static class XMLUtils {
|
||||
private static Method load = null;
|
||||
private static Method save = null;
|
||||
static {
|
||||
private static XmlPropertiesProvider loadProviderFromProperty(ClassLoader cl) {
|
||||
String cn = System.getProperty("sun.util.spi.XmlPropertiesProvider");
|
||||
if (cn == null)
|
||||
return null;
|
||||
try {
|
||||
// reference sun.util.xml.Utils reflectively
|
||||
// to allow the Properties class be compiled in
|
||||
// the absence of XML
|
||||
Class<?> c = Class.forName("sun.util.xml.XMLUtils", true, null);
|
||||
load = c.getMethod("load", Properties.class, InputStream.class);
|
||||
save = c.getMethod("save", Properties.class, OutputStream.class,
|
||||
String.class, String.class);
|
||||
} catch (ClassNotFoundException cnf) {
|
||||
throw new AssertionError(cnf);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new AssertionError(e);
|
||||
Class<?> c = Class.forName(cn, true, cl);
|
||||
return (XmlPropertiesProvider)c.newInstance();
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
InstantiationException x) {
|
||||
throw new ServiceConfigurationError(null, x);
|
||||
}
|
||||
}
|
||||
|
||||
static void invoke(Method m, Object... args) throws IOException {
|
||||
try {
|
||||
m.invoke(null, args);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new AssertionError(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable t = e.getCause();
|
||||
if (t instanceof RuntimeException)
|
||||
throw (RuntimeException)t;
|
||||
|
||||
if (t instanceof IOException) {
|
||||
throw (IOException)t;
|
||||
} else {
|
||||
throw new AssertionError(t);
|
||||
}
|
||||
}
|
||||
private static XmlPropertiesProvider loadProviderAsService(ClassLoader cl) {
|
||||
Iterator<XmlPropertiesProvider> iterator =
|
||||
ServiceLoader.load(XmlPropertiesProvider.class, cl).iterator();
|
||||
return iterator.hasNext() ? iterator.next() : null;
|
||||
}
|
||||
|
||||
private static XmlPropertiesProvider loadProvider() {
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<XmlPropertiesProvider>() {
|
||||
public XmlPropertiesProvider run() {
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
XmlPropertiesProvider provider = loadProviderFromProperty(cl);
|
||||
if (provider != null)
|
||||
return provider;
|
||||
provider = loadProviderAsService(cl);
|
||||
if (provider != null)
|
||||
return provider;
|
||||
throw new InternalError("No fallback");
|
||||
}});
|
||||
}
|
||||
|
||||
private static final XmlPropertiesProvider PROVIDER = loadProvider();
|
||||
|
||||
static void load(Properties props, InputStream in)
|
||||
throws IOException, InvalidPropertiesFormatException
|
||||
{
|
||||
if (load == null)
|
||||
throw new InternalError("sun.util.xml.XMLUtils not found");
|
||||
invoke(load, props, in);
|
||||
PROVIDER.load(props, in);
|
||||
}
|
||||
|
||||
static void save(Properties props, OutputStream os, String comment,
|
||||
String encoding)
|
||||
throws IOException
|
||||
{
|
||||
if (save == null)
|
||||
throw new InternalError("sun.util.xml.XMLUtils not found");
|
||||
invoke(save, props, os, comment, encoding);
|
||||
PROVIDER.store(props, os, comment, encoding);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,18 +130,15 @@ public final class PropertyPermission extends BasicPermission {
|
||||
* @param mask the actions mask to use.
|
||||
*
|
||||
*/
|
||||
|
||||
private void init(int mask)
|
||||
{
|
||||
|
||||
private void init(int mask) {
|
||||
if ((mask & ALL) != mask)
|
||||
throw new IllegalArgumentException("invalid actions mask");
|
||||
throw new IllegalArgumentException("invalid actions mask");
|
||||
|
||||
if (mask == NONE)
|
||||
throw new IllegalArgumentException("invalid actions mask");
|
||||
throw new IllegalArgumentException("invalid actions mask");
|
||||
|
||||
if (getName() == null)
|
||||
throw new NullPointerException("name can't be null");
|
||||
throw new NullPointerException("name can't be null");
|
||||
|
||||
this.mask = mask;
|
||||
}
|
||||
@ -160,9 +157,7 @@ public final class PropertyPermission extends BasicPermission {
|
||||
* @throws IllegalArgumentException if <code>name</code> is empty or if
|
||||
* <code>actions</code> is invalid.
|
||||
*/
|
||||
|
||||
public PropertyPermission(String name, String actions)
|
||||
{
|
||||
public PropertyPermission(String name, String actions) {
|
||||
super(name,actions);
|
||||
init(getMask(actions));
|
||||
}
|
||||
@ -196,7 +191,6 @@ public final class PropertyPermission extends BasicPermission {
|
||||
return ((this.mask & that.mask) == that.mask) && super.implies(that);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks two PropertyPermission objects for equality. Checks that <i>obj</i> is
|
||||
* a PropertyPermission, and has the same name and actions as this object.
|
||||
@ -226,16 +220,14 @@ public final class PropertyPermission extends BasicPermission {
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
|
||||
public int hashCode() {
|
||||
return this.getName().hashCode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts an actions String to an actions mask.
|
||||
*
|
||||
* @param action the action string.
|
||||
* @param actions the action string.
|
||||
* @return the actions mask.
|
||||
*/
|
||||
private static int getMask(String actions) {
|
||||
@ -332,8 +324,7 @@ public final class PropertyPermission extends BasicPermission {
|
||||
*
|
||||
* @return the canonical string representation of the actions.
|
||||
*/
|
||||
static String getActions(int mask)
|
||||
{
|
||||
static String getActions(int mask) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean comma = false;
|
||||
|
||||
@ -359,8 +350,7 @@ public final class PropertyPermission extends BasicPermission {
|
||||
*
|
||||
* @return the canonical string representation of the actions.
|
||||
*/
|
||||
public String getActions()
|
||||
{
|
||||
public String getActions() {
|
||||
if (actions == null)
|
||||
actions = getActions(this.mask);
|
||||
|
||||
@ -373,7 +363,6 @@ public final class PropertyPermission extends BasicPermission {
|
||||
*
|
||||
* @return the actions mask.
|
||||
*/
|
||||
|
||||
int getMask() {
|
||||
return mask;
|
||||
}
|
||||
@ -386,7 +375,6 @@ public final class PropertyPermission extends BasicPermission {
|
||||
* @return a new PermissionCollection object suitable for storing
|
||||
* PropertyPermissions.
|
||||
*/
|
||||
|
||||
public PermissionCollection newPermissionCollection() {
|
||||
return new PropertyPermissionCollection();
|
||||
}
|
||||
@ -436,7 +424,7 @@ public final class PropertyPermission extends BasicPermission {
|
||||
* @serial include
|
||||
*/
|
||||
final class PropertyPermissionCollection extends PermissionCollection
|
||||
implements Serializable
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
/**
|
||||
@ -454,10 +442,8 @@ implements Serializable
|
||||
private boolean all_allowed;
|
||||
|
||||
/**
|
||||
* Create an empty PropertyPermissions object.
|
||||
*
|
||||
* Create an empty PropertyPermissionCollection object.
|
||||
*/
|
||||
|
||||
public PropertyPermissionCollection() {
|
||||
perms = new HashMap<>(32); // Capacity for default policy
|
||||
all_allowed = false;
|
||||
@ -475,9 +461,7 @@ implements Serializable
|
||||
* @exception SecurityException - if this PropertyPermissionCollection
|
||||
* object has been marked readonly
|
||||
*/
|
||||
|
||||
public void add(Permission permission)
|
||||
{
|
||||
public void add(Permission permission) {
|
||||
if (! (permission instanceof PropertyPermission))
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
permission);
|
||||
@ -514,14 +498,12 @@ implements Serializable
|
||||
* Check and see if this set of permissions implies the permissions
|
||||
* expressed in "permission".
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return true if "permission" is a proper subset of a permission in
|
||||
* the set, false if not.
|
||||
*/
|
||||
|
||||
public boolean implies(Permission permission)
|
||||
{
|
||||
public boolean implies(Permission permission) {
|
||||
if (! (permission instanceof PropertyPermission))
|
||||
return false;
|
||||
|
||||
@ -655,8 +637,9 @@ implements Serializable
|
||||
* Reads in a Hashtable of PropertyPermissions and saves them in the
|
||||
* perms field. Reads in all_allowed.
|
||||
*/
|
||||
private void readObject(ObjectInputStream in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
// Don't call defaultReadObject()
|
||||
|
||||
// Read in serialized fields
|
||||
|
@ -289,7 +289,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
* the same size, and every member of the given set is contained in
|
||||
* this set.
|
||||
*
|
||||
* @param e object to be compared for equality with this set
|
||||
* @param o object to be compared for equality with this set
|
||||
* @return <tt>true</tt> if the specified object is equal to this set
|
||||
*/
|
||||
public boolean equals(Object o) {
|
||||
|
@ -568,9 +568,8 @@ public final class Scanner implements Iterator<String>, Closeable {
|
||||
* Constructs a <code>Scanner</code> that returns values scanned
|
||||
* from the specified source delimited by the specified pattern.
|
||||
*
|
||||
* @param source A character source implementing the Readable interface
|
||||
* @param source A character source implementing the Readable interface
|
||||
* @param pattern A delimiting pattern
|
||||
* @return A scanner with the specified source and pattern
|
||||
*/
|
||||
private Scanner(Readable source, Pattern pattern) {
|
||||
assert source != null : "source should not be null";
|
||||
|
@ -213,7 +213,7 @@ public final class ServiceLoader<S>
|
||||
}
|
||||
|
||||
private ServiceLoader(Class<S> svc, ClassLoader cl) {
|
||||
service = svc;
|
||||
service = Objects.requireNonNull(svc, "Service interface cannot be null");
|
||||
loader = cl;
|
||||
reload();
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
||||
* @param date the milliseconds (since January 1, 1970,
|
||||
* 00:00:00.000 GMT) at which the time zone offset and daylight
|
||||
* saving amount are found
|
||||
* @param offset an array of int where the raw GMT offset
|
||||
* @param offsets an array of int where the raw GMT offset
|
||||
* (offset[0]) and daylight saving amount (offset[1]) are stored,
|
||||
* or null if those values are not needed. The method assumes that
|
||||
* the length of the given array is two or larger.
|
||||
|
@ -41,8 +41,8 @@ import java.util.ArrayList;
|
||||
* @since 1.5
|
||||
*
|
||||
* @see javax.management
|
||||
* @see java.util.Logger
|
||||
* @see java.util.LogManager
|
||||
* @see Logger
|
||||
* @see LogManager
|
||||
*/
|
||||
class Logging implements LoggingMXBean {
|
||||
|
||||
|
@ -92,7 +92,7 @@ class XmlSupport {
|
||||
* @throws BackingStoreException if preference data cannot be read from
|
||||
* backing store.
|
||||
* @throws IllegalStateException if this node (or an ancestor) has been
|
||||
* removed with the {@link #removeNode()} method.
|
||||
* removed with the {@link Preferences#removeNode()} method.
|
||||
*/
|
||||
static void export(OutputStream os, final Preferences p, boolean subTree)
|
||||
throws IOException, BackingStoreException {
|
||||
|
@ -136,8 +136,7 @@ final class CryptoAllPermissionCollection extends PermissionCollection
|
||||
* @exception SecurityException - if this CryptoAllPermissionCollection
|
||||
* object has been marked readonly
|
||||
*/
|
||||
public void add(Permission permission)
|
||||
{
|
||||
public void add(Permission permission) {
|
||||
if (isReadOnly())
|
||||
throw new SecurityException("attempt to add a Permission to " +
|
||||
"a readonly PermissionCollection");
|
||||
@ -152,13 +151,12 @@ final class CryptoAllPermissionCollection extends PermissionCollection
|
||||
* Check and see if this set of permissions implies the permissions
|
||||
* expressed in "permission".
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return true if the given permission is implied by this
|
||||
* CryptoAllPermissionCollection.
|
||||
*/
|
||||
public boolean implies(Permission permission)
|
||||
{
|
||||
public boolean implies(Permission permission) {
|
||||
if (!(permission instanceof CryptoPermission)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -471,8 +471,8 @@ class CryptoPermission extends java.security.Permission {
|
||||
* @author Sharon Liu
|
||||
*/
|
||||
final class CryptoPermissionCollection extends PermissionCollection
|
||||
implements Serializable {
|
||||
|
||||
implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -511215555898802763L;
|
||||
|
||||
private Vector<Permission> permissions;
|
||||
@ -493,8 +493,7 @@ implements Serializable {
|
||||
* @exception SecurityException - if this CryptoPermissionCollection
|
||||
* object has been marked <i>readOnly</i>.
|
||||
*/
|
||||
public void add(Permission permission)
|
||||
{
|
||||
public void add(Permission permission) {
|
||||
if (isReadOnly())
|
||||
throw new SecurityException("attempt to add a Permission " +
|
||||
"to a readonly PermissionCollection");
|
||||
@ -506,10 +505,10 @@ implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and see if this CryptoPermission object implies
|
||||
* the given Permission object.
|
||||
* Check and see if this CryptoPermission object implies
|
||||
* the given Permission object.
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return true if the given permission is implied by this
|
||||
* CryptoPermissionCollection, false if not.
|
||||
@ -538,8 +537,7 @@ implements Serializable {
|
||||
* @return an enumeration of all the CryptoPermission objects.
|
||||
*/
|
||||
|
||||
public Enumeration<Permission> elements()
|
||||
{
|
||||
public Enumeration<Permission> elements() {
|
||||
return permissions.elements();
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ import java.lang.reflect.*;
|
||||
* @author Sharon Liu
|
||||
*
|
||||
* @see java.security.Permissions
|
||||
* @see java.security.spec.AlgrithomParameterSpec
|
||||
* @see java.security.spec.AlgorithmParameterSpec
|
||||
* @see javax.crypto.CryptoPermission
|
||||
* @see javax.crypto.CryptoAllPermission
|
||||
* @see javax.crypto.CryptoPermissions
|
||||
|
@ -33,7 +33,7 @@ import java.security.spec.*;
|
||||
* tranform the plaintext.
|
||||
*
|
||||
* @author Li Gong
|
||||
* @see Nullcipher
|
||||
* @see NullCipher
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
|
@ -798,7 +798,7 @@ public class MLet extends java.net.URLClassLoader
|
||||
* Allows the m-let to perform any operations it needs before being unregistered
|
||||
* by the MBean server.
|
||||
*
|
||||
* @exception java.langException This exception should be caught
|
||||
* @exception java.lang.Exception This exception should be caught
|
||||
* by the MBean server and re-thrown as an
|
||||
* MBeanRegistrationException.
|
||||
*/
|
||||
|
@ -189,7 +189,7 @@ public class ModelMBeanAttributeInfo
|
||||
* May be null if the property is write-only.
|
||||
* @param setter The method used for writing the attribute value.
|
||||
* May be null if the attribute is read-only.
|
||||
* @exception IntrospectionException There is a consistency
|
||||
* @exception javax.management.IntrospectionException There is a consistency
|
||||
* problem in the definition of this attribute.
|
||||
*
|
||||
*/
|
||||
@ -233,7 +233,7 @@ public class ModelMBeanAttributeInfo
|
||||
* it is null, then a default descriptor will be created. If
|
||||
* the descriptor does not contain the field "displayName" this field is added
|
||||
* in the descriptor with its default value.
|
||||
* @exception IntrospectionException There is a consistency
|
||||
* @exception javax.management.IntrospectionException There is a consistency
|
||||
* problem in the definition of this attribute.
|
||||
* @exception RuntimeOperationsException Wraps an
|
||||
* IllegalArgumentException. The descriptor is invalid, or descriptor
|
||||
|
@ -124,11 +124,6 @@ public class CompositeDataInvocationHandler implements InvocationHandler {
|
||||
<p>Construct a handler backed by the given {@code
|
||||
CompositeData}.</p>
|
||||
|
||||
@param mbsc the {@code MBeanServerConnection} related to this
|
||||
{@code CompositeData}. This is only relevant if a method in
|
||||
the interface for which this is an invocation handler returns
|
||||
a type that is an MXBean interface. Otherwise, it can be null.
|
||||
|
||||
@param compositeData the {@code CompositeData} that will supply
|
||||
information to getters.
|
||||
|
||||
|
@ -416,7 +416,7 @@ public class NamingManager {
|
||||
* specified.
|
||||
* See the <code>getObjectInstance</code> method for
|
||||
* details.
|
||||
* @param ctx The context relative to which <code>name</code> is
|
||||
* @param nameCtx The context relative to which <code>name</code> is
|
||||
* specified, or null for the default initial context.
|
||||
* See the <code>getObjectInstance</code> method for
|
||||
* details.
|
||||
|
@ -178,7 +178,6 @@ public final class DelegationPermission extends BasicPermission
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
|
||||
public int hashCode() {
|
||||
return getName().hashCode();
|
||||
}
|
||||
@ -278,12 +277,11 @@ final class KrbDelegationPermissionCollection extends PermissionCollection
|
||||
* Check and see if this collection of permissions implies the permissions
|
||||
* expressed in "permission".
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return true if "permission" is a proper subset of a permission in
|
||||
* the collection, false if not.
|
||||
*/
|
||||
|
||||
public boolean implies(Permission permission) {
|
||||
if (! (permission instanceof DelegationPermission))
|
||||
return false;
|
||||
@ -310,7 +308,6 @@ final class KrbDelegationPermissionCollection extends PermissionCollection
|
||||
* @exception SecurityException - if this PermissionCollection object
|
||||
* has been marked readonly
|
||||
*/
|
||||
|
||||
public void add(Permission permission) {
|
||||
if (! (permission instanceof DelegationPermission))
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
@ -329,7 +326,6 @@ final class KrbDelegationPermissionCollection extends PermissionCollection
|
||||
*
|
||||
* @return an enumeration of all the DelegationPermission objects.
|
||||
*/
|
||||
|
||||
public Enumeration<Permission> elements() {
|
||||
// Convert Iterator into Enumeration
|
||||
synchronized (this) {
|
||||
@ -376,8 +372,9 @@ final class KrbDelegationPermissionCollection extends PermissionCollection
|
||||
* Reads in a Vector of DelegationPermissions and saves them in the perms field.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
// Don't call defaultReadObject()
|
||||
|
||||
// Read in serialized fields
|
||||
|
@ -259,7 +259,6 @@ public final class ServicePermission extends Permission
|
||||
* Always returns present actions in the following order:
|
||||
* initiate, accept.
|
||||
*/
|
||||
|
||||
public String getActions() {
|
||||
if (actions == null)
|
||||
actions = getActions(this.mask);
|
||||
@ -280,7 +279,6 @@ public final class ServicePermission extends Permission
|
||||
* @return a new PermissionCollection object suitable for storing
|
||||
* ServicePermissions.
|
||||
*/
|
||||
|
||||
public PermissionCollection newPermissionCollection() {
|
||||
return new KrbServicePermissionCollection();
|
||||
}
|
||||
@ -290,7 +288,6 @@ public final class ServicePermission extends Permission
|
||||
*
|
||||
* @return the actions mask.
|
||||
*/
|
||||
|
||||
int getMask() {
|
||||
return mask;
|
||||
}
|
||||
@ -301,7 +298,6 @@ public final class ServicePermission extends Permission
|
||||
* @param action the action string
|
||||
* @return the action mask
|
||||
*/
|
||||
|
||||
private static int getMask(String action) {
|
||||
|
||||
if (action == null) {
|
||||
@ -468,12 +464,11 @@ final class KrbServicePermissionCollection extends PermissionCollection
|
||||
* Check and see if this collection of permissions implies the permissions
|
||||
* expressed in "permission".
|
||||
*
|
||||
* @param p the Permission object to compare
|
||||
* @param permission the Permission object to compare
|
||||
*
|
||||
* @return true if "permission" is a proper subset of a permission in
|
||||
* the collection, false if not.
|
||||
*/
|
||||
|
||||
public boolean implies(Permission permission) {
|
||||
if (! (permission instanceof ServicePermission))
|
||||
return false;
|
||||
@ -517,7 +512,6 @@ final class KrbServicePermissionCollection extends PermissionCollection
|
||||
* @exception SecurityException - if this PermissionCollection object
|
||||
* has been marked readonly
|
||||
*/
|
||||
|
||||
public void add(Permission permission) {
|
||||
if (! (permission instanceof ServicePermission))
|
||||
throw new IllegalArgumentException("invalid permission: "+
|
||||
@ -584,8 +578,9 @@ final class KrbServicePermissionCollection extends PermissionCollection
|
||||
* Reads in a Vector of ServicePermissions and saves them in the perms field.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
// Don't call defaultReadObject()
|
||||
|
||||
// Read in serialized fields
|
||||
|
@ -48,7 +48,7 @@ public interface ConnectionPoolDataSource extends CommonDataSource {
|
||||
* connection to the database that this
|
||||
* <code>ConnectionPoolDataSource</code> object represents
|
||||
* @exception SQLException if a database access error occurs
|
||||
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
|
||||
* @exception java.sql.SQLFeatureNotSupportedException if the JDBC driver does not support
|
||||
* this method
|
||||
* @since 1.4
|
||||
*/
|
||||
@ -64,7 +64,7 @@ public interface ConnectionPoolDataSource extends CommonDataSource {
|
||||
* connection to the database that this
|
||||
* <code>ConnectionPoolDataSource</code> object represents
|
||||
* @exception SQLException if a database access error occurs
|
||||
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
|
||||
* @exception java.sql.SQLFeatureNotSupportedException if the JDBC driver does not support
|
||||
* this method
|
||||
* @since 1.4
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user