diff --git a/jdk/make/gendata/GendataBreakIterator.gmk b/jdk/make/gendata/GendataBreakIterator.gmk
index 828e6314790..39a5dfb5efc 100644
--- a/jdk/make/gendata/GendataBreakIterator.gmk
+++ b/jdk/make/gendata/GendataBreakIterator.gmk
@@ -55,7 +55,6 @@ $(eval $(call SetupJavaCompilation,BUILD_BREAKITERATOR_BASE, \
$(eval $(call SetupJavaCompilation,BUILD_BREAKITERATOR_LD, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(JDK_TOPDIR)/src/jdk.localedata/share/classes, \
- INCLUDES := $(TEXT_PKG_LD), \
INCLUDE_FILES := \
$(TEXT_PKG_LD)/BreakIteratorRules_th.java \
$(TEXT_PKG_LD)/BreakIteratorInfo_th.java, \
diff --git a/jdk/make/mapfiles/libsplashscreen/mapfile-vers b/jdk/make/mapfiles/libsplashscreen/mapfile-vers
index b948ef474a6..088cb4d2896 100644
--- a/jdk/make/mapfiles/libsplashscreen/mapfile-vers
+++ b/jdk/make/mapfiles/libsplashscreen/mapfile-vers
@@ -44,6 +44,7 @@ SUNWprivate_1.1 {
SplashSetFileJarName;
SplashSetScaleFactor;
SplashGetScaledImageName;
+ SplashGetScaledImgNameMaxPstfixLen;
local:
*;
};
diff --git a/jdk/src/java.base/share/classes/java/io/FileInputStream.java b/jdk/src/java.base/share/classes/java/io/FileInputStream.java
index cc77e5bd7c4..713b2ad0e95 100644
--- a/jdk/src/java.base/share/classes/java/io/FileInputStream.java
+++ b/jdk/src/java.base/share/classes/java/io/FileInputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
package java.io;
import java.nio.channels.FileChannel;
-import java.util.concurrent.atomic.AtomicBoolean;
import sun.nio.ch.FileChannelImpl;
@@ -60,7 +59,9 @@ class FileInputStream extends InputStream
private volatile FileChannel channel;
- private final AtomicBoolean closed = new AtomicBoolean(false);
+ private final Object closeLock = new Object();
+
+ private volatile boolean closed;
/**
* Creates a FileInputStream by
@@ -313,14 +314,21 @@ class FileInputStream extends InputStream
* @spec JSR-51
*/
public void close() throws IOException {
- if (!closed.compareAndSet(false, true)) {
- // if compareAndSet() returns false closed was already true
+ if (closed) {
return;
}
+ synchronized (closeLock) {
+ if (closed) {
+ return;
+ }
+ closed = true;
+ }
FileChannel fc = channel;
if (fc != null) {
- fc.close();
+ // possible race with getChannel(), benign since
+ // FileChannel.close is final and idempotent
+ fc.close();
}
fd.closeAll(new Closeable() {
@@ -370,8 +378,10 @@ class FileInputStream extends InputStream
fc = this.channel;
if (fc == null) {
this.channel = fc = FileChannelImpl.open(fd, path, true, false, this);
- if (closed.get()) {
+ if (closed) {
try {
+ // possible race with close(), benign since
+ // FileChannel.close is final and idempotent
fc.close();
} catch (IOException ioe) {
throw new InternalError(ioe); // should not happen
diff --git a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java
index 52d1596b3c4..f6bdb1f3b5f 100644
--- a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java
+++ b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
package java.io;
import java.nio.channels.FileChannel;
-import java.util.concurrent.atomic.AtomicBoolean;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaIOFileDescriptorAccess;
import sun.nio.ch.FileChannelImpl;
@@ -77,7 +76,9 @@ class FileOutputStream extends OutputStream
*/
private final String path;
- private final AtomicBoolean closed = new AtomicBoolean(false);
+ private final Object closeLock = new Object();
+
+ private volatile boolean closed;
/**
* Creates a file output stream to write to the file with the
@@ -341,14 +342,21 @@ class FileOutputStream extends OutputStream
* @spec JSR-51
*/
public void close() throws IOException {
- if (!closed.compareAndSet(false, true)) {
- // if compareAndSet() returns false closed was already true
+ if (closed) {
return;
}
+ synchronized (closeLock) {
+ if (closed) {
+ return;
+ }
+ closed = true;
+ }
FileChannel fc = channel;
if (fc != null) {
- fc.close();
+ // possible race with getChannel(), benign since
+ // FileChannel.close is final and idempotent
+ fc.close();
}
fd.closeAll(new Closeable() {
@@ -399,8 +407,10 @@ class FileOutputStream extends OutputStream
fc = this.channel;
if (fc == null) {
this.channel = fc = FileChannelImpl.open(fd, path, false, true, this);
- if (closed.get()) {
+ if (closed) {
try {
+ // possible race with close(), benign since
+ // FileChannel.close is final and idempotent
fc.close();
} catch (IOException ioe) {
throw new InternalError(ioe); // should not happen
diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
index a7c093c7034..7b5a79277ed 100644
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
@@ -104,9 +104,9 @@ import sun.security.util.SecurityConstants;
* class or resource itself.
*
*
@@ -1448,8 +1448,10 @@ public abstract class ClassLoader {
* Note that once a class loader is registered as parallel capable, there
* is no way to change it back.
*
- * @return true if the caller is successfully registered as
- * parallel capable and false if otherwise.
+ * @return {@code true} if the caller is successfully registered as
+ * parallel capable and {@code false} if otherwise.
+ *
+ * @see #isParallelCapable()
*
* @since 1.7
*/
@@ -1460,6 +1462,22 @@ public abstract class ClassLoader {
return ParallelLoaders.register(callerClass);
}
+ /**
+ * Returns {@code true} if this class loader is
+ * {@linkplain #registerAsParallelCapable parallel capable}, otherwise
+ * {@code false}.
+ *
+ * @return {@code true} if this class loader is parallel capable,
+ * otherwise {@code false}.
+ *
+ * @see #registerAsParallelCapable()
+ *
+ * @since 9
+ */
+ public final boolean isParallelCapable() {
+ return ParallelLoaders.isRegistered(this.getClass());
+ }
+
/**
* Find a resource of the specified name from the search path used to load
* classes. This method locates the resource through the system class
@@ -1663,6 +1681,15 @@ public abstract class ClassLoader {
* this method during startup should take care not to cache the return
* value until the system is fully initialized.
*
+ * The class path used by the built-in system class loader is determined
+ * by the system property "{@code java.class.path}" during early
+ * initialization of the VM. If the system property is not defined,
+ * or its value is an empty string, then there is no class path
+ * when the initial module is a module on the application module path,
+ * i.e. a named module. If the initial module is not on
+ * the application module path then the class path defaults to
+ * the current working directory.
+ *
* @return The system ClassLoader for delegation
*
* @throws SecurityException
diff --git a/jdk/src/java.base/share/classes/java/net/InetAddress.java b/jdk/src/java.base/share/classes/java/net/InetAddress.java
index b008b35260a..84457f30066 100644
--- a/jdk/src/java.base/share/classes/java/net/InetAddress.java
+++ b/jdk/src/java.base/share/classes/java/net/InetAddress.java
@@ -201,13 +201,13 @@ class InetAddress implements java.io.Serializable {
* Specify the address family: Internet Protocol, Version 4
* @since 1.4
*/
- static final int IPv4 = 1;
+ @Native static final int IPv4 = 1;
/**
* Specify the address family: Internet Protocol, Version 6
* @since 1.4
*/
- static final int IPv6 = 2;
+ @Native static final int IPv6 = 2;
/* Specify address family preference */
static transient final int preferIPv6Address;
diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
index deaf34c41c2..428b6fc06a8 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java
@@ -69,16 +69,17 @@ public class ClassLoaders {
bcp = toURLClassPath(s);
// we have a class path if -cp is specified or -m is not specified.
- // If neither is specified then default to -cp .
+ // If neither is specified then default to -cp
+ // If -cp is not specified and -m is specified, the value of
+ // java.class.path is an empty string, then no class path.
URLClassPath ucp = null;
String mainMid = System.getProperty("jdk.module.main");
String cp = System.getProperty("java.class.path");
- if (mainMid == null && cp == null)
+ if (cp == null)
cp = "";
- if (cp != null)
+ if (mainMid == null || cp.length() > 0)
ucp = toURLClassPath(cp);
-
// create the class loaders
BOOT_LOADER = new BootClassLoader(bcp);
PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER);
diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
index b68e6a6a448..3801d542fcc 100644
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@ java.launcher.opt.header = Usage: {0} [options] class [args...]\n\
\ (to execute the main class in a module)\n\
where options include:\n
-java.launcher.opt.datamodel =\ -d{0}\t use a {0}-bit data model if available\n
+java.launcher.opt.datamodel =\ -d{0}\t Deprecated, will be removed in a future release\n
java.launcher.opt.vmselect =\ {0}\t to select the "{1}" VM\n
java.launcher.opt.hotspot =\ {0}\t is a synonym for the "{1}" VM [deprecated]\n
@@ -95,6 +95,12 @@ java.launcher.opt.footer =\ -cp \n\
\ show splash screen with specified image\n\
+\ HiDPI scaled images are automatically supported and used\n\
+\ if available. The unscaled image filename, e.g. image.ext,\n\
+\ should always be passed as the argument to the -splash option.\n\
+\ The most appropriate scaled image provided will be picked up\n\
+\ automatically.\n\
+\ See the SplashScreen API documentation for more information.\n\
\ @ read options from the specified file\n\
\To specify an argument for a long option, you can use --= or\n\
\-- .\n\
diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java b/jdk/src/java.base/share/classes/sun/text/BreakDictionary.java
similarity index 70%
rename from jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java
rename to jdk/src/java.base/share/classes/sun/text/BreakDictionary.java
index 4be1363b58f..ae2aba1e7c2 100644
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakDictionary.java
+++ b/jdk/src/java.base/share/classes/sun/text/BreakDictionary.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,15 +37,10 @@
* This notice and attribution to Taligent may not be removed.
* Taligent is a registered trademark of Taligent, Inc.
*/
-package sun.util.locale.provider;
+package sun.text;
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.lang.reflect.Module;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
import java.util.MissingResourceException;
import sun.text.CompactByteArray;
import sun.text.SupplementaryCharacterData;
@@ -137,131 +132,90 @@ class BreakDictionary {
// deserialization
//=========================================================================
- BreakDictionary(Module module, String dictionaryName)
- throws IOException, MissingResourceException {
-
- readDictionaryFile(module, dictionaryName);
+ BreakDictionary(String dictionaryName, byte[] dictionaryData) {
+ try {
+ setupDictionary(dictionaryName, dictionaryData);
+ } catch (BufferUnderflowException bue) {
+ MissingResourceException e;
+ e = new MissingResourceException("Corrupted dictionary data",
+ dictionaryName, "");
+ e.initCause(bue);
+ throw e;
+ }
}
- private void readDictionaryFile(final Module module, final String dictionaryName)
- throws IOException, MissingResourceException {
-
- BufferedInputStream in;
- try {
- PrivilegedExceptionAction pa = () -> {
- String pathName = "jdk.localedata".equals(module.getName()) ?
- "sun/text/resources/ext/" :
- "sun/text/resources/";
- InputStream is = module.getResourceAsStream(pathName + dictionaryName);
- if (is == null) {
- // Try to load the file with "java.base" module instance. Assumption
- // here is that the fall back data files to be read should reside in
- // java.base.
- is = BreakDictionary.class.getModule().getResourceAsStream("sun/text/resources/" + dictionaryName);
- }
-
- return new BufferedInputStream(is);
- };
- in = AccessController.doPrivileged(pa);
- }
- catch (PrivilegedActionException e) {
- throw new InternalError(e.toString(), e);
- }
-
- byte[] buf = new byte[8];
- if (in.read(buf) != 8) {
- throw new MissingResourceException("Wrong data length",
- dictionaryName, "");
- }
+ private void setupDictionary(String dictionaryName, byte[] dictionaryData) {
+ ByteBuffer bb = ByteBuffer.wrap(dictionaryData);
// check version
- int version = RuleBasedBreakIterator.getInt(buf, 0);
+ int version = bb.getInt();
if (version != supportedVersion) {
throw new MissingResourceException("Dictionary version(" + version + ") is unsupported",
- dictionaryName, "");
- }
-
- // get data size
- int len = RuleBasedBreakIterator.getInt(buf, 4);
- buf = new byte[len];
- if (in.read(buf) != len) {
- throw new MissingResourceException("Wrong data length",
dictionaryName, "");
}
- // close the stream
- in.close();
-
- int l;
- int offset = 0;
+ // Check data size
+ int len = bb.getInt();
+ if (bb.position() + len != bb.limit()) {
+ throw new MissingResourceException("Dictionary size is wrong: " + bb.limit(),
+ dictionaryName, "");
+ }
// read in the column map for BMP characteres (this is serialized in
// its internal form: an index array followed by a data array)
- l = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- short[] temp = new short[l];
- for (int i = 0; i < l; i++, offset+=2) {
- temp[i] = RuleBasedBreakIterator.getShort(buf, offset);
- }
- l = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- byte[] temp2 = new byte[l];
- for (int i = 0; i < l; i++, offset++) {
- temp2[i] = buf[offset];
+ len = bb.getInt();
+ short[] temp = new short[len];
+ for (int i = 0; i < len; i++) {
+ temp[i] = bb.getShort();
}
+ len = bb.getInt();
+ byte[] temp2 = new byte[len];
+ bb.get(temp2);
columnMap = new CompactByteArray(temp, temp2);
// read in numCols and numColGroups
- numCols = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- numColGroups = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
+ numCols = bb.getInt();
+ numColGroups = bb.getInt();
// read in the row-number index
- l = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- rowIndex = new short[l];
- for (int i = 0; i < l; i++, offset+=2) {
- rowIndex[i] = RuleBasedBreakIterator.getShort(buf, offset);
+ len = bb.getInt();
+ rowIndex = new short[len];
+ for (int i = 0; i < len; i++) {
+ rowIndex[i] = bb.getShort();
}
// load in the populated-cells bitmap: index first, then bitmap list
- l = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- rowIndexFlagsIndex = new short[l];
- for (int i = 0; i < l; i++, offset+=2) {
- rowIndexFlagsIndex[i] = RuleBasedBreakIterator.getShort(buf, offset);
+ len = bb.getInt();
+ rowIndexFlagsIndex = new short[len];
+ for (int i = 0; i < len; i++) {
+ rowIndexFlagsIndex[i] = bb.getShort();
}
- l = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- rowIndexFlags = new int[l];
- for (int i = 0; i < l; i++, offset+=4) {
- rowIndexFlags[i] = RuleBasedBreakIterator.getInt(buf, offset);
+ len = bb.getInt();
+ rowIndexFlags = new int[len];
+ for (int i = 0; i < len; i++) {
+ rowIndexFlags[i] = bb.getInt();
}
// load in the row-shift index
- l = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- rowIndexShifts = new byte[l];
- for (int i = 0; i < l; i++, offset++) {
- rowIndexShifts[i] = buf[offset];
- }
+ len = bb.getInt();
+ rowIndexShifts = new byte[len];
+ bb.get(rowIndexShifts);
// load in the actual state table
- l = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- table = new short[l];
- for (int i = 0; i < l; i++, offset+=2) {
- table[i] = RuleBasedBreakIterator.getShort(buf, offset);
+ len = bb.getInt();
+ table = new short[len];
+ for (int i = 0; i < len; i++) {
+ table[i] = bb.getShort();
}
// finally, prepare the column map for supplementary characters
- l = RuleBasedBreakIterator.getInt(buf, offset);
- offset += 4;
- int[] temp3 = new int[l];
- for (int i = 0; i < l; i++, offset+=4) {
- temp3[i] = RuleBasedBreakIterator.getInt(buf, offset);
+ len = bb.getInt();
+ int[] temp3 = new int[len];
+ for (int i = 0; i < len; i++) {
+ temp3[i] = bb.getInt();
}
+ assert bb.position() == bb.limit();
+
supplementaryCharColumnMap = new SupplementaryCharacterData(temp3);
}
diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/DictionaryBasedBreakIterator.java b/jdk/src/java.base/share/classes/sun/text/DictionaryBasedBreakIterator.java
similarity index 96%
rename from jdk/src/java.base/share/classes/sun/util/locale/provider/DictionaryBasedBreakIterator.java
rename to jdk/src/java.base/share/classes/sun/text/DictionaryBasedBreakIterator.java
index f7eff4e80cf..bd47872bec1 100644
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/DictionaryBasedBreakIterator.java
+++ b/jdk/src/java.base/share/classes/sun/text/DictionaryBasedBreakIterator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,10 +38,8 @@
* Taligent is a registered trademark of Taligent, Inc.
*/
-package sun.util.locale.provider;
+package sun.text;
-import java.io.IOException;
-import java.lang.reflect.Module;
import java.text.CharacterIterator;
import java.util.ArrayList;
import java.util.List;
@@ -72,7 +70,7 @@ import java.util.Stack;
* slow) BuildDictionaryFile utility for creating dictionary files, but aren't
* currently making it public. Contact us for help.
*/
-class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
+public class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
/**
* a list of known words that is used to divide up contiguous ranges of letters,
@@ -109,18 +107,22 @@ class DictionaryBasedBreakIterator extends RuleBasedBreakIterator {
/**
* Constructs a DictionaryBasedBreakIterator.
- * @param module The module where the dictionary file resides
- * @param dictionaryFilename The filename of the dictionary file to use
+ *
+ * @param ruleFile the name of the rule data file
+ * @param ruleData the rule data loaded from the rule data file
+ * @param dictionaryFile the name of the dictionary file
+ * @param dictionartData the dictionary data loaded from the dictionary file
+ * @throws MissingResourceException if rule data or dictionary initialization failed
*/
- DictionaryBasedBreakIterator(Module module, String dataFile, String dictionaryFile)
- throws IOException {
- super(module, dataFile);
+ public DictionaryBasedBreakIterator(String ruleFile, byte[] ruleData,
+ String dictionaryFile, byte[] dictionaryData) {
+ super(ruleFile, ruleData);
byte[] tmp = super.getAdditionalData();
if (tmp != null) {
prepareCategoryFlags(tmp);
super.setAdditionalData(null);
}
- dictionary = new BreakDictionary(module, dictionaryFile);
+ dictionary = new BreakDictionary(dictionaryFile, dictionaryData);
}
private void prepareCategoryFlags(byte[] data) {
diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java b/jdk/src/java.base/share/classes/sun/text/RuleBasedBreakIterator.java
similarity index 88%
rename from jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java
rename to jdk/src/java.base/share/classes/sun/text/RuleBasedBreakIterator.java
index ebf6ba1956e..b3abf812f29 100644
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/RuleBasedBreakIterator.java
+++ b/jdk/src/java.base/share/classes/sun/text/RuleBasedBreakIterator.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -38,15 +38,10 @@
* Taligent is a registered trademark of Taligent, Inc.
*/
-package sun.util.locale.provider;
+package sun.text;
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.lang.reflect.Module;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
+import java.nio.BufferUnderflowException;
+import java.nio.ByteBuffer;
import java.text.BreakIterator;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
@@ -218,7 +213,7 @@ import sun.text.SupplementaryCharacterData;
*
* @author Richard Gillam
*/
-class RuleBasedBreakIterator extends BreakIterator {
+public class RuleBasedBreakIterator extends BreakIterator {
/**
* A token used as a character-category value to identify ignore characters
@@ -249,11 +244,6 @@ class RuleBasedBreakIterator extends BreakIterator {
*/
static final byte supportedVersion = 1;
- /**
- * Header size in byte count
- */
- private static final int HEADER_LENGTH = 36;
-
/**
* An array length of indices for BMP characters
*/
@@ -315,16 +305,26 @@ class RuleBasedBreakIterator extends BreakIterator {
//=======================================================================
/**
- * Constructs a RuleBasedBreakIterator according to the module and the datafile
- * provided.
+ * Constructs a RuleBasedBreakIterator using the given rule data.
+ *
+ * @throws MissingResourceException if the rule data is invalid or corrupted
*/
- RuleBasedBreakIterator(Module module, String datafile)
- throws IOException, MissingResourceException {
- readTables(module, datafile);
+ public RuleBasedBreakIterator(String ruleFile, byte[] ruleData) {
+ ByteBuffer bb = ByteBuffer.wrap(ruleData);
+ try {
+ validateRuleData(ruleFile, bb);
+ setupTables(ruleFile, bb);
+ } catch (BufferUnderflowException bue) {
+ MissingResourceException e;
+ e = new MissingResourceException("Corrupted rule data file", ruleFile, "");
+ e.initCause(bue);
+ throw e;
+ }
}
/**
- * Read datafile. The datafile's format is as follows:
+ * Initializes the fields with the given rule data.
+ * The data format is as follows:
*
* BreakIteratorData {
* u1 magic[7];
@@ -370,133 +370,101 @@ class RuleBasedBreakIterator extends BreakIterator {
* u1 additionalData[additionalDataLength];
* }
*
+ *
+ * @throws BufferUnderflowException if the end-of-data is reached before
+ * setting up all the tables
*/
- protected final void readTables(Module module, String datafile)
- throws IOException, MissingResourceException {
-
- byte[] buffer = readFile(module, datafile);
-
+ private void setupTables(String ruleFile, ByteBuffer bb) {
/* Read header_info. */
- int stateTableLength = getInt(buffer, 0);
- int backwardsStateTableLength = getInt(buffer, 4);
- int endStatesLength = getInt(buffer, 8);
- int lookaheadStatesLength = getInt(buffer, 12);
- int BMPdataLength = getInt(buffer, 16);
- int nonBMPdataLength = getInt(buffer, 20);
- int additionalDataLength = getInt(buffer, 24);
- checksum = getLong(buffer, 28);
+ int stateTableLength = bb.getInt();
+ int backwardsStateTableLength = bb.getInt();
+ int endStatesLength = bb.getInt();
+ int lookaheadStatesLength = bb.getInt();
+ int BMPdataLength = bb.getInt();
+ int nonBMPdataLength = bb.getInt();
+ int additionalDataLength = bb.getInt();
+ checksum = bb.getLong();
/* Read stateTable[numCategories * numRows] */
stateTable = new short[stateTableLength];
- int offset = HEADER_LENGTH;
- for (int i = 0; i < stateTableLength; i++, offset+=2) {
- stateTable[i] = getShort(buffer, offset);
+ for (int i = 0; i < stateTableLength; i++) {
+ stateTable[i] = bb.getShort();
}
/* Read backwardsStateTable[numCategories * numRows] */
backwardsStateTable = new short[backwardsStateTableLength];
- for (int i = 0; i < backwardsStateTableLength; i++, offset+=2) {
- backwardsStateTable[i] = getShort(buffer, offset);
+ for (int i = 0; i < backwardsStateTableLength; i++) {
+ backwardsStateTable[i] = bb.getShort();
}
/* Read endStates[numRows] */
endStates = new boolean[endStatesLength];
- for (int i = 0; i < endStatesLength; i++, offset++) {
- endStates[i] = buffer[offset] == 1;
+ for (int i = 0; i < endStatesLength; i++) {
+ endStates[i] = bb.get() == 1;
}
/* Read lookaheadStates[numRows] */
lookaheadStates = new boolean[lookaheadStatesLength];
- for (int i = 0; i < lookaheadStatesLength; i++, offset++) {
- lookaheadStates[i] = buffer[offset] == 1;
+ for (int i = 0; i < lookaheadStatesLength; i++) {
+ lookaheadStates[i] = bb.get() == 1;
}
/* Read a category table and indices for BMP characters. */
short[] temp1 = new short[BMP_INDICES_LENGTH]; // BMPindices
- for (int i = 0; i < BMP_INDICES_LENGTH; i++, offset+=2) {
- temp1[i] = getShort(buffer, offset);
+ for (int i = 0; i < BMP_INDICES_LENGTH; i++) {
+ temp1[i] = bb.getShort();
}
byte[] temp2 = new byte[BMPdataLength]; // BMPdata
- System.arraycopy(buffer, offset, temp2, 0, BMPdataLength);
- offset += BMPdataLength;
+ bb.get(temp2);
charCategoryTable = new CompactByteArray(temp1, temp2);
/* Read a category table for non-BMP characters. */
int[] temp3 = new int[nonBMPdataLength];
- for (int i = 0; i < nonBMPdataLength; i++, offset+=4) {
- temp3[i] = getInt(buffer, offset);
+ for (int i = 0; i < nonBMPdataLength; i++) {
+ temp3[i] = bb.getInt();
}
supplementaryCharCategoryTable = new SupplementaryCharacterData(temp3);
/* Read additional data */
if (additionalDataLength > 0) {
additionalData = new byte[additionalDataLength];
- System.arraycopy(buffer, offset, additionalData, 0, additionalDataLength);
+ bb.get(additionalData);
}
+ assert bb.position() == bb.limit();
/* Set numCategories */
numCategories = stateTable.length / endStates.length;
}
- protected byte[] readFile(final Module module, final String datafile)
- throws IOException, MissingResourceException {
-
- BufferedInputStream is;
- try {
- PrivilegedExceptionAction pa = () -> {
- String pathName = "jdk.localedata".equals(module.getName()) ?
- "sun/text/resources/ext/" :
- "sun/text/resources/";
- InputStream in = module.getResourceAsStream(pathName + datafile);
- if (in == null) {
- // Try to load the file with "java.base" module instance. Assumption
- // here is that the fall back data files to be read should reside in
- // java.base.
- in = RuleBasedBreakIterator.class.getModule().getResourceAsStream("sun/text/resources/" + datafile);
- }
-
- return new BufferedInputStream(in);
- };
- is = AccessController.doPrivileged(pa);
- } catch (PrivilegedActionException e) {
- throw new InternalError(e.toString(), e);
- }
-
- int offset = 0;
-
- /* First, read magic, version, and header_info. */
- int len = LABEL_LENGTH + 5;
- byte[] buf = new byte[len];
- if (is.read(buf) != len) {
- throw new MissingResourceException("Wrong header length",
- datafile, "");
- }
-
- /* Validate the magic number. */
- for (int i = 0; i < LABEL_LENGTH; i++, offset++) {
- if (buf[offset] != LABEL[offset]) {
+ /**
+ * Validates the magic number, version, and the length of the given data.
+ *
+ * @throws BufferUnderflowException if the end-of-data is reached while
+ * validating data
+ * @throws MissingResourceException if valification failed
+ */
+ void validateRuleData(String ruleFile, ByteBuffer bb) {
+ /* Verify the magic number. */
+ for (int i = 0; i < LABEL_LENGTH; i++) {
+ if (bb.get() != LABEL[i]) {
throw new MissingResourceException("Wrong magic number",
- datafile, "");
+ ruleFile, "");
}
}
- /* Validate the version number. */
- if (buf[offset] != supportedVersion) {
- throw new MissingResourceException("Unsupported version(" + buf[offset] + ")",
- datafile, "");
+ /* Verify the version number. */
+ byte version = bb.get();
+ if (version != supportedVersion) {
+ throw new MissingResourceException("Unsupported version(" + version + ")",
+ ruleFile, "");
}
- /* Read data: totalDataSize + 8(for checksum) */
- len = getInt(buf, ++offset);
- buf = new byte[len];
- if (is.read(buf) != len) {
+ // Check the length of the rest of data
+ int len = bb.getInt();
+ if (bb.position() + len != bb.limit()) {
throw new MissingResourceException("Wrong data length",
- datafile, "");
+ ruleFile, "");
}
-
- is.close();
-
- return buf;
}
byte[] getAdditionalData() {
@@ -1061,28 +1029,6 @@ class RuleBasedBreakIterator extends BreakIterator {
return backwardsStateTable[state * numCategories + category];
}
- static long getLong(byte[] buf, int offset) {
- long num = buf[offset]&0xFF;
- for (int i = 1; i < 8; i++) {
- num = num<<8 | (buf[offset+i]&0xFF);
- }
- return num;
- }
-
- static int getInt(byte[] buf, int offset) {
- int num = buf[offset]&0xFF;
- for (int i = 1; i < 4; i++) {
- num = num<<8 | (buf[offset+i]&0xFF);
- }
- return num;
- }
-
- static short getShort(byte[] buf, int offset) {
- short num = (short)(buf[offset]&0xFF);
- num = (short)(num<<8 | (buf[offset+1]&0xFF));
- return num;
- }
-
/*
* This class exists to work around a bug in incorrect implementations
* of CharacterIterator, which incorrectly handle setIndex(endIndex).
diff --git a/jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorResources.java b/jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorResources.java
new file mode 100644
index 00000000000..848117e126e
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/text/resources/BreakIteratorResources.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. 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.text.resources;
+
+import java.util.ResourceBundle;
+import sun.util.resources.BreakIteratorResourceBundle;
+
+public class BreakIteratorResources extends BreakIteratorResourceBundle {
+ @Override
+ protected ResourceBundle getBreakIteratorInfo() {
+ return new BreakIteratorInfo();
+ }
+}
diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakIteratorProviderImpl.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakIteratorProviderImpl.java
index 2de50a98962..1343dadb3b9 100644
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakIteratorProviderImpl.java
+++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/BreakIteratorProviderImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,8 @@ import java.util.Locale;
import java.util.MissingResourceException;
import java.util.Objects;
import java.util.Set;
+import sun.text.DictionaryBasedBreakIterator;
+import sun.text.RuleBasedBreakIterator;
/**
* Concrete implementation of the {@link java.text.spi.BreakIteratorProvider
@@ -153,29 +155,31 @@ public class BreakIteratorProviderImpl extends BreakIteratorProvider
}
private BreakIterator getBreakInstance(Locale locale,
- int type,
- String dataName,
- String dictionaryName) {
+ int type,
+ String ruleName,
+ String dictionaryName) {
Objects.requireNonNull(locale);
LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
String[] classNames = (String[]) lr.getBreakIteratorInfo("BreakIteratorClasses");
- String dataFile = (String) lr.getBreakIteratorInfo(dataName);
+ String ruleFile = (String) lr.getBreakIteratorInfo(ruleName);
+ byte[] ruleData = lr.getBreakIteratorResources(ruleName);
try {
switch (classNames[type]) {
case "RuleBasedBreakIterator":
- return new RuleBasedBreakIterator(
- lr.getBreakIteratorDataModule(), dataFile);
+ return new RuleBasedBreakIterator(ruleFile, ruleData);
+
case "DictionaryBasedBreakIterator":
String dictionaryFile = (String) lr.getBreakIteratorInfo(dictionaryName);
- return new DictionaryBasedBreakIterator(
- lr.getBreakIteratorDataModule(), dataFile, dictionaryFile);
+ byte[] dictionaryData = lr.getBreakIteratorResources(dictionaryName);
+ return new DictionaryBasedBreakIterator(ruleFile, ruleData,
+ dictionaryFile, dictionaryData);
default:
throw new IllegalArgumentException("Invalid break iterator class \"" +
classNames[type] + "\"");
}
- } catch (IOException | MissingResourceException | IllegalArgumentException e) {
+ } catch (MissingResourceException | IllegalArgumentException e) {
throw new InternalError(e.toString(), e);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java
index 2269d608eb5..a6f3bc53bb0 100644
--- a/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java
+++ b/jdk/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@ package sun.util.locale.provider;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
-import java.lang.reflect.Module;
import java.text.MessageFormat;
import java.util.Calendar;
import java.util.LinkedHashSet;
@@ -113,13 +112,14 @@ public class LocaleResources {
if (data == null || ((biInfo = data.get()) == null)) {
biInfo = localeData.getBreakIteratorInfo(locale).getObject(key);
cache.put(cacheKey, new ResourceReference(cacheKey, biInfo, referenceQueue));
- }
+ }
return biInfo;
}
- Module getBreakIteratorDataModule() {
- return localeData.getBreakIteratorInfo(locale).getClass().getModule();
+ @SuppressWarnings("unchecked")
+ byte[] getBreakIteratorResources(String key) {
+ return (byte[]) localeData.getBreakIteratorResources(locale).getObject(key);
}
int getCalendarData(String key) {
diff --git a/jdk/src/java.base/share/classes/sun/util/resources/BreakIteratorResourceBundle.java b/jdk/src/java.base/share/classes/sun/util/resources/BreakIteratorResourceBundle.java
new file mode 100644
index 00000000000..d859e2a3ace
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/util/resources/BreakIteratorResourceBundle.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. 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.util.resources;
+
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * BreakIteratorResourceBundle is an abstract class for loading BreakIterator
+ * data (rules or dictionary) from each module. An implementation class must
+ * implement getBreakIteratorInfo() that returns an instance of the
+ * corresponding BreakIteratorInfo (basename). The data name is taken from the
+ * BreakIteratorInfo instance.
+ *
+ * For example, if the given key is "WordDictionary" and Locale is "th", the
+ * data name is taken from a BreakIteratorInfo_th and the key's value is
+ * "thai_dict". Its data thai_dict is loaded from the Module of the
+ * implementation class of this class.
+ */
+
+public abstract class BreakIteratorResourceBundle extends ResourceBundle {
+ // If any keys that are not for data names are added to BreakIteratorInfo*,
+ // those keys must be added to NON_DATA_KEYS.
+ private static final Set NON_DATA_KEYS = Set.of("BreakIteratorClasses");
+
+ private volatile Set keys;
+
+ /**
+ * Returns an instance of the corresponding {@code BreakIteratorInfo} (basename).
+ * The instance shouldn't have its parent.
+ */
+ protected abstract ResourceBundle getBreakIteratorInfo();
+
+ @Override
+ protected Object handleGetObject(String key) {
+ if (NON_DATA_KEYS.contains(key)) {
+ return null;
+ }
+ ResourceBundle info = getBreakIteratorInfo();
+ if (!info.containsKey(key)) {
+ return null;
+ }
+ String path = getClass().getPackage().getName().replace('.', '/')
+ + '/' + info.getString(key);
+ byte[] data;
+ try (InputStream is = getResourceAsStream(path)) {
+ data = is.readAllBytes();
+ } catch (Exception e) {
+ throw new InternalError("Can't load " + path, e);
+ }
+ return data;
+ }
+
+ private InputStream getResourceAsStream(String path) throws Exception {
+ PrivilegedExceptionAction pa;
+ pa = () -> getClass().getModule().getResourceAsStream(path);
+ InputStream is;
+ try {
+ is = AccessController.doPrivileged(pa);
+ } catch (PrivilegedActionException e) {
+ throw e.getException();
+ }
+ return is;
+ }
+
+ @Override
+ public Enumeration getKeys() {
+ return Collections.enumeration(keySet());
+ }
+
+ @Override
+ protected Set handleKeySet() {
+ if (keys == null) {
+ ResourceBundle info = getBreakIteratorInfo();
+ Set k = info.keySet();
+ k.removeAll(NON_DATA_KEYS);
+ synchronized (this) {
+ if (keys == null) {
+ keys = k;
+ }
+ }
+ }
+ return keys;
+ }
+}
diff --git a/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java b/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java
index 5510b6cc250..497742667e7 100644
--- a/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java
+++ b/jdk/src/java.base/share/classes/sun/util/resources/LocaleData.java
@@ -122,6 +122,14 @@ public class LocaleData {
return getBundle(type.getTextResourcesPackage() + ".BreakIteratorInfo", locale);
}
+ /**
+ * Gets a break iterator resources resource bundle, using
+ * privileges to allow accessing a sun.* package.
+ */
+ public ResourceBundle getBreakIteratorResources(Locale locale) {
+ return getBundle(type.getTextResourcesPackage() + ".BreakIteratorResources", locale);
+ }
+
/**
* Gets a collation data resource bundle, using privileges
* to allow accessing a sun.* package.
diff --git a/jdk/src/java.base/share/lib/security/default.policy b/jdk/src/java.base/share/lib/security/default.policy
index 17e1c80e627..966898459a7 100644
--- a/jdk/src/java.base/share/lib/security/default.policy
+++ b/jdk/src/java.base/share/lib/security/default.policy
@@ -32,8 +32,22 @@ grant codeBase "jrt:/java.smartcardio" {
permission javax.smartcardio.CardPermission "*", "*";
permission java.lang.RuntimePermission "loadLibrary.j2pcsc";
permission java.lang.RuntimePermission
- "accessClassInPackage.sun.security.*";
- permission java.util.PropertyPermission "*", "read";
+ "accessClassInPackage.sun.security.jca";
+ permission java.lang.RuntimePermission
+ "accessClassInPackage.sun.security.util";
+ permission java.util.PropertyPermission
+ "javax.smartcardio.TerminalFactory.DefaultType", "read";
+ permission java.util.PropertyPermission "os.name", "read";
+ permission java.util.PropertyPermission "os.arch", "read";
+ permission java.util.PropertyPermission "sun.arch.data.model", "read";
+ permission java.util.PropertyPermission
+ "sun.security.smartcardio.library", "read";
+ permission java.util.PropertyPermission
+ "sun.security.smartcardio.t0GetResponse", "read";
+ permission java.util.PropertyPermission
+ "sun.security.smartcardio.t1GetResponse", "read";
+ permission java.util.PropertyPermission
+ "sun.security.smartcardio.t1StripLe", "read";
// needed for looking up native PC/SC library
permission java.io.FilePermission "<>","read";
permission java.security.SecurityPermission "putProviderProperty.SunPCSC";
diff --git a/jdk/src/java.base/share/native/launcher/defines.h b/jdk/src/java.base/share/native/launcher/defines.h
index 3b63e038f9d..1dd0cbe5b32 100644
--- a/jdk/src/java.base/share/native/launcher/defines.h
+++ b/jdk/src/java.base/share/native/launcher/defines.h
@@ -51,16 +51,6 @@ static const char* const_progname = PROGNAME;
static char* const_progname = NULL;
#endif
static const char* const_jargs[] = JAVA_ARGS;
-/*
- * ApplicationHome is prepended to each of these entries; the resulting
- * strings are concatenated (separated by PATH_SEPARATOR) and used as the
- * value of -cp option to the launcher.
- */
-#ifndef APP_CLASSPATH
-static const char* const_appclasspath[] = { NULL };
-#else
-static const char* const_appclasspath[] = APP_CLASSPATH;
-#endif /* APP_CLASSPATH */
#else /* !JAVA_ARGS */
#define HAS_JAVA_ARGS JNI_FALSE
static const char* const_progname = "java";
diff --git a/jdk/src/java.base/share/native/launcher/main.c b/jdk/src/java.base/share/native/launcher/main.c
index 9c24c2ebf68..22298385114 100644
--- a/jdk/src/java.base/share/native/launcher/main.c
+++ b/jdk/src/java.base/share/native/launcher/main.c
@@ -83,7 +83,7 @@ char **__initenv;
int WINAPI
WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
{
- int margc, appclassc;
+ int margc;
char** margv;
const jboolean const_javaw = JNI_TRUE;
@@ -93,7 +93,7 @@ WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
int
main(int argc, char **argv)
{
- int margc, appclassc;
+ int margc;
char** margv;
const jboolean const_javaw = JNI_FALSE;
#endif /* JAVAW */
@@ -148,14 +148,9 @@ main(int argc, char **argv)
margv = args->elements;
}
#endif /* WIN32 */
- if (const_appclasspath[0] == NULL) {
- appclassc = 0;
- } else {
- appclassc = sizeof(const_appclasspath) / sizeof(char *);
- }
return JLI_Launch(margc, margv,
sizeof(const_jargs) / sizeof(char *), const_jargs,
- appclassc, const_appclasspath,
+ 0, NULL,
VERSION_STRING,
DOT_VERSION,
(const_progname != NULL) ? const_progname : *margv,
diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c
index 6dc9674a6ed..70a7bf7a6d9 100644
--- a/jdk/src/java.base/share/native/libjli/java.c
+++ b/jdk/src/java.base/share/native/libjli/java.c
@@ -1664,19 +1664,21 @@ AddApplicationOptions(int cpathc, const char **cpathv)
AddOption(apphome, NULL);
/* How big is the application's classpath? */
- size = 40; /* 40: "-Djava.class.path=" */
- for (i = 0; i < cpathc; i++) {
- size += (int)JLI_StrLen(home) + (int)JLI_StrLen(cpathv[i]) + 1; /* 1: separator */
+ if (cpathc > 0) {
+ size = 40; /* 40: "-Djava.class.path=" */
+ for (i = 0; i < cpathc; i++) {
+ size += (int)JLI_StrLen(home) + (int)JLI_StrLen(cpathv[i]) + 1; /* 1: separator */
+ }
+ appcp = (char *)JLI_MemAlloc(size + 1);
+ JLI_StrCpy(appcp, "-Djava.class.path=");
+ for (i = 0; i < cpathc; i++) {
+ JLI_StrCat(appcp, home); /* c:\program files\myapp */
+ JLI_StrCat(appcp, cpathv[i]); /* \lib\myapp.jar */
+ JLI_StrCat(appcp, separator); /* ; */
+ }
+ appcp[JLI_StrLen(appcp)-1] = '\0'; /* remove trailing path separator */
+ AddOption(appcp, NULL);
}
- appcp = (char *)JLI_MemAlloc(size + 1);
- JLI_StrCpy(appcp, "-Djava.class.path=");
- for (i = 0; i < cpathc; i++) {
- JLI_StrCat(appcp, home); /* c:\program files\myapp */
- JLI_StrCat(appcp, cpathv[i]); /* \lib\myapp.jar */
- JLI_StrCat(appcp, separator); /* ; */
- }
- appcp[JLI_StrLen(appcp)-1] = '\0'; /* remove trailing path separator */
- AddOption(appcp, NULL);
return JNI_TRUE;
}
diff --git a/jdk/src/java.base/share/native/libnet/net_util.c b/jdk/src/java.base/share/native/libnet/net_util.c
index c2d4b002b04..6e76eb639e2 100644
--- a/jdk/src/java.base/share/native/libnet/net_util.c
+++ b/jdk/src/java.base/share/native/libnet/net_util.c
@@ -23,20 +23,19 @@
* questions.
*/
-#include "jni.h"
-#include "jvm.h"
-#include "jni_util.h"
#include "net_util.h"
-int IPv6_supported() ;
-int reuseport_supported() ;
+#include "java_net_InetAddress.h"
+
+int IPv6_supported();
+int reuseport_supported();
static int IPv6_available;
static int REUSEPORT_available;
JNIEXPORT jint JNICALL ipv6_available()
{
- return IPv6_available ;
+ return IPv6_available;
}
JNIEXPORT jint JNICALL reuseport_available()
@@ -206,11 +205,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
jobject iaObj;
#ifdef AF_INET6
if (him->sa_family == AF_INET6) {
-#ifdef WIN32
- struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
-#else
struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-#endif
jbyte *caddr = (jbyte *)&(him6->sin6_addr);
if (NET_IsIPv4Mapped(caddr)) {
int address;
@@ -218,7 +213,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
CHECK_NULL_RETURN(iaObj, NULL);
address = NET_IPv4MappedToIPv4(caddr);
setInetAddress_addr(env, iaObj, address);
- setInetAddress_family(env, iaObj, IPv4);
+ setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
} else {
jint scope;
jboolean ret;
@@ -227,7 +222,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr));
if (ret == JNI_FALSE)
return NULL;
- setInetAddress_family(env, iaObj, IPv6);
+ setInetAddress_family(env, iaObj, java_net_InetAddress_IPv6);
scope = getScopeID(him);
setInet6Address_scopeid(env, iaObj, scope);
}
@@ -238,7 +233,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
struct sockaddr_in *him4 = (struct sockaddr_in *)him;
iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
CHECK_NULL_RETURN(iaObj, NULL);
- setInetAddress_family(env, iaObj, IPv4);
+ setInetAddress_family(env, iaObj, java_net_InetAddress_IPv4);
setInetAddress_addr(env, iaObj, ntohl(him4->sin_addr.s_addr));
*port = ntohs(him4->sin_port);
}
@@ -251,13 +246,10 @@ NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj)
jint family = AF_INET;
#ifdef AF_INET6
- family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6;
+ family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
+ AF_INET : AF_INET6;
if (him->sa_family == AF_INET6) {
-#ifdef WIN32
- struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
-#else
struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
-#endif
jbyte *caddrNew = (jbyte *)&(him6->sin6_addr);
if (NET_IsIPv4Mapped(caddrNew)) {
int addrNew;
diff --git a/jdk/src/java.base/share/native/libnet/net_util.h b/jdk/src/java.base/share/native/libnet/net_util.h
index 159079cd8f7..c625d60c27f 100644
--- a/jdk/src/java.base/share/native/libnet/net_util.h
+++ b/jdk/src/java.base/share/native/libnet/net_util.h
@@ -36,12 +36,6 @@
#define MAX_PACKET_LEN 65536
-#define IPv4 1
-#define IPv6 2
-
-#define NET_ERROR(env, ex, msg) \
-{ if (!(*env)->ExceptionOccurred(env)) JNU_ThrowByName(env, ex, msg); }
-
#define NET_WAIT_READ 0x01
#define NET_WAIT_WRITE 0x02
#define NET_WAIT_CONNECT 0x04
@@ -127,45 +121,43 @@ JNIEXPORT void JNICALL Java_java_net_Inet6Address_init(JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL NET_ThrowNew(JNIEnv *env, int errorNum, char *msg);
+
int NET_GetError();
void NET_ThrowCurrent(JNIEnv *env, char *msg);
jfieldID NET_GetFileDescriptorID(JNIEnv *env);
-JNIEXPORT jint JNICALL ipv6_available() ;
+JNIEXPORT jint JNICALL ipv6_available();
-JNIEXPORT jint JNICALL reuseport_available() ;
+JNIEXPORT jint JNICALL reuseport_available();
JNIEXPORT int JNICALL
-NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr *him, int *len, jboolean v4MappedAddress);
+NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port,
+ struct sockaddr *him, int *len,
+ jboolean v4MappedAddress);
JNIEXPORT jobject JNICALL
NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port);
void platformInit();
+
void parseExclusiveBindProperty(JNIEnv *env);
-void
-NET_SetTrafficClass(struct sockaddr *him, int trafficClass);
+void NET_SetTrafficClass(struct sockaddr *him, int trafficClass);
-JNIEXPORT jint JNICALL
-NET_GetPortFromSockaddr(struct sockaddr *him);
+JNIEXPORT jint JNICALL NET_GetPortFromSockaddr(struct sockaddr *him);
JNIEXPORT jint JNICALL
NET_SockaddrEqualsInetAddress(JNIEnv *env,struct sockaddr *him, jobject iaObj);
-int
-NET_IsIPv4Mapped(jbyte* caddr);
+int NET_IsIPv4Mapped(jbyte* caddr);
-int
-NET_IPv4MappedToIPv4(jbyte* caddr);
+int NET_IPv4MappedToIPv4(jbyte* caddr);
-int
-NET_IsEqual(jbyte* caddr1, jbyte* caddr2);
+int NET_IsEqual(jbyte* caddr1, jbyte* caddr2);
-int
-NET_IsZeroAddr(jbyte* caddr);
+int NET_IsZeroAddr(jbyte* caddr);
/* Socket operations
*
@@ -191,9 +183,9 @@ NET_MapSocketOptionV6(jint cmd, int *level, int *optname);
JNIEXPORT jint JNICALL
NET_EnableFastTcpLoopback(int fd);
-int getScopeID (struct sockaddr *);
+int getScopeID(struct sockaddr *);
-int cmpScopeID (unsigned int, struct sockaddr *);
+int cmpScopeID(unsigned int, struct sockaddr *);
unsigned short in_cksum(unsigned short *addr, int len);
diff --git a/jdk/src/java.base/unix/conf/s390x/jvm.cfg b/jdk/src/java.base/unix/conf/s390x/jvm.cfg
new file mode 100644
index 00000000000..2c147c9b97d
--- /dev/null
+++ b/jdk/src/java.base/unix/conf/s390x/jvm.cfg
@@ -0,0 +1,34 @@
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# 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.
+#
+# List of JVMs that can be used as an option to java, javac, etc.
+# Order is important -- first in this list is the default JVM.
+# NOTE that this both this file and its format are UNSUPPORTED and
+# WILL GO AWAY in a future release.
+#
+# You may also select a JVM in an arbitrary location with the
+# "-XXaltjvm=" option, but that too is unsupported
+# and may not be available in a future release.
+#
+-server KNOWN
+-client IGNORE
diff --git a/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c b/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c
index d8786309105..e2e0f10fad9 100644
--- a/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c
@@ -22,27 +22,17 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
+#include
#include
-#include
#include
-#include
-#include
#include
+#include
#include
#include
-#include
-#include
#include
-#include
+#include
+#include
-#ifdef _ALLBSD_SOURCE
-#include
-#include
-#endif
-
-#include "jvm.h"
-#include "jni_util.h"
#include "net_util.h"
#include "java_net_Inet4AddressImpl.h"
@@ -293,13 +283,12 @@ Java_java_net_Inet4AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
addr |= ((caddr[2] <<8) & 0xff00);
addr |= (caddr[3] & 0xff);
memset((char *) &him4, 0, sizeof(him4));
- him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+ him4.sin_addr.s_addr = htonl(addr);
him4.sin_family = AF_INET;
sa = (struct sockaddr *) &him4;
len = sizeof(him4);
- error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0,
- NI_NAMEREQD);
+ error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
if (!error) {
ret = (*env)->NewStringUTF(env, host);
@@ -443,7 +432,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
if (!skip) {
struct addrinfo *next
- = (struct addrinfo*) malloc(sizeof(struct addrinfo));
+ = (struct addrinfo *)malloc(sizeof(struct addrinfo));
if (!next) {
JNU_ThrowOutOfMemoryError(env, "Native heap allocation failed");
ret = NULL;
@@ -528,13 +517,12 @@ Java_java_net_Inet4AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
addr |= ((caddr[2] <<8) & 0xff00);
addr |= (caddr[3] & 0xff);
memset((void *) &him4, 0, sizeof(him4));
- him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+ him4.sin_addr.s_addr = htonl(addr);
him4.sin_family = AF_INET;
sa = (struct sockaddr *) &him4;
len = sizeof(him4);
- error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0,
- NI_NAMEREQD);
+ error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
if (!error) {
ret = (*env)->NewStringUTF(env, host);
diff --git a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c
index c297c3b3a64..c447129bc83 100644
--- a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c
@@ -22,29 +22,21 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
+#include
#include
+#include
+#include
#include
#include
-#include
#include
-#include
-#include
-#include
-#include
-#include
-#ifdef MACOSX
+#include
+
+#if defined(_ALLBSD_SOURCE)
#include
#include
-#include /* gethostname */
#endif
-#include "jvm.h"
-#include "jni_util.h"
#include "net_util.h"
-#ifndef IPV6_DEFS_H
-#include
-#endif
#include "java_net_Inet4AddressImpl.h"
#include "java_net_Inet6AddressImpl.h"
@@ -504,24 +496,23 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
addr |= ((caddr[2] <<8) & 0xff00);
addr |= (caddr[3] & 0xff);
memset((void *) &him4, 0, sizeof(him4));
- him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+ him4.sin_addr.s_addr = htonl(addr);
him4.sin_family = AF_INET;
- sa = (struct sockaddr *) &him4;
+ sa = (struct sockaddr *)&him4;
len = sizeof(him4);
} else {
/*
* For IPv6 address construct a sockaddr_in6 structure.
*/
(*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
- memset((void *) &him6, 0, sizeof(him6));
- memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
+ memset((void *)&him6, 0, sizeof(him6));
+ memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr));
him6.sin6_family = AF_INET6;
- sa = (struct sockaddr *) &him6 ;
- len = sizeof(him6) ;
+ sa = (struct sockaddr *)&him6;
+ len = sizeof(him6);
}
- error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0,
- NI_NAMEREQD);
+ error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
if (!error) {
ret = (*env)->NewStringUTF(env, host);
diff --git a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c
index d5b1824b314..10ac3e2c5fb 100644
--- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c
+++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c
@@ -22,55 +22,36 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
#include
+#include
#include
#include
-
-#if defined(__solaris__)
-#include
-#include
-#include
-#include
-#endif
-
-#if defined(__linux__)
+#include
+#include
#include
-#include
-#include
-#endif
#if defined(_AIX)
-#include
#include
#include
#include
#endif
-#if defined(_ALLBSD_SOURCE)
-#include
-#include
+#if defined(__solaris__)
+#include
+#include
#include
-#if defined(__APPLE__)
-#include
-#include
-#include
-#include
-#include
-#endif
#endif
-#include "jvm.h"
-#include "jni_util.h"
+#if defined(_ALLBSD_SOURCE)
+#include
+#include
+#include
+#endif
+
#include "net_util.h"
+#include "java_net_InetAddress.h"
+
#if defined(__linux__)
#define _PATH_PROCNET_IFINET6 "/proc/net/if_inet6"
#elif defined(__solaris__)
@@ -332,7 +313,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
{
netif *ifs, *curr;
#if defined(AF_INET6)
- int family = (getInetAddress_family(env, iaObj) == IPv4) ? AF_INET : AF_INET6;
+ int family = (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) ? AF_INET : AF_INET6;
#else
int family = AF_INET;
#endif
diff --git a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
index a716db9d7cb..95dd712a6eb 100644
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
@@ -22,29 +22,23 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
#include
-#include
#include
#include
-#include
-#include
+#include
-#ifdef __solaris__
-#include
-#include
-#include
+#if defined(__solaris__)
+#include
+#endif
+
+#include "net_util.h"
+
+#include "java_net_PlainDatagramSocketImpl.h"
+#include "java_net_InetAddress.h"
+#include "java_net_NetworkInterface.h"
+#include "java_net_SocketOptions.h"
-#ifndef BSD_COMP
-#define BSD_COMP
-#endif
-#endif
#ifdef __linux__
-#include
-#include
-#include
-#include
-
#define IPV6_MULTICAST_IF 17
#ifndef SO_BSDCOMPAT
#define SO_BSDCOMPAT 14
@@ -58,7 +52,11 @@
#endif
#endif // __linux__
-#include
+#ifdef __solaris__
+#ifndef BSD_COMP
+#define BSD_COMP
+#endif
+#endif
#ifndef IPTOS_TOS_MASK
#define IPTOS_TOS_MASK 0x1e
@@ -67,12 +65,6 @@
#define IPTOS_PREC_MASK 0xe0
#endif
-#include "jvm.h"
-#include "jni_util.h"
-#include "net_util.h"
-#include "java_net_SocketOptions.h"
-#include "java_net_PlainDatagramSocketImpl.h"
-#include "java_net_NetworkInterface.h"
/************************************************************************
* PlainDatagramSocketImpl
*/
@@ -151,9 +143,6 @@ static int getFD(JNIEnv *env, jobject this) {
JNIEXPORT void JNICALL
Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
-#ifdef __linux__
- struct utsname sysinfo;
-#endif
pdsi_fdID = (*env)->GetFieldID(env, cls, "fd",
"Ljava/io/FileDescriptor;");
CHECK_NULL(pdsi_fdID);
@@ -550,7 +539,8 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
iaObj = NET_SockaddrToInetAddress(env, &rmtaddr.sa, &port);
#ifdef AF_INET6
- family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6;
+ family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
+ AF_INET : AF_INET6;
#else
family = AF_INET;
#endif
@@ -1071,7 +1061,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
*/
for (i = 0; i < len; i++) {
addr = (*env)->GetObjectArrayElement(env, addrArray, i);
- if (getInetAddress_family(env, addr) == IPv4) {
+ if (getInetAddress_family(env, addr) == java_net_InetAddress_IPv4) {
in.s_addr = htonl(getInetAddress_addr(env, addr));
break;
}
@@ -1970,7 +1960,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
ipv6_join_leave = ipv6_available();
#ifdef __linux__
- if (getInetAddress_family(env, iaObj) == IPv4) {
+ if (getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4) {
ipv6_join_leave = JNI_FALSE;
}
#endif
@@ -2162,7 +2152,8 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
jbyte caddr[16];
jint family;
jint address;
- family = getInetAddress_family(env, iaObj) == IPv4? AF_INET : AF_INET6;
+ family = getInetAddress_family(env, iaObj) == java_net_InetAddress_IPv4 ?
+ AF_INET : AF_INET6;
if (family == AF_INET) { /* will convert to IPv4-mapped address */
memset((char *) caddr, 0, 16);
address = getInetAddress_addr(env, iaObj);
diff --git a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
index c605edb700d..cafed013f06 100644
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
@@ -22,32 +22,8 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
#include
-#include
-#include
-#include
-#if defined(__linux__)
-#include
-#endif
-#include /* Defines TCP_NODELAY, needed for 2.6 */
-#include
-#ifdef __linux__
-#include
-#endif
-#include
-#include
-#ifdef __solaris__
-#include
-#endif
-#ifdef __linux__
-#include
-#include
-#endif
-
-#include "jvm.h"
-#include "jni_util.h"
#include "net_util.h"
#include "java_net_SocketOptions.h"
diff --git a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
index a27902b1f83..961f53c7baf 100644
--- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
+++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
@@ -22,20 +22,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
#include
+#include
#include
-#include
-#include
-#include "jvm.h"
-#include "jni_util.h"
#include "net_util.h"
#include "java_net_SocketInputStream.h"
-/************************************************************************
+/*
* SocketInputStream
*/
diff --git a/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c b/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c
index f5a685a741c..17afe8b8d46 100644
--- a/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c
+++ b/jdk/src/java.base/unix/native/libnet/SocketOutputStream.c
@@ -22,15 +22,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
#include
+#include
#include
-#include
-#include
-#include "jni_util.h"
-#include "jvm.h"
#include "net_util.h"
#include "java_net_SocketOutputStream.h"
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.c b/jdk/src/java.base/unix/native/libnet/net_util_md.c
index 13b97dcbc9a..08ac62c8a26 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c
@@ -22,59 +22,41 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include
-#include
-#include /* Defines TCP_NODELAY, needed for 2.6 */
-#include
-#include
-#include
-#include
#include
+#include
+#include
+#include // defines TCP_NODELAY
+#include
+#include
+#include
#include
-#ifndef _ALLBSD_SOURCE
-#include
-#else
-#include
-#include
-#include
-#include
-#ifndef MAXINT
-#define MAXINT INT_MAX
-#endif
-#endif
-
-#ifdef __solaris__
-#include
-#include
-#include
-#include
-#endif
-
-#ifdef __linux__
-#include
+#if defined(__linux__)
#include
#include
#include
-
-#ifndef IPV6_FLOWINFO_SEND
-#define IPV6_FLOWINFO_SEND 33
#endif
+#if defined(__solaris__)
+#include
+#include
+#include
+#include
+#include
#endif
-#ifdef _AIX
-#include
-#endif
-
-#include "jni_util.h"
-#include "jvm.h"
#include "net_util.h"
#include "java_net_SocketOptions.h"
+#include "java_net_InetAddress.h"
+
+#if defined(__linux__) && !defined(IPV6_FLOWINFO_SEND)
+#define IPV6_FLOWINFO_SEND 33
+#endif
+
+#if defined(__solaris__) && !defined(MAXINT)
+#define MAXINT INT_MAX
+#endif
/*
* EXCLBIND socket options only on Solaris
@@ -806,13 +788,15 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
family = getInetAddress_family(env, iaObj);
#ifdef AF_INET6
/* needs work. 1. family 2. clean up him6 etc deallocate memory */
- if (ipv6_available() && !(family == IPv4 && v4MappedAddress == JNI_FALSE)) {
+ if (ipv6_available() && !(family == java_net_InetAddress_IPv4 &&
+ v4MappedAddress == JNI_FALSE)) {
struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
jbyte caddr[16];
jint address;
- if (family == IPv4) { /* will convert to IPv4-mapped address */
+ if (family == java_net_InetAddress_IPv4) {
+ // convert to IPv4-mapped address
memset((char *) caddr, 0, 16);
address = getInetAddress_addr(env, iaObj);
if (address == INADDR_ANY) {
@@ -906,7 +890,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
#else
/* handle scope_id for solaris */
- if (family != IPv4) {
+ if (family != java_net_InetAddress_IPv4) {
if (ia6_scopeidID) {
him6->sin6_scope_id = getInet6Address_scopeid(env, iaObj);
}
@@ -917,14 +901,14 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
{
struct sockaddr_in *him4 = (struct sockaddr_in*)him;
jint address;
- if (family == IPv6) {
+ if (family == java_net_InetAddress_IPv6) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Protocol family unavailable");
return -1;
}
memset((char *) him4, 0, sizeof(struct sockaddr_in));
address = getInetAddress_addr(env, iaObj);
him4->sin_port = htons((short) port);
- him4->sin_addr.s_addr = (uint32_t) htonl(address);
+ him4->sin_addr.s_addr = htonl(address);
him4->sin_family = AF_INET;
*len = sizeof(struct sockaddr_in);
}
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.h b/jdk/src/java.base/unix/native/libnet/net_util_md.h
index d7f526d8e7c..2aaa2474e4b 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h
@@ -26,13 +26,9 @@
#ifndef NET_UTILS_MD_H
#define NET_UTILS_MD_H
-#include
-#include
#include
-#include
-#include
-
#include
+#include
int NET_Timeout(int s, long timeout);
int NET_Timeout0(int s, long timeout, long currentTime);
diff --git a/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c b/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c
index 3ea2333fa08..d834ef9bf11 100644
--- a/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c
+++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainDatagramSocketImpl.c
@@ -22,10 +22,8 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-#include
-#include
-#include "jni.h"
#include "net_util.h"
+
#include "java_net_DualStackPlainDatagramSocketImpl.h"
/*
diff --git a/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c b/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c
index 0fa6d79be6a..39178408823 100644
--- a/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c
+++ b/jdk/src/java.base/windows/native/libnet/DualStackPlainSocketImpl.c
@@ -22,11 +22,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-#include
-#include
-#include "jni.h"
#include "net_util.h"
+
#include "java_net_DualStackPlainSocketImpl.h"
+#include "java_net_SocketOptions.h"
#define SET_BLOCKING 0
#define SET_NONBLOCKING 1
diff --git a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c
index 3a9e650a5f8..f7dc5c2ebe0 100644
--- a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c
+++ b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,24 +22,12 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include
-#include
-#include
#include
-#include
-#include
-#include
-#include
-#include
+
+#include "net_util.h"
#include "java_net_InetAddress.h"
#include "java_net_Inet4AddressImpl.h"
-#include "net_util.h"
-#include "icmp.h"
-
/*
* Returns true if hostname is in dotted IP address format. Note that this
diff --git a/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c
index b62a887a030..9918f38fcaf 100644
--- a/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c
+++ b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c
@@ -22,38 +22,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include
-#include
-#include
#include
-#include
-#include
-#include
-#include
+
+#include "net_util.h"
#include "java_net_InetAddress.h"
#include "java_net_Inet4AddressImpl.h"
#include "java_net_Inet6AddressImpl.h"
-#include "net_util.h"
-#include "icmp.h"
-
-#ifdef WIN32
-#ifndef _WIN64
-
-/* Retain this code a little longer to support building in
- * old environments. _MSC_VER is defined as:
- * 1200 for MSVC++ 6.0
- * 1310 for Vc7
- */
-#if defined(_MSC_VER) && _MSC_VER < 1310
-#define sockaddr_in6 SOCKADDR_IN6
-#endif
-#endif
-#define uint32_t UINT32
-#endif
/*
* Inet6AddressImpl
@@ -300,7 +275,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
addr |= ((caddr[2] <<8) & 0xff00);
addr |= (caddr[3] & 0xff);
memset((char *) &him4, 0, sizeof(him4));
- him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+ him4.sin_addr.s_addr = htonl(addr);
him4.sin_family = AF_INET;
sa = (struct sockaddr *) &him4;
len = sizeof(him4);
diff --git a/jdk/src/java.base/windows/native/libnet/NetworkInterface.c b/jdk/src/java.base/windows/native/libnet/NetworkInterface.c
index ec2fd4c0a1d..4d07b399af7 100644
--- a/jdk/src/java.base/windows/native/libnet/NetworkInterface.c
+++ b/jdk/src/java.base/windows/native/libnet/NetworkInterface.c
@@ -22,17 +22,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include /* needed for htonl */
-#include
-#include
+#include "net_util.h"
+#include "NetworkInterface.h"
#include "java_net_NetworkInterface.h"
-#include "jni_util.h"
-
-#include "NetworkInterface.h"
/*
* Windows implementation of the java.net.NetworkInterface native methods.
diff --git a/jdk/src/java.base/windows/native/libnet/NetworkInterface.h b/jdk/src/java.base/windows/native/libnet/NetworkInterface.h
index 3bf4ed06aec..9a95d77cecd 100644
--- a/jdk/src/java.base/windows/native/libnet/NetworkInterface.h
+++ b/jdk/src/java.base/windows/native/libnet/NetworkInterface.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
#ifndef NETWORK_INTERFACE_H
#define NETWORK_INTERFACE_H
-#include
#include "net_util.h"
/*
diff --git a/jdk/src/java.base/windows/native/libnet/NetworkInterface_winXP.c b/jdk/src/java.base/windows/native/libnet/NetworkInterface_winXP.c
index 0f0fbe19712..ed191648e70 100644
--- a/jdk/src/java.base/windows/native/libnet/NetworkInterface_winXP.c
+++ b/jdk/src/java.base/windows/native/libnet/NetworkInterface_winXP.c
@@ -22,19 +22,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include /* needed for htonl */
-#include
-#include
-#include
+#include "net_util.h"
+#include "NetworkInterface.h"
#include "java_net_NetworkInterface.h"
-#include "jni_util.h"
-
-#include "NetworkInterface.h"
-#include "net_util.h"
/*
* Windows implementation of the java.net.NetworkInterface native methods.
diff --git a/jdk/src/java.base/windows/native/libnet/SocketInputStream.c b/jdk/src/java.base/windows/native/libnet/SocketInputStream.c
index 3e9da6e7176..b4022fb5d60 100644
--- a/jdk/src/java.base/windows/native/libnet/SocketInputStream.c
+++ b/jdk/src/java.base/windows/native/libnet/SocketInputStream.c
@@ -22,24 +22,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include
-#include
-#include
#include
-#include
-
-#include "java_net_SocketInputStream.h"
#include "net_util.h"
-#include "jni_util.h"
+
+#include "java_net_SocketInputStream.h"
/*************************************************************************
* SocketInputStream
*/
-
static jfieldID IO_fd_fdID;
/*
diff --git a/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c b/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c
index 4bcfbc32434..9894cb0e596 100644
--- a/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c
+++ b/jdk/src/java.base/windows/native/libnet/SocketOutputStream.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,19 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include
-#include
-#include
#include
-#include
-
-#include "java_net_SocketOutputStream.h"
#include "net_util.h"
-#include "jni_util.h"
+
+#include "java_net_SocketOutputStream.h"
/************************************************************************
* SocketOutputStream
diff --git a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c
index a01c46b36fd..d382267742c 100644
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c
@@ -22,15 +22,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include
-#include
-#include
-#include
#include
-#include
+
+#include "net_util.h"
+#include "NetworkInterface.h"
+
+#include "java_net_TwoStacksPlainDatagramSocketImpl.h"
+#include "java_net_SocketOptions.h"
+#include "java_net_NetworkInterface.h"
+#include "java_net_InetAddress.h"
#ifndef IPTOS_TOS_MASK
#define IPTOS_TOS_MASK 0x1e
@@ -39,14 +39,6 @@
#define IPTOS_PREC_MASK 0xe0
#endif
-#include "java_net_TwoStacksPlainDatagramSocketImpl.h"
-#include "java_net_SocketOptions.h"
-#include "java_net_NetworkInterface.h"
-
-#include "NetworkInterface.h"
-#include "jvm.h"
-#include "jni_util.h"
-#include "net_util.h"
#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
#define IN_MULTICAST(i) IN_CLASSD(i)
@@ -439,7 +431,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
memset((char *)&lcladdr, 0, sizeof(lcladdr));
family = getInetAddress_family(env, addressObj);
- if (family == IPv6 && !ipv6_supported) {
+ if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Protocol family not supported");
return;
@@ -561,13 +553,13 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_connect0(JNIEnv *env, jobject thi
addr = getInetAddress_addr(env, address);
family = getInetAddress_family(env, address);
- if (family == IPv6 && !ipv6_supported) {
+ if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Protocol family not supported");
return;
}
- fdc = family == IPv4? fd: fd1;
+ fdc = family == java_net_InetAddress_IPv4 ? fd : fd1;
if (xp_or_later) {
/* SIO_UDP_CONNRESET fixes a bug introduced in Windows 2000, which
@@ -605,12 +597,12 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject
jint fd, len;
SOCKETADDRESS addr;
- if (family == IPv4) {
+ if (family == java_net_InetAddress_IPv4) {
fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
- len = sizeof (struct sockaddr_in);
+ len = sizeof(struct sockaddr_in);
} else {
fdObj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
- len = sizeof (struct SOCKADDR_IN6);
+ len = sizeof(struct sockaddr_in6);
}
if (IS_NULL(fdObj)) {
@@ -678,7 +670,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
}
family = getInetAddress_family(env, iaObj);
- if (family == IPv4) {
+ if (family == java_net_InetAddress_IPv4) {
fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
} else {
if (!ipv6_available()) {
@@ -906,7 +898,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
return 0;
}
setInetAddress_addr(env, addressObj, ntohl(remote_addr.sa4.sin_addr.s_addr));
- setInetAddress_family(env, addressObj, IPv4);
+ setInetAddress_family(env, addressObj, java_net_InetAddress_IPv4);
/* return port */
return ntohs(remote_addr.sa4.sin_port);
@@ -1610,7 +1602,7 @@ static int getInet4AddrFromIf (JNIEnv *env, jobject nif, struct in_addr *iaddr)
{
jobject addr;
- int ret = getInetAddrFromIf (env, IPv4, nif, &addr);
+ int ret = getInetAddrFromIf(env, java_net_InetAddress_IPv4, nif, &addr);
if (ret == -1) {
return -1;
}
@@ -2285,9 +2277,9 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress
len = sizeof(struct sockaddr_in);
/* family==-1 when socket is not connected */
- if ((family == IPv6) || (family == -1 && fd == -1)) {
+ if ((family == java_net_InetAddress_IPv6) || (family == -1 && fd == -1)) {
fd = fd1; /* must be IPv6 only */
- len = sizeof (struct SOCKADDR_IN6);
+ len = sizeof(struct sockaddr_in6);
}
if (fd == -1) {
diff --git a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c
index 51e33a5b464..f8f1063c904 100644
--- a/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c
+++ b/jdk/src/java.base/windows/native/libnet/TwoStacksPlainSocketImpl.c
@@ -22,23 +22,13 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-#include
-#include
-#include
#include
-#include
-
-#include "java_net_SocketOptions.h"
-#include "java_net_TwoStacksPlainSocketImpl.h"
-#include "java_net_InetAddress.h"
-#include "java_io_FileDescriptor.h"
-#include "java_lang_Integer.h"
#include "net_util.h"
-#include "jni_util.h"
+
+#include "java_net_TwoStacksPlainSocketImpl.h"
+#include "java_net_SocketOptions.h"
+#include "java_net_InetAddress.h"
/************************************************************************
* TwoStacksPlainSocketImpl
@@ -413,7 +403,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketBind(JNIEnv *env, jobject this,
family = getInetAddress_family(env, iaObj);
- if (family == IPv6 && !ipv6_supported) {
+ if (family == java_net_InetAddress_IPv6 && !ipv6_supported) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Protocol family not supported");
return;
@@ -655,18 +645,18 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
return;
}
if (fd2 == fd) { /* v4 */
- len = sizeof (struct sockaddr_in);
+ len = sizeof(struct sockaddr_in);
} else {
- len = sizeof (struct SOCKADDR_IN6);
+ len = sizeof(struct sockaddr_in6);
}
fd = fd2;
} else {
int ret;
if (fd1 != -1) {
fd = fd1;
- len = sizeof (struct SOCKADDR_IN6);
+ len = sizeof(struct sockaddr_in6);
} else {
- len = sizeof (struct sockaddr_in);
+ len = sizeof(struct sockaddr_in);
}
if (timeout) {
ret = NET_Timeout(fd, timeout);
@@ -728,7 +718,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
}
setInetAddress_addr(env, socketAddressObj, ntohl(him.sa4.sin_addr.s_addr));
- setInetAddress_family(env, socketAddressObj, IPv4);
+ setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv4);
(*env)->SetObjectField(env, socket, psi_addressID, socketAddressObj);
} else {
/* AF_INET6 -> Inet6Address */
@@ -754,7 +744,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
return;
}
setInet6Address_ipaddress(env, socketAddressObj, (char *)&him.sa6.sin6_addr);
- setInetAddress_family(env, socketAddressObj, IPv6);
+ setInetAddress_family(env, socketAddressObj, java_net_InetAddress_IPv6);
setInet6Address_scopeid(env, socketAddressObj, him.sa6.sin6_scope_id);
}
diff --git a/jdk/src/java.base/windows/native/libnet/icmp.h b/jdk/src/java.base/windows/native/libnet/icmp.h
deleted file mode 100644
index 50362555acb..00000000000
--- a/jdk/src/java.base/windows/native/libnet/icmp.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2003, 2013, 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.
- */
-
-#ifndef ICMP_H
-#define ICMP_H
-
-/*
- * Structure of an internet header, naked of options.
- *
- * We declare ip_len and ip_off to be short, rather than ushort_t
- * pragmatically since otherwise unsigned comparisons can result
- * against negative integers quite easily, and fail in subtle ways.
- */
-struct ip {
- unsigned char ip_hl:4, /* header length */
- ip_v:4; /* version */
- unsigned char ip_tos; /* type of service */
- short ip_len; /* total length */
- unsigned short ip_id; /* identification */
- short ip_off; /* fragment offset field */
-#define IP_DF 0x4000 /* don't fragment flag */
-#define IP_MF 0x2000 /* more fragments flag */
- unsigned char ip_ttl; /* time to live */
- unsigned char ip_p; /* protocol */
- unsigned short ip_sum; /* checksum */
- struct in_addr ip_src, ip_dst; /* source and dest address */
-};
-
-/*
- * Structure of an icmp header.
- */
-struct icmp {
- unsigned char icmp_type; /* type of message, see below */
- unsigned char icmp_code; /* type sub code */
- unsigned short icmp_cksum; /* ones complement cksum of struct */
- union {
- unsigned char ih_pptr; /* ICMP_PARAMPROB */
- struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
- struct ih_idseq {
- unsigned short icd_id;
- unsigned short icd_seq;
- } ih_idseq;
- int ih_void;
-
- /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
- struct ih_pmtu {
- unsigned short ipm_void;
- unsigned short ipm_nextmtu;
- } ih_pmtu;
-
- struct ih_rtradv {
- unsigned char irt_num_addrs;
- unsigned char irt_wpa;
- unsigned short irt_lifetime;
- } ih_rtradv;
- } icmp_hun;
-#define icmp_pptr icmp_hun.ih_pptr
-#define icmp_gwaddr icmp_hun.ih_gwaddr
-#define icmp_id icmp_hun.ih_idseq.icd_id
-#define icmp_seq icmp_hun.ih_idseq.icd_seq
-#define icmp_void icmp_hun.ih_void
-#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
-#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
- union {
- struct id_ts {
- unsigned int its_otime;
- unsigned int its_rtime;
- unsigned int its_ttime;
- } id_ts;
- struct id_ip {
- struct ip idi_ip;
- /* options and then 64 bits of data */
- } id_ip;
- unsigned int id_mask;
- char id_data[1];
- } icmp_dun;
-#define icmp_otime icmp_dun.id_ts.its_otime
-#define icmp_rtime icmp_dun.id_ts.its_rtime
-#define icmp_ttime icmp_dun.id_ts.its_ttime
-#define icmp_ip icmp_dun.id_ip.idi_ip
-#define icmp_mask icmp_dun.id_mask
-#define icmp_data icmp_dun.id_data
-};
-
-#define ICMP_ECHOREPLY 0 /* echo reply */
-#define ICMP_ECHO 8 /* echo service */
-
-/*
- * ICMPv6 structures & constants
- */
-
-typedef struct icmp6_hdr {
- u_char icmp6_type; /* type field */
- u_char icmp6_code; /* code field */
- u_short icmp6_cksum; /* checksum field */
- union {
- u_int icmp6_un_data32[1]; /* type-specific field */
- u_short icmp6_un_data16[2]; /* type-specific field */
- u_char icmp6_un_data8[4]; /* type-specific field */
- } icmp6_dataun;
-} icmp6_t;
-
-#define icmp6_data32 icmp6_dataun.icmp6_un_data32
-#define icmp6_data16 icmp6_dataun.icmp6_un_data16
-#define icmp6_data8 icmp6_dataun.icmp6_un_data8
-#define icmp6_pptr icmp6_data32[0] /* parameter prob */
-#define icmp6_mtu icmp6_data32[0] /* packet too big */
-#define icmp6_id icmp6_data16[0] /* echo request/reply */
-#define icmp6_seq icmp6_data16[1] /* echo request/reply */
-#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
-
-struct ip6_pseudo_hdr /* for calculate the ICMPv6 checksum */
-{
- struct in6_addr ip6_src;
- struct in6_addr ip6_dst;
- u_int ip6_plen;
- u_int ip6_nxt;
-};
-
-#define ICMP6_ECHO_REQUEST 128
-#define ICMP6_ECHO_REPLY 129
-#define IPPROTO_ICMPV6 58
-#define IPV6_UNICAST_HOPS 4 /* Set/get IP unicast hop limit */
-
-
-#endif
diff --git a/jdk/src/java.base/windows/native/libnet/net_util_md.c b/jdk/src/java.base/windows/native/libnet/net_util_md.c
index 0afbe08b881..e0bd5681e33 100644
--- a/jdk/src/java.base/windows/native/libnet/net_util_md.c
+++ b/jdk/src/java.base/windows/native/libnet/net_util_md.c
@@ -22,12 +22,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
-#include
-#include
-
#include "net_util.h"
-#include "jni.h"
+
+#include "java_net_InetAddress.h"
+#include "java_net_SocketOptions.h"
// Taken from mstcpip.h in Windows SDK 8.0 or newer.
#define SIO_LOOPBACK_FAST_PATH _WSAIOW(IOC_VENDOR,16)
@@ -593,7 +591,7 @@ NET_Timeout2(int fd, int fd1, long timeout, int *fdret) {
void dumpAddr (char *str, void *addr) {
- struct SOCKADDR_IN6 *a = (struct SOCKADDR_IN6 *)addr;
+ struct sockaddr_in6 *a = (struct sockaddr_in6 *)addr;
int family = a->sin6_family;
printf ("%s\n", str);
if (family == AF_INET) {
@@ -812,7 +810,7 @@ NET_BindV6(struct ipv6bind *b, jboolean exclBind) {
* 0 if error
* > 0 interface index to use
*/
-jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr)
+jint getDefaultIPv6Interface(JNIEnv *env, struct sockaddr_in6 *target_addr)
{
int ret;
DWORD b;
@@ -866,9 +864,9 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
int *len, jboolean v4MappedAddress) {
jint family, iafam;
iafam = getInetAddress_family(env, iaObj);
- family = (iafam == IPv4)? AF_INET : AF_INET6;
+ family = (iafam == java_net_InetAddress_IPv4)? AF_INET : AF_INET6;
if (ipv6_available() && !(family == AF_INET && v4MappedAddress == JNI_FALSE)) {
- struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
+ struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
jbyte caddr[16];
jint address, scopeid = 0;
jint cached_scope_id = 0;
@@ -894,7 +892,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
cached_scope_id = (jint)(*env)->GetIntField(env, iaObj, ia6_cachedscopeidID);
}
- memset((char *)him6, 0, sizeof(struct SOCKADDR_IN6));
+ memset((char *)him6, 0, sizeof(struct sockaddr_in6));
him6->sin6_port = (u_short) htons((u_short)port);
memcpy((void *)&(him6->sin6_addr), caddr, sizeof(struct in6_addr) );
him6->sin6_family = AF_INET6;
@@ -904,7 +902,7 @@ NET_InetAddressToSockaddr(JNIEnv *env, jobject iaObj, int port, struct sockaddr
(*env)->SetIntField(env, iaObj, ia6_cachedscopeidID, cached_scope_id);
}
him6->sin6_scope_id = scopeid != 0 ? scopeid : cached_scope_id;
- *len = sizeof(struct SOCKADDR_IN6) ;
+ *len = sizeof(struct sockaddr_in6) ;
} else {
struct sockaddr_in *him4 = (struct sockaddr_in *)him;
jint address;
@@ -964,12 +962,12 @@ NET_IsEqual(jbyte* caddr1, jbyte* caddr2) {
}
int getScopeID(struct sockaddr *him) {
- struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
+ struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
return him6->sin6_scope_id;
}
int cmpScopeID(unsigned int scope, struct sockaddr *him) {
- struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
+ struct sockaddr_in6 *him6 = (struct sockaddr_in6 *)him;
return him6->sin6_scope_id == scope;
}
diff --git a/jdk/src/java.base/windows/native/libnet/net_util_md.h b/jdk/src/java.base/windows/native/libnet/net_util_md.h
index af598564482..96c122b33c5 100644
--- a/jdk/src/java.base/windows/native/libnet/net_util_md.h
+++ b/jdk/src/java.base/windows/native/libnet/net_util_md.h
@@ -22,195 +22,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
-
#include
#include
-
-/* typedefs that were defined correctly for the first time
- * in Nov. 2001 SDK, which we need to include here.
- * Specifically, in6_addr and sockaddr_in6 (which is defined but
- * not correctly). When moving to a later SDK remove following
- * code between START and END
- */
-
-/* --- START --- */
-
-/* WIN64 already uses newer SDK */
-#ifdef _WIN64
-
-#define SOCKADDR_IN6 sockaddr_in6
-
-#else
-
-#ifdef _MSC_VER
-#define WS2TCPIP_INLINE __inline
-#else
-#define WS2TCPIP_INLINE extern inline /* GNU style */
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1310
-
-#define SOCKADDR_IN6 sockaddr_in6
-
-#else
-
-/*SO_REUSEPORT is not supported on Windows, define it to 0*/
-#define SO_REUSEPORT 0
-
-/* Retain this code a little longer to support building in
- * old environments. _MSC_VER is defined as:
- * 1200 for MSVC++ 6.0
- * 1310 for Vc7
- */
-
-#define IPPROTO_IPV6 41
-#define IPV6_MULTICAST_IF 9
-
-struct in6_addr {
- union {
- u_char Byte[16];
- u_short Word[8];
- } u;
-};
-
-/*
-** Defines to match RFC 2553.
-*/
-#define _S6_un u
-#define _S6_u8 Byte
-#define s6_addr _S6_un._S6_u8
-
-/*
-** Defines for our implementation.
-*/
-#define s6_bytes u.Byte
-#define s6_words u.Word
-
-/* IPv6 socket address structure, RFC 2553 */
-
-struct SOCKADDR_IN6 {
- short sin6_family; /* AF_INET6 */
- u_short sin6_port; /* Transport level port number */
- u_long sin6_flowinfo; /* IPv6 flow information */
- struct in6_addr sin6_addr; /* IPv6 address */
- u_long sin6_scope_id; /* set of interfaces for a scope */
-};
-
-
-/* Error codes from getaddrinfo() */
-
-#define EAI_AGAIN WSATRY_AGAIN
-#define EAI_BADFLAGS WSAEINVAL
-#define EAI_FAIL WSANO_RECOVERY
-#define EAI_FAMILY WSAEAFNOSUPPORT
-#define EAI_MEMORY WSA_NOT_ENOUGH_MEMORY
-//#define EAI_NODATA WSANO_DATA
-#define EAI_NONAME WSAHOST_NOT_FOUND
-#define EAI_SERVICE WSATYPE_NOT_FOUND
-#define EAI_SOCKTYPE WSAESOCKTNOSUPPORT
-
-#define EAI_NODATA EAI_NONAME
-
-/* Structure used in getaddrinfo() call */
-
-typedef struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* Length of ai_addr */
- char *ai_canonname; /* Canonical name for nodename */
- struct sockaddr *ai_addr; /* Binary address */
- struct addrinfo *ai_next; /* Next structure in linked list */
-} ADDRINFO, FAR * LPADDRINFO;
-
-/* Flags used in "hints" argument to getaddrinfo() */
-
-#define AI_PASSIVE 0x1 /* Socket address will be used in bind() call */
-#define AI_CANONNAME 0x2 /* Return canonical name in first ai_canonname */
-#define AI_NUMERICHOST 0x4 /* Nodename must be a numeric address string */
-
-/* IPv6 Multicasting definitions */
-
-/* Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP */
-
-typedef struct ipv6_mreq {
- struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast address */
- unsigned int ipv6mr_interface; /* Interface index */
-} IPV6_MREQ;
-
-#define IPV6_ADD_MEMBERSHIP 12 /* Add an IP group membership */
-#define IPV6_DROP_MEMBERSHIP 13 /* Drop an IP group membership */
-#define IPV6_MULTICAST_LOOP 11 /* Set/get IP multicast loopback */
-
-WS2TCPIP_INLINE int
-IN6_IS_ADDR_MULTICAST(const struct in6_addr *a)
-{
- return (a->s6_bytes[0] == 0xff);
-}
-
-WS2TCPIP_INLINE int
-IN6_IS_ADDR_LINKLOCAL(const struct in6_addr *a)
-{
- return (a->s6_bytes[0] == 0xfe
- && a->s6_bytes[1] == 0x80);
-}
-
-#define NI_MAXHOST 1025 /* Max size of a fully-qualified domain name */
-#define NI_MAXSERV 32 /* Max size of a service name */
-
-#define INET_ADDRSTRLEN 16 /* Max size of numeric form of IPv4 address */
-#define INET6_ADDRSTRLEN 46 /* Max size of numeric form of IPv6 address */
-
-/* Flags for getnameinfo() */
-
-#define NI_NOFQDN 0x01 /* Only return nodename portion for local hosts */
-#define NI_NUMERICHOST 0x02 /* Return numeric form of the host's address */
-#define NI_NAMEREQD 0x04 /* Error if the host's name not in DNS */
-#define NI_NUMERICSERV 0x08 /* Return numeric form of the service (port #) */
-#define NI_DGRAM 0x10 /* Service is a datagram service */
-
-
-#define IN6_IS_ADDR_V4MAPPED(a) \
- (((a)->s6_words[0] == 0) && ((a)->s6_words[1] == 0) && \
- ((a)->s6_words[2] == 0) && ((a)->s6_words[3] == 0) && \
- ((a)->s6_words[4] == 0) && ((a)->s6_words[5] == 0xffff))
-
-
-/* --- END --- */
-#endif /* end 'else older build environment' */
-
-#endif
-
-#if !INCL_WINSOCK_API_TYPEDEFS
-
-typedef
-int
-(WSAAPI * LPFN_GETADDRINFO)(
- IN const char FAR * nodename,
- IN const char FAR * servname,
- IN const struct addrinfo FAR * hints,
- OUT struct addrinfo FAR * FAR * res
- );
-
-typedef
-void
-(WSAAPI * LPFN_FREEADDRINFO)(
- IN struct addrinfo FAR * ai
- );
-
-typedef
-int
-(WSAAPI * LPFN_GETNAMEINFO)(
- IN const struct sockaddr FAR * sa,
- IN int salen,
- OUT char FAR * host,
- IN DWORD hostlen,
- OUT char FAR * serv,
- IN DWORD servlen,
- IN int flags
- );
-#endif
+#include
+#include
/* used to disable connection reset messages on Windows XP */
#ifndef SIO_UDP_CONNRESET
@@ -229,13 +44,9 @@ int
#define IPV6_V6ONLY 27 /* Treat wildcard bind as AF_INET6-only. */
#endif
-#include "java_io_FileDescriptor.h"
-#include "java_net_SocketOptions.h"
-
#define MAX_BUFFER_LEN 2048
#define MAX_HEAP_BUFFER_LEN 65536
-
/* true if SO_RCVTIMEO is supported by underlying provider */
extern jboolean isRcvTimeoutSupported;
@@ -249,7 +60,7 @@ int NET_GetDefaultTOS(void);
typedef union {
struct sockaddr sa;
struct sockaddr_in sa4;
- struct SOCKADDR_IN6 sa6;
+ struct sockaddr_in6 sa6;
} SOCKETADDRESS;
/*
@@ -264,7 +75,7 @@ struct ipv6bind {
#define SOCKETADDRESS_COPY(DST,SRC) { \
if ((SRC)->sa_family == AF_INET6) { \
- memcpy ((DST), (SRC), sizeof (struct SOCKADDR_IN6)); \
+ memcpy ((DST), (SRC), sizeof (struct sockaddr_in6)); \
} else { \
memcpy ((DST), (SRC), sizeof (struct sockaddr_in)); \
} \
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java
index e8bfd053bfc..ea3bf9d010d 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java
@@ -29,11 +29,9 @@ import sun.lwawt.LWWindowPeer;
import java.awt.*;
import java.beans.*;
-import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.concurrent.Callable;
-import sun.awt.AWTAccessor;
import javax.accessibility.*;
import javax.swing.*;
@@ -73,8 +71,20 @@ class CAccessibility implements PropertyChangeListener {
}
public void propertyChange(final PropertyChangeEvent evt) {
- if (evt.getNewValue() == null) return;
- focusChanged();
+ Object newValue = evt.getNewValue();
+ if (newValue == null) return;
+ // Don't post focus on things that don't matter, i.e. alert, colorchooser,
+ // desktoppane, dialog, directorypane, filechooser, filler, fontchoose,
+ // frame, glasspane, layeredpane, optionpane, panel, rootpane, separator,
+ // tooltip, viewport, window.
+ // List taken from initializeRoles() in JavaComponentUtilities.m.
+ if (newValue instanceof Accessible) {
+ AccessibleContext nvAC = ((Accessible) newValue).getAccessibleContext();
+ AccessibleRole nvRole = nvAC.getAccessibleRole();
+ if (!ignoredRoles.contains(roleKey(nvRole))) {
+ focusChanged();
+ }
+ }
}
private native void focusChanged();
@@ -683,9 +693,15 @@ class CAccessibility implements PropertyChangeListener {
if (context == null) continue;
if (whichChildren == JAVA_AX_VISIBLE_CHILDREN) {
- if (!context.getAccessibleComponent().isVisible()) continue;
+ AccessibleComponent acomp = context.getAccessibleComponent();
+ if (acomp == null || !acomp.isVisible()) {
+ continue;
+ }
} else if (whichChildren == JAVA_AX_SELECTED_CHILDREN) {
- if (!ac.getAccessibleSelection().isAccessibleChildSelected(i)) continue;
+ AccessibleSelection sel = ac.getAccessibleSelection();
+ if (sel == null || !sel.isAccessibleChildSelected(i)) {
+ continue;
+ }
}
if (!allowIgnored) {
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java
index d3d3dca9538..06d481111e8 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java
@@ -39,7 +39,10 @@ import javax.swing.event.ChangeListener;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_CARET_PROPERTY;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY;
+import static javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY;
import static javax.accessibility.AccessibleContext.ACCESSIBLE_TEXT_PROPERTY;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
import sun.awt.AWTAccessor;
@@ -63,6 +66,9 @@ class CAccessible extends CFRetainedResource implements Accessible {
private static native void valueChanged(long ptr);
private static native void selectedTextChanged(long ptr);
private static native void selectionChanged(long ptr);
+ private static native void menuOpened(long ptr);
+ private static native void menuClosed(long ptr);
+ private static native void menuItemSelected(long ptr);
private Accessible accessible;
@@ -111,16 +117,45 @@ class CAccessible extends CFRetainedResource implements Accessible {
public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
if ( ptr != 0 ) {
+ Object newValue = e.getNewValue();
+ Object oldValue = e.getOldValue();
if (name.compareTo(ACCESSIBLE_CARET_PROPERTY) == 0) {
selectedTextChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_TEXT_PROPERTY) == 0 ) {
valueChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_SELECTION_PROPERTY) == 0 ) {
selectionChanged(ptr);
- } else if (name.compareTo(ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY) == 0 ) {
- Object nv = e.getNewValue();
- if (nv instanceof AccessibleContext) {
- activeDescendant = (AccessibleContext)nv;
+ } else if (name.compareTo(ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY) == 0 ) {
+ if (newValue instanceof AccessibleContext) {
+ activeDescendant = (AccessibleContext)newValue;
+ }
+ } else if (name.compareTo(ACCESSIBLE_STATE_PROPERTY) == 0) {
+ AccessibleContext thisAC = accessible.getAccessibleContext();
+ AccessibleRole thisRole = thisAC.getAccessibleRole();
+ Accessible parentAccessible = thisAC.getAccessibleParent();
+ AccessibleRole parentRole = null;
+ if (parentAccessible != null) {
+ parentRole = parentAccessible.getAccessibleContext().getAccessibleRole();
+ }
+ // At least for now don't handle combo box menu state changes.
+ // This may change when later fixing issues which currently
+ // exist for combo boxes, but for now the following is only
+ // for JPopupMenus, not for combobox menus.
+ if (parentRole != AccessibleRole.COMBO_BOX) {
+ if (thisRole == AccessibleRole.POPUP_MENU) {
+ if ( newValue != null &&
+ ((AccessibleState)newValue) == AccessibleState.VISIBLE ) {
+ menuOpened(ptr);
+ } else if ( oldValue != null &&
+ ((AccessibleState)oldValue) == AccessibleState.VISIBLE ) {
+ menuClosed(ptr);
+ }
+ } else if (thisRole == AccessibleRole.MENU_ITEM) {
+ if ( newValue != null &&
+ ((AccessibleState)newValue) == AccessibleState.FOCUSED ) {
+ menuItemSelected(ptr);
+ }
+ }
}
}
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
index 0fbdf00246c..c0280fe4caf 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
@@ -97,7 +97,7 @@ public class CEmbeddedFrame extends EmbeddedFrame {
int absY = locationOnScreen.y + y;
responder.handleScrollEvent(x, y, absX, absY, modifierFlags, deltaX,
- deltaY);
+ deltaY, NSEvent.SCROLL_PHASE_UNSUPPORTED);
}
public void handleKeyEvent(int eventType, int modifierFlags, String characters,
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
index 0283b05e5d8..de99473a176 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
@@ -44,6 +44,8 @@ final class CPlatformResponder {
private final PlatformEventNotifier eventNotifier;
private final boolean isNpapiCallback;
private int lastKeyPressCode = KeyEvent.VK_UNDEFINED;
+ private final DeltaAccumulator deltaAccumulatorX = new DeltaAccumulator();
+ private final DeltaAccumulator deltaAccumulatorY = new DeltaAccumulator();
CPlatformResponder(final PlatformEventNotifier eventNotifier,
final boolean isNpapiCallback) {
@@ -89,37 +91,37 @@ final class CPlatformResponder {
*/
void handleScrollEvent(final int x, final int y, final int absX,
final int absY, final int modifierFlags,
- final double deltaX, final double deltaY) {
+ final double deltaX, final double deltaY,
+ final int scrollPhase) {
int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
final boolean isShift = (jmodifiers & InputEvent.SHIFT_DOWN_MASK) != 0;
+ int roundDeltaX = deltaAccumulatorX.getRoundedDelta(deltaX, scrollPhase);
+ int roundDeltaY = deltaAccumulatorY.getRoundedDelta(deltaY, scrollPhase);
+
// Vertical scroll.
- if (!isShift && deltaY != 0.0) {
- dispatchScrollEvent(x, y, absX, absY, jmodifiers, deltaY);
+ if (!isShift && (deltaY != 0.0 || roundDeltaY != 0)) {
+ dispatchScrollEvent(x, y, absX, absY, jmodifiers, roundDeltaY, deltaY);
}
// Horizontal scroll or shirt+vertical scroll.
final double delta = isShift && deltaY != 0.0 ? deltaY : deltaX;
- if (delta != 0.0) {
+ final int roundDelta = isShift && roundDeltaY != 0 ? roundDeltaY : roundDeltaX;
+ if (delta != 0.0 || roundDelta != 0) {
jmodifiers |= InputEvent.SHIFT_DOWN_MASK;
- dispatchScrollEvent(x, y, absX, absY, jmodifiers, delta);
+ dispatchScrollEvent(x, y, absX, absY, jmodifiers, roundDelta, delta);
}
}
private void dispatchScrollEvent(final int x, final int y, final int absX,
final int absY, final int modifiers,
- final double delta) {
+ final int roundDelta, final double delta) {
final long when = System.currentTimeMillis();
final int scrollType = MouseWheelEvent.WHEEL_UNIT_SCROLL;
final int scrollAmount = 1;
- int wheelRotation = (int) delta;
- int signum = (int) Math.signum(delta);
- if (signum * delta < 1) {
- wheelRotation = signum;
- }
// invert the wheelRotation for the peer
eventNotifier.notifyMouseWheelEvent(when, x, y, absX, absY, modifiers,
scrollType, scrollAmount,
- -wheelRotation, -delta, null);
+ -roundDelta, -delta, null);
}
/**
@@ -260,4 +262,46 @@ final class CPlatformResponder {
void handleWindowFocusEvent(boolean gained, LWWindowPeer opposite) {
eventNotifier.notifyActivation(gained, opposite);
}
+
+ static class DeltaAccumulator {
+
+ static final double MIN_THRESHOLD = 0.1;
+ static final double MAX_THRESHOLD = 0.5;
+ double accumulatedDelta;
+
+ int getRoundedDelta(double delta, int scrollPhase) {
+
+ int roundDelta = (int) Math.round(delta);
+
+ if (scrollPhase == NSEvent.SCROLL_PHASE_UNSUPPORTED) { // mouse wheel
+ if (roundDelta == 0 && delta != 0) {
+ roundDelta = delta > 0 ? 1 : -1;
+ }
+ } else { // trackpad
+ boolean begin = scrollPhase == NSEvent.SCROLL_PHASE_BEGAN;
+ boolean end = scrollPhase == NSEvent.SCROLL_MASK_PHASE_ENDED
+ || scrollPhase == NSEvent.SCROLL_MASK_PHASE_CANCELLED;
+
+ if (begin) {
+ accumulatedDelta = 0;
+ }
+
+ accumulatedDelta += delta;
+
+ double absAccumulatedDelta = Math.abs(accumulatedDelta);
+ if (absAccumulatedDelta > MAX_THRESHOLD) {
+ roundDelta = (int) Math.round(accumulatedDelta);
+ accumulatedDelta -= roundDelta;
+ }
+
+ if (end) {
+ if (roundDelta == 0 && absAccumulatedDelta > MIN_THRESHOLD) {
+ roundDelta = accumulatedDelta > 0 ? 1 : -1;
+ }
+ }
+ }
+
+ return roundDelta;
+ }
+ }
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java
index ee88f8f75ce..5dcf376646a 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java
@@ -194,7 +194,8 @@ public class CPlatformView extends CFRetainedResource {
if (event.getType() == CocoaConstants.NSScrollWheel) {
responder.handleScrollEvent(x, y, absX, absY, event.getModifierFlags(),
- event.getScrollDeltaX(), event.getScrollDeltaY());
+ event.getScrollDeltaX(), event.getScrollDeltaY(),
+ event.getScrollPhase());
} else {
responder.handleMouseEvent(event.getType(), event.getModifierFlags(), event.getButtonNumber(),
event.getClickCount(), x, y,
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java
index d39f559be22..5710988643d 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/NSEvent.java
@@ -32,6 +32,13 @@ import java.awt.event.*;
* JDK functionality.
*/
final class NSEvent {
+
+ static final int SCROLL_PHASE_UNSUPPORTED = 1;
+ static final int SCROLL_PHASE_BEGAN = 2;
+ static final int SCROLL_PHASE_CONTINUED = 3;
+ static final int SCROLL_MASK_PHASE_CANCELLED = 4;
+ static final int SCROLL_MASK_PHASE_ENDED = 5;
+
private int type;
private int modifierFlags;
@@ -42,6 +49,7 @@ final class NSEvent {
private int y;
private double scrollDeltaY;
private double scrollDeltaX;
+ private int scrollPhase;
private int absX;
private int absY;
@@ -62,7 +70,7 @@ final class NSEvent {
// Called from native
NSEvent(int type, int modifierFlags, int clickCount, int buttonNumber,
int x, int y, int absX, int absY,
- double scrollDeltaY, double scrollDeltaX) {
+ double scrollDeltaY, double scrollDeltaX, int scrollPhase) {
this.type = type;
this.modifierFlags = modifierFlags;
this.clickCount = clickCount;
@@ -73,6 +81,7 @@ final class NSEvent {
this.absY = absY;
this.scrollDeltaY = scrollDeltaY;
this.scrollDeltaX = scrollDeltaX;
+ this.scrollPhase = scrollPhase;
}
int getType() {
@@ -107,6 +116,10 @@ final class NSEvent {
return scrollDeltaX;
}
+ int getScrollPhase() {
+ return scrollPhase;
+ }
+
int getAbsX() {
return absX;
}
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
index dfe3906bf90..208d22d69ff 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
@@ -383,7 +383,7 @@ static BOOL shouldUsePressAndHold() {
}
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
- static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V");
+ static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
[event type],
[event modifierFlags],
@@ -392,7 +392,8 @@ static BOOL shouldUsePressAndHold() {
(jint)localPoint.x, (jint)localPoint.y,
(jint)absP.x, (jint)absP.y,
[event deltaY],
- [event deltaX]);
+ [event deltaX],
+ [AWTToolkit scrollStateWithEvent: event]);
CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
index 211be30d895..8b76294c32d 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m
@@ -317,7 +317,7 @@ AWT_ASSERT_APPKIT_THREAD;
[self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
if (IS(self.styleBits, IS_POPUP)) {
- [self.nsWindow setCollectionBehavior:(1 << 8) /*NSWindowCollectionBehaviorFullScreenAuxiliary*/];
+ [self.nsWindow setCollectionBehavior:(1 << 8) /*NSWindowCollectionBehaviorFullScreenAuxiliary*/];
}
return self;
@@ -330,7 +330,7 @@ AWT_ASSERT_APPKIT_THREAD;
// returns id for the topmost window under mouse
+ (NSInteger) getTopmostWindowUnderMouseID {
NSInteger result = -1;
-
+
NSRect screenRect = [[NSScreen mainScreen] frame];
NSPoint nsMouseLocation = [NSEvent mouseLocation];
CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
@@ -433,18 +433,18 @@ AWT_ASSERT_APPKIT_THREAD;
// Tests wheather the corresponding Java paltform window is visible or not
+ (BOOL) isJavaPlatformWindowVisible:(NSWindow *)window {
BOOL isVisible = NO;
-
+
if ([AWTWindow isAWTWindow:window] && [window delegate] != nil) {
AWTWindow *awtWindow = (AWTWindow *)[window delegate];
[AWTToolkit eventCountPlusPlus];
-
+
JNIEnv *env = [ThreadUtilities getJNIEnv];
jobject platformWindow = [awtWindow.javaPlatformWindow jObjectWithEnv:env];
if (platformWindow != NULL) {
static JNF_MEMBER_CACHE(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z");
isVisible = JNFCallBooleanMethod(env, platformWindow, jm_isVisible) == JNI_TRUE ? YES : NO;
(*env)->DeleteLocalRef(env, platformWindow);
-
+
}
}
return isVisible;
@@ -577,7 +577,9 @@ AWT_ASSERT_APPKIT_THREAD;
- (NSRect)windowWillUseStandardFrame:(NSWindow *)window
defaultFrame:(NSRect)newFrame {
- return [self standardFrame];
+ return NSEqualSizes(NSZeroSize, [self standardFrame].size)
+ ? newFrame
+ : [self standardFrame];
}
// Hides/shows window's childs during iconify/de-iconify operation
@@ -1085,17 +1087,17 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowSt
jdouble width, jdouble height)
{
JNF_COCOA_ENTER(env);
-
+
NSRect jrect = NSMakeRect(originX, originY, width, height);
-
+
NSWindow *nsWindow = OBJC(windowPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
-
+
NSRect rect = ConvertNSScreenRect(NULL, jrect);
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
window.standardFrame = rect;
}];
-
+
JNF_COCOA_EXIT(env);
}
@@ -1366,7 +1368,7 @@ JNF_COCOA_ENTER(env);
} else {
[JNFException raise:env as:kIllegalArgumentException reason:"unknown event type"];
}
-
+
JNF_COCOA_EXIT(env);
}
@@ -1476,7 +1478,7 @@ JNF_COCOA_ENTER(env);
if (CGDisplayRelease(aID) == kCGErrorSuccess) {
NSUInteger styleMask = [AWTWindow styleMaskForStyleBits:window.styleBits];
- [nsWindow setStyleMask:styleMask];
+ [nsWindow setStyleMask:styleMask];
[nsWindow setLevel: window.preFullScreenLevel];
// GraphicsDevice takes care of restoring pre full screen bounds
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobotKeyCode.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobotKeyCode.m
index e75648d18b8..799887f187e 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobotKeyCode.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CRobotKeyCode.m
@@ -45,7 +45,7 @@
self = [super init];
if (nil != self) {
- javaToMacKeyMap = [NSDictionary dictionaryWithObjectsAndKeys :
+ self.javaToMacKeyMap = [NSDictionary dictionaryWithObjectsAndKeys :
[NSNumber numberWithInt : OSX_Delete], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_BACK_SPACE],
[NSNumber numberWithInt : OSX_kVK_Tab], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_TAB],
[NSNumber numberWithInt : OSX_kVK_Return], [NSNumber numberWithInt : java_awt_event_KeyEvent_VK_ENTER],
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m
index 36d13667f55..0cc9e84eb0d 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m
@@ -139,9 +139,9 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
jint clickCount;
clickCount = [event clickCount];
-
+
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
- static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDD)V");
+ static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
[event type],
[event modifierFlags],
@@ -150,7 +150,8 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
(jint)localPoint.x, (jint)localPoint.y,
(jint)absP.x, (jint)absP.y,
[event deltaY],
- [event deltaX]);
+ [event deltaX],
+ [AWTToolkit scrollStateWithEvent: event]);
CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon");
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
index ad2fce0e55b..5a91adf70b5 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
@@ -66,7 +66,6 @@ static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible");
static JNF_MEMBER_CACHE(jf_ptr, sjc_CAccessible, "ptr", "J");
static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessible", "(Ljavax/accessibility/Accessible;)Lsun/lwawt/macosx/CAccessible;");
-
static jobject sAccessibilityClass = NULL;
// sAttributeNamesForRoleCache holds the names of the attributes to which each java
@@ -213,6 +212,24 @@ static NSObject *sAttributeNamesLOCK = nil;
NSAccessibilityPostNotification(self, NSAccessibilitySelectedChildrenChangedNotification);
}
+- (void)postMenuOpened
+{
+ AWT_ASSERT_APPKIT_THREAD;
+ NSAccessibilityPostNotification(self, (NSString *)kAXMenuOpenedNotification);
+}
+
+- (void)postMenuClosed
+{
+ AWT_ASSERT_APPKIT_THREAD;
+ NSAccessibilityPostNotification(self, (NSString *)kAXMenuClosedNotification);
+}
+
+- (void)postMenuItemSelected
+{
+ AWT_ASSERT_APPKIT_THREAD;
+ NSAccessibilityPostNotification(self, (NSString *)kAXMenuItemSelectedNotification);
+}
+
- (BOOL)isEqual:(id)anObject
{
if (![anObject isKindOfClass:[self class]]) return NO;
@@ -278,8 +295,7 @@ static NSObject *sAttributeNamesLOCK = nil;
+ (jobject) getCAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env {
if (JNFIsInstanceOf(env, jaccessible, &sjc_CAccessible)) {
return jaccessible;
- }
- else if (JNFIsInstanceOf(env, jaccessible, &sjc_Accessible)) {
+ } else if (JNFIsInstanceOf(env, jaccessible, &sjc_Accessible)) {
return JNFCallStaticObjectMethod(env, sjm_getCAccessible, jaccessible);
}
return NULL;
@@ -368,6 +384,14 @@ static NSObject *sAttributeNamesLOCK = nil;
// must init freshly -alloc'd object
[newChild initWithParent:parent withEnv:env withAccessible:jCAX withIndex:index withView:view withJavaRole:javaRole]; // must init new instance
+ // If creating a JPopupMenu (not a combobox popup list) need to fire menuOpened.
+ // This is the only way to know if the menu is opening; visible state change
+ // can't be caught because the listeners are not set up in time.
+ if ( [javaRole isEqualToString:@"popupmenu"] &&
+ ![[parent javaRole] isEqualToString:@"combobox"] ) {
+ [newChild postMenuOpened];
+ }
+
// must hard retain pointer poked into Java object
[newChild retain];
JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild));
@@ -634,6 +658,15 @@ static NSObject *sAttributeNamesLOCK = nil;
return moreNames;
}
}
+ // popupmenu's return values not selected children
+ if ( [javaRole isEqualToString:@"popupmenu"] &&
+ ![[[self parent] javaRole] isEqualToString:@"combobox"] ) {
+ NSMutableArray *moreNames =
+ [[NSMutableArray alloc] initWithCapacity: [names count] + 1];
+ [moreNames addObjectsFromArray: names];
+ [moreNames addObject:NSAccessibilityValueAttribute];
+ return moreNames;
+ }
return names;
} // end @synchronized
@@ -707,6 +740,7 @@ static NSObject *sAttributeNamesLOCK = nil;
return value;
}
+
- (BOOL)accessibilityIsChildrenAttributeSettable
{
return NO;
@@ -939,6 +973,13 @@ static NSObject *sAttributeNamesLOCK = nil;
if (fNSRole == nil) {
NSString *javaRole = [self javaRole];
fNSRole = [sRoles objectForKey:javaRole];
+ // The sRoles NSMutableDictionary maps popupmenu to Mac's popup button.
+ // JComboBox behavior currently relies on this. However this is not the
+ // proper mapping for a JPopupMenu so fix that.
+ if ( [javaRole isEqualToString:@"popupmenu"] &&
+ ![[[self parent] javaRole] isEqualToString:@"combobox"] ) {
+ fNSRole = NSAccessibilityMenuRole;
+ }
if (fNSRole == nil) {
// this component has assigned itself a custom AccessibleRole not in the sRoles array
fNSRole = javaRole;
@@ -947,6 +988,7 @@ static NSObject *sAttributeNamesLOCK = nil;
}
return fNSRole;
}
+
- (BOOL)accessibilityIsRoleAttributeSettable
{
return NO;
@@ -1046,8 +1088,7 @@ static NSObject *sAttributeNamesLOCK = nil;
- (NSString *)accessibilitySubroleAttribute
{
NSString *value = nil;
- if ([[self javaRole] isEqualToString:@"passwordtext"])
- {
+ if ([[self javaRole] isEqualToString:@"passwordtext"]) {
value = NSAccessibilitySecureTextFieldSubrole;
}
/*
@@ -1123,6 +1164,45 @@ static NSObject *sAttributeNamesLOCK = nil;
JNIEnv* env = [ThreadUtilities getJNIEnv];
+ // Need to handle popupmenus differently.
+ //
+ // At least for now don't handle combo box menus.
+ // This may change when later fixing issues which currently
+ // exist for combo boxes, but for now the following is only
+ // for JPopupMenus, not for combobox menus.
+ id parent = [self parent];
+ if ( [[self javaRole] isEqualToString:@"popupmenu"] &&
+ ![[parent javaRole] isEqualToString:@"combobox"] ) {
+ NSArray *children =
+ [JavaComponentAccessibility childrenOfParent:self
+ withEnv:env
+ withChildrenCode:JAVA_AX_ALL_CHILDREN
+ allowIgnored:YES];
+ if ([children count] > 0) {
+ // handle case of AXMenuItem
+ // need to ask menu what is selected
+ NSArray *selectedChildrenOfMenu =
+ [self accessibilitySelectedChildrenAttribute];
+ JavaComponentAccessibility *selectedMenuItem =
+ [selectedChildrenOfMenu objectAtIndex:0];
+ if (selectedMenuItem != nil) {
+ jobject itemValue =
+ JNFCallStaticObjectMethod( env,
+ sjm_getAccessibleName,
+ selectedMenuItem->fAccessible,
+ selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop)
+ if (itemValue == NULL) {
+ return nil;
+ }
+ NSString* itemString = JNFJavaToNSString(env, itemValue);
+ (*env)->DeleteLocalRef(env, itemValue);
+ return itemString;
+ } else {
+ return nil;
+ }
+ }
+ }
+
// ask Java for the component's accessibleValue. In java, the "accessibleValue" just means a numerical value
// a text value is taken care of in JavaTextAccessibility
@@ -1343,6 +1423,54 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env);
}
+/*
+ * Class: sun_lwawt_macosx_CAccessible
+ * Method: menuOpened
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuOpened
+(JNIEnv *env, jclass jklass, jlong element)
+{
+JNF_COCOA_ENTER(env);
+ [ThreadUtilities performOnMainThread:@selector(postMenuOpened)
+ on:(JavaComponentAccessibility *)jlong_to_ptr(element)
+ withObject:nil
+ waitUntilDone:NO];
+JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class: sun_lwawt_macosx_CAccessible
+ * Method: menuClosed
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuClosed
+(JNIEnv *env, jclass jklass, jlong element)
+{
+JNF_COCOA_ENTER(env);
+ [ThreadUtilities performOnMainThread:@selector(postMenuClosed)
+ on:(JavaComponentAccessibility *)jlong_to_ptr(element)
+ withObject:nil
+ waitUntilDone:NO];
+JNF_COCOA_EXIT(env);
+}
+
+/*
+ * Class: sun_lwawt_macosx_CAccessible
+ * Method: menuItemSelected
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuItemSelected
+(JNIEnv *env, jclass jklass, jlong element)
+{
+JNF_COCOA_ENTER(env);
+ [ThreadUtilities performOnMainThread:@selector(postMenuItemSelected)
+ on:(JavaComponentAccessibility *)jlong_to_ptr(element)
+ withObject:nil
+ waitUntilDone:NO];
+JNF_COCOA_EXIT(env);
+}
+
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: unregisterFromCocoaAXSystem
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.h b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.h
index 7c07c9d9689..c581cb45be1 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.h
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.h
@@ -41,6 +41,7 @@ extern jint* gButtonDownMasks;
@interface AWTToolkit : NSObject { }
+ (long) getEventCount;
+ (void) eventCountPlusPlus;
++ (jint) scrollStateWithEvent: (NSEvent*) event;
@end
/*
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m
index 54253484173..41e966894ce 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m
@@ -43,6 +43,13 @@
#import
+// SCROLL PHASE STATE
+#define SCROLL_PHASE_UNSUPPORTED 1
+#define SCROLL_PHASE_BEGAN 2
+#define SCROLL_PHASE_CONTINUED 3
+#define SCROLL_PHASE_CANCELLED 4
+#define SCROLL_PHASE_ENDED 5
+
int gNumberOfButtons;
jint* gButtonDownMasks;
@@ -72,6 +79,23 @@ static long eventCount;
eventCount++;
}
++ (jint) scrollStateWithEvent: (NSEvent*) event {
+
+ if ([event type] != NSScrollWheel) {
+ return 0;
+ }
+
+ NSEventPhase phase = [event phase];
+ NSEventPhase momentumPhase = [event momentumPhase];
+
+ if (!phase && !momentumPhase) return SCROLL_PHASE_UNSUPPORTED;
+ switch (phase) {
+ case NSEventPhaseBegan: return SCROLL_PHASE_BEGAN;
+ case NSEventPhaseCancelled: return SCROLL_PHASE_CANCELLED;
+ case NSEventPhaseEnded: return SCROLL_PHASE_ENDED;
+ default: return SCROLL_PHASE_CONTINUED;
+ }
+}
@end
diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m
index 548fd5015d6..d374e5a1241 100644
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/font/AWTFont.m
@@ -193,6 +193,44 @@ GetFamilyNameForFontName(NSString* fontname)
return [sFontFamilyTable objectForKey:fontname];
}
+static void addFont(CTFontUIFontType uiType,
+ NSMutableArray *allFonts,
+ NSMutableDictionary* fontFamilyTable) {
+
+ CTFontRef font = CTFontCreateUIFontForLanguage(uiType, 0.0, NULL);
+ if (font == NULL) {
+ return;
+ }
+ CTFontDescriptorRef desc = CTFontCopyFontDescriptor(font);
+ if (desc == NULL) {
+ CFRelease(font);
+ return;
+ }
+ CFStringRef family = CTFontDescriptorCopyAttribute(desc, kCTFontFamilyNameAttribute);
+ if (family == NULL) {
+ CFRelease(desc);
+ CFRelease(font);
+ return;
+ }
+ CFStringRef name = CTFontDescriptorCopyAttribute(desc, kCTFontNameAttribute);
+ if (name == NULL) {
+ CFRelease(family);
+ CFRelease(desc);
+ CFRelease(font);
+ return;
+ }
+ [allFonts addObject:name];
+ [fontFamilyTable setObject:family forKey:name];
+#ifdef DEBUG
+ NSLog(@"name is : %@", (NSString*)name);
+ NSLog(@"family is : %@", (NSString*)family);
+#endif
+ CFRelease(family);
+ CFRelease(name);
+ CFRelease(desc);
+ CFRelease(font);
+}
+
static NSArray*
GetFilteredFonts()
{
@@ -227,6 +265,16 @@ GetFilteredFonts()
}
}
+ /*
+ * JavaFX registers these fonts and so JDK needs to do so as well.
+ * If this isn't done we will have mis-matched rendering, since
+ * although these may include fonts that are enumerated normally
+ * they also demonstrably includes fonts that are not.
+ */
+ addFont(kCTFontUIFontSystem, allFonts, fontFamilyTable);
+ addFont(kCTFontUIFontEmphasizedSystem, allFonts, fontFamilyTable);
+ addFont(kCTFontUIFontUserFixedPitch, allFonts, fontFamilyTable);
+
sFilteredFonts = allFonts;
sFontFamilyTable = fontFamilyTable;
}
diff --git a/jdk/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m b/jdk/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m
index 82619b70244..1eda7334665 100644
--- a/jdk/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m
+++ b/jdk/src/java.desktop/macosx/native/libsplashscreen/splashscreen_sys.m
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,10 @@
#include
#import "ThreadUtilities.h"
+NSString* findScaledImageName(NSString *fileName,
+ NSUInteger dotIndex,
+ NSString *strToAppend);
+
static NSScreen* SplashNSScreen()
{
return [[NSScreen screens] objectAtIndex: 0];
@@ -134,8 +138,8 @@ BOOL isSWTRunning() {
}
jboolean SplashGetScaledImageName(const char* jar, const char* file,
- float *scaleFactor, char *scaledFile,
- const size_t scaledImageLength) {
+ float *scaleFactor, char *scaledFile,
+ const size_t scaledImageLength) {
*scaleFactor = 1;
if(isSWTRunning()){
@@ -158,18 +162,14 @@ jboolean SplashGetScaledImageName(const char* jar, const char* file,
options:NSBackwardsSearch];
NSUInteger dotIndex = range.location;
NSString *fileName2x = nil;
-
- if (dotIndex == NSNotFound) {
- fileName2x = [fileName stringByAppendingString: @"@2x"];
- } else {
- fileName2x = [fileName substringToIndex: dotIndex];
- fileName2x = [fileName2x stringByAppendingString: @"@2x"];
- fileName2x = [fileName2x stringByAppendingString:
- [fileName substringFromIndex: dotIndex]];
+
+ fileName2x = findScaledImageName(fileName, dotIndex, @"@2x");
+ if(![[NSFileManager defaultManager]
+ fileExistsAtPath: fileName2x]) {
+ fileName2x = findScaledImageName(fileName, dotIndex, @"@200pct");
}
-
- if ((fileName2x != nil) && (jar || [[NSFileManager defaultManager]
- fileExistsAtPath: fileName2x])){
+ if (jar || [[NSFileManager defaultManager]
+ fileExistsAtPath: fileName2x]){
if (strlen([fileName2x UTF8String]) > scaledImageLength) {
[pool drain];
return JNI_FALSE;
@@ -458,3 +458,16 @@ SplashReconfigure(Splash * splash) {
sendctl(splash, SPLASHCTL_RECONFIGURE);
}
+NSString* findScaledImageName(NSString *fileName, NSUInteger dotIndex, NSString *strToAppend) {
+ NSString *fileName2x = nil;
+ if (dotIndex == NSNotFound) {
+ fileName2x = [fileName stringByAppendingString: strToAppend];
+ } else {
+ fileName2x = [fileName substringToIndex: dotIndex];
+ fileName2x = [fileName2x stringByAppendingString: strToAppend];
+ fileName2x = [fileName2x stringByAppendingString:
+ [fileName substringFromIndex: dotIndex]];
+ }
+ return fileName2x;
+}
+
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
index 61b00538596..067b275ab25 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java
@@ -1314,7 +1314,7 @@ class GIFImageWriteParam extends ImageWriteParam {
super(locale);
this.canWriteCompressed = true;
this.canWriteProgressive = true;
- this.compressionTypes = new String[] {"LZW", "lzw"};
+ this.compressionTypes = new String[] {"LZW"};
this.compressionType = compressionTypes[0];
}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifComboBoxUI.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifComboBoxUI.java
index 7e5c4701e11..82bfd92f92c 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifComboBoxUI.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifComboBoxUI.java
@@ -298,31 +298,24 @@ public class MotifComboBoxUI extends BasicComboBoxUI implements Serializable {
public void paintIcon(Component c, Graphics g, int xo, int yo) {
int w = getIconWidth();
int h = getIconHeight();
+ int x1 = xo + w - 1;
+ int y1 = yo;
+ int x2 = xo + w / 2;
+ int y2 = yo + h - 1;
+ g.setColor(fill);
+ g.fillPolygon(new int[]{xo, x1, x2}, new int[]{yo, y1, y2}, 3);
g.setColor(lightShadow);
- g.drawLine(xo, yo, xo+w-1, yo);
- g.drawLine(xo, yo+1, xo+w-3, yo+1);
- g.setColor(darkShadow);
- g.drawLine(xo+w-2, yo+1, xo+w-1, yo+1);
-
- for ( int x = xo+1, y = yo+2, dx = w-6; y+1 < yo+h; y += 2 ) {
- g.setColor(lightShadow);
- g.drawLine(x, y, x+1, y);
- g.drawLine(x, y+1, x+1, y+1);
- if ( dx > 0 ) {
- g.setColor(fill);
- g.drawLine(x+2, y, x+1+dx, y);
- g.drawLine(x+2, y+1, x+1+dx, y+1);
- }
- g.setColor(darkShadow);
- g.drawLine(x+dx+2, y, x+dx+3, y);
- g.drawLine(x+dx+2, y+1, x+dx+3, y+1);
- x += 1;
- dx -= 2;
- }
+ g.drawLine(xo, yo, x1, y1);
+ g.drawLine(xo, yo + 1, x2, y2);
+ g.drawLine(xo, yo + 1, x1, y1 + 1);
+ g.drawLine(xo + 1, yo + 1, x2, y2 - 1);
g.setColor(darkShadow);
- g.drawLine(xo+(w/2), yo+h-1, xo+(w/2), yo+h-1);
+ g.drawLine(x1, y1 + 1, x2, y2);
+ g.drawLine(x1 - 1, y1 + 1, x2, y2 - 1);
+ g.drawLine(x1 - 1, y1 + 1, x1, y1 + 1); // corner
+ g.drawLine(x2, y2, x2, y2); // corner
}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifIconFactory.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifIconFactory.java
index 4c8e33fcf87..99efe02a03d 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifIconFactory.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifIconFactory.java
@@ -249,17 +249,11 @@ public class MotifIconFactory implements Serializable
if (check) {
// draw check
g.setColor(foreground);
- g.drawLine(csize-2,1,csize-2,2);
- g.drawLine(csize-3,2,csize-3,3);
- g.drawLine(csize-4,3,csize-4,4);
- g.drawLine(csize-5,4,csize-5,6);
- g.drawLine(csize-6,5,csize-6,8);
- g.drawLine(csize-7,6,csize-7,10);
- g.drawLine(csize-8,7,csize-8,10);
- g.drawLine(csize-9,6,csize-9,9);
- g.drawLine(csize-10,5,csize-10,8);
- g.drawLine(csize-11,5,csize-11,7);
- g.drawLine(csize-12,6,csize-12,6);
+ int[] xa = {csize - 12, csize - 8, csize - 7, csize - 4,
+ csize - 2, csize - 2, csize - 8, csize - 10,
+ csize - 11};
+ int[] ya = new int[]{6, 10, 10, 4, 2, 1, 7, 5, 5};
+ g.fillPolygon(xa, ya, 9);
}
g.translate(-x, -y);
g.setColor(oldColor);
@@ -301,50 +295,18 @@ public class MotifIconFactory implements Serializable
if (checkIn){
g.setColor(shadow);
- g.drawLine(x+5,y+0,x+8,y+0);
- g.drawLine(x+3,y+1,x+4,y+1);
- g.drawLine(x+9,y+1,x+9,y+1);
- g.drawLine(x+2,y+2,x+2,y+2);
- g.drawLine(x+1,y+3,x+1,y+3);
- g.drawLine(x,y+4,x,y+9);
- g.drawLine(x+1,y+10,x+1,y+10);
- g.drawLine(x+2,y+11,x+2,y+11);
+ g.drawArc(x, y, w - 1, h - 1, 45, 180);
g.setColor(highlight);
- g.drawLine(x+3,y+12,x+4,y+12);
- g.drawLine(x+5,y+13,x+8,y+13);
- g.drawLine(x+9,y+12,x+10,y+12);
- g.drawLine(x+11,y+11,x+11,y+11);
- g.drawLine(x+12,y+10,x+12,y+10);
- g.drawLine(x+13,y+9,x+13,y+4);
- g.drawLine(x+12,y+3,x+12,y+3);
- g.drawLine(x+11,y+2,x+11,y+2);
- g.drawLine(x+10,y+1,x+10,y+1);
+ g.drawArc(x, y, w - 1, h - 1, 45, -180);
g.setColor(dot);
- g.fillRect(x+4,y+5,6,4);
- g.drawLine(x+5,y+4,x+8,y+4);
- g.drawLine(x+5,y+9,x+8,y+9);
+ g.fillOval(x + 3, y + 3, 7, 7);
}
else {
g.setColor(highlight);
- g.drawLine(x+5,y+0,x+8,y+0);
- g.drawLine(x+3,y+1,x+4,y+1);
- g.drawLine(x+9,y+1,x+9,y+1);
- g.drawLine(x+2,y+2,x+2,y+2);
- g.drawLine(x+1,y+3,x+1,y+3);
- g.drawLine(x,y+4,x,y+9);
- g.drawLine(x+1,y+10,x+1,y+10);
- g.drawLine(x+2,y+11,x+2,y+11);
+ g.drawArc(x, y, w - 1, h - 1, 45, 180);
g.setColor(shadow);
- g.drawLine(x+3,y+12,x+4,y+12);
- g.drawLine(x+5,y+13,x+8,y+13);
- g.drawLine(x+9,y+12,x+10,y+12);
- g.drawLine(x+11,y+11,x+11,y+11);
- g.drawLine(x+12,y+10,x+12,y+10);
- g.drawLine(x+13,y+9,x+13,y+4);
- g.drawLine(x+12,y+3,x+12,y+3);
- g.drawLine(x+11,y+2,x+11,y+2);
- g.drawLine(x+10,y+1,x+10,y+1);
+ g.drawArc(x, y, w - 1, h - 1, 45, -180);
}
}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarButton.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarButton.java
index 680a658a6c6..cb586512c82 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarButton.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifScrollBarButton.java
@@ -117,95 +117,57 @@ public class MotifScrollBarButton extends BasicArrowButton
switch (direction) {
case NORTH:
+ g.setColor(fill);
+ g.fillPolygon(new int[]{cx, 0, s - 1}, new int[]{0, s - 1, s - 1}, 3);
+ g.setColor(trail);
+ g.drawLine(cx, 0, s - 1, s - 2);
+ g.drawLine(0, s - 1, s - 1, s - 1);
+ g.drawLine(s - 1, s - 2, s - 1, s - 1); // corner
g.setColor(lead);
- g.drawLine(cx, 0, cx, 0);
- for (int x = cx - 1, y = 1, dx = 1; y <= s - 2; y += 2) {
- g.setColor(lead);
- g.drawLine(x, y, x, y);
- if (y >= (s - 2)) {
- g.drawLine(x, y + 1, x, y + 1);
- }
- g.setColor(fill);
- g.drawLine(x + 1, y, x + dx, y);
- if (y < (s - 2)) {
- g.drawLine(x, y + 1, x + dx + 1, y + 1);
- }
- g.setColor(trail);
- g.drawLine(x + dx + 1, y, x + dx + 1, y);
- if (y >= (s - 2)) {
- g.drawLine(x + 1, y + 1, x + dx + 1, y + 1);
- }
- dx += 2;
- x -= 1;
- }
+ g.drawLine(cx, 0, 0, s - 2);
+ g.drawLine(cx, 0, cx, 0); // corner
+ g.drawLine(0, s - 1, 0, s - 1); // corner
break;
case SOUTH:
+ g.setColor(fill);
+ g.fillPolygon(new int[]{0, s - 1, cx}, new int[]{1, 1, s}, 3);
g.setColor(trail);
- g.drawLine(cx, s, cx, s);
- for (int x = cx - 1, y = s - 1, dx = 1; y >= 1; y -= 2) {
- g.setColor(lead);
- g.drawLine(x, y, x, y);
- if (y <= 2) {
- g.drawLine(x, y - 1, x + dx + 1, y - 1);
- }
- g.setColor(fill);
- g.drawLine(x + 1, y, x + dx, y);
- if (y > 2) {
- g.drawLine(x, y - 1, x + dx + 1, y - 1);
- }
- g.setColor(trail);
- g.drawLine(x + dx + 1, y, x + dx + 1, y);
-
- dx += 2;
- x -= 1;
- }
+ g.drawLine(s - 1, 2, cx, s);
+ g.drawLine(s - 1, 2, s - 1, 2); // corner
+ g.setColor(lead);
+ g.drawLine(0, 2, cx, s);
+ g.drawLine(0, 1, s - 1, 1);
+ g.drawLine(0, 1, 0, 2);
+ g.setColor(trail);
+ g.drawLine(cx, s, cx, s); // corner
break;
case EAST:
+ g.setColor(fill);
+ g.fillPolygon(new int[]{1, s, 1}, new int[]{0, cy, s}, 3);
+ g.setColor(trail);
+ g.drawLine(1, s, s, cy);
+ g.drawLine(2, s, 2, s); // corner
g.setColor(lead);
+ g.drawLine(1, 0, 1, s);
+ g.drawLine(2, 0, s, cy);
+ g.drawLine(2, 0, 2, 0); // corner
g.drawLine(s, cy, s, cy);
- for (int y = cy - 1, x = s - 1, dy = 1; x >= 1; x -= 2) {
- g.setColor(lead);
- g.drawLine(x, y, x, y);
- if (x <= 2) {
- g.drawLine(x - 1, y, x - 1, y + dy + 1);
- }
- g.setColor(fill);
- g.drawLine(x, y + 1, x, y + dy);
- if (x > 2) {
- g.drawLine(x - 1, y, x - 1, y + dy + 1);
- }
- g.setColor(trail);
- g.drawLine(x, y + dy + 1, x, y + dy + 1);
-
- dy += 2;
- y -= 1;
- }
break;
case WEST:
+ g.setColor(fill);
+ g.fillPolygon(new int[]{0, s - 1, s - 1}, new int[]{cy, 0, s}, 3);
+ g.drawLine(s - 1, 0, s - 1, s);
g.setColor(trail);
- g.drawLine(0, cy, 0, cy);
- for (int y = cy - 1, x = 1, dy = 1; x <= s - 2; x += 2) {
- g.setColor(lead);
- g.drawLine(x, y, x, y);
- if (x >= (s - 2)) {
- g.drawLine(x + 1, y, x + 1, y);
- }
- g.setColor(fill);
- g.drawLine(x, y + 1, x, y + dy);
- if (x < (s - 2)) {
- g.drawLine(x + 1, y, x + 1, y + dy + 1);
- }
- g.setColor(trail);
- g.drawLine(x, y + dy + 1, x, y + dy + 1);
- if (x >= (s - 2)) {
- g.drawLine(x + 1, y + 1, x + 1, y + dy + 1);
- }
- dy += 2;
- y -= 1;
- }
+ g.drawLine(0, cy, s - 1, s);
+ g.drawLine(s - 1, 0, s - 1, s);
+ g.setColor(lead);
+ g.drawLine(0, cy, s - 2, 0);
+ g.drawLine(s - 2, 0, s - 1, 0); // corner
+ g.setColor(trail);
+ g.drawLine(0, cy, 0, cy); // corner
break;
}
}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AlawCodec.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AlawCodec.java
index 30dd2e8d726..a585a2b93ce 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AlawCodec.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AlawCodec.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,25 +30,26 @@ import java.util.Objects;
import java.util.Vector;
import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.spi.FormatConversionProvider;
/**
* A-law encodes linear data, and decodes a-law data to linear data.
*
* @author Kara Kytle
*/
-public final class AlawCodec extends SunCodec {
+public final class AlawCodec extends FormatConversionProvider {
/* Tables used for A-law decoding */
private static final byte[] ALAW_TABH = new byte[256];
private static final byte[] ALAW_TABL = new byte[256];
- private static final AudioFormat.Encoding[] alawEncodings = { AudioFormat.Encoding.ALAW, AudioFormat.Encoding.PCM_SIGNED };
-
- private static final short seg_end [] = {0xFF, 0x1FF, 0x3FF,
- 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
+ private static final short seg_end[] = {
+ 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF
+ };
/**
* Initializes the decode tables.
@@ -73,13 +74,14 @@ public final class AlawCodec extends SunCodec {
}
}
+ @Override
+ public AudioFormat.Encoding[] getSourceEncodings() {
+ return new Encoding[]{Encoding.ALAW, Encoding.PCM_SIGNED};
+ }
- /**
- * Constructs a new ALAW codec object.
- */
- public AlawCodec() {
-
- super(alawEncodings, alawEncodings);
+ @Override
+ public AudioFormat.Encoding[] getTargetEncodings() {
+ return getSourceEncodings();
}
@Override
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
index d28729fd7c5..6dbbb338450 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -562,8 +562,7 @@ public final class AudioFloatFormatConverter extends FormatConversionProvider {
@Override
public Encoding[] getTargetEncodings() {
- return new Encoding[] { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
- Encoding.PCM_FLOAT };
+ return getSourceEncodings();
}
@Override
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java
index f65351e31c8..27c7e1bc7f6 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1034,6 +1034,7 @@ final class DirectAudioDevice extends AbstractMixer {
// $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
Toolkit.isFullySpecifiedAudioFormat(format);
+ Toolkit.validateBuffer(format.getFrameSize(), bufferSize);
byte[] newData = new byte[bufferSize];
System.arraycopy(data, offset, newData, 0, bufferSize);
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/PCMtoPCMCodec.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/PCMtoPCMCodec.java
index edb26d5c9a5..f623d7db60e 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/PCMtoPCMCodec.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/PCMtoPCMCodec.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,32 +30,26 @@ import java.util.Objects;
import java.util.Vector;
import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.spi.FormatConversionProvider;
/**
* Converts among signed/unsigned and little/big endianness of sampled.
*
* @author Jan Borgersen
*/
-public final class PCMtoPCMCodec extends SunCodec {
+public final class PCMtoPCMCodec extends FormatConversionProvider {
- private static final AudioFormat.Encoding[] inputEncodings = {
- AudioFormat.Encoding.PCM_SIGNED,
- AudioFormat.Encoding.PCM_UNSIGNED,
- };
+ @Override
+ public AudioFormat.Encoding[] getSourceEncodings() {
+ return new Encoding[]{Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED};
+ }
- private static final AudioFormat.Encoding[] outputEncodings = {
- AudioFormat.Encoding.PCM_SIGNED,
- AudioFormat.Encoding.PCM_UNSIGNED,
- };
-
- /**
- * Constructs a new PCMtoPCM codec object.
- */
- public PCMtoPCMCodec() {
-
- super( inputEncodings, outputEncodings);
+ @Override
+ public AudioFormat.Encoding[] getTargetEncodings() {
+ return getSourceEncodings();
}
@Override
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMixingClip.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMixingClip.java
index af3577493fe..020d32ed6c4 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMixingClip.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMixingClip.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -363,9 +363,7 @@ public final class SoftMixingClip extends SoftMixingDataLine implements Clip {
if (AudioFloatConverter.getConverter(format) == null)
throw new IllegalArgumentException("Invalid format : "
+ format.toString());
- if (bufferSize % format.getFrameSize() != 0)
- throw new IllegalArgumentException(
- "Buffer size does not represent an integral number of sample frames!");
+ Toolkit.validateBuffer(format.getFrameSize(), bufferSize);
if (data != null) {
this.data = Arrays.copyOf(data, data.length);
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunCodec.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunCodec.java
deleted file mode 100644
index a878d123e15..00000000000
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunCodec.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. 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 com.sun.media.sound;
-
-import javax.sound.sampled.AudioFormat;
-import javax.sound.sampled.spi.FormatConversionProvider;
-
-/**
- * A codec can encode and/or decode audio data. It provides an
- * AudioInputStream from which processed data may be read.
- *
- * Its input format represents the format of the incoming
- * audio data, or the format of the data in the underlying stream.
- *
- * Its output format represents the format of the processed, outgoing
- * audio data. This is the format of the data which may be read from
- * the filtered stream.
- *
- * @author Kara Kytle
- */
-abstract class SunCodec extends FormatConversionProvider {
-
- private final AudioFormat.Encoding[] inputEncodings;
- private final AudioFormat.Encoding[] outputEncodings;
-
- /**
- * Constructs a new codec object.
- */
- SunCodec(final AudioFormat.Encoding[] inputEncodings,
- final AudioFormat.Encoding[] outputEncodings) {
- this.inputEncodings = inputEncodings;
- this.outputEncodings = outputEncodings;
- }
-
- @Override
- public final AudioFormat.Encoding[] getSourceEncodings() {
- AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[inputEncodings.length];
- System.arraycopy(inputEncodings, 0, encodings, 0, inputEncodings.length);
- return encodings;
- }
-
- @Override
- public final AudioFormat.Encoding[] getTargetEncodings() {
- AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[outputEncodings.length];
- System.arraycopy(outputEncodings, 0, encodings, 0, outputEncodings.length);
- return encodings;
- }
-}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/Toolkit.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/Toolkit.java
index cc1d0a91c49..1b903a3bcf1 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/Toolkit.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/Toolkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -149,6 +149,20 @@ public final class Toolkit {
return (long) (((double) frames) / format.getFrameRate() * 1000000.0d);
}
+ /**
+ * Throws an exception if the buffer size does not represent an integral
+ * number of sample frames.
+ */
+ static void validateBuffer(final int frameSize, final int bufferSize) {
+ if (bufferSize % frameSize == 0) {
+ return;
+ }
+ throw new IllegalArgumentException(String.format(
+ "Buffer size (%d) does not represent an integral number of "
+ + "sample frames (%d)", bufferSize, frameSize));
+ }
+
+
static void isFullySpecifiedAudioFormat(AudioFormat format) {
if (!format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED)
&& !format.getEncoding().equals(AudioFormat.Encoding.PCM_UNSIGNED)
diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/UlawCodec.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/UlawCodec.java
index 3d39395da9c..77564e86c27 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/UlawCodec.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/UlawCodec.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,26 +30,26 @@ import java.util.Objects;
import java.util.Vector;
import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFormat.Encoding;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.spi.FormatConversionProvider;
/**
* U-law encodes linear data, and decodes u-law data to linear data.
*
* @author Kara Kytle
*/
-public final class UlawCodec extends SunCodec {
+public final class UlawCodec extends FormatConversionProvider {
/* Tables used for U-law decoding */
private static final byte[] ULAW_TABH = new byte[256];
private static final byte[] ULAW_TABL = new byte[256];
- private static final AudioFormat.Encoding[] ulawEncodings = {AudioFormat.Encoding.ULAW,
- AudioFormat.Encoding.PCM_SIGNED};
-
- private static final short seg_end [] = {0xFF, 0x1FF, 0x3FF,
- 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
+ private static final short seg_end[] = {
+ 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF
+ };
/**
* Initializes the decode tables.
@@ -69,11 +69,14 @@ public final class UlawCodec extends SunCodec {
}
}
- /**
- * Constructs a new ULAW codec object.
- */
- public UlawCodec() {
- super(ulawEncodings, ulawEncodings);
+ @Override
+ public AudioFormat.Encoding[] getSourceEncodings() {
+ return new Encoding[]{Encoding.ULAW, Encoding.PCM_SIGNED};
+ }
+
+ @Override
+ public AudioFormat.Encoding[] getTargetEncodings() {
+ return getSourceEncodings();
}
@Override
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java
index 228e14c93d2..05fbfabe80f 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java
@@ -851,8 +851,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
{
comp.setGraphicsConfiguration(gc);
}
- public boolean requestFocus(Component comp, FocusEvent.Cause cause) {
- return comp.requestFocus(cause);
+ public void requestFocus(Component comp, FocusEvent.Cause cause) {
+ comp.requestFocus(cause);
}
public boolean canBeFocusOwner(Component comp) {
return comp.canBeFocusOwner();
@@ -7511,8 +7511,51 @@ public abstract class Component implements ImageObserver, MenuContainer,
requestFocusHelper(false, true);
}
- boolean requestFocus(FocusEvent.Cause cause) {
- return requestFocusHelper(false, true, cause);
+
+ /**
+ * Requests by the reason of {@code cause} that this Component get the input
+ * focus, and that this Component's top-level ancestor become the
+ * focused Window. This component must be displayable, focusable, visible
+ * and all of its ancestors (with the exception of the top-level Window)
+ * must be visible for the request to be granted. Every effort will be
+ * made to honor the request; however, in some cases it may be
+ * impossible to do so. Developers must never assume that this
+ * Component is the focus owner until this Component receives a
+ * FOCUS_GAINED event.
+ *
+ * The focus request effect may also depend on the provided
+ * cause value. If this request is succeed the {@code FocusEvent}
+ * generated in the result will receive the cause value specified as the
+ * argument of method. If this request is denied because this Component's
+ * top-level Window cannot become the focused Window, the request will be
+ * remembered and will be granted when the Window is later focused by the
+ * user.
+ *
+ * This method cannot be used to set the focus owner to no Component at
+ * all. Use {@code KeyboardFocusManager.clearGlobalFocusOwner()}
+ * instead.
+ *
+ * Because the focus behavior of this method is platform-dependent,
+ * developers are strongly encouraged to use
+ * {@code requestFocusInWindow(FocusEvent.Cause)} when possible.
+ *
+ *
Note: Not all focus transfers result from invoking this method. As
+ * such, a component may receive focus without this or any of the other
+ * {@code requestFocus} methods of {@code Component} being invoked.
+ *
+ * @param cause the cause why the focus is requested
+ * @see FocusEvent
+ * @see FocusEvent.Cause
+ * @see #requestFocusInWindow(FocusEvent.Cause)
+ * @see java.awt.event.FocusEvent
+ * @see #addFocusListener
+ * @see #isFocusable
+ * @see #isDisplayable
+ * @see KeyboardFocusManager#clearGlobalFocusOwner
+ * @since 9
+ */
+ public void requestFocus(FocusEvent.Cause cause) {
+ requestFocusHelper(false, true, cause);
}
/**
@@ -7578,9 +7621,77 @@ public abstract class Component implements ImageObserver, MenuContainer,
return requestFocusHelper(temporary, true);
}
- boolean requestFocus(boolean temporary, FocusEvent.Cause cause) {
+ /**
+ * Requests by the reason of {@code cause} that this {@code Component} get
+ * the input focus, and that this {@code Component}'s top-level ancestor
+ * become the focused {@code Window}. This component must be
+ * displayable, focusable, visible and all of its ancestors (with
+ * the exception of the top-level Window) must be visible for the
+ * request to be granted. Every effort will be made to honor the
+ * request; however, in some cases it may be impossible to do
+ * so. Developers must never assume that this component is the
+ * focus owner until this component receives a FOCUS_GAINED
+ * event. If this request is denied because this component's
+ * top-level window cannot become the focused window, the request
+ * will be remembered and will be granted when the window is later
+ * focused by the user.
+ *
+ * This method returns a boolean value. If {@code false} is returned,
+ * the request is guaranteed to fail. If {@code true} is
+ * returned, the request will succeed unless it is vetoed, or an
+ * extraordinary event, such as disposal of the component's peer, occurs
+ * before the request can be granted by the native windowing system. Again,
+ * while a return value of {@code true} indicates that the request is
+ * likely to succeed, developers must never assume that this component is
+ * the focus owner until this component receives a FOCUS_GAINED event.
+ *
+ * The focus request effect may also depend on the provided
+ * cause value. If this request is succeed the {FocusEvent}
+ * generated in the result will receive the cause value specified as the
+ * argument of the method.
+ *
+ * This method cannot be used to set the focus owner to no component at
+ * all. Use {@code KeyboardFocusManager.clearGlobalFocusOwner}
+ * instead.
+ *
+ * Because the focus behavior of this method is platform-dependent,
+ * developers are strongly encouraged to use
+ * {@code requestFocusInWindow} when possible.
+ *
+ * Every effort will be made to ensure that {@code FocusEvent}s
+ * generated as a
+ * result of this request will have the specified temporary value. However,
+ * because specifying an arbitrary temporary state may not be implementable
+ * on all native windowing systems, correct behavior for this method can be
+ * guaranteed only for lightweight {@code Component}s.
+ * This method is not intended
+ * for general use, but exists instead as a hook for lightweight component
+ * libraries, such as Swing.
+ *
+ * Note: Not all focus transfers result from invoking this method. As
+ * such, a component may receive focus without this or any of the other
+ * {@code requestFocus} methods of {@code Component} being invoked.
+ *
+ * @param temporary true if the focus change is temporary,
+ * such as when the window loses the focus; for
+ * more information on temporary focus changes see the
+ *Focus Specification
+ *
+ * @param cause the cause why the focus is requested
+ * @return {@code false} if the focus change request is guaranteed to
+ * fail; {@code true} if it is likely to succeed
+ * @see FocusEvent
+ * @see FocusEvent.Cause
+ * @see #addFocusListener
+ * @see #isFocusable
+ * @see #isDisplayable
+ * @see KeyboardFocusManager#clearGlobalFocusOwner
+ * @since 9
+ */
+ protected boolean requestFocus(boolean temporary, FocusEvent.Cause cause) {
return requestFocusHelper(temporary, true, cause);
}
+
/**
* Requests that this Component get the input focus, if this
* Component's top-level ancestor is already the focused
@@ -7629,7 +7740,59 @@ public abstract class Component implements ImageObserver, MenuContainer,
return requestFocusHelper(false, false);
}
- boolean requestFocusInWindow(FocusEvent.Cause cause) {
+ /**
+ * Requests by the reason of {@code cause} that this Component get the input
+ * focus, if this Component's top-level ancestor is already the focused
+ * Window. This component must be displayable, focusable, visible
+ * and all of its ancestors (with the exception of the top-level
+ * Window) must be visible for the request to be granted. Every
+ * effort will be made to honor the request; however, in some
+ * cases it may be impossible to do so. Developers must never
+ * assume that this Component is the focus owner until this
+ * Component receives a FOCUS_GAINED event.
+ *
+ * This method returns a boolean value. If {@code false} is returned,
+ * the request is guaranteed to fail. If {@code true} is
+ * returned, the request will succeed unless it is vetoed, or an
+ * extraordinary event, such as disposal of the Component's peer, occurs
+ * before the request can be granted by the native windowing system. Again,
+ * while a return value of {@code true} indicates that the request is
+ * likely to succeed, developers must never assume that this Component is
+ * the focus owner until this Component receives a FOCUS_GAINED event.
+ *
+ * The focus request effect may also depend on the provided
+ * cause value. If this request is succeed the {@code FocusEvent}
+ * generated in the result will receive the cause value specified as the
+ * argument of the method.
+ *
+ * This method cannot be used to set the focus owner to no Component at
+ * all. Use {@code KeyboardFocusManager.clearGlobalFocusOwner()}
+ * instead.
+ *
+ * The focus behavior of this method can be implemented uniformly across
+ * platforms, and thus developers are strongly encouraged to use this
+ * method over {@code requestFocus(FocusEvent.Cause)} when possible.
+ * Code which relies on {@code requestFocus(FocusEvent.Cause)} may exhibit
+ * different focus behavior on different platforms.
+ *
+ *
Note: Not all focus transfers result from invoking this method. As
+ * such, a component may receive focus without this or any of the other
+ * {@code requestFocus} methods of {@code Component} being invoked.
+ *
+ * @param cause the cause why the focus is requested
+ * @return {@code false} if the focus change request is guaranteed to
+ * fail; {@code true} if it is likely to succeed
+ * @see #requestFocus(FocusEvent.Cause)
+ * @see FocusEvent
+ * @see FocusEvent.Cause
+ * @see java.awt.event.FocusEvent
+ * @see #addFocusListener
+ * @see #isFocusable
+ * @see #isDisplayable
+ * @see KeyboardFocusManager#clearGlobalFocusOwner
+ * @since 9
+ */
+ public boolean requestFocusInWindow(FocusEvent.Cause cause) {
return requestFocusHelper(false, false, cause);
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/DisplayMode.java b/jdk/src/java.desktop/share/classes/java/awt/DisplayMode.java
index 3dafedb2be8..fd0d6f95be7 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/DisplayMode.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/DisplayMode.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -142,6 +142,7 @@ public final class DisplayMode {
/**
* {@inheritDoc}
*/
+ @Override
public boolean equals(Object dm) {
if (dm instanceof DisplayMode) {
return equals((DisplayMode)dm);
@@ -153,9 +154,20 @@ public final class DisplayMode {
/**
* {@inheritDoc}
*/
+ @Override
public int hashCode() {
return getWidth() + getHeight() + getBitDepth() * 7
+ getRefreshRate() * 13;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return getWidth() + "x" + getHeight() + "x" +
+ (getBitDepth() > 0 ? getBitDepth() + "bpp": "[Multi depth]")
+ + "@" + (getRefreshRate() > 0 ? getRefreshRate() + "Hz" :
+ "[Unknown refresh rate]");
+ }
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Font.java b/jdk/src/java.desktop/share/classes/java/awt/Font.java
index 3e63e9af52f..18046fd9ea3 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Font.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Font.java
@@ -154,6 +154,10 @@ import static sun.font.EAttribute.*;
* associated with a font face, each differing in size, style, transform
* and font features.
*
+ * Glyphs may not always be rendered with the requested properties (e.g, font
+ * and style) due to platform limitations such as the absence of suitable
+ * platform fonts to implement a logical font.
+ *
* The {@link GraphicsEnvironment#getAllFonts() getAllFonts} method
* of the {@code GraphicsEnvironment} class returns an
* array of all font faces available in the system. These font faces are
diff --git a/jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java b/jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java
index 952a6dc5bf2..3992172adcc 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/SplashScreen.java
@@ -65,6 +65,16 @@ import sun.awt.image.SunWritableRaster;
*
* java -splash:filename.gif Test
*
+ * HiDPI scaled image is also supported.
+ * Unscaled image name i.e. filename.gif should be passed in
+ * {@code manifest.mf}/{@code -splash:} option for all image types irrespective of
+ * HiDPI and Non-HiDPI.
+ * Following is the naming convention for scaled images.
+ * Screen scale 1.25: filename@125pct.gif
+ * Screen scale 1.50: filename@150pct.gif
+ * Screen scale 2: filename@200pct.gif and filename@2x.gif both are supported
+ * Screen scale 2.50: filename@250pct.gif
+ * Screen scale 3: filename@300pct.gif and filename@3x.gif both are supported
* The command line interface has higher precedence over the manifest
* setting.
*
diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadataNode.java b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadataNode.java
index dd054ea90dc..f957d997b7d 100644
--- a/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadataNode.java
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/metadata/IIOMetadataNode.java
@@ -122,7 +122,7 @@ class IIONodeList implements NodeList {
}
public Node item(int index) {
- if (index < 0 || index > nodes.size()) {
+ if (index < 0 || index >= nodes.size()) {
return null;
}
return nodes.get(index);
@@ -882,7 +882,7 @@ public class IIOMetadataNode implements Element, NodeList {
}
private void getElementsByTagName(String name, List l) {
- if (nodeName.equals(name)) {
+ if (nodeName.equals(name) || "*".equals(name)) {
l.add(this);
}
diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java
index 565db2d4a66..9860ad3d476 100644
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/FormatConversionProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
package javax.sound.sampled.spi;
-import java.util.Objects;
+import java.util.stream.Stream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
@@ -81,16 +81,8 @@ public abstract class FormatConversionProvider {
* {@code false}
* @throws NullPointerException if {@code sourceEncoding} is {@code null}
*/
- public boolean isSourceEncodingSupported(Encoding sourceEncoding) {
- Objects.requireNonNull(sourceEncoding);
- Encoding sourceEncodings[] = getSourceEncodings();
-
- for(int i=0; i