\n";
diff --git a/jdk/src/java.base/share/classes/java/lang/String.java b/jdk/src/java.base/share/classes/java/lang/String.java
index a1772977727..33222a586b5 100644
--- a/jdk/src/java.base/share/classes/java/lang/String.java
+++ b/jdk/src/java.base/share/classes/java/lang/String.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2015, 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
@@ -78,14 +78,8 @@ import jdk.internal.vm.annotation.Stable;
*
* The Java language provides special support for the string
* concatenation operator ( + ), and for conversion of
- * other objects to strings. String concatenation is implemented
- * through the {@code StringBuilder}(or {@code StringBuffer})
- * class and its {@code append} method.
- * String conversions are implemented through the method
- * {@code toString}, defined by {@code Object} and
- * inherited by all classes in Java. For additional information on
- * string concatenation and conversion, see Gosling, Joy, and Steele,
- * The Java Language Specification.
+ * other objects to strings. For additional information on string
+ * concatenation and conversion, see The Java™ Language Specification.
*
*
Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
@@ -106,6 +100,14 @@ import jdk.internal.vm.annotation.Stable;
* into account. The {@link java.text.Collator} class provides methods for
* finer-grain, locale-sensitive String comparison.
*
+ * @implNote The implementation of the string concatenation operator is left to
+ * the discretion of a Java compiler, as long as the compiler ultimately conforms
+ * to The Java™ Language Specification. For example, the {@code javac} compiler
+ * may implement the operator with {@code StringBuffer}, {@code StringBuilder},
+ * or {@code java.lang.invoke.StringConcatFactory} depending on the JDK version. The
+ * implementation of string conversion is typically through the method {@code toString},
+ * defined by {@code Object} and inherited by all classes in Java.
+ *
* @author Lee Boynton
* @author Arthur van Hoff
* @author Martin Buchholz
@@ -115,6 +117,7 @@ import jdk.internal.vm.annotation.Stable;
* @see java.lang.StringBuilder
* @see java.nio.charset.Charset
* @since 1.0
+ * @jls 15.18.1 String Concatenation Operator +
*/
public final class String
@@ -2977,6 +2980,7 @@ public final class String
*
* @return a string that has the same contents as this string, but is
* guaranteed to be from a pool of unique strings.
+ * @jls 3.10.5 String Literals
*/
public native String intern();
diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java
index 2ddd37f5da1..d6e80e71908 100644
--- a/jdk/src/java.base/share/classes/java/lang/System.java
+++ b/jdk/src/java.base/share/classes/java/lang/System.java
@@ -1155,8 +1155,9 @@ public final class System {
* @param level the log message level.
* @param msg the string message (or a key in the message catalog, if
* this logger is a {@link
- * LoggerFinder#getLocalizedLogger(java.lang.String, java.util.ResourceBundle, java.lang.Class)
- * localized logger}); can be {@code null}.
+ * LoggerFinder#getLocalizedLogger(java.lang.String,
+ * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * can be {@code null}.
*
* @throws NullPointerException if {@code level} is {@code null}.
*/
@@ -1222,8 +1223,9 @@ public final class System {
* @param level the log message level.
* @param msg the string message (or a key in the message catalog, if
* this logger is a {@link
- * LoggerFinder#getLocalizedLogger(java.lang.String, java.util.ResourceBundle, java.lang.Class)
- * localized logger}); can be {@code null}.
+ * LoggerFinder#getLocalizedLogger(java.lang.String,
+ * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * can be {@code null}.
* @param thrown a {@code Throwable} associated with the log message;
* can be {@code null}.
*
@@ -1270,8 +1272,9 @@ public final class System {
* @param format the string message format in {@link
* java.text.MessageFormat} format, (or a key in the message
* catalog, if this logger is a {@link
- * LoggerFinder#getLocalizedLogger(java.lang.String, java.util.ResourceBundle, java.lang.Class)
- * localized logger}); can be {@code null}.
+ * LoggerFinder#getLocalizedLogger(java.lang.String,
+ * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * can be {@code null}.
* @param params an optional list of parameters to the message (may be
* none).
*
@@ -1453,30 +1456,30 @@ public final class System {
/**
* Returns an instance of {@link Logger Logger}
- * for the given {@code caller}.
+ * for the given {@code module}.
*
* @param name the name of the logger.
- * @param caller the class for which the logger is being requested.
+ * @param module the module for which the logger is being requested.
*
- * @return a {@link Logger logger} suitable for the given caller's
- * use.
+ * @return a {@link Logger logger} suitable for use within the given
+ * module.
* @throws NullPointerException if {@code name} is {@code null} or
- * {@code caller} is {@code null}.
+ * {@code module} is {@code null}.
* @throws SecurityException if a security manager is present and its
* {@code checkPermission} method doesn't allow the
* {@code RuntimePermission("loggerFinder")}.
*/
- public abstract Logger getLogger(String name, /* Module */ Class> caller);
+ public abstract Logger getLogger(String name, Module module);
/**
* Returns a localizable instance of {@link Logger Logger}
- * for the given {@code caller}.
+ * for the given {@code module}.
* The returned logger will use the provided resource bundle for
* message localization.
*
* @implSpec By default, this method calls {@link
- * #getLogger(java.lang.String, java.lang.Class)
- * this.getLogger(name, caller)} to obtain a logger, then wraps that
+ * #getLogger(java.lang.String, java.lang.reflect.Module)
+ * this.getLogger(name, module)} to obtain a logger, then wraps that
* logger in a {@link Logger} instance where all methods that do not
* take a {@link ResourceBundle} as parameter are redirected to one
* which does - passing the given {@code bundle} for
@@ -1499,19 +1502,19 @@ public final class System {
*
* @param name the name of the logger.
* @param bundle a resource bundle; can be {@code null}.
- * @param caller the class for which the logger is being requested.
+ * @param module the module for which the logger is being requested.
* @return an instance of {@link Logger Logger} which will use the
* provided resource bundle for message localization.
*
* @throws NullPointerException if {@code name} is {@code null} or
- * {@code caller} is {@code null}.
+ * {@code module} is {@code null}.
* @throws SecurityException if a security manager is present and its
* {@code checkPermission} method doesn't allow the
* {@code RuntimePermission("loggerFinder")}.
*/
public Logger getLocalizedLogger(String name, ResourceBundle bundle,
- /* Module */ Class> caller) {
- return new LocalizedLoggerWrapper<>(getLogger(name, caller), bundle);
+ Module module) {
+ return new LocalizedLoggerWrapper<>(getLogger(name, module), bundle);
}
/**
@@ -1558,12 +1561,13 @@ public final class System {
*
* @implSpec
* Instances returned by this method route messages to loggers
- * obtained by calling {@link LoggerFinder#getLogger(java.lang.String, java.lang.Class)
- * LoggerFinder.getLogger(name, caller)}.
+ * obtained by calling {@link LoggerFinder#getLogger(java.lang.String,
+ * java.lang.reflect.Module) LoggerFinder.getLogger(name, module)}, where
+ * {@code module} is the caller's module.
*
* @apiNote
* This method may defer calling the {@link
- * LoggerFinder#getLogger(java.lang.String, java.lang.Class)
+ * LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)
* LoggerFinder.getLogger} method to create an actual logger supplied by
* the logging backend, for instance, to allow loggers to be obtained during
* the system initialization time.
@@ -1579,7 +1583,7 @@ public final class System {
public static Logger getLogger(String name) {
Objects.requireNonNull(name);
final Class> caller = Reflection.getCallerClass();
- return LazyLoggers.getLogger(name, caller);
+ return LazyLoggers.getLogger(name, caller.getModule());
}
/**
@@ -1591,8 +1595,9 @@ public final class System {
* @implSpec
* The returned logger will perform message localization as specified
* by {@link LoggerFinder#getLocalizedLogger(java.lang.String,
- * java.util.ResourceBundle, java.lang.Class)
- * LoggerFinder.getLocalizedLogger(name, bundle, caller}.
+ * java.util.ResourceBundle, java.lang.reflect.Module)
+ * LoggerFinder.getLocalizedLogger(name, bundle, module}, where
+ * {@code module} is the caller's module.
*
* @apiNote
* This method is intended to be used after the system is fully initialized.
@@ -1624,12 +1629,14 @@ public final class System {
// Bootstrap sensitive classes in the JDK do not use resource bundles
// when logging. This could be revisited later, if it needs to.
if (sm != null) {
- return AccessController.doPrivileged((PrivilegedAction)
- () -> LoggerFinder.accessProvider().getLocalizedLogger(name, rb, caller),
- null,
- LoggerFinder.LOGGERFINDER_PERMISSION);
+ final PrivilegedAction pa =
+ () -> LoggerFinder.accessProvider()
+ .getLocalizedLogger(name, rb, caller.getModule());
+ return AccessController.doPrivileged(pa, null,
+ LoggerFinder.LOGGERFINDER_PERMISSION);
}
- return LoggerFinder.accessProvider().getLocalizedLogger(name, rb, caller);
+ return LoggerFinder.accessProvider()
+ .getLocalizedLogger(name, rb, caller.getModule());
}
/**
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
index a108836ce51..782eff613ae 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
@@ -25,6 +25,7 @@
package java.lang.invoke;
+import java.lang.reflect.Array;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
@@ -1892,7 +1893,8 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
MH_tryFinallyExec = 12,
MH_tryFinallyVoidExec = 13,
MH_decrementCounter = 14,
- MH_LIMIT = 15;
+ MH_Array_newInstance = 15,
+ MH_LIMIT = 16;
static MethodHandle getConstantHandle(int idx) {
MethodHandle handle = HANDLES[idx];
@@ -1965,6 +1967,9 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
case MH_decrementCounter:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "decrementCounter",
MethodType.methodType(int.class, int.class));
+ case MH_Array_newInstance:
+ return IMPL_LOOKUP.findStatic(Array.class, "newInstance",
+ MethodType.methodType(Object.class, Class.class, int.class));
}
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
index 6c37371a57b..c3a97a178a3 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
@@ -25,34 +25,38 @@
package java.lang.invoke;
-import java.lang.reflect.*;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Arrays;
-import java.util.Objects;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyAccess;
import sun.invoke.util.Wrapper;
-import jdk.internal.reflect.CallerSensitive;
-import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
import sun.security.util.SecurityConstants;
-import java.lang.invoke.LambdaForm.BasicType;
-import static java.lang.invoke.MethodHandleImpl.Intrinsic;
-import static java.lang.invoke.MethodHandleNatives.Constants.*;
+import java.lang.invoke.LambdaForm.BasicType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ReflectPermission;
+import java.nio.ByteOrder;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.internal.org.objectweb.asm.Opcodes;
-
+import static java.lang.invoke.MethodHandleImpl.Intrinsic;
+import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.newIllegalArgumentException;
import static java.lang.invoke.MethodType.methodType;
@@ -741,10 +745,13 @@ public class MethodHandles {
if (name.startsWith("java.lang.invoke."))
throw newIllegalArgumentException("illegal lookupClass: "+lookupClass);
- // For caller-sensitive MethodHandles.lookup()
- // disallow lookup more restricted packages
+ // For caller-sensitive MethodHandles.lookup() disallow lookup from
+ // restricted packages. This a fragile and blunt approach.
+ // TODO replace with a more formal and less fragile mechanism
+ // that does not bluntly restrict classes under packages within
+ // java.base from looking up MethodHandles or VarHandles.
if (allowedModes == ALL_MODES && lookupClass.getClassLoader() == null) {
- if (name.startsWith("java.") ||
+ if ((name.startsWith("java.") && !name.startsWith("java.util.concurrent.")) ||
(name.startsWith("sun.") && !name.startsWith("sun.invoke."))) {
throw newIllegalArgumentException("illegal lookupClass: " + lookupClass);
}
@@ -1003,6 +1010,9 @@ assertEquals("[x, y, z]", pb.command().toString());
* @throws NullPointerException if any argument is null
*/
public MethodHandle findConstructor(Class> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ if (refc.isArray()) {
+ throw new NoSuchMethodException("no constructor for array class: " + refc.getName());
+ }
String name = "";
MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type);
return getDirectConstructor(refc, ctor);
@@ -2213,6 +2223,27 @@ return mh1;
static final Lookup PUBLIC_LOOKUP = new Lookup(PUBLIC_LOOKUP_CLASS, Lookup.PUBLIC);
}
+ /**
+ * Produces a method handle constructing arrays of a desired type.
+ * The return type of the method handle will be the array type.
+ * The type of its sole argument will be {@code int}, which specifies the size of the array.
+ * @param arrayClass an array type
+ * @return a method handle which can create arrays of the given type
+ * @throws NullPointerException if the argument is {@code null}
+ * @throws IllegalArgumentException if {@code arrayClass} is not an array type
+ * @see java.lang.reflect.Array#newInstance(Class, int)
+ * @since 9
+ */
+ public static
+ MethodHandle arrayConstructor(Class> arrayClass) throws IllegalArgumentException {
+ if (!arrayClass.isArray()) {
+ throw newIllegalArgumentException("not an array class: " + arrayClass.getName());
+ }
+ MethodHandle ani = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_Array_newInstance).
+ bindTo(arrayClass.getComponentType());
+ return ani.asType(ani.type().changeReturnType(arrayClass));
+ }
+
/**
* Produces a method handle giving read access to elements of an array.
* The type of the method handle will have a return type of the array's
@@ -2337,13 +2368,12 @@ return mh1;
*
* @param viewArrayClass the view array class, with a component type of
* type {@code T}
- * @param bigEndian true if the endianness of the view array elements, as
- * stored in the underlying {@code byte} array, is big endian, otherwise
- * little endian
+ * @param byteOrder the endianness of the view array elements, as
+ * stored in the underlying {@code byte} array
* @return a VarHandle giving access to elements of a {@code byte[]} array
* viewed as if elements corresponding to the components type of the view
* array class
- * @throws NullPointerException if viewArrayClass is null
+ * @throws NullPointerException if viewArrayClass or byteOrder is null
* @throws IllegalArgumentException if viewArrayClass is not an array type
* @throws UnsupportedOperationException if the component type of
* viewArrayClass is not supported as a variable type
@@ -2351,8 +2381,10 @@ return mh1;
*/
public static
VarHandle byteArrayViewVarHandle(Class> viewArrayClass,
- boolean bigEndian) throws IllegalArgumentException {
- return VarHandles.byteArrayViewHandle(viewArrayClass, bigEndian);
+ ByteOrder byteOrder) throws IllegalArgumentException {
+ Objects.requireNonNull(byteOrder);
+ return VarHandles.byteArrayViewHandle(viewArrayClass,
+ byteOrder == ByteOrder.BIG_ENDIAN);
}
/**
@@ -2422,14 +2454,13 @@ return mh1;
*
* @param viewArrayClass the view array class, with a component type of
* type {@code T}
- * @param bigEndian true if the endianness of the view array elements, as
- * stored in the underlying {@code ByteBuffer}, is big endian, otherwise
- * little endian (Note this overrides the endianness of a
- * {@code ByteBuffer})
+ * @param byteOrder the endianness of the view array elements, as
+ * stored in the underlying {@code ByteBuffer} (Note this overrides the
+ * endianness of a {@code ByteBuffer})
* @return a VarHandle giving access to elements of a {@code ByteBuffer}
* viewed as if elements corresponding to the components type of the view
* array class
- * @throws NullPointerException if viewArrayClass is null
+ * @throws NullPointerException if viewArrayClass or byteOrder is null
* @throws IllegalArgumentException if viewArrayClass is not an array type
* @throws UnsupportedOperationException if the component type of
* viewArrayClass is not supported as a variable type
@@ -2437,8 +2468,10 @@ return mh1;
*/
public static
VarHandle byteBufferViewVarHandle(Class> viewArrayClass,
- boolean bigEndian) throws IllegalArgumentException {
- return VarHandles.makeByteBufferViewHandle(viewArrayClass, bigEndian);
+ ByteOrder byteOrder) throws IllegalArgumentException {
+ Objects.requireNonNull(byteOrder);
+ return VarHandles.makeByteBufferViewHandle(viewArrayClass,
+ byteOrder == ByteOrder.BIG_ENDIAN);
}
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
index 44f29a4a136..f302c75af79 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
@@ -123,7 +123,7 @@ public final class StringConcatFactory {
* Concatenation strategy to use. See {@link Strategy} for possible options.
* This option is controllable with -Djava.lang.invoke.stringConcat JDK option.
*/
- private static final Strategy STRATEGY;
+ private static Strategy STRATEGY;
/**
* Default strategy to use for concatenation.
@@ -187,6 +187,16 @@ public final class StringConcatFactory {
private static final ProxyClassesDumper DUMPER;
static {
+ // In case we need to double-back onto the StringConcatFactory during this
+ // static initialization, make sure we have the reasonable defaults to complete
+ // the static initialization properly. After that, actual users would use the
+ // the proper values we have read from the the properties.
+ STRATEGY = DEFAULT_STRATEGY;
+ // CACHE_ENABLE = false; // implied
+ // CACHE = null; // implied
+ // DEBUG = false; // implied
+ // DUMPER = null; // implied
+
Properties props = GetPropertyAction.getProperties();
final String strategy =
props.getProperty("java.lang.invoke.stringConcat");
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
index cf869b3ebe7..4eb7f260a6c 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
@@ -136,6 +136,7 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
* consists of the methods
* {@link #compareAndSet compareAndSet},
* {@link #weakCompareAndSet weakCompareAndSet},
+ * {@link #weakCompareAndSetVolatile weakCompareAndSetVolatile},
* {@link #weakCompareAndSetAcquire weakCompareAndSetAcquire},
* {@link #weakCompareAndSetRelease weakCompareAndSetRelease},
* {@link #compareAndExchangeAcquire compareAndExchangeAcquire},
@@ -458,7 +459,7 @@ public abstract class VarHandle {
*
* The symbolic type descriptor at the call site of {@code get}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.get)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET)} on this VarHandle.
*
*
This access mode is supported by all VarHandle instances and never
* throws {@code UnsupportedOperationException}.
@@ -488,7 +489,7 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code set}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.set)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.SET)} on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T newValue)}
@@ -516,7 +517,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getVolatile}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getVolatile)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_VOLATILE)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT)}
@@ -544,7 +546,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code setVolatile}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.setVolatile)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.SET_VOLATILE)} on this
+ * VarHandle.
*
* @apiNote
* Ignoring the many semantic differences from C and C++, this method has
@@ -574,7 +577,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getOpaque}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getOpaque)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_OPAQUE)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT)}
@@ -603,7 +607,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code setOpaque}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.setOpaque)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.SET_OPAQUE)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T newValue)}
@@ -631,7 +636,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getAcquire}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getAcquire)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_ACQUIRE)} on this
+ * VarHandle.
*
* @apiNote
* Ignoring the many semantic differences from C and C++, this method has
@@ -664,7 +670,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code setRelease}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.setRelease)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.SET_RELEASE)} on this
+ * VarHandle.
*
* @apiNote
* Ignoring the many semantic differences from C and C++, this method has
@@ -700,7 +707,7 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code
* compareAndSet} must match the access mode type that is the result of
- * calling {@code accessModeType(VarHandle.AccessMode.compareAndSet)} on
+ * calling {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_SET)} on
* this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
@@ -734,7 +741,7 @@ public abstract class VarHandle {
*
The symbolic type descriptor at the call site of {@code
* compareAndExchangeVolatile}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeVolatile)}
+ * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE)}
* on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
@@ -769,7 +776,7 @@ public abstract class VarHandle {
*
The symbolic type descriptor at the call site of {@code
* compareAndExchangeAcquire}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeAcquire)} on
+ * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)} on
* this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
@@ -804,7 +811,8 @@ public abstract class VarHandle {
*
The symbolic type descriptor at the call site of {@code
* compareAndExchangeRelease}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeRelease)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)}
+ * on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T expectedValue, T newValue)}
@@ -836,14 +844,14 @@ public abstract class VarHandle {
* {@link #get}.
*
*
This operation may fail spuriously (typically, due to memory
- * contention) even if the current value does match the expected value.
+ * contention) even if the witness value does match the expected value.
*
*
The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
*
*
The symbolic type descriptor at the call site of {@code
* weakCompareAndSet} must match the access mode type that is the result of
- * calling {@code accessModeType(VarHandle.AccessMode.weakCompareAndSet)} on
- * this VarHandle.
+ * calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)}
+ * on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T expectedValue, T newValue)}
@@ -865,6 +873,43 @@ public abstract class VarHandle {
@HotSpotIntrinsicCandidate
boolean weakCompareAndSet(Object... args);
+ /**
+ * Possibly atomically sets the value of a variable to the {@code newValue}
+ * with the memory semantics of {@link #setVolatile} if the variable's
+ * current value, referred to as the witness value, {@code ==} the
+ * {@code expectedValue}, as accessed with the memory semantics of
+ * {@link #getVolatile}.
+ *
+ *
This operation may fail spuriously (typically, due to memory
+ * contention) even if the witness value does match the expected value.
+ *
+ *
The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
+ *
+ *
The symbolic type descriptor at the call site of {@code
+ * weakCompareAndSetVolatile} must match the access mode type that is the
+ * result of calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)}
+ * on this VarHandle.
+ *
+ * @param args the signature-polymorphic parameter list of the form
+ * {@code (CT, T expectedValue, T newValue)}
+ * , statically represented using varargs.
+ * @return {@code true} if successful, otherwise {@code false} if the
+ * witness value was not the same as the {@code expectedValue} or if this
+ * operation spuriously failed.
+ * @throws UnsupportedOperationException if the access mode is unsupported
+ * for this VarHandle.
+ * @throws WrongMethodTypeException if the access mode type is not
+ * compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
+ * @see #setVolatile(Object...)
+ * @see #getVolatile(Object...)
+ */
+ public final native
+ @MethodHandle.PolymorphicSignature
+ @HotSpotIntrinsicCandidate
+ boolean weakCompareAndSetVolatile(Object... args);
+
/**
* Possibly atomically sets the value of a variable to the {@code newValue}
* with the semantics of {@link #set} if the variable's current value,
@@ -873,14 +918,15 @@ public abstract class VarHandle {
* {@link #getAcquire}.
*
*
This operation may fail spuriously (typically, due to memory
- * contention) even if the current value does match the expected value.
+ * contention) even if the witness value does match the expected value.
*
*
The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
*
*
The symbolic type descriptor at the call site of {@code
* weakCompareAndSetAcquire}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.weakCompareAndSetAcquire)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)}
+ * on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T expectedValue, T newValue)}
@@ -910,14 +956,15 @@ public abstract class VarHandle {
* {@link #get}.
*
*
This operation may fail spuriously (typically, due to memory
- * contention) even if the current value does match the expected value.
+ * contention) even if the witness value does match the expected value.
*
*
The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
*
*
The symbolic type descriptor at the call site of {@code
* weakCompareAndSetRelease}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.weakCompareAndSetRelease)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)}
+ * on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T expectedValue, T newValue)}
@@ -949,7 +996,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getAndSet}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getAndSet)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T newValue)}
@@ -985,7 +1033,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getAndAdd}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getAndAdd)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T value)}
@@ -1017,7 +1066,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code addAndGet}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.addAndGet)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.ADD_AND_GET)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T value)}
@@ -1083,109 +1133,115 @@ public abstract class VarHandle {
* method
* {@link VarHandle#get VarHandle.get}
*/
- GET("get", AccessType.GET, Object.class), // 0
+ GET("get", AccessType.GET, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#set VarHandle.set}
*/
- SET("set", AccessType.SET, void.class), // 1
+ SET("set", AccessType.SET, void.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getVolatile VarHandle.getVolatile}
*/
- GET_VOLATILE("getVolatile", AccessType.GET, Object.class), // 2
+ GET_VOLATILE("getVolatile", AccessType.GET, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setVolatile VarHandle.setVolatile}
*/
- SET_VOLATILE("setVolatile", AccessType.SET, void.class), // 3
+ SET_VOLATILE("setVolatile", AccessType.SET, void.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAcquire VarHandle.getAcquire}
*/
- GET_ACQUIRE("getAcquire", AccessType.GET, Object.class), // 4
+ GET_ACQUIRE("getAcquire", AccessType.GET, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setRelease VarHandle.setRelease}
*/
- SET_RELEASE("setRelease", AccessType.SET, void.class), // 5
+ SET_RELEASE("setRelease", AccessType.SET, void.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getOpaque VarHandle.getOpaque}
*/
- GET_OPAQUE("getOpaque", AccessType.GET, Object.class), // 6
+ GET_OPAQUE("getOpaque", AccessType.GET, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setOpaque VarHandle.setOpaque}
*/
- SET_OPAQUE("setOpaque", AccessType.SET, void.class), // 7
+ SET_OPAQUE("setOpaque", AccessType.SET, void.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndSet VarHandle.compareAndSet}
*/
- COMPARE_AND_SET("compareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class), // 8
+ COMPARE_AND_SET("compareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeVolatile VarHandle.compareAndExchangeVolatile}
*/
- COMPARE_AND_EXCHANGE_VOLATILE("compareAndExchangeVolatile", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 9
+ COMPARE_AND_EXCHANGE_VOLATILE("compareAndExchangeVolatile", AccessType.COMPARE_AND_EXCHANGE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeAcquire VarHandle.compareAndExchangeAcquire}
*/
- COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 10
+ COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeRelease VarHandle.compareAndExchangeRelease}
*/
- COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 11
+ COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet}
*/
- WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class), // 12
+ WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class),
+ /**
+ * The access mode whose access is specified by the corresponding
+ * method
+ * {@link VarHandle#weakCompareAndSetVolatile VarHandle.weakCompareAndSetVolatile}
+ */
+ WEAK_COMPARE_AND_SET_VOLATILE("weakCompareAndSetVolatile", AccessType.COMPARE_AND_SWAP, boolean.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSetAcquire VarHandle.weakCompareAndSetAcquire}
*/
- WEAK_COMPARE_AND_SET_ACQUIRE("weakCompareAndSetAcquire", AccessType.COMPARE_AND_SWAP, boolean.class), // 13
+ WEAK_COMPARE_AND_SET_ACQUIRE("weakCompareAndSetAcquire", AccessType.COMPARE_AND_SWAP, boolean.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSetRelease VarHandle.weakCompareAndSetRelease}
*/
- WEAK_COMPARE_AND_SET_RELEASE("weakCompareAndSetRelease", AccessType.COMPARE_AND_SWAP, boolean.class), // 14
+ WEAK_COMPARE_AND_SET_RELEASE("weakCompareAndSetRelease", AccessType.COMPARE_AND_SWAP, boolean.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAndSet VarHandle.getAndSet}
*/
- GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE, Object.class), // 15
+ GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAndAdd VarHandle.getAndAdd}
*/
- GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE, Object.class), // 16
+ GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#addAndGet VarHandle.addAndGet}
*/
- ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE, Object.class), // 17
+ ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE, Object.class),
;
static final Map methodNameToAccessMode;
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
index bcec64bd390..4a9d9e11e36 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
@@ -154,6 +154,15 @@ final class VarHandle$Type$s {
{#if[Object]?handle.fieldType.cast(value):value});
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+ handle.fieldOffset,
+ {#if[Object]?handle.fieldType.cast(expected):expected},
+ {#if[Object]?handle.fieldType.cast(value):value});
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
return UNSAFE.weakCompareAndSwap$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
@@ -318,6 +327,15 @@ final class VarHandle$Type$s {
{#if[Object]?handle.fieldType.cast(value):value});
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$Type$(handle.base,
+ handle.fieldOffset,
+ {#if[Object]?handle.fieldType.cast(expected):expected},
+ {#if[Object]?handle.fieldType.cast(value):value});
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
return UNSAFE.weakCompareAndSwap$Type$Acquire(handle.base,
@@ -534,6 +552,20 @@ final class VarHandle$Type$s {
{#if[Object]?handle.componentType.cast(value):value});
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
+#if[Object]
+ Object[] array = (Object[]) handle.arrayType.cast(oarray);
+#else[Object]
+ $type$[] array = ($type$[]) oarray;
+#end[Object]
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$Type$(array,
+ (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+ {#if[Object]?handle.componentType.cast(expected):expected},
+ {#if[Object]?handle.componentType.cast(value):value});
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
#if[Object]
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
index bdc77a820d2..b5bf9cba232 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
@@ -227,6 +227,16 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
convEndian(handle.be, expected), convEndian(handle.be, value));
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
+ byte[] ba = (byte[]) oba;
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$RawType$(
+ ba,
+ address(ba, index(ba, index)),
+ convEndian(handle.be, expected), convEndian(handle.be, value));
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
byte[] ba = (byte[]) oba;
@@ -443,6 +453,16 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
convEndian(handle.be, expected), convEndian(handle.be, value));
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
+ ByteBuffer bb = (ByteBuffer) obb;
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$RawType$(
+ UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+ address(bb, indexRO(bb, index)),
+ convEndian(handle.be, expected), convEndian(handle.be, value));
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
ByteBuffer bb = (ByteBuffer) obb;
diff --git a/jdk/src/java.base/share/classes/java/util/Arrays.java b/jdk/src/java.base/share/classes/java/util/Arrays.java
index cc7b19de64e..6d7e858fbed 100644
--- a/jdk/src/java.base/share/classes/java/util/Arrays.java
+++ b/jdk/src/java.base/share/classes/java/util/Arrays.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, 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
@@ -4403,6 +4403,35 @@ public class Arrays {
public void sort(Comparator super E> c) {
Arrays.sort(a, c);
}
+
+ @Override
+ public Iterator iterator() {
+ return new ArrayItr<>(a);
+ }
+ }
+
+ private static class ArrayItr implements Iterator {
+ private int cursor;
+ private final E[] a;
+
+ ArrayItr(E[] a) {
+ this.a = a;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return cursor < a.length;
+ }
+
+ @Override
+ public E next() {
+ int i = cursor;
+ if (i >= a.length) {
+ throw new NoSuchElementException();
+ }
+ cursor = i + 1;
+ return a[i];
+ }
}
/**
diff --git a/jdk/src/java.base/share/classes/java/util/Observable.java b/jdk/src/java.base/share/classes/java/util/Observable.java
index cff9e1f4d7b..b19830bb64e 100644
--- a/jdk/src/java.base/share/classes/java/util/Observable.java
+++ b/jdk/src/java.base/share/classes/java/util/Observable.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2012, 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
@@ -58,7 +58,19 @@ package java.util;
* @see java.util.Observer
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
* @since 1.0
+ *
+ * @deprecated
+ * This class and the {@link Observer} interface have been deprecated.
+ * The event model supported by {@code Observer} and {@code Observable}
+ * is quite limited, the order of notifications delivered by
+ * {@code Observable} is unspecified, and state changes are not in
+ * one-for-one correspondence with notifications.
+ * For a richer event model, consider using the
+ * {@link java.beans} package. For reliable and ordered
+ * messaging among threads, consider using one of the concurrent data
+ * structures in the {@link java.util.concurrent} package.
*/
+@Deprecated(since="9")
public class Observable {
private boolean changed = false;
private Vector obs;
diff --git a/jdk/src/java.base/share/classes/java/util/Observer.java b/jdk/src/java.base/share/classes/java/util/Observer.java
index 2db27b44a2d..47f793376ab 100644
--- a/jdk/src/java.base/share/classes/java/util/Observer.java
+++ b/jdk/src/java.base/share/classes/java/util/Observer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 1998, 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
@@ -31,7 +31,12 @@ package java.util;
* @author Chris Warth
* @see java.util.Observable
* @since 1.0
+ *
+ * @deprecated
+ * This interface has been deprecated. See the {@link Observable}
+ * class for further information.
*/
+@Deprecated(since="9")
public interface Observer {
/**
* This method is called whenever the observed object is changed. An
diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java b/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java
index 56a5f57cc57..199a3d37f6a 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -167,6 +167,19 @@ abstract class DoublePipeline
return Nodes.doubleBuilder(exactSizeIfKnown);
}
+ private Stream mapToObj(DoubleFunction extends U> mapper, int opFlags) {
+ return new ReferencePipeline.StatelessOp(this, StreamShape.DOUBLE_VALUE, opFlags) {
+ @Override
+ Sink opWrapSink(int flags, Sink sink) {
+ return new Sink.ChainedDouble(sink) {
+ @Override
+ public void accept(double t) {
+ downstream.accept(mapper.apply(t));
+ }
+ };
+ }
+ };
+ }
// DoubleStream
@@ -184,7 +197,7 @@ abstract class DoublePipeline
@Override
public final Stream boxed() {
- return mapToObj(Double::valueOf);
+ return mapToObj(Double::valueOf, 0);
}
@Override
@@ -207,18 +220,7 @@ abstract class DoublePipeline
@Override
public final Stream mapToObj(DoubleFunction extends U> mapper) {
Objects.requireNonNull(mapper);
- return new ReferencePipeline.StatelessOp(this, StreamShape.DOUBLE_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
- @Override
- Sink opWrapSink(int flags, Sink sink) {
- return new Sink.ChainedDouble(sink) {
- @Override
- public void accept(double t) {
- downstream.accept(mapper.apply(t));
- }
- };
- }
- };
+ return mapToObj(mapper, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT);
}
@Override
diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java b/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java
index 7cf0622ce89..fe7bac59b6e 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.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
@@ -170,6 +170,19 @@ abstract class IntPipeline
return Nodes.intBuilder(exactSizeIfKnown);
}
+ private Stream mapToObj(IntFunction extends U> mapper, int opFlags) {
+ return new ReferencePipeline.StatelessOp(this, StreamShape.INT_VALUE, opFlags) {
+ @Override
+ Sink opWrapSink(int flags, Sink sink) {
+ return new Sink.ChainedInt(sink) {
+ @Override
+ public void accept(int t) {
+ downstream.accept(mapper.apply(t));
+ }
+ };
+ }
+ };
+ }
// IntStream
@@ -187,8 +200,7 @@ abstract class IntPipeline
@Override
public final LongStream asLongStream() {
- return new LongPipeline.StatelessOp(this, StreamShape.INT_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
+ return new LongPipeline.StatelessOp(this, StreamShape.INT_VALUE, 0) {
@Override
Sink opWrapSink(int flags, Sink sink) {
return new Sink.ChainedInt(sink) {
@@ -203,8 +215,7 @@ abstract class IntPipeline
@Override
public final DoubleStream asDoubleStream() {
- return new DoublePipeline.StatelessOp(this, StreamShape.INT_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
+ return new DoublePipeline.StatelessOp(this, StreamShape.INT_VALUE, 0) {
@Override
Sink opWrapSink(int flags, Sink sink) {
return new Sink.ChainedInt(sink) {
@@ -219,7 +230,7 @@ abstract class IntPipeline
@Override
public final Stream boxed() {
- return mapToObj(Integer::valueOf);
+ return mapToObj(Integer::valueOf, 0);
}
@Override
@@ -242,18 +253,7 @@ abstract class IntPipeline
@Override
public final Stream mapToObj(IntFunction extends U> mapper) {
Objects.requireNonNull(mapper);
- return new ReferencePipeline.StatelessOp(this, StreamShape.INT_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
- @Override
- Sink opWrapSink(int flags, Sink sink) {
- return new Sink.ChainedInt(sink) {
- @Override
- public void accept(int t) {
- downstream.accept(mapper.apply(t));
- }
- };
- }
- };
+ return mapToObj(mapper, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT);
}
@Override
diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java b/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java
index 19097b7e630..0d70b9707ca 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -167,6 +167,19 @@ abstract class LongPipeline
return Nodes.longBuilder(exactSizeIfKnown);
}
+ private Stream mapToObj(LongFunction extends U> mapper, int opFlags) {
+ return new ReferencePipeline.StatelessOp(this, StreamShape.LONG_VALUE, opFlags) {
+ @Override
+ Sink opWrapSink(int flags, Sink sink) {
+ return new Sink.ChainedLong(sink) {
+ @Override
+ public void accept(long t) {
+ downstream.accept(mapper.apply(t));
+ }
+ };
+ }
+ };
+ }
// LongStream
@@ -184,8 +197,7 @@ abstract class LongPipeline
@Override
public final DoubleStream asDoubleStream() {
- return new DoublePipeline.StatelessOp(this, StreamShape.LONG_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
+ return new DoublePipeline.StatelessOp(this, StreamShape.LONG_VALUE, StreamOpFlag.NOT_DISTINCT) {
@Override
Sink opWrapSink(int flags, Sink sink) {
return new Sink.ChainedLong(sink) {
@@ -200,7 +212,7 @@ abstract class LongPipeline
@Override
public final Stream boxed() {
- return mapToObj(Long::valueOf);
+ return mapToObj(Long::valueOf, 0);
}
@Override
@@ -223,18 +235,7 @@ abstract class LongPipeline
@Override
public final Stream mapToObj(LongFunction extends U> mapper) {
Objects.requireNonNull(mapper);
- return new ReferencePipeline.StatelessOp(this, StreamShape.LONG_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
- @Override
- Sink opWrapSink(int flags, Sink sink) {
- return new Sink.ChainedLong(sink) {
- @Override
- public void accept(long t) {
- downstream.accept(mapper.apply(t));
- }
- };
- }
- };
+ return mapToObj(mapper, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT);
}
@Override
diff --git a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
index 7e8d81150a8..cb92b2ebfad 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
@@ -28,6 +28,7 @@ import java.util.Comparator;
import java.util.Objects;
import java.util.Spliterator;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
@@ -905,6 +906,7 @@ class StreamSpliterators {
// The spliterator to slice
protected final T_SPLITR s;
protected final boolean unlimited;
+ protected final int chunkSize;
private final long skipThreshold;
private final AtomicLong permits;
@@ -912,6 +914,8 @@ class StreamSpliterators {
this.s = s;
this.unlimited = limit < 0;
this.skipThreshold = limit >= 0 ? limit : 0;
+ this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE,
+ ((skip + limit) / AbstractTask.LEAF_TARGET) + 1) : CHUNK_SIZE;
this.permits = new AtomicLong(limit >= 0 ? skip + limit : skip);
}
@@ -921,6 +925,7 @@ class StreamSpliterators {
this.unlimited = parent.unlimited;
this.permits = parent.permits;
this.skipThreshold = parent.skipThreshold;
+ this.chunkSize = parent.chunkSize;
}
/**
@@ -1029,13 +1034,13 @@ class StreamSpliterators {
PermitStatus permitStatus;
while ((permitStatus = permitStatus()) != PermitStatus.NO_MORE) {
if (permitStatus == PermitStatus.MAYBE_MORE) {
- // Optimistically traverse elements up to a threshold of CHUNK_SIZE
+ // Optimistically traverse elements up to a threshold of chunkSize
if (sb == null)
- sb = new ArrayBuffer.OfRef<>(CHUNK_SIZE);
+ sb = new ArrayBuffer.OfRef<>(chunkSize);
else
sb.reset();
long permitsRequested = 0;
- do { } while (s.tryAdvance(sb) && ++permitsRequested < CHUNK_SIZE);
+ do { } while (s.tryAdvance(sb) && ++permitsRequested < chunkSize);
if (permitsRequested == 0)
return;
sb.forEach(action, acquirePermits(permitsRequested));
@@ -1102,15 +1107,15 @@ class StreamSpliterators {
PermitStatus permitStatus;
while ((permitStatus = permitStatus()) != PermitStatus.NO_MORE) {
if (permitStatus == PermitStatus.MAYBE_MORE) {
- // Optimistically traverse elements up to a threshold of CHUNK_SIZE
+ // Optimistically traverse elements up to a threshold of chunkSize
if (sb == null)
- sb = bufferCreate(CHUNK_SIZE);
+ sb = bufferCreate(chunkSize);
else
sb.reset();
@SuppressWarnings("unchecked")
T_CONS sbc = (T_CONS) sb;
long permitsRequested = 0;
- do { } while (s.tryAdvance(sbc) && ++permitsRequested < CHUNK_SIZE);
+ do { } while (s.tryAdvance(sbc) && ++permitsRequested < chunkSize);
if (permitsRequested == 0)
return;
sb.forEach(action, acquirePermits(permitsRequested));
diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
index da255a3e2b8..e24fcad2bd4 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
@@ -33,6 +33,9 @@ import java.util.function.Function;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.ref.ReferenceQueue;
+import java.lang.reflect.Module;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.ResourceBundle;
@@ -129,41 +132,49 @@ public class DefaultLoggerFinder extends LoggerFinder {
return w;
}
-
final static SharedLoggers system = new SharedLoggers();
final static SharedLoggers application = new SharedLoggers();
}
+ public static boolean isSystem(Module m) {
+ ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<>() {
+ @Override
+ public ClassLoader run() {
+ return m.getClassLoader();
+ }
+ });
+ return cl == null;
+ }
+
@Override
- public final Logger getLogger(String name, /* Module */ Class> caller) {
+ public final Logger getLogger(String name, Module module) {
checkPermission();
- return demandLoggerFor(name, caller);
+ return demandLoggerFor(name, module);
}
@Override
public final Logger getLocalizedLogger(String name, ResourceBundle bundle,
- /* Module */ Class> caller) {
- return super.getLocalizedLogger(name, bundle, caller);
+ Module module) {
+ return super.getLocalizedLogger(name, bundle, module);
}
-
-
/**
- * Returns a {@link Logger logger} suitable for the caller usage.
+ * Returns a {@link Logger logger} suitable for use within the
+ * given {@code module}.
*
* @implSpec The default implementation for this method is to return a
* simple logger that will print all messages of INFO level and above
* to the console. That simple logger is not configurable.
*
* @param name The name of the logger.
- * @param caller The class on behalf of which the logger is created.
+ * @param module The module on behalf of which the logger is created.
* @return A {@link Logger logger} suitable for the application usage.
* @throws SecurityException if the calling code does not have the
* {@code RuntimePermission("loggerFinder")}.
*/
- protected Logger demandLoggerFor(String name, /* Module */ Class> caller) {
+ protected Logger demandLoggerFor(String name, Module module) {
checkPermission();
- if (caller.getClassLoader() == null) {
+ if (isSystem(module)) {
return SharedLoggers.system.get(SimpleConsoleLogger::makeSimpleLogger, name);
} else {
return SharedLoggers.application.get(SimpleConsoleLogger::makeSimpleLogger, name);
diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
index 04b64ea98b1..6c65426ca8e 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
@@ -31,6 +31,7 @@ import java.util.function.BiFunction;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.ref.WeakReference;
+import java.lang.reflect.Module;
import java.util.Objects;
import jdk.internal.misc.VM;
import sun.util.logging.PlatformLogger;
@@ -59,15 +60,15 @@ public final class LazyLoggers {
* A factory method to create an SPI logger.
* Usually, this will be something like LazyLoggers::getSystemLogger.
*/
- final BiFunction, L> loggerSupplier;
+ final BiFunction loggerSupplier;
- public LazyLoggerFactories(BiFunction, L> loggerSupplier) {
+ public LazyLoggerFactories(BiFunction loggerSupplier) {
this(Objects.requireNonNull(loggerSupplier),
(Void)null);
}
- private LazyLoggerFactories(BiFunction, L> loggerSupplier,
+ private LazyLoggerFactories(BiFunction loggerSupplier,
Void unused) {
this.loggerSupplier = loggerSupplier;
}
@@ -107,8 +108,8 @@ public final class LazyLoggers {
// The factories that will be used to create the logger lazyly
final LazyLoggerFactories extends Logger> factories;
- // We need to pass the actual caller when creating the logger.
- private final WeakReference> callerRef;
+ // We need to pass the actual caller module when creating the logger.
+ private final WeakReference moduleRef;
// The name of the logger that will be created lazyly
final String name;
@@ -121,17 +122,17 @@ public final class LazyLoggers {
private LazyLoggerAccessor(String name,
LazyLoggerFactories extends Logger> factories,
- Class> caller) {
+ Module module) {
this(Objects.requireNonNull(name), Objects.requireNonNull(factories),
- Objects.requireNonNull(caller), null);
+ Objects.requireNonNull(module), null);
}
private LazyLoggerAccessor(String name,
LazyLoggerFactories extends Logger> factories,
- Class> caller, Void unused) {
+ Module module, Void unused) {
this.name = name;
this.factories = factories;
- this.callerRef = new WeakReference>(caller);
+ this.moduleRef = new WeakReference<>(module);
}
/**
@@ -270,12 +271,12 @@ public final class LazyLoggers {
// Creates the wrapped logger by invoking the SPI.
Logger createLogger() {
- final Class> caller = callerRef.get();
- if (caller == null) {
- throw new IllegalStateException("The class for which this logger"
+ final Module module = moduleRef.get();
+ if (module == null) {
+ throw new IllegalStateException("The module for which this logger"
+ " was created has been garbage collected");
}
- return this.factories.loggerSupplier.apply(name, caller);
+ return this.factories.loggerSupplier.apply(name, module);
}
/**
@@ -289,8 +290,8 @@ public final class LazyLoggers {
* @return A new LazyLoggerAccessor.
*/
public static LazyLoggerAccessor makeAccessor(String name,
- LazyLoggerFactories extends Logger> factories, Class> caller) {
- return new LazyLoggerAccessor(name, factories, caller);
+ LazyLoggerFactories extends Logger> factories, Module module) {
+ return new LazyLoggerAccessor(name, factories, module);
}
}
@@ -346,11 +347,11 @@ public final class LazyLoggers {
// Avoid using lambda here as lazy loggers could be created early
// in the bootstrap sequence...
- private static final BiFunction, Logger> loggerSupplier =
+ private static final BiFunction loggerSupplier =
new BiFunction<>() {
@Override
- public Logger apply(String name, Class> caller) {
- return LazyLoggers.getLoggerFromFinder(name, caller);
+ public Logger apply(String name, Module module) {
+ return LazyLoggers.getLoggerFromFinder(name, module);
}
};
@@ -367,8 +368,8 @@ public final class LazyLoggers {
// logger provider until the VM has finished booting.
//
private static final class JdkLazyLogger extends LazyLoggerWrapper {
- JdkLazyLogger(String name, Class> caller) {
- this(LazyLoggerAccessor.makeAccessor(name, factories, caller),
+ JdkLazyLogger(String name, Module module) {
+ this(LazyLoggerAccessor.makeAccessor(name, factories, module),
(Void)null);
}
private JdkLazyLogger(LazyLoggerAccessor holder, Void unused) {
@@ -380,16 +381,16 @@ public final class LazyLoggers {
* Gets a logger from the LoggerFinder. Creates the actual concrete
* logger.
* @param name name of the logger
- * @param caller class on behalf of which the logger is created
+ * @param module module on behalf of which the logger is created
* @return The logger returned by the LoggerFinder.
*/
- static Logger getLoggerFromFinder(String name, Class> caller) {
+ static Logger getLoggerFromFinder(String name, Module module) {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
- return accessLoggerFinder().getLogger(name, caller);
+ return accessLoggerFinder().getLogger(name, module);
} else {
return AccessController.doPrivileged((PrivilegedAction)
- () -> {return accessLoggerFinder().getLogger(name, caller);},
+ () -> {return accessLoggerFinder().getLogger(name, module);},
null, LOGGERFINDER_PERMISSION);
}
}
@@ -398,22 +399,22 @@ public final class LazyLoggers {
* Returns a (possibly lazy) Logger for the caller.
*
* @param name the logger name
- * @param caller The class on behalf of which the logger is created.
- * If the caller is not loaded from the Boot ClassLoader,
+ * @param module The module on behalf of which the logger is created.
+ * If the module is not loaded from the Boot ClassLoader,
* the LoggerFinder is accessed and the logger returned
- * by {@link LoggerFinder#getLogger(java.lang.String, java.lang.Class)}
+ * by {@link LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)}
* is returned to the caller directly.
* Otherwise, the logger returned by
- * {@link #getLazyLogger(java.lang.String, java.lang.Class)}
+ * {@link #getLazyLogger(java.lang.String, java.lang.reflect.Module)}
* is returned to the caller.
*
* @return a (possibly lazy) Logger instance.
*/
- public static final Logger getLogger(String name, Class> caller) {
- if (caller.getClassLoader() == null) {
- return getLazyLogger(name, caller);
+ public static final Logger getLogger(String name, Module module) {
+ if (DefaultLoggerFinder.isSystem(module)) {
+ return getLazyLogger(name, module);
} else {
- return getLoggerFromFinder(name, caller);
+ return getLoggerFromFinder(name, module);
}
}
@@ -423,10 +424,10 @@ public final class LazyLoggers {
* returned by {@link BootstrapLogger#useLazyLoggers()}.
*
* @param name the logger name
- * @param caller the class on behalf of which the logger is created.
+ * @param module the module on behalf of which the logger is created.
* @return a (possibly lazy) Logger instance.
*/
- public static final Logger getLazyLogger(String name, Class> caller) {
+ public static final Logger getLazyLogger(String name, Module module) {
// BootstrapLogger has the logic to determine whether a LazyLogger
// should be used. Usually, it is worth it only if:
@@ -438,10 +439,10 @@ public final class LazyLoggers {
// configuration, we're not going to delay the creation of loggers...
final boolean useLazyLogger = BootstrapLogger.useLazyLoggers();
if (useLazyLogger) {
- return new JdkLazyLogger(name, caller);
+ return new JdkLazyLogger(name, module);
} else {
// Directly invoke the LoggerFinder.
- return getLoggerFromFinder(name, caller);
+ return getLoggerFromFinder(name, module);
}
}
diff --git a/jdk/src/java.base/share/classes/jdk/net/ExtendedSocketOptions.java b/jdk/src/java.base/share/classes/jdk/net/ExtendedSocketOptions.java
deleted file mode 100644
index 12af5aff7ee..00000000000
--- a/jdk/src/java.base/share/classes/jdk/net/ExtendedSocketOptions.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2014, 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 jdk.net;
-
-import java.net.SocketOption;
-
-/**
- * Defines extended socket options, beyond those defined in
- * {@link java.net.StandardSocketOptions}. These options may be platform
- * specific.
- *
- * @since 1.8
- */
-public final class ExtendedSocketOptions {
-
- private static class ExtSocketOption implements SocketOption {
- private final String name;
- private final Class type;
- ExtSocketOption(String name, Class type) {
- this.name = name;
- this.type = type;
- }
- @Override public String name() { return name; }
- @Override public Class type() { return type; }
- @Override public String toString() { return name; }
- }
-
- private ExtendedSocketOptions() {}
-
- /**
- * Service level properties. When a security manager is installed,
- * setting or getting this option requires a {@link NetworkPermission}
- * {@code ("setOption.SO_FLOW_SLA")} or {@code "getOption.SO_FLOW_SLA"}
- * respectively.
- */
- public static final SocketOption SO_FLOW_SLA = new
- ExtSocketOption("SO_FLOW_SLA", SocketFlow.class);
-}
diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java
index 942c0582ea0..a597253d168 100644
--- a/jdk/src/java.base/share/classes/module-info.java
+++ b/jdk/src/java.base/share/classes/module-info.java
@@ -83,8 +83,6 @@ module java.base {
// see JDK-8144062
exports jdk;
- // see JDK-8044773
- exports jdk.net;
// the service types defined by the APIs in this module
@@ -168,6 +166,7 @@ module java.base {
java.sql,
java.xml,
jdk.charsets,
+ jdk.net,
jdk.scripting.nashorn,
jdk.unsupported,
jdk.vm.ci;
@@ -194,6 +193,8 @@ module java.base {
jdk.jvmstat;
exports sun.net to
java.httpclient;
+ exports sun.net.ext to
+ jdk.net;
exports sun.net.dns to
java.security.jgss,
jdk.naming.dns;
diff --git a/jdk/src/java.base/share/classes/sun/net/ExtendedOptionsImpl.java b/jdk/src/java.base/share/classes/sun/net/ExtendedOptionsImpl.java
deleted file mode 100644
index 8fbcdd7b49d..00000000000
--- a/jdk/src/java.base/share/classes/sun/net/ExtendedOptionsImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2014, 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.net;
-
-import java.net.*;
-import jdk.net.*;
-import java.io.IOException;
-import java.io.FileDescriptor;
-import java.security.PrivilegedAction;
-import java.security.AccessController;
-import java.lang.reflect.Field;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Collections;
-
-/**
- * Contains the native implementation for extended socket options
- * together with some other static utilities
- */
-public class ExtendedOptionsImpl {
-
- static {
- AccessController.doPrivileged((PrivilegedAction)() -> {
- System.loadLibrary("net");
- return null;
- });
- init();
- }
-
- private ExtendedOptionsImpl() {}
-
- public static void checkSetOptionPermission(SocketOption> option) {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null) {
- return;
- }
- String check = "setOption." + option.name();
- sm.checkPermission(new NetworkPermission(check));
- }
-
- public static void checkGetOptionPermission(SocketOption> option) {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null) {
- return;
- }
- String check = "getOption." + option.name();
- sm.checkPermission(new NetworkPermission(check));
- }
-
- public static void checkValueType(Object value, Class> type) {
- if (!type.isAssignableFrom(value.getClass())) {
- String s = "Found: " + value.getClass().toString() + " Expected: "
- + type.toString();
- throw new IllegalArgumentException(s);
- }
- }
-
- private static native void init();
-
- /*
- * Extension native implementations
- *
- * SO_FLOW_SLA
- */
- public static native void setFlowOption(FileDescriptor fd, SocketFlow f);
- public static native void getFlowOption(FileDescriptor fd, SocketFlow f);
- public static native boolean flowSupported();
-}
diff --git a/jdk/src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java b/jdk/src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java
new file mode 100644
index 00000000000..a3300c3c0e9
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java
@@ -0,0 +1,110 @@
+/*
+ * 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.net.ext;
+
+import java.io.FileDescriptor;
+import java.net.SocketException;
+import java.net.SocketOption;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * Defines the infrastructure to support extended socket options, beyond those
+ * defined in {@link java.net.StandardSocketOptions}.
+ *
+ * Extended socket options are accessed through the jdk.net API, which is in
+ * the jdk.net module.
+ */
+public abstract class ExtendedSocketOptions {
+
+ private final Set> options;
+
+ /** Tells whether or not the option is supported. */
+ public final boolean isOptionSupported(SocketOption> option) {
+ return options().contains(option);
+ }
+
+ /** Return the, possibly empty, set of extended socket options available. */
+ public final Set> options() { return options; }
+
+ /** Sets the value of a socket option, for the given socket. */
+ public abstract void setOption(FileDescriptor fd, SocketOption> option, Object value)
+ throws SocketException;
+
+ /** Returns the value of a socket option, for the given socket. */
+ public abstract Object getOption(FileDescriptor fd, SocketOption> option)
+ throws SocketException;
+
+ protected ExtendedSocketOptions(Set> options) {
+ this.options = options;
+ }
+
+ private static volatile ExtendedSocketOptions instance;
+
+ public static final ExtendedSocketOptions getInstance() { return instance; }
+
+ /** Registers support for extended socket options. Invoked by the jdk.net module. */
+ public static final void register(ExtendedSocketOptions extOptions) {
+ if (instance != null)
+ throw new InternalError("Attempting to reregister extended options");
+
+ instance = extOptions;
+ }
+
+ static {
+ try {
+ // If the class is present, it will be initialized which
+ // triggers registration of the extended socket options.
+ Class> c = Class.forName("jdk.net.ExtendedSocketOptions");
+ } catch (ClassNotFoundException e) {
+ // the jdk.net module is not present => no extended socket options
+ instance = new NoExtendedSocketOptions();
+ }
+ }
+
+ static final class NoExtendedSocketOptions extends ExtendedSocketOptions {
+
+ NoExtendedSocketOptions() {
+ super(Collections.>emptySet());
+ }
+
+ @Override
+ public void setOption(FileDescriptor fd, SocketOption> option, Object value)
+ throws SocketException
+ {
+ throw new UnsupportedOperationException(
+ "no extended options: " + option.name());
+ }
+
+ @Override
+ public Object getOption(FileDescriptor fd, SocketOption> option)
+ throws SocketException
+ {
+ throw new UnsupportedOperationException(
+ "no extended options: " + option.name());
+ }
+ }
+}
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java
index 6f1f8e86f04..81fa9836a87 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
-import sun.misc.*;
/**
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java
index 36b3c1b7ab9..1faf49b8578 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java
@@ -39,7 +39,7 @@ import java.util.Collections;
import java.util.concurrent.*;
import java.util.concurrent.locks.*;
import sun.net.NetHooks;
-import sun.net.ExtendedOptionsImpl;
+import sun.net.ext.ExtendedSocketOptions;
/**
* Base implementation of AsynchronousSocketChannel
@@ -512,9 +512,9 @@ abstract class AsynchronousSocketChannelImpl
set.add(StandardSocketOptions.SO_REUSEPORT);
}
set.add(StandardSocketOptions.TCP_NODELAY);
- if (ExtendedOptionsImpl.flowSupported()) {
- set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
- }
+ ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+ set.addAll(extendedOptions.options());
return Collections.unmodifiableSet(set);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
index 77d14619222..f063e13ac13 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
@@ -33,7 +33,7 @@ import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
import sun.net.ResourceManager;
-import sun.net.ExtendedOptionsImpl;
+import sun.net.ext.ExtendedSocketOptions;
/**
* An implementation of DatagramChannels.
@@ -306,9 +306,9 @@ class DatagramChannelImpl
set.add(StandardSocketOptions.IP_MULTICAST_IF);
set.add(StandardSocketOptions.IP_MULTICAST_TTL);
set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
- if (ExtendedOptionsImpl.flowSupported()) {
- set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
- }
+ ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+ set.addAll(extendedOptions.options());
return Collections.unmodifiableSet(set);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/Net.java b/jdk/src/java.base/share/classes/sun/nio/ch/Net.java
index 9a5c4dcb6f8..59d3167745b 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/Net.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/Net.java
@@ -27,15 +27,13 @@ package sun.nio.ch;
import java.io.*;
import java.net.*;
-import jdk.net.*;
import java.nio.channels.*;
import java.util.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import sun.net.ExtendedOptionsImpl;
+import sun.net.ext.ExtendedSocketOptions;
import sun.security.action.GetPropertyAction;
-
public class Net {
private Net() { }
@@ -281,6 +279,9 @@ public class Net {
// -- Socket options
+ static final ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+
static void setSocketOption(FileDescriptor fd, ProtocolFamily family,
SocketOption> name, Object value)
throws IOException
@@ -291,12 +292,8 @@ public class Net {
// only simple values supported by this method
Class> type = name.type();
- if (type == SocketFlow.class) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new NetworkPermission("setOption.SO_FLOW_SLA"));
- }
- ExtendedOptionsImpl.setFlowOption(fd, (SocketFlow)value);
+ if (extendedOptions.isOptionSupported(name)) {
+ extendedOptions.setOption(fd, name, value);
return;
}
@@ -353,14 +350,8 @@ public class Net {
{
Class> type = name.type();
- if (type == SocketFlow.class) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA"));
- }
- SocketFlow flow = SocketFlow.create();
- ExtendedOptionsImpl.getFlowOption(fd, flow);
- return flow;
+ if (extendedOptions.isOptionSupported(name)) {
+ return extendedOptions.getOption(fd, name);
}
// only simple values supported by this method
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
index c4644920c3e..856e0cf2fb6 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
@@ -33,8 +33,7 @@ import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
import sun.net.NetHooks;
-import sun.net.ExtendedOptionsImpl;
-
+import sun.net.ext.ExtendedSocketOptions;
/**
* An implementation of SocketChannels
@@ -242,9 +241,9 @@ class SocketChannelImpl
// additional options required by socket adaptor
set.add(StandardSocketOptions.IP_TOS);
set.add(ExtendedSocketOption.SO_OOBINLINE);
- if (ExtendedOptionsImpl.flowSupported()) {
- set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
- }
+ ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+ set.addAll(extendedOptions.options());
return Collections.unmodifiableSet(set);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/security/action/GetBooleanSecurityPropertyAction.java b/jdk/src/java.base/share/classes/sun/security/action/GetBooleanSecurityPropertyAction.java
deleted file mode 100644
index 9b180f1bdfd..00000000000
--- a/jdk/src/java.base/share/classes/sun/security/action/GetBooleanSecurityPropertyAction.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2009, 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.security.action;
-
-import java.security.Security;
-
-/**
- * A convenience class for retrieving the boolean value of a security property
- * as a privileged action.
- *
- * An instance of this class can be used as the argument of
- * AccessController.doPrivileged
.
- *
- *
The following code retrieves the boolean value of the security
- * property named "prop"
as a privileged action:
- *
- *
- * boolean b = java.security.AccessController.doPrivileged
- * (new GetBooleanSecurityPropertyAction("prop")).booleanValue();
- *
- *
- */
-public class GetBooleanSecurityPropertyAction
- implements java.security.PrivilegedAction {
- private String theProp;
-
- /**
- * Constructor that takes the name of the security property whose boolean
- * value needs to be determined.
- *
- * @param theProp the name of the security property
- */
- public GetBooleanSecurityPropertyAction(String theProp) {
- this.theProp = theProp;
- }
-
- /**
- * Determines the boolean value of the security property whose name was
- * specified in the constructor.
- *
- * @return the Boolean
value of the security property.
- */
- public Boolean run() {
- boolean b = false;
- try {
- String value = Security.getProperty(theProp);
- b = (value != null) && value.equalsIgnoreCase("true");
- } catch (NullPointerException e) {}
- return b;
- }
-}
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
index b71121423d8..b210d18e073 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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,12 +31,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.EnumSet;
-import java.util.HashSet;
import java.math.BigInteger;
import java.security.PublicKey;
import java.security.KeyFactory;
import java.security.AlgorithmParameters;
-import java.security.NoSuchAlgorithmException;
import java.security.GeneralSecurityException;
import java.security.cert.Certificate;
import java.security.cert.X509CRL;
@@ -48,10 +46,13 @@ import java.security.cert.CertificateException;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertPathValidatorException.BasicReason;
import java.security.cert.PKIXReason;
-import java.io.IOException;
-import java.security.interfaces.*;
-import java.security.spec.*;
+import java.security.interfaces.DSAParams;
+import java.security.interfaces.DSAPublicKey;
+import java.security.spec.DSAPublicKeySpec;
+import sun.security.util.AnchorCertificates;
+import sun.security.util.CertConstraintParameters;
+import sun.security.util.Debug;
import sun.security.util.DisabledAlgorithmConstraints;
import sun.security.x509.X509CertImpl;
import sun.security.x509.X509CRLImpl;
@@ -69,6 +70,7 @@ import sun.security.x509.AlgorithmId;
* @see PKIXParameters
*/
public final class AlgorithmChecker extends PKIXCertPathChecker {
+ private static final Debug debug = Debug.getInstance("certpath");
private final AlgorithmConstraints constraints;
private final PublicKey trustedPubKey;
@@ -88,6 +90,14 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
certPathDefaultConstraints = new DisabledAlgorithmConstraints(
DisabledAlgorithmConstraints.PROPERTY_CERTPATH_DISABLED_ALGS);
+ // If there is no "cacerts" keyword, then disable anchor checking
+ private static final boolean publicCALimits =
+ certPathDefaultConstraints.checkProperty("jdkCA");
+
+ // If anchor checking enabled, this will be true if the trust anchor
+ // has a match in the cacerts file
+ private boolean trustedMatch = false;
+
/**
* Create a new AlgorithmChecker
with the algorithm
* constraints specified in security property
@@ -136,6 +146,11 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
if (anchor.getTrustedCert() != null) {
this.trustedPubKey = anchor.getTrustedCert().getPublicKey();
+ // Check for anchor certificate restrictions
+ trustedMatch = checkFingerprint(anchor.getTrustedCert());
+ if (trustedMatch && debug != null) {
+ debug.println("trustedMatch = true");
+ }
} else {
this.trustedPubKey = anchor.getCAPublicKey();
}
@@ -144,6 +159,19 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
this.constraints = constraints;
}
+ // Check this 'cert' for restrictions in the AnchorCertificates
+ // trusted certificates list
+ private static boolean checkFingerprint(X509Certificate cert) {
+ if (!publicCALimits) {
+ return false;
+ }
+
+ if (debug != null) {
+ debug.println("AlgorithmChecker.contains: " + cert.getSigAlgName());
+ }
+ return AnchorCertificates.contains(cert);
+ }
+
@Override
public void init(boolean forward) throws CertPathValidatorException {
// Note that this class does not support forward mode.
@@ -181,36 +209,8 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
return;
}
- X509CertImpl x509Cert = null;
- try {
- x509Cert = X509CertImpl.toImpl((X509Certificate)cert);
- } catch (CertificateException ce) {
- throw new CertPathValidatorException(ce);
- }
-
- PublicKey currPubKey = x509Cert.getPublicKey();
- String currSigAlg = x509Cert.getSigAlgName();
-
- AlgorithmId algorithmId = null;
- try {
- algorithmId = (AlgorithmId)x509Cert.get(X509CertImpl.SIG_ALG);
- } catch (CertificateException ce) {
- throw new CertPathValidatorException(ce);
- }
-
- AlgorithmParameters currSigAlgParams = algorithmId.getParameters();
-
- // Check the current signature algorithm
- if (!constraints.permits(
- SIGNATURE_PRIMITIVE_SET,
- currSigAlg, currSigAlgParams)) {
- throw new CertPathValidatorException(
- "Algorithm constraints check failed: " + currSigAlg,
- null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
- }
-
// check the key usage and key size
- boolean[] keyUsage = x509Cert.getKeyUsage();
+ boolean[] keyUsage = ((X509Certificate) cert).getKeyUsage();
if (keyUsage != null && keyUsage.length < 9) {
throw new CertPathValidatorException(
"incorrect KeyUsage extension",
@@ -248,27 +248,67 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
if (primitives.isEmpty()) {
throw new CertPathValidatorException(
- "incorrect KeyUsage extension",
+ "incorrect KeyUsage extension bits",
null, null, -1, PKIXReason.INVALID_KEY_USAGE);
}
}
- if (!constraints.permits(primitives, currPubKey)) {
- throw new CertPathValidatorException(
- "algorithm constraints check failed",
- null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ PublicKey currPubKey = cert.getPublicKey();
+
+ // Check against DisabledAlgorithmConstraints certpath constraints.
+ // permits() will throw exception on failure.
+ certPathDefaultConstraints.permits(primitives,
+ new CertConstraintParameters((X509Certificate)cert,
+ trustedMatch));
+ // new CertConstraintParameters(x509Cert, trustedMatch));
+ // If there is no previous key, set one and exit
+ if (prevPubKey == null) {
+ prevPubKey = currPubKey;
+ return;
+ }
+
+ X509CertImpl x509Cert;
+ AlgorithmId algorithmId;
+ try {
+ x509Cert = X509CertImpl.toImpl((X509Certificate)cert);
+ algorithmId = (AlgorithmId)x509Cert.get(X509CertImpl.SIG_ALG);
+ } catch (CertificateException ce) {
+ throw new CertPathValidatorException(ce);
+ }
+
+ AlgorithmParameters currSigAlgParams = algorithmId.getParameters();
+ String currSigAlg = x509Cert.getSigAlgName();
+
+ // If 'constraints' is not of DisabledAlgorithmConstraints, check all
+ // everything individually
+ if (!(constraints instanceof DisabledAlgorithmConstraints)) {
+ // Check the current signature algorithm
+ if (!constraints.permits(
+ SIGNATURE_PRIMITIVE_SET,
+ currSigAlg, currSigAlgParams)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on signature " +
+ "algorithm: " + currSigAlg, null, null, -1,
+ BasicReason.ALGORITHM_CONSTRAINED);
+ }
+
+ if (!constraints.permits(primitives, currPubKey)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on keysize: " +
+ sun.security.util.KeyUtil.getKeySize(currPubKey),
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
}
// Check with previous cert for signature algorithm and public key
if (prevPubKey != null) {
- if (currSigAlg != null) {
- if (!constraints.permits(
- SIGNATURE_PRIMITIVE_SET,
- currSigAlg, prevPubKey, currSigAlgParams)) {
- throw new CertPathValidatorException(
- "Algorithm constraints check failed: " + currSigAlg,
- null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
- }
+ if (!constraints.permits(
+ SIGNATURE_PRIMITIVE_SET,
+ currSigAlg, prevPubKey, currSigAlgParams)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on " +
+ "signature algorithm: " + currSigAlg,
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
// Inherit key parameters from previous key
@@ -282,7 +322,7 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
DSAParams params = ((DSAPublicKey)prevPubKey).getParams();
if (params == null) {
throw new CertPathValidatorException(
- "Key parameters missing");
+ "Key parameters missing from public key.");
}
try {
@@ -330,6 +370,11 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
// Don't bother to change the trustedPubKey.
if (anchor.getTrustedCert() != null) {
prevPubKey = anchor.getTrustedCert().getPublicKey();
+ // Check for anchor certificate restrictions
+ trustedMatch = checkFingerprint(anchor.getTrustedCert());
+ if (trustedMatch && debug != null) {
+ debug.println("trustedMatch = true");
+ }
} else {
prevPubKey = anchor.getCAPublicKey();
}
@@ -370,7 +415,8 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
if (!certPathDefaultConstraints.permits(
SIGNATURE_PRIMITIVE_SET, sigAlgName, key, sigAlgParams)) {
throw new CertPathValidatorException(
- "algorithm check failed: " + sigAlgName + " is disabled",
+ "Algorithm constraints check failed on signature algorithm: " +
+ sigAlgName + " is disabled",
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
index cfffba8329a..e85ef2d0303 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
@@ -131,8 +131,8 @@ class PKIXMasterCertPathValidator {
} catch (CertPathValidatorException cpve) {
throw new CertPathValidatorException(cpve.getMessage(),
- cpve.getCause(), cpOriginal, cpSize - (i + 1),
- cpve.getReason());
+ (cpve.getCause() != null) ? cpve.getCause() : cpve,
+ cpOriginal, cpSize - (i + 1), cpve.getReason());
}
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java b/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
index 94670e40324..2825e14254f 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@ import java.security.AccessController;
import java.security.AlgorithmConstraints;
import java.security.PrivilegedAction;
import java.security.Security;
-import java.util.Map;
import java.util.Set;
/**
@@ -45,8 +44,7 @@ public abstract class AbstractAlgorithmConstraints
}
// Get algorithm constraints from the specified security property.
- private static void loadAlgorithmsMap(Map algorithmsMap,
- String propertyName) {
+ static String[] getAlgorithms(String propertyName) {
String property = AccessController.doPrivileged(
(PrivilegedAction) () -> Security.getProperty(
propertyName));
@@ -68,18 +66,7 @@ public abstract class AbstractAlgorithmConstraints
if (algorithmsInProperty == null) {
algorithmsInProperty = new String[0];
}
- algorithmsMap.put(propertyName, algorithmsInProperty);
- }
-
- static String[] getAlgorithms(Map algorithmsMap,
- String propertyName) {
- synchronized (algorithmsMap) {
- if (!algorithmsMap.containsKey(propertyName)) {
- loadAlgorithmsMap(algorithmsMap, propertyName);
- }
-
- return algorithmsMap.get(propertyName);
- }
+ return algorithmsInProperty;
}
static boolean checkAlgorithm(String[] algorithms, String algorithm,
diff --git a/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java b/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java
index 4410a3102be..bff76cf1721 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,19 +40,7 @@ public class AlgorithmDecomposer {
private static final Pattern pattern =
Pattern.compile("with|and|(?
- * For example, we need to decompose "SHA1WithRSA" into "SHA1" and "RSA"
- * so that we can check the "SHA1" and "RSA" algorithm constraints
- * separately.
- *
- * Please override the method if need to support more name pattern.
- */
- public Set decompose(String algorithm) {
- if (algorithm == null || algorithm.length() == 0) {
- return new HashSet<>();
- }
+ private static Set decomposeImpl(String algorithm) {
// algorithm/mode/padding
String[] transTockens = transPattern.split(algorithm);
@@ -79,6 +67,24 @@ public class AlgorithmDecomposer {
elements.add(token);
}
}
+ return elements;
+ }
+
+ /**
+ * Decompose the standard algorithm name into sub-elements.
+ *
+ * For example, we need to decompose "SHA1WithRSA" into "SHA1" and "RSA"
+ * so that we can check the "SHA1" and "RSA" algorithm constraints
+ * separately.
+ *
+ * Please override the method if need to support more name pattern.
+ */
+ public Set decompose(String algorithm) {
+ if (algorithm == null || algorithm.length() == 0) {
+ return new HashSet<>();
+ }
+
+ Set elements = decomposeImpl(algorithm);
// In Java standard algorithm name specification, for different
// purpose, the SHA-1 and SHA-2 algorithm names are different. For
@@ -130,4 +136,40 @@ public class AlgorithmDecomposer {
return elements;
}
+ private static void hasLoop(Set elements, String find, String replace) {
+ if (elements.contains(find)) {
+ if (!elements.contains(replace)) {
+ elements.add(replace);
+ }
+ elements.remove(find);
+ }
+ }
+
+ /*
+ * This decomposes a standard name into sub-elements with a consistent
+ * message digest algorithm name to avoid overly complicated checking.
+ */
+ public static Set decomposeOneHash(String algorithm) {
+ if (algorithm == null || algorithm.length() == 0) {
+ return new HashSet<>();
+ }
+
+ Set elements = decomposeImpl(algorithm);
+
+ hasLoop(elements, "SHA-1", "SHA1");
+ hasLoop(elements, "SHA-224", "SHA224");
+ hasLoop(elements, "SHA-256", "SHA256");
+ hasLoop(elements, "SHA-384", "SHA384");
+ hasLoop(elements, "SHA-512", "SHA512");
+
+ return elements;
+ }
+
+ /*
+ * The provided message digest algorithm name will return a consistent
+ * naming scheme.
+ */
+ public static String hashName(String algorithm) {
+ return algorithm.replace("-", "");
+ }
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java b/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java
new file mode 100644
index 00000000000..6bc003054d1
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java
@@ -0,0 +1,101 @@
+/*
+ * 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.security.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.security.AccessController;
+import java.security.KeyStore;
+import java.security.PrivilegedAction;
+import java.security.cert.X509Certificate;
+import java.util.Enumeration;
+import java.util.HashSet;
+
+import sun.security.x509.X509CertImpl;
+
+/**
+ * The purpose of this class is to determine the trust anchor certificates is in
+ * the cacerts file. This is used for PKIX CertPath checking.
+ */
+public class AnchorCertificates {
+
+ private static final Debug debug = Debug.getInstance("certpath");
+ private static final String HASH = "SHA-256";
+ private static HashSet certs;
+
+ static {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Void run() {
+ File f = new File(System.getProperty("java.home"),
+ "lib/security/cacerts");
+ KeyStore cacerts;
+ try {
+ cacerts = KeyStore.getInstance("JKS");
+ try (FileInputStream fis = new FileInputStream(f)) {
+ cacerts.load(fis, "changeit".toCharArray());
+ certs = new HashSet<>();
+ Enumeration list = cacerts.aliases();
+ String alias;
+ while (list.hasMoreElements()) {
+ alias = list.nextElement();
+ // Check if this cert is labeled a trust anchor.
+ if (alias.contains(" [jdk")) {
+ X509Certificate cert = (X509Certificate) cacerts
+ .getCertificate(alias);
+ certs.add(X509CertImpl.getFingerprint(HASH, cert));
+ }
+ }
+ }
+ } catch (Exception e) {
+ if (debug != null) {
+ debug.println("Error parsing cacerts");
+ }
+ e.printStackTrace();
+ }
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Checks if a certificate is a trust anchor.
+ *
+ * @param cert the certificate to check
+ * @return true if the certificate is trusted.
+ */
+ public static boolean contains(X509Certificate cert) {
+ String key = X509CertImpl.getFingerprint(HASH, cert);
+ boolean result = certs.contains(key);
+ if (result && debug != null) {
+ debug.println("AnchorCertificate.contains: matched " +
+ cert.getSubjectDN());
+ }
+ return result;
+ }
+
+ private AnchorCertificates() {}
+}
diff --git a/jdk/src/java.base/windows/native/libnet/ExtendedOptionsImpl.c b/jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java
similarity index 52%
rename from jdk/src/java.base/windows/native/libnet/ExtendedOptionsImpl.c
rename to jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java
index 2bd955cd13e..9f7a938dede 100644
--- a/jdk/src/java.base/windows/native/libnet/ExtendedOptionsImpl.c
+++ b/jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -23,43 +23,37 @@
* questions.
*/
-#include
-#include
+package sun.security.util;
-#include "net_util.h"
+import java.security.cert.X509Certificate;
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: init
- * Signature: ()V
+/**
+ * This class is a wrapper for keeping state and passing objects between PKIX,
+ * AlgorithmChecker, and DisabledAlgorithmConstraints.
*/
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_init
- (JNIEnv *env, jclass UNUSED)
-{
-}
+public class CertConstraintParameters {
+ // A certificate being passed to check against constraints.
+ private final X509Certificate cert;
-/* Non Solaris. Functionality is not supported. So, throw UnsupportedOpExc */
+ // This is true if the trust anchor in the certificate chain matches a cert
+ // in AnchorCertificates
+ private final boolean trustedMatch;
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
-}
+ public CertConstraintParameters(X509Certificate c, boolean match) {
+ cert = c;
+ trustedMatch = match;
+ }
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
-}
+ public CertConstraintParameters(X509Certificate c) {
+ this(c, false);
+ }
-static jboolean flowSupported0() {
- return JNI_FALSE;
-}
+ // Returns if the trust anchor has a match if anchor checking is enabled.
+ public boolean isTrustedMatch() {
+ return trustedMatch;
+ }
-JNIEXPORT jboolean JNICALL Java_sun_net_ExtendedOptionsImpl_flowSupported
- (JNIEnv *env, jclass UNUSED)
-{
- return JNI_FALSE;
+ public X509Certificate getCertificate() {
+ return cert;
+ }
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
index fd4b198ce11..d4b2a4054b3 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,12 +28,14 @@ package sun.security.util;
import java.security.CryptoPrimitive;
import java.security.AlgorithmParameters;
import java.security.Key;
-import java.util.Locale;
-import java.util.Set;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertPathValidatorException.BasicReason;
+import java.security.cert.X509Certificate;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -44,6 +46,7 @@ import java.util.regex.Matcher;
* for the syntax of the disabled algorithm string.
*/
public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
+ private static final Debug debug = Debug.getInstance("certpath");
// the known security property, jdk.certpath.disabledAlgorithms
public static final String PROPERTY_CERTPATH_DISABLED_ALGS =
@@ -53,13 +56,8 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
public static final String PROPERTY_TLS_DISABLED_ALGS =
"jdk.tls.disabledAlgorithms";
- private static final Map disabledAlgorithmsMap =
- new HashMap<>();
- private static final Map keySizeConstraintsMap =
- new HashMap<>();
-
private final String[] disabledAlgorithms;
- private final KeySizeConstraints keySizeConstraints;
+ private final Constraints algorithmConstraints;
/**
* Initialize algorithm constraints with the specified security property.
@@ -74,11 +72,14 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
public DisabledAlgorithmConstraints(String propertyName,
AlgorithmDecomposer decomposer) {
super(decomposer);
- disabledAlgorithms = getAlgorithms(disabledAlgorithmsMap, propertyName);
- keySizeConstraints = getKeySizeConstraints(disabledAlgorithms,
- propertyName);
+ disabledAlgorithms = getAlgorithms(propertyName);
+ algorithmConstraints = new Constraints(disabledAlgorithms);
}
+ /*
+ * This only checks if the algorithm has been completely disabled. If
+ * there are keysize or other limit, this method allow the algorithm.
+ */
@Override
public final boolean permits(Set primitives,
String algorithm, AlgorithmParameters parameters) {
@@ -91,11 +92,19 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return checkAlgorithm(disabledAlgorithms, algorithm, decomposer);
}
+ /*
+ * Checks if the key algorithm has been disabled or constraints have been
+ * placed on the key.
+ */
@Override
public final boolean permits(Set primitives, Key key) {
return checkConstraints(primitives, "", key, null);
}
+ /*
+ * Checks if the key algorithm has been disabled or if constraints have
+ * been placed on the key.
+ */
@Override
public final boolean permits(Set primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
@@ -107,7 +116,39 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return checkConstraints(primitives, algorithm, key, parameters);
}
- // Check algorithm constraints
+ /*
+ * Check if a x509Certificate object is permitted. Check if all
+ * algorithms are allowed, certificate constraints, and the
+ * public key against key constraints.
+ *
+ * Uses new style permit() which throws exceptions.
+ */
+ public final void permits(Set primitives,
+ CertConstraintParameters cp) throws CertPathValidatorException {
+ checkConstraints(primitives, cp);
+ }
+
+ /*
+ * Check if Certificate object is within the constraints.
+ * Uses new style permit() which throws exceptions.
+ */
+ public final void permits(Set primitives,
+ X509Certificate cert) throws CertPathValidatorException {
+ checkConstraints(primitives, new CertConstraintParameters(cert));
+ }
+
+ // Check if a string is contained inside the property
+ public boolean checkProperty(String param) {
+ param = param.toLowerCase(Locale.ENGLISH);
+ for (String block : disabledAlgorithms) {
+ if (block.toLowerCase(Locale.ENGLISH).indexOf(param) >= 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // Check algorithm constraints with key and algorithm
private boolean checkConstraints(Set primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
@@ -116,7 +157,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
throw new IllegalArgumentException("The key cannot be null");
}
- // check the target algorithm
+ // check the signature algorithm
if (algorithm != null && algorithm.length() != 0) {
if (!permits(primitives, algorithm, parameters)) {
return false;
@@ -129,97 +170,203 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
}
// check the key constraints
- if (keySizeConstraints.disables(key)) {
- return false;
- }
-
- return true;
+ return algorithmConstraints.permits(key);
}
- private static KeySizeConstraints getKeySizeConstraints(
- String[] disabledAlgorithms, String propertyName) {
- synchronized (keySizeConstraintsMap) {
- if(!keySizeConstraintsMap.containsKey(propertyName)) {
- // map the key constraints
- KeySizeConstraints keySizeConstraints =
- new KeySizeConstraints(disabledAlgorithms);
- keySizeConstraintsMap.put(propertyName, keySizeConstraints);
- }
+ /*
+ * Check algorithm constraints with Certificate
+ * Uses new style permit() which throws exceptions.
+ */
+ private void checkConstraints(Set primitives,
+ CertConstraintParameters cp) throws CertPathValidatorException {
- return keySizeConstraintsMap.get(propertyName);
+ X509Certificate cert = cp.getCertificate();
+ String algorithm = cert.getSigAlgName();
+
+ // Check signature algorithm is not disabled
+ if (!permits(primitives, algorithm, null)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on disabled "+
+ "signature algorithm: " + algorithm,
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
+
+ // Check key algorithm is not disabled
+ if (!permits(primitives, cert.getPublicKey().getAlgorithm(), null)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on disabled "+
+ "public key algorithm: " + algorithm,
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
+
+ // Check the certificate and key constraints
+ algorithmConstraints.permits(cp);
+
}
/**
- * key constraints
+ * Key and Certificate Constraints
+ *
+ * The complete disabling of an algorithm is not handled by Constraints or
+ * Constraint classes. That is addressed with
+ * permit(Set, String, AlgorithmParameters)
+ *
+ * When passing a Key to permit(), the boolean return values follow the
+ * same as the interface class AlgorithmConstraints.permit(). This is to
+ * maintain compatibility:
+ * 'true' means the operation is allowed.
+ * 'false' means it failed the constraints and is disallowed.
+ *
+ * When passing CertConstraintParameters through permit(), an exception
+ * will be thrown on a failure to better identify why the operation was
+ * disallowed.
*/
- private static class KeySizeConstraints {
- private static final Pattern pattern = Pattern.compile(
- "(\\S+)\\s+keySize\\s*(<=|<|==|!=|>|>=)\\s*(\\d+)");
- private Map> constraintsMap =
- Collections.synchronizedMap(
- new HashMap>());
+ private static class Constraints {
+ private Map> constraintsMap = new HashMap<>();
+ private static final Pattern keySizePattern = Pattern.compile(
+ "keySize\\s*(<=|<|==|!=|>|>=)\\s*(\\d+)");
- public KeySizeConstraints(String[] restrictions) {
- for (String restriction : restrictions) {
- if (restriction == null || restriction.isEmpty()) {
+ public Constraints(String[] constraintArray) {
+ for (String constraintEntry : constraintArray) {
+ if (constraintEntry == null || constraintEntry.isEmpty()) {
continue;
}
- Matcher matcher = pattern.matcher(restriction);
- if (matcher.matches()) {
- String algorithm = matcher.group(1);
+ constraintEntry = constraintEntry.trim();
+ if (debug != null) {
+ debug.println("Constraints: " + constraintEntry);
+ }
- KeySizeConstraint.Operator operator =
- KeySizeConstraint.Operator.of(matcher.group(2));
- int length = Integer.parseInt(matcher.group(3));
+ // Check if constraint is a complete disabling of an
+ // algorithm or has conditions.
+ String algorithm;
+ String policy;
+ int space = constraintEntry.indexOf(' ');
+ if (space > 0) {
+ algorithm = AlgorithmDecomposer.hashName(
+ constraintEntry.substring(0, space).
+ toUpperCase(Locale.ENGLISH));
+ policy = constraintEntry.substring(space + 1);
+ } else {
+ constraintsMap.computeIfAbsent(
+ constraintEntry.toUpperCase(Locale.ENGLISH),
+ k -> new HashSet<>());
+ continue;
+ }
- algorithm = algorithm.toLowerCase(Locale.ENGLISH);
+ // Convert constraint conditions into Constraint classes
+ Constraint c, lastConstraint = null;
+ // Allow only one jdkCA entry per constraint entry
+ boolean jdkCALimit = false;
- synchronized (constraintsMap) {
- if (!constraintsMap.containsKey(algorithm)) {
- constraintsMap.put(algorithm,
- new HashSet());
+ for (String entry : policy.split("&")) {
+ entry = entry.trim();
+
+ Matcher matcher = keySizePattern.matcher(entry);
+ if (matcher.matches()) {
+ if (debug != null) {
+ debug.println("Constraints set to keySize: " +
+ entry);
}
+ c = new KeySizeConstraint(algorithm,
+ KeySizeConstraint.Operator.of(matcher.group(1)),
+ Integer.parseInt(matcher.group(2)));
- Set constraintSet =
- constraintsMap.get(algorithm);
- KeySizeConstraint constraint =
- new KeySizeConstraint(operator, length);
- constraintSet.add(constraint);
+ } else if (entry.equalsIgnoreCase("jdkCA")) {
+ if (debug != null) {
+ debug.println("Constraints set to jdkCA.");
+ }
+ if (jdkCALimit) {
+ throw new IllegalArgumentException("Only one " +
+ "jdkCA entry allowed in property. " +
+ "Constraint: " + constraintEntry);
+ }
+ c = new jdkCAConstraint(algorithm);
+ jdkCALimit = true;
+ } else {
+ throw new IllegalArgumentException("Error in security" +
+ " property. Constraint unknown: " + entry);
}
+
+ // Link multiple conditions for a single constraint
+ // into a linked list.
+ if (lastConstraint == null) {
+ if (!constraintsMap.containsKey(algorithm)) {
+ constraintsMap.putIfAbsent(algorithm,
+ new HashSet<>());
+ }
+ constraintsMap.get(algorithm).add(c);
+ } else {
+ lastConstraint.nextConstraint = c;
+ }
+ lastConstraint = c;
}
}
}
- // Does this KeySizeConstraints disable the specified key?
- public boolean disables(Key key) {
- String algorithm = key.getAlgorithm().toLowerCase(Locale.ENGLISH);
- synchronized (constraintsMap) {
- if (constraintsMap.containsKey(algorithm)) {
- Set constraintSet =
- constraintsMap.get(algorithm);
- for (KeySizeConstraint constraint : constraintSet) {
- if (constraint.disables(key)) {
- return true;
- }
+ // Get applicable constraints based off the signature algorithm
+ private Set getConstraints(String algorithm) {
+ return constraintsMap.get(algorithm);
+ }
+
+ // Check if KeySizeConstraints permit the specified key
+ public boolean permits(Key key) {
+ Set set = getConstraints(key.getAlgorithm());
+ if (set == null) {
+ return true;
+ }
+ for (Constraint constraint : set) {
+ if (!constraint.permits(key)) {
+ if (debug != null) {
+ debug.println("keySizeConstraint: failed key " +
+ "constraint check " + KeyUtil.getKeySize(key));
}
+ return false;
}
}
+ return true;
+ }
- return false;
+ // Check if constraints permit this cert.
+ public void permits(CertConstraintParameters cp)
+ throws CertPathValidatorException {
+ X509Certificate cert = cp.getCertificate();
+
+ if (debug != null) {
+ debug.println("Constraints.permits(): " + cert.getSigAlgName());
+ }
+
+ // Get all signature algorithms to check for constraints
+ Set algorithms =
+ AlgorithmDecomposer.decomposeOneHash(cert.getSigAlgName());
+ if (algorithms == null || algorithms.isEmpty()) {
+ return;
+ }
+
+ // Attempt to add the public key algorithm to the set
+ algorithms.add(cert.getPublicKey().getAlgorithm());
+
+ // Check all applicable constraints
+ for (String algorithm : algorithms) {
+ Set set = getConstraints(algorithm);
+ if (set == null) {
+ continue;
+ }
+ for (Constraint constraint : set) {
+ constraint.permits(cp);
+ }
+ }
}
}
- /**
- * Key size constraint.
- *
- * e.g. "keysize <= 1024"
- */
- private static class KeySizeConstraint {
+ // Abstract class for algorithm constraint checking
+ private abstract static class Constraint {
+ String algorithm;
+ Constraint nextConstraint = null;
+
// operator
- static enum Operator {
+ enum Operator {
EQ, // "=="
NE, // "!="
LT, // "<"
@@ -243,16 +390,77 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return GE;
}
- throw new IllegalArgumentException(
- s + " is not a legal Operator");
+ throw new IllegalArgumentException("Error in security " +
+ "property. " + s + " is not a legal Operator");
}
}
+ /**
+ * Check if an algorithm constraint permit this key to be used.
+ * @param key Public key
+ * @return true if constraints do not match
+ */
+ public boolean permits(Key key) {
+ return true;
+ }
+
+ /**
+ * Check if an algorithm constraint is permit this certificate to
+ * be used.
+ * @param cp CertificateParameter containing certificate and state info
+ * @return true if constraints do not match
+ */
+ public abstract void permits(CertConstraintParameters cp)
+ throws CertPathValidatorException;
+ }
+
+ /*
+ * This class contains constraints dealing with the certificate chain
+ * of the certificate.
+ */
+ private static class jdkCAConstraint extends Constraint {
+ jdkCAConstraint(String algo) {
+ algorithm = algo;
+ }
+
+ /*
+ * Check if each constraint fails and check if there is a linked
+ * constraint Any permitted constraint will exit the linked list
+ * to allow the operation.
+ */
+ public void permits(CertConstraintParameters cp)
+ throws CertPathValidatorException {
+ if (debug != null) {
+ debug.println("jdkCAConstraints.permits(): " + algorithm);
+ }
+
+ // Return false if the chain has a trust anchor in cacerts
+ if (cp.isTrustedMatch()) {
+ if (nextConstraint != null) {
+ nextConstraint.permits(cp);
+ return;
+ }
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on certificate " +
+ "anchor limits",
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
+ }
+ }
+
+
+ /*
+ * This class contains constraints dealing with the key size
+ * support limits per algorithm. e.g. "keySize <= 1024"
+ */
+ private static class KeySizeConstraint extends Constraint {
+
private int minSize; // the minimal available key size
private int maxSize; // the maximal available key size
private int prohibitedSize = -1; // unavailable key sizes
- public KeySizeConstraint(Operator operator, int length) {
+ public KeySizeConstraint(String algo, Operator operator, int length) {
+ algorithm = algo;
switch (operator) {
case EQ: // an unavailable key size
this.minSize = 0;
@@ -286,21 +494,59 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
}
}
- // Does this key constraint disable the specified key?
- public boolean disables(Key key) {
- int size = KeyUtil.getKeySize(key);
+ /*
+ * If we are passed a certificate, extract the public key and use it.
+ *
+ * Check if each constraint fails and check if there is a linked
+ * constraint Any permitted constraint will exit the linked list
+ * to allow the operation.
+ */
+ public void permits(CertConstraintParameters cp)
+ throws CertPathValidatorException {
+ if (!permitsImpl(cp.getCertificate().getPublicKey())) {
+ if (nextConstraint != null) {
+ nextConstraint.permits(cp);
+ return;
+ }
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on keysize limits",
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
+ }
+
+ // Check if key constraint disable the specified key
+ // Uses old style permit()
+ public boolean permits(Key key) {
+ // If we recursively find a constraint that permits us to use
+ // this key, return true and skip any other constraint checks.
+ if (nextConstraint != null && nextConstraint.permits(key)) {
+ return true;
+ }
+ if (debug != null) {
+ debug.println("KeySizeConstraints.permits(): " + algorithm);
+ }
+
+ return permitsImpl(key);
+ }
+
+ private boolean permitsImpl(Key key) {
+ // Verify this constraint is for this public key algorithm
+ if (algorithm.compareToIgnoreCase(key.getAlgorithm()) != 0) {
+ return true;
+ }
+
+ int size = KeyUtil.getKeySize(key);
if (size == 0) {
- return true; // we don't allow any key of size 0.
+ return false; // we don't allow any key of size 0.
} else if (size > 0) {
- return ((size < minSize) || (size > maxSize) ||
+ return !((size < minSize) || (size > maxSize) ||
(prohibitedSize == size));
} // Otherwise, the key size is not accessible. Conservatively,
// please don't disable such keys.
- return false;
+ return true;
}
}
-
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java b/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
index d8803348a5d..7c8fe9af51d 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,6 @@ package sun.security.util;
import java.security.AlgorithmParameters;
import java.security.CryptoPrimitive;
import java.security.Key;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
import static sun.security.util.AbstractAlgorithmConstraints.getAlgorithms;
@@ -42,15 +40,12 @@ public class LegacyAlgorithmConstraints extends AbstractAlgorithmConstraints {
public static final String PROPERTY_TLS_LEGACY_ALGS =
"jdk.tls.legacyAlgorithms";
- private static final Map legacyAlgorithmsMap =
- new HashMap<>();
-
private final String[] legacyAlgorithms;
public LegacyAlgorithmConstraints(String propertyName,
AlgorithmDecomposer decomposer) {
super(decomposer);
- legacyAlgorithms = getAlgorithms(legacyAlgorithmsMap, propertyName);
+ legacyAlgorithms = getAlgorithms(propertyName);
}
@Override
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
index 0e4da831a83..8d496ad85c4 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1924,17 +1924,18 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
public String getFingerprint(String algorithm) {
return fingerprints.computeIfAbsent(algorithm,
- x -> getCertificateFingerPrint(x));
+ x -> getFingerprint(x, this));
}
/**
* Gets the requested finger print of the certificate. The result
* only contains 0-9 and A-F. No small case, no colon.
*/
- private String getCertificateFingerPrint(String mdAlg) {
+ public static String getFingerprint(String algorithm,
+ X509Certificate cert) {
try {
- byte[] encCertInfo = getEncoded();
- MessageDigest md = MessageDigest.getInstance(mdAlg);
+ byte[] encCertInfo = cert.getEncoded();
+ MessageDigest md = MessageDigest.getInstance(algorithm);
byte[] digest = md.digest(encCertInfo);
StringBuilder sb = new StringBuilder(digest.length * 2);
for (int i = 0; i < digest.length; i++) {
diff --git a/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java b/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java
index 655dc96a299..e8df610c4c1 100644
--- a/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java
+++ b/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java
@@ -286,12 +286,15 @@ public class PlatformLogger {
}
if (log == null) {
log = new PlatformLogger(PlatformLogger.Bridge.convert(
- // We pass PlatformLogger.class rather than the actual caller
+ // We pass PlatformLogger.class.getModule() (java.base)
+ // rather than the actual module of the caller
// because we want PlatformLoggers to be system loggers: we
// won't need to resolve any resource bundles anyway.
// Note: Many unit tests depend on the fact that
- // PlatformLogger.getLoggerFromFinder is not caller sensitive.
- LazyLoggers.getLazyLogger(name, PlatformLogger.class)));
+ // PlatformLogger.getLoggerFromFinder is not caller
+ // sensitive, and this strategy ensure that the tests
+ // still pass.
+ LazyLoggers.getLazyLogger(name, PlatformLogger.class.getModule())));
loggers.put(name, new WeakReference<>(log));
}
return log;
diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security
index 6a9803bf425..fa2da13c195 100644
--- a/jdk/src/java.base/share/conf/security/java.security
+++ b/jdk/src/java.base/share/conf/security/java.security
@@ -497,13 +497,13 @@ krb5.kdc.bad.policy = tryLast
# " DisabledAlgorithm { , DisabledAlgorithm } "
#
# DisabledAlgorithm:
-# AlgorithmName [Constraint]
+# AlgorithmName [Constraint] { '&' Constraint }
#
# AlgorithmName:
# (see below)
#
# Constraint:
-# KeySizeConstraint
+# KeySizeConstraint, CertConstraint
#
# KeySizeConstraint:
# keySize Operator DecimalInteger
@@ -520,6 +520,9 @@ krb5.kdc.bad.policy = tryLast
# DecimalDigit: one of
# 1 2 3 4 5 6 7 8 9 0
#
+# CertConstraint
+# jdkCA
+#
# The "AlgorithmName" is the standard algorithm name of the disabled
# algorithm. See "Java Cryptography Architecture Standard Algorithm Name
# Documentation" for information about Standard Algorithm Names. Matching
@@ -542,6 +545,29 @@ krb5.kdc.bad.policy = tryLast
# be disabled. Note that the "KeySizeConstraint" only makes sense to key
# algorithms.
#
+# "CertConstraint" specifies additional constraints for
+# certificates that contain algorithms that are restricted:
+#
+# Â Â "jdkCA" prohibits the specified algorithm only if the algorithm is used
+# Â Â Â Â in a certificate chain that terminates at a marked trust anchor in the
+# Â Â Â Â lib/security/cacerts keystore. Â All other chains are not affected.
+# Â Â Â Â If the jdkCA constraint is not set, then all chains using the
+# Â Â Â Â specified algorithm are restricted. jdkCA may only be used once in
+# a DisabledAlgorithm expression.
+# Â Â Â Â Example: Â To apply this constraint to SHA-1 certificates, include
+# Â Â Â Â the following: Â "SHA1 jdkCA"
+#
+# When an algorithm must satisfy more than one constraint, it must be
+# delimited by an ampersand '&'. For example, to restrict certificates in a
+# chain that terminate at a distribution provided trust anchor and contain
+# RSA keys that are less than or equal to 1024 bits, add the following
+# constraint: "RSA keySize <= 1024 & jdkCA".
+#
+# All DisabledAlgorithms expressions are processed in the order defined in the
+# property. This requires lower keysize constraints to be specified
+# before larger keysize constraints of the same algorithm. For example:
+# "RSA keySize < 1024 & jdkCA, RSA keySize < 2048".
+#
# Note: This property is currently used by Oracle's PKIX implementation. It
# is not guaranteed to be examined and used by other implementations.
#
diff --git a/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java b/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
index f7c65931613..32640dff272 100644
--- a/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
+++ b/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
@@ -27,9 +27,7 @@ package java.net;
import java.io.IOException;
import java.util.Set;
import java.util.HashSet;
-import java.util.Collections;
-import jdk.net.*;
-import static sun.net.ExtendedOptionsImpl.*;
+import sun.net.ext.ExtendedSocketOptions;
/*
* On Unix systems we simply delegate to native methods.
@@ -43,8 +41,11 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
init();
}
+ static final ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+
protected void setOption(SocketOption name, T value) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
super.setOption(name, value);
} else {
@@ -55,21 +56,16 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
}
}
} else {
- if (!flowSupported()) {
- throw new UnsupportedOperationException("unsupported option");
- }
if (isClosed()) {
throw new SocketException("Socket closed");
}
- checkSetOptionPermission(name);
- checkValueType(value, SocketFlow.class);
- setFlowOption(getFileDescriptor(), (SocketFlow)value);
+ extendedOptions.setOption(fd, name, value);
}
}
@SuppressWarnings("unchecked")
protected T getOption(SocketOption name) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
return super.getOption(name);
} else {
@@ -79,31 +75,23 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
throw new UnsupportedOperationException("unsupported option");
}
}
+ } else {
+ if (isClosed()) {
+ throw new SocketException("Socket closed");
+ }
+ return (T) extendedOptions.getOption(fd, name);
}
- if (!flowSupported()) {
- throw new UnsupportedOperationException("unsupported option");
- }
- if (isClosed()) {
- throw new SocketException("Socket closed");
- }
- checkGetOptionPermission(name);
- SocketFlow flow = SocketFlow.create();
- getFlowOption(getFileDescriptor(), flow);
- return (T)flow;
}
protected Set> supportedOptions() {
- HashSet> options = new HashSet<>(
- super.supportedOptions());
-
- if (flowSupported()) {
- options.add(ExtendedSocketOptions.SO_FLOW_SLA);
- }
+ HashSet> options = new HashSet<>(super.supportedOptions());
+ options.addAll(extendedOptions.options());
return options;
}
protected void socketSetOption(int opt, Object val) throws SocketException {
- if (opt == SocketOptions.SO_REUSEPORT && !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
+ if (opt == SocketOptions.SO_REUSEPORT &&
+ !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
throw new UnsupportedOperationException("unsupported option");
}
try {
diff --git a/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java b/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java
index 2ec573ea5a9..4a5f2b5ddd6 100644
--- a/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java
+++ b/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java
@@ -28,10 +28,7 @@ import java.io.IOException;
import java.io.FileDescriptor;
import java.util.Set;
import java.util.HashSet;
-import java.util.Collections;
-import jdk.net.*;
-
-import static sun.net.ExtendedOptionsImpl.*;
+import sun.net.ext.ExtendedSocketOptions;
/*
* On Unix systems we simply delegate to native methods.
@@ -57,8 +54,11 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
this.fd = fd;
}
+ static final ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+
protected void setOption(SocketOption name, T value) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
super.setOption(name, value);
} else {
@@ -69,21 +69,19 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
}
}
} else {
- if (getSocket() == null || !flowSupported()) {
+ if (getSocket() == null) {
throw new UnsupportedOperationException("unsupported option");
}
if (isClosedOrPending()) {
throw new SocketException("Socket closed");
}
- checkSetOptionPermission(name);
- checkValueType(value, SocketFlow.class);
- setFlowOption(getFileDescriptor(), (SocketFlow)value);
+ extendedOptions.setOption(fd, name, value);
}
}
@SuppressWarnings("unchecked")
protected T getOption(SocketOption name) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
return super.getOption(name);
} else {
@@ -93,31 +91,28 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
throw new UnsupportedOperationException("unsupported option");
}
}
+ } else {
+ if (getSocket() == null) {
+ throw new UnsupportedOperationException("unsupported option");
+ }
+ if (isClosedOrPending()) {
+ throw new SocketException("Socket closed");
+ }
+ return (T) extendedOptions.getOption(fd, name);
}
- if (getSocket() == null || !flowSupported()) {
- throw new UnsupportedOperationException("unsupported option");
- }
- if (isClosedOrPending()) {
- throw new SocketException("Socket closed");
- }
- checkGetOptionPermission(name);
- SocketFlow flow = SocketFlow.create();
- getFlowOption(getFileDescriptor(), flow);
- return (T)flow;
}
protected Set> supportedOptions() {
- HashSet> options = new HashSet<>(
- super.supportedOptions());
-
- if (getSocket() != null && flowSupported()) {
- options.add(ExtendedSocketOptions.SO_FLOW_SLA);
+ HashSet> options = new HashSet<>(super.supportedOptions());
+ if (getSocket() != null) {
+ options.addAll(extendedOptions.options());
}
return options;
}
protected void socketSetOption(int opt, boolean b, Object val) throws SocketException {
- if (opt == SocketOptions.SO_REUSEPORT && !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
+ if (opt == SocketOptions.SO_REUSEPORT &&
+ !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
throw new UnsupportedOperationException("unsupported option");
}
try {
diff --git a/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java b/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java
index 1911c3507c0..27c7a41937e 100644
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
-import sun.misc.*;
/**
diff --git a/jdk/src/java.base/unix/native/libnet/ExtendedOptionsImpl.c b/jdk/src/java.base/unix/native/libnet/ExtendedOptionsImpl.c
deleted file mode 100644
index 116d2e97d92..00000000000
--- a/jdk/src/java.base/unix/native/libnet/ExtendedOptionsImpl.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 2014, 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.
- */
-
-#include
-#include
-
-#include "net_util.h"
-#include "jdk_net_SocketFlow.h"
-
-static jclass sf_status_class; /* Status enum type */
-
-static jfieldID sf_status;
-static jfieldID sf_priority;
-static jfieldID sf_bandwidth;
-
-static jfieldID sf_fd_fdID; /* FileDescriptor.fd */
-
-/* References to the literal enum values */
-
-static jobject sfs_NOSTATUS;
-static jobject sfs_OK;
-static jobject sfs_NOPERMISSION;
-static jobject sfs_NOTCONNECTED;
-static jobject sfs_NOTSUPPORTED;
-static jobject sfs_ALREADYCREATED;
-static jobject sfs_INPROGRESS;
-static jobject sfs_OTHER;
-
-static jobject getEnumField(JNIEnv *env, char *name);
-static void setStatus(JNIEnv *env, jobject obj, int errval);
-
-/* OS specific code is implemented in these three functions */
-
-static jboolean flowSupported0() ;
-
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_init
- (JNIEnv *env, jclass UNUSED)
-{
- static int initialized = 0;
- jclass c;
-
- /* Global class references */
-
- if (initialized) {
- return;
- }
-
- c = (*env)->FindClass(env, "jdk/net/SocketFlow$Status");
- CHECK_NULL(c);
- sf_status_class = (*env)->NewGlobalRef(env, c);
- CHECK_NULL(sf_status_class);
-
- /* int "fd" field of java.io.FileDescriptor */
-
- c = (*env)->FindClass(env, "java/io/FileDescriptor");
- CHECK_NULL(c);
- sf_fd_fdID = (*env)->GetFieldID(env, c, "fd", "I");
- CHECK_NULL(sf_fd_fdID);
-
-
- /* SocketFlow fields */
-
- c = (*env)->FindClass(env, "jdk/net/SocketFlow");
- CHECK_NULL(c);
-
- /* status */
-
- sf_status = (*env)->GetFieldID(env, c, "status",
- "Ljdk/net/SocketFlow$Status;");
- CHECK_NULL(sf_status);
-
- /* priority */
-
- sf_priority = (*env)->GetFieldID(env, c, "priority", "I");
- CHECK_NULL(sf_priority);
-
- /* bandwidth */
-
- sf_bandwidth = (*env)->GetFieldID(env, c, "bandwidth", "J");
- CHECK_NULL(sf_bandwidth);
-
- /* Initialize the static enum values */
-
- sfs_NOSTATUS = getEnumField(env, "NO_STATUS");
- CHECK_NULL(sfs_NOSTATUS);
- sfs_OK = getEnumField(env, "OK");
- CHECK_NULL(sfs_OK);
- sfs_NOPERMISSION = getEnumField(env, "NO_PERMISSION");
- CHECK_NULL(sfs_NOPERMISSION);
- sfs_NOTCONNECTED = getEnumField(env, "NOT_CONNECTED");
- CHECK_NULL(sfs_NOTCONNECTED);
- sfs_NOTSUPPORTED = getEnumField(env, "NOT_SUPPORTED");
- CHECK_NULL(sfs_NOTSUPPORTED);
- sfs_ALREADYCREATED = getEnumField(env, "ALREADY_CREATED");
- CHECK_NULL(sfs_ALREADYCREATED);
- sfs_INPROGRESS = getEnumField(env, "IN_PROGRESS");
- CHECK_NULL(sfs_INPROGRESS);
- sfs_OTHER = getEnumField(env, "OTHER");
- CHECK_NULL(sfs_OTHER);
- initialized = JNI_TRUE;
-}
-
-static jobject getEnumField(JNIEnv *env, char *name)
-{
- jobject f;
- jfieldID fID = (*env)->GetStaticFieldID(env, sf_status_class, name,
- "Ljdk/net/SocketFlow$Status;");
- CHECK_NULL_RETURN(fID, NULL);
-
- f = (*env)->GetStaticObjectField(env, sf_status_class, fID);
- CHECK_NULL_RETURN(f, NULL);
- f = (*env)->NewGlobalRef(env, f);
- CHECK_NULL_RETURN(f, NULL);
- return f;
-}
-
-/*
- * Retrieve the int file-descriptor from a public socket type object.
- * Gets impl, then the FileDescriptor from the impl, and then the fd
- * from that.
- */
-static int getFD(JNIEnv *env, jobject fileDesc) {
- return (*env)->GetIntField(env, fileDesc, sf_fd_fdID);
-}
-
-/**
- * Sets the status field of a SocketFlow to one of the
- * canned enum values
- */
-static void setStatus (JNIEnv *env, jobject obj, int errval)
-{
- switch (errval) {
- case 0: /* OK */
- (*env)->SetObjectField(env, obj, sf_status, sfs_OK);
- break;
- case EPERM:
- (*env)->SetObjectField(env, obj, sf_status, sfs_NOPERMISSION);
- break;
- case ENOTCONN:
- (*env)->SetObjectField(env, obj, sf_status, sfs_NOTCONNECTED);
- break;
- case EOPNOTSUPP:
- (*env)->SetObjectField(env, obj, sf_status, sfs_NOTSUPPORTED);
- break;
- case EALREADY:
- (*env)->SetObjectField(env, obj, sf_status, sfs_ALREADYCREATED);
- break;
- case EINPROGRESS:
- (*env)->SetObjectField(env, obj, sf_status, sfs_INPROGRESS);
- break;
- default:
- (*env)->SetObjectField(env, obj, sf_status, sfs_OTHER);
- break;
- }
-}
-
-#ifdef __solaris__
-
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: setFlowOption
- * Signature: (Ljava/io/FileDescriptor;Ljdk/net/SocketFlow;)V
- */
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- int fd = getFD(env, fileDesc);
-
- if (fd < 0) {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException", "socket closed");
- return;
- } else {
- sock_flow_props_t props;
- jlong bandwidth;
- int rv;
-
- jint priority = (*env)->GetIntField(env, flow, sf_priority);
- memset(&props, 0, sizeof(props));
- props.sfp_version = SOCK_FLOW_PROP_VERSION1;
-
- if (priority != jdk_net_SocketFlow_UNSET) {
- props.sfp_mask |= SFP_PRIORITY;
- props.sfp_priority = priority;
- }
- bandwidth = (*env)->GetLongField(env, flow, sf_bandwidth);
- if (bandwidth > -1) {
- props.sfp_mask |= SFP_MAXBW;
- props.sfp_maxbw = (uint64_t) bandwidth;
- }
- rv = setsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &props, sizeof(props));
- if (rv < 0) {
- if (errno == ENOPROTOOPT) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
- } else if (errno == EACCES || errno == EPERM) {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException",
- "Permission denied");
- } else {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException",
- "set option SO_FLOW_SLA failed");
- }
- return;
- }
- setStatus(env, flow, props.sfp_status);
- }
-}
-
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: getFlowOption
- * Signature: (Ljava/io/FileDescriptor;Ljdk/net/SocketFlow;)V
- */
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- int fd = getFD(env, fileDesc);
-
- if (fd < 0) {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException", "socket closed");
- return;
- } else {
- sock_flow_props_t props;
- int status;
- socklen_t sz = sizeof(props);
-
- int rv = getsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &props, &sz);
- if (rv < 0) {
- if (errno == ENOPROTOOPT) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
- } else if (errno == EACCES || errno == EPERM) {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException",
- "Permission denied");
- } else {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException",
- "set option SO_FLOW_SLA failed");
- }
- return;
- }
- /* first check status to see if flow exists */
- status = props.sfp_status;
- setStatus(env, flow, status);
- if (status == 0) { /* OK */
- /* can set the other fields now */
- if (props.sfp_mask & SFP_PRIORITY) {
- (*env)->SetIntField(env, flow, sf_priority, props.sfp_priority);
- }
- if (props.sfp_mask & SFP_MAXBW) {
- (*env)->SetLongField(env, flow, sf_bandwidth,
- (jlong)props.sfp_maxbw);
- }
- }
- }
-}
-
-static jboolean flowsupported;
-static jboolean flowsupported_set = JNI_FALSE;
-
-static jboolean flowSupported0()
-{
- /* Do a simple dummy call, and try to figure out from that */
- sock_flow_props_t props;
- int rv, s;
- if (flowsupported_set) {
- return flowsupported;
- }
- s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (s < 0) {
- flowsupported = JNI_FALSE;
- flowsupported_set = JNI_TRUE;
- return JNI_FALSE;
- }
- memset(&props, 0, sizeof(props));
- props.sfp_version = SOCK_FLOW_PROP_VERSION1;
- props.sfp_mask |= SFP_PRIORITY;
- props.sfp_priority = SFP_PRIO_NORMAL;
- rv = setsockopt(s, SOL_SOCKET, SO_FLOW_SLA, &props, sizeof(props));
- if (rv != 0 && errno == ENOPROTOOPT) {
- rv = JNI_FALSE;
- } else {
- rv = JNI_TRUE;
- }
- close(s);
- flowsupported = rv;
- flowsupported_set = JNI_TRUE;
- return flowsupported;
-}
-
-#else /* __solaris__ */
-
-/* Non Solaris. Functionality is not supported. So, throw UnsupportedOpExc */
-
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
-}
-
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
-}
-
-static jboolean flowSupported0() {
- return JNI_FALSE;
-}
-
-#endif /* __solaris__ */
-
-JNIEXPORT jboolean JNICALL Java_sun_net_ExtendedOptionsImpl_flowSupported
- (JNIEnv *env, jclass UNUSED)
-{
- return flowSupported0();
-}
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 f440bd8ae6a..3a8c9f4d48e 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
@@ -120,47 +120,6 @@ int getDefaultIPv6Interface(struct in6_addr *target_addr);
#ifdef __solaris__
int net_getParam(char *driver, char *param);
-
-#ifndef SO_FLOW_SLA
-#define SO_FLOW_SLA 0x1018
-
-#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
-#pragma pack(4)
#endif
-/*
- * Used with the setsockopt(SO_FLOW_SLA, ...) call to set
- * per socket service level properties.
- * When the application uses per-socket API, we will enforce the properties
- * on both outbound and inbound packets.
- *
- * For now, only priority and maxbw are supported in SOCK_FLOW_PROP_VERSION1.
- */
-typedef struct sock_flow_props_s {
- int sfp_version;
- uint32_t sfp_mask;
- int sfp_priority; /* flow priority */
- uint64_t sfp_maxbw; /* bandwidth limit in bps */
- int sfp_status; /* flow create status for getsockopt */
-} sock_flow_props_t;
-
-#define SOCK_FLOW_PROP_VERSION1 1
-
-/* bit mask values for sfp_mask */
-#define SFP_MAXBW 0x00000001 /* Flow Bandwidth Limit */
-#define SFP_PRIORITY 0x00000008 /* Flow priority */
-
-/* possible values for sfp_priority */
-#define SFP_PRIO_NORMAL 1
-#define SFP_PRIO_HIGH 2
-
-#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
-#pragma pack()
-#endif /* _LONG_LONG_ALIGNMENT */
-
-#endif /* SO_FLOW_SLA */
-#endif /* __solaris__ */
-
-JNIEXPORT jboolean JNICALL NET_IsFlowSupported();
-
#endif /* NET_UTILS_MD_H */
diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java
index 63b2112aca1..00e68fb785b 100644
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java
@@ -113,6 +113,10 @@ class WindowsWatchService
// completion key (used to map I/O completion to WatchKey)
private int completionKey;
+ // flag indicates that ReadDirectoryChangesW failed
+ // and overlapped I/O operation wasn't started
+ private boolean errorStartingOverlapped;
+
WindowsWatchKey(Path dir,
AbstractWatchService watcher,
FileKey fileKey)
@@ -175,6 +179,14 @@ class WindowsWatchService
return completionKey;
}
+ void setErrorStartingOverlapped(boolean value) {
+ errorStartingOverlapped = value;
+ }
+
+ boolean isErrorStartingOverlapped() {
+ return errorStartingOverlapped;
+ }
+
// Invalidate the key, assumes that resources have been released
void invalidate() {
((WindowsWatchService)watcher()).poller.releaseResources(this);
@@ -182,6 +194,7 @@ class WindowsWatchService
buffer = null;
countAddress = 0;
overlappedAddress = 0;
+ errorStartingOverlapped = false;
}
@Override
@@ -455,11 +468,13 @@ class WindowsWatchService
* resources.
*/
private void releaseResources(WindowsWatchKey key) {
- try {
- CancelIo(key.handle());
- GetOverlappedResult(key.handle(), key.overlappedAddress());
- } catch (WindowsException expected) {
- // expected as I/O operation has been cancelled
+ if (!key.isErrorStartingOverlapped()) {
+ try {
+ CancelIo(key.handle());
+ GetOverlappedResult(key.handle(), key.overlappedAddress());
+ } catch (WindowsException expected) {
+ // expected as I/O operation has been cancelled
+ }
}
CloseHandle(key.handle());
closeAttachedEvent(key.overlappedAddress());
@@ -628,6 +643,7 @@ class WindowsWatchService
} catch (WindowsException x) {
// no choice but to cancel key
criticalError = true;
+ key.setErrorStartingOverlapped(true);
}
}
if (criticalError) {
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java
index 3a132f25595..027cbcf67e6 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java
@@ -83,7 +83,7 @@ class _AppMenuBarHandler {
// if we have no foreground frames, then we have to "kick" the menubar
final JFrame pingFrame = new JFrame();
- pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
+ pingFrame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(0.0f));
pingFrame.setUndecorated(true);
pingFrame.setVisible(true);
pingFrame.toFront();
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java
index 332cb7e46ff..88faf6b06e8 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java
@@ -58,7 +58,7 @@ class AquaComboBoxPopup extends BasicComboPopup {
updateContents(false);
// TODO: CPlatformWindow?
- putClientProperty(CPlatformWindow.WINDOW_FADE_OUT, new Integer(150));
+ putClientProperty(CPlatformWindow.WINDOW_FADE_OUT, Integer.valueOf(150));
}
public void updateContents(final boolean remove) {
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java
index 1534d6d80c7..e12033fceb5 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java
@@ -91,7 +91,7 @@ public class AquaInternalFramePaneUI extends BasicDesktopPaneUI implements Mouse
JComponent getDock() {
if (fDock == null) {
fDock = new Dock(desktop);
- desktop.add(fDock, new Integer(399)); // Just below the DRAG_LAYER
+ desktop.add(fDock, Integer.valueOf(399)); // Just below the DRAG_LAYER
}
return fDock;
}
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java
index f04d42de03b..6694dd4c292 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java
@@ -416,7 +416,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"Button.select", selected,
"Button.border",(LazyValue) t -> AquaButtonBorder.getDynamicButtonBorder(),
"Button.font", controlFont,
- "Button.textIconGap", new Integer(4),
+ "Button.textIconGap", Integer.valueOf(4),
"Button.textShiftOffset", zero, // radar 3308129 - aqua doesn't move images when pressed.
"Button.focusInputMap", controlFocusInputMap,
"Button.margin", new InsetsUIResource(0, 2, 0, 2),
@@ -635,8 +635,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
//"Menu.checkIcon", emptyCheckIcon, // A non-drawing GlyphIcon to make the spacing consistent
"Menu.arrowIcon",(LazyValue) t -> AquaImageFactory.getMenuArrowIcon(),
"Menu.consumesTabs", Boolean.TRUE,
- "Menu.menuPopupOffsetY", new Integer(1),
- "Menu.submenuPopupOffsetY", new Integer(-4),
+ "Menu.menuPopupOffsetY", Integer.valueOf(1),
+ "Menu.submenuPopupOffsetY", Integer.valueOf(-4),
"MenuBar.font", menuFont,
"MenuBar.background", menuBackgroundColor, // not a menu item, not selected
@@ -694,7 +694,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"OptionPane.informationSound", null, // Info and Plain
"OptionPane.questionSound", null,
"OptionPane.warningSound", null,
- "OptionPane.buttonClickThreshhold", new Integer(500),
+ "OptionPane.buttonClickThreshhold", Integer.valueOf(500),
"OptionPane.yesButtonMnemonic", "",
"OptionPane.noButtonMnemonic", "",
"OptionPane.okButtonMnemonic", "",
@@ -717,7 +717,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"PasswordField.caretBlinkRate", textCaretBlinkRate,
"PasswordField.border", textFieldBorder,
"PasswordField.margin", zeroInsets,
- "PasswordField.echoChar", new Character((char)0x25CF),
+ "PasswordField.echoChar", Character.valueOf((char)0x25CF),
"PasswordField.capsLockIconColor", textPasswordFieldCapsLockIconColor,
"PopupMenu.font", menuFont,
@@ -736,7 +736,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"ProgressBar.selectionForeground", black,
"ProgressBar.selectionBackground", white,
"ProgressBar.border", new BorderUIResource(BorderFactory.createEmptyBorder()),
- "ProgressBar.repaintInterval", new Integer(20),
+ "ProgressBar.repaintInterval", Integer.valueOf(20),
"RadioButton.background", controlBackgroundColor,
"RadioButton.foreground", black,
@@ -772,7 +772,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"ScrollBar.border", null,
"ScrollBar.focusInputMap", aquaKeyBindings.getScrollBarInputMap(),
"ScrollBar.focusInputMap.RightToLeft", aquaKeyBindings.getScrollBarRightToLeftInputMap(),
- "ScrollBar.width", new Integer(16),
+ "ScrollBar.width", Integer.valueOf(16),
"ScrollBar.background", white,
"ScrollBar.foreground", black,
@@ -816,7 +816,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
//"SplitPane.shadow", table.get("controlShadow"),
"SplitPane.background", panelBackgroundColor,
"SplitPane.border", scollListBorder,
- "SplitPane.dividerSize", new Integer(9), //$
+ "SplitPane.dividerSize", Integer.valueOf(9), //$
"SplitPaneDivider.border", null, // AquaSplitPaneDividerUI draws it
"SplitPaneDivider.horizontalGradientVariant",(LazyValue) t -> AquaSplitPaneDividerUI.getHorizontalSplitDividerGradientVariant(),
@@ -833,7 +833,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
//"TabbedPane.darkShadow", table.get("controlDkShadow"),
//"TabbedPane.focus", table.get("controlText"),
"TabbedPane.opaque", useOpaqueComponents,
- "TabbedPane.textIconGap", new Integer(4),
+ "TabbedPane.textIconGap", Integer.valueOf(4),
"TabbedPane.tabInsets", new InsetsUIResource(0, 10, 3, 10), // Label within tab (top, left, bottom, right)
//"TabbedPane.rightTabInsets", new InsetsUIResource(0, 10, 3, 10), // Label within tab (top, left, bottom, right)
"TabbedPane.leftTabInsets", new InsetsUIResource(0, 10, 3, 10), // Label within tab
@@ -973,9 +973,9 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"Tree.selectionBorderColor", selectionBackground, // match the background so it looks like we don't draw anything
"Tree.editorBorderSelectionColor", null, // The EditTextFrame provides its own border
// "Tree.editorBorder", textFieldBorder, // If you still have Sun bug 4376328 in DefaultTreeCellEditor, it has to have the same insets as TextField.border
- "Tree.leftChildIndent", new Integer(7),//$
- "Tree.rightChildIndent", new Integer(13),//$
- "Tree.rowHeight", new Integer(19),// iconHeight + 3, to match finder - a zero would have the renderer decide, except that leaves the icons touching
+ "Tree.leftChildIndent", Integer.valueOf(7),//$
+ "Tree.rightChildIndent", Integer.valueOf(13),//$
+ "Tree.rowHeight", Integer.valueOf(19),// iconHeight + 3, to match finder - a zero would have the renderer decide, except that leaves the icons touching
"Tree.scrollsOnExpand", Boolean.FALSE,
"Tree.openIcon",(LazyValue) t -> AquaImageFactory.getTreeOpenFolderIcon(), // Open folder icon
"Tree.closedIcon",(LazyValue) t -> AquaImageFactory.getTreeFolderIcon(), // Closed folder icon
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java
index d85ed9e8f67..ad78bc26ca3 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java
@@ -521,7 +521,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
}
// [2165820] Mac OS X change: mnemonics need to be triggered with ctrl-option, not just option.
mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, Event.ALT_MASK | Event.CTRL_MASK), "setSelectedIndex");
- mnemonicToIndexMap.put(new Integer(mnemonic), new Integer(index));
+ mnemonicToIndexMap.put(Integer.valueOf(mnemonic), Integer.valueOf(index));
}
/**
@@ -2084,7 +2084,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
if (mnemonic >= 'a' && mnemonic <= 'z') {
mnemonic -= ('a' - 'A');
}
- final Integer index = ui.mnemonicToIndexMap.get(new Integer(mnemonic));
+ final Integer index = ui.mnemonicToIndexMap.get(Integer.valueOf(mnemonic));
if (index != null && pane.isEnabledAt(index.intValue())) {
pane.setSelectedIndex(index.intValue());
}
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java
index 2acc1eaedcf..999d24a7886 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java
@@ -268,7 +268,7 @@ public class AquaUtilControlSize {
public SizeVariant alterFontSize(final float newSize) {
final float oldSize = fontSize == null ? 0.0f : fontSize.floatValue();
- fontSize = new Float(newSize + oldSize);
+ fontSize = newSize + oldSize;
return this;
}
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java
index bb2c0f1081b..b08b890aa2b 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java
@@ -32,8 +32,8 @@ import sun.lwawt.macosx.CPlatformWindow;
import sun.swing.SwingAccessor;
class ScreenPopupFactory extends PopupFactory {
- static final Float TRANSLUCENT = new Float(248f/255f);
- static final Float OPAQUE = new Float(1.0f);
+ static final Float TRANSLUCENT = 248f/255f;
+ static final Float OPAQUE = 1.0f;
boolean fIsActive = true;
diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
index c50533a5947..ed3838886c9 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
@@ -386,7 +386,7 @@ public final class CStrike extends PhysicalStrike {
if (generalCache == null) {
return 0L;
}
- final Long value = generalCache.get(new Integer(index));
+ final Long value = generalCache.get(Integer.valueOf(index));
if (value == null) {
return 0L;
}
@@ -415,7 +415,7 @@ public final class CStrike extends PhysicalStrike {
generalCache = new HashMap();
}
- generalCache.put(new Integer(index), Long.valueOf(value));
+ generalCache.put(Integer.valueOf(index), Long.valueOf(value));
}
public synchronized void dispose() {
@@ -526,7 +526,7 @@ public final class CStrike extends PhysicalStrike {
}
if (generalCache == null) return 0;
- final Float value = generalCache.get(new Integer(index));
+ final Float value = generalCache.get(Integer.valueOf(index));
if (value == null) return 0;
return value.floatValue();
}
@@ -553,7 +553,7 @@ public final class CStrike extends PhysicalStrike {
generalCache = new HashMap();
}
- generalCache.put(new Integer(index), new Float(value));
+ generalCache.put(Integer.valueOf(index), Float.valueOf(value));
}
private static class SparseBitShiftingTwoLayerArray {
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java
index d0a3f65ed58..a024da398b5 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java
@@ -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
@@ -903,7 +903,7 @@ public abstract class LWComponentPeer
@Override
public boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
focusLog.finest("lightweightChild=" + lightweightChild + ", temporary=" + temporary +
@@ -1278,7 +1278,7 @@ public abstract class LWComponentPeer
assert (e.getSource() == target);
if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
- LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
+ LWKeyboardFocusManagerPeer.requestFocusFor(target, FocusEvent.Cause.MOUSE_EVENT);
}
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java
index 4491b7c9c05..8205956b649 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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,8 +31,8 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.dnd.DropTarget;
+import java.awt.event.FocusEvent;
-import sun.awt.CausedFocusEvent;
import sun.awt.LightweightFrame;
import sun.swing.JLightweightFrame;
import sun.swing.SwingAccessor;
@@ -60,7 +60,7 @@ public class LWLightweightFramePeer extends LWWindowPeer {
}
@Override
- public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+ public boolean requestWindowFocus(FocusEvent.Cause cause) {
if (!focusAllowedFor()) {
return false;
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java
index b7262a5a402..daa02981c27 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java
@@ -404,6 +404,10 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
public final PrintJob getPrintJob(Frame frame, String doctitle,
JobAttributes jobAttributes,
PageAttributes pageAttributes) {
+ if (frame == null) {
+ throw new NullPointerException("frame must not be null");
+ }
+
if (GraphicsEnvironment.isHeadless()) {
throw new IllegalArgumentException();
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
index fabc2a21ba1..658be0638bb 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, 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
@@ -256,14 +256,14 @@ public class LWWindowPeer
if (!getTarget().isAutoRequestFocus()) {
return;
} else {
- requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
+ requestWindowFocus(FocusEvent.Cause.ACTIVATION);
}
// Focus the owner in case this window is focused.
} else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) {
// Transfer focus to the owner.
LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this);
if (owner != null) {
- owner.requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
+ owner.requestWindowFocus(FocusEvent.Cause.ACTIVATION);
}
}
}
@@ -295,7 +295,7 @@ public class LWWindowPeer
if (f == null) {
f = DEFAULT_FONT;
}
- return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f));
+ return new SunGraphics2D(getSurfaceData(), fg, bg, f);
}
@Override
@@ -848,7 +848,7 @@ public class LWWindowPeer
// 2. An active but not focused owner frame/dialog is clicked.
// The mouse event then will trigger a focus request "in window" to the component, so the window
// should gain focus before.
- requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
+ requestWindowFocus(FocusEvent.Cause.MOUSE_EVENT);
mouseDownTarget[targetIdx] = targetPeer;
} else if (id == MouseEvent.MOUSE_DRAGGED) {
@@ -1199,7 +1199,7 @@ public class LWWindowPeer
* Requests platform to set native focus on a frame/dialog.
* In case of a simple window, triggers appropriate java focus change.
*/
- public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+ public boolean requestWindowFocus(FocusEvent.Cause cause) {
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
focusLog.fine("requesting native focus to " + this);
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java
index 06bc5f48a83..0e3be9d81a1 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, 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
@@ -26,8 +26,8 @@
package sun.lwawt;
import java.awt.*;
+import java.awt.event.FocusEvent;
-import sun.awt.CausedFocusEvent;
import sun.java2d.SurfaceData;
// TODO Is it worth to generify this interface, like that:
@@ -114,7 +114,7 @@ public interface PlatformWindow {
public void updateFocusableWindowState();
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause);
+ public boolean rejectFocusRequest(FocusEvent.Cause cause);
public boolean requestWindowFocus();
@@ -130,12 +130,6 @@ public interface PlatformWindow {
*/
public void setSizeConstraints(int minW, int minH, int maxW, int maxH);
- /**
- * Transforms the given Graphics object according to the native
- * implementation traits (insets, etc.).
- */
- public Graphics transformGraphics(Graphics g);
-
/*
* Installs the images for particular window.
*/
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java
new file mode 100644
index 00000000000..c575590802b
--- /dev/null
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java
@@ -0,0 +1,253 @@
+/*
+ * 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
+ * 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.lwawt.macosx;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+import javax.swing.event.EventListenerList;
+
+/**
+ * {@code AccessibilityEventMonitor} implements a PropertyChange listener
+ * on every UI object that implements interface {@code Accessible} in the Java
+ * Virtual Machine. The events captured by these listeners are made available
+ * through listeners supported by {@code AccessibilityEventMonitor}.
+ * With this, all the individual events on each of the UI object
+ * instances are funneled into one set of PropertyChange listeners.
+ *
+ * This code is a subset of com.sun.java.accessibility.util.AccessibilityEventMonitor
+ * which resides in module jdk.accessibility. Due to modularization the code in
+ * this package, java.desktop, can not be dependent on code in jdk.accessibility.
+ */
+
+class AccessibilityEventMonitor {
+
+ /**
+ * The current list of registered {@link java.beans.PropertyChangeListener
+ * PropertyChangeListener} classes.
+ *
+ * @see #addPropertyChangeListener
+ */
+ private static final EventListenerList listenerList =
+ new EventListenerList();
+
+
+ /**
+ * The actual listener that is installed on the component instances.
+ * This listener calls the other registered listeners when an event
+ * occurs. By doing things this way, the actual number of listeners
+ * installed on a component instance is drastically reduced.
+ */
+ private static final AccessibilityEventListener accessibilityListener =
+ new AccessibilityEventListener();
+
+ /**
+ * Adds the specified listener to receive all PropertyChange events on
+ * each UI object instance in the Java Virtual Machine as they occur.
+ *
Note: This listener is automatically added to all component
+ * instances created after this method is called. In addition, it
+ * is only added to UI object instances that support this listener type.
+ *
+ * @param l the listener to add
+ * @param a the Accessible object to add the PropertyChangeListener to
+ */
+
+ static void addPropertyChangeListener(PropertyChangeListener l, Accessible a) {
+ if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) {
+ accessibilityListener.installListeners(a);
+ }
+ listenerList.add(PropertyChangeListener.class, l);
+ }
+
+ /**
+ * AccessibilityEventListener is the class that does all the work for
+ * AccessibilityEventMonitor. It is not intended for use by any other
+ * class except AccessibilityEventMonitor.
+ */
+
+ private static class AccessibilityEventListener implements PropertyChangeListener {
+
+ /**
+ * Installs PropertyChange listeners to the Accessible object, and its
+ * children (so long as the object isn't of TRANSIENT state).
+ *
+ * @param a the Accessible object to add listeners to
+ */
+ private void installListeners(Accessible a) {
+ installListeners(a.getAccessibleContext());
+ }
+
+ /**
+ * Installs PropertyChange listeners to the AccessibleContext object,
+ * and its * children (so long as the object isn't of TRANSIENT state).
+ *
+ * @param ac the AccessibleContext to add listeners to
+ */
+ private void installListeners(AccessibleContext ac) {
+
+ if (ac != null) {
+ AccessibleStateSet states = ac.getAccessibleStateSet();
+ if (!states.contains(AccessibleState.TRANSIENT)) {
+ ac.addPropertyChangeListener(this);
+ /*
+ * Don't add listeners to transient children. Components
+ * with transient children should return an AccessibleStateSet
+ * containing AccessibleState.MANAGES_DESCENDANTS. Components
+ * may not explicitly return the MANAGES_DESCENDANTS state.
+ * In this case, don't add listeners to the children of
+ * lists, tables and trees.
+ */
+ AccessibleStateSet set = ac.getAccessibleStateSet();
+ if (set.contains(AccessibleState.MANAGES_DESCENDANTS)) {
+ return;
+ }
+ AccessibleRole role = ac.getAccessibleRole();
+ if ( role == AccessibleRole.LIST ||
+ role == AccessibleRole.TREE ) {
+ return;
+ }
+ if (role == AccessibleRole.TABLE) {
+ // handle Oracle tables containing tables
+ Accessible child = ac.getAccessibleChild(0);
+ if (child != null) {
+ AccessibleContext ac2 = child.getAccessibleContext();
+ if (ac2 != null) {
+ role = ac2.getAccessibleRole();
+ if (role != null && role != AccessibleRole.TABLE) {
+ return;
+ }
+ }
+ }
+ }
+ int count = ac.getAccessibleChildrenCount();
+ for (int i = 0; i < count; i++) {
+ Accessible child = ac.getAccessibleChild(i);
+ if (child != null) {
+ installListeners(child);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes PropertyChange listeners for the given Accessible object,
+ * its children (so long as the object isn't of TRANSIENT state).
+ *
+ * @param a the Accessible object to remove listeners from
+ */
+ private void removeListeners(Accessible a) {
+ removeListeners(a.getAccessibleContext());
+ }
+
+ /**
+ * Removes PropertyChange listeners for the given AccessibleContext
+ * object, its children (so long as the object isn't of TRANSIENT
+ * state).
+ *
+ * @param a the Accessible object to remove listeners from
+ */
+ private void removeListeners(AccessibleContext ac) {
+
+ if (ac != null) {
+ // Listeners are not added to transient components.
+ AccessibleStateSet states = ac.getAccessibleStateSet();
+ if (!states.contains(AccessibleState.TRANSIENT)) {
+ ac.removePropertyChangeListener(this);
+ /*
+ * Listeners are not added to transient children. Components
+ * with transient children should return an AccessibleStateSet
+ * containing AccessibleState.MANAGES_DESCENDANTS. Components
+ * may not explicitly return the MANAGES_DESCENDANTS state.
+ * In this case, don't remove listeners from the children of
+ * lists, tables and trees.
+ */
+ if (states.contains(AccessibleState.MANAGES_DESCENDANTS)) {
+ return;
+ }
+ AccessibleRole role = ac.getAccessibleRole();
+ if ( role == AccessibleRole.LIST ||
+ role == AccessibleRole.TABLE ||
+ role == AccessibleRole.TREE ) {
+ return;
+ }
+ int count = ac.getAccessibleChildrenCount();
+ for (int i = 0; i < count; i++) {
+ Accessible child = ac.getAccessibleChild(i);
+ if (child != null) {
+ removeListeners(child);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ // propogate the event
+ Object[] listeners =
+ AccessibilityEventMonitor.listenerList.getListenerList();
+ for (int i = listeners.length-2; i>=0; i-=2) {
+ if (listeners[i]==PropertyChangeListener.class) {
+ ((PropertyChangeListener)listeners[i+1]).propertyChange(e);
+ }
+ }
+
+ // handle childbirth/death
+ String name = e.getPropertyName();
+ if (name.compareTo(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) == 0) {
+ Object oldValue = e.getOldValue();
+ Object newValue = e.getNewValue();
+
+ if ((oldValue == null) ^ (newValue == null)) { // one null, not both
+ if (oldValue != null) {
+ // this Accessible is a child that's going away
+ if (oldValue instanceof Accessible) {
+ Accessible a = (Accessible) oldValue;
+ removeListeners(a.getAccessibleContext());
+ } else if (oldValue instanceof AccessibleContext) {
+ removeListeners((AccessibleContext) oldValue);
+ }
+ } else if (newValue != null) {
+ // this Accessible is a child was just born
+ if (newValue instanceof Accessible) {
+ Accessible a = (Accessible) newValue;
+ installListeners(a.getAccessibleContext());
+ } else if (newValue instanceof AccessibleContext) {
+ installListeners((AccessibleContext) newValue);
+ }
+ }
+ } else {
+ System.out.println("ERROR in usage of PropertyChangeEvents for: " + e.toString());
+ }
+ }
+ }
+ }
+}
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 c5611c4d453..20ce3551d94 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
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,20 +26,18 @@
package sun.lwawt.macosx;
import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.lang.reflect.Field;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.JProgressBar;
import javax.swing.JSlider;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.text.JTextComponent;
+import sun.lwawt.macosx.CFRetainedResource;
class CAccessible extends CFRetainedResource implements Accessible {
static Field getNativeAXResourceField() {
@@ -99,13 +97,10 @@ class CAccessible extends CFRetainedResource implements Accessible {
return accessible.getAccessibleContext();
}
- // currently only supports text components
public void addNotificationListeners(Component c) {
- if (c instanceof JTextComponent) {
- JTextComponent tc = (JTextComponent) c;
- AXTextChangeNotifier listener = new AXTextChangeNotifier();
- tc.getDocument().addDocumentListener(listener);
- tc.addCaretListener(listener);
+ AXTextChangeNotifier listener = new AXTextChangeNotifier();
+ if (c instanceof Accessible) {
+ AccessibilityEventMonitor.addPropertyChangeListener(listener, (Accessible)c);
}
if (c instanceof JProgressBar) {
JProgressBar pb = (JProgressBar) c;
@@ -117,29 +112,23 @@ class CAccessible extends CFRetainedResource implements Accessible {
}
- private class AXTextChangeNotifier implements DocumentListener, CaretListener {
- @Override
- public void changedUpdate(DocumentEvent e) {
- if (ptr != 0) valueChanged(ptr);
- }
+ private class AXTextChangeNotifier implements PropertyChangeListener {
@Override
- public void insertUpdate(DocumentEvent e) {
- if (ptr != 0) valueChanged(ptr);
- }
-
- @Override
- public void removeUpdate(DocumentEvent e) {
- if (ptr != 0) valueChanged(ptr);
- }
-
- @Override
- public void caretUpdate(CaretEvent e) {
- if (ptr != 0) selectionChanged(ptr);
+ public void propertyChange(PropertyChangeEvent e) {
+ String name = e.getPropertyName();
+ if ( ptr != 0 ) {
+ if (name.compareTo(AccessibleContext.ACCESSIBLE_CARET_PROPERTY) == 0) {
+ selectionChanged(ptr);
+ } else if (name.compareTo(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY) == 0 ) {
+ valueChanged(ptr);
+ }
+ }
}
}
private class AXProgressChangeNotifier implements ChangeListener {
+ @Override
public void stateChanged(ChangeEvent e) {
if (ptr != 0) valueChanged(ptr);
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java
index 34651baba70..e232541c4e3 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, 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
@@ -26,6 +26,7 @@
package sun.lwawt.macosx;
import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
import java.awt.peer.*;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.event.*;
@@ -34,7 +35,6 @@ import java.security.AccessController;
import java.util.List;
import java.io.*;
-import sun.awt.CausedFocusEvent.Cause;
import sun.awt.AWTAccessor;
import sun.java2d.pipe.Region;
import sun.security.action.GetBooleanAction;
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
index f6ab6bbb4ad..d7c6d2903f6 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, 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
@@ -26,11 +26,11 @@
package sun.lwawt.macosx;
import java.awt.*;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent;
+
import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLLayer;
import sun.lwawt.LWWindowPeer;
-import sun.lwawt.LWWindowPeer.PeerType;
import sun.lwawt.PlatformWindow;
import sun.util.logging.PlatformLogger;
@@ -39,7 +39,8 @@ import sun.util.logging.PlatformLogger;
*/
public class CPlatformEmbeddedFrame implements PlatformWindow {
- private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformEmbeddedFrame");
+ private static final PlatformLogger focusLogger = PlatformLogger.getLogger(
+ "sun.lwawt.macosx.focus.CPlatformEmbeddedFrame");
private CGLLayer windowLayer;
private LWWindowPeer peer;
@@ -133,9 +134,9 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
public void updateFocusableWindowState() {}
@Override
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+ public boolean rejectFocusRequest(FocusEvent.Cause cause) {
// Cross-app activation requests are not allowed.
- if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
+ if (cause != FocusEvent.Cause.MOUSE_EVENT &&
!target.isParentWindowActive())
{
focusLogger.fine("the embedder is inactive, so the request is rejected");
@@ -160,11 +161,6 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
@Override
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {}
- @Override
- public Graphics transformGraphics(Graphics g) {
- return g;
- }
-
@Override
public void updateIconImages() {}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
index 0d9f9744c41..a056df5cc10 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@ package sun.lwawt.macosx;
import java.awt.Font;
import java.awt.FontMetrics;
-import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
@@ -37,7 +36,7 @@ import java.awt.Rectangle;
import java.awt.Window;
import sun.awt.CGraphicsDevice;
import sun.awt.CGraphicsEnvironment;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent;
import sun.awt.LightweightFrame;
import sun.java2d.SurfaceData;
import sun.lwawt.LWLightweightFramePeer;
@@ -134,7 +133,7 @@ public class CPlatformLWWindow extends CPlatformWindow {
}
@Override
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+ public boolean rejectFocusRequest(FocusEvent.Cause cause) {
return false;
}
@@ -152,11 +151,6 @@ public class CPlatformLWWindow extends CPlatformWindow {
public void updateFocusableWindowState() {
}
- @Override
- public Graphics transformGraphics(Graphics g) {
- return null;
- }
-
@Override
public void setAlwaysOnTop(boolean isAlwaysOnTop) {
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
index a9214b45ba7..f0d0a22b3bc 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, 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
@@ -706,9 +706,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
}
@Override
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+ public boolean rejectFocusRequest(FocusEvent.Cause cause) {
// Cross-app activation requests are not allowed.
- if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
+ if (cause != FocusEvent.Cause.MOUSE_EVENT &&
!((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
{
focusLogger.fine("the app is inactive, so the request is rejected");
@@ -740,12 +740,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once
}
- @Override
- public Graphics transformGraphics(Graphics g) {
- // is this where we can inject a transform for HiDPI?
- return g;
- }
-
@Override
public void setAlwaysOnTop(boolean isAlwaysOnTop) {
setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java
index 2d82a2eb1c1..abd092b8be9 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java
@@ -98,15 +98,26 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
private native long nativeCreate();
//invocation from the AWTTrayIcon.m
- public long getPopupMenuModel(){
- if(popup == null) {
- PopupMenu popupMenu = target.getPopupMenu();
- if (popupMenu != null) {
- popup = popupMenu;
+ public long getPopupMenuModel() {
+ PopupMenu newPopup = target.getPopupMenu();
+
+ if (popup == newPopup) {
+ if (popup == null) {
+ return 0L;
+ }
+ } else {
+ if (newPopup != null) {
+ if (popup != null) {
+ popup.removeNotify();
+ popup = newPopup;
+ } else {
+ popup = newPopup;
+ }
} else {
return 0L;
}
}
+
return checkAndCreatePopupPeer().getModel();
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java
index 095922047fe..5fbb825a342 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java
@@ -87,23 +87,22 @@ public class CViewEmbeddedFrame extends EmbeddedFrame {
}
}
- /*
+ /**
* Initializes the embedded frame bounds and validates a component.
- * Designed to be called from the main thread
- * This method should be called once from the initialization of the SWT_AWT Bridge
+ * Designed to be called from the main thread. This method should be called
+ * once from the initialization of the SWT_AWT Bridge.
*/
- public void validateWithBounds(final int x, final int y, final int width, final int height) {
+ public void validateWithBounds(final int x, final int y, final int width,
+ final int height) {
try {
- final LWWindowPeer peer = AWTAccessor.getComponentAccessor()
- .getPeer(this);
- LWCToolkit.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- peer.setBoundsPrivate(0, 0, width, height);
- validate();
- setVisible(true);
- }
+ LWCToolkit.invokeAndWait(() -> {
+ final LWWindowPeer peer = AWTAccessor.getComponentAccessor()
+ .getPeer(this);
+ peer.setBoundsPrivate(0, 0, width, height);
+ validate();
+ setVisible(true);
}, this);
- } catch (InvocationTargetException ex) {}
+ } catch (InvocationTargetException ex) {
+ }
}
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
index 1c11789713f..2312fbb94be 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.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
@@ -27,13 +27,12 @@ package sun.lwawt.macosx;
import java.awt.Font;
import java.awt.FontMetrics;
-import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.Insets;
import java.awt.MenuBar;
import java.awt.Point;
import java.awt.Window;
-import sun.awt.CausedFocusEvent.Cause;
+import java.awt.event.FocusEvent.Cause;
import sun.java2d.SurfaceData;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformWindow;
@@ -170,11 +169,6 @@ public class CViewPlatformEmbeddedFrame implements PlatformWindow {
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
}
- @Override
- public Graphics transformGraphics(Graphics g) {
- return g;
- }
-
@Override
public void updateIconImages() {
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java
index b2c36705a09..28a4b657e55 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -364,8 +364,8 @@ public final class CWarningWindow extends CPlatformWindow
return null;
}
- return transformGraphics(new SunGraphics2D(sd, SystemColor.windowText,
- SystemColor.window, ownerWindow.getFont()));
+ return new SunGraphics2D(sd, SystemColor.windowText, SystemColor.window,
+ ownerWindow.getFont());
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
index f0bf99c7321..309bc8ca8b1 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
@@ -378,9 +378,9 @@ public final class LWCToolkit extends LWToolkit {
// These DnD properties must be set, otherwise Swing ends up spewing NPEs
// all over the place. The values came straight off of MToolkit.
- desktopProperties.put("DnD.Autoscroll.initialDelay", new Integer(50));
- desktopProperties.put("DnD.Autoscroll.interval", new Integer(50));
- desktopProperties.put("DnD.Autoscroll.cursorHysteresis", new Integer(5));
+ desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50));
+ desktopProperties.put("DnD.Autoscroll.interval", Integer.valueOf(50));
+ desktopProperties.put("DnD.Autoscroll.cursorHysteresis", Integer.valueOf(5));
desktopProperties.put("DnD.isDragImageSupported", Boolean.TRUE);
diff --git a/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java b/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java
index 69fbdce51dd..f753e04e83a 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java
@@ -42,7 +42,7 @@ import java.util.List;
* <new class="java.lang.Long">
* <string>10</string>
* </new>
- * is equivalent to {@code new Long("10")} in Java code.
+ * is equivalent to {@code Long.valueOf("10")} in Java code.
*
The following attributes are supported:
*
* - class
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java
index d955c5f593c..4510882ad4b 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java
@@ -128,7 +128,7 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants {
addChildNode(root, "BMPVersion", bmpVersion);
addChildNode(root, "Width", width);
addChildNode(root, "Height", height);
- addChildNode(root, "BitsPerPixel", new Short(bitsPerPixel));
+ addChildNode(root, "BitsPerPixel", Short.valueOf(bitsPerPixel));
addChildNode(root, "Compression", compression);
addChildNode(root, "ImageSize", imageSize);
@@ -172,12 +172,12 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants {
red = palette[j++] & 0xff;
green = palette[j++] & 0xff;
blue = palette[j++] & 0xff;
- addChildNode(entry, "Red", new Byte((byte)red));
- addChildNode(entry, "Green", new Byte((byte)green));
- addChildNode(entry, "Blue", new Byte((byte)blue));
+ addChildNode(entry, "Red", Byte.valueOf((byte)red));
+ addChildNode(entry, "Green", Byte.valueOf((byte)green));
+ addChildNode(entry, "Blue", Byte.valueOf((byte)blue));
if (numComps == 4)
addChildNode(entry, "Alpha",
- new Byte((byte)(palette[j++] & 0xff)));
+ Byte.valueOf((byte)(palette[j++] & 0xff)));
}
}
@@ -284,9 +284,9 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants {
private void addXYZPoints(IIOMetadataNode root, String name, double x, double y, double z) {
IIOMetadataNode node = addChildNode(root, name, null);
- addChildNode(node, "X", new Double(x));
- addChildNode(node, "Y", new Double(y));
- addChildNode(node, "Z", new Double(z));
+ addChildNode(node, "X", Double.valueOf(x));
+ addChildNode(node, "Y", Double.valueOf(y));
+ addChildNode(node, "Z", Double.valueOf(z));
}
private IIOMetadataNode addChildNode(IIOMetadataNode root,
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
index f52982a4461..940b0107a93 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -158,8 +158,8 @@ class GTKEngine {
int widgetType, int state, int shadowType, String detail,
int x, int y, int width, int height, int synthState, int dir);
private native void native_paint_slider(
- int widgetType, int state, int shadowType, String detail,
- int x, int y, int width, int height, int orientation);
+ int widgetType, int state, int shadowType, String detail, int x,
+ int y, int width, int height, int orientation, boolean hasFocus);
private native void native_paint_vline(
int widgetType, int state, String detail,
int x, int y, int width, int height);
@@ -491,6 +491,14 @@ class GTKEngine {
int gtkState =
GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
int synthState = context.getComponentState();
+ Container parent = context.getComponent().getParent();
+ if(GTKLookAndFeel.is3()) {
+ if (parent != null && parent.getParent() instanceof JComboBox) {
+ if (parent.getParent().hasFocus()) {
+ synthState |= SynthConstants.FOCUSED;
+ }
+ }
+ }
int dir = getTextDirection(context);
int widget = getWidgetType(context.getComponent(), id).ordinal();
native_paint_shadow(widget, gtkState, shadowType.ordinal(), detail,
@@ -498,13 +506,13 @@ class GTKEngine {
}
public void paintSlider(Graphics g, SynthContext context,
- Region id, int state, ShadowType shadowType, String detail,
- int x, int y, int w, int h, Orientation orientation) {
+ Region id, int state, ShadowType shadowType, String detail, int x,
+ int y, int w, int h, Orientation orientation, boolean hasFocus) {
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
int widget = getWidgetType(context.getComponent(), id).ordinal();
native_paint_slider(widget, state, shadowType.ordinal(), detail,
- x - x0, y - y0, w, h, orientation.ordinal());
+ x - x0, y - y0, w, h, orientation.ordinal(), hasFocus);
}
public void paintVline(Graphics g, SynthContext context,
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
index 199806d133a..be422a6275b 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, 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
@@ -54,7 +54,8 @@ import sun.swing.SwingUtilities2;
*/
@SuppressWarnings("serial") // Superclass not serializable
public class GTKLookAndFeel extends SynthLookAndFeel {
- private static final boolean IS_22;
+ private static boolean IS_22;
+ private static boolean IS_3;
/**
* Whether or not text is drawn antialiased. This keys off the
@@ -107,17 +108,6 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
private static String gtkThemeName = "Default";
static {
- // Backup for specifying the version, this isn't currently documented.
- // If you pass in anything but 2.2 you got the 2.0 colors/look.
- String version = AccessController.doPrivileged(
- new GetPropertyAction("swing.gtk.version"));
- if (version != null) {
- IS_22 = version.equals("2.2");
- }
- else {
- IS_22 = true;
- }
-
String language = Locale.getDefault().getLanguage();
boolean cjkLocale =
(Locale.CHINESE.getLanguage().equals(language) ||
@@ -158,6 +148,10 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
return IS_22;
}
+ static boolean is3() {
+ return IS_3;
+ }
+
/**
* Maps a swing constant to a GTK constant.
*/
@@ -385,7 +379,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
}
Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
- Double defaultCaretAspectRatio = new Double(0.025);
+ Double defaultCaretAspectRatio = Double.valueOf(0.025);
Color caretColor = table.getColor("caretColor");
Color controlText = table.getColor("controlText");
@@ -1460,6 +1454,19 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
throw new InternalError("Unable to load native GTK libraries");
}
+ if (UNIXToolkit.getGtkVersion() == UNIXToolkit.GtkVersions.GTK2) {
+ String version = AccessController.doPrivileged(
+ new GetPropertyAction("jdk.gtk.version"));
+ if (version != null) {
+ IS_22 = version.equals("2.2");
+ } else {
+ IS_22 = true;
+ }
+ } else if (UNIXToolkit.getGtkVersion() ==
+ UNIXToolkit.GtkVersions.GTK3) {
+ IS_3 = true;
+ }
+
super.initialize();
inInitialize = true;
loadStyles();
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
index ad61aca85f1..a607d4c41d4 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.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
@@ -576,12 +576,11 @@ class GTKPainter extends SynthPainter {
ShadowType.OUT, "menu", x, y, w, h);
GTKStyle style = (GTKStyle)context.getStyle();
- int xThickness = style.getXThickness();
- int yThickness = style.getYThickness();
+ Insets insets = style.getInsets(context, null);
ENGINE.paintBackground(g, context, id, gtkState,
- style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
- x + xThickness, y + yThickness,
- w - xThickness - xThickness, h - yThickness - yThickness);
+ style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
+ x + insets.left, y + insets.top, w - insets.left - insets.right,
+ h - insets.top - insets.bottom);
ENGINE.finishPainting();
}
}
@@ -640,6 +639,34 @@ class GTKPainter extends SynthPainter {
int state = context.getComponentState();
JComponent c = context.getComponent();
+ GTKStyle style = (GTKStyle) context.getStyle();
+ String detail;
+ // wide-separators are painted using box not line
+ if (style.getClassSpecificBoolValue(context,
+ "wide-separators", false)) {
+ Insets insets = c.getInsets();
+ x += insets.left;
+ y += insets.top;
+ if (orientation == JSeparator.HORIZONTAL) {
+ w -= (insets.left + insets.right);
+ detail = "hseparator";
+ } else {
+ h -= (insets.top + insets.bottom);
+ detail = "vseparator";
+ }
+ synchronized (UNIXToolkit.GTK_LOCK) {
+ if (! ENGINE.paintCachedImage(g, x, y, w, h, id, state,
+ detail, orientation)) {
+ ENGINE.startPainting(g, x, y, w, h, id, state,
+ detail, orientation);
+ ENGINE.paintBox(g, context, id, state,
+ ShadowType.ETCHED_OUT, detail, x, y, w, h);
+ ENGINE.finishPainting();
+ }
+ }
+ return;
+ }
+
/*
* Note: In theory, the style's x/y thickness values would determine
* the width of the separator content. In practice, however, some
@@ -650,7 +677,6 @@ class GTKPainter extends SynthPainter {
* the w/h values below too much, so that the full thickness of the
* rendered line will be captured by our image caching code.
*/
- String detail;
if (c instanceof JToolBar.Separator) {
/*
* GTK renders toolbar separators differently in that an
@@ -678,7 +704,6 @@ class GTKPainter extends SynthPainter {
float pct = 0.2f;
JToolBar.Separator sep = (JToolBar.Separator)c;
Dimension size = sep.getSeparatorSize();
- GTKStyle style = (GTKStyle)context.getStyle();
if (orientation == JSeparator.HORIZONTAL) {
x += (int)(w * pct);
w -= (int)(w * pct * 2);
@@ -743,6 +768,15 @@ class GTKPainter extends SynthPainter {
// The ubuntulooks engine paints slider troughs differently depending
// on the current slider value and its component orientation.
JSlider slider = (JSlider)context.getComponent();
+ if (GTKLookAndFeel.is3()) {
+ if (slider.getOrientation() == JSlider.VERTICAL) {
+ y += 1;
+ h -= 2;
+ } else {
+ x += 1;
+ w -= 2;
+ }
+ }
double value = slider.getValue();
double min = slider.getMinimum();
double max = slider.getMaximum();
@@ -776,15 +810,19 @@ class GTKPainter extends SynthPainter {
Region id = context.getRegion();
int gtkState = GTKLookAndFeel.synthStateToGTKState(
id, context.getComponentState());
+ boolean hasFocus = GTKLookAndFeel.is3() &&
+ ((context.getComponentState() & SynthConstants.FOCUSED) != 0);
synchronized (UNIXToolkit.GTK_LOCK) {
- if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir)) {
+ if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir,
+ hasFocus)) {
Orientation orientation = (dir == JSlider.HORIZONTAL ?
Orientation.HORIZONTAL : Orientation.VERTICAL);
String detail = (dir == JSlider.HORIZONTAL ?
"hscale" : "vscale");
ENGINE.startPainting(g, x, y, w, h, id, gtkState, dir);
ENGINE.paintSlider(g, context, id, gtkState,
- ShadowType.OUT, detail, x, y, w, h, orientation);
+ ShadowType.OUT, detail, x, y, w, h, orientation,
+ hasFocus);
ENGINE.finishPainting();
}
}
@@ -963,15 +1001,21 @@ class GTKPainter extends SynthPainter {
int yThickness = style.getYThickness();
ENGINE.startPainting(g, x, y, w, h, id, state);
+ if (GTKLookAndFeel.is3()) {
+ ENGINE.paintBackground(g, context, id, gtkState, null,
+ x, y, w, h);
+ }
ENGINE.paintShadow(g, context, id, gtkState,
ShadowType.IN, "entry", x, y, w, h);
- ENGINE.paintFlatBox(g, context, id,
- gtkState, ShadowType.NONE, "entry_bg",
- x + xThickness,
- y + yThickness,
- w - (2 * xThickness),
- h - (2 * yThickness),
- ColorType.TEXT_BACKGROUND);
+ if (!GTKLookAndFeel.is3()) {
+ ENGINE.paintFlatBox(g, context, id,
+ gtkState, ShadowType.NONE, "entry_bg",
+ x + xThickness,
+ y + yThickness,
+ w - (2 * xThickness),
+ h - (2 * yThickness),
+ ColorType.TEXT_BACKGROUND);
+ }
if (focusSize > 0 && (state & SynthConstants.FOCUSED) != 0) {
if (!interiorFocus) {
@@ -982,14 +1026,14 @@ class GTKPainter extends SynthPainter {
} else {
if (containerParent instanceof JComboBox) {
x += (focusSize + 2);
- y += (focusSize + 1);
- w -= (2 * focusSize + 1);
- h -= (2 * focusSize + 2);
+ y += focusSize + (GTKLookAndFeel.is3() ? 3 : 1);
+ w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 1);
+ h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 6 : 2);
} else {
- x += focusSize;
- y += focusSize;
- w -= 2 * focusSize;
- h -= 2 * focusSize;
+ x += focusSize + (GTKLookAndFeel.is3() ? 2 : 0);
+ y += focusSize + (GTKLookAndFeel.is3() ? 2 :0 );
+ w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0);
+ h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0);
}
}
ENGINE.paintFocus(g, context, id, gtkState,
@@ -1138,8 +1182,8 @@ class GTKPainter extends SynthPainter {
Orientation orientation = (dir == JScrollBar.HORIZONTAL ?
Orientation.HORIZONTAL : Orientation.VERTICAL);
ENGINE.setRangeValue(context, id, value, min, max, visible);
- ENGINE.paintSlider(g, context, id, gtkState,
- ShadowType.OUT, "slider", x, y, w, h, orientation);
+ ENGINE.paintSlider(g, context, id, gtkState, ShadowType.OUT,
+ "slider", x, y, w, h, orientation, false);
ENGINE.finishPainting();
}
}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
index 4fa44c758e5..2c60551dd04 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, 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
@@ -715,29 +715,33 @@ class GTKStyle extends SynthStyle implements GTKConstants {
if (region == Region.COMBO_BOX ||
region == Region.DESKTOP_PANE ||
region == Region.DESKTOP_ICON ||
- region == Region.EDITOR_PANE ||
- region == Region.FORMATTED_TEXT_FIELD ||
region == Region.INTERNAL_FRAME ||
region == Region.LIST ||
region == Region.MENU_BAR ||
region == Region.PANEL ||
- region == Region.PASSWORD_FIELD ||
region == Region.POPUP_MENU ||
region == Region.PROGRESS_BAR ||
region == Region.ROOT_PANE ||
region == Region.SCROLL_PANE ||
- region == Region.SPINNER ||
region == Region.SPLIT_PANE_DIVIDER ||
region == Region.TABLE ||
region == Region.TEXT_AREA ||
- region == Region.TEXT_FIELD ||
- region == Region.TEXT_PANE ||
region == Region.TOOL_BAR_DRAG_WINDOW ||
region == Region.TOOL_TIP ||
region == Region.TREE ||
region == Region.VIEWPORT) {
return true;
}
+ if (!GTKLookAndFeel.is3()) {
+ if (region == Region.EDITOR_PANE ||
+ region == Region.FORMATTED_TEXT_FIELD ||
+ region == Region.PASSWORD_FIELD ||
+ region == Region.SPINNER ||
+ region == Region.TEXT_FIELD ||
+ region == Region.TEXT_PANE) {
+ return true;
+ }
+ }
Component c = context.getComponent();
String name = c.getName();
if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") {
@@ -776,6 +780,15 @@ class GTKStyle extends SynthStyle implements GTKConstants {
}
else if (key == "Separator.thickness") {
JSeparator sep = (JSeparator)context.getComponent();
+ if (getClassSpecificBoolValue(context, "wide-separators", false)) {
+ if (sep.getOrientation() == JSeparator.HORIZONTAL) {
+ return getClassSpecificIntValue(context,
+ "separator-height", 0);
+ } else {
+ return getClassSpecificIntValue(context,
+ "separator-width", 0);
+ }
+ }
if (sep.getOrientation() == JSeparator.HORIZONTAL) {
return getYThickness();
} else {
@@ -783,6 +796,12 @@ class GTKStyle extends SynthStyle implements GTKConstants {
}
}
else if (key == "ToolBar.separatorSize") {
+ if (getClassSpecificBoolValue(context, "wide-separators", false)) {
+ return new DimensionUIResource(
+ getClassSpecificIntValue(context, "separator-width", 2),
+ getClassSpecificIntValue(context, "separator-height", 2)
+ );
+ }
int size = getClassSpecificIntValue(WidgetType.TOOL_BAR,
"space-size", 12);
return new DimensionUIResource(size, size);
@@ -833,6 +852,8 @@ class GTKStyle extends SynthStyle implements GTKConstants {
int focusPad =
getClassSpecificIntValue(context, "focus-padding", 1);
return indicatorSpacing + focusSize + focusPad;
+ } else if (GTKLookAndFeel.is3() && "ComboBox.forceOpaque".equals(key)) {
+ return true;
}
// Is it a stock icon ?
@@ -1112,6 +1133,7 @@ class GTKStyle extends SynthStyle implements GTKConstants {
static {
CLASS_SPECIFIC_MAP = new HashMap();
CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width");
+ CLASS_SPECIFIC_MAP.put("Slider.thumbWidth", "slider-length");
CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border");
CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size");
CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size");
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
index 3a0342792b3..b8b77f5ec93 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
@@ -185,7 +185,7 @@ class Metacity implements SynthConstants {
getIntAttr(child, "bottom", 0),
getIntAttr(child, "right", 0));
} else if ("aspect_ratio".equals(name)) {
- value = new Float(getFloatAttr(child, "value", 1.0F));
+ value = Float.valueOf(getFloatAttr(child, "value", 1.0F));
} else {
logError(themeName, "Unknown Metacity frame geometry value type: "+name);
}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java
index dab22fd293e..eb47262b29c 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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,7 +37,6 @@ import javax.swing.*;
-import sun.swing.UIClientPropertyKey;
import com.sun.java.swing.plaf.windows.TMSchema.State;
import static com.sun.java.swing.plaf.windows.TMSchema.State.*;
import com.sun.java.swing.plaf.windows.TMSchema.Part;
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 a01b9065c36..b2b51e08559 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,6 @@ import sun.awt.AWTAccessor;
import sun.awt.ConstrainableGraphics;
import sun.awt.SubRegionShowable;
import sun.awt.SunToolkit;
-import sun.awt.CausedFocusEvent;
import sun.awt.EmbeddedFrame;
import sun.awt.dnd.SunDropTargetEvent;
import sun.awt.im.CompositionArea;
@@ -878,7 +877,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
{
comp.setGraphicsConfiguration(gc);
}
- public boolean requestFocus(Component comp, CausedFocusEvent.Cause cause) {
+ public boolean requestFocus(Component comp, FocusEvent.Cause cause) {
return comp.requestFocus(cause);
}
public boolean canBeFocusOwner(Component comp) {
@@ -7538,7 +7537,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
requestFocusHelper(false, true);
}
- boolean requestFocus(CausedFocusEvent.Cause cause) {
+ boolean requestFocus(FocusEvent.Cause cause) {
return requestFocusHelper(false, true, cause);
}
@@ -7605,7 +7604,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
return requestFocusHelper(temporary, true);
}
- boolean requestFocus(boolean temporary, CausedFocusEvent.Cause cause) {
+ boolean requestFocus(boolean temporary, FocusEvent.Cause cause) {
return requestFocusHelper(temporary, true, cause);
}
/**
@@ -7656,7 +7655,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
return requestFocusHelper(false, false);
}
- boolean requestFocusInWindow(CausedFocusEvent.Cause cause) {
+ boolean requestFocusInWindow(FocusEvent.Cause cause) {
return requestFocusHelper(false, false, cause);
}
@@ -7721,18 +7720,18 @@ public abstract class Component implements ImageObserver, MenuContainer,
return requestFocusHelper(temporary, false);
}
- boolean requestFocusInWindow(boolean temporary, CausedFocusEvent.Cause cause) {
+ boolean requestFocusInWindow(boolean temporary, FocusEvent.Cause cause) {
return requestFocusHelper(temporary, false, cause);
}
final boolean requestFocusHelper(boolean temporary,
boolean focusedWindowChangeAllowed) {
- return requestFocusHelper(temporary, focusedWindowChangeAllowed, CausedFocusEvent.Cause.UNKNOWN);
+ return requestFocusHelper(temporary, focusedWindowChangeAllowed, FocusEvent.Cause.UNKNOWN);
}
final boolean requestFocusHelper(boolean temporary,
boolean focusedWindowChangeAllowed,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
// 1) Check if the event being dispatched is a system-generated mouse event.
AWTEvent currentEvent = EventQueue.getCurrentEvent();
@@ -7820,7 +7819,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
private boolean isRequestFocusAccepted(boolean temporary,
boolean focusedWindowChangeAllowed,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
if (!isFocusable() || !isVisible()) {
if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
@@ -7867,7 +7866,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
return true;
}
- if (CausedFocusEvent.Cause.ACTIVATION == cause) {
+ if (FocusEvent.Cause.ACTIVATION == cause) {
// we shouldn't call RequestFocusController in case we are
// in activation. We do request focus on component which
// has got temporary focus lost and then on component which is
@@ -7899,7 +7898,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
private static class DummyRequestFocusController implements RequestFocusController {
public boolean acceptRequestFocus(Component from, Component to,
boolean temporary, boolean focusedWindowChangeAllowed,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
return true;
}
@@ -7983,7 +7982,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
Component toFocus = getNextFocusCandidate();
boolean res = false;
if (toFocus != null && !toFocus.isFocusOwner() && toFocus != this) {
- res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_FORWARD);
+ res = toFocus.requestFocusInWindow(FocusEvent.Cause.TRAVERSAL_FORWARD);
}
if (clearOnFailure && !res) {
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
@@ -8063,7 +8062,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
toFocus = policy.getDefaultComponent(rootAncestor);
}
if (toFocus != null) {
- res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_BACKWARD);
+ res = toFocus.requestFocusInWindow(FocusEvent.Cause.TRAVERSAL_BACKWARD);
}
}
if (clearOnFailure && !res) {
@@ -8108,7 +8107,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRootPriv(fcr);
- rootAncestor.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
+ rootAncestor.requestFocus(FocusEvent.Cause.TRAVERSAL_UP);
} else {
Window window = getContainingWindow();
@@ -8118,7 +8117,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (toFocus != null) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRootPriv(window);
- toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
+ toFocus.requestFocus(FocusEvent.Cause.TRAVERSAL_UP);
}
}
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Container.java b/jdk/src/java.desktop/share/classes/java/awt/Container.java
index a16c2f55d97..04e3f1e89bd 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Container.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Container.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,6 @@ import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
@@ -3515,7 +3514,7 @@ public class Container extends Component {
Component toFocus = getFocusTraversalPolicy().
getDefaultComponent(this);
if (toFocus != null) {
- toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_DOWN);
+ toFocus.requestFocus(FocusEvent.Cause.TRAVERSAL_DOWN);
}
}
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java
index b6f1bcfbe4e..ad23e21655a 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, 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
@@ -40,7 +40,6 @@ import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
import sun.awt.TimedWindowEvent;
/**
@@ -165,13 +164,13 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
boolean clearOnFailure)
{
if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
- toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
+ toFocus.requestFocus(false, FocusEvent.Cause.ROLLBACK))
{
return true;
} else {
Component nextFocus = toFocus.getNextFocusCandidate();
if (nextFocus != null && nextFocus != vetoedComponent &&
- nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
+ nextFocus.requestFocusInWindow(FocusEvent.Cause.ROLLBACK))
{
return true;
} else if (clearOnFailure) {
@@ -431,13 +430,13 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
tempLost, toFocus);
}
if (tempLost != null) {
- tempLost.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+ tempLost.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
}
if (toFocus != null && toFocus != tempLost) {
// If there is a component which requested focus when this window
// was inactive it expects to receive focus after activation.
- toFocus.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+ toFocus.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
}
}
@@ -490,8 +489,6 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
case FocusEvent.FOCUS_GAINED: {
FocusEvent fe = (FocusEvent)e;
- CausedFocusEvent.Cause cause = (fe instanceof CausedFocusEvent) ?
- ((CausedFocusEvent)fe).getCause() : CausedFocusEvent.Cause.UNKNOWN;
Component oldFocusOwner = getGlobalFocusOwner();
Component newFocusOwner = fe.getComponent();
if (oldFocusOwner == newFocusOwner) {
@@ -509,10 +506,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
if (oldFocusOwner != null) {
boolean isEventDispatched =
sendMessage(oldFocusOwner,
- new CausedFocusEvent(oldFocusOwner,
+ new FocusEvent(oldFocusOwner,
FocusEvent.FOCUS_LOST,
fe.isTemporary(),
- newFocusOwner, cause));
+ newFocusOwner, fe.getCause()));
// Failed to dispatch, clear by ourselves
if (!isEventDispatched) {
setGlobalFocusOwner(null);
@@ -552,7 +549,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
// Refuse focus on a disabled component if the focus event
// isn't of UNKNOWN reason (i.e. not a result of a direct request
// but traversal, activation or system generated).
- (newFocusOwner.isEnabled() || cause.equals(CausedFocusEvent.Cause.UNKNOWN))))
+ (newFocusOwner.isEnabled() || fe.getCause().equals(FocusEvent.Cause.UNKNOWN))))
{
// we should not accept focus on such component, so reject it.
dequeueKeyEvents(-1, newFocusOwner);
@@ -601,10 +598,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
Component realOppositeComponent = this.realOppositeComponentWR.get();
if (realOppositeComponent != null &&
realOppositeComponent != fe.getOppositeComponent()) {
- fe = new CausedFocusEvent(newFocusOwner,
+ fe = new FocusEvent(newFocusOwner,
FocusEvent.FOCUS_GAINED,
fe.isTemporary(),
- realOppositeComponent, cause);
+ realOppositeComponent, fe.getCause());
((AWTEvent) fe).isPosted = true;
}
return typeAheadAssertions(newFocusOwner, fe);
@@ -729,10 +726,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
oppositeComp = oppositeWindow;
}
sendMessage(currentFocusOwner,
- new CausedFocusEvent(currentFocusOwner,
+ new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
true,
- oppositeComp, CausedFocusEvent.Cause.ACTIVATION));
+ oppositeComp, FocusEvent.Cause.ACTIVATION));
}
setGlobalFocusedWindow(null);
diff --git a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java
index 6b7d779a7db..aa9d64367a4 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, 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
@@ -57,7 +57,6 @@ import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
-import sun.awt.CausedFocusEvent;
import sun.awt.KeyboardFocusManagerPeerProvider;
import sun.awt.AWTAccessor;
@@ -124,7 +123,7 @@ public abstract class KeyboardFocusManager
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
return KeyboardFocusManager.shouldNativelyFocusHeavyweight(
heavyweight, descendant, temporary, focusedWindowChangeAllowed, time, cause);
@@ -2164,9 +2163,9 @@ public abstract class KeyboardFocusManager
private static final class LightweightFocusRequest {
final Component component;
final boolean temporary;
- final CausedFocusEvent.Cause cause;
+ final FocusEvent.Cause cause;
- LightweightFocusRequest(Component component, boolean temporary, CausedFocusEvent.Cause cause) {
+ LightweightFocusRequest(Component component, boolean temporary, FocusEvent.Cause cause) {
this.component = component;
this.temporary = temporary;
this.cause = cause;
@@ -2190,7 +2189,7 @@ public abstract class KeyboardFocusManager
}
HeavyweightFocusRequest(Component heavyweight, Component descendant,
- boolean temporary, CausedFocusEvent.Cause cause) {
+ boolean temporary, FocusEvent.Cause cause) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (heavyweight == null) {
log.fine("Assertion (heavyweight != null) failed");
@@ -2202,7 +2201,7 @@ public abstract class KeyboardFocusManager
addLightweightRequest(descendant, temporary, cause);
}
boolean addLightweightRequest(Component descendant,
- boolean temporary, CausedFocusEvent.Cause cause) {
+ boolean temporary, FocusEvent.Cause cause) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
@@ -2314,7 +2313,7 @@ public abstract class KeyboardFocusManager
hwFocusRequest =
new HeavyweightFocusRequest(heavyweight, descendant,
- temporary, CausedFocusEvent.Cause.UNKNOWN);
+ temporary, FocusEvent.Cause.UNKNOWN);
heavyweightRequests.add(hwFocusRequest);
if (currentFocusOwner != null) {
@@ -2379,7 +2378,7 @@ public abstract class KeyboardFocusManager
*/
static int shouldNativelyFocusHeavyweight
(Component heavyweight, Component descendant, boolean temporary,
- boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
+ boolean focusedWindowChangeAllowed, long time, FocusEvent.Cause cause)
{
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (heavyweight == null) {
@@ -2445,7 +2444,7 @@ public abstract class KeyboardFocusManager
if (currentFocusOwner != null) {
FocusEvent currentFocusOwnerEvent =
- new CausedFocusEvent(currentFocusOwner,
+ new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
temporary, descendant, cause);
// Fix 5028014. Rolled out.
@@ -2454,7 +2453,7 @@ public abstract class KeyboardFocusManager
currentFocusOwnerEvent);
}
FocusEvent newFocusOwnerEvent =
- new CausedFocusEvent(descendant, FocusEvent.FOCUS_GAINED,
+ new FocusEvent(descendant, FocusEvent.FOCUS_GAINED,
temporary, currentFocusOwner, cause);
// Fix 5028014. Rolled out.
// SunToolkit.postPriorityEvent(newFocusOwnerEvent);
@@ -2670,13 +2669,13 @@ public abstract class KeyboardFocusManager
* lw requests.
*/
if (currentFocusOwner != null) {
- currentFocusOwnerEvent = new CausedFocusEvent(currentFocusOwner,
+ currentFocusOwnerEvent = new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
lwFocusRequest.temporary,
lwFocusRequest.component, lwFocusRequest.cause);
}
FocusEvent newFocusOwnerEvent =
- new CausedFocusEvent(lwFocusRequest.component,
+ new FocusEvent(lwFocusRequest.component,
FocusEvent.FOCUS_GAINED,
lwFocusRequest.temporary,
currentFocusOwner == null ? lastFocusOwner : currentFocusOwner,
@@ -2726,8 +2725,8 @@ public abstract class KeyboardFocusManager
{
temporary = true;
}
- return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
- CausedFocusEvent.Cause.NATIVE_SYSTEM);
+ return new FocusEvent(source, fe.getID(), temporary, opposite,
+ FocusEvent.Cause.UNEXPECTED);
}
}
@@ -2802,7 +2801,7 @@ public abstract class KeyboardFocusManager
// 'opposite' will be fixed by
// DefaultKeyboardFocusManager.realOppositeComponent
- return new CausedFocusEvent(newSource,
+ return new FocusEvent(newSource,
FocusEvent.FOCUS_GAINED, temporary,
opposite, lwFocusRequest.cause);
}
@@ -2815,8 +2814,8 @@ public abstract class KeyboardFocusManager
// If it arrives as the result of activation we should skip it
// This event will not have appropriate request record and
// on arrival there will be already some focus owner set.
- return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false,
- null, CausedFocusEvent.Cause.ACTIVATION);
+ return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false,
+ null, FocusEvent.Cause.ACTIVATION);
}
return retargetUnexpectedFocusEvent(fe);
@@ -2839,9 +2838,9 @@ public abstract class KeyboardFocusManager
if (currentFocusOwner != null) {
// Call to KeyboardFocusManager.clearGlobalFocusOwner()
heavyweightRequests.removeFirst();
- return new CausedFocusEvent(currentFocusOwner,
+ return new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST, false, null,
- CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
+ FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
}
// Otherwise, fall through to failure case below
@@ -2850,9 +2849,9 @@ public abstract class KeyboardFocusManager
{
// Focus leaving application
if (currentFocusOwner != null) {
- return new CausedFocusEvent(currentFocusOwner,
+ return new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
- true, null, CausedFocusEvent.Cause.ACTIVATION);
+ true, null, FocusEvent.Cause.ACTIVATION);
} else {
return fe;
}
@@ -2878,15 +2877,15 @@ public abstract class KeyboardFocusManager
? true
: lwFocusRequest.temporary;
- return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
+ return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
temporary, lwFocusRequest.component, lwFocusRequest.cause);
} else if (focusedWindowChanged(opposite, currentFocusOwner)) {
// If top-level changed there might be no focus request in a list
// But we know the opposite, we now it is temporary - dispatch the event.
if (!fe.isTemporary() && currentFocusOwner != null) {
// Create copy of the event with only difference in temporary parameter.
- fe = new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
- true, opposite, CausedFocusEvent.Cause.ACTIVATION);
+ fe = new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
+ true, opposite, FocusEvent.Cause.ACTIVATION);
}
return fe;
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Window.java b/jdk/src/java.desktop/share/classes/java/awt/Window.java
index 5894ad303b7..71fc98009b3 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Window.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,6 @@ import javax.accessibility.*;
import sun.awt.AWTAccessor;
import sun.awt.AWTPermissions;
import sun.awt.AppContext;
-import sun.awt.CausedFocusEvent;
import sun.awt.DebugSettings;
import sun.awt.SunToolkit;
import sun.awt.util.IdentityArrayList;
@@ -2599,7 +2598,7 @@ public class Window extends Container implements Accessible {
{
Component toFocus =
KeyboardFocusManager.getMostRecentFocusOwner(owner);
- if (toFocus != null && toFocus.requestFocus(false, CausedFocusEvent.Cause.ACTIVATION)) {
+ if (toFocus != null && toFocus.requestFocus(false, FocusEvent.Cause.ACTIVATION)) {
return;
}
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java
index afef05edef0..c4483a4d927 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
package java.awt.event;
import java.awt.Component;
+import java.io.ObjectStreamException;
+
+import sun.awt.AWTAccessor;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
@@ -51,6 +54,10 @@ import sun.awt.SunToolkit;
* the FOCUS_GAINED and FOCUS_LOST event ids; the level may be distinguished in
* the event using the isTemporary() method.
*
+ * Every {@code FocusEvent} records its cause - the reason why this event was
+ * generated. The cause is assigned during the focus event creation and may be
+ * retrieved by calling {@link #getCause}.
+ *
* An unspecified behavior will be caused if the {@code id} parameter
* of any particular {@code FocusEvent} instance is not
* in the range from {@code FOCUS_FIRST} to {@code FOCUS_LAST}.
@@ -65,6 +72,61 @@ import sun.awt.SunToolkit;
*/
public class FocusEvent extends ComponentEvent {
+ /**
+ * This enum represents the cause of a {@code FocusEvent}- the reason why it
+ * occurred. Possible reasons include mouse events, keyboard focus
+ * traversal, window activation.
+ * If no cause is provided then the reason is {@code UNKNOWN}.
+ *
+ * @since 9
+ */
+ public enum Cause {
+ /**
+ * The default value.
+ */
+ UNKNOWN,
+ /**
+ * An activating mouse event.
+ */
+ MOUSE_EVENT,
+ /**
+ * A focus traversal action with unspecified direction.
+ */
+ TRAVERSAL,
+ /**
+ * An up-cycle focus traversal action.
+ */
+ TRAVERSAL_UP,
+ /**
+ * A down-cycle focus traversal action.
+ */
+ TRAVERSAL_DOWN,
+ /**
+ * A forward focus traversal action.
+ */
+ TRAVERSAL_FORWARD,
+ /**
+ * A backward focus traversal action.
+ */
+ TRAVERSAL_BACKWARD,
+ /**
+ * Restoring focus after a focus request has been rejected.
+ */
+ ROLLBACK,
+ /**
+ * A system action causing an unexpected focus change.
+ */
+ UNEXPECTED,
+ /**
+ * An activation of a toplevel window.
+ */
+ ACTIVATION,
+ /**
+ * Clearing global focus owner.
+ */
+ CLEAR_GLOBAL_FOCUS_OWNER
+ }
+
/**
* The first number in the range of ids used for focus events.
*/
@@ -85,6 +147,16 @@ public class FocusEvent extends ComponentEvent {
*/
public static final int FOCUS_LOST = 1 + FOCUS_FIRST; //Event.LOST_FOCUS
+ /**
+ * A focus event has the reason why this event was generated.
+ * The cause is set during the focus event creation.
+ *
+ * @serial
+ * @see #getCause()
+ * @since 9
+ */
+ private final Cause cause;
+
/**
* A focus event can have two different levels, permanent and temporary.
* It will be set to true if some operation takes away the focus
@@ -115,7 +187,8 @@ public class FocusEvent extends ComponentEvent {
/**
* Constructs a {@code FocusEvent} object with the
- * specified temporary state and opposite {@code Component}.
+ * specified temporary state, opposite {@code Component} and the
+ * {@code Cause.UNKNOWN} cause.
* The opposite {@code Component} is the other
* {@code Component} involved in this focus change.
* For a {@code FOCUS_GAINED} event, this is the
@@ -142,13 +215,57 @@ public class FocusEvent extends ComponentEvent {
* @see #getID()
* @see #isTemporary()
* @see #getOppositeComponent()
+ * @see Cause#UNKNOWN
* @since 1.4
*/
public FocusEvent(Component source, int id, boolean temporary,
Component opposite) {
+ this(source, id, temporary, opposite, Cause.UNKNOWN);
+ }
+
+ /**
+ * Constructs a {@code FocusEvent} object with the
+ * specified temporary state, opposite {@code Component} and the cause.
+ * The opposite {@code Component} is the other
+ * {@code Component} involved in this focus change.
+ * For a {@code FOCUS_GAINED} event, this is the
+ * {@code Component} that lost focus. For a
+ * {@code FOCUS_LOST} event, this is the {@code Component}
+ * that gained focus. If this focus change occurs with a native
+ * application, with a Java application in a different VM,
+ * or with no other {@code Component}, then the opposite
+ * {@code Component} is {@code null}.
+ *
This method throws an
+ * {@code IllegalArgumentException} if {@code source} or {@code cause}
+ * is {@code null}.
+ *
+ * @param source The {@code Component} that originated the event
+ * @param id An integer indicating the type of event.
+ * For information on allowable values, see
+ * the class description for {@link FocusEvent}
+ * @param temporary Equals {@code true} if the focus change is temporary;
+ * {@code false} otherwise
+ * @param opposite The other Component involved in the focus change,
+ * or {@code null}
+ * @param cause The focus event cause.
+ * @throws IllegalArgumentException if {@code source} equals {@code null}
+ * or if {@code cause} equals {@code null}
+ * @see #getSource()
+ * @see #getID()
+ * @see #isTemporary()
+ * @see #getOppositeComponent()
+ * @see Cause
+ * @since 9
+ */
+ public FocusEvent(Component source, int id, boolean temporary,
+ Component opposite, Cause cause) {
super(source, id);
+ if (cause == null) {
+ throw new IllegalArgumentException("null cause");
+ }
this.temporary = temporary;
this.opposite = opposite;
+ this.cause = cause;
}
/**
@@ -220,8 +337,8 @@ public class FocusEvent extends ComponentEvent {
return (SunToolkit.targetToAppContext(opposite) ==
AppContext.getAppContext())
- ? opposite
- : null;
+ ? opposite
+ : null;
}
/**
@@ -233,17 +350,56 @@ public class FocusEvent extends ComponentEvent {
public String paramString() {
String typeStr;
switch(id) {
- case FOCUS_GAINED:
- typeStr = "FOCUS_GAINED";
- break;
- case FOCUS_LOST:
- typeStr = "FOCUS_LOST";
- break;
- default:
- typeStr = "unknown type";
+ case FOCUS_GAINED:
+ typeStr = "FOCUS_GAINED";
+ break;
+ case FOCUS_LOST:
+ typeStr = "FOCUS_LOST";
+ break;
+ default:
+ typeStr = "unknown type";
}
return typeStr + (temporary ? ",temporary" : ",permanent") +
- ",opposite=" + getOppositeComponent();
+ ",opposite=" + getOppositeComponent() + ",cause=" + getCause();
}
-}
+ /**
+ * Returns the event cause.
+ *
+ * @return one of {@link Cause} values
+ * @since 9
+ */
+ public final Cause getCause() {
+ return cause;
+ }
+
+ /**
+ * Checks if this deserialized {@code FocusEvent} instance is compatible
+ * with the current specification which implies that focus event has
+ * non-null {@code cause} value. If the check fails a new {@code FocusEvent}
+ * instance is returned which {@code cause} field equals to
+ * {@link Cause#UNKNOWN} and its other fields have the same values as in
+ * this {@code FocusEvent} instance.
+ *
+ * @serial
+ * @see #cause
+ * @since 9
+ */
+ @SuppressWarnings("serial")
+ Object readResolve() throws ObjectStreamException {
+ if (cause != null) {
+ return this;
+ }
+ FocusEvent focusEvent = new FocusEvent(new Component(){}, getID(),
+ isTemporary(), getOppositeComponent());
+ focusEvent.setSource(null);
+ focusEvent.consumed = consumed;
+
+ AWTAccessor.AWTEventAccessor accessor =
+ AWTAccessor.getAWTEventAccessor();
+ accessor.setBData(focusEvent, accessor.getBData(this));
+ return focusEvent;
+ }
+
+
+}
\ No newline at end of file
diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java
index 238dcb988f9..c9ae83659f6 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java
@@ -79,7 +79,7 @@ import jdk.internal.misc.SharedSecrets;
* will be ignored.
*
- The identity of the value does not matter, only the actual
* value. For example, {@code TextAttribute.WEIGHT_BOLD} and
- * {@code new Float(2.0)}
+ * {@code Float.valueOf(2.0f)}
* indicate the same {@code WEIGHT}.
*
- Attribute values of type {@code Number} (used for
* {@code WEIGHT}, {@code WIDTH}, {@code POSTURE},
diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java b/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java
index 4511d0eab15..5f47384697a 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java
@@ -105,7 +105,7 @@ public final class TextMeasurer implements Cloneable {
String s = System.getProperty("estLines");
if (s != null) {
try {
- Float f = new Float(s);
+ Float f = Float.valueOf(s);
EST_LINES = f.floatValue();
}
catch(NumberFormatException e) {
diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java
index bfbaf5e1b2a..f9a3a2d2058 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java
@@ -392,7 +392,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock add(float f) {
- return add(new Float(f));
+ return add(Float.valueOf(f));
}
/**
@@ -403,7 +403,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock add(double d) {
- return add(new Double(d));
+ return add(Double.valueOf(d));
}
/**
@@ -521,7 +521,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock set(float f, int index) {
- return set(new Float(f), index);
+ return set(Float.valueOf(f), index);
}
/**
@@ -537,7 +537,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock set(double d, int index) {
- return set(new Double(d), index);
+ return set(Double.valueOf(d), index);
}
/**
diff --git a/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java b/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java
index 2ac37efb7d1..40890c784e8 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,12 @@ package java.awt.peer;
import java.awt.*;
import java.awt.event.PaintEvent;
+import java.awt.event.FocusEvent.Cause;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
-import sun.awt.CausedFocusEvent;
import sun.java2d.pipe.Region;
@@ -343,7 +343,7 @@ public interface ComponentPeer {
*/
boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
- CausedFocusEvent.Cause cause);
+ Cause cause);
/**
* Returns {@code true} when the component takes part in the focus
diff --git a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java
index 3044cd2413a..5a1cf128607 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java
@@ -577,6 +577,8 @@ public abstract class PrinterJob {
/**
* Gets the name of the printing user.
* @return the name of the printing user
+ * @throws SecurityException if a security manager exists and
+ * PropertyPermission - user.name is not given in the policy file
*/
public abstract String getUserName();
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java
index 883e0c0cf7c..56d1df019ba 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, 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
@@ -36,7 +36,6 @@ import java.util.Set;
import java.awt.*;
import java.awt.event.*;
-import java.awt.peer.LightweightPeer;
import java.applet.Applet;
@@ -57,7 +56,6 @@ import javax.accessibility.*;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
import sun.swing.SwingUtilities2;
-import sun.swing.UIClientPropertyKey;
/**
* The base class for all Swing components except top-level containers.
@@ -3558,7 +3556,7 @@ public abstract class JComponent extends Container implements Serializable,
new sun.awt.RequestFocusController() {
public boolean acceptRequestFocus(Component from, Component to,
boolean temporary, boolean focusedWindowChangeAllowed,
- sun.awt.CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
if ((to == null) || !(to instanceof JComponent)) {
return true;
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java
index 3d561b99bef..6de8a0bd750 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java
@@ -98,7 +98,7 @@ import javax.accessibility.*;
*
* layeredPane.add(child, JLayeredPane.DEFAULT_LAYER);
* or
- * layeredPane.add(child, new Integer(10));
+ * layeredPane.add(child, Integer.valueOf.valueOf(10));
*
* The layer attribute can also be set on a Component by calling
* layeredPaneParent.setLayer(child, 10)
@@ -162,23 +162,23 @@ import javax.accessibility.*;
@SuppressWarnings("serial")
public class JLayeredPane extends JComponent implements Accessible {
/// Watch the values in getObjectForLayer()
- /** Convenience object defining the Default layer. Equivalent to new Integer(0).*/
+ /** Convenience object defining the Default layer. Equivalent to Integer.valueOf(0).*/
public static final Integer DEFAULT_LAYER = 0;
- /** Convenience object defining the Palette layer. Equivalent to new Integer(100).*/
+ /** Convenience object defining the Palette layer. Equivalent to Integer.valueOf(100).*/
public static final Integer PALETTE_LAYER = 100;
- /** Convenience object defining the Modal layer. Equivalent to new Integer(200).*/
+ /** Convenience object defining the Modal layer. Equivalent to Integer.valueOf(200).*/
public static final Integer MODAL_LAYER = 200;
- /** Convenience object defining the Popup layer. Equivalent to new Integer(300).*/
+ /** Convenience object defining the Popup layer. Equivalent to Integer.valueOf(300).*/
public static final Integer POPUP_LAYER = 300;
- /** Convenience object defining the Drag layer. Equivalent to new Integer(400).*/
+ /** Convenience object defining the Drag layer. Equivalent to Integer.valueOf(400).*/
public static final Integer DRAG_LAYER = 400;
/** Convenience object defining the Frame Content layer.
* This layer is normally only use to position the contentPane and menuBar
* components of JFrame.
- * Equivalent to new Integer(-30000).
+ * Equivalent to Integer.valueOf(-30000).
* @see JFrame
*/
- public static final Integer FRAME_CONTENT_LAYER = new Integer(-30000);
+ public static final Integer FRAME_CONTENT_LAYER = -30000;
/** Bound property */
public static final String LAYER_PROPERTY = "layeredContainerLayer";
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java b/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java
index 3504f2ef16a..216b18f4b19 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java
@@ -478,7 +478,7 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib
if (format == null) {
format = NumberFormat.getPercentInstance();
}
- return format.format(new Double(getPercentComplete()));
+ return format.format(Double.valueOf(getPercentComplete()));
}
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java
index 9ca12ea6ee1..ee53fbffd91 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java
@@ -81,7 +81,7 @@ import sun.swing.PrintingStatus;
* TableModel dataModel = new AbstractTableModel() {
* public int getColumnCount() { return 10; }
* public int getRowCount() { return 10;}
- * public Object getValueAt(int row, int col) { return new Integer(row*col); }
+ * public Object getValueAt(int row, int col) { return Integer.valueOf(row*col); }
* };
* JTable table = new JTable(dataModel);
* JScrollPane scrollpane = new JScrollPane(table);
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java b/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java
index 1d7fa9dec20..3fbd668bb80 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java
@@ -51,10 +51,10 @@ import java.io.Serializable;
* range zero to one hundred, with
* fifty as the initial value, one could write:
*
- * Integer value = new Integer(50);
- * Integer min = new Integer(0);
- * Integer max = new Integer(100);
- * Integer step = new Integer(1);
+ * Integer value = Integer.valueOf(50);
+ * Integer min = Integer.valueOf(0);
+ * Integer max = Integer.valueOf(100);
+ * Integer step = Integer.valueOf(1);
* SpinnerNumberModel model = new SpinnerNumberModel(value, min, max, step);
* int fifty = model.getNumber().intValue();
*
@@ -175,7 +175,8 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializ
* minimum <= value <= maximum
*/
public SpinnerNumberModel(double value, double minimum, double maximum, double stepSize) {
- this(new Double(value), new Double(minimum), new Double(maximum), new Double(stepSize));
+ this(Double.valueOf(value), Double.valueOf(minimum),
+ Double.valueOf(maximum), Double.valueOf(stepSize));
}
@@ -337,10 +338,10 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializ
if ((value instanceof Float) || (value instanceof Double)) {
double v = value.doubleValue() + (stepSize.doubleValue() * (double)dir);
if (value instanceof Double) {
- newValue = new Double(v);
+ newValue = Double.valueOf(v);
}
else {
- newValue = new Float(v);
+ newValue = Float.valueOf((float)v);
}
} else {
long v = value.longValue() + (stepSize.longValue() * (long)dir);
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java
index 6a48eb423a3..9900c9b7e0e 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java
@@ -845,6 +845,38 @@ public class SwingUtilities implements SwingConstants
return result;
}
+ /**
+ * Check whether MouseEvent contains speficied mouse button or
+ * mouse button down mask based on MouseEvent ID.
+ *
+ * @param anEvent a MouseEvent object
+ * @param mouseButton mouse button type
+ * @param mouseButtonDownMask mouse button down mask event modifier
+ *
+ * @return true if the anEvent contains speficied mouseButton or
+ * mouseButtonDownMask based on MouseEvent ID.
+ */
+ private static boolean checkMouseButton(MouseEvent anEvent,
+ int mouseButton,
+ int mouseButtonDownMask)
+ {
+ switch (anEvent.getID()) {
+ case MouseEvent.MOUSE_PRESSED:
+ case MouseEvent.MOUSE_RELEASED:
+ case MouseEvent.MOUSE_CLICKED:
+ return (anEvent.getButton() == mouseButton);
+
+ case MouseEvent.MOUSE_ENTERED:
+ case MouseEvent.MOUSE_EXITED:
+ case MouseEvent.MOUSE_DRAGGED:
+ return ((anEvent.getModifiersEx() & mouseButtonDownMask) != 0);
+
+ default:
+ return ((anEvent.getModifiersEx() & mouseButtonDownMask) != 0 ||
+ anEvent.getButton() == mouseButton);
+ }
+ }
+
/**
* Returns true if the mouse event specifies the left mouse button.
*
@@ -852,8 +884,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the left mouse button was active
*/
public static boolean isLeftMouseButton(MouseEvent anEvent) {
- return ((anEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0 ||
- anEvent.getButton() == MouseEvent.BUTTON1);
+ return checkMouseButton(anEvent, MouseEvent.BUTTON1,
+ InputEvent.BUTTON1_DOWN_MASK);
}
/**
@@ -863,8 +895,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the middle mouse button was active
*/
public static boolean isMiddleMouseButton(MouseEvent anEvent) {
- return ((anEvent.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0 ||
- anEvent.getButton() == MouseEvent.BUTTON2);
+ return checkMouseButton(anEvent, MouseEvent.BUTTON2,
+ InputEvent.BUTTON2_DOWN_MASK);
}
/**
@@ -874,8 +906,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the right mouse button was active
*/
public static boolean isRightMouseButton(MouseEvent anEvent) {
- return ((anEvent.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0 ||
- anEvent.getButton() == MouseEvent.BUTTON3);
+ return checkMouseButton(anEvent, MouseEvent.BUTTON3,
+ InputEvent.BUTTON3_DOWN_MASK);
}
/**
diff --git a/jdk/src/java.desktop/share/classes/sun/swing/UIClientPropertyKey.java b/jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java
similarity index 76%
rename from jdk/src/java.desktop/share/classes/sun/swing/UIClientPropertyKey.java
rename to jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java
index 6ec361cbf45..8aa2bf393fc 100644
--- a/jdk/src/java.desktop/share/classes/sun/swing/UIClientPropertyKey.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -23,18 +23,19 @@
* questions.
*/
-package sun.swing;
+package javax.swing;
/**
- * This interface is used only for tagging keys for client properties
- * for {@code JComponent} set by UI which needs to be cleared on {@literal L&F}
+ * This interface is used only for tagging keys for client properties for
+ * {@code JComponent} set by UI which needs to be cleared on {@literal L&F}
* change and serialization.
- *
- * All such keys are removed from client properties in {@code
- * JComponent.setUI()} method after uninstalling old UI and before
- * intalling the new one. They are also removed prior to serialization.
+ *
+ * All such keys are removed from client properties in
+ * {@code JComponent.setUI()} method after uninstalling old UI and before
+ * installing the new one. They are also removed prior to serialization.
*
* @author Igor Kushnirskiy
+ * @since 9
*/
public interface UIClientPropertyKey {
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java
index 1955407b75a..2ad447e6a18 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java
@@ -120,7 +120,7 @@ public class UIDefaults extends Hashtable