\n";
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/lang/String.java
--- a/jdk/src/java.base/share/classes/java/lang/String.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/String.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
*
* 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 @@
* 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 @@
* @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 @@
*
* @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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/lang/System.java
--- a/jdk/src/java.base/share/classes/java/lang/System.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/System.java Wed Jul 05 21:39:33 2017 +0200
@@ -1155,8 +1155,9 @@
* @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 @@
* @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 @@
* @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 @@
/**
* 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 @@
*
* @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 @@
*
* @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 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 @@
* @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 @@
// 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Wed Jul 05 21:39:33 2017 +0200
@@ -25,34 +25,38 @@
package java.lang.invoke;
-import java.lang.reflect.*;
+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 sun.reflect.misc.ReflectUtil;
+import sun.security.util.SecurityConstants;
+
+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.Arrays;
import java.util.Objects;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-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.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 @@
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 @@
* @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);
@@ -2214,6 +2224,27 @@
}
/**
+ * 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
* element type. Its first argument will be the array type,
@@ -2337,13 +2368,12 @@
*
* @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 @@
*/
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 @@
*
* @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 @@
*/
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java Wed Jul 05 21:39:33 2017 +0200
@@ -123,7 +123,7 @@
* 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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java Wed Jul 05 21:39:33 2017 +0200
@@ -136,6 +136,7 @@
* 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 @@
*
* 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 @@
*
*
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 @@
*
*
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 @@
*
*
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 @@
*
*
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 @@
*
*
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 @@
*
*
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 @@
*
*
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 @@
*
*
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 @@
*
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 @@
*
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 @@
*
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 @@
* {@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)}
@@ -867,20 +875,58 @@
/**
* 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,
* referred to as the witness value, {@code ==} the
* {@code expectedValue}, as accessed with the memory semantics of
* {@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 @@
* {@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 @@
*
*
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 @@
*
*
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 @@
*
*
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 @@
* 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template Wed Jul 05 21:39:33 2017 +0200
@@ -155,6 +155,15 @@
}
@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)),
handle.fieldOffset,
@@ -319,6 +328,15 @@
}
@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,
handle.fieldOffset,
@@ -535,6 +553,20 @@
}
@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]
Object[] array = (Object[]) handle.arrayType.cast(oarray);
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template Wed Jul 05 21:39:33 2017 +0200
@@ -228,6 +228,16 @@
}
@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;
return UNSAFE.weakCompareAndSwap$RawType$Acquire(
@@ -444,6 +454,16 @@
}
@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;
return UNSAFE.weakCompareAndSwap$RawType$Acquire(
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/util/Arrays.java
--- a/jdk/src/java.base/share/classes/java/util/Arrays.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/Arrays.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/util/Observable.java
--- a/jdk/src/java.base/share/classes/java/util/Observable.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/Observable.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
* @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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/util/Observer.java
--- a/jdk/src/java.base/share/classes/java/util/Observer.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/Observer.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
* @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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java
--- a/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
@Override
public final Stream boxed() {
- return mapToObj(Double::valueOf);
+ return mapToObj(Double::valueOf, 0);
}
@Override
@@ -207,18 +220,7 @@
@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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java
--- a/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
@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 @@
@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 @@
@Override
public final Stream boxed() {
- return mapToObj(Integer::valueOf);
+ return mapToObj(Integer::valueOf, 0);
}
@Override
@@ -242,18 +253,7 @@
@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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java
--- a/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
@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 @@
@Override
public final Stream boxed() {
- return mapToObj(Long::valueOf);
+ return mapToObj(Long::valueOf, 0);
}
@Override
@@ -223,18 +235,7 @@
@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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
--- a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java Wed Jul 05 21:39:33 2017 +0200
@@ -28,6 +28,7 @@
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 @@
// 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 @@
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 @@
this.unlimited = parent.unlimited;
this.permits = parent.permits;
this.skipThreshold = parent.skipThreshold;
+ this.chunkSize = parent.chunkSize;
}
/**
@@ -1029,13 +1034,13 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java Wed Jul 05 21:39:33 2017 +0200
@@ -33,6 +33,9 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java Wed Jul 05 21:39:33 2017 +0200
@@ -31,6 +31,7 @@
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 @@
* 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 @@
// 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 @@
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 @@
// 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 @@
* @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 @@
// 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 @@
// 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 @@
* 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 @@
* 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 @@
* 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 @@
// 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/jdk/net/ExtendedSocketOptions.java
--- a/jdk/src/java.base/share/classes/jdk/net/ExtendedSocketOptions.java Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/jdk/net/NetworkPermission.java
--- a/jdk/src/java.base/share/classes/jdk/net/NetworkPermission.java Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 jdk.net;
-
-import java.security.BasicPermission;
-
-/**
- * Represents permission to access the extended networking capabilities
- * defined in the jdk.net package. These permissions contain a target
- * name, but no actions list. Callers either possess the permission or not.
- *
- * The following targets are defined:
- *
- *
- *
- * Permission Target Name |
- * What the Permission Allows |
- * Risks of Allowing this Permission |
- *
- *
- * setOption.SO_FLOW_SLA |
- * set the {@link ExtendedSocketOptions#SO_FLOW_SLA SO_FLOW_SLA} option
- * on any socket that supports it |
- * allows caller to set a higher priority or bandwidth allocation
- * to sockets it creates, than they might otherwise be allowed. |
- *
- *
- * getOption.SO_FLOW_SLA |
- * retrieve the {@link ExtendedSocketOptions#SO_FLOW_SLA SO_FLOW_SLA}
- * setting from any socket that supports the option |
- * allows caller access to SLA information that it might not
- * otherwise have |
- *
- *
- * @see jdk.net.ExtendedSocketOptions
- *
- * @since 1.8
- */
-
-public final class NetworkPermission extends BasicPermission {
-
- private static final long serialVersionUID = -2012939586906722291L;
-
- /**
- * Creates a NetworkPermission with the given target name.
- *
- * @param name the permission target name
- * @throws NullPointerException if {@code name} is {@code null}.
- * @throws IllegalArgumentException if {@code name} is empty.
- */
- public NetworkPermission(String name)
- {
- super(name);
- }
-
- /**
- * Creates a NetworkPermission with the given target name.
- *
- * @param name the permission target name
- * @param actions should be {@code null}. Is ignored if not.
- * @throws NullPointerException if {@code name} is {@code null}.
- * @throws IllegalArgumentException if {@code name} is empty.
- */
- public NetworkPermission(String name, String actions)
- {
- super(name, actions);
- }
-}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/jdk/net/SocketFlow.java
--- a/jdk/src/java.base/share/classes/jdk/net/SocketFlow.java Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +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.lang.annotation.Native;
-
-/**
- * Represents the service level properties for the platform specific socket
- * option {@link ExtendedSocketOptions#SO_FLOW_SLA}.
- *
- * The priority and bandwidth parameters must be set before
- * setting the socket option.
- *
- * When the {@code SO_FLOW_SLA} option is set then it may not take effect
- * immediately. If the value of the socket option is obtained with
- * {@code getOption()} then the status may be returned as {@code INPROGRESS}
- * until it takes effect. The priority and bandwidth values are only valid when
- * the status is returned as OK.
- *
- * When a security manager is installed, a {@link NetworkPermission}
- * is required to set or get this option.
- *
- * @since 1.8
- */
-public class SocketFlow {
-
- private static final int UNSET = -1;
- @Native public static final int NORMAL_PRIORITY = 1;
- @Native public static final int HIGH_PRIORITY = 2;
-
- private int priority = NORMAL_PRIORITY;
-
- private long bandwidth = UNSET;
-
- private Status status = Status.NO_STATUS;
-
- private SocketFlow() {}
-
- /**
- * Enumeration of the return values from the SO_FLOW_SLA
- * socket option. Both setting and getting the option return
- * one of these statuses, which reflect the state of socket's
- * flow.
- *
- * @since 1.8
- */
- public enum Status {
- /**
- * Set or get socket option has not been called yet. Status
- * values can only be retrieved after calling set or get.
- */
- NO_STATUS,
- /**
- * Flow successfully created.
- */
- OK,
- /**
- * Caller has no permission to create flow.
- */
- NO_PERMISSION,
- /**
- * Flow can not be created because socket is not connected.
- */
- NOT_CONNECTED,
- /**
- * Flow creation not supported for this socket.
- */
- NOT_SUPPORTED,
- /**
- * A flow already exists with identical attributes.
- */
- ALREADY_CREATED,
- /**
- * A flow is being created.
- */
- IN_PROGRESS,
- /**
- * Some other unspecified error.
- */
- OTHER
- }
-
- /**
- * Creates a new SocketFlow that can be used to set the SO_FLOW_SLA
- * socket option and create a socket flow.
- */
- public static SocketFlow create() {
- return new SocketFlow();
- }
-
- /**
- * Sets this SocketFlow's priority. Must be either NORMAL_PRIORITY
- * HIGH_PRIORITY. If not set, a flow's priority is normal.
- *
- * @throws IllegalArgumentException if priority is not NORMAL_PRIORITY or
- * HIGH_PRIORITY.
- */
- public SocketFlow priority(int priority) {
- if (priority != NORMAL_PRIORITY && priority != HIGH_PRIORITY) {
- throw new IllegalArgumentException("invalid priority");
- }
- this.priority = priority;
- return this;
- }
-
- /**
- * Sets this SocketFlow's bandwidth. Must be greater than or equal to zero.
- * A value of zero drops all packets for the socket.
- *
- * @throws IllegalArgumentException if bandwidth is less than zero.
- */
- public SocketFlow bandwidth(long bandwidth) {
- if (bandwidth < 0) {
- throw new IllegalArgumentException("invalid bandwidth");
- } else {
- this.bandwidth = bandwidth;
- }
- return this;
- }
-
- /**
- * Returns this SocketFlow's priority.
- */
- public int priority() {
- return priority;
- }
-
- /**
- * Returns this SocketFlow's bandwidth.
- *
- * @return this SocketFlow's bandwidth, or {@code -1} if status is not OK.
- */
- public long bandwidth() {
- return bandwidth;
- }
-
- /**
- * Returns the Status value of this SocketFlow. NO_STATUS is returned
- * if the object was not used in a call to set or get the option.
- */
- public Status status() {
- return status;
- }
-}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/jdk/net/Sockets.java
--- a/jdk/src/java.base/share/classes/jdk/net/Sockets.java Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,339 +0,0 @@
-/*
- * 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 jdk.net;
-
-import java.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;
-import sun.net.ExtendedOptionsImpl;
-
-/**
- * Defines static methods to set and get socket options defined by the
- * {@link java.net.SocketOption} interface. All of the standard options defined
- * by {@link java.net.Socket}, {@link java.net.ServerSocket}, and
- * {@link java.net.DatagramSocket} can be set this way, as well as additional
- * or platform specific options supported by each socket type.
- *
- * The {@link #supportedOptions(Class)} method can be called to determine
- * the complete set of options available (per socket type) on the
- * current system.
- *
- * When a security manager is installed, some non-standard socket options
- * may require a security permission before being set or get.
- * The details are specified in {@link ExtendedSocketOptions}. No permission
- * is required for {@link java.net.StandardSocketOptions}.
- *
- * @see java.nio.channels.NetworkChannel
- */
-public class Sockets {
-
- private static final HashMap,Set>>
- options = new HashMap<>();
-
- static {
- initOptionSets();
- }
-
- private Sockets() {}
-
- /**
- * Sets the value of a socket option on a {@link java.net.Socket}
- *
- * @param s the socket
- * @param name The socket option
- * @param value The value of the socket option. May be null for some
- * options.
- *
- * @throws UnsupportedOperationException if the socket does not support
- * the option.
- *
- * @throws IllegalArgumentException if the value is not valid for
- * the option.
- *
- * @throws IOException if an I/O error occurs, or socket is closed.
- *
- * @throws SecurityException if a security manager is set and the
- * caller does not have any required permission.
- *
- * @throws NullPointerException if name is null
- *
- * @see java.net.StandardSocketOptions
- */
- public static void setOption(Socket s, SocketOption name, T value) throws IOException
- {
- s.setOption(name, value);
- }
-
- /**
- * Returns the value of a socket option from a {@link java.net.Socket}
- *
- * @param s the socket
- * @param name The socket option
- *
- * @return The value of the socket option.
- *
- * @throws UnsupportedOperationException if the socket does not support
- * the option.
- *
- * @throws IOException if an I/O error occurs
- *
- * @throws SecurityException if a security manager is set and the
- * caller does not have any required permission.
- *
- * @throws NullPointerException if name is null
- *
- * @see java.net.StandardSocketOptions
- */
- public static T getOption(Socket s, SocketOption name) throws IOException
- {
- return s.getOption(name);
- }
-
- /**
- * Sets the value of a socket option on a {@link java.net.ServerSocket}
- *
- * @param s the socket
- * @param name The socket option
- * @param value The value of the socket option.
- *
- * @throws UnsupportedOperationException if the socket does not support
- * the option.
- *
- * @throws IllegalArgumentException if the value is not valid for
- * the option.
- *
- * @throws IOException if an I/O error occurs
- *
- * @throws NullPointerException if name is null
- *
- * @throws SecurityException if a security manager is set and the
- * caller does not have any required permission.
- *
- * @see java.net.StandardSocketOptions
- */
- public static void setOption(ServerSocket s, SocketOption name, T value) throws IOException
- {
- s.setOption(name, value);
- }
-
- /**
- * Returns the value of a socket option from a {@link java.net.ServerSocket}
- *
- * @param s the socket
- * @param name The socket option
- *
- * @return The value of the socket option.
- *
- * @throws UnsupportedOperationException if the socket does not support
- * the option.
- *
- * @throws IOException if an I/O error occurs
- *
- * @throws NullPointerException if name is null
- *
- * @throws SecurityException if a security manager is set and the
- * caller does not have any required permission.
- *
- * @see java.net.StandardSocketOptions
- */
- public static T getOption(ServerSocket s, SocketOption name) throws IOException
- {
- return s.getOption(name);
- }
-
- /**
- * Sets the value of a socket option on a {@link java.net.DatagramSocket}
- * or {@link java.net.MulticastSocket}
- *
- * @param s the socket
- * @param name The socket option
- * @param value The value of the socket option.
- *
- * @throws UnsupportedOperationException if the socket does not support
- * the option.
- *
- * @throws IllegalArgumentException if the value is not valid for
- * the option.
- *
- * @throws IOException if an I/O error occurs
- *
- * @throws NullPointerException if name is null
- *
- * @throws SecurityException if a security manager is set and the
- * caller does not have any required permission.
- *
- * @see java.net.StandardSocketOptions
- */
- public static void setOption(DatagramSocket s, SocketOption name, T value) throws IOException
- {
- s.setOption(name, value);
- }
-
- /**
- * Returns the value of a socket option from a
- * {@link java.net.DatagramSocket} or {@link java.net.MulticastSocket}
- *
- * @param s the socket
- * @param name The socket option
- *
- * @return The value of the socket option.
- *
- * @throws UnsupportedOperationException if the socket does not support
- * the option.
- *
- * @throws IOException if an I/O error occurs
- *
- * @throws NullPointerException if name is null
- *
- * @throws SecurityException if a security manager is set and the
- * caller does not have any required permission.
- *
- * @see java.net.StandardSocketOptions
- */
- public static T getOption(DatagramSocket s, SocketOption name) throws IOException
- {
- return s.getOption(name);
- }
-
- /**
- * Returns a set of {@link java.net.SocketOption}s supported by the
- * given socket type. This set may include standard options and also
- * non standard extended options.
- *
- * @param socketType the type of java.net socket
- *
- * @throws IllegalArgumentException if socketType is not a valid
- * socket type from the java.net package.
- */
- public static Set> supportedOptions(Class> socketType) {
- Set> set = options.get(socketType);
- if (set == null) {
- throw new IllegalArgumentException("unknown socket type");
- }
- return set;
- }
-
- private 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 volatile boolean checkedReusePort;
- private static volatile boolean isReusePortAvailable;
-
- /**
- * Tells whether SO_REUSEPORT is supported.
- */
- static boolean isReusePortAvailable() {
- if (!checkedReusePort) {
- isReusePortAvailable = isReusePortAvailable0();
- checkedReusePort = true;
- }
- return isReusePortAvailable;
- }
-
- private static void initOptionSets() {
- boolean flowsupported = ExtendedOptionsImpl.flowSupported();
- boolean reuseportsupported = isReusePortAvailable();
- // Socket
-
- Set> set = new HashSet<>();
- set.add(StandardSocketOptions.SO_KEEPALIVE);
- set.add(StandardSocketOptions.SO_SNDBUF);
- set.add(StandardSocketOptions.SO_RCVBUF);
- set.add(StandardSocketOptions.SO_REUSEADDR);
- if (reuseportsupported) {
- set.add(StandardSocketOptions.SO_REUSEPORT);
- }
- set.add(StandardSocketOptions.SO_LINGER);
- set.add(StandardSocketOptions.IP_TOS);
- set.add(StandardSocketOptions.TCP_NODELAY);
- if (flowsupported) {
- set.add(ExtendedSocketOptions.SO_FLOW_SLA);
- }
- set = Collections.unmodifiableSet(set);
- options.put(Socket.class, set);
-
- // ServerSocket
-
- set = new HashSet<>();
- set.add(StandardSocketOptions.SO_RCVBUF);
- set.add(StandardSocketOptions.SO_REUSEADDR);
- if (reuseportsupported) {
- set.add(StandardSocketOptions.SO_REUSEPORT);
- }
- set.add(StandardSocketOptions.IP_TOS);
- set = Collections.unmodifiableSet(set);
- options.put(ServerSocket.class, set);
-
- // DatagramSocket
-
- set = new HashSet<>();
- set.add(StandardSocketOptions.SO_SNDBUF);
- set.add(StandardSocketOptions.SO_RCVBUF);
- set.add(StandardSocketOptions.SO_REUSEADDR);
- if (reuseportsupported) {
- set.add(StandardSocketOptions.SO_REUSEPORT);
- }
- set.add(StandardSocketOptions.IP_TOS);
- if (flowsupported) {
- set.add(ExtendedSocketOptions.SO_FLOW_SLA);
- }
- set = Collections.unmodifiableSet(set);
- options.put(DatagramSocket.class, set);
-
- // MulticastSocket
-
- set = new HashSet<>();
- set.add(StandardSocketOptions.SO_SNDBUF);
- set.add(StandardSocketOptions.SO_RCVBUF);
- set.add(StandardSocketOptions.SO_REUSEADDR);
- if (reuseportsupported) {
- set.add(StandardSocketOptions.SO_REUSEPORT);
- }
- set.add(StandardSocketOptions.IP_TOS);
- set.add(StandardSocketOptions.IP_MULTICAST_IF);
- set.add(StandardSocketOptions.IP_MULTICAST_TTL);
- set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
- if (flowsupported) {
- set.add(ExtendedSocketOptions.SO_FLOW_SLA);
- }
- set = Collections.unmodifiableSet(set);
- options.put(MulticastSocket.class, set);
- }
-
- private static native boolean isReusePortAvailable0();
-}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/jdk/net/package-info.java
--- a/jdk/src/java.base/share/classes/jdk/net/package-info.java Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +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.
- */
-
-/**
- * Platform specific socket options for the {@code java.net} and {@code java.nio.channels}
- * socket classes.
- *
- * @since 1.8
- */
-
-package jdk.net;
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/module-info.java
--- a/jdk/src/java.base/share/classes/module-info.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/module-info.java Wed Jul 05 21:39:33 2017 +0200
@@ -83,8 +83,6 @@
// 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 @@
java.sql,
java.xml,
jdk.charsets,
+ jdk.net,
jdk.scripting.nashorn,
jdk.unsupported,
jdk.vm.ci;
@@ -194,6 +193,8 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/net/ExtendedOptionsImpl.java
--- a/jdk/src/java.base/share/classes/sun/net/ExtendedOptionsImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java
--- a/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
-import sun.misc.*;
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java
--- a/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -39,7 +39,7 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
--- a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -33,7 +33,7 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/nio/ch/Net.java
--- a/jdk/src/java.base/share/classes/sun/nio/ch/Net.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/Net.java Wed Jul 05 21:39:33 2017 +0200
@@ -27,15 +27,13 @@
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 @@
// -- 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 @@
// 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 @@
{
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
--- a/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -33,8 +33,7 @@
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 @@
// 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/action/GetBooleanSecurityPropertyAction.java
--- a/jdk/src/java.base/share/classes/sun/security/action/GetBooleanSecurityPropertyAction.java Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.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.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 @@
* @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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java Wed Jul 05 21:39:33 2017 +0200
@@ -131,8 +131,8 @@
} 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
--- a/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.AlgorithmConstraints;
import java.security.PrivilegedAction;
import java.security.Security;
-import java.util.Map;
import java.util.Set;
/**
@@ -45,8 +44,7 @@
}
// 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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java
--- a/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java Wed Jul 05 21:39:33 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * 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.security.cert.X509Certificate;
+
+/**
+ * This class is a wrapper for keeping state and passing objects between PKIX,
+ * AlgorithmChecker, and DisabledAlgorithmConstraints.
+ */
+public class CertConstraintParameters {
+ // A certificate being passed to check against constraints.
+ private final X509Certificate cert;
+
+ // This is true if the trust anchor in the certificate chain matches a cert
+ // in AnchorCertificates
+ private final boolean trustedMatch;
+
+ public CertConstraintParameters(X509Certificate c, boolean match) {
+ cert = c;
+ trustedMatch = match;
+ }
+
+ public CertConstraintParameters(X509Certificate c) {
+ this(c, false);
+ }
+
+ // Returns if the trust anchor has a match if anchor checking is enabled.
+ public boolean isTrustedMatch() {
+ return trustedMatch;
+ }
+
+ public X509Certificate getCertificate() {
+ return cert;
+ }
+}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
--- a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
import java.security.CryptoPrimitive;
import java.security.AlgorithmParameters;
import java.security.Key;
+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.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.HashMap;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -44,6 +46,7 @@
* 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 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 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 @@
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 @@
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 @@
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 @@
}
// 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 {
+
+ X509Certificate cert = cp.getCertificate();
+ String algorithm = cert.getSigAlgName();
- return keySizeConstraintsMap.get(propertyName);
+ // 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;
+
+ for (String entry : policy.split("&")) {
+ entry = entry.trim();
- synchronized (constraintsMap) {
- if (!constraintsMap.containsKey(algorithm)) {
- constraintsMap.put(algorithm,
- new HashSet());
+ 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 @@
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 @@
}
}
- // 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
--- a/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java
--- a/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java Wed Jul 05 21:39:33 2017 +0200
@@ -286,12 +286,15 @@
}
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/share/conf/security/java.security
--- a/jdk/src/java.base/share/conf/security/java.security Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/share/conf/security/java.security Wed Jul 05 21:39:33 2017 +0200
@@ -497,13 +497,13 @@
# " DisabledAlgorithm { , DisabledAlgorithm } "
#
# DisabledAlgorithm:
-# AlgorithmName [Constraint]
+# AlgorithmName [Constraint] { '&' Constraint }
#
# AlgorithmName:
# (see below)
#
# Constraint:
-# KeySizeConstraint
+# KeySizeConstraint, CertConstraint
#
# KeySizeConstraint:
# keySize Operator DecimalInteger
@@ -520,6 +520,9 @@
# 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 @@
# 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
--- a/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -27,9 +27,7 @@
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 @@
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 @@
}
}
} 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 @@
throw new UnsupportedOperationException("unsupported option");
}
}
- }
- if (!flowSupported()) {
- throw new UnsupportedOperationException("unsupported option");
+ } else {
+ if (isClosed()) {
+ throw new SocketException("Socket closed");
+ }
+ return (T) extendedOptions.getOption(fd, name);
}
- 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java
--- a/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -28,10 +28,7 @@
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 @@
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 @@
}
}
} 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 @@
throw new UnsupportedOperationException("unsupported option");
}
}
- }
- if (getSocket() == null || !flowSupported()) {
- 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 (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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
-import sun.misc.*;
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/unix/native/libnet/ExtendedOptionsImpl.c
--- a/jdk/src/java.base/unix/native/libnet/ExtendedOptionsImpl.c Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/unix/native/libnet/net_util_md.h
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h Wed Jul 05 21:39:33 2017 +0200
@@ -120,47 +120,6 @@
#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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java Wed Jul 05 21:39:33 2017 +0200
@@ -113,6 +113,10 @@
// 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 @@
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 @@
buffer = null;
countAddress = 0;
overlappedAddress = 0;
+ errorStartingOverlapped = false;
}
@Override
@@ -455,11 +468,13 @@
* 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 @@
} catch (WindowsException x) {
// no choice but to cancel key
criticalError = true;
+ key.setErrorStartingOverlapped(true);
}
}
if (criticalError) {
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.base/windows/native/libnet/ExtendedOptionsImpl.c
--- a/jdk/src/java.base/windows/native/libnet/ExtendedOptionsImpl.c Wed Jul 05 21:38:13 2017 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +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"
-
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_init
- (JNIEnv *env, jclass UNUSED)
-{
-}
-
-/* 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;
-}
-
-JNIEXPORT jboolean JNICALL Java_sun_net_ExtendedOptionsImpl_flowSupported
- (JNIEnv *env, jclass UNUSED)
-{
- return JNI_FALSE;
-}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java Wed Jul 05 21:39:33 2017 +0200
@@ -83,7 +83,7 @@
// 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java Wed Jul 05 21:39:33 2017 +0200
@@ -58,7 +58,7 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -91,7 +91,7 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java Wed Jul 05 21:39:33 2017 +0200
@@ -416,7 +416,7 @@
"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 @@
//"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
//"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 @@
//"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 @@
"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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -521,7 +521,7 @@
}
// [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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java Wed Jul 05 21:39:33 2017 +0200
@@ -268,7 +268,7 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java Wed Jul 05 21:39:33 2017 +0200
@@ -32,8 +32,8 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java Wed Jul 05 21:39:33 2017 +0200
@@ -386,7 +386,7 @@
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 @@
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 @@
}
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 @@
generalCache = new HashMap();
}
- generalCache.put(new Integer(index), new Float(value));
+ generalCache.put(Integer.valueOf(index), Float.valueOf(value));
}
private static class SparseBitShiftingTwoLayerArray {
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
@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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.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 @@
}
@Override
- public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+ public boolean requestWindowFocus(FocusEvent.Cause cause) {
if (!focusAllowedFor()) {
return false;
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java Wed Jul 05 21:39:33 2017 +0200
@@ -404,6 +404,10 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
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 @@
// 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 @@
* 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 void updateFocusableWindowState();
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause);
+ public boolean rejectFocusRequest(FocusEvent.Cause cause);
public boolean requestWindowFocus();
@@ -130,12 +130,6 @@
*/
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
}
- 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
*/
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 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");
@@ -161,11 +162,6 @@
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {}
@Override
- public Graphics transformGraphics(Graphics g) {
- return g;
- }
-
- @Override
public void updateIconImages() {}
@Override
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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.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 @@
}
@Override
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+ public boolean rejectFocusRequest(FocusEvent.Cause cause) {
return false;
}
@@ -153,11 +152,6 @@
}
@Override
- public Graphics transformGraphics(Graphics g) {
- return null;
- }
-
- @Override
public void setAlwaysOnTop(boolean isAlwaysOnTop) {
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
}
@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");
@@ -741,12 +741,6 @@
}
@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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java Wed Jul 05 21:39:33 2017 +0200
@@ -98,15 +98,26 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java Wed Jul 05 21:39:33 2017 +0200
@@ -87,23 +87,22 @@
}
}
- /*
+ /**
* 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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;
@@ -171,11 +170,6 @@
}
@Override
- public Graphics transformGraphics(Graphics g) {
- return g;
- }
-
- @Override
public void updateIconImages() {
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
return null;
}
- return transformGraphics(new SunGraphics2D(sd, SystemColor.windowText,
- SystemColor.window, ownerWindow.getFont()));
+ return new SunGraphics2D(sd, SystemColor.windowText, SystemColor.window,
+ ownerWindow.getFont());
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Jul 05 21:39:33 2017 +0200
@@ -378,9 +378,9 @@
// 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java
--- a/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java Wed Jul 05 21:39:33 2017 +0200
@@ -42,7 +42,7 @@
* <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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java Wed Jul 05 21:39:33 2017 +0200
@@ -128,7 +128,7 @@
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 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
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 @@
}
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
*/
@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 @@
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 @@
return IS_22;
}
+ static boolean is3() {
+ return IS_3;
+ }
+
/**
* Maps a swing constant to a GTK constant.
*/
@@ -385,7 +379,7 @@
}
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
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 @@
* 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 @@
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 @@
// 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 @@
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 @@
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 @@
} 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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
}
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 @@
}
}
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 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java Wed Jul 05 21:39:33 2017 +0200
@@ -185,7 +185,7 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/Component.java
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.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 @@
{
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 @@
requestFocusHelper(false, true);
}
- boolean requestFocus(CausedFocusEvent.Cause cause) {
+ boolean requestFocus(FocusEvent.Cause cause) {
return requestFocusHelper(false, true, cause);
}
@@ -7605,7 +7604,7 @@
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 @@
return requestFocusHelper(false, false);
}
- boolean requestFocusInWindow(CausedFocusEvent.Cause cause) {
+ boolean requestFocusInWindow(FocusEvent.Cause cause) {
return requestFocusHelper(false, false, cause);
}
@@ -7721,18 +7720,18 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRootPriv(fcr);
- rootAncestor.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
+ rootAncestor.requestFocus(FocusEvent.Cause.TRAVERSAL_UP);
} else {
Window window = getContainingWindow();
@@ -8118,7 +8117,7 @@
if (toFocus != null) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRootPriv(window);
- toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
+ toFocus.requestFocus(FocusEvent.Cause.TRAVERSAL_UP);
}
}
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/Container.java
--- a/jdk/src/java.desktop/share/classes/java/awt/Container.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/Container.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.awt.AppContext;
import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
@@ -3515,7 +3514,7 @@
Component toFocus = getFocusTraversalPolicy().
getDefaultComponent(this);
if (toFocus != null) {
- toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_DOWN);
+ toFocus.requestFocus(FocusEvent.Cause.TRAVERSAL_DOWN);
}
}
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java
--- a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.awt.AppContext;
import sun.awt.SunToolkit;
import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
import sun.awt.TimedWindowEvent;
/**
@@ -165,13 +164,13 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java
--- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.awt.AppContext;
import sun.awt.SunToolkit;
-import sun.awt.CausedFocusEvent;
import sun.awt.KeyboardFocusManagerPeerProvider;
import sun.awt.AWTAccessor;
@@ -124,7 +123,7 @@
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 @@
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 @@
}
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 @@
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 @@
hwFocusRequest =
new HeavyweightFocusRequest(heavyweight, descendant,
- temporary, CausedFocusEvent.Cause.UNKNOWN);
+ temporary, FocusEvent.Cause.UNKNOWN);
heavyweightRequests.add(hwFocusRequest);
if (currentFocusOwner != null) {
@@ -2379,7 +2378,7 @@
*/
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 @@
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 @@
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 @@
* 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 @@
{
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 @@
// '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 @@
// 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 @@
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 @@
{
// 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 @@
? 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/Window.java
--- a/jdk/src/java.desktop/share/classes/java/awt/Window.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 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 @@
{
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java
--- a/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
* 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}.
@@ -66,6 +73,61 @@
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.
*/
public static final int FOCUS_FIRST = 1004;
@@ -86,6 +148,16 @@
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
* temporarily and intends on getting it back once the event is completed.
@@ -115,7 +187,8 @@
/**
* 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 @@
* @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 @@
return (SunToolkit.targetToAppContext(opposite) ==
AppContext.getAppContext())
- ? opposite
- : null;
+ ? opposite
+ : null;
}
/**
@@ -233,17 +350,56 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java
--- a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java Wed Jul 05 21:39:33 2017 +0200
@@ -79,7 +79,7 @@
* 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java
--- a/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java Wed Jul 05 21:39:33 2017 +0200
@@ -105,7 +105,7 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java
--- a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java Wed Jul 05 21:39:33 2017 +0200
@@ -392,7 +392,7 @@
* the specified parameter.
*/
public ParameterBlock add(float f) {
- return add(new Float(f));
+ return add(Float.valueOf(f));
}
/**
@@ -403,7 +403,7 @@
* the specified parameter.
*/
public ParameterBlock add(double d) {
- return add(new Double(d));
+ return add(Double.valueOf(d));
}
/**
@@ -521,7 +521,7 @@
* 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 @@
* the specified parameter.
*/
public ParameterBlock set(double d, int index) {
- return set(new Double(d), index);
+ return set(Double.valueOf(d), index);
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java
--- a/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java Wed Jul 05 21:39:33 2017 +0200
@@ -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 @@
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 @@
*/
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java
--- a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java Wed Jul 05 21:39:33 2017 +0200
@@ -577,6 +577,8 @@
/**
* 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/JComponent.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java Wed Jul 05 21:39:33 2017 +0200
@@ -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.awt.*;
import java.awt.event.*;
-import java.awt.peer.LightweightPeer;
import java.applet.Applet;
@@ -57,7 +56,6 @@
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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java Wed Jul 05 21:39:33 2017 +0200
@@ -98,7 +98,7 @@
*
* 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 @@
@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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java Wed Jul 05 21:39:33 2017 +0200
@@ -478,7 +478,7 @@
if (format == null) {
format = NumberFormat.getPercentInstance();
}
- return format.format(new Double(getPercentComplete()));
+ return format.format(Double.valueOf(getPercentComplete()));
}
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/JTable.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java Wed Jul 05 21:39:33 2017 +0200
@@ -81,7 +81,7 @@
* 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java Wed Jul 05 21:39:33 2017 +0200
@@ -51,10 +51,10 @@
* 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 @@
* 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 @@
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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java Wed Jul 05 21:39:33 2017 +0200
@@ -846,14 +846,46 @@
}
/**
+ * 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.
*
* @param anEvent a MouseEvent object
* @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 @@
* @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 @@
* @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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java Wed Jul 05 21:39:33 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * 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
+ * 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 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}
+ * change and 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 -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java Wed Jul 05 21:39:33 2017 +0200
@@ -120,7 +120,7 @@
Object[] uiDefaults = {
"Font", new Font("Dialog", Font.BOLD, 12),
"Color", Color.red,
- "five", new Integer(5)
+ "five", Integer.valueOf(5)
}
UIDefaults myDefaults = new UIDefaults(uiDefaults);
*
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java Wed Jul 05 21:39:33 2017 +0200
@@ -134,7 +134,7 @@
new BorderUIResource.LineBorderUIResource(getPrimary1());
// .30 0 DDE8F3 white secondary2
java.util.List> buttonGradient = Arrays.asList(
- new Object[] {new Float(.3f), new Float(0f),
+ new Object[] {Float.valueOf(.3f), Float.valueOf(0f),
new ColorUIResource(0xDDE8F3), getWhite(), getSecondary2() });
// Other possible properties that aren't defined:
@@ -150,7 +150,7 @@
Object directoryIcon = getIconResource("icons/ocean/directory.gif");
Object fileIcon = getIconResource("icons/ocean/file.gif");
java.util.List> sliderGradient = Arrays.asList(new Object[] {
- new Float(.3f), new Float(.2f),
+ Float.valueOf(.3f), Float.valueOf(.2f),
c8ddf2, getWhite(), new ColorUIResource(SECONDARY2) });
Object[] defaults = new Object[] {
@@ -192,7 +192,7 @@
"Menu.opaque", Boolean.FALSE,
"MenuBar.gradient", Arrays.asList(new Object[] {
- new Float(1f), new Float(0f),
+ Float.valueOf(1f), Float.valueOf(0f),
getWhite(), dadada,
new ColorUIResource(dadada) }),
"MenuBar.borderColor", cccccc,
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java Wed Jul 05 21:39:33 2017 +0200
@@ -139,7 +139,6 @@
}
}
- context.dispose();
return dim;
}
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java Wed Jul 05 21:39:33 2017 +0200
@@ -61,7 +61,6 @@
return;
}
ui.paintBorder(context, g, x, y, width, height);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -105,7 +105,6 @@
}
}
- context.dispose();
}
/**
@@ -125,7 +124,6 @@
SynthContext context = getContext(b, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -226,7 +224,6 @@
else {
baseline = textRect.y + fm.getAscent();
}
- context.dispose();
return baseline;
}
@@ -253,7 +250,6 @@
SynthLookAndFeel.update(context, g);
paintBackground(context, g, c);
paint(context, g);
- context.dispose();
}
/**
@@ -270,7 +266,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -321,7 +316,6 @@
protected Icon getDefaultIcon(AbstractButton b) {
SynthContext context = getContext(b);
Icon icon = context.getStyle().getIcon(context, getPropertyPrefix() + "icon");
- context.dispose();
return icon;
}
@@ -473,7 +467,6 @@
b.getVerticalTextPosition(), b.getIconTextGap(),
b.getDisplayedMnemonicIndex());
- ss.dispose();
return size;
}
@@ -494,7 +487,6 @@
b.getVerticalTextPosition(), b.getIconTextGap(),
b.getDisplayedMnemonicIndex());
- ss.dispose();
return size;
}
@@ -516,7 +508,6 @@
b.getVerticalTextPosition(), b.getIconTextGap(),
b.getDisplayedMnemonicIndex());
- ss.dispose();
return size;
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -65,7 +65,6 @@
SynthContext context = getContext(chooser, ENABLED);
AbstractColorChooserPanel[] panels = (AbstractColorChooserPanel[])
context.getStyle().get(context, "ColorChooser.panels");
- context.dispose();
if (panels == null) {
panels = ColorChooserComponentFactory.getDefaultChooserPanels();
@@ -85,7 +84,6 @@
private void updateStyle(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -96,7 +94,6 @@
SynthContext context = getContext(chooser, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
super.uninstallDefaults();
}
@@ -155,7 +152,6 @@
context.getPainter().paintColorChooserBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -172,7 +168,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -144,7 +144,6 @@
forceOpaque = style.getBoolean(context,
"ComboBox.forceOpaque", false);
}
- context.dispose();
if(listBox != null) {
SynthLookAndFeel.updateStyles(listBox);
@@ -182,7 +181,6 @@
SynthContext context = getContext(comboBox, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -323,7 +321,6 @@
context.getPainter().paintComboBoxBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -340,7 +337,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java Wed Jul 05 21:39:33 2017 +0200
@@ -24,8 +24,6 @@
*/
package javax.swing.plaf.synth;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
import javax.swing.JComponent;
/**
@@ -40,7 +38,6 @@
* @author Scott Violet
*/
public class SynthContext {
- private static final Queue queue = new ConcurrentLinkedQueue<>();
private JComponent component;
private Region region;
@@ -54,19 +51,15 @@
static SynthContext getContext(JComponent component,
Region region, SynthStyle style,
int state) {
- SynthContext context = queue.poll();
- if (context == null) {
- context = new SynthContext();
- }
- context.reset(component, region, style, state);
+ SynthContext context = new SynthContext();
+ context.component = component;
+ context.region = region;
+ context.style = style;
+ context.state = state;
return context;
}
- static void releaseContext(SynthContext context) {
- queue.offer(context);
- }
-
- SynthContext() {
+ private SynthContext() {
}
/**
@@ -86,7 +79,11 @@
throw new NullPointerException(
"You must supply a non-null component, region and style");
}
- reset(component, region, style, state);
+
+ this.component = component;
+ this.region = region;
+ this.style = style;
+ this.state = state;
}
@@ -147,23 +144,6 @@
}
/**
- * Resets the state of the Context.
- */
- void reset(JComponent component, Region region, SynthStyle style,
- int state) {
- this.component = component;
- this.region = region;
- this.style = style;
- this.state = state;
- }
-
- void dispose() {
- this.component = null;
- this.style = null;
- releaseContext(this);
- }
-
- /**
* Convenience method to get the Painter from the current SynthStyle.
* This will NEVER return null.
*/
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java Wed Jul 05 21:39:33 2017 +0200
@@ -41,7 +41,6 @@
}
SynthContext context = ((SynthUI)ui).getContext(c);
Object value = context.getStyle().get(context, key);
- context.dispose();
return value;
}
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -121,7 +121,6 @@
private void updateStyle(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -131,7 +130,6 @@
protected void uninstallDefaults() {
SynthContext context = getContext(desktopIcon, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -171,7 +169,6 @@
context.getPainter().paintDesktopIconBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -188,7 +185,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -119,7 +119,6 @@
uninstallKeyboardActions();
installKeyboardActions();
}
- context.dispose();
}
/**
@@ -143,7 +142,6 @@
SynthContext context = getContext(desktop, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
if (taskBar != null) {
@@ -460,7 +458,6 @@
context.getPainter().paintDesktopPaneBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -477,7 +474,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -83,7 +83,6 @@
c.putClientProperty("caretAspectRatio", null);
style.uninstallDefaults(context);
- context.dispose();
style = null;
Object clientProperty =
@@ -127,7 +126,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -165,7 +163,6 @@
SynthLookAndFeel.update(context, g);
paintBackground(context, g, c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java Wed Jul 05 21:39:33 2017 +0200
@@ -138,7 +138,6 @@
}
}
}
- context.dispose();
}
protected void installDefaults() {
@@ -149,7 +148,6 @@
protected void uninstallDefaults() {
SynthContext context = getContext(this, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
JInternalFrame.JDesktopIcon di = frame.getDesktopIcon();
if(di != null && di.getComponentPopupMenu() == systemPopupMenu) {
@@ -235,7 +233,6 @@
context.getPainter().paintInternalFrameTitlePaneBackground(context,
g, 0, 0, getWidth(), getHeight());
paint(context, g);
- context.dispose();
}
protected void paint(SynthContext context, Graphics g) {
@@ -321,7 +318,6 @@
SynthContext context = getContext(this);
LayoutManager lm =
(LayoutManager)style.get(context, "InternalFrameTitlePane.titlePaneLayout");
- context.dispose();
return (lm != null) ? lm : new SynthTitlePaneLayout();
}
@@ -362,7 +358,6 @@
Image.SCALE_SMOOTH));
}
}
- context.dispose();
menuButton.setIcon(frameIcon);
}
@@ -433,7 +428,6 @@
Insets insets = getInsets();
height += insets.top + insets.bottom;
width += insets.left + insets.right;
- context.dispose();
return new Dimension(width, height);
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -118,7 +118,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -128,7 +127,6 @@
protected void uninstallDefaults() {
SynthContext context = getContext(frame, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
if(frame.getLayout() == internalFrameLayout) {
frame.setLayout(null);
@@ -216,7 +214,6 @@
context.getPainter().paintInternalFrameBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -233,7 +230,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -67,7 +67,6 @@
void updateStyle(JLabel c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -78,7 +77,6 @@
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -150,7 +148,6 @@
else {
baseline = textRect.y + fm.getAscent();
}
- context.dispose();
return baseline;
}
@@ -174,7 +171,6 @@
context.getPainter().paintLabelBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -191,7 +187,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -242,7 +237,6 @@
label.getVerticalTextPosition(), label.getIconTextGap(),
label.getDisplayedMnemonicIndex());
- context.dispose();
return size;
}
@@ -263,7 +257,6 @@
label.getVerticalTextPosition(), label.getIconTextGap(),
label.getDisplayedMnemonicIndex());
- context.dispose();
return size;
}
@@ -284,7 +277,6 @@
label.getVerticalTextPosition(), label.getIconTextGap(),
label.getDisplayedMnemonicIndex());
- context.dispose();
return size;
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -75,7 +75,6 @@
SynthLookAndFeel.update(context, g);
context.getPainter().paintListBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
- context.dispose();
paint(g, c);
}
@@ -162,7 +161,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -175,7 +173,6 @@
SynthContext context = getContext(list, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java Wed Jul 05 21:39:33 2017 +0200
@@ -976,7 +976,6 @@
if (currBG != null && !currBG.equals(lastBG)) {
comp.repaint();
}
- context.dispose();
}
}
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -83,7 +83,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -94,7 +93,6 @@
SynthContext context = getContext(menuBar, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -143,7 +141,6 @@
context.getPainter().paintMenuBarBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -160,7 +157,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -124,13 +124,11 @@
installKeyboardActions();
}
}
- context.dispose();
SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
ENABLED);
accStyle = SynthLookAndFeel.updateStyle(accContext, this);
- accContext.dispose();
}
/**
@@ -140,13 +138,11 @@
protected void uninstallDefaults() {
SynthContext context = getContext(menuItem, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
SynthContext accContext = getContext(menuItem,
Region.MENU_ITEM_ACCELERATOR, ENABLED);
accStyle.uninstallDefaults(accContext);
- accContext.dispose();
accStyle = null;
super.uninstallDefaults();
@@ -218,8 +214,6 @@
defaultTextIconGap, acceleratorDelimiter,
MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix());
- context.dispose();
- accContext.dispose();
return value;
}
@@ -243,7 +237,6 @@
SynthLookAndFeel.update(context, g);
paintBackground(context, g, c);
paint(context, g);
- context.dispose();
}
/**
@@ -260,7 +253,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -280,7 +272,6 @@
Icon arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
SynthGraphicsUtils.paint(context, accContext, g, checkIcon, arrowIcon,
acceleratorDelimiter, defaultTextIconGap, getPropertyPrefix());
- accContext.dispose();
}
void paintBackground(SynthContext context, Graphics g, JComponent c) {
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -110,13 +110,11 @@
installKeyboardActions();
}
}
- context.dispose();
SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
ENABLED);
accStyle = SynthLookAndFeel.updateStyle(accContext, this);
- accContext.dispose();
}
/**
@@ -140,13 +138,11 @@
protected void uninstallDefaults() {
SynthContext context = getContext(menuItem, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
SynthContext accContext = getContext(menuItem,
Region.MENU_ITEM_ACCELERATOR, ENABLED);
accStyle.uninstallDefaults(accContext);
- accContext.dispose();
accStyle = null;
super.uninstallDefaults();
@@ -218,8 +214,6 @@
defaultTextIconGap, acceleratorDelimiter,
MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix());
- context.dispose();
- accContext.dispose();
return value;
}
@@ -243,7 +237,6 @@
context.getPainter().paintMenuBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -260,7 +253,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -279,7 +271,6 @@
Icon arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
SynthGraphicsUtils.paint(context, accContext, g, checkIcon, arrowIcon,
acceleratorDelimiter, defaultTextIconGap, getPropertyPrefix());
- accContext.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -88,7 +88,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -99,7 +98,6 @@
SynthContext context = getContext(optionPane, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -125,7 +123,6 @@
SynthContext context = getContext(optionPane, ENABLED);
optionPane.add(Box.createVerticalStrut(context.getStyle().
getInt(context, "OptionPane.separatorPadding", 6)));
- context.dispose();
}
optionPane.add(createButtonArea());
optionPane.applyComponentOrientation(optionPane.getComponentOrientation());
@@ -167,7 +164,6 @@
context.getPainter().paintOptionPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -184,7 +180,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -259,7 +254,6 @@
SynthContext context = getContext(optionPane, ENABLED);
cons.anchor = context.getStyle().getInt(context,
"OptionPane.messageAnchor", GridBagConstraints.CENTER);
- context.dispose();
cons.insets = new Insets(0,0,3,0);
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -108,14 +108,12 @@
SynthContext context = getContext(p, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
private void updateStyle(JPanel c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -154,7 +152,6 @@
context.getPainter().paintPanelBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -171,7 +168,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -77,7 +77,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -97,7 +96,6 @@
SynthContext context = getContext(popupMenu, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
if (popupMenu.getLayout() instanceof UIResource) {
@@ -150,7 +148,6 @@
context.getPainter().paintPopupMenuBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -167,7 +164,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -118,7 +118,6 @@
}
minBarSize = (Dimension)style.get(context, "ProgressBar.minBarSize");
glowWidth = style.getInt(context, "ProgressBar.glowWidth", 0);
- context.dispose();
}
/**
@@ -129,7 +128,6 @@
SynthContext context = getContext(progressBar, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -160,7 +158,6 @@
SynthContext context = getContext(c);
Font font = context.getStyle().getFont(context);
FontMetrics metrics = progressBar.getFontMetrics(font);
- context.dispose();
return (height - metrics.getAscent() - metrics.getDescent()) / 2 +
metrics.getAscent();
}
@@ -216,7 +213,6 @@
g, 0, 0, c.getWidth(), c.getHeight(),
progressBar.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -233,7 +229,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -67,7 +67,6 @@
SynthContext context = getContext(root, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -97,7 +96,6 @@
installKeyboardActions((JRootPane)c);
}
}
- context.dispose();
}
/**
@@ -120,7 +118,6 @@
context.getPainter().paintRootPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -137,7 +134,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -129,15 +129,12 @@
installKeyboardActions();
}
}
- context.dispose();
context = getContext(c, Region.SCROLL_BAR_TRACK, ENABLED);
trackStyle = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
context = getContext(c, Region.SCROLL_BAR_THUMB, ENABLED);
thumbStyle = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -165,17 +162,14 @@
protected void uninstallDefaults(){
SynthContext context = getContext(scrollbar, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
context = getContext(scrollbar, Region.SCROLL_BAR_TRACK, ENABLED);
trackStyle.uninstallDefaults(context);
- context.dispose();
trackStyle = null;
context = getContext(scrollbar, Region.SCROLL_BAR_THUMB, ENABLED);
thumbStyle.uninstallDefaults(context);
- context.dispose();
thumbStyle = null;
super.uninstallDefaults();
@@ -222,7 +216,6 @@
SynthContext context = getContext(scrollbar);
boolean value = style.getBoolean(context,
"ScrollBar.allowsAbsolutePositioning", false);
- context.dispose();
return value;
}
@@ -247,7 +240,6 @@
g, 0, 0, c.getWidth(), c.getHeight(),
scrollbar.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -264,7 +256,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -278,11 +269,9 @@
SynthContext subcontext = getContext(scrollbar,
Region.SCROLL_BAR_TRACK);
paintTrack(subcontext, g, getTrackBounds());
- subcontext.dispose();
subcontext = getContext(scrollbar, Region.SCROLL_BAR_THUMB);
paintThumb(subcontext, g, getThumbBounds());
- subcontext.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -83,7 +83,6 @@
context.getPainter().paintScrollPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -100,7 +99,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -150,7 +148,6 @@
installKeyboardActions(c);
}
}
- context.dispose();
}
/**
@@ -178,7 +175,6 @@
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
if (scrollpane.getViewportBorder() instanceof UIResource) {
scrollpane.setViewportBorder(null);
@@ -254,7 +250,6 @@
}
context.getPainter().paintViewportBorder(context, g, x, y, width,
height);
- context.dispose();
}
@Override
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -106,7 +106,6 @@
}
}
- context.dispose();
}
/**
@@ -120,7 +119,6 @@
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -168,7 +166,6 @@
g, 0, 0, c.getWidth(), c.getHeight(),
separator.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -185,7 +182,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -231,7 +227,6 @@
size = new Dimension(insets.left + insets.right,
insets.top + insets.bottom + thickness);
}
- context.dispose();
return size;
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -116,17 +116,14 @@
protected void uninstallDefaults(JSlider slider) {
SynthContext context = getContext(slider, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
context = getContext(slider, Region.SLIDER_TRACK, ENABLED);
sliderTrackStyle.uninstallDefaults(context);
- context.dispose();
sliderTrackStyle = null;
context = getContext(slider, Region.SLIDER_THUMB, ENABLED);
sliderThumbStyle.uninstallDefaults(context);
- context.dispose();
sliderThumbStyle = null;
}
@@ -190,17 +187,14 @@
installKeyboardActions(c);
}
}
- context.dispose();
context = getContext(c, Region.SLIDER_TRACK, ENABLED);
sliderTrackStyle =
SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
context = getContext(c, Region.SLIDER_THUMB, ENABLED);
sliderThumbStyle =
SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -252,14 +246,12 @@
SynthContext trackContext = getContext(slider,
Region.SLIDER_TRACK);
style.getInsets(trackContext, trackInsets);
- trackContext.dispose();
if (slider.getOrientation() == JSlider.HORIZONTAL) {
int valueHeight = 0;
if (paintValue) {
SynthContext context = getContext(slider);
valueHeight = context.getStyle().getGraphicsUtils(context).
getMaximumCharHeight(context);
- context.dispose();
}
int tickHeight = 0;
if (slider.getPaintTicks()) {
@@ -287,7 +279,6 @@
SynthContext context = getContext(slider);
valueHeight = context.getStyle().getGraphicsUtils(
context).getMaximumCharHeight(context);
- context.dispose();
}
int contentHeight = height - insetCache.top -
insetCache.bottom;
@@ -359,7 +350,6 @@
Insets trackInsets = new Insets(0, 0, 0, 0);
SynthContext trackContext = getContext(slider, Region.SLIDER_TRACK);
style.getInsets(trackContext, trackInsets);
- trackContext.dispose();
if (slider.getOrientation() == JSlider.HORIZONTAL) {
// Calculate the height of all the subcomponents so we can center
@@ -509,7 +499,6 @@
trackRect.x = startX + tickRect.width + trackInsets.left;
}
}
- context.dispose();
lastSize = slider.getSize();
}
@@ -715,7 +704,6 @@
insetCache = newInsets;
calculateGeometry();
}
- context.dispose();
}
/**
@@ -774,7 +762,6 @@
g, 0, 0, c.getWidth(), c.getHeight(),
slider.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -790,7 +777,6 @@
public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -835,13 +821,11 @@
if (slider.getPaintTrack() && clip.intersects(trackRect)) {
SynthContext subcontext = getContext(slider, Region.SLIDER_TRACK);
paintTrack(subcontext, g, trackRect);
- subcontext.dispose();
}
if (clip.intersects(thumbRect)) {
SynthContext subcontext = getContext(slider, Region.SLIDER_THUMB);
paintThumb(subcontext, g, thumbRect);
- subcontext.dispose();
}
if (slider.getPaintTicks() && clip.intersects(tickRect)) {
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -131,7 +131,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
@@ -151,7 +150,6 @@
SynthContext context = getContext(spinner, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -301,7 +299,6 @@
context.getPainter().paintSpinnerBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
@@ -319,7 +316,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java Wed Jul 05 21:39:33 2017 +0200
@@ -81,7 +81,6 @@
context.getPainter().paintSplitPaneDividerForeground(context, g, 0, 0,
getWidth(), getHeight(), splitPane.getOrientation());
- context.dispose();
// super.paint(g2);
for (int counter = 0; counter < getComponentCount(); counter++) {
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -121,7 +121,6 @@
ENABLED);
SynthStyle oldDividerStyle = dividerStyle;
dividerStyle = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
context = getContext(splitPane, ENABLED);
SynthStyle oldStyle = style;
@@ -160,7 +159,6 @@
divider.setBasicSplitPaneUI(this);
splitPane.add(divider, JSplitPane.DIVIDER);
}
- context.dispose();
}
/**
@@ -180,12 +178,10 @@
SynthContext context = getContext(splitPane, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
context = getContext(splitPane, Region.SPLIT_PANE_DIVIDER, ENABLED);
dividerStyle.uninstallDefaults(context);
- context.dispose();
dividerStyle = null;
super.uninstallDefaults();
@@ -287,7 +283,6 @@
context.getPainter().paintSplitPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -304,7 +299,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -338,7 +332,6 @@
context.getPainter().paintSplitPaneDragDivider(context, g, x, y, w, h,
splitPane.getOrientation());
g.setClip(oldClip);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -154,27 +154,17 @@
installKeyboardActions();
}
}
- context.dispose();
- if (tabContext != null) {
- tabContext.dispose();
- }
tabContext = getContext(c, Region.TABBED_PANE_TAB, ENABLED);
this.tabStyle = SynthLookAndFeel.updateStyle(tabContext, this);
tabInsets = tabStyle.getInsets(tabContext, null);
- if (tabAreaContext != null) {
- tabAreaContext.dispose();
- }
tabAreaContext = getContext(c, Region.TABBED_PANE_TAB_AREA, ENABLED);
this.tabAreaStyle = SynthLookAndFeel.updateStyle(tabAreaContext, this);
tabAreaInsets = tabAreaStyle.getInsets(tabAreaContext, null);
- if (tabContentContext != null) {
- tabContentContext.dispose();
- }
tabContentContext = getContext(c, Region.TABBED_PANE_CONTENT, ENABLED);
this.tabContentStyle = SynthLookAndFeel.updateStyle(tabContentContext,
this);
@@ -207,21 +197,17 @@
protected void uninstallDefaults() {
SynthContext context = getContext(tabPane, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
tabStyle.uninstallDefaults(tabContext);
- tabContext.dispose();
tabContext = null;
tabStyle = null;
tabAreaStyle.uninstallDefaults(tabAreaContext);
- tabAreaContext.dispose();
tabAreaContext = null;
tabAreaStyle = null;
tabContentStyle.uninstallDefaults(tabContentContext);
- tabContentContext.dispose();
tabContentContext = null;
tabContentStyle = null;
}
@@ -374,7 +360,6 @@
context.getPainter().paintTabbedPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -424,7 +409,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -85,7 +85,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -109,7 +108,6 @@
SynthContext context = getContext(header, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -142,7 +140,6 @@
context.getPainter().paintTableHeaderBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -159,7 +156,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -189,7 +189,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -220,7 +219,6 @@
}
SynthContext context = getContext(table, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -273,7 +271,6 @@
context.getPainter().paintTableBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -299,7 +296,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -88,7 +88,6 @@
getComponent().removeFocusListener(handler);
style.uninstallDefaults(context);
- context.dispose();
style = null;
super.uninstallDefaults();
}
@@ -107,7 +106,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -142,7 +140,6 @@
context.getPainter().paintTextAreaBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -79,7 +79,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
static void updateStyle(JTextComponent comp, SynthContext context,
@@ -179,7 +178,6 @@
SynthLookAndFeel.update(context, g);
paintBackground(context, g, c);
paint(context, g);
- context.dispose();
}
/**
@@ -262,7 +260,6 @@
getComponent().removeFocusListener(handler);
style.uninstallDefaults(context);
- context.dispose();
style = null;
super.uninstallDefaults();
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -98,11 +98,9 @@
SynthContext context = getContext(
c, Region.TOOL_BAR_CONTENT, null, ENABLED);
contentStyle = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
context = getContext(c, Region.TOOL_BAR_DRAG_WINDOW, null, ENABLED);
dragWindowStyle = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
context = getContext(c, ENABLED);
SynthStyle oldStyle = style;
@@ -116,7 +114,6 @@
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -127,7 +124,6 @@
SynthContext context = getContext(toolBar, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
handleIcon = null;
@@ -135,13 +131,11 @@
context = getContext(toolBar, Region.TOOL_BAR_CONTENT,
contentStyle, ENABLED);
contentStyle.uninstallDefaults(context);
- context.dispose();
contentStyle = null;
context = getContext(toolBar, Region.TOOL_BAR_DRAG_WINDOW,
dragWindowStyle, ENABLED);
dragWindowStyle.uninstallDefaults(context);
- context.dispose();
dragWindowStyle = null;
toolBar.setLayout(null);
@@ -215,7 +209,6 @@
g, 0, 0, c.getWidth(), c.getHeight(),
toolBar.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -232,7 +225,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -289,7 +281,6 @@
SynthContext subcontext = getContext(
toolBar, Region.TOOL_BAR_CONTENT, contentStyle);
paintContent(subcontext, g, contentRect);
- subcontext.dispose();
}
/**
@@ -326,7 +317,6 @@
dragWindow.getOrientation());
context.getPainter().paintToolBarDragWindowBorder(context, g, 0, 0, w, h,
dragWindow.getOrientation());
- context.dispose();
}
//
@@ -383,7 +373,6 @@
dim.width += insets.left + insets.right;
dim.height += insets.top + insets.bottom;
- context.dispose();
return dim;
}
@@ -421,7 +410,6 @@
dim.width += insets.left + insets.right;
dim.height += insets.top + insets.bottom;
- context.dispose();
return dim;
}
@@ -543,7 +531,6 @@
}
}
}
- context.dispose();
}
private boolean isGlue(Component c) {
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -68,7 +68,6 @@
private void updateStyle(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -78,7 +77,6 @@
protected void uninstallDefaults(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -139,7 +137,6 @@
context.getPainter().paintToolTipBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -165,7 +162,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -218,7 +214,6 @@
prefSize.height += fm.getHeight();
}
}
- context.dispose();
return prefSize;
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -147,11 +147,9 @@
installKeyboardActions();
}
}
- context.dispose();
context = getContext(tree, Region.TREE_CELL, ENABLED);
cellStyle = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -223,12 +221,10 @@
SynthContext context = getContext(tree, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
context = getContext(tree, Region.TREE_CELL, ENABLED);
cellStyle.uninstallDefaults(context);
- context.dispose();
cellStyle = null;
@@ -266,7 +262,6 @@
context.getPainter().paintTreeBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -292,7 +287,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -425,7 +419,6 @@
row++;
}
}
- cellContext.dispose();
paintDropLine(g);
@@ -743,7 +736,6 @@
context.getPainter().paintTreeCellFocus(context, g,
0, 0, getWidth() - imageOffset, getHeight());
}
- context.dispose();
}
SynthLookAndFeel.resetSelectedUI();
}
@@ -785,7 +777,6 @@
if (context == null) {
context = getContext(tree);
SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
- context.dispose();
}
else {
SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
@@ -797,7 +788,6 @@
if (context == null) {
context = getContext(tree);
width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
- context.dispose();
}
else {
width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
@@ -810,7 +800,6 @@
if (context == null) {
context = getContext(tree);
height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
- context.dispose();
}
else {
height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java Wed Jul 05 21:39:33 2017 +0200
@@ -99,7 +99,6 @@
newStyle.installDefaults(context);
}
this.style = newStyle;
- context.dispose();
}
/**
@@ -128,7 +127,6 @@
protected void uninstallDefaults(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -168,7 +166,6 @@
context.getPainter().paintViewportBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -202,7 +199,6 @@
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java Wed Jul 05 21:39:33 2017 +0200
@@ -2580,7 +2580,7 @@
* @param e the DocumentEvent
*/
public void insertUpdate(DocumentEvent e) {
- final Integer pos = new Integer (e.getOffset());
+ final Integer pos = e.getOffset();
if (SwingUtilities.isEventDispatchThread()) {
firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, pos);
} else {
@@ -2602,7 +2602,7 @@
* @param e the DocumentEvent
*/
public void removeUpdate(DocumentEvent e) {
- final Integer pos = new Integer (e.getOffset());
+ final Integer pos = e.getOffset();
if (SwingUtilities.isEventDispatchThread()) {
firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, pos);
} else {
@@ -2624,7 +2624,7 @@
* @param e the DocumentEvent
*/
public void changedUpdate(DocumentEvent e) {
- final Integer pos = new Integer (e.getOffset());
+ final Integer pos = e.getOffset();
if (SwingUtilities.isEventDispatchThread()) {
firePropertyChange(ACCESSIBLE_TEXT_PROPERTY, null, pos);
} else {
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java Wed Jul 05 21:39:33 2017 +0200
@@ -73,7 +73,7 @@
* type the value class represents. For example:
* setValueClass(Integer.class)
will cause the resulting
* value to be created via
- * new Integer(((Number)formatter.parseObject(string)).intValue())
.
+ * Integer.valueOf(((Number)formatter.parseObject(string)).intValue())
.
* This is typically useful if you
* wish to set a min/max value as the various Number
* implementations are generally not comparable to each other. This is also
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/text/StyleConstants.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/StyleConstants.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/StyleConstants.java Wed Jul 05 21:39:33 2017 +0200
@@ -608,7 +608,7 @@
* @param i the value
*/
public static void setFirstLineIndent(MutableAttributeSet a, float i) {
- a.addAttribute(FirstLineIndent, new Float(i));
+ a.addAttribute(FirstLineIndent, Float.valueOf(i));
}
/**
@@ -632,7 +632,7 @@
* @param i the value
*/
public static void setRightIndent(MutableAttributeSet a, float i) {
- a.addAttribute(RightIndent, new Float(i));
+ a.addAttribute(RightIndent, Float.valueOf(i));
}
/**
@@ -656,7 +656,7 @@
* @param i the value
*/
public static void setLeftIndent(MutableAttributeSet a, float i) {
- a.addAttribute(LeftIndent, new Float(i));
+ a.addAttribute(LeftIndent, Float.valueOf(i));
}
/**
@@ -680,7 +680,7 @@
* @param i the value
*/
public static void setLineSpacing(MutableAttributeSet a, float i) {
- a.addAttribute(LineSpacing, new Float(i));
+ a.addAttribute(LineSpacing, Float.valueOf(i));
}
/**
@@ -704,7 +704,7 @@
* @param i the value
*/
public static void setSpaceAbove(MutableAttributeSet a, float i) {
- a.addAttribute(SpaceAbove, new Float(i));
+ a.addAttribute(SpaceAbove, Float.valueOf(i));
}
/**
@@ -728,7 +728,7 @@
* @param i the value
*/
public static void setSpaceBelow(MutableAttributeSet a, float i) {
- a.addAttribute(SpaceBelow, new Float(i));
+ a.addAttribute(SpaceBelow, Float.valueOf(i));
}
/**
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java Wed Jul 05 21:39:33 2017 +0200
@@ -2564,7 +2564,7 @@
* represents the CSS attribute value
*/
Object toStyleConstants(StyleConstants key, View v) {
- return new Float(getValue(false));
+ return Float.valueOf(getValue(false));
}
/** If true, span is a percentage value, and that to determine
@@ -2837,25 +2837,25 @@
static Hashtable lengthMapping = new Hashtable(6);
static Hashtable w3cLengthMapping = new Hashtable(6);
static {
- lengthMapping.put("pt", new Float(1f));
+ lengthMapping.put("pt", Float.valueOf(1f));
// Not sure about 1.3, determined by experiementation.
- lengthMapping.put("px", new Float(1.3f));
- lengthMapping.put("mm", new Float(2.83464f));
- lengthMapping.put("cm", new Float(28.3464f));
- lengthMapping.put("pc", new Float(12f));
- lengthMapping.put("in", new Float(72f));
+ lengthMapping.put("px", Float.valueOf(1.3f));
+ lengthMapping.put("mm", Float.valueOf(2.83464f));
+ lengthMapping.put("cm", Float.valueOf(28.3464f));
+ lengthMapping.put("pc", Float.valueOf(12f));
+ lengthMapping.put("in", Float.valueOf(72f));
int res = 72;
try {
res = Toolkit.getDefaultToolkit().getScreenResolution();
} catch (HeadlessException e) {
}
// mapping according to the CSS2 spec
- w3cLengthMapping.put("pt", new Float(res/72f));
- w3cLengthMapping.put("px", new Float(1f));
- w3cLengthMapping.put("mm", new Float(res/25.4f));
- w3cLengthMapping.put("cm", new Float(res/2.54f));
- w3cLengthMapping.put("pc", new Float(res/6f));
- w3cLengthMapping.put("in", new Float(res));
+ w3cLengthMapping.put("pt", Float.valueOf(res/72f));
+ w3cLengthMapping.put("px", Float.valueOf(1f));
+ w3cLengthMapping.put("mm", Float.valueOf(res/25.4f));
+ w3cLengthMapping.put("cm", Float.valueOf(res/2.54f));
+ w3cLengthMapping.put("pc", Float.valueOf(res/6f));
+ w3cLengthMapping.put("in", Float.valueOf((float)res));
}
LengthUnit(String value, short defaultType, float defaultValue) {
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/javax/swing/text/rtf/RTFAttributes.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/RTFAttributes.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/RTFAttributes.java Wed Jul 05 21:39:33 2017 +0200
@@ -357,7 +357,7 @@
public static NumericAttribute NewTwips(int d, Object s, String r,
float ds, int dr)
{
- return new NumericAttribute(d, s, r, new Float(ds), dr, 20f);
+ return new NumericAttribute(d, s, r, Float.valueOf(ds), dr, 20f);
}
public static NumericAttribute NewTwips(int d, Object s, String r,
@@ -378,7 +378,7 @@
if (scale == 1f)
swingValue = Integer.valueOf(parameter);
else
- swingValue = new Float(parameter / scale);
+ swingValue = Float.valueOf(parameter / scale);
target.addAttribute(swingName, swingValue);
return true;
}
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java Wed Jul 05 21:39:33 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
import javax.accessibility.AccessibleContext;
import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
import java.awt.dnd.DragSourceContext;
import java.awt.dnd.DropTargetContext;
import java.awt.dnd.peer.DragSourceContextPeer;
@@ -104,7 +105,7 @@
/*
* Requests focus to the component.
*/
- boolean requestFocus(Component comp, CausedFocusEvent.Cause cause);
+ boolean requestFocus(Component comp, Cause cause);
/*
* Determines if the component can gain focus.
*/
@@ -438,7 +439,7 @@
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause);
+ Cause cause);
/**
* Delivers focus for the lightweight descendant of the heavyweight
* synchronously.
diff -r ff3dad4e4c51 -r 82b8d12a553f jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java
--- a/jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java Wed Jul 05 21:38:13 2017 +0200
+++ b/jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java Wed Jul 05 21:39:33 2017 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,17 +27,18 @@
import java.awt.event.FocusEvent;
import java.awt.Component;
+import java.io.ObjectStreamException;
+import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
/**
- * This class represents FocusEvents with a known "cause" - reason why this event happened. It can
- * be mouse press, traversal, activation, and so on - all causes are described as Cause enum. The
- * event with the cause can be constructed in two ways - explicitly through constructor of
- * CausedFocusEvent class or implicitly, by calling appropriate requestFocusXXX method with "cause"
- * parameter. The default cause is UNKNOWN.
+ * This class exists for deserialization compatibility only.
*/
-@SuppressWarnings("serial")
-public class CausedFocusEvent extends FocusEvent {
- public enum Cause {
+class CausedFocusEvent extends FocusEvent {
+ private static final long serialVersionUID = -3647309088427840738L;
+
+ private enum Cause {
UNKNOWN,
MOUSE_EVENT,
TRAVERSAL,
@@ -51,39 +52,82 @@
NATIVE_SYSTEM,
ACTIVATION,
CLEAR_GLOBAL_FOCUS_OWNER,
- RETARGETED
+ RETARGETED;
};
+ @SuppressWarnings("serial")
+ private static final Component dummy = new Component(){};
+
private final Cause cause;
- public Cause getCause() {
- return cause;
- }
-
- public String toString() {
- return "java.awt.FocusEvent[" + super.paramString() + ",cause=" + cause + "] on " + getSource();
- }
-
- public CausedFocusEvent(Component source, int id, boolean temporary,
+ private CausedFocusEvent(Component source, int id, boolean temporary,
Component opposite, Cause cause) {
super(source, id, temporary, opposite);
- if (cause == null) {
- cause = Cause.UNKNOWN;
- }
- this.cause = cause;
+ throw new IllegalStateException();
}
- /**
- * Retargets the original focus event to the new target. If the
- * original focus event is CausedFocusEvent, it remains such and
- * cause is copied. Otherwise, new CausedFocusEvent is created,
- * with cause as RETARGETED.
- * @return retargeted event, or null if e is null
- */
- public static FocusEvent retarget(FocusEvent e, Component newSource) {
- if (e == null) return null;
+ Object readResolve() throws ObjectStreamException {
+ FocusEvent.Cause newCause;
+ switch (cause) {
+ case UNKNOWN:
+ newCause = FocusEvent.Cause.UNKNOWN;
+ break;
+ case MOUSE_EVENT:
+ newCause = FocusEvent.Cause.MOUSE_EVENT;
+ break;
+ case TRAVERSAL:
+ newCause = FocusEvent.Cause.TRAVERSAL;
+ break;
+ case TRAVERSAL_UP:
+ newCause = FocusEvent.Cause.TRAVERSAL_UP;
+ break;
+ case TRAVERSAL_DOWN:
+ newCause = FocusEvent.Cause.TRAVERSAL_DOWN;
+ break;
+ case TRAVERSAL_FORWARD:
+ newCause = FocusEvent.Cause.TRAVERSAL_FORWARD;
+ break;
+ case TRAVERSAL_BACKWARD:
+ newCause = FocusEvent.Cause.TRAVERSAL_BACKWARD;
+ break;
+ case ROLLBACK:
+ newCause = FocusEvent.Cause.ROLLBACK;
+ break;
+ case NATIVE_SYSTEM:
+ newCause = FocusEvent.Cause.UNEXPECTED;
+ break;
+ case ACTIVATION:
+ newCause = FocusEvent.Cause.ACTIVATION;
+ break;
+ case CLEAR_GLOBAL_FOCUS_OWNER:
+ newCause = FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER;
+ break;
+ default:
+ newCause = FocusEvent.Cause.UNKNOWN;
+ }
- return new CausedFocusEvent(newSource, e.getID(), e.isTemporary(), e.getOppositeComponent(),
- (e instanceof CausedFocusEvent) ? ((CausedFocusEvent)e).getCause() : Cause.RETARGETED);
+ FocusEvent focusEvent = new FocusEvent(dummy, getID(), isTemporary(),
+ getOppositeComponent(), newCause);
+ focusEvent.setSource(null);
+ try {
+ final Field consumedField = FocusEvent.class.getField("consumed");
+ AccessController.doPrivileged(new PrivilegedAction