\n";
diff --git a/jdk/src/java.base/share/classes/java/lang/String.java b/jdk/src/java.base/share/classes/java/lang/String.java
index a1772977727..33222a586b5 100644
--- a/jdk/src/java.base/share/classes/java/lang/String.java
+++ b/jdk/src/java.base/share/classes/java/lang/String.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -78,14 +78,8 @@ import jdk.internal.vm.annotation.Stable;
*
* The Java language provides special support for the string
* concatenation operator ( + ), and for conversion of
- * other objects to strings. String concatenation is implemented
- * through the {@code StringBuilder}(or {@code StringBuffer})
- * class and its {@code append} method.
- * String conversions are implemented through the method
- * {@code toString}, defined by {@code Object} and
- * inherited by all classes in Java. For additional information on
- * string concatenation and conversion, see Gosling, Joy, and Steele,
- * The Java Language Specification .
+ * other objects to strings. For additional information on string
+ * concatenation and conversion, see The Java™ Language Specification .
*
*
Unless otherwise noted, passing a {@code null} argument to a constructor
* or method in this class will cause a {@link NullPointerException} to be
@@ -106,6 +100,14 @@ import jdk.internal.vm.annotation.Stable;
* into account. The {@link java.text.Collator} class provides methods for
* finer-grain, locale-sensitive String comparison.
*
+ * @implNote The implementation of the string concatenation operator is left to
+ * the discretion of a Java compiler, as long as the compiler ultimately conforms
+ * to The Java™ Language Specification . For example, the {@code javac} compiler
+ * may implement the operator with {@code StringBuffer}, {@code StringBuilder},
+ * or {@code java.lang.invoke.StringConcatFactory} depending on the JDK version. The
+ * implementation of string conversion is typically through the method {@code toString},
+ * defined by {@code Object} and inherited by all classes in Java.
+ *
* @author Lee Boynton
* @author Arthur van Hoff
* @author Martin Buchholz
@@ -115,6 +117,7 @@ import jdk.internal.vm.annotation.Stable;
* @see java.lang.StringBuilder
* @see java.nio.charset.Charset
* @since 1.0
+ * @jls 15.18.1 String Concatenation Operator +
*/
public final class String
@@ -2977,6 +2980,7 @@ public final class String
*
* @return a string that has the same contents as this string, but is
* guaranteed to be from a pool of unique strings.
+ * @jls 3.10.5 String Literals
*/
public native String intern();
diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java
index 2ddd37f5da1..d6e80e71908 100644
--- a/jdk/src/java.base/share/classes/java/lang/System.java
+++ b/jdk/src/java.base/share/classes/java/lang/System.java
@@ -1155,8 +1155,9 @@ public final class System {
* @param level the log message level.
* @param msg the string message (or a key in the message catalog, if
* this logger is a {@link
- * LoggerFinder#getLocalizedLogger(java.lang.String, java.util.ResourceBundle, java.lang.Class)
- * localized logger}); can be {@code null}.
+ * LoggerFinder#getLocalizedLogger(java.lang.String,
+ * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * can be {@code null}.
*
* @throws NullPointerException if {@code level} is {@code null}.
*/
@@ -1222,8 +1223,9 @@ public final class System {
* @param level the log message level.
* @param msg the string message (or a key in the message catalog, if
* this logger is a {@link
- * LoggerFinder#getLocalizedLogger(java.lang.String, java.util.ResourceBundle, java.lang.Class)
- * localized logger}); can be {@code null}.
+ * LoggerFinder#getLocalizedLogger(java.lang.String,
+ * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * can be {@code null}.
* @param thrown a {@code Throwable} associated with the log message;
* can be {@code null}.
*
@@ -1270,8 +1272,9 @@ public final class System {
* @param format the string message format in {@link
* java.text.MessageFormat} format, (or a key in the message
* catalog, if this logger is a {@link
- * LoggerFinder#getLocalizedLogger(java.lang.String, java.util.ResourceBundle, java.lang.Class)
- * localized logger}); can be {@code null}.
+ * LoggerFinder#getLocalizedLogger(java.lang.String,
+ * java.util.ResourceBundle, java.lang.reflect.Module) localized logger});
+ * can be {@code null}.
* @param params an optional list of parameters to the message (may be
* none).
*
@@ -1453,30 +1456,30 @@ public final class System {
/**
* Returns an instance of {@link Logger Logger}
- * for the given {@code caller}.
+ * for the given {@code module}.
*
* @param name the name of the logger.
- * @param caller the class for which the logger is being requested.
+ * @param module the module for which the logger is being requested.
*
- * @return a {@link Logger logger} suitable for the given caller's
- * use.
+ * @return a {@link Logger logger} suitable for use within the given
+ * module.
* @throws NullPointerException if {@code name} is {@code null} or
- * {@code caller} is {@code null}.
+ * {@code module} is {@code null}.
* @throws SecurityException if a security manager is present and its
* {@code checkPermission} method doesn't allow the
* {@code RuntimePermission("loggerFinder")}.
*/
- public abstract Logger getLogger(String name, /* Module */ Class> caller);
+ public abstract Logger getLogger(String name, Module module);
/**
* Returns a localizable instance of {@link Logger Logger}
- * for the given {@code caller}.
+ * for the given {@code module}.
* The returned logger will use the provided resource bundle for
* message localization.
*
* @implSpec By default, this method calls {@link
- * #getLogger(java.lang.String, java.lang.Class)
- * this.getLogger(name, caller)} to obtain a logger, then wraps that
+ * #getLogger(java.lang.String, java.lang.reflect.Module)
+ * this.getLogger(name, module)} to obtain a logger, then wraps that
* logger in a {@link Logger} instance where all methods that do not
* take a {@link ResourceBundle} as parameter are redirected to one
* which does - passing the given {@code bundle} for
@@ -1499,19 +1502,19 @@ public final class System {
*
* @param name the name of the logger.
* @param bundle a resource bundle; can be {@code null}.
- * @param caller the class for which the logger is being requested.
+ * @param module the module for which the logger is being requested.
* @return an instance of {@link Logger Logger} which will use the
* provided resource bundle for message localization.
*
* @throws NullPointerException if {@code name} is {@code null} or
- * {@code caller} is {@code null}.
+ * {@code module} is {@code null}.
* @throws SecurityException if a security manager is present and its
* {@code checkPermission} method doesn't allow the
* {@code RuntimePermission("loggerFinder")}.
*/
public Logger getLocalizedLogger(String name, ResourceBundle bundle,
- /* Module */ Class> caller) {
- return new LocalizedLoggerWrapper<>(getLogger(name, caller), bundle);
+ Module module) {
+ return new LocalizedLoggerWrapper<>(getLogger(name, module), bundle);
}
/**
@@ -1558,12 +1561,13 @@ public final class System {
*
* @implSpec
* Instances returned by this method route messages to loggers
- * obtained by calling {@link LoggerFinder#getLogger(java.lang.String, java.lang.Class)
- * LoggerFinder.getLogger(name, caller)}.
+ * obtained by calling {@link LoggerFinder#getLogger(java.lang.String,
+ * java.lang.reflect.Module) LoggerFinder.getLogger(name, module)}, where
+ * {@code module} is the caller's module.
*
* @apiNote
* This method may defer calling the {@link
- * LoggerFinder#getLogger(java.lang.String, java.lang.Class)
+ * LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)
* LoggerFinder.getLogger} method to create an actual logger supplied by
* the logging backend, for instance, to allow loggers to be obtained during
* the system initialization time.
@@ -1579,7 +1583,7 @@ public final class System {
public static Logger getLogger(String name) {
Objects.requireNonNull(name);
final Class> caller = Reflection.getCallerClass();
- return LazyLoggers.getLogger(name, caller);
+ return LazyLoggers.getLogger(name, caller.getModule());
}
/**
@@ -1591,8 +1595,9 @@ public final class System {
* @implSpec
* The returned logger will perform message localization as specified
* by {@link LoggerFinder#getLocalizedLogger(java.lang.String,
- * java.util.ResourceBundle, java.lang.Class)
- * LoggerFinder.getLocalizedLogger(name, bundle, caller}.
+ * java.util.ResourceBundle, java.lang.reflect.Module)
+ * LoggerFinder.getLocalizedLogger(name, bundle, module}, where
+ * {@code module} is the caller's module.
*
* @apiNote
* This method is intended to be used after the system is fully initialized.
@@ -1624,12 +1629,14 @@ public final class System {
// Bootstrap sensitive classes in the JDK do not use resource bundles
// when logging. This could be revisited later, if it needs to.
if (sm != null) {
- return AccessController.doPrivileged((PrivilegedAction)
- () -> LoggerFinder.accessProvider().getLocalizedLogger(name, rb, caller),
- null,
- LoggerFinder.LOGGERFINDER_PERMISSION);
+ final PrivilegedAction pa =
+ () -> LoggerFinder.accessProvider()
+ .getLocalizedLogger(name, rb, caller.getModule());
+ return AccessController.doPrivileged(pa, null,
+ LoggerFinder.LOGGERFINDER_PERMISSION);
}
- return LoggerFinder.accessProvider().getLocalizedLogger(name, rb, caller);
+ return LoggerFinder.accessProvider()
+ .getLocalizedLogger(name, rb, caller.getModule());
}
/**
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
index a108836ce51..782eff613ae 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
@@ -25,6 +25,7 @@
package java.lang.invoke;
+import java.lang.reflect.Array;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Arrays;
@@ -1892,7 +1893,8 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
MH_tryFinallyExec = 12,
MH_tryFinallyVoidExec = 13,
MH_decrementCounter = 14,
- MH_LIMIT = 15;
+ MH_Array_newInstance = 15,
+ MH_LIMIT = 16;
static MethodHandle getConstantHandle(int idx) {
MethodHandle handle = HANDLES[idx];
@@ -1965,6 +1967,9 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
case MH_decrementCounter:
return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "decrementCounter",
MethodType.methodType(int.class, int.class));
+ case MH_Array_newInstance:
+ return IMPL_LOOKUP.findStatic(Array.class, "newInstance",
+ MethodType.methodType(Object.class, Class.class, int.class));
}
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
index 6c37371a57b..c3a97a178a3 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
@@ -25,34 +25,38 @@
package java.lang.invoke;
-import java.lang.reflect.*;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Arrays;
-import java.util.Objects;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Opcodes;
+import jdk.internal.reflect.CallerSensitive;
+import jdk.internal.reflect.Reflection;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyAccess;
import sun.invoke.util.Wrapper;
-import jdk.internal.reflect.CallerSensitive;
-import jdk.internal.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
import sun.security.util.SecurityConstants;
-import java.lang.invoke.LambdaForm.BasicType;
-import static java.lang.invoke.MethodHandleImpl.Intrinsic;
-import static java.lang.invoke.MethodHandleNatives.Constants.*;
+import java.lang.invoke.LambdaForm.BasicType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ReflectPermission;
+import java.nio.ByteOrder;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.internal.org.objectweb.asm.ClassWriter;
-import jdk.internal.org.objectweb.asm.Opcodes;
-
+import static java.lang.invoke.MethodHandleImpl.Intrinsic;
+import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.newIllegalArgumentException;
import static java.lang.invoke.MethodType.methodType;
@@ -741,10 +745,13 @@ public class MethodHandles {
if (name.startsWith("java.lang.invoke."))
throw newIllegalArgumentException("illegal lookupClass: "+lookupClass);
- // For caller-sensitive MethodHandles.lookup()
- // disallow lookup more restricted packages
+ // For caller-sensitive MethodHandles.lookup() disallow lookup from
+ // restricted packages. This a fragile and blunt approach.
+ // TODO replace with a more formal and less fragile mechanism
+ // that does not bluntly restrict classes under packages within
+ // java.base from looking up MethodHandles or VarHandles.
if (allowedModes == ALL_MODES && lookupClass.getClassLoader() == null) {
- if (name.startsWith("java.") ||
+ if ((name.startsWith("java.") && !name.startsWith("java.util.concurrent.")) ||
(name.startsWith("sun.") && !name.startsWith("sun.invoke."))) {
throw newIllegalArgumentException("illegal lookupClass: " + lookupClass);
}
@@ -1003,6 +1010,9 @@ assertEquals("[x, y, z]", pb.command().toString());
* @throws NullPointerException if any argument is null
*/
public MethodHandle findConstructor(Class> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ if (refc.isArray()) {
+ throw new NoSuchMethodException("no constructor for array class: " + refc.getName());
+ }
String name = "";
MemberName ctor = resolveOrFail(REF_newInvokeSpecial, refc, name, type);
return getDirectConstructor(refc, ctor);
@@ -2213,6 +2223,27 @@ return mh1;
static final Lookup PUBLIC_LOOKUP = new Lookup(PUBLIC_LOOKUP_CLASS, Lookup.PUBLIC);
}
+ /**
+ * Produces a method handle constructing arrays of a desired type.
+ * The return type of the method handle will be the array type.
+ * The type of its sole argument will be {@code int}, which specifies the size of the array.
+ * @param arrayClass an array type
+ * @return a method handle which can create arrays of the given type
+ * @throws NullPointerException if the argument is {@code null}
+ * @throws IllegalArgumentException if {@code arrayClass} is not an array type
+ * @see java.lang.reflect.Array#newInstance(Class, int)
+ * @since 9
+ */
+ public static
+ MethodHandle arrayConstructor(Class> arrayClass) throws IllegalArgumentException {
+ if (!arrayClass.isArray()) {
+ throw newIllegalArgumentException("not an array class: " + arrayClass.getName());
+ }
+ MethodHandle ani = MethodHandleImpl.getConstantHandle(MethodHandleImpl.MH_Array_newInstance).
+ bindTo(arrayClass.getComponentType());
+ return ani.asType(ani.type().changeReturnType(arrayClass));
+ }
+
/**
* Produces a method handle giving read access to elements of an array.
* The type of the method handle will have a return type of the array's
@@ -2337,13 +2368,12 @@ return mh1;
*
* @param viewArrayClass the view array class, with a component type of
* type {@code T}
- * @param bigEndian true if the endianness of the view array elements, as
- * stored in the underlying {@code byte} array, is big endian, otherwise
- * little endian
+ * @param byteOrder the endianness of the view array elements, as
+ * stored in the underlying {@code byte} array
* @return a VarHandle giving access to elements of a {@code byte[]} array
* viewed as if elements corresponding to the components type of the view
* array class
- * @throws NullPointerException if viewArrayClass is null
+ * @throws NullPointerException if viewArrayClass or byteOrder is null
* @throws IllegalArgumentException if viewArrayClass is not an array type
* @throws UnsupportedOperationException if the component type of
* viewArrayClass is not supported as a variable type
@@ -2351,8 +2381,10 @@ return mh1;
*/
public static
VarHandle byteArrayViewVarHandle(Class> viewArrayClass,
- boolean bigEndian) throws IllegalArgumentException {
- return VarHandles.byteArrayViewHandle(viewArrayClass, bigEndian);
+ ByteOrder byteOrder) throws IllegalArgumentException {
+ Objects.requireNonNull(byteOrder);
+ return VarHandles.byteArrayViewHandle(viewArrayClass,
+ byteOrder == ByteOrder.BIG_ENDIAN);
}
/**
@@ -2422,14 +2454,13 @@ return mh1;
*
* @param viewArrayClass the view array class, with a component type of
* type {@code T}
- * @param bigEndian true if the endianness of the view array elements, as
- * stored in the underlying {@code ByteBuffer}, is big endian, otherwise
- * little endian (Note this overrides the endianness of a
- * {@code ByteBuffer})
+ * @param byteOrder the endianness of the view array elements, as
+ * stored in the underlying {@code ByteBuffer} (Note this overrides the
+ * endianness of a {@code ByteBuffer})
* @return a VarHandle giving access to elements of a {@code ByteBuffer}
* viewed as if elements corresponding to the components type of the view
* array class
- * @throws NullPointerException if viewArrayClass is null
+ * @throws NullPointerException if viewArrayClass or byteOrder is null
* @throws IllegalArgumentException if viewArrayClass is not an array type
* @throws UnsupportedOperationException if the component type of
* viewArrayClass is not supported as a variable type
@@ -2437,8 +2468,10 @@ return mh1;
*/
public static
VarHandle byteBufferViewVarHandle(Class> viewArrayClass,
- boolean bigEndian) throws IllegalArgumentException {
- return VarHandles.makeByteBufferViewHandle(viewArrayClass, bigEndian);
+ ByteOrder byteOrder) throws IllegalArgumentException {
+ Objects.requireNonNull(byteOrder);
+ return VarHandles.makeByteBufferViewHandle(viewArrayClass,
+ byteOrder == ByteOrder.BIG_ENDIAN);
}
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
index 44f29a4a136..f302c75af79 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java
@@ -123,7 +123,7 @@ public final class StringConcatFactory {
* Concatenation strategy to use. See {@link Strategy} for possible options.
* This option is controllable with -Djava.lang.invoke.stringConcat JDK option.
*/
- private static final Strategy STRATEGY;
+ private static Strategy STRATEGY;
/**
* Default strategy to use for concatenation.
@@ -187,6 +187,16 @@ public final class StringConcatFactory {
private static final ProxyClassesDumper DUMPER;
static {
+ // In case we need to double-back onto the StringConcatFactory during this
+ // static initialization, make sure we have the reasonable defaults to complete
+ // the static initialization properly. After that, actual users would use the
+ // the proper values we have read from the the properties.
+ STRATEGY = DEFAULT_STRATEGY;
+ // CACHE_ENABLE = false; // implied
+ // CACHE = null; // implied
+ // DEBUG = false; // implied
+ // DUMPER = null; // implied
+
Properties props = GetPropertyAction.getProperties();
final String strategy =
props.getProperty("java.lang.invoke.stringConcat");
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
index cf869b3ebe7..4eb7f260a6c 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java
@@ -136,6 +136,7 @@ import static java.lang.invoke.MethodHandleStatics.newInternalError;
* consists of the methods
* {@link #compareAndSet compareAndSet},
* {@link #weakCompareAndSet weakCompareAndSet},
+ * {@link #weakCompareAndSetVolatile weakCompareAndSetVolatile},
* {@link #weakCompareAndSetAcquire weakCompareAndSetAcquire},
* {@link #weakCompareAndSetRelease weakCompareAndSetRelease},
* {@link #compareAndExchangeAcquire compareAndExchangeAcquire},
@@ -458,7 +459,7 @@ public abstract class VarHandle {
*
* The symbolic type descriptor at the call site of {@code get}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.get)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET)} on this VarHandle.
*
*
This access mode is supported by all VarHandle instances and never
* throws {@code UnsupportedOperationException}.
@@ -488,7 +489,7 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code set}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.set)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.SET)} on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T newValue)}
@@ -516,7 +517,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getVolatile}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getVolatile)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_VOLATILE)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT)}
@@ -544,7 +546,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code setVolatile}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.setVolatile)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.SET_VOLATILE)} on this
+ * VarHandle.
*
* @apiNote
* Ignoring the many semantic differences from C and C++, this method has
@@ -574,7 +577,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getOpaque}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getOpaque)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_OPAQUE)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT)}
@@ -603,7 +607,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code setOpaque}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.setOpaque)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.SET_OPAQUE)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T newValue)}
@@ -631,7 +636,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getAcquire}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getAcquire)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_ACQUIRE)} on this
+ * VarHandle.
*
* @apiNote
* Ignoring the many semantic differences from C and C++, this method has
@@ -664,7 +670,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code setRelease}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.setRelease)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.SET_RELEASE)} on this
+ * VarHandle.
*
* @apiNote
* Ignoring the many semantic differences from C and C++, this method has
@@ -700,7 +707,7 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code
* compareAndSet} must match the access mode type that is the result of
- * calling {@code accessModeType(VarHandle.AccessMode.compareAndSet)} on
+ * calling {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_SET)} on
* this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
@@ -734,7 +741,7 @@ public abstract class VarHandle {
*
The symbolic type descriptor at the call site of {@code
* compareAndExchangeVolatile}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeVolatile)}
+ * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE)}
* on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
@@ -769,7 +776,7 @@ public abstract class VarHandle {
*
The symbolic type descriptor at the call site of {@code
* compareAndExchangeAcquire}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeAcquire)} on
+ * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)} on
* this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
@@ -804,7 +811,8 @@ public abstract class VarHandle {
*
The symbolic type descriptor at the call site of {@code
* compareAndExchangeRelease}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.compareAndExchangeRelease)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)}
+ * on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T expectedValue, T newValue)}
@@ -836,14 +844,14 @@ public abstract class VarHandle {
* {@link #get}.
*
*
This operation may fail spuriously (typically, due to memory
- * contention) even if the current value does match the expected value.
+ * contention) even if the witness value does match the expected value.
*
*
The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
*
*
The symbolic type descriptor at the call site of {@code
* weakCompareAndSet} must match the access mode type that is the result of
- * calling {@code accessModeType(VarHandle.AccessMode.weakCompareAndSet)} on
- * this VarHandle.
+ * calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)}
+ * on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T expectedValue, T newValue)}
@@ -865,6 +873,43 @@ public abstract class VarHandle {
@HotSpotIntrinsicCandidate
boolean weakCompareAndSet(Object... args);
+ /**
+ * Possibly atomically sets the value of a variable to the {@code newValue}
+ * with the memory semantics of {@link #setVolatile} if the variable's
+ * current value, referred to as the witness value , {@code ==} the
+ * {@code expectedValue}, as accessed with the memory semantics of
+ * {@link #getVolatile}.
+ *
+ *
This operation may fail spuriously (typically, due to memory
+ * contention) even if the witness value does match the expected value.
+ *
+ *
The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
+ *
+ *
The symbolic type descriptor at the call site of {@code
+ * weakCompareAndSetVolatile} must match the access mode type that is the
+ * result of calling {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)}
+ * on this VarHandle.
+ *
+ * @param args the signature-polymorphic parameter list of the form
+ * {@code (CT, T expectedValue, T newValue)}
+ * , statically represented using varargs.
+ * @return {@code true} if successful, otherwise {@code false} if the
+ * witness value was not the same as the {@code expectedValue} or if this
+ * operation spuriously failed.
+ * @throws UnsupportedOperationException if the access mode is unsupported
+ * for this VarHandle.
+ * @throws WrongMethodTypeException if the access mode type is not
+ * compatible with the caller's symbolic type descriptor.
+ * @throws ClassCastException if the access mode type is compatible with the
+ * caller's symbolic type descriptor, but a reference cast fails.
+ * @see #setVolatile(Object...)
+ * @see #getVolatile(Object...)
+ */
+ public final native
+ @MethodHandle.PolymorphicSignature
+ @HotSpotIntrinsicCandidate
+ boolean weakCompareAndSetVolatile(Object... args);
+
/**
* Possibly atomically sets the value of a variable to the {@code newValue}
* with the semantics of {@link #set} if the variable's current value,
@@ -873,14 +918,15 @@ public abstract class VarHandle {
* {@link #getAcquire}.
*
*
This operation may fail spuriously (typically, due to memory
- * contention) even if the current value does match the expected value.
+ * contention) even if the witness value does match the expected value.
*
*
The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
*
*
The symbolic type descriptor at the call site of {@code
* weakCompareAndSetAcquire}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.weakCompareAndSetAcquire)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)}
+ * on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T expectedValue, T newValue)}
@@ -910,14 +956,15 @@ public abstract class VarHandle {
* {@link #get}.
*
*
This operation may fail spuriously (typically, due to memory
- * contention) even if the current value does match the expected value.
+ * contention) even if the witness value does match the expected value.
*
*
The method signature is of the form {@code (CT, T expectedValue, T newValue)boolean}.
*
*
The symbolic type descriptor at the call site of {@code
* weakCompareAndSetRelease}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.weakCompareAndSetRelease)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)}
+ * on this VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T expectedValue, T newValue)}
@@ -949,7 +996,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getAndSet}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getAndSet)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_AND_SET)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T newValue)}
@@ -985,7 +1033,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code getAndAdd}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.getAndAdd)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.GET_AND_ADD)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T value)}
@@ -1017,7 +1066,8 @@ public abstract class VarHandle {
*
*
The symbolic type descriptor at the call site of {@code addAndGet}
* must match the access mode type that is the result of calling
- * {@code accessModeType(VarHandle.AccessMode.addAndGet)} on this VarHandle.
+ * {@code accessModeType(VarHandle.AccessMode.ADD_AND_GET)} on this
+ * VarHandle.
*
* @param args the signature-polymorphic parameter list of the form
* {@code (CT, T value)}
@@ -1083,109 +1133,115 @@ public abstract class VarHandle {
* method
* {@link VarHandle#get VarHandle.get}
*/
- GET("get", AccessType.GET, Object.class), // 0
+ GET("get", AccessType.GET, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#set VarHandle.set}
*/
- SET("set", AccessType.SET, void.class), // 1
+ SET("set", AccessType.SET, void.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getVolatile VarHandle.getVolatile}
*/
- GET_VOLATILE("getVolatile", AccessType.GET, Object.class), // 2
+ GET_VOLATILE("getVolatile", AccessType.GET, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setVolatile VarHandle.setVolatile}
*/
- SET_VOLATILE("setVolatile", AccessType.SET, void.class), // 3
+ SET_VOLATILE("setVolatile", AccessType.SET, void.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAcquire VarHandle.getAcquire}
*/
- GET_ACQUIRE("getAcquire", AccessType.GET, Object.class), // 4
+ GET_ACQUIRE("getAcquire", AccessType.GET, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setRelease VarHandle.setRelease}
*/
- SET_RELEASE("setRelease", AccessType.SET, void.class), // 5
+ SET_RELEASE("setRelease", AccessType.SET, void.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getOpaque VarHandle.getOpaque}
*/
- GET_OPAQUE("getOpaque", AccessType.GET, Object.class), // 6
+ GET_OPAQUE("getOpaque", AccessType.GET, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#setOpaque VarHandle.setOpaque}
*/
- SET_OPAQUE("setOpaque", AccessType.SET, void.class), // 7
+ SET_OPAQUE("setOpaque", AccessType.SET, void.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndSet VarHandle.compareAndSet}
*/
- COMPARE_AND_SET("compareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class), // 8
+ COMPARE_AND_SET("compareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeVolatile VarHandle.compareAndExchangeVolatile}
*/
- COMPARE_AND_EXCHANGE_VOLATILE("compareAndExchangeVolatile", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 9
+ COMPARE_AND_EXCHANGE_VOLATILE("compareAndExchangeVolatile", AccessType.COMPARE_AND_EXCHANGE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeAcquire VarHandle.compareAndExchangeAcquire}
*/
- COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 10
+ COMPARE_AND_EXCHANGE_ACQUIRE("compareAndExchangeAcquire", AccessType.COMPARE_AND_EXCHANGE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#compareAndExchangeRelease VarHandle.compareAndExchangeRelease}
*/
- COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE, Object.class), // 11
+ COMPARE_AND_EXCHANGE_RELEASE("compareAndExchangeRelease", AccessType.COMPARE_AND_EXCHANGE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSet VarHandle.weakCompareAndSet}
*/
- WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class), // 12
+ WEAK_COMPARE_AND_SET("weakCompareAndSet", AccessType.COMPARE_AND_SWAP, boolean.class),
+ /**
+ * The access mode whose access is specified by the corresponding
+ * method
+ * {@link VarHandle#weakCompareAndSetVolatile VarHandle.weakCompareAndSetVolatile}
+ */
+ WEAK_COMPARE_AND_SET_VOLATILE("weakCompareAndSetVolatile", AccessType.COMPARE_AND_SWAP, boolean.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSetAcquire VarHandle.weakCompareAndSetAcquire}
*/
- WEAK_COMPARE_AND_SET_ACQUIRE("weakCompareAndSetAcquire", AccessType.COMPARE_AND_SWAP, boolean.class), // 13
+ WEAK_COMPARE_AND_SET_ACQUIRE("weakCompareAndSetAcquire", AccessType.COMPARE_AND_SWAP, boolean.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#weakCompareAndSetRelease VarHandle.weakCompareAndSetRelease}
*/
- WEAK_COMPARE_AND_SET_RELEASE("weakCompareAndSetRelease", AccessType.COMPARE_AND_SWAP, boolean.class), // 14
+ WEAK_COMPARE_AND_SET_RELEASE("weakCompareAndSetRelease", AccessType.COMPARE_AND_SWAP, boolean.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAndSet VarHandle.getAndSet}
*/
- GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE, Object.class), // 15
+ GET_AND_SET("getAndSet", AccessType.GET_AND_UPDATE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#getAndAdd VarHandle.getAndAdd}
*/
- GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE, Object.class), // 16
+ GET_AND_ADD("getAndAdd", AccessType.GET_AND_UPDATE, Object.class),
/**
* The access mode whose access is specified by the corresponding
* method
* {@link VarHandle#addAndGet VarHandle.addAndGet}
*/
- ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE, Object.class), // 17
+ ADD_AND_GET("addAndGet", AccessType.GET_AND_UPDATE, Object.class),
;
static final Map methodNameToAccessMode;
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
index bcec64bd390..4a9d9e11e36 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
@@ -154,6 +154,15 @@ final class VarHandle$Type$s {
{#if[Object]?handle.fieldType.cast(value):value});
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+ handle.fieldOffset,
+ {#if[Object]?handle.fieldType.cast(expected):expected},
+ {#if[Object]?handle.fieldType.cast(value):value});
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
return UNSAFE.weakCompareAndSwap$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
@@ -318,6 +327,15 @@ final class VarHandle$Type$s {
{#if[Object]?handle.fieldType.cast(value):value});
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$Type$(handle.base,
+ handle.fieldOffset,
+ {#if[Object]?handle.fieldType.cast(expected):expected},
+ {#if[Object]?handle.fieldType.cast(value):value});
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
return UNSAFE.weakCompareAndSwap$Type$Acquire(handle.base,
@@ -534,6 +552,20 @@ final class VarHandle$Type$s {
{#if[Object]?handle.componentType.cast(value):value});
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
+#if[Object]
+ Object[] array = (Object[]) handle.arrayType.cast(oarray);
+#else[Object]
+ $type$[] array = ($type$[]) oarray;
+#end[Object]
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$Type$(array,
+ (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
+ {#if[Object]?handle.componentType.cast(expected):expected},
+ {#if[Object]?handle.componentType.cast(value):value});
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(Array handle, Object oarray, int index, $type$ expected, $type$ value) {
#if[Object]
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
index bdc77a820d2..b5bf9cba232 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
@@ -227,6 +227,16 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
convEndian(handle.be, expected), convEndian(handle.be, value));
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
+ byte[] ba = (byte[]) oba;
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$RawType$(
+ ba,
+ address(ba, index(ba, index)),
+ convEndian(handle.be, expected), convEndian(handle.be, value));
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
byte[] ba = (byte[]) oba;
@@ -443,6 +453,16 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase {
convEndian(handle.be, expected), convEndian(handle.be, value));
}
+ @ForceInline
+ static boolean weakCompareAndSetVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
+ ByteBuffer bb = (ByteBuffer) obb;
+ // TODO defer to strong form until new Unsafe method is added
+ return UNSAFE.compareAndSwap$RawType$(
+ UNSAFE.getObject(bb, BYTE_BUFFER_HB),
+ address(bb, indexRO(bb, index)),
+ convEndian(handle.be, expected), convEndian(handle.be, value));
+ }
+
@ForceInline
static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
ByteBuffer bb = (ByteBuffer) obb;
diff --git a/jdk/src/java.base/share/classes/java/util/Arrays.java b/jdk/src/java.base/share/classes/java/util/Arrays.java
index cc7b19de64e..6d7e858fbed 100644
--- a/jdk/src/java.base/share/classes/java/util/Arrays.java
+++ b/jdk/src/java.base/share/classes/java/util/Arrays.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -4403,6 +4403,35 @@ public class Arrays {
public void sort(Comparator super E> c) {
Arrays.sort(a, c);
}
+
+ @Override
+ public Iterator iterator() {
+ return new ArrayItr<>(a);
+ }
+ }
+
+ private static class ArrayItr implements Iterator {
+ private int cursor;
+ private final E[] a;
+
+ ArrayItr(E[] a) {
+ this.a = a;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return cursor < a.length;
+ }
+
+ @Override
+ public E next() {
+ int i = cursor;
+ if (i >= a.length) {
+ throw new NoSuchElementException();
+ }
+ cursor = i + 1;
+ return a[i];
+ }
}
/**
diff --git a/jdk/src/java.base/share/classes/java/util/Observable.java b/jdk/src/java.base/share/classes/java/util/Observable.java
index cff9e1f4d7b..b19830bb64e 100644
--- a/jdk/src/java.base/share/classes/java/util/Observable.java
+++ b/jdk/src/java.base/share/classes/java/util/Observable.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,19 @@ package java.util;
* @see java.util.Observer
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
* @since 1.0
+ *
+ * @deprecated
+ * This class and the {@link Observer} interface have been deprecated.
+ * The event model supported by {@code Observer} and {@code Observable}
+ * is quite limited, the order of notifications delivered by
+ * {@code Observable} is unspecified, and state changes are not in
+ * one-for-one correspondence with notifications.
+ * For a richer event model, consider using the
+ * {@link java.beans} package. For reliable and ordered
+ * messaging among threads, consider using one of the concurrent data
+ * structures in the {@link java.util.concurrent} package.
*/
+@Deprecated(since="9")
public class Observable {
private boolean changed = false;
private Vector obs;
diff --git a/jdk/src/java.base/share/classes/java/util/Observer.java b/jdk/src/java.base/share/classes/java/util/Observer.java
index 2db27b44a2d..47f793376ab 100644
--- a/jdk/src/java.base/share/classes/java/util/Observer.java
+++ b/jdk/src/java.base/share/classes/java/util/Observer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,12 @@ package java.util;
* @author Chris Warth
* @see java.util.Observable
* @since 1.0
+ *
+ * @deprecated
+ * This interface has been deprecated. See the {@link Observable}
+ * class for further information.
*/
+@Deprecated(since="9")
public interface Observer {
/**
* This method is called whenever the observed object is changed. An
diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java b/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java
index 56a5f57cc57..199a3d37f6a 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/DoublePipeline.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -167,6 +167,19 @@ abstract class DoublePipeline
return Nodes.doubleBuilder(exactSizeIfKnown);
}
+ private Stream mapToObj(DoubleFunction extends U> mapper, int opFlags) {
+ return new ReferencePipeline.StatelessOp(this, StreamShape.DOUBLE_VALUE, opFlags) {
+ @Override
+ Sink opWrapSink(int flags, Sink sink) {
+ return new Sink.ChainedDouble(sink) {
+ @Override
+ public void accept(double t) {
+ downstream.accept(mapper.apply(t));
+ }
+ };
+ }
+ };
+ }
// DoubleStream
@@ -184,7 +197,7 @@ abstract class DoublePipeline
@Override
public final Stream boxed() {
- return mapToObj(Double::valueOf);
+ return mapToObj(Double::valueOf, 0);
}
@Override
@@ -207,18 +220,7 @@ abstract class DoublePipeline
@Override
public final Stream mapToObj(DoubleFunction extends U> mapper) {
Objects.requireNonNull(mapper);
- return new ReferencePipeline.StatelessOp(this, StreamShape.DOUBLE_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
- @Override
- Sink opWrapSink(int flags, Sink sink) {
- return new Sink.ChainedDouble(sink) {
- @Override
- public void accept(double t) {
- downstream.accept(mapper.apply(t));
- }
- };
- }
- };
+ return mapToObj(mapper, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT);
}
@Override
diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java b/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java
index 7cf0622ce89..fe7bac59b6e 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/IntPipeline.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -170,6 +170,19 @@ abstract class IntPipeline
return Nodes.intBuilder(exactSizeIfKnown);
}
+ private Stream mapToObj(IntFunction extends U> mapper, int opFlags) {
+ return new ReferencePipeline.StatelessOp(this, StreamShape.INT_VALUE, opFlags) {
+ @Override
+ Sink opWrapSink(int flags, Sink sink) {
+ return new Sink.ChainedInt(sink) {
+ @Override
+ public void accept(int t) {
+ downstream.accept(mapper.apply(t));
+ }
+ };
+ }
+ };
+ }
// IntStream
@@ -187,8 +200,7 @@ abstract class IntPipeline
@Override
public final LongStream asLongStream() {
- return new LongPipeline.StatelessOp(this, StreamShape.INT_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
+ return new LongPipeline.StatelessOp(this, StreamShape.INT_VALUE, 0) {
@Override
Sink opWrapSink(int flags, Sink sink) {
return new Sink.ChainedInt(sink) {
@@ -203,8 +215,7 @@ abstract class IntPipeline
@Override
public final DoubleStream asDoubleStream() {
- return new DoublePipeline.StatelessOp(this, StreamShape.INT_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
+ return new DoublePipeline.StatelessOp(this, StreamShape.INT_VALUE, 0) {
@Override
Sink opWrapSink(int flags, Sink sink) {
return new Sink.ChainedInt(sink) {
@@ -219,7 +230,7 @@ abstract class IntPipeline
@Override
public final Stream boxed() {
- return mapToObj(Integer::valueOf);
+ return mapToObj(Integer::valueOf, 0);
}
@Override
@@ -242,18 +253,7 @@ abstract class IntPipeline
@Override
public final Stream mapToObj(IntFunction extends U> mapper) {
Objects.requireNonNull(mapper);
- return new ReferencePipeline.StatelessOp(this, StreamShape.INT_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
- @Override
- Sink opWrapSink(int flags, Sink sink) {
- return new Sink.ChainedInt(sink) {
- @Override
- public void accept(int t) {
- downstream.accept(mapper.apply(t));
- }
- };
- }
- };
+ return mapToObj(mapper, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT);
}
@Override
diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java b/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java
index 19097b7e630..0d70b9707ca 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/LongPipeline.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -167,6 +167,19 @@ abstract class LongPipeline
return Nodes.longBuilder(exactSizeIfKnown);
}
+ private Stream mapToObj(LongFunction extends U> mapper, int opFlags) {
+ return new ReferencePipeline.StatelessOp(this, StreamShape.LONG_VALUE, opFlags) {
+ @Override
+ Sink opWrapSink(int flags, Sink sink) {
+ return new Sink.ChainedLong(sink) {
+ @Override
+ public void accept(long t) {
+ downstream.accept(mapper.apply(t));
+ }
+ };
+ }
+ };
+ }
// LongStream
@@ -184,8 +197,7 @@ abstract class LongPipeline
@Override
public final DoubleStream asDoubleStream() {
- return new DoublePipeline.StatelessOp(this, StreamShape.LONG_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
+ return new DoublePipeline.StatelessOp(this, StreamShape.LONG_VALUE, StreamOpFlag.NOT_DISTINCT) {
@Override
Sink opWrapSink(int flags, Sink sink) {
return new Sink.ChainedLong(sink) {
@@ -200,7 +212,7 @@ abstract class LongPipeline
@Override
public final Stream boxed() {
- return mapToObj(Long::valueOf);
+ return mapToObj(Long::valueOf, 0);
}
@Override
@@ -223,18 +235,7 @@ abstract class LongPipeline
@Override
public final Stream mapToObj(LongFunction extends U> mapper) {
Objects.requireNonNull(mapper);
- return new ReferencePipeline.StatelessOp(this, StreamShape.LONG_VALUE,
- StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
- @Override
- Sink opWrapSink(int flags, Sink sink) {
- return new Sink.ChainedLong(sink) {
- @Override
- public void accept(long t) {
- downstream.accept(mapper.apply(t));
- }
- };
- }
- };
+ return mapToObj(mapper, StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT);
}
@Override
diff --git a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
index 7e8d81150a8..cb92b2ebfad 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java
@@ -28,6 +28,7 @@ import java.util.Comparator;
import java.util.Objects;
import java.util.Spliterator;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
@@ -905,6 +906,7 @@ class StreamSpliterators {
// The spliterator to slice
protected final T_SPLITR s;
protected final boolean unlimited;
+ protected final int chunkSize;
private final long skipThreshold;
private final AtomicLong permits;
@@ -912,6 +914,8 @@ class StreamSpliterators {
this.s = s;
this.unlimited = limit < 0;
this.skipThreshold = limit >= 0 ? limit : 0;
+ this.chunkSize = limit >= 0 ? (int)Math.min(CHUNK_SIZE,
+ ((skip + limit) / AbstractTask.LEAF_TARGET) + 1) : CHUNK_SIZE;
this.permits = new AtomicLong(limit >= 0 ? skip + limit : skip);
}
@@ -921,6 +925,7 @@ class StreamSpliterators {
this.unlimited = parent.unlimited;
this.permits = parent.permits;
this.skipThreshold = parent.skipThreshold;
+ this.chunkSize = parent.chunkSize;
}
/**
@@ -1029,13 +1034,13 @@ class StreamSpliterators {
PermitStatus permitStatus;
while ((permitStatus = permitStatus()) != PermitStatus.NO_MORE) {
if (permitStatus == PermitStatus.MAYBE_MORE) {
- // Optimistically traverse elements up to a threshold of CHUNK_SIZE
+ // Optimistically traverse elements up to a threshold of chunkSize
if (sb == null)
- sb = new ArrayBuffer.OfRef<>(CHUNK_SIZE);
+ sb = new ArrayBuffer.OfRef<>(chunkSize);
else
sb.reset();
long permitsRequested = 0;
- do { } while (s.tryAdvance(sb) && ++permitsRequested < CHUNK_SIZE);
+ do { } while (s.tryAdvance(sb) && ++permitsRequested < chunkSize);
if (permitsRequested == 0)
return;
sb.forEach(action, acquirePermits(permitsRequested));
@@ -1102,15 +1107,15 @@ class StreamSpliterators {
PermitStatus permitStatus;
while ((permitStatus = permitStatus()) != PermitStatus.NO_MORE) {
if (permitStatus == PermitStatus.MAYBE_MORE) {
- // Optimistically traverse elements up to a threshold of CHUNK_SIZE
+ // Optimistically traverse elements up to a threshold of chunkSize
if (sb == null)
- sb = bufferCreate(CHUNK_SIZE);
+ sb = bufferCreate(chunkSize);
else
sb.reset();
@SuppressWarnings("unchecked")
T_CONS sbc = (T_CONS) sb;
long permitsRequested = 0;
- do { } while (s.tryAdvance(sbc) && ++permitsRequested < CHUNK_SIZE);
+ do { } while (s.tryAdvance(sbc) && ++permitsRequested < chunkSize);
if (permitsRequested == 0)
return;
sb.forEach(action, acquirePermits(permitsRequested));
diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
index da255a3e2b8..e24fcad2bd4 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/DefaultLoggerFinder.java
@@ -33,6 +33,9 @@ import java.util.function.Function;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.ref.ReferenceQueue;
+import java.lang.reflect.Module;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.ResourceBundle;
@@ -129,41 +132,49 @@ public class DefaultLoggerFinder extends LoggerFinder {
return w;
}
-
final static SharedLoggers system = new SharedLoggers();
final static SharedLoggers application = new SharedLoggers();
}
+ public static boolean isSystem(Module m) {
+ ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<>() {
+ @Override
+ public ClassLoader run() {
+ return m.getClassLoader();
+ }
+ });
+ return cl == null;
+ }
+
@Override
- public final Logger getLogger(String name, /* Module */ Class> caller) {
+ public final Logger getLogger(String name, Module module) {
checkPermission();
- return demandLoggerFor(name, caller);
+ return demandLoggerFor(name, module);
}
@Override
public final Logger getLocalizedLogger(String name, ResourceBundle bundle,
- /* Module */ Class> caller) {
- return super.getLocalizedLogger(name, bundle, caller);
+ Module module) {
+ return super.getLocalizedLogger(name, bundle, module);
}
-
-
/**
- * Returns a {@link Logger logger} suitable for the caller usage.
+ * Returns a {@link Logger logger} suitable for use within the
+ * given {@code module}.
*
* @implSpec The default implementation for this method is to return a
* simple logger that will print all messages of INFO level and above
* to the console. That simple logger is not configurable.
*
* @param name The name of the logger.
- * @param caller The class on behalf of which the logger is created.
+ * @param module The module on behalf of which the logger is created.
* @return A {@link Logger logger} suitable for the application usage.
* @throws SecurityException if the calling code does not have the
* {@code RuntimePermission("loggerFinder")}.
*/
- protected Logger demandLoggerFor(String name, /* Module */ Class> caller) {
+ protected Logger demandLoggerFor(String name, Module module) {
checkPermission();
- if (caller.getClassLoader() == null) {
+ if (isSystem(module)) {
return SharedLoggers.system.get(SimpleConsoleLogger::makeSimpleLogger, name);
} else {
return SharedLoggers.application.get(SimpleConsoleLogger::makeSimpleLogger, name);
diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
index 04b64ea98b1..6c65426ca8e 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java
@@ -31,6 +31,7 @@ import java.util.function.BiFunction;
import java.lang.System.LoggerFinder;
import java.lang.System.Logger;
import java.lang.ref.WeakReference;
+import java.lang.reflect.Module;
import java.util.Objects;
import jdk.internal.misc.VM;
import sun.util.logging.PlatformLogger;
@@ -59,15 +60,15 @@ public final class LazyLoggers {
* A factory method to create an SPI logger.
* Usually, this will be something like LazyLoggers::getSystemLogger.
*/
- final BiFunction, L> loggerSupplier;
+ final BiFunction loggerSupplier;
- public LazyLoggerFactories(BiFunction, L> loggerSupplier) {
+ public LazyLoggerFactories(BiFunction loggerSupplier) {
this(Objects.requireNonNull(loggerSupplier),
(Void)null);
}
- private LazyLoggerFactories(BiFunction, L> loggerSupplier,
+ private LazyLoggerFactories(BiFunction loggerSupplier,
Void unused) {
this.loggerSupplier = loggerSupplier;
}
@@ -107,8 +108,8 @@ public final class LazyLoggers {
// The factories that will be used to create the logger lazyly
final LazyLoggerFactories extends Logger> factories;
- // We need to pass the actual caller when creating the logger.
- private final WeakReference> callerRef;
+ // We need to pass the actual caller module when creating the logger.
+ private final WeakReference moduleRef;
// The name of the logger that will be created lazyly
final String name;
@@ -121,17 +122,17 @@ public final class LazyLoggers {
private LazyLoggerAccessor(String name,
LazyLoggerFactories extends Logger> factories,
- Class> caller) {
+ Module module) {
this(Objects.requireNonNull(name), Objects.requireNonNull(factories),
- Objects.requireNonNull(caller), null);
+ Objects.requireNonNull(module), null);
}
private LazyLoggerAccessor(String name,
LazyLoggerFactories extends Logger> factories,
- Class> caller, Void unused) {
+ Module module, Void unused) {
this.name = name;
this.factories = factories;
- this.callerRef = new WeakReference>(caller);
+ this.moduleRef = new WeakReference<>(module);
}
/**
@@ -270,12 +271,12 @@ public final class LazyLoggers {
// Creates the wrapped logger by invoking the SPI.
Logger createLogger() {
- final Class> caller = callerRef.get();
- if (caller == null) {
- throw new IllegalStateException("The class for which this logger"
+ final Module module = moduleRef.get();
+ if (module == null) {
+ throw new IllegalStateException("The module for which this logger"
+ " was created has been garbage collected");
}
- return this.factories.loggerSupplier.apply(name, caller);
+ return this.factories.loggerSupplier.apply(name, module);
}
/**
@@ -289,8 +290,8 @@ public final class LazyLoggers {
* @return A new LazyLoggerAccessor.
*/
public static LazyLoggerAccessor makeAccessor(String name,
- LazyLoggerFactories extends Logger> factories, Class> caller) {
- return new LazyLoggerAccessor(name, factories, caller);
+ LazyLoggerFactories extends Logger> factories, Module module) {
+ return new LazyLoggerAccessor(name, factories, module);
}
}
@@ -346,11 +347,11 @@ public final class LazyLoggers {
// Avoid using lambda here as lazy loggers could be created early
// in the bootstrap sequence...
- private static final BiFunction, Logger> loggerSupplier =
+ private static final BiFunction loggerSupplier =
new BiFunction<>() {
@Override
- public Logger apply(String name, Class> caller) {
- return LazyLoggers.getLoggerFromFinder(name, caller);
+ public Logger apply(String name, Module module) {
+ return LazyLoggers.getLoggerFromFinder(name, module);
}
};
@@ -367,8 +368,8 @@ public final class LazyLoggers {
// logger provider until the VM has finished booting.
//
private static final class JdkLazyLogger extends LazyLoggerWrapper {
- JdkLazyLogger(String name, Class> caller) {
- this(LazyLoggerAccessor.makeAccessor(name, factories, caller),
+ JdkLazyLogger(String name, Module module) {
+ this(LazyLoggerAccessor.makeAccessor(name, factories, module),
(Void)null);
}
private JdkLazyLogger(LazyLoggerAccessor holder, Void unused) {
@@ -380,16 +381,16 @@ public final class LazyLoggers {
* Gets a logger from the LoggerFinder. Creates the actual concrete
* logger.
* @param name name of the logger
- * @param caller class on behalf of which the logger is created
+ * @param module module on behalf of which the logger is created
* @return The logger returned by the LoggerFinder.
*/
- static Logger getLoggerFromFinder(String name, Class> caller) {
+ static Logger getLoggerFromFinder(String name, Module module) {
final SecurityManager sm = System.getSecurityManager();
if (sm == null) {
- return accessLoggerFinder().getLogger(name, caller);
+ return accessLoggerFinder().getLogger(name, module);
} else {
return AccessController.doPrivileged((PrivilegedAction)
- () -> {return accessLoggerFinder().getLogger(name, caller);},
+ () -> {return accessLoggerFinder().getLogger(name, module);},
null, LOGGERFINDER_PERMISSION);
}
}
@@ -398,22 +399,22 @@ public final class LazyLoggers {
* Returns a (possibly lazy) Logger for the caller.
*
* @param name the logger name
- * @param caller The class on behalf of which the logger is created.
- * If the caller is not loaded from the Boot ClassLoader,
+ * @param module The module on behalf of which the logger is created.
+ * If the module is not loaded from the Boot ClassLoader,
* the LoggerFinder is accessed and the logger returned
- * by {@link LoggerFinder#getLogger(java.lang.String, java.lang.Class)}
+ * by {@link LoggerFinder#getLogger(java.lang.String, java.lang.reflect.Module)}
* is returned to the caller directly.
* Otherwise, the logger returned by
- * {@link #getLazyLogger(java.lang.String, java.lang.Class)}
+ * {@link #getLazyLogger(java.lang.String, java.lang.reflect.Module)}
* is returned to the caller.
*
* @return a (possibly lazy) Logger instance.
*/
- public static final Logger getLogger(String name, Class> caller) {
- if (caller.getClassLoader() == null) {
- return getLazyLogger(name, caller);
+ public static final Logger getLogger(String name, Module module) {
+ if (DefaultLoggerFinder.isSystem(module)) {
+ return getLazyLogger(name, module);
} else {
- return getLoggerFromFinder(name, caller);
+ return getLoggerFromFinder(name, module);
}
}
@@ -423,10 +424,10 @@ public final class LazyLoggers {
* returned by {@link BootstrapLogger#useLazyLoggers()}.
*
* @param name the logger name
- * @param caller the class on behalf of which the logger is created.
+ * @param module the module on behalf of which the logger is created.
* @return a (possibly lazy) Logger instance.
*/
- public static final Logger getLazyLogger(String name, Class> caller) {
+ public static final Logger getLazyLogger(String name, Module module) {
// BootstrapLogger has the logic to determine whether a LazyLogger
// should be used. Usually, it is worth it only if:
@@ -438,10 +439,10 @@ public final class LazyLoggers {
// configuration, we're not going to delay the creation of loggers...
final boolean useLazyLogger = BootstrapLogger.useLazyLoggers();
if (useLazyLogger) {
- return new JdkLazyLogger(name, caller);
+ return new JdkLazyLogger(name, module);
} else {
// Directly invoke the LoggerFinder.
- return getLoggerFromFinder(name, caller);
+ return getLoggerFromFinder(name, module);
}
}
diff --git a/jdk/src/java.base/share/classes/jdk/net/ExtendedSocketOptions.java b/jdk/src/java.base/share/classes/jdk/net/ExtendedSocketOptions.java
deleted file mode 100644
index 12af5aff7ee..00000000000
--- a/jdk/src/java.base/share/classes/jdk/net/ExtendedSocketOptions.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.net;
-
-import java.net.SocketOption;
-
-/**
- * Defines extended socket options, beyond those defined in
- * {@link java.net.StandardSocketOptions}. These options may be platform
- * specific.
- *
- * @since 1.8
- */
-public final class ExtendedSocketOptions {
-
- private static class ExtSocketOption implements SocketOption {
- private final String name;
- private final Class type;
- ExtSocketOption(String name, Class type) {
- this.name = name;
- this.type = type;
- }
- @Override public String name() { return name; }
- @Override public Class type() { return type; }
- @Override public String toString() { return name; }
- }
-
- private ExtendedSocketOptions() {}
-
- /**
- * Service level properties. When a security manager is installed,
- * setting or getting this option requires a {@link NetworkPermission}
- * {@code ("setOption.SO_FLOW_SLA")} or {@code "getOption.SO_FLOW_SLA"}
- * respectively.
- */
- public static final SocketOption SO_FLOW_SLA = new
- ExtSocketOption("SO_FLOW_SLA", SocketFlow.class);
-}
diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java
index 942c0582ea0..a597253d168 100644
--- a/jdk/src/java.base/share/classes/module-info.java
+++ b/jdk/src/java.base/share/classes/module-info.java
@@ -83,8 +83,6 @@ module java.base {
// see JDK-8144062
exports jdk;
- // see JDK-8044773
- exports jdk.net;
// the service types defined by the APIs in this module
@@ -168,6 +166,7 @@ module java.base {
java.sql,
java.xml,
jdk.charsets,
+ jdk.net,
jdk.scripting.nashorn,
jdk.unsupported,
jdk.vm.ci;
@@ -194,6 +193,8 @@ module java.base {
jdk.jvmstat;
exports sun.net to
java.httpclient;
+ exports sun.net.ext to
+ jdk.net;
exports sun.net.dns to
java.security.jgss,
jdk.naming.dns;
diff --git a/jdk/src/java.base/share/classes/sun/net/ExtendedOptionsImpl.java b/jdk/src/java.base/share/classes/sun/net/ExtendedOptionsImpl.java
deleted file mode 100644
index 8fbcdd7b49d..00000000000
--- a/jdk/src/java.base/share/classes/sun/net/ExtendedOptionsImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.net;
-
-import java.net.*;
-import jdk.net.*;
-import java.io.IOException;
-import java.io.FileDescriptor;
-import java.security.PrivilegedAction;
-import java.security.AccessController;
-import java.lang.reflect.Field;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Collections;
-
-/**
- * Contains the native implementation for extended socket options
- * together with some other static utilities
- */
-public class ExtendedOptionsImpl {
-
- static {
- AccessController.doPrivileged((PrivilegedAction)() -> {
- System.loadLibrary("net");
- return null;
- });
- init();
- }
-
- private ExtendedOptionsImpl() {}
-
- public static void checkSetOptionPermission(SocketOption> option) {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null) {
- return;
- }
- String check = "setOption." + option.name();
- sm.checkPermission(new NetworkPermission(check));
- }
-
- public static void checkGetOptionPermission(SocketOption> option) {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null) {
- return;
- }
- String check = "getOption." + option.name();
- sm.checkPermission(new NetworkPermission(check));
- }
-
- public static void checkValueType(Object value, Class> type) {
- if (!type.isAssignableFrom(value.getClass())) {
- String s = "Found: " + value.getClass().toString() + " Expected: "
- + type.toString();
- throw new IllegalArgumentException(s);
- }
- }
-
- private static native void init();
-
- /*
- * Extension native implementations
- *
- * SO_FLOW_SLA
- */
- public static native void setFlowOption(FileDescriptor fd, SocketFlow f);
- public static native void getFlowOption(FileDescriptor fd, SocketFlow f);
- public static native boolean flowSupported();
-}
diff --git a/jdk/src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java b/jdk/src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java
new file mode 100644
index 00000000000..a3300c3c0e9
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/net/ext/ExtendedSocketOptions.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.net.ext;
+
+import java.io.FileDescriptor;
+import java.net.SocketException;
+import java.net.SocketOption;
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * Defines the infrastructure to support extended socket options, beyond those
+ * defined in {@link java.net.StandardSocketOptions}.
+ *
+ * Extended socket options are accessed through the jdk.net API, which is in
+ * the jdk.net module.
+ */
+public abstract class ExtendedSocketOptions {
+
+ private final Set> options;
+
+ /** Tells whether or not the option is supported. */
+ public final boolean isOptionSupported(SocketOption> option) {
+ return options().contains(option);
+ }
+
+ /** Return the, possibly empty, set of extended socket options available. */
+ public final Set> options() { return options; }
+
+ /** Sets the value of a socket option, for the given socket. */
+ public abstract void setOption(FileDescriptor fd, SocketOption> option, Object value)
+ throws SocketException;
+
+ /** Returns the value of a socket option, for the given socket. */
+ public abstract Object getOption(FileDescriptor fd, SocketOption> option)
+ throws SocketException;
+
+ protected ExtendedSocketOptions(Set> options) {
+ this.options = options;
+ }
+
+ private static volatile ExtendedSocketOptions instance;
+
+ public static final ExtendedSocketOptions getInstance() { return instance; }
+
+ /** Registers support for extended socket options. Invoked by the jdk.net module. */
+ public static final void register(ExtendedSocketOptions extOptions) {
+ if (instance != null)
+ throw new InternalError("Attempting to reregister extended options");
+
+ instance = extOptions;
+ }
+
+ static {
+ try {
+ // If the class is present, it will be initialized which
+ // triggers registration of the extended socket options.
+ Class> c = Class.forName("jdk.net.ExtendedSocketOptions");
+ } catch (ClassNotFoundException e) {
+ // the jdk.net module is not present => no extended socket options
+ instance = new NoExtendedSocketOptions();
+ }
+ }
+
+ static final class NoExtendedSocketOptions extends ExtendedSocketOptions {
+
+ NoExtendedSocketOptions() {
+ super(Collections.>emptySet());
+ }
+
+ @Override
+ public void setOption(FileDescriptor fd, SocketOption> option, Object value)
+ throws SocketException
+ {
+ throw new UnsupportedOperationException(
+ "no extended options: " + option.name());
+ }
+
+ @Override
+ public Object getOption(FileDescriptor fd, SocketOption> option)
+ throws SocketException
+ {
+ throw new UnsupportedOperationException(
+ "no extended options: " + option.name());
+ }
+ }
+}
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java
index 6f1f8e86f04..81fa9836a87 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
-import sun.misc.*;
/**
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java
index 36b3c1b7ab9..1faf49b8578 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/AsynchronousSocketChannelImpl.java
@@ -39,7 +39,7 @@ import java.util.Collections;
import java.util.concurrent.*;
import java.util.concurrent.locks.*;
import sun.net.NetHooks;
-import sun.net.ExtendedOptionsImpl;
+import sun.net.ext.ExtendedSocketOptions;
/**
* Base implementation of AsynchronousSocketChannel
@@ -512,9 +512,9 @@ abstract class AsynchronousSocketChannelImpl
set.add(StandardSocketOptions.SO_REUSEPORT);
}
set.add(StandardSocketOptions.TCP_NODELAY);
- if (ExtendedOptionsImpl.flowSupported()) {
- set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
- }
+ ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+ set.addAll(extendedOptions.options());
return Collections.unmodifiableSet(set);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
index 77d14619222..f063e13ac13 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/DatagramChannelImpl.java
@@ -33,7 +33,7 @@ import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
import sun.net.ResourceManager;
-import sun.net.ExtendedOptionsImpl;
+import sun.net.ext.ExtendedSocketOptions;
/**
* An implementation of DatagramChannels.
@@ -306,9 +306,9 @@ class DatagramChannelImpl
set.add(StandardSocketOptions.IP_MULTICAST_IF);
set.add(StandardSocketOptions.IP_MULTICAST_TTL);
set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
- if (ExtendedOptionsImpl.flowSupported()) {
- set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
- }
+ ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+ set.addAll(extendedOptions.options());
return Collections.unmodifiableSet(set);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/Net.java b/jdk/src/java.base/share/classes/sun/nio/ch/Net.java
index 9a5c4dcb6f8..59d3167745b 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/Net.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/Net.java
@@ -27,15 +27,13 @@ package sun.nio.ch;
import java.io.*;
import java.net.*;
-import jdk.net.*;
import java.nio.channels.*;
import java.util.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import sun.net.ExtendedOptionsImpl;
+import sun.net.ext.ExtendedSocketOptions;
import sun.security.action.GetPropertyAction;
-
public class Net {
private Net() { }
@@ -281,6 +279,9 @@ public class Net {
// -- Socket options
+ static final ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+
static void setSocketOption(FileDescriptor fd, ProtocolFamily family,
SocketOption> name, Object value)
throws IOException
@@ -291,12 +292,8 @@ public class Net {
// only simple values supported by this method
Class> type = name.type();
- if (type == SocketFlow.class) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new NetworkPermission("setOption.SO_FLOW_SLA"));
- }
- ExtendedOptionsImpl.setFlowOption(fd, (SocketFlow)value);
+ if (extendedOptions.isOptionSupported(name)) {
+ extendedOptions.setOption(fd, name, value);
return;
}
@@ -353,14 +350,8 @@ public class Net {
{
Class> type = name.type();
- if (type == SocketFlow.class) {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- sm.checkPermission(new NetworkPermission("getOption.SO_FLOW_SLA"));
- }
- SocketFlow flow = SocketFlow.create();
- ExtendedOptionsImpl.getFlowOption(fd, flow);
- return flow;
+ if (extendedOptions.isOptionSupported(name)) {
+ return extendedOptions.getOption(fd, name);
}
// only simple values supported by this method
diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
index c4644920c3e..856e0cf2fb6 100644
--- a/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
+++ b/jdk/src/java.base/share/classes/sun/nio/ch/SocketChannelImpl.java
@@ -33,8 +33,7 @@ import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
import sun.net.NetHooks;
-import sun.net.ExtendedOptionsImpl;
-
+import sun.net.ext.ExtendedSocketOptions;
/**
* An implementation of SocketChannels
@@ -242,9 +241,9 @@ class SocketChannelImpl
// additional options required by socket adaptor
set.add(StandardSocketOptions.IP_TOS);
set.add(ExtendedSocketOption.SO_OOBINLINE);
- if (ExtendedOptionsImpl.flowSupported()) {
- set.add(jdk.net.ExtendedSocketOptions.SO_FLOW_SLA);
- }
+ ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+ set.addAll(extendedOptions.options());
return Collections.unmodifiableSet(set);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/security/action/GetBooleanSecurityPropertyAction.java b/jdk/src/java.base/share/classes/sun/security/action/GetBooleanSecurityPropertyAction.java
deleted file mode 100644
index 9b180f1bdfd..00000000000
--- a/jdk/src/java.base/share/classes/sun/security/action/GetBooleanSecurityPropertyAction.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.action;
-
-import java.security.Security;
-
-/**
- * A convenience class for retrieving the boolean value of a security property
- * as a privileged action.
- *
- * An instance of this class can be used as the argument of
- * AccessController.doPrivileged
.
- *
- *
The following code retrieves the boolean value of the security
- * property named "prop"
as a privileged action:
- *
- *
- * boolean b = java.security.AccessController.doPrivileged
- * (new GetBooleanSecurityPropertyAction("prop")).booleanValue();
- *
- *
- */
-public class GetBooleanSecurityPropertyAction
- implements java.security.PrivilegedAction {
- private String theProp;
-
- /**
- * Constructor that takes the name of the security property whose boolean
- * value needs to be determined.
- *
- * @param theProp the name of the security property
- */
- public GetBooleanSecurityPropertyAction(String theProp) {
- this.theProp = theProp;
- }
-
- /**
- * Determines the boolean value of the security property whose name was
- * specified in the constructor.
- *
- * @return the Boolean
value of the security property.
- */
- public Boolean run() {
- boolean b = false;
- try {
- String value = Security.getProperty(theProp);
- b = (value != null) && value.equalsIgnoreCase("true");
- } catch (NullPointerException e) {}
- return b;
- }
-}
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
index b71121423d8..b210d18e073 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AlgorithmChecker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,12 +31,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.EnumSet;
-import java.util.HashSet;
import java.math.BigInteger;
import java.security.PublicKey;
import java.security.KeyFactory;
import java.security.AlgorithmParameters;
-import java.security.NoSuchAlgorithmException;
import java.security.GeneralSecurityException;
import java.security.cert.Certificate;
import java.security.cert.X509CRL;
@@ -48,10 +46,13 @@ import java.security.cert.CertificateException;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CertPathValidatorException.BasicReason;
import java.security.cert.PKIXReason;
-import java.io.IOException;
-import java.security.interfaces.*;
-import java.security.spec.*;
+import java.security.interfaces.DSAParams;
+import java.security.interfaces.DSAPublicKey;
+import java.security.spec.DSAPublicKeySpec;
+import sun.security.util.AnchorCertificates;
+import sun.security.util.CertConstraintParameters;
+import sun.security.util.Debug;
import sun.security.util.DisabledAlgorithmConstraints;
import sun.security.x509.X509CertImpl;
import sun.security.x509.X509CRLImpl;
@@ -69,6 +70,7 @@ import sun.security.x509.AlgorithmId;
* @see PKIXParameters
*/
public final class AlgorithmChecker extends PKIXCertPathChecker {
+ private static final Debug debug = Debug.getInstance("certpath");
private final AlgorithmConstraints constraints;
private final PublicKey trustedPubKey;
@@ -88,6 +90,14 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
certPathDefaultConstraints = new DisabledAlgorithmConstraints(
DisabledAlgorithmConstraints.PROPERTY_CERTPATH_DISABLED_ALGS);
+ // If there is no "cacerts" keyword, then disable anchor checking
+ private static final boolean publicCALimits =
+ certPathDefaultConstraints.checkProperty("jdkCA");
+
+ // If anchor checking enabled, this will be true if the trust anchor
+ // has a match in the cacerts file
+ private boolean trustedMatch = false;
+
/**
* Create a new AlgorithmChecker
with the algorithm
* constraints specified in security property
@@ -136,6 +146,11 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
if (anchor.getTrustedCert() != null) {
this.trustedPubKey = anchor.getTrustedCert().getPublicKey();
+ // Check for anchor certificate restrictions
+ trustedMatch = checkFingerprint(anchor.getTrustedCert());
+ if (trustedMatch && debug != null) {
+ debug.println("trustedMatch = true");
+ }
} else {
this.trustedPubKey = anchor.getCAPublicKey();
}
@@ -144,6 +159,19 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
this.constraints = constraints;
}
+ // Check this 'cert' for restrictions in the AnchorCertificates
+ // trusted certificates list
+ private static boolean checkFingerprint(X509Certificate cert) {
+ if (!publicCALimits) {
+ return false;
+ }
+
+ if (debug != null) {
+ debug.println("AlgorithmChecker.contains: " + cert.getSigAlgName());
+ }
+ return AnchorCertificates.contains(cert);
+ }
+
@Override
public void init(boolean forward) throws CertPathValidatorException {
// Note that this class does not support forward mode.
@@ -181,36 +209,8 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
return;
}
- X509CertImpl x509Cert = null;
- try {
- x509Cert = X509CertImpl.toImpl((X509Certificate)cert);
- } catch (CertificateException ce) {
- throw new CertPathValidatorException(ce);
- }
-
- PublicKey currPubKey = x509Cert.getPublicKey();
- String currSigAlg = x509Cert.getSigAlgName();
-
- AlgorithmId algorithmId = null;
- try {
- algorithmId = (AlgorithmId)x509Cert.get(X509CertImpl.SIG_ALG);
- } catch (CertificateException ce) {
- throw new CertPathValidatorException(ce);
- }
-
- AlgorithmParameters currSigAlgParams = algorithmId.getParameters();
-
- // Check the current signature algorithm
- if (!constraints.permits(
- SIGNATURE_PRIMITIVE_SET,
- currSigAlg, currSigAlgParams)) {
- throw new CertPathValidatorException(
- "Algorithm constraints check failed: " + currSigAlg,
- null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
- }
-
// check the key usage and key size
- boolean[] keyUsage = x509Cert.getKeyUsage();
+ boolean[] keyUsage = ((X509Certificate) cert).getKeyUsage();
if (keyUsage != null && keyUsage.length < 9) {
throw new CertPathValidatorException(
"incorrect KeyUsage extension",
@@ -248,27 +248,67 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
if (primitives.isEmpty()) {
throw new CertPathValidatorException(
- "incorrect KeyUsage extension",
+ "incorrect KeyUsage extension bits",
null, null, -1, PKIXReason.INVALID_KEY_USAGE);
}
}
- if (!constraints.permits(primitives, currPubKey)) {
- throw new CertPathValidatorException(
- "algorithm constraints check failed",
- null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ PublicKey currPubKey = cert.getPublicKey();
+
+ // Check against DisabledAlgorithmConstraints certpath constraints.
+ // permits() will throw exception on failure.
+ certPathDefaultConstraints.permits(primitives,
+ new CertConstraintParameters((X509Certificate)cert,
+ trustedMatch));
+ // new CertConstraintParameters(x509Cert, trustedMatch));
+ // If there is no previous key, set one and exit
+ if (prevPubKey == null) {
+ prevPubKey = currPubKey;
+ return;
+ }
+
+ X509CertImpl x509Cert;
+ AlgorithmId algorithmId;
+ try {
+ x509Cert = X509CertImpl.toImpl((X509Certificate)cert);
+ algorithmId = (AlgorithmId)x509Cert.get(X509CertImpl.SIG_ALG);
+ } catch (CertificateException ce) {
+ throw new CertPathValidatorException(ce);
+ }
+
+ AlgorithmParameters currSigAlgParams = algorithmId.getParameters();
+ String currSigAlg = x509Cert.getSigAlgName();
+
+ // If 'constraints' is not of DisabledAlgorithmConstraints, check all
+ // everything individually
+ if (!(constraints instanceof DisabledAlgorithmConstraints)) {
+ // Check the current signature algorithm
+ if (!constraints.permits(
+ SIGNATURE_PRIMITIVE_SET,
+ currSigAlg, currSigAlgParams)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on signature " +
+ "algorithm: " + currSigAlg, null, null, -1,
+ BasicReason.ALGORITHM_CONSTRAINED);
+ }
+
+ if (!constraints.permits(primitives, currPubKey)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on keysize: " +
+ sun.security.util.KeyUtil.getKeySize(currPubKey),
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
}
// Check with previous cert for signature algorithm and public key
if (prevPubKey != null) {
- if (currSigAlg != null) {
- if (!constraints.permits(
- SIGNATURE_PRIMITIVE_SET,
- currSigAlg, prevPubKey, currSigAlgParams)) {
- throw new CertPathValidatorException(
- "Algorithm constraints check failed: " + currSigAlg,
- null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
- }
+ if (!constraints.permits(
+ SIGNATURE_PRIMITIVE_SET,
+ currSigAlg, prevPubKey, currSigAlgParams)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on " +
+ "signature algorithm: " + currSigAlg,
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
// Inherit key parameters from previous key
@@ -282,7 +322,7 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
DSAParams params = ((DSAPublicKey)prevPubKey).getParams();
if (params == null) {
throw new CertPathValidatorException(
- "Key parameters missing");
+ "Key parameters missing from public key.");
}
try {
@@ -330,6 +370,11 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
// Don't bother to change the trustedPubKey.
if (anchor.getTrustedCert() != null) {
prevPubKey = anchor.getTrustedCert().getPublicKey();
+ // Check for anchor certificate restrictions
+ trustedMatch = checkFingerprint(anchor.getTrustedCert());
+ if (trustedMatch && debug != null) {
+ debug.println("trustedMatch = true");
+ }
} else {
prevPubKey = anchor.getCAPublicKey();
}
@@ -370,7 +415,8 @@ public final class AlgorithmChecker extends PKIXCertPathChecker {
if (!certPathDefaultConstraints.permits(
SIGNATURE_PRIMITIVE_SET, sigAlgName, key, sigAlgParams)) {
throw new CertPathValidatorException(
- "algorithm check failed: " + sigAlgName + " is disabled",
+ "Algorithm constraints check failed on signature algorithm: " +
+ sigAlgName + " is disabled",
null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
}
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
index cfffba8329a..e85ef2d0303 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXMasterCertPathValidator.java
@@ -131,8 +131,8 @@ class PKIXMasterCertPathValidator {
} catch (CertPathValidatorException cpve) {
throw new CertPathValidatorException(cpve.getMessage(),
- cpve.getCause(), cpOriginal, cpSize - (i + 1),
- cpve.getReason());
+ (cpve.getCause() != null) ? cpve.getCause() : cpve,
+ cpOriginal, cpSize - (i + 1), cpve.getReason());
}
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java b/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
index 94670e40324..2825e14254f 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@ import java.security.AccessController;
import java.security.AlgorithmConstraints;
import java.security.PrivilegedAction;
import java.security.Security;
-import java.util.Map;
import java.util.Set;
/**
@@ -45,8 +44,7 @@ public abstract class AbstractAlgorithmConstraints
}
// Get algorithm constraints from the specified security property.
- private static void loadAlgorithmsMap(Map algorithmsMap,
- String propertyName) {
+ static String[] getAlgorithms(String propertyName) {
String property = AccessController.doPrivileged(
(PrivilegedAction) () -> Security.getProperty(
propertyName));
@@ -68,18 +66,7 @@ public abstract class AbstractAlgorithmConstraints
if (algorithmsInProperty == null) {
algorithmsInProperty = new String[0];
}
- algorithmsMap.put(propertyName, algorithmsInProperty);
- }
-
- static String[] getAlgorithms(Map algorithmsMap,
- String propertyName) {
- synchronized (algorithmsMap) {
- if (!algorithmsMap.containsKey(propertyName)) {
- loadAlgorithmsMap(algorithmsMap, propertyName);
- }
-
- return algorithmsMap.get(propertyName);
- }
+ return algorithmsInProperty;
}
static boolean checkAlgorithm(String[] algorithms, String algorithm,
diff --git a/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java b/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java
index 4410a3102be..bff76cf1721 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,19 +40,7 @@ public class AlgorithmDecomposer {
private static final Pattern pattern =
Pattern.compile("with|and|(?
- * For example, we need to decompose "SHA1WithRSA" into "SHA1" and "RSA"
- * so that we can check the "SHA1" and "RSA" algorithm constraints
- * separately.
- *
- * Please override the method if need to support more name pattern.
- */
- public Set decompose(String algorithm) {
- if (algorithm == null || algorithm.length() == 0) {
- return new HashSet<>();
- }
+ private static Set decomposeImpl(String algorithm) {
// algorithm/mode/padding
String[] transTockens = transPattern.split(algorithm);
@@ -79,6 +67,24 @@ public class AlgorithmDecomposer {
elements.add(token);
}
}
+ return elements;
+ }
+
+ /**
+ * Decompose the standard algorithm name into sub-elements.
+ *
+ * For example, we need to decompose "SHA1WithRSA" into "SHA1" and "RSA"
+ * so that we can check the "SHA1" and "RSA" algorithm constraints
+ * separately.
+ *
+ * Please override the method if need to support more name pattern.
+ */
+ public Set decompose(String algorithm) {
+ if (algorithm == null || algorithm.length() == 0) {
+ return new HashSet<>();
+ }
+
+ Set elements = decomposeImpl(algorithm);
// In Java standard algorithm name specification, for different
// purpose, the SHA-1 and SHA-2 algorithm names are different. For
@@ -130,4 +136,40 @@ public class AlgorithmDecomposer {
return elements;
}
+ private static void hasLoop(Set elements, String find, String replace) {
+ if (elements.contains(find)) {
+ if (!elements.contains(replace)) {
+ elements.add(replace);
+ }
+ elements.remove(find);
+ }
+ }
+
+ /*
+ * This decomposes a standard name into sub-elements with a consistent
+ * message digest algorithm name to avoid overly complicated checking.
+ */
+ public static Set decomposeOneHash(String algorithm) {
+ if (algorithm == null || algorithm.length() == 0) {
+ return new HashSet<>();
+ }
+
+ Set elements = decomposeImpl(algorithm);
+
+ hasLoop(elements, "SHA-1", "SHA1");
+ hasLoop(elements, "SHA-224", "SHA224");
+ hasLoop(elements, "SHA-256", "SHA256");
+ hasLoop(elements, "SHA-384", "SHA384");
+ hasLoop(elements, "SHA-512", "SHA512");
+
+ return elements;
+ }
+
+ /*
+ * The provided message digest algorithm name will return a consistent
+ * naming scheme.
+ */
+ public static String hashName(String algorithm) {
+ return algorithm.replace("-", "");
+ }
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java b/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java
new file mode 100644
index 00000000000..6bc003054d1
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/security/util/AnchorCertificates.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.security.AccessController;
+import java.security.KeyStore;
+import java.security.PrivilegedAction;
+import java.security.cert.X509Certificate;
+import java.util.Enumeration;
+import java.util.HashSet;
+
+import sun.security.x509.X509CertImpl;
+
+/**
+ * The purpose of this class is to determine the trust anchor certificates is in
+ * the cacerts file. This is used for PKIX CertPath checking.
+ */
+public class AnchorCertificates {
+
+ private static final Debug debug = Debug.getInstance("certpath");
+ private static final String HASH = "SHA-256";
+ private static HashSet certs;
+
+ static {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public Void run() {
+ File f = new File(System.getProperty("java.home"),
+ "lib/security/cacerts");
+ KeyStore cacerts;
+ try {
+ cacerts = KeyStore.getInstance("JKS");
+ try (FileInputStream fis = new FileInputStream(f)) {
+ cacerts.load(fis, "changeit".toCharArray());
+ certs = new HashSet<>();
+ Enumeration list = cacerts.aliases();
+ String alias;
+ while (list.hasMoreElements()) {
+ alias = list.nextElement();
+ // Check if this cert is labeled a trust anchor.
+ if (alias.contains(" [jdk")) {
+ X509Certificate cert = (X509Certificate) cacerts
+ .getCertificate(alias);
+ certs.add(X509CertImpl.getFingerprint(HASH, cert));
+ }
+ }
+ }
+ } catch (Exception e) {
+ if (debug != null) {
+ debug.println("Error parsing cacerts");
+ }
+ e.printStackTrace();
+ }
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Checks if a certificate is a trust anchor.
+ *
+ * @param cert the certificate to check
+ * @return true if the certificate is trusted.
+ */
+ public static boolean contains(X509Certificate cert) {
+ String key = X509CertImpl.getFingerprint(HASH, cert);
+ boolean result = certs.contains(key);
+ if (result && debug != null) {
+ debug.println("AnchorCertificate.contains: matched " +
+ cert.getSubjectDN());
+ }
+ return result;
+ }
+
+ private AnchorCertificates() {}
+}
diff --git a/jdk/src/java.base/windows/native/libnet/ExtendedOptionsImpl.c b/jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java
similarity index 52%
rename from jdk/src/java.base/windows/native/libnet/ExtendedOptionsImpl.c
rename to jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java
index 2bd955cd13e..9f7a938dede 100644
--- a/jdk/src/java.base/windows/native/libnet/ExtendedOptionsImpl.c
+++ b/jdk/src/java.base/share/classes/sun/security/util/CertConstraintParameters.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,43 +23,37 @@
* questions.
*/
-#include
-#include
+package sun.security.util;
-#include "net_util.h"
+import java.security.cert.X509Certificate;
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: init
- * Signature: ()V
+/**
+ * This class is a wrapper for keeping state and passing objects between PKIX,
+ * AlgorithmChecker, and DisabledAlgorithmConstraints.
*/
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_init
- (JNIEnv *env, jclass UNUSED)
-{
-}
+public class CertConstraintParameters {
+ // A certificate being passed to check against constraints.
+ private final X509Certificate cert;
-/* Non Solaris. Functionality is not supported. So, throw UnsupportedOpExc */
+ // This is true if the trust anchor in the certificate chain matches a cert
+ // in AnchorCertificates
+ private final boolean trustedMatch;
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
-}
+ public CertConstraintParameters(X509Certificate c, boolean match) {
+ cert = c;
+ trustedMatch = match;
+ }
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
-}
+ public CertConstraintParameters(X509Certificate c) {
+ this(c, false);
+ }
-static jboolean flowSupported0() {
- return JNI_FALSE;
-}
+ // Returns if the trust anchor has a match if anchor checking is enabled.
+ public boolean isTrustedMatch() {
+ return trustedMatch;
+ }
-JNIEXPORT jboolean JNICALL Java_sun_net_ExtendedOptionsImpl_flowSupported
- (JNIEnv *env, jclass UNUSED)
-{
- return JNI_FALSE;
+ public X509Certificate getCertificate() {
+ return cert;
+ }
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
index fd4b198ce11..d4b2a4054b3 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,12 +28,14 @@ package sun.security.util;
import java.security.CryptoPrimitive;
import java.security.AlgorithmParameters;
import java.security.Key;
-import java.util.Locale;
-import java.util.Set;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertPathValidatorException.BasicReason;
+import java.security.cert.X509Certificate;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -44,6 +46,7 @@ import java.util.regex.Matcher;
* for the syntax of the disabled algorithm string.
*/
public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
+ private static final Debug debug = Debug.getInstance("certpath");
// the known security property, jdk.certpath.disabledAlgorithms
public static final String PROPERTY_CERTPATH_DISABLED_ALGS =
@@ -53,13 +56,8 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
public static final String PROPERTY_TLS_DISABLED_ALGS =
"jdk.tls.disabledAlgorithms";
- private static final Map disabledAlgorithmsMap =
- new HashMap<>();
- private static final Map keySizeConstraintsMap =
- new HashMap<>();
-
private final String[] disabledAlgorithms;
- private final KeySizeConstraints keySizeConstraints;
+ private final Constraints algorithmConstraints;
/**
* Initialize algorithm constraints with the specified security property.
@@ -74,11 +72,14 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
public DisabledAlgorithmConstraints(String propertyName,
AlgorithmDecomposer decomposer) {
super(decomposer);
- disabledAlgorithms = getAlgorithms(disabledAlgorithmsMap, propertyName);
- keySizeConstraints = getKeySizeConstraints(disabledAlgorithms,
- propertyName);
+ disabledAlgorithms = getAlgorithms(propertyName);
+ algorithmConstraints = new Constraints(disabledAlgorithms);
}
+ /*
+ * This only checks if the algorithm has been completely disabled. If
+ * there are keysize or other limit, this method allow the algorithm.
+ */
@Override
public final boolean permits(Set primitives,
String algorithm, AlgorithmParameters parameters) {
@@ -91,11 +92,19 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return checkAlgorithm(disabledAlgorithms, algorithm, decomposer);
}
+ /*
+ * Checks if the key algorithm has been disabled or constraints have been
+ * placed on the key.
+ */
@Override
public final boolean permits(Set primitives, Key key) {
return checkConstraints(primitives, "", key, null);
}
+ /*
+ * Checks if the key algorithm has been disabled or if constraints have
+ * been placed on the key.
+ */
@Override
public final boolean permits(Set primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
@@ -107,7 +116,39 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return checkConstraints(primitives, algorithm, key, parameters);
}
- // Check algorithm constraints
+ /*
+ * Check if a x509Certificate object is permitted. Check if all
+ * algorithms are allowed, certificate constraints, and the
+ * public key against key constraints.
+ *
+ * Uses new style permit() which throws exceptions.
+ */
+ public final void permits(Set primitives,
+ CertConstraintParameters cp) throws CertPathValidatorException {
+ checkConstraints(primitives, cp);
+ }
+
+ /*
+ * Check if Certificate object is within the constraints.
+ * Uses new style permit() which throws exceptions.
+ */
+ public final void permits(Set primitives,
+ X509Certificate cert) throws CertPathValidatorException {
+ checkConstraints(primitives, new CertConstraintParameters(cert));
+ }
+
+ // Check if a string is contained inside the property
+ public boolean checkProperty(String param) {
+ param = param.toLowerCase(Locale.ENGLISH);
+ for (String block : disabledAlgorithms) {
+ if (block.toLowerCase(Locale.ENGLISH).indexOf(param) >= 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // Check algorithm constraints with key and algorithm
private boolean checkConstraints(Set primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
@@ -116,7 +157,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
throw new IllegalArgumentException("The key cannot be null");
}
- // check the target algorithm
+ // check the signature algorithm
if (algorithm != null && algorithm.length() != 0) {
if (!permits(primitives, algorithm, parameters)) {
return false;
@@ -129,97 +170,203 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
}
// check the key constraints
- if (keySizeConstraints.disables(key)) {
- return false;
- }
-
- return true;
+ return algorithmConstraints.permits(key);
}
- private static KeySizeConstraints getKeySizeConstraints(
- String[] disabledAlgorithms, String propertyName) {
- synchronized (keySizeConstraintsMap) {
- if(!keySizeConstraintsMap.containsKey(propertyName)) {
- // map the key constraints
- KeySizeConstraints keySizeConstraints =
- new KeySizeConstraints(disabledAlgorithms);
- keySizeConstraintsMap.put(propertyName, keySizeConstraints);
- }
+ /*
+ * Check algorithm constraints with Certificate
+ * Uses new style permit() which throws exceptions.
+ */
+ private void checkConstraints(Set primitives,
+ CertConstraintParameters cp) throws CertPathValidatorException {
- return keySizeConstraintsMap.get(propertyName);
+ X509Certificate cert = cp.getCertificate();
+ String algorithm = cert.getSigAlgName();
+
+ // Check signature algorithm is not disabled
+ if (!permits(primitives, algorithm, null)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on disabled "+
+ "signature algorithm: " + algorithm,
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
}
+
+ // Check key algorithm is not disabled
+ if (!permits(primitives, cert.getPublicKey().getAlgorithm(), null)) {
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on disabled "+
+ "public key algorithm: " + algorithm,
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
+
+ // Check the certificate and key constraints
+ algorithmConstraints.permits(cp);
+
}
/**
- * key constraints
+ * Key and Certificate Constraints
+ *
+ * The complete disabling of an algorithm is not handled by Constraints or
+ * Constraint classes. That is addressed with
+ * permit(Set, String, AlgorithmParameters)
+ *
+ * When passing a Key to permit(), the boolean return values follow the
+ * same as the interface class AlgorithmConstraints.permit(). This is to
+ * maintain compatibility:
+ * 'true' means the operation is allowed.
+ * 'false' means it failed the constraints and is disallowed.
+ *
+ * When passing CertConstraintParameters through permit(), an exception
+ * will be thrown on a failure to better identify why the operation was
+ * disallowed.
*/
- private static class KeySizeConstraints {
- private static final Pattern pattern = Pattern.compile(
- "(\\S+)\\s+keySize\\s*(<=|<|==|!=|>|>=)\\s*(\\d+)");
- private Map> constraintsMap =
- Collections.synchronizedMap(
- new HashMap>());
+ private static class Constraints {
+ private Map> constraintsMap = new HashMap<>();
+ private static final Pattern keySizePattern = Pattern.compile(
+ "keySize\\s*(<=|<|==|!=|>|>=)\\s*(\\d+)");
- public KeySizeConstraints(String[] restrictions) {
- for (String restriction : restrictions) {
- if (restriction == null || restriction.isEmpty()) {
+ public Constraints(String[] constraintArray) {
+ for (String constraintEntry : constraintArray) {
+ if (constraintEntry == null || constraintEntry.isEmpty()) {
continue;
}
- Matcher matcher = pattern.matcher(restriction);
- if (matcher.matches()) {
- String algorithm = matcher.group(1);
+ constraintEntry = constraintEntry.trim();
+ if (debug != null) {
+ debug.println("Constraints: " + constraintEntry);
+ }
- KeySizeConstraint.Operator operator =
- KeySizeConstraint.Operator.of(matcher.group(2));
- int length = Integer.parseInt(matcher.group(3));
+ // Check if constraint is a complete disabling of an
+ // algorithm or has conditions.
+ String algorithm;
+ String policy;
+ int space = constraintEntry.indexOf(' ');
+ if (space > 0) {
+ algorithm = AlgorithmDecomposer.hashName(
+ constraintEntry.substring(0, space).
+ toUpperCase(Locale.ENGLISH));
+ policy = constraintEntry.substring(space + 1);
+ } else {
+ constraintsMap.computeIfAbsent(
+ constraintEntry.toUpperCase(Locale.ENGLISH),
+ k -> new HashSet<>());
+ continue;
+ }
- algorithm = algorithm.toLowerCase(Locale.ENGLISH);
+ // Convert constraint conditions into Constraint classes
+ Constraint c, lastConstraint = null;
+ // Allow only one jdkCA entry per constraint entry
+ boolean jdkCALimit = false;
- synchronized (constraintsMap) {
- if (!constraintsMap.containsKey(algorithm)) {
- constraintsMap.put(algorithm,
- new HashSet());
+ for (String entry : policy.split("&")) {
+ entry = entry.trim();
+
+ Matcher matcher = keySizePattern.matcher(entry);
+ if (matcher.matches()) {
+ if (debug != null) {
+ debug.println("Constraints set to keySize: " +
+ entry);
}
+ c = new KeySizeConstraint(algorithm,
+ KeySizeConstraint.Operator.of(matcher.group(1)),
+ Integer.parseInt(matcher.group(2)));
- Set constraintSet =
- constraintsMap.get(algorithm);
- KeySizeConstraint constraint =
- new KeySizeConstraint(operator, length);
- constraintSet.add(constraint);
+ } else if (entry.equalsIgnoreCase("jdkCA")) {
+ if (debug != null) {
+ debug.println("Constraints set to jdkCA.");
+ }
+ if (jdkCALimit) {
+ throw new IllegalArgumentException("Only one " +
+ "jdkCA entry allowed in property. " +
+ "Constraint: " + constraintEntry);
+ }
+ c = new jdkCAConstraint(algorithm);
+ jdkCALimit = true;
+ } else {
+ throw new IllegalArgumentException("Error in security" +
+ " property. Constraint unknown: " + entry);
}
+
+ // Link multiple conditions for a single constraint
+ // into a linked list.
+ if (lastConstraint == null) {
+ if (!constraintsMap.containsKey(algorithm)) {
+ constraintsMap.putIfAbsent(algorithm,
+ new HashSet<>());
+ }
+ constraintsMap.get(algorithm).add(c);
+ } else {
+ lastConstraint.nextConstraint = c;
+ }
+ lastConstraint = c;
}
}
}
- // Does this KeySizeConstraints disable the specified key?
- public boolean disables(Key key) {
- String algorithm = key.getAlgorithm().toLowerCase(Locale.ENGLISH);
- synchronized (constraintsMap) {
- if (constraintsMap.containsKey(algorithm)) {
- Set constraintSet =
- constraintsMap.get(algorithm);
- for (KeySizeConstraint constraint : constraintSet) {
- if (constraint.disables(key)) {
- return true;
- }
+ // Get applicable constraints based off the signature algorithm
+ private Set getConstraints(String algorithm) {
+ return constraintsMap.get(algorithm);
+ }
+
+ // Check if KeySizeConstraints permit the specified key
+ public boolean permits(Key key) {
+ Set set = getConstraints(key.getAlgorithm());
+ if (set == null) {
+ return true;
+ }
+ for (Constraint constraint : set) {
+ if (!constraint.permits(key)) {
+ if (debug != null) {
+ debug.println("keySizeConstraint: failed key " +
+ "constraint check " + KeyUtil.getKeySize(key));
}
+ return false;
}
}
+ return true;
+ }
- return false;
+ // Check if constraints permit this cert.
+ public void permits(CertConstraintParameters cp)
+ throws CertPathValidatorException {
+ X509Certificate cert = cp.getCertificate();
+
+ if (debug != null) {
+ debug.println("Constraints.permits(): " + cert.getSigAlgName());
+ }
+
+ // Get all signature algorithms to check for constraints
+ Set algorithms =
+ AlgorithmDecomposer.decomposeOneHash(cert.getSigAlgName());
+ if (algorithms == null || algorithms.isEmpty()) {
+ return;
+ }
+
+ // Attempt to add the public key algorithm to the set
+ algorithms.add(cert.getPublicKey().getAlgorithm());
+
+ // Check all applicable constraints
+ for (String algorithm : algorithms) {
+ Set set = getConstraints(algorithm);
+ if (set == null) {
+ continue;
+ }
+ for (Constraint constraint : set) {
+ constraint.permits(cp);
+ }
+ }
}
}
- /**
- * Key size constraint.
- *
- * e.g. "keysize <= 1024"
- */
- private static class KeySizeConstraint {
+ // Abstract class for algorithm constraint checking
+ private abstract static class Constraint {
+ String algorithm;
+ Constraint nextConstraint = null;
+
// operator
- static enum Operator {
+ enum Operator {
EQ, // "=="
NE, // "!="
LT, // "<"
@@ -243,16 +390,77 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
return GE;
}
- throw new IllegalArgumentException(
- s + " is not a legal Operator");
+ throw new IllegalArgumentException("Error in security " +
+ "property. " + s + " is not a legal Operator");
}
}
+ /**
+ * Check if an algorithm constraint permit this key to be used.
+ * @param key Public key
+ * @return true if constraints do not match
+ */
+ public boolean permits(Key key) {
+ return true;
+ }
+
+ /**
+ * Check if an algorithm constraint is permit this certificate to
+ * be used.
+ * @param cp CertificateParameter containing certificate and state info
+ * @return true if constraints do not match
+ */
+ public abstract void permits(CertConstraintParameters cp)
+ throws CertPathValidatorException;
+ }
+
+ /*
+ * This class contains constraints dealing with the certificate chain
+ * of the certificate.
+ */
+ private static class jdkCAConstraint extends Constraint {
+ jdkCAConstraint(String algo) {
+ algorithm = algo;
+ }
+
+ /*
+ * Check if each constraint fails and check if there is a linked
+ * constraint Any permitted constraint will exit the linked list
+ * to allow the operation.
+ */
+ public void permits(CertConstraintParameters cp)
+ throws CertPathValidatorException {
+ if (debug != null) {
+ debug.println("jdkCAConstraints.permits(): " + algorithm);
+ }
+
+ // Return false if the chain has a trust anchor in cacerts
+ if (cp.isTrustedMatch()) {
+ if (nextConstraint != null) {
+ nextConstraint.permits(cp);
+ return;
+ }
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on certificate " +
+ "anchor limits",
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
+ }
+ }
+
+
+ /*
+ * This class contains constraints dealing with the key size
+ * support limits per algorithm. e.g. "keySize <= 1024"
+ */
+ private static class KeySizeConstraint extends Constraint {
+
private int minSize; // the minimal available key size
private int maxSize; // the maximal available key size
private int prohibitedSize = -1; // unavailable key sizes
- public KeySizeConstraint(Operator operator, int length) {
+ public KeySizeConstraint(String algo, Operator operator, int length) {
+ algorithm = algo;
switch (operator) {
case EQ: // an unavailable key size
this.minSize = 0;
@@ -286,21 +494,59 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
}
}
- // Does this key constraint disable the specified key?
- public boolean disables(Key key) {
- int size = KeyUtil.getKeySize(key);
+ /*
+ * If we are passed a certificate, extract the public key and use it.
+ *
+ * Check if each constraint fails and check if there is a linked
+ * constraint Any permitted constraint will exit the linked list
+ * to allow the operation.
+ */
+ public void permits(CertConstraintParameters cp)
+ throws CertPathValidatorException {
+ if (!permitsImpl(cp.getCertificate().getPublicKey())) {
+ if (nextConstraint != null) {
+ nextConstraint.permits(cp);
+ return;
+ }
+ throw new CertPathValidatorException(
+ "Algorithm constraints check failed on keysize limits",
+ null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+ }
+ }
+
+ // Check if key constraint disable the specified key
+ // Uses old style permit()
+ public boolean permits(Key key) {
+ // If we recursively find a constraint that permits us to use
+ // this key, return true and skip any other constraint checks.
+ if (nextConstraint != null && nextConstraint.permits(key)) {
+ return true;
+ }
+ if (debug != null) {
+ debug.println("KeySizeConstraints.permits(): " + algorithm);
+ }
+
+ return permitsImpl(key);
+ }
+
+ private boolean permitsImpl(Key key) {
+ // Verify this constraint is for this public key algorithm
+ if (algorithm.compareToIgnoreCase(key.getAlgorithm()) != 0) {
+ return true;
+ }
+
+ int size = KeyUtil.getKeySize(key);
if (size == 0) {
- return true; // we don't allow any key of size 0.
+ return false; // we don't allow any key of size 0.
} else if (size > 0) {
- return ((size < minSize) || (size > maxSize) ||
+ return !((size < minSize) || (size > maxSize) ||
(prohibitedSize == size));
} // Otherwise, the key size is not accessible. Conservatively,
// please don't disable such keys.
- return false;
+ return true;
}
}
-
}
diff --git a/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java b/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
index d8803348a5d..7c8fe9af51d 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,6 @@ package sun.security.util;
import java.security.AlgorithmParameters;
import java.security.CryptoPrimitive;
import java.security.Key;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
import static sun.security.util.AbstractAlgorithmConstraints.getAlgorithms;
@@ -42,15 +40,12 @@ public class LegacyAlgorithmConstraints extends AbstractAlgorithmConstraints {
public static final String PROPERTY_TLS_LEGACY_ALGS =
"jdk.tls.legacyAlgorithms";
- private static final Map legacyAlgorithmsMap =
- new HashMap<>();
-
private final String[] legacyAlgorithms;
public LegacyAlgorithmConstraints(String propertyName,
AlgorithmDecomposer decomposer) {
super(decomposer);
- legacyAlgorithms = getAlgorithms(legacyAlgorithmsMap, propertyName);
+ legacyAlgorithms = getAlgorithms(propertyName);
}
@Override
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
index 0e4da831a83..8d496ad85c4 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1924,17 +1924,18 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
public String getFingerprint(String algorithm) {
return fingerprints.computeIfAbsent(algorithm,
- x -> getCertificateFingerPrint(x));
+ x -> getFingerprint(x, this));
}
/**
* Gets the requested finger print of the certificate. The result
* only contains 0-9 and A-F. No small case, no colon.
*/
- private String getCertificateFingerPrint(String mdAlg) {
+ public static String getFingerprint(String algorithm,
+ X509Certificate cert) {
try {
- byte[] encCertInfo = getEncoded();
- MessageDigest md = MessageDigest.getInstance(mdAlg);
+ byte[] encCertInfo = cert.getEncoded();
+ MessageDigest md = MessageDigest.getInstance(algorithm);
byte[] digest = md.digest(encCertInfo);
StringBuilder sb = new StringBuilder(digest.length * 2);
for (int i = 0; i < digest.length; i++) {
diff --git a/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java b/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java
index 655dc96a299..e8df610c4c1 100644
--- a/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java
+++ b/jdk/src/java.base/share/classes/sun/util/logging/PlatformLogger.java
@@ -286,12 +286,15 @@ public class PlatformLogger {
}
if (log == null) {
log = new PlatformLogger(PlatformLogger.Bridge.convert(
- // We pass PlatformLogger.class rather than the actual caller
+ // We pass PlatformLogger.class.getModule() (java.base)
+ // rather than the actual module of the caller
// because we want PlatformLoggers to be system loggers: we
// won't need to resolve any resource bundles anyway.
// Note: Many unit tests depend on the fact that
- // PlatformLogger.getLoggerFromFinder is not caller sensitive.
- LazyLoggers.getLazyLogger(name, PlatformLogger.class)));
+ // PlatformLogger.getLoggerFromFinder is not caller
+ // sensitive, and this strategy ensure that the tests
+ // still pass.
+ LazyLoggers.getLazyLogger(name, PlatformLogger.class.getModule())));
loggers.put(name, new WeakReference<>(log));
}
return log;
diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security
index 6a9803bf425..fa2da13c195 100644
--- a/jdk/src/java.base/share/conf/security/java.security
+++ b/jdk/src/java.base/share/conf/security/java.security
@@ -497,13 +497,13 @@ krb5.kdc.bad.policy = tryLast
# " DisabledAlgorithm { , DisabledAlgorithm } "
#
# DisabledAlgorithm:
-# AlgorithmName [Constraint]
+# AlgorithmName [Constraint] { '&' Constraint }
#
# AlgorithmName:
# (see below)
#
# Constraint:
-# KeySizeConstraint
+# KeySizeConstraint, CertConstraint
#
# KeySizeConstraint:
# keySize Operator DecimalInteger
@@ -520,6 +520,9 @@ krb5.kdc.bad.policy = tryLast
# DecimalDigit: one of
# 1 2 3 4 5 6 7 8 9 0
#
+# CertConstraint
+# jdkCA
+#
# The "AlgorithmName" is the standard algorithm name of the disabled
# algorithm. See "Java Cryptography Architecture Standard Algorithm Name
# Documentation" for information about Standard Algorithm Names. Matching
@@ -542,6 +545,29 @@ krb5.kdc.bad.policy = tryLast
# be disabled. Note that the "KeySizeConstraint" only makes sense to key
# algorithms.
#
+# "CertConstraint" specifies additional constraints for
+# certificates that contain algorithms that are restricted:
+#
+# Â Â "jdkCA" prohibits the specified algorithm only if the algorithm is used
+# Â Â Â Â in a certificate chain that terminates at a marked trust anchor in the
+# Â Â Â Â lib/security/cacerts keystore. Â All other chains are not affected.
+# Â Â Â Â If the jdkCA constraint is not set, then all chains using the
+# Â Â Â Â specified algorithm are restricted. jdkCA may only be used once in
+# a DisabledAlgorithm expression.
+# Â Â Â Â Example: Â To apply this constraint to SHA-1 certificates, include
+# Â Â Â Â the following: Â "SHA1 jdkCA"
+#
+# When an algorithm must satisfy more than one constraint, it must be
+# delimited by an ampersand '&'. For example, to restrict certificates in a
+# chain that terminate at a distribution provided trust anchor and contain
+# RSA keys that are less than or equal to 1024 bits, add the following
+# constraint: "RSA keySize <= 1024 & jdkCA".
+#
+# All DisabledAlgorithms expressions are processed in the order defined in the
+# property. This requires lower keysize constraints to be specified
+# before larger keysize constraints of the same algorithm. For example:
+# "RSA keySize < 1024 & jdkCA, RSA keySize < 2048".
+#
# Note: This property is currently used by Oracle's PKIX implementation. It
# is not guaranteed to be examined and used by other implementations.
#
diff --git a/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java b/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
index f7c65931613..32640dff272 100644
--- a/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
+++ b/jdk/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
@@ -27,9 +27,7 @@ package java.net;
import java.io.IOException;
import java.util.Set;
import java.util.HashSet;
-import java.util.Collections;
-import jdk.net.*;
-import static sun.net.ExtendedOptionsImpl.*;
+import sun.net.ext.ExtendedSocketOptions;
/*
* On Unix systems we simply delegate to native methods.
@@ -43,8 +41,11 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
init();
}
+ static final ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+
protected void setOption(SocketOption name, T value) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
super.setOption(name, value);
} else {
@@ -55,21 +56,16 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
}
}
} else {
- if (!flowSupported()) {
- throw new UnsupportedOperationException("unsupported option");
- }
if (isClosed()) {
throw new SocketException("Socket closed");
}
- checkSetOptionPermission(name);
- checkValueType(value, SocketFlow.class);
- setFlowOption(getFileDescriptor(), (SocketFlow)value);
+ extendedOptions.setOption(fd, name, value);
}
}
@SuppressWarnings("unchecked")
protected T getOption(SocketOption name) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
return super.getOption(name);
} else {
@@ -79,31 +75,23 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
throw new UnsupportedOperationException("unsupported option");
}
}
+ } else {
+ if (isClosed()) {
+ throw new SocketException("Socket closed");
+ }
+ return (T) extendedOptions.getOption(fd, name);
}
- if (!flowSupported()) {
- throw new UnsupportedOperationException("unsupported option");
- }
- if (isClosed()) {
- throw new SocketException("Socket closed");
- }
- checkGetOptionPermission(name);
- SocketFlow flow = SocketFlow.create();
- getFlowOption(getFileDescriptor(), flow);
- return (T)flow;
}
protected Set> supportedOptions() {
- HashSet> options = new HashSet<>(
- super.supportedOptions());
-
- if (flowSupported()) {
- options.add(ExtendedSocketOptions.SO_FLOW_SLA);
- }
+ HashSet> options = new HashSet<>(super.supportedOptions());
+ options.addAll(extendedOptions.options());
return options;
}
protected void socketSetOption(int opt, Object val) throws SocketException {
- if (opt == SocketOptions.SO_REUSEPORT && !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
+ if (opt == SocketOptions.SO_REUSEPORT &&
+ !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
throw new UnsupportedOperationException("unsupported option");
}
try {
diff --git a/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java b/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java
index 2ec573ea5a9..4a5f2b5ddd6 100644
--- a/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java
+++ b/jdk/src/java.base/unix/classes/java/net/PlainSocketImpl.java
@@ -28,10 +28,7 @@ import java.io.IOException;
import java.io.FileDescriptor;
import java.util.Set;
import java.util.HashSet;
-import java.util.Collections;
-import jdk.net.*;
-
-import static sun.net.ExtendedOptionsImpl.*;
+import sun.net.ext.ExtendedSocketOptions;
/*
* On Unix systems we simply delegate to native methods.
@@ -57,8 +54,11 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
this.fd = fd;
}
+ static final ExtendedSocketOptions extendedOptions =
+ ExtendedSocketOptions.getInstance();
+
protected void setOption(SocketOption name, T value) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
super.setOption(name, value);
} else {
@@ -69,21 +69,19 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
}
}
} else {
- if (getSocket() == null || !flowSupported()) {
+ if (getSocket() == null) {
throw new UnsupportedOperationException("unsupported option");
}
if (isClosedOrPending()) {
throw new SocketException("Socket closed");
}
- checkSetOptionPermission(name);
- checkValueType(value, SocketFlow.class);
- setFlowOption(getFileDescriptor(), (SocketFlow)value);
+ extendedOptions.setOption(fd, name, value);
}
}
@SuppressWarnings("unchecked")
protected T getOption(SocketOption name) throws IOException {
- if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
+ if (!extendedOptions.isOptionSupported(name)) {
if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
return super.getOption(name);
} else {
@@ -93,31 +91,28 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
throw new UnsupportedOperationException("unsupported option");
}
}
+ } else {
+ if (getSocket() == null) {
+ throw new UnsupportedOperationException("unsupported option");
+ }
+ if (isClosedOrPending()) {
+ throw new SocketException("Socket closed");
+ }
+ return (T) extendedOptions.getOption(fd, name);
}
- if (getSocket() == null || !flowSupported()) {
- throw new UnsupportedOperationException("unsupported option");
- }
- if (isClosedOrPending()) {
- throw new SocketException("Socket closed");
- }
- checkGetOptionPermission(name);
- SocketFlow flow = SocketFlow.create();
- getFlowOption(getFileDescriptor(), flow);
- return (T)flow;
}
protected Set> supportedOptions() {
- HashSet> options = new HashSet<>(
- super.supportedOptions());
-
- if (getSocket() != null && flowSupported()) {
- options.add(ExtendedSocketOptions.SO_FLOW_SLA);
+ HashSet> options = new HashSet<>(super.supportedOptions());
+ if (getSocket() != null) {
+ options.addAll(extendedOptions.options());
}
return options;
}
protected void socketSetOption(int opt, boolean b, Object val) throws SocketException {
- if (opt == SocketOptions.SO_REUSEPORT && !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
+ if (opt == SocketOptions.SO_REUSEPORT &&
+ !supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
throw new UnsupportedOperationException("unsupported option");
}
try {
diff --git a/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java b/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java
index 1911c3507c0..27c7a41937e 100644
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java
+++ b/jdk/src/java.base/unix/classes/sun/nio/ch/PollSelectorImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.util.*;
-import sun.misc.*;
/**
diff --git a/jdk/src/java.base/unix/native/libnet/ExtendedOptionsImpl.c b/jdk/src/java.base/unix/native/libnet/ExtendedOptionsImpl.c
deleted file mode 100644
index 116d2e97d92..00000000000
--- a/jdk/src/java.base/unix/native/libnet/ExtendedOptionsImpl.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include
-#include
-
-#include "net_util.h"
-#include "jdk_net_SocketFlow.h"
-
-static jclass sf_status_class; /* Status enum type */
-
-static jfieldID sf_status;
-static jfieldID sf_priority;
-static jfieldID sf_bandwidth;
-
-static jfieldID sf_fd_fdID; /* FileDescriptor.fd */
-
-/* References to the literal enum values */
-
-static jobject sfs_NOSTATUS;
-static jobject sfs_OK;
-static jobject sfs_NOPERMISSION;
-static jobject sfs_NOTCONNECTED;
-static jobject sfs_NOTSUPPORTED;
-static jobject sfs_ALREADYCREATED;
-static jobject sfs_INPROGRESS;
-static jobject sfs_OTHER;
-
-static jobject getEnumField(JNIEnv *env, char *name);
-static void setStatus(JNIEnv *env, jobject obj, int errval);
-
-/* OS specific code is implemented in these three functions */
-
-static jboolean flowSupported0() ;
-
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_init
- (JNIEnv *env, jclass UNUSED)
-{
- static int initialized = 0;
- jclass c;
-
- /* Global class references */
-
- if (initialized) {
- return;
- }
-
- c = (*env)->FindClass(env, "jdk/net/SocketFlow$Status");
- CHECK_NULL(c);
- sf_status_class = (*env)->NewGlobalRef(env, c);
- CHECK_NULL(sf_status_class);
-
- /* int "fd" field of java.io.FileDescriptor */
-
- c = (*env)->FindClass(env, "java/io/FileDescriptor");
- CHECK_NULL(c);
- sf_fd_fdID = (*env)->GetFieldID(env, c, "fd", "I");
- CHECK_NULL(sf_fd_fdID);
-
-
- /* SocketFlow fields */
-
- c = (*env)->FindClass(env, "jdk/net/SocketFlow");
- CHECK_NULL(c);
-
- /* status */
-
- sf_status = (*env)->GetFieldID(env, c, "status",
- "Ljdk/net/SocketFlow$Status;");
- CHECK_NULL(sf_status);
-
- /* priority */
-
- sf_priority = (*env)->GetFieldID(env, c, "priority", "I");
- CHECK_NULL(sf_priority);
-
- /* bandwidth */
-
- sf_bandwidth = (*env)->GetFieldID(env, c, "bandwidth", "J");
- CHECK_NULL(sf_bandwidth);
-
- /* Initialize the static enum values */
-
- sfs_NOSTATUS = getEnumField(env, "NO_STATUS");
- CHECK_NULL(sfs_NOSTATUS);
- sfs_OK = getEnumField(env, "OK");
- CHECK_NULL(sfs_OK);
- sfs_NOPERMISSION = getEnumField(env, "NO_PERMISSION");
- CHECK_NULL(sfs_NOPERMISSION);
- sfs_NOTCONNECTED = getEnumField(env, "NOT_CONNECTED");
- CHECK_NULL(sfs_NOTCONNECTED);
- sfs_NOTSUPPORTED = getEnumField(env, "NOT_SUPPORTED");
- CHECK_NULL(sfs_NOTSUPPORTED);
- sfs_ALREADYCREATED = getEnumField(env, "ALREADY_CREATED");
- CHECK_NULL(sfs_ALREADYCREATED);
- sfs_INPROGRESS = getEnumField(env, "IN_PROGRESS");
- CHECK_NULL(sfs_INPROGRESS);
- sfs_OTHER = getEnumField(env, "OTHER");
- CHECK_NULL(sfs_OTHER);
- initialized = JNI_TRUE;
-}
-
-static jobject getEnumField(JNIEnv *env, char *name)
-{
- jobject f;
- jfieldID fID = (*env)->GetStaticFieldID(env, sf_status_class, name,
- "Ljdk/net/SocketFlow$Status;");
- CHECK_NULL_RETURN(fID, NULL);
-
- f = (*env)->GetStaticObjectField(env, sf_status_class, fID);
- CHECK_NULL_RETURN(f, NULL);
- f = (*env)->NewGlobalRef(env, f);
- CHECK_NULL_RETURN(f, NULL);
- return f;
-}
-
-/*
- * Retrieve the int file-descriptor from a public socket type object.
- * Gets impl, then the FileDescriptor from the impl, and then the fd
- * from that.
- */
-static int getFD(JNIEnv *env, jobject fileDesc) {
- return (*env)->GetIntField(env, fileDesc, sf_fd_fdID);
-}
-
-/**
- * Sets the status field of a SocketFlow to one of the
- * canned enum values
- */
-static void setStatus (JNIEnv *env, jobject obj, int errval)
-{
- switch (errval) {
- case 0: /* OK */
- (*env)->SetObjectField(env, obj, sf_status, sfs_OK);
- break;
- case EPERM:
- (*env)->SetObjectField(env, obj, sf_status, sfs_NOPERMISSION);
- break;
- case ENOTCONN:
- (*env)->SetObjectField(env, obj, sf_status, sfs_NOTCONNECTED);
- break;
- case EOPNOTSUPP:
- (*env)->SetObjectField(env, obj, sf_status, sfs_NOTSUPPORTED);
- break;
- case EALREADY:
- (*env)->SetObjectField(env, obj, sf_status, sfs_ALREADYCREATED);
- break;
- case EINPROGRESS:
- (*env)->SetObjectField(env, obj, sf_status, sfs_INPROGRESS);
- break;
- default:
- (*env)->SetObjectField(env, obj, sf_status, sfs_OTHER);
- break;
- }
-}
-
-#ifdef __solaris__
-
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: setFlowOption
- * Signature: (Ljava/io/FileDescriptor;Ljdk/net/SocketFlow;)V
- */
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- int fd = getFD(env, fileDesc);
-
- if (fd < 0) {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException", "socket closed");
- return;
- } else {
- sock_flow_props_t props;
- jlong bandwidth;
- int rv;
-
- jint priority = (*env)->GetIntField(env, flow, sf_priority);
- memset(&props, 0, sizeof(props));
- props.sfp_version = SOCK_FLOW_PROP_VERSION1;
-
- if (priority != jdk_net_SocketFlow_UNSET) {
- props.sfp_mask |= SFP_PRIORITY;
- props.sfp_priority = priority;
- }
- bandwidth = (*env)->GetLongField(env, flow, sf_bandwidth);
- if (bandwidth > -1) {
- props.sfp_mask |= SFP_MAXBW;
- props.sfp_maxbw = (uint64_t) bandwidth;
- }
- rv = setsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &props, sizeof(props));
- if (rv < 0) {
- if (errno == ENOPROTOOPT) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
- } else if (errno == EACCES || errno == EPERM) {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException",
- "Permission denied");
- } else {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException",
- "set option SO_FLOW_SLA failed");
- }
- return;
- }
- setStatus(env, flow, props.sfp_status);
- }
-}
-
-/*
- * Class: sun_net_ExtendedOptionsImpl
- * Method: getFlowOption
- * Signature: (Ljava/io/FileDescriptor;Ljdk/net/SocketFlow;)V
- */
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- int fd = getFD(env, fileDesc);
-
- if (fd < 0) {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException", "socket closed");
- return;
- } else {
- sock_flow_props_t props;
- int status;
- socklen_t sz = sizeof(props);
-
- int rv = getsockopt(fd, SOL_SOCKET, SO_FLOW_SLA, &props, &sz);
- if (rv < 0) {
- if (errno == ENOPROTOOPT) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
- } else if (errno == EACCES || errno == EPERM) {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException",
- "Permission denied");
- } else {
- NET_ERROR(env, JNU_JAVANETPKG "SocketException",
- "set option SO_FLOW_SLA failed");
- }
- return;
- }
- /* first check status to see if flow exists */
- status = props.sfp_status;
- setStatus(env, flow, status);
- if (status == 0) { /* OK */
- /* can set the other fields now */
- if (props.sfp_mask & SFP_PRIORITY) {
- (*env)->SetIntField(env, flow, sf_priority, props.sfp_priority);
- }
- if (props.sfp_mask & SFP_MAXBW) {
- (*env)->SetLongField(env, flow, sf_bandwidth,
- (jlong)props.sfp_maxbw);
- }
- }
- }
-}
-
-static jboolean flowsupported;
-static jboolean flowsupported_set = JNI_FALSE;
-
-static jboolean flowSupported0()
-{
- /* Do a simple dummy call, and try to figure out from that */
- sock_flow_props_t props;
- int rv, s;
- if (flowsupported_set) {
- return flowsupported;
- }
- s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (s < 0) {
- flowsupported = JNI_FALSE;
- flowsupported_set = JNI_TRUE;
- return JNI_FALSE;
- }
- memset(&props, 0, sizeof(props));
- props.sfp_version = SOCK_FLOW_PROP_VERSION1;
- props.sfp_mask |= SFP_PRIORITY;
- props.sfp_priority = SFP_PRIO_NORMAL;
- rv = setsockopt(s, SOL_SOCKET, SO_FLOW_SLA, &props, sizeof(props));
- if (rv != 0 && errno == ENOPROTOOPT) {
- rv = JNI_FALSE;
- } else {
- rv = JNI_TRUE;
- }
- close(s);
- flowsupported = rv;
- flowsupported_set = JNI_TRUE;
- return flowsupported;
-}
-
-#else /* __solaris__ */
-
-/* Non Solaris. Functionality is not supported. So, throw UnsupportedOpExc */
-
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_setFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
-}
-
-JNIEXPORT void JNICALL Java_sun_net_ExtendedOptionsImpl_getFlowOption
- (JNIEnv *env, jclass UNUSED, jobject fileDesc, jobject flow)
-{
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "unsupported socket option");
-}
-
-static jboolean flowSupported0() {
- return JNI_FALSE;
-}
-
-#endif /* __solaris__ */
-
-JNIEXPORT jboolean JNICALL Java_sun_net_ExtendedOptionsImpl_flowSupported
- (JNIEnv *env, jclass UNUSED)
-{
- return flowSupported0();
-}
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.h b/jdk/src/java.base/unix/native/libnet/net_util_md.h
index f440bd8ae6a..3a8c9f4d48e 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h
@@ -120,47 +120,6 @@ int getDefaultIPv6Interface(struct in6_addr *target_addr);
#ifdef __solaris__
int net_getParam(char *driver, char *param);
-
-#ifndef SO_FLOW_SLA
-#define SO_FLOW_SLA 0x1018
-
-#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
-#pragma pack(4)
#endif
-/*
- * Used with the setsockopt(SO_FLOW_SLA, ...) call to set
- * per socket service level properties.
- * When the application uses per-socket API, we will enforce the properties
- * on both outbound and inbound packets.
- *
- * For now, only priority and maxbw are supported in SOCK_FLOW_PROP_VERSION1.
- */
-typedef struct sock_flow_props_s {
- int sfp_version;
- uint32_t sfp_mask;
- int sfp_priority; /* flow priority */
- uint64_t sfp_maxbw; /* bandwidth limit in bps */
- int sfp_status; /* flow create status for getsockopt */
-} sock_flow_props_t;
-
-#define SOCK_FLOW_PROP_VERSION1 1
-
-/* bit mask values for sfp_mask */
-#define SFP_MAXBW 0x00000001 /* Flow Bandwidth Limit */
-#define SFP_PRIORITY 0x00000008 /* Flow priority */
-
-/* possible values for sfp_priority */
-#define SFP_PRIO_NORMAL 1
-#define SFP_PRIO_HIGH 2
-
-#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
-#pragma pack()
-#endif /* _LONG_LONG_ALIGNMENT */
-
-#endif /* SO_FLOW_SLA */
-#endif /* __solaris__ */
-
-JNIEXPORT jboolean JNICALL NET_IsFlowSupported();
-
#endif /* NET_UTILS_MD_H */
diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java
index 63b2112aca1..00e68fb785b 100644
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java
@@ -113,6 +113,10 @@ class WindowsWatchService
// completion key (used to map I/O completion to WatchKey)
private int completionKey;
+ // flag indicates that ReadDirectoryChangesW failed
+ // and overlapped I/O operation wasn't started
+ private boolean errorStartingOverlapped;
+
WindowsWatchKey(Path dir,
AbstractWatchService watcher,
FileKey fileKey)
@@ -175,6 +179,14 @@ class WindowsWatchService
return completionKey;
}
+ void setErrorStartingOverlapped(boolean value) {
+ errorStartingOverlapped = value;
+ }
+
+ boolean isErrorStartingOverlapped() {
+ return errorStartingOverlapped;
+ }
+
// Invalidate the key, assumes that resources have been released
void invalidate() {
((WindowsWatchService)watcher()).poller.releaseResources(this);
@@ -182,6 +194,7 @@ class WindowsWatchService
buffer = null;
countAddress = 0;
overlappedAddress = 0;
+ errorStartingOverlapped = false;
}
@Override
@@ -455,11 +468,13 @@ class WindowsWatchService
* resources.
*/
private void releaseResources(WindowsWatchKey key) {
- try {
- CancelIo(key.handle());
- GetOverlappedResult(key.handle(), key.overlappedAddress());
- } catch (WindowsException expected) {
- // expected as I/O operation has been cancelled
+ if (!key.isErrorStartingOverlapped()) {
+ try {
+ CancelIo(key.handle());
+ GetOverlappedResult(key.handle(), key.overlappedAddress());
+ } catch (WindowsException expected) {
+ // expected as I/O operation has been cancelled
+ }
}
CloseHandle(key.handle());
closeAttachedEvent(key.overlappedAddress());
@@ -628,6 +643,7 @@ class WindowsWatchService
} catch (WindowsException x) {
// no choice but to cancel key
criticalError = true;
+ key.setErrorStartingOverlapped(true);
}
}
if (criticalError) {
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java
index 3a132f25595..027cbcf67e6 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMenuBarHandler.java
@@ -83,7 +83,7 @@ class _AppMenuBarHandler {
// if we have no foreground frames, then we have to "kick" the menubar
final JFrame pingFrame = new JFrame();
- pingFrame.getRootPane().putClientProperty("Window.alpha", new Float(0.0f));
+ pingFrame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(0.0f));
pingFrame.setUndecorated(true);
pingFrame.setVisible(true);
pingFrame.toFront();
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java
index 332cb7e46ff..88faf6b06e8 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaComboBoxPopup.java
@@ -58,7 +58,7 @@ class AquaComboBoxPopup extends BasicComboPopup {
updateContents(false);
// TODO: CPlatformWindow?
- putClientProperty(CPlatformWindow.WINDOW_FADE_OUT, new Integer(150));
+ putClientProperty(CPlatformWindow.WINDOW_FADE_OUT, Integer.valueOf(150));
}
public void updateContents(final boolean remove) {
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java
index 1534d6d80c7..e12033fceb5 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFramePaneUI.java
@@ -91,7 +91,7 @@ public class AquaInternalFramePaneUI extends BasicDesktopPaneUI implements Mouse
JComponent getDock() {
if (fDock == null) {
fDock = new Dock(desktop);
- desktop.add(fDock, new Integer(399)); // Just below the DRAG_LAYER
+ desktop.add(fDock, Integer.valueOf(399)); // Just below the DRAG_LAYER
}
return fDock;
}
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java
index f04d42de03b..6694dd4c292 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java
@@ -416,7 +416,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"Button.select", selected,
"Button.border",(LazyValue) t -> AquaButtonBorder.getDynamicButtonBorder(),
"Button.font", controlFont,
- "Button.textIconGap", new Integer(4),
+ "Button.textIconGap", Integer.valueOf(4),
"Button.textShiftOffset", zero, // radar 3308129 - aqua doesn't move images when pressed.
"Button.focusInputMap", controlFocusInputMap,
"Button.margin", new InsetsUIResource(0, 2, 0, 2),
@@ -635,8 +635,8 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
//"Menu.checkIcon", emptyCheckIcon, // A non-drawing GlyphIcon to make the spacing consistent
"Menu.arrowIcon",(LazyValue) t -> AquaImageFactory.getMenuArrowIcon(),
"Menu.consumesTabs", Boolean.TRUE,
- "Menu.menuPopupOffsetY", new Integer(1),
- "Menu.submenuPopupOffsetY", new Integer(-4),
+ "Menu.menuPopupOffsetY", Integer.valueOf(1),
+ "Menu.submenuPopupOffsetY", Integer.valueOf(-4),
"MenuBar.font", menuFont,
"MenuBar.background", menuBackgroundColor, // not a menu item, not selected
@@ -694,7 +694,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"OptionPane.informationSound", null, // Info and Plain
"OptionPane.questionSound", null,
"OptionPane.warningSound", null,
- "OptionPane.buttonClickThreshhold", new Integer(500),
+ "OptionPane.buttonClickThreshhold", Integer.valueOf(500),
"OptionPane.yesButtonMnemonic", "",
"OptionPane.noButtonMnemonic", "",
"OptionPane.okButtonMnemonic", "",
@@ -717,7 +717,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"PasswordField.caretBlinkRate", textCaretBlinkRate,
"PasswordField.border", textFieldBorder,
"PasswordField.margin", zeroInsets,
- "PasswordField.echoChar", new Character((char)0x25CF),
+ "PasswordField.echoChar", Character.valueOf((char)0x25CF),
"PasswordField.capsLockIconColor", textPasswordFieldCapsLockIconColor,
"PopupMenu.font", menuFont,
@@ -736,7 +736,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"ProgressBar.selectionForeground", black,
"ProgressBar.selectionBackground", white,
"ProgressBar.border", new BorderUIResource(BorderFactory.createEmptyBorder()),
- "ProgressBar.repaintInterval", new Integer(20),
+ "ProgressBar.repaintInterval", Integer.valueOf(20),
"RadioButton.background", controlBackgroundColor,
"RadioButton.foreground", black,
@@ -772,7 +772,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"ScrollBar.border", null,
"ScrollBar.focusInputMap", aquaKeyBindings.getScrollBarInputMap(),
"ScrollBar.focusInputMap.RightToLeft", aquaKeyBindings.getScrollBarRightToLeftInputMap(),
- "ScrollBar.width", new Integer(16),
+ "ScrollBar.width", Integer.valueOf(16),
"ScrollBar.background", white,
"ScrollBar.foreground", black,
@@ -816,7 +816,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
//"SplitPane.shadow", table.get("controlShadow"),
"SplitPane.background", panelBackgroundColor,
"SplitPane.border", scollListBorder,
- "SplitPane.dividerSize", new Integer(9), //$
+ "SplitPane.dividerSize", Integer.valueOf(9), //$
"SplitPaneDivider.border", null, // AquaSplitPaneDividerUI draws it
"SplitPaneDivider.horizontalGradientVariant",(LazyValue) t -> AquaSplitPaneDividerUI.getHorizontalSplitDividerGradientVariant(),
@@ -833,7 +833,7 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
//"TabbedPane.darkShadow", table.get("controlDkShadow"),
//"TabbedPane.focus", table.get("controlText"),
"TabbedPane.opaque", useOpaqueComponents,
- "TabbedPane.textIconGap", new Integer(4),
+ "TabbedPane.textIconGap", Integer.valueOf(4),
"TabbedPane.tabInsets", new InsetsUIResource(0, 10, 3, 10), // Label within tab (top, left, bottom, right)
//"TabbedPane.rightTabInsets", new InsetsUIResource(0, 10, 3, 10), // Label within tab (top, left, bottom, right)
"TabbedPane.leftTabInsets", new InsetsUIResource(0, 10, 3, 10), // Label within tab
@@ -973,9 +973,9 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
"Tree.selectionBorderColor", selectionBackground, // match the background so it looks like we don't draw anything
"Tree.editorBorderSelectionColor", null, // The EditTextFrame provides its own border
// "Tree.editorBorder", textFieldBorder, // If you still have Sun bug 4376328 in DefaultTreeCellEditor, it has to have the same insets as TextField.border
- "Tree.leftChildIndent", new Integer(7),//$
- "Tree.rightChildIndent", new Integer(13),//$
- "Tree.rowHeight", new Integer(19),// iconHeight + 3, to match finder - a zero would have the renderer decide, except that leaves the icons touching
+ "Tree.leftChildIndent", Integer.valueOf(7),//$
+ "Tree.rightChildIndent", Integer.valueOf(13),//$
+ "Tree.rowHeight", Integer.valueOf(19),// iconHeight + 3, to match finder - a zero would have the renderer decide, except that leaves the icons touching
"Tree.scrollsOnExpand", Boolean.FALSE,
"Tree.openIcon",(LazyValue) t -> AquaImageFactory.getTreeOpenFolderIcon(), // Open folder icon
"Tree.closedIcon",(LazyValue) t -> AquaImageFactory.getTreeFolderIcon(), // Closed folder icon
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java
index d85ed9e8f67..ad78bc26ca3 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java
@@ -521,7 +521,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
}
// [2165820] Mac OS X change: mnemonics need to be triggered with ctrl-option, not just option.
mnemonicInputMap.put(KeyStroke.getKeyStroke(mnemonic, Event.ALT_MASK | Event.CTRL_MASK), "setSelectedIndex");
- mnemonicToIndexMap.put(new Integer(mnemonic), new Integer(index));
+ mnemonicToIndexMap.put(Integer.valueOf(mnemonic), Integer.valueOf(index));
}
/**
@@ -2084,7 +2084,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
if (mnemonic >= 'a' && mnemonic <= 'z') {
mnemonic -= ('a' - 'A');
}
- final Integer index = ui.mnemonicToIndexMap.get(new Integer(mnemonic));
+ final Integer index = ui.mnemonicToIndexMap.get(Integer.valueOf(mnemonic));
if (index != null && pane.isEnabledAt(index.intValue())) {
pane.setSelectedIndex(index.intValue());
}
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java
index 2acc1eaedcf..999d24a7886 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtilControlSize.java
@@ -268,7 +268,7 @@ public class AquaUtilControlSize {
public SizeVariant alterFontSize(final float newSize) {
final float oldSize = fontSize == null ? 0.0f : fontSize.floatValue();
- fontSize = new Float(newSize + oldSize);
+ fontSize = newSize + oldSize;
return this;
}
diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java
index bb2c0f1081b..b08b890aa2b 100644
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/ScreenPopupFactory.java
@@ -32,8 +32,8 @@ import sun.lwawt.macosx.CPlatformWindow;
import sun.swing.SwingAccessor;
class ScreenPopupFactory extends PopupFactory {
- static final Float TRANSLUCENT = new Float(248f/255f);
- static final Float OPAQUE = new Float(1.0f);
+ static final Float TRANSLUCENT = 248f/255f;
+ static final Float OPAQUE = 1.0f;
boolean fIsActive = true;
diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
index c50533a5947..ed3838886c9 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CStrike.java
@@ -386,7 +386,7 @@ public final class CStrike extends PhysicalStrike {
if (generalCache == null) {
return 0L;
}
- final Long value = generalCache.get(new Integer(index));
+ final Long value = generalCache.get(Integer.valueOf(index));
if (value == null) {
return 0L;
}
@@ -415,7 +415,7 @@ public final class CStrike extends PhysicalStrike {
generalCache = new HashMap();
}
- generalCache.put(new Integer(index), Long.valueOf(value));
+ generalCache.put(Integer.valueOf(index), Long.valueOf(value));
}
public synchronized void dispose() {
@@ -526,7 +526,7 @@ public final class CStrike extends PhysicalStrike {
}
if (generalCache == null) return 0;
- final Float value = generalCache.get(new Integer(index));
+ final Float value = generalCache.get(Integer.valueOf(index));
if (value == null) return 0;
return value.floatValue();
}
@@ -553,7 +553,7 @@ public final class CStrike extends PhysicalStrike {
generalCache = new HashMap();
}
- generalCache.put(new Integer(index), new Float(value));
+ generalCache.put(Integer.valueOf(index), Float.valueOf(value));
}
private static class SparseBitShiftingTwoLayerArray {
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java
index d0a3f65ed58..a024da398b5 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -903,7 +903,7 @@ public abstract class LWComponentPeer
@Override
public boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
focusLog.finest("lightweightChild=" + lightweightChild + ", temporary=" + temporary +
@@ -1278,7 +1278,7 @@ public abstract class LWComponentPeer
assert (e.getSource() == target);
if (!target.isFocusOwner() && LWKeyboardFocusManagerPeer.shouldFocusOnClick(target)) {
- LWKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
+ LWKeyboardFocusManagerPeer.requestFocusFor(target, FocusEvent.Cause.MOUSE_EVENT);
}
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java
index 4491b7c9c05..8205956b649 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWLightweightFramePeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,8 +31,8 @@ import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.dnd.DropTarget;
+import java.awt.event.FocusEvent;
-import sun.awt.CausedFocusEvent;
import sun.awt.LightweightFrame;
import sun.swing.JLightweightFrame;
import sun.swing.SwingAccessor;
@@ -60,7 +60,7 @@ public class LWLightweightFramePeer extends LWWindowPeer {
}
@Override
- public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+ public boolean requestWindowFocus(FocusEvent.Cause cause) {
if (!focusAllowedFor()) {
return false;
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java
index b7262a5a402..daa02981c27 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java
@@ -404,6 +404,10 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
public final PrintJob getPrintJob(Frame frame, String doctitle,
JobAttributes jobAttributes,
PageAttributes pageAttributes) {
+ if (frame == null) {
+ throw new NullPointerException("frame must not be null");
+ }
+
if (GraphicsEnvironment.isHeadless()) {
throw new IllegalArgumentException();
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
index fabc2a21ba1..658be0638bb 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -256,14 +256,14 @@ public class LWWindowPeer
if (!getTarget().isAutoRequestFocus()) {
return;
} else {
- requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
+ requestWindowFocus(FocusEvent.Cause.ACTIVATION);
}
// Focus the owner in case this window is focused.
} else if (kfmPeer.getCurrentFocusedWindow() == getTarget()) {
// Transfer focus to the owner.
LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this);
if (owner != null) {
- owner.requestWindowFocus(CausedFocusEvent.Cause.ACTIVATION);
+ owner.requestWindowFocus(FocusEvent.Cause.ACTIVATION);
}
}
}
@@ -295,7 +295,7 @@ public class LWWindowPeer
if (f == null) {
f = DEFAULT_FONT;
}
- return platformWindow.transformGraphics(new SunGraphics2D(getSurfaceData(), fg, bg, f));
+ return new SunGraphics2D(getSurfaceData(), fg, bg, f);
}
@Override
@@ -848,7 +848,7 @@ public class LWWindowPeer
// 2. An active but not focused owner frame/dialog is clicked.
// The mouse event then will trigger a focus request "in window" to the component, so the window
// should gain focus before.
- requestWindowFocus(CausedFocusEvent.Cause.MOUSE_EVENT);
+ requestWindowFocus(FocusEvent.Cause.MOUSE_EVENT);
mouseDownTarget[targetIdx] = targetPeer;
} else if (id == MouseEvent.MOUSE_DRAGGED) {
@@ -1199,7 +1199,7 @@ public class LWWindowPeer
* Requests platform to set native focus on a frame/dialog.
* In case of a simple window, triggers appropriate java focus change.
*/
- public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+ public boolean requestWindowFocus(FocusEvent.Cause cause) {
if (focusLog.isLoggable(PlatformLogger.Level.FINE)) {
focusLog.fine("requesting native focus to " + this);
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java
index 06bc5f48a83..0e3be9d81a1 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/PlatformWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,8 @@
package sun.lwawt;
import java.awt.*;
+import java.awt.event.FocusEvent;
-import sun.awt.CausedFocusEvent;
import sun.java2d.SurfaceData;
// TODO Is it worth to generify this interface, like that:
@@ -114,7 +114,7 @@ public interface PlatformWindow {
public void updateFocusableWindowState();
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause);
+ public boolean rejectFocusRequest(FocusEvent.Cause cause);
public boolean requestWindowFocus();
@@ -130,12 +130,6 @@ public interface PlatformWindow {
*/
public void setSizeConstraints(int minW, int minH, int maxW, int maxH);
- /**
- * Transforms the given Graphics object according to the native
- * implementation traits (insets, etc.).
- */
- public Graphics transformGraphics(Graphics g);
-
/*
* Installs the images for particular window.
*/
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java
new file mode 100644
index 00000000000..c575590802b
--- /dev/null
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/AccessibilityEventMonitor.java
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.lwawt.macosx;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+import javax.swing.event.EventListenerList;
+
+/**
+ * {@code AccessibilityEventMonitor} implements a PropertyChange listener
+ * on every UI object that implements interface {@code Accessible} in the Java
+ * Virtual Machine. The events captured by these listeners are made available
+ * through listeners supported by {@code AccessibilityEventMonitor}.
+ * With this, all the individual events on each of the UI object
+ * instances are funneled into one set of PropertyChange listeners.
+ *
+ * This code is a subset of com.sun.java.accessibility.util.AccessibilityEventMonitor
+ * which resides in module jdk.accessibility. Due to modularization the code in
+ * this package, java.desktop, can not be dependent on code in jdk.accessibility.
+ */
+
+class AccessibilityEventMonitor {
+
+ /**
+ * The current list of registered {@link java.beans.PropertyChangeListener
+ * PropertyChangeListener} classes.
+ *
+ * @see #addPropertyChangeListener
+ */
+ private static final EventListenerList listenerList =
+ new EventListenerList();
+
+
+ /**
+ * The actual listener that is installed on the component instances.
+ * This listener calls the other registered listeners when an event
+ * occurs. By doing things this way, the actual number of listeners
+ * installed on a component instance is drastically reduced.
+ */
+ private static final AccessibilityEventListener accessibilityListener =
+ new AccessibilityEventListener();
+
+ /**
+ * Adds the specified listener to receive all PropertyChange events on
+ * each UI object instance in the Java Virtual Machine as they occur.
+ *
Note: This listener is automatically added to all component
+ * instances created after this method is called. In addition, it
+ * is only added to UI object instances that support this listener type.
+ *
+ * @param l the listener to add
+ * @param a the Accessible object to add the PropertyChangeListener to
+ */
+
+ static void addPropertyChangeListener(PropertyChangeListener l, Accessible a) {
+ if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) {
+ accessibilityListener.installListeners(a);
+ }
+ listenerList.add(PropertyChangeListener.class, l);
+ }
+
+ /**
+ * AccessibilityEventListener is the class that does all the work for
+ * AccessibilityEventMonitor. It is not intended for use by any other
+ * class except AccessibilityEventMonitor.
+ */
+
+ private static class AccessibilityEventListener implements PropertyChangeListener {
+
+ /**
+ * Installs PropertyChange listeners to the Accessible object, and its
+ * children (so long as the object isn't of TRANSIENT state).
+ *
+ * @param a the Accessible object to add listeners to
+ */
+ private void installListeners(Accessible a) {
+ installListeners(a.getAccessibleContext());
+ }
+
+ /**
+ * Installs PropertyChange listeners to the AccessibleContext object,
+ * and its * children (so long as the object isn't of TRANSIENT state).
+ *
+ * @param ac the AccessibleContext to add listeners to
+ */
+ private void installListeners(AccessibleContext ac) {
+
+ if (ac != null) {
+ AccessibleStateSet states = ac.getAccessibleStateSet();
+ if (!states.contains(AccessibleState.TRANSIENT)) {
+ ac.addPropertyChangeListener(this);
+ /*
+ * Don't add listeners to transient children. Components
+ * with transient children should return an AccessibleStateSet
+ * containing AccessibleState.MANAGES_DESCENDANTS. Components
+ * may not explicitly return the MANAGES_DESCENDANTS state.
+ * In this case, don't add listeners to the children of
+ * lists, tables and trees.
+ */
+ AccessibleStateSet set = ac.getAccessibleStateSet();
+ if (set.contains(AccessibleState.MANAGES_DESCENDANTS)) {
+ return;
+ }
+ AccessibleRole role = ac.getAccessibleRole();
+ if ( role == AccessibleRole.LIST ||
+ role == AccessibleRole.TREE ) {
+ return;
+ }
+ if (role == AccessibleRole.TABLE) {
+ // handle Oracle tables containing tables
+ Accessible child = ac.getAccessibleChild(0);
+ if (child != null) {
+ AccessibleContext ac2 = child.getAccessibleContext();
+ if (ac2 != null) {
+ role = ac2.getAccessibleRole();
+ if (role != null && role != AccessibleRole.TABLE) {
+ return;
+ }
+ }
+ }
+ }
+ int count = ac.getAccessibleChildrenCount();
+ for (int i = 0; i < count; i++) {
+ Accessible child = ac.getAccessibleChild(i);
+ if (child != null) {
+ installListeners(child);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes PropertyChange listeners for the given Accessible object,
+ * its children (so long as the object isn't of TRANSIENT state).
+ *
+ * @param a the Accessible object to remove listeners from
+ */
+ private void removeListeners(Accessible a) {
+ removeListeners(a.getAccessibleContext());
+ }
+
+ /**
+ * Removes PropertyChange listeners for the given AccessibleContext
+ * object, its children (so long as the object isn't of TRANSIENT
+ * state).
+ *
+ * @param a the Accessible object to remove listeners from
+ */
+ private void removeListeners(AccessibleContext ac) {
+
+ if (ac != null) {
+ // Listeners are not added to transient components.
+ AccessibleStateSet states = ac.getAccessibleStateSet();
+ if (!states.contains(AccessibleState.TRANSIENT)) {
+ ac.removePropertyChangeListener(this);
+ /*
+ * Listeners are not added to transient children. Components
+ * with transient children should return an AccessibleStateSet
+ * containing AccessibleState.MANAGES_DESCENDANTS. Components
+ * may not explicitly return the MANAGES_DESCENDANTS state.
+ * In this case, don't remove listeners from the children of
+ * lists, tables and trees.
+ */
+ if (states.contains(AccessibleState.MANAGES_DESCENDANTS)) {
+ return;
+ }
+ AccessibleRole role = ac.getAccessibleRole();
+ if ( role == AccessibleRole.LIST ||
+ role == AccessibleRole.TABLE ||
+ role == AccessibleRole.TREE ) {
+ return;
+ }
+ int count = ac.getAccessibleChildrenCount();
+ for (int i = 0; i < count; i++) {
+ Accessible child = ac.getAccessibleChild(i);
+ if (child != null) {
+ removeListeners(child);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ // propogate the event
+ Object[] listeners =
+ AccessibilityEventMonitor.listenerList.getListenerList();
+ for (int i = listeners.length-2; i>=0; i-=2) {
+ if (listeners[i]==PropertyChangeListener.class) {
+ ((PropertyChangeListener)listeners[i+1]).propertyChange(e);
+ }
+ }
+
+ // handle childbirth/death
+ String name = e.getPropertyName();
+ if (name.compareTo(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) == 0) {
+ Object oldValue = e.getOldValue();
+ Object newValue = e.getNewValue();
+
+ if ((oldValue == null) ^ (newValue == null)) { // one null, not both
+ if (oldValue != null) {
+ // this Accessible is a child that's going away
+ if (oldValue instanceof Accessible) {
+ Accessible a = (Accessible) oldValue;
+ removeListeners(a.getAccessibleContext());
+ } else if (oldValue instanceof AccessibleContext) {
+ removeListeners((AccessibleContext) oldValue);
+ }
+ } else if (newValue != null) {
+ // this Accessible is a child was just born
+ if (newValue instanceof Accessible) {
+ Accessible a = (Accessible) newValue;
+ installListeners(a.getAccessibleContext());
+ } else if (newValue instanceof AccessibleContext) {
+ installListeners((AccessibleContext) newValue);
+ }
+ }
+ } else {
+ System.out.println("ERROR in usage of PropertyChangeEvents for: " + e.toString());
+ }
+ }
+ }
+ }
+}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java
index c5611c4d453..20ce3551d94 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,20 +26,18 @@
package sun.lwawt.macosx;
import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.lang.reflect.Field;
import javax.accessibility.Accessible;
import javax.accessibility.AccessibleContext;
import javax.swing.JProgressBar;
import javax.swing.JSlider;
-import javax.swing.event.CaretEvent;
-import javax.swing.event.CaretListener;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.text.JTextComponent;
+import sun.lwawt.macosx.CFRetainedResource;
class CAccessible extends CFRetainedResource implements Accessible {
static Field getNativeAXResourceField() {
@@ -99,13 +97,10 @@ class CAccessible extends CFRetainedResource implements Accessible {
return accessible.getAccessibleContext();
}
- // currently only supports text components
public void addNotificationListeners(Component c) {
- if (c instanceof JTextComponent) {
- JTextComponent tc = (JTextComponent) c;
- AXTextChangeNotifier listener = new AXTextChangeNotifier();
- tc.getDocument().addDocumentListener(listener);
- tc.addCaretListener(listener);
+ AXTextChangeNotifier listener = new AXTextChangeNotifier();
+ if (c instanceof Accessible) {
+ AccessibilityEventMonitor.addPropertyChangeListener(listener, (Accessible)c);
}
if (c instanceof JProgressBar) {
JProgressBar pb = (JProgressBar) c;
@@ -117,29 +112,23 @@ class CAccessible extends CFRetainedResource implements Accessible {
}
- private class AXTextChangeNotifier implements DocumentListener, CaretListener {
- @Override
- public void changedUpdate(DocumentEvent e) {
- if (ptr != 0) valueChanged(ptr);
- }
+ private class AXTextChangeNotifier implements PropertyChangeListener {
@Override
- public void insertUpdate(DocumentEvent e) {
- if (ptr != 0) valueChanged(ptr);
- }
-
- @Override
- public void removeUpdate(DocumentEvent e) {
- if (ptr != 0) valueChanged(ptr);
- }
-
- @Override
- public void caretUpdate(CaretEvent e) {
- if (ptr != 0) selectionChanged(ptr);
+ public void propertyChange(PropertyChangeEvent e) {
+ String name = e.getPropertyName();
+ if ( ptr != 0 ) {
+ if (name.compareTo(AccessibleContext.ACCESSIBLE_CARET_PROPERTY) == 0) {
+ selectionChanged(ptr);
+ } else if (name.compareTo(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY) == 0 ) {
+ valueChanged(ptr);
+ }
+ }
}
}
private class AXProgressChangeNotifier implements ChangeListener {
+ @Override
public void stateChanged(ChangeEvent e) {
if (ptr != 0) valueChanged(ptr);
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java
index 34651baba70..e232541c4e3 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
package sun.lwawt.macosx;
import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
import java.awt.peer.*;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.event.*;
@@ -34,7 +35,6 @@ import java.security.AccessController;
import java.util.List;
import java.io.*;
-import sun.awt.CausedFocusEvent.Cause;
import sun.awt.AWTAccessor;
import sun.java2d.pipe.Region;
import sun.security.action.GetBooleanAction;
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
index f6ab6bbb4ad..d7c6d2903f6 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,11 +26,11 @@
package sun.lwawt.macosx;
import java.awt.*;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent;
+
import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLLayer;
import sun.lwawt.LWWindowPeer;
-import sun.lwawt.LWWindowPeer.PeerType;
import sun.lwawt.PlatformWindow;
import sun.util.logging.PlatformLogger;
@@ -39,7 +39,8 @@ import sun.util.logging.PlatformLogger;
*/
public class CPlatformEmbeddedFrame implements PlatformWindow {
- private static final PlatformLogger focusLogger = PlatformLogger.getLogger("sun.lwawt.macosx.focus.CPlatformEmbeddedFrame");
+ private static final PlatformLogger focusLogger = PlatformLogger.getLogger(
+ "sun.lwawt.macosx.focus.CPlatformEmbeddedFrame");
private CGLLayer windowLayer;
private LWWindowPeer peer;
@@ -133,9 +134,9 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
public void updateFocusableWindowState() {}
@Override
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+ public boolean rejectFocusRequest(FocusEvent.Cause cause) {
// Cross-app activation requests are not allowed.
- if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
+ if (cause != FocusEvent.Cause.MOUSE_EVENT &&
!target.isParentWindowActive())
{
focusLogger.fine("the embedder is inactive, so the request is rejected");
@@ -160,11 +161,6 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
@Override
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {}
- @Override
- public Graphics transformGraphics(Graphics g) {
- return g;
- }
-
@Override
public void updateIconImages() {}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
index 0d9f9744c41..a056df5cc10 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformLWWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@ package sun.lwawt.macosx;
import java.awt.Font;
import java.awt.FontMetrics;
-import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
@@ -37,7 +36,7 @@ import java.awt.Rectangle;
import java.awt.Window;
import sun.awt.CGraphicsDevice;
import sun.awt.CGraphicsEnvironment;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent;
import sun.awt.LightweightFrame;
import sun.java2d.SurfaceData;
import sun.lwawt.LWLightweightFramePeer;
@@ -134,7 +133,7 @@ public class CPlatformLWWindow extends CPlatformWindow {
}
@Override
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+ public boolean rejectFocusRequest(FocusEvent.Cause cause) {
return false;
}
@@ -152,11 +151,6 @@ public class CPlatformLWWindow extends CPlatformWindow {
public void updateFocusableWindowState() {
}
- @Override
- public Graphics transformGraphics(Graphics g) {
- return null;
- }
-
@Override
public void setAlwaysOnTop(boolean isAlwaysOnTop) {
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
index a9214b45ba7..f0d0a22b3bc 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -706,9 +706,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
}
@Override
- public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) {
+ public boolean rejectFocusRequest(FocusEvent.Cause cause) {
// Cross-app activation requests are not allowed.
- if (cause != CausedFocusEvent.Cause.MOUSE_EVENT &&
+ if (cause != FocusEvent.Cause.MOUSE_EVENT &&
!((LWCToolkit)Toolkit.getDefaultToolkit()).isApplicationActive())
{
focusLogger.fine("the app is inactive, so the request is rejected");
@@ -740,12 +740,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
setStyleBits(SHOULD_BECOME_KEY | SHOULD_BECOME_MAIN, isFocusable); // set both bits at once
}
- @Override
- public Graphics transformGraphics(Graphics g) {
- // is this where we can inject a transform for HiDPI?
- return g;
- }
-
@Override
public void setAlwaysOnTop(boolean isAlwaysOnTop) {
setStyleBits(ALWAYS_ON_TOP, isAlwaysOnTop);
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java
index 2d82a2eb1c1..abd092b8be9 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java
@@ -98,15 +98,26 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
private native long nativeCreate();
//invocation from the AWTTrayIcon.m
- public long getPopupMenuModel(){
- if(popup == null) {
- PopupMenu popupMenu = target.getPopupMenu();
- if (popupMenu != null) {
- popup = popupMenu;
+ public long getPopupMenuModel() {
+ PopupMenu newPopup = target.getPopupMenu();
+
+ if (popup == newPopup) {
+ if (popup == null) {
+ return 0L;
+ }
+ } else {
+ if (newPopup != null) {
+ if (popup != null) {
+ popup.removeNotify();
+ popup = newPopup;
+ } else {
+ popup = newPopup;
+ }
} else {
return 0L;
}
}
+
return checkAndCreatePopupPeer().getModel();
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java
index 095922047fe..5fbb825a342 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewEmbeddedFrame.java
@@ -87,23 +87,22 @@ public class CViewEmbeddedFrame extends EmbeddedFrame {
}
}
- /*
+ /**
* Initializes the embedded frame bounds and validates a component.
- * Designed to be called from the main thread
- * This method should be called once from the initialization of the SWT_AWT Bridge
+ * Designed to be called from the main thread. This method should be called
+ * once from the initialization of the SWT_AWT Bridge.
*/
- public void validateWithBounds(final int x, final int y, final int width, final int height) {
+ public void validateWithBounds(final int x, final int y, final int width,
+ final int height) {
try {
- final LWWindowPeer peer = AWTAccessor.getComponentAccessor()
- .getPeer(this);
- LWCToolkit.invokeAndWait(new Runnable() {
- @Override
- public void run() {
- peer.setBoundsPrivate(0, 0, width, height);
- validate();
- setVisible(true);
- }
+ LWCToolkit.invokeAndWait(() -> {
+ final LWWindowPeer peer = AWTAccessor.getComponentAccessor()
+ .getPeer(this);
+ peer.setBoundsPrivate(0, 0, width, height);
+ validate();
+ setVisible(true);
}, this);
- } catch (InvocationTargetException ex) {}
+ } catch (InvocationTargetException ex) {
+ }
}
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
index 1c11789713f..2312fbb94be 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CViewPlatformEmbeddedFrame.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,12 @@ package sun.lwawt.macosx;
import java.awt.Font;
import java.awt.FontMetrics;
-import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.Insets;
import java.awt.MenuBar;
import java.awt.Point;
import java.awt.Window;
-import sun.awt.CausedFocusEvent.Cause;
+import java.awt.event.FocusEvent.Cause;
import sun.java2d.SurfaceData;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformWindow;
@@ -170,11 +169,6 @@ public class CViewPlatformEmbeddedFrame implements PlatformWindow {
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
}
- @Override
- public Graphics transformGraphics(Graphics g) {
- return g;
- }
-
@Override
public void updateIconImages() {
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java
index b2c36705a09..28a4b657e55 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -364,8 +364,8 @@ public final class CWarningWindow extends CPlatformWindow
return null;
}
- return transformGraphics(new SunGraphics2D(sd, SystemColor.windowText,
- SystemColor.window, ownerWindow.getFont()));
+ return new SunGraphics2D(sd, SystemColor.windowText, SystemColor.window,
+ ownerWindow.getFont());
}
diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
index f0bf99c7321..309bc8ca8b1 100644
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
@@ -378,9 +378,9 @@ public final class LWCToolkit extends LWToolkit {
// These DnD properties must be set, otherwise Swing ends up spewing NPEs
// all over the place. The values came straight off of MToolkit.
- desktopProperties.put("DnD.Autoscroll.initialDelay", new Integer(50));
- desktopProperties.put("DnD.Autoscroll.interval", new Integer(50));
- desktopProperties.put("DnD.Autoscroll.cursorHysteresis", new Integer(5));
+ desktopProperties.put("DnD.Autoscroll.initialDelay", Integer.valueOf(50));
+ desktopProperties.put("DnD.Autoscroll.interval", Integer.valueOf(50));
+ desktopProperties.put("DnD.Autoscroll.cursorHysteresis", Integer.valueOf(5));
desktopProperties.put("DnD.isDragImageSupported", Boolean.TRUE);
diff --git a/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java b/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java
index 69fbdce51dd..f753e04e83a 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/beans/decoder/NewElementHandler.java
@@ -42,7 +42,7 @@ import java.util.List;
* <new class="java.lang.Long">
* <string>10</string>
* </new>
- * is equivalent to {@code new Long("10")} in Java code.
+ * is equivalent to {@code Long.valueOf("10")} in Java code.
*
The following attributes are supported:
*
* class
diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java
index d955c5f593c..4510882ad4b 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPMetadata.java
@@ -128,7 +128,7 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants {
addChildNode(root, "BMPVersion", bmpVersion);
addChildNode(root, "Width", width);
addChildNode(root, "Height", height);
- addChildNode(root, "BitsPerPixel", new Short(bitsPerPixel));
+ addChildNode(root, "BitsPerPixel", Short.valueOf(bitsPerPixel));
addChildNode(root, "Compression", compression);
addChildNode(root, "ImageSize", imageSize);
@@ -172,12 +172,12 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants {
red = palette[j++] & 0xff;
green = palette[j++] & 0xff;
blue = palette[j++] & 0xff;
- addChildNode(entry, "Red", new Byte((byte)red));
- addChildNode(entry, "Green", new Byte((byte)green));
- addChildNode(entry, "Blue", new Byte((byte)blue));
+ addChildNode(entry, "Red", Byte.valueOf((byte)red));
+ addChildNode(entry, "Green", Byte.valueOf((byte)green));
+ addChildNode(entry, "Blue", Byte.valueOf((byte)blue));
if (numComps == 4)
addChildNode(entry, "Alpha",
- new Byte((byte)(palette[j++] & 0xff)));
+ Byte.valueOf((byte)(palette[j++] & 0xff)));
}
}
@@ -284,9 +284,9 @@ public class BMPMetadata extends IIOMetadata implements BMPConstants {
private void addXYZPoints(IIOMetadataNode root, String name, double x, double y, double z) {
IIOMetadataNode node = addChildNode(root, name, null);
- addChildNode(node, "X", new Double(x));
- addChildNode(node, "Y", new Double(y));
- addChildNode(node, "Z", new Double(z));
+ addChildNode(node, "X", Double.valueOf(x));
+ addChildNode(node, "Y", Double.valueOf(y));
+ addChildNode(node, "Z", Double.valueOf(z));
}
private IIOMetadataNode addChildNode(IIOMetadataNode root,
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
index f52982a4461..940b0107a93 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -158,8 +158,8 @@ class GTKEngine {
int widgetType, int state, int shadowType, String detail,
int x, int y, int width, int height, int synthState, int dir);
private native void native_paint_slider(
- int widgetType, int state, int shadowType, String detail,
- int x, int y, int width, int height, int orientation);
+ int widgetType, int state, int shadowType, String detail, int x,
+ int y, int width, int height, int orientation, boolean hasFocus);
private native void native_paint_vline(
int widgetType, int state, String detail,
int x, int y, int width, int height);
@@ -491,6 +491,14 @@ class GTKEngine {
int gtkState =
GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
int synthState = context.getComponentState();
+ Container parent = context.getComponent().getParent();
+ if(GTKLookAndFeel.is3()) {
+ if (parent != null && parent.getParent() instanceof JComboBox) {
+ if (parent.getParent().hasFocus()) {
+ synthState |= SynthConstants.FOCUSED;
+ }
+ }
+ }
int dir = getTextDirection(context);
int widget = getWidgetType(context.getComponent(), id).ordinal();
native_paint_shadow(widget, gtkState, shadowType.ordinal(), detail,
@@ -498,13 +506,13 @@ class GTKEngine {
}
public void paintSlider(Graphics g, SynthContext context,
- Region id, int state, ShadowType shadowType, String detail,
- int x, int y, int w, int h, Orientation orientation) {
+ Region id, int state, ShadowType shadowType, String detail, int x,
+ int y, int w, int h, Orientation orientation, boolean hasFocus) {
state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
int widget = getWidgetType(context.getComponent(), id).ordinal();
native_paint_slider(widget, state, shadowType.ordinal(), detail,
- x - x0, y - y0, w, h, orientation.ordinal());
+ x - x0, y - y0, w, h, orientation.ordinal(), hasFocus);
}
public void paintVline(Graphics g, SynthContext context,
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
index 199806d133a..be422a6275b 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,8 @@ import sun.swing.SwingUtilities2;
*/
@SuppressWarnings("serial") // Superclass not serializable
public class GTKLookAndFeel extends SynthLookAndFeel {
- private static final boolean IS_22;
+ private static boolean IS_22;
+ private static boolean IS_3;
/**
* Whether or not text is drawn antialiased. This keys off the
@@ -107,17 +108,6 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
private static String gtkThemeName = "Default";
static {
- // Backup for specifying the version, this isn't currently documented.
- // If you pass in anything but 2.2 you got the 2.0 colors/look.
- String version = AccessController.doPrivileged(
- new GetPropertyAction("swing.gtk.version"));
- if (version != null) {
- IS_22 = version.equals("2.2");
- }
- else {
- IS_22 = true;
- }
-
String language = Locale.getDefault().getLanguage();
boolean cjkLocale =
(Locale.CHINESE.getLanguage().equals(language) ||
@@ -158,6 +148,10 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
return IS_22;
}
+ static boolean is3() {
+ return IS_3;
+ }
+
/**
* Maps a swing constant to a GTK constant.
*/
@@ -385,7 +379,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
}
Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
- Double defaultCaretAspectRatio = new Double(0.025);
+ Double defaultCaretAspectRatio = Double.valueOf(0.025);
Color caretColor = table.getColor("caretColor");
Color controlText = table.getColor("controlText");
@@ -1460,6 +1454,19 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
throw new InternalError("Unable to load native GTK libraries");
}
+ if (UNIXToolkit.getGtkVersion() == UNIXToolkit.GtkVersions.GTK2) {
+ String version = AccessController.doPrivileged(
+ new GetPropertyAction("jdk.gtk.version"));
+ if (version != null) {
+ IS_22 = version.equals("2.2");
+ } else {
+ IS_22 = true;
+ }
+ } else if (UNIXToolkit.getGtkVersion() ==
+ UNIXToolkit.GtkVersions.GTK3) {
+ IS_3 = true;
+ }
+
super.initialize();
inInitialize = true;
loadStyles();
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
index ad61aca85f1..a607d4c41d4 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -576,12 +576,11 @@ class GTKPainter extends SynthPainter {
ShadowType.OUT, "menu", x, y, w, h);
GTKStyle style = (GTKStyle)context.getStyle();
- int xThickness = style.getXThickness();
- int yThickness = style.getYThickness();
+ Insets insets = style.getInsets(context, null);
ENGINE.paintBackground(g, context, id, gtkState,
- style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
- x + xThickness, y + yThickness,
- w - xThickness - xThickness, h - yThickness - yThickness);
+ style.getGTKColor(context, gtkState, GTKColorType.BACKGROUND),
+ x + insets.left, y + insets.top, w - insets.left - insets.right,
+ h - insets.top - insets.bottom);
ENGINE.finishPainting();
}
}
@@ -640,6 +639,34 @@ class GTKPainter extends SynthPainter {
int state = context.getComponentState();
JComponent c = context.getComponent();
+ GTKStyle style = (GTKStyle) context.getStyle();
+ String detail;
+ // wide-separators are painted using box not line
+ if (style.getClassSpecificBoolValue(context,
+ "wide-separators", false)) {
+ Insets insets = c.getInsets();
+ x += insets.left;
+ y += insets.top;
+ if (orientation == JSeparator.HORIZONTAL) {
+ w -= (insets.left + insets.right);
+ detail = "hseparator";
+ } else {
+ h -= (insets.top + insets.bottom);
+ detail = "vseparator";
+ }
+ synchronized (UNIXToolkit.GTK_LOCK) {
+ if (! ENGINE.paintCachedImage(g, x, y, w, h, id, state,
+ detail, orientation)) {
+ ENGINE.startPainting(g, x, y, w, h, id, state,
+ detail, orientation);
+ ENGINE.paintBox(g, context, id, state,
+ ShadowType.ETCHED_OUT, detail, x, y, w, h);
+ ENGINE.finishPainting();
+ }
+ }
+ return;
+ }
+
/*
* Note: In theory, the style's x/y thickness values would determine
* the width of the separator content. In practice, however, some
@@ -650,7 +677,6 @@ class GTKPainter extends SynthPainter {
* the w/h values below too much, so that the full thickness of the
* rendered line will be captured by our image caching code.
*/
- String detail;
if (c instanceof JToolBar.Separator) {
/*
* GTK renders toolbar separators differently in that an
@@ -678,7 +704,6 @@ class GTKPainter extends SynthPainter {
float pct = 0.2f;
JToolBar.Separator sep = (JToolBar.Separator)c;
Dimension size = sep.getSeparatorSize();
- GTKStyle style = (GTKStyle)context.getStyle();
if (orientation == JSeparator.HORIZONTAL) {
x += (int)(w * pct);
w -= (int)(w * pct * 2);
@@ -743,6 +768,15 @@ class GTKPainter extends SynthPainter {
// The ubuntulooks engine paints slider troughs differently depending
// on the current slider value and its component orientation.
JSlider slider = (JSlider)context.getComponent();
+ if (GTKLookAndFeel.is3()) {
+ if (slider.getOrientation() == JSlider.VERTICAL) {
+ y += 1;
+ h -= 2;
+ } else {
+ x += 1;
+ w -= 2;
+ }
+ }
double value = slider.getValue();
double min = slider.getMinimum();
double max = slider.getMaximum();
@@ -776,15 +810,19 @@ class GTKPainter extends SynthPainter {
Region id = context.getRegion();
int gtkState = GTKLookAndFeel.synthStateToGTKState(
id, context.getComponentState());
+ boolean hasFocus = GTKLookAndFeel.is3() &&
+ ((context.getComponentState() & SynthConstants.FOCUSED) != 0);
synchronized (UNIXToolkit.GTK_LOCK) {
- if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir)) {
+ if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir,
+ hasFocus)) {
Orientation orientation = (dir == JSlider.HORIZONTAL ?
Orientation.HORIZONTAL : Orientation.VERTICAL);
String detail = (dir == JSlider.HORIZONTAL ?
"hscale" : "vscale");
ENGINE.startPainting(g, x, y, w, h, id, gtkState, dir);
ENGINE.paintSlider(g, context, id, gtkState,
- ShadowType.OUT, detail, x, y, w, h, orientation);
+ ShadowType.OUT, detail, x, y, w, h, orientation,
+ hasFocus);
ENGINE.finishPainting();
}
}
@@ -963,15 +1001,21 @@ class GTKPainter extends SynthPainter {
int yThickness = style.getYThickness();
ENGINE.startPainting(g, x, y, w, h, id, state);
+ if (GTKLookAndFeel.is3()) {
+ ENGINE.paintBackground(g, context, id, gtkState, null,
+ x, y, w, h);
+ }
ENGINE.paintShadow(g, context, id, gtkState,
ShadowType.IN, "entry", x, y, w, h);
- ENGINE.paintFlatBox(g, context, id,
- gtkState, ShadowType.NONE, "entry_bg",
- x + xThickness,
- y + yThickness,
- w - (2 * xThickness),
- h - (2 * yThickness),
- ColorType.TEXT_BACKGROUND);
+ if (!GTKLookAndFeel.is3()) {
+ ENGINE.paintFlatBox(g, context, id,
+ gtkState, ShadowType.NONE, "entry_bg",
+ x + xThickness,
+ y + yThickness,
+ w - (2 * xThickness),
+ h - (2 * yThickness),
+ ColorType.TEXT_BACKGROUND);
+ }
if (focusSize > 0 && (state & SynthConstants.FOCUSED) != 0) {
if (!interiorFocus) {
@@ -982,14 +1026,14 @@ class GTKPainter extends SynthPainter {
} else {
if (containerParent instanceof JComboBox) {
x += (focusSize + 2);
- y += (focusSize + 1);
- w -= (2 * focusSize + 1);
- h -= (2 * focusSize + 2);
+ y += focusSize + (GTKLookAndFeel.is3() ? 3 : 1);
+ w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 1);
+ h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 6 : 2);
} else {
- x += focusSize;
- y += focusSize;
- w -= 2 * focusSize;
- h -= 2 * focusSize;
+ x += focusSize + (GTKLookAndFeel.is3() ? 2 : 0);
+ y += focusSize + (GTKLookAndFeel.is3() ? 2 :0 );
+ w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0);
+ h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0);
}
}
ENGINE.paintFocus(g, context, id, gtkState,
@@ -1138,8 +1182,8 @@ class GTKPainter extends SynthPainter {
Orientation orientation = (dir == JScrollBar.HORIZONTAL ?
Orientation.HORIZONTAL : Orientation.VERTICAL);
ENGINE.setRangeValue(context, id, value, min, max, visible);
- ENGINE.paintSlider(g, context, id, gtkState,
- ShadowType.OUT, "slider", x, y, w, h, orientation);
+ ENGINE.paintSlider(g, context, id, gtkState, ShadowType.OUT,
+ "slider", x, y, w, h, orientation, false);
ENGINE.finishPainting();
}
}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
index 4fa44c758e5..2c60551dd04 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -715,29 +715,33 @@ class GTKStyle extends SynthStyle implements GTKConstants {
if (region == Region.COMBO_BOX ||
region == Region.DESKTOP_PANE ||
region == Region.DESKTOP_ICON ||
- region == Region.EDITOR_PANE ||
- region == Region.FORMATTED_TEXT_FIELD ||
region == Region.INTERNAL_FRAME ||
region == Region.LIST ||
region == Region.MENU_BAR ||
region == Region.PANEL ||
- region == Region.PASSWORD_FIELD ||
region == Region.POPUP_MENU ||
region == Region.PROGRESS_BAR ||
region == Region.ROOT_PANE ||
region == Region.SCROLL_PANE ||
- region == Region.SPINNER ||
region == Region.SPLIT_PANE_DIVIDER ||
region == Region.TABLE ||
region == Region.TEXT_AREA ||
- region == Region.TEXT_FIELD ||
- region == Region.TEXT_PANE ||
region == Region.TOOL_BAR_DRAG_WINDOW ||
region == Region.TOOL_TIP ||
region == Region.TREE ||
region == Region.VIEWPORT) {
return true;
}
+ if (!GTKLookAndFeel.is3()) {
+ if (region == Region.EDITOR_PANE ||
+ region == Region.FORMATTED_TEXT_FIELD ||
+ region == Region.PASSWORD_FIELD ||
+ region == Region.SPINNER ||
+ region == Region.TEXT_FIELD ||
+ region == Region.TEXT_PANE) {
+ return true;
+ }
+ }
Component c = context.getComponent();
String name = c.getName();
if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") {
@@ -776,6 +780,15 @@ class GTKStyle extends SynthStyle implements GTKConstants {
}
else if (key == "Separator.thickness") {
JSeparator sep = (JSeparator)context.getComponent();
+ if (getClassSpecificBoolValue(context, "wide-separators", false)) {
+ if (sep.getOrientation() == JSeparator.HORIZONTAL) {
+ return getClassSpecificIntValue(context,
+ "separator-height", 0);
+ } else {
+ return getClassSpecificIntValue(context,
+ "separator-width", 0);
+ }
+ }
if (sep.getOrientation() == JSeparator.HORIZONTAL) {
return getYThickness();
} else {
@@ -783,6 +796,12 @@ class GTKStyle extends SynthStyle implements GTKConstants {
}
}
else if (key == "ToolBar.separatorSize") {
+ if (getClassSpecificBoolValue(context, "wide-separators", false)) {
+ return new DimensionUIResource(
+ getClassSpecificIntValue(context, "separator-width", 2),
+ getClassSpecificIntValue(context, "separator-height", 2)
+ );
+ }
int size = getClassSpecificIntValue(WidgetType.TOOL_BAR,
"space-size", 12);
return new DimensionUIResource(size, size);
@@ -833,6 +852,8 @@ class GTKStyle extends SynthStyle implements GTKConstants {
int focusPad =
getClassSpecificIntValue(context, "focus-padding", 1);
return indicatorSpacing + focusSize + focusPad;
+ } else if (GTKLookAndFeel.is3() && "ComboBox.forceOpaque".equals(key)) {
+ return true;
}
// Is it a stock icon ?
@@ -1112,6 +1133,7 @@ class GTKStyle extends SynthStyle implements GTKConstants {
static {
CLASS_SPECIFIC_MAP = new HashMap();
CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width");
+ CLASS_SPECIFIC_MAP.put("Slider.thumbWidth", "slider-length");
CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border");
CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size");
CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size");
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
index 3a0342792b3..b8b77f5ec93 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java
@@ -185,7 +185,7 @@ class Metacity implements SynthConstants {
getIntAttr(child, "bottom", 0),
getIntAttr(child, "right", 0));
} else if ("aspect_ratio".equals(name)) {
- value = new Float(getFloatAttr(child, "value", 1.0F));
+ value = Float.valueOf(getFloatAttr(child, "value", 1.0F));
} else {
logError(themeName, "Unknown Metacity frame geometry value type: "+name);
}
diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java
index dab22fd293e..eb47262b29c 100644
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/AnimationController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,6 @@ import javax.swing.*;
-import sun.swing.UIClientPropertyKey;
import com.sun.java.swing.plaf.windows.TMSchema.State;
import static com.sun.java.swing.plaf.windows.TMSchema.State.*;
import com.sun.java.swing.plaf.windows.TMSchema.Part;
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java
index a01b9065c36..b2b51e08559 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Component.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,6 @@ import sun.awt.AWTAccessor;
import sun.awt.ConstrainableGraphics;
import sun.awt.SubRegionShowable;
import sun.awt.SunToolkit;
-import sun.awt.CausedFocusEvent;
import sun.awt.EmbeddedFrame;
import sun.awt.dnd.SunDropTargetEvent;
import sun.awt.im.CompositionArea;
@@ -878,7 +877,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
{
comp.setGraphicsConfiguration(gc);
}
- public boolean requestFocus(Component comp, CausedFocusEvent.Cause cause) {
+ public boolean requestFocus(Component comp, FocusEvent.Cause cause) {
return comp.requestFocus(cause);
}
public boolean canBeFocusOwner(Component comp) {
@@ -7538,7 +7537,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
requestFocusHelper(false, true);
}
- boolean requestFocus(CausedFocusEvent.Cause cause) {
+ boolean requestFocus(FocusEvent.Cause cause) {
return requestFocusHelper(false, true, cause);
}
@@ -7605,7 +7604,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
return requestFocusHelper(temporary, true);
}
- boolean requestFocus(boolean temporary, CausedFocusEvent.Cause cause) {
+ boolean requestFocus(boolean temporary, FocusEvent.Cause cause) {
return requestFocusHelper(temporary, true, cause);
}
/**
@@ -7656,7 +7655,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
return requestFocusHelper(false, false);
}
- boolean requestFocusInWindow(CausedFocusEvent.Cause cause) {
+ boolean requestFocusInWindow(FocusEvent.Cause cause) {
return requestFocusHelper(false, false, cause);
}
@@ -7721,18 +7720,18 @@ public abstract class Component implements ImageObserver, MenuContainer,
return requestFocusHelper(temporary, false);
}
- boolean requestFocusInWindow(boolean temporary, CausedFocusEvent.Cause cause) {
+ boolean requestFocusInWindow(boolean temporary, FocusEvent.Cause cause) {
return requestFocusHelper(temporary, false, cause);
}
final boolean requestFocusHelper(boolean temporary,
boolean focusedWindowChangeAllowed) {
- return requestFocusHelper(temporary, focusedWindowChangeAllowed, CausedFocusEvent.Cause.UNKNOWN);
+ return requestFocusHelper(temporary, focusedWindowChangeAllowed, FocusEvent.Cause.UNKNOWN);
}
final boolean requestFocusHelper(boolean temporary,
boolean focusedWindowChangeAllowed,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
// 1) Check if the event being dispatched is a system-generated mouse event.
AWTEvent currentEvent = EventQueue.getCurrentEvent();
@@ -7820,7 +7819,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
private boolean isRequestFocusAccepted(boolean temporary,
boolean focusedWindowChangeAllowed,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
if (!isFocusable() || !isVisible()) {
if (focusLog.isLoggable(PlatformLogger.Level.FINEST)) {
@@ -7867,7 +7866,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
return true;
}
- if (CausedFocusEvent.Cause.ACTIVATION == cause) {
+ if (FocusEvent.Cause.ACTIVATION == cause) {
// we shouldn't call RequestFocusController in case we are
// in activation. We do request focus on component which
// has got temporary focus lost and then on component which is
@@ -7899,7 +7898,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
private static class DummyRequestFocusController implements RequestFocusController {
public boolean acceptRequestFocus(Component from, Component to,
boolean temporary, boolean focusedWindowChangeAllowed,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
return true;
}
@@ -7983,7 +7982,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
Component toFocus = getNextFocusCandidate();
boolean res = false;
if (toFocus != null && !toFocus.isFocusOwner() && toFocus != this) {
- res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_FORWARD);
+ res = toFocus.requestFocusInWindow(FocusEvent.Cause.TRAVERSAL_FORWARD);
}
if (clearOnFailure && !res) {
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
@@ -8063,7 +8062,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
toFocus = policy.getDefaultComponent(rootAncestor);
}
if (toFocus != null) {
- res = toFocus.requestFocusInWindow(CausedFocusEvent.Cause.TRAVERSAL_BACKWARD);
+ res = toFocus.requestFocusInWindow(FocusEvent.Cause.TRAVERSAL_BACKWARD);
}
}
if (clearOnFailure && !res) {
@@ -8108,7 +8107,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRootPriv(fcr);
- rootAncestor.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
+ rootAncestor.requestFocus(FocusEvent.Cause.TRAVERSAL_UP);
} else {
Window window = getContainingWindow();
@@ -8118,7 +8117,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (toFocus != null) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
setGlobalCurrentFocusCycleRootPriv(window);
- toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_UP);
+ toFocus.requestFocus(FocusEvent.Cause.TRAVERSAL_UP);
}
}
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Container.java b/jdk/src/java.desktop/share/classes/java/awt/Container.java
index a16c2f55d97..04e3f1e89bd 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Container.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Container.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,6 @@ import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
@@ -3515,7 +3514,7 @@ public class Container extends Component {
Component toFocus = getFocusTraversalPolicy().
getDefaultComponent(this);
if (toFocus != null) {
- toFocus.requestFocus(CausedFocusEvent.Cause.TRAVERSAL_DOWN);
+ toFocus.requestFocus(FocusEvent.Cause.TRAVERSAL_DOWN);
}
}
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java
index b6f1bcfbe4e..ad23e21655a 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,6 @@ import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
import sun.awt.TimedWindowEvent;
/**
@@ -165,13 +164,13 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
boolean clearOnFailure)
{
if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
- toFocus.requestFocus(false, CausedFocusEvent.Cause.ROLLBACK))
+ toFocus.requestFocus(false, FocusEvent.Cause.ROLLBACK))
{
return true;
} else {
Component nextFocus = toFocus.getNextFocusCandidate();
if (nextFocus != null && nextFocus != vetoedComponent &&
- nextFocus.requestFocusInWindow(CausedFocusEvent.Cause.ROLLBACK))
+ nextFocus.requestFocusInWindow(FocusEvent.Cause.ROLLBACK))
{
return true;
} else if (clearOnFailure) {
@@ -431,13 +430,13 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
tempLost, toFocus);
}
if (tempLost != null) {
- tempLost.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+ tempLost.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
}
if (toFocus != null && toFocus != tempLost) {
// If there is a component which requested focus when this window
// was inactive it expects to receive focus after activation.
- toFocus.requestFocusInWindow(CausedFocusEvent.Cause.ACTIVATION);
+ toFocus.requestFocusInWindow(FocusEvent.Cause.ACTIVATION);
}
}
@@ -490,8 +489,6 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
case FocusEvent.FOCUS_GAINED: {
FocusEvent fe = (FocusEvent)e;
- CausedFocusEvent.Cause cause = (fe instanceof CausedFocusEvent) ?
- ((CausedFocusEvent)fe).getCause() : CausedFocusEvent.Cause.UNKNOWN;
Component oldFocusOwner = getGlobalFocusOwner();
Component newFocusOwner = fe.getComponent();
if (oldFocusOwner == newFocusOwner) {
@@ -509,10 +506,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
if (oldFocusOwner != null) {
boolean isEventDispatched =
sendMessage(oldFocusOwner,
- new CausedFocusEvent(oldFocusOwner,
+ new FocusEvent(oldFocusOwner,
FocusEvent.FOCUS_LOST,
fe.isTemporary(),
- newFocusOwner, cause));
+ newFocusOwner, fe.getCause()));
// Failed to dispatch, clear by ourselves
if (!isEventDispatched) {
setGlobalFocusOwner(null);
@@ -552,7 +549,7 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
// Refuse focus on a disabled component if the focus event
// isn't of UNKNOWN reason (i.e. not a result of a direct request
// but traversal, activation or system generated).
- (newFocusOwner.isEnabled() || cause.equals(CausedFocusEvent.Cause.UNKNOWN))))
+ (newFocusOwner.isEnabled() || fe.getCause().equals(FocusEvent.Cause.UNKNOWN))))
{
// we should not accept focus on such component, so reject it.
dequeueKeyEvents(-1, newFocusOwner);
@@ -601,10 +598,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
Component realOppositeComponent = this.realOppositeComponentWR.get();
if (realOppositeComponent != null &&
realOppositeComponent != fe.getOppositeComponent()) {
- fe = new CausedFocusEvent(newFocusOwner,
+ fe = new FocusEvent(newFocusOwner,
FocusEvent.FOCUS_GAINED,
fe.isTemporary(),
- realOppositeComponent, cause);
+ realOppositeComponent, fe.getCause());
((AWTEvent) fe).isPosted = true;
}
return typeAheadAssertions(newFocusOwner, fe);
@@ -729,10 +726,10 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
oppositeComp = oppositeWindow;
}
sendMessage(currentFocusOwner,
- new CausedFocusEvent(currentFocusOwner,
+ new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
true,
- oppositeComp, CausedFocusEvent.Cause.ACTIVATION));
+ oppositeComp, FocusEvent.Cause.ACTIVATION));
}
setGlobalFocusedWindow(null);
diff --git a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java
index 6b7d779a7db..aa9d64367a4 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -57,7 +57,6 @@ import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
-import sun.awt.CausedFocusEvent;
import sun.awt.KeyboardFocusManagerPeerProvider;
import sun.awt.AWTAccessor;
@@ -124,7 +123,7 @@ public abstract class KeyboardFocusManager
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
return KeyboardFocusManager.shouldNativelyFocusHeavyweight(
heavyweight, descendant, temporary, focusedWindowChangeAllowed, time, cause);
@@ -2164,9 +2163,9 @@ public abstract class KeyboardFocusManager
private static final class LightweightFocusRequest {
final Component component;
final boolean temporary;
- final CausedFocusEvent.Cause cause;
+ final FocusEvent.Cause cause;
- LightweightFocusRequest(Component component, boolean temporary, CausedFocusEvent.Cause cause) {
+ LightweightFocusRequest(Component component, boolean temporary, FocusEvent.Cause cause) {
this.component = component;
this.temporary = temporary;
this.cause = cause;
@@ -2190,7 +2189,7 @@ public abstract class KeyboardFocusManager
}
HeavyweightFocusRequest(Component heavyweight, Component descendant,
- boolean temporary, CausedFocusEvent.Cause cause) {
+ boolean temporary, FocusEvent.Cause cause) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (heavyweight == null) {
log.fine("Assertion (heavyweight != null) failed");
@@ -2202,7 +2201,7 @@ public abstract class KeyboardFocusManager
addLightweightRequest(descendant, temporary, cause);
}
boolean addLightweightRequest(Component descendant,
- boolean temporary, CausedFocusEvent.Cause cause) {
+ boolean temporary, FocusEvent.Cause cause) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
@@ -2314,7 +2313,7 @@ public abstract class KeyboardFocusManager
hwFocusRequest =
new HeavyweightFocusRequest(heavyweight, descendant,
- temporary, CausedFocusEvent.Cause.UNKNOWN);
+ temporary, FocusEvent.Cause.UNKNOWN);
heavyweightRequests.add(hwFocusRequest);
if (currentFocusOwner != null) {
@@ -2379,7 +2378,7 @@ public abstract class KeyboardFocusManager
*/
static int shouldNativelyFocusHeavyweight
(Component heavyweight, Component descendant, boolean temporary,
- boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
+ boolean focusedWindowChangeAllowed, long time, FocusEvent.Cause cause)
{
if (log.isLoggable(PlatformLogger.Level.FINE)) {
if (heavyweight == null) {
@@ -2445,7 +2444,7 @@ public abstract class KeyboardFocusManager
if (currentFocusOwner != null) {
FocusEvent currentFocusOwnerEvent =
- new CausedFocusEvent(currentFocusOwner,
+ new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
temporary, descendant, cause);
// Fix 5028014. Rolled out.
@@ -2454,7 +2453,7 @@ public abstract class KeyboardFocusManager
currentFocusOwnerEvent);
}
FocusEvent newFocusOwnerEvent =
- new CausedFocusEvent(descendant, FocusEvent.FOCUS_GAINED,
+ new FocusEvent(descendant, FocusEvent.FOCUS_GAINED,
temporary, currentFocusOwner, cause);
// Fix 5028014. Rolled out.
// SunToolkit.postPriorityEvent(newFocusOwnerEvent);
@@ -2670,13 +2669,13 @@ public abstract class KeyboardFocusManager
* lw requests.
*/
if (currentFocusOwner != null) {
- currentFocusOwnerEvent = new CausedFocusEvent(currentFocusOwner,
+ currentFocusOwnerEvent = new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
lwFocusRequest.temporary,
lwFocusRequest.component, lwFocusRequest.cause);
}
FocusEvent newFocusOwnerEvent =
- new CausedFocusEvent(lwFocusRequest.component,
+ new FocusEvent(lwFocusRequest.component,
FocusEvent.FOCUS_GAINED,
lwFocusRequest.temporary,
currentFocusOwner == null ? lastFocusOwner : currentFocusOwner,
@@ -2726,8 +2725,8 @@ public abstract class KeyboardFocusManager
{
temporary = true;
}
- return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
- CausedFocusEvent.Cause.NATIVE_SYSTEM);
+ return new FocusEvent(source, fe.getID(), temporary, opposite,
+ FocusEvent.Cause.UNEXPECTED);
}
}
@@ -2802,7 +2801,7 @@ public abstract class KeyboardFocusManager
// 'opposite' will be fixed by
// DefaultKeyboardFocusManager.realOppositeComponent
- return new CausedFocusEvent(newSource,
+ return new FocusEvent(newSource,
FocusEvent.FOCUS_GAINED, temporary,
opposite, lwFocusRequest.cause);
}
@@ -2815,8 +2814,8 @@ public abstract class KeyboardFocusManager
// If it arrives as the result of activation we should skip it
// This event will not have appropriate request record and
// on arrival there will be already some focus owner set.
- return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false,
- null, CausedFocusEvent.Cause.ACTIVATION);
+ return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_GAINED, false,
+ null, FocusEvent.Cause.ACTIVATION);
}
return retargetUnexpectedFocusEvent(fe);
@@ -2839,9 +2838,9 @@ public abstract class KeyboardFocusManager
if (currentFocusOwner != null) {
// Call to KeyboardFocusManager.clearGlobalFocusOwner()
heavyweightRequests.removeFirst();
- return new CausedFocusEvent(currentFocusOwner,
+ return new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST, false, null,
- CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
+ FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
}
// Otherwise, fall through to failure case below
@@ -2850,9 +2849,9 @@ public abstract class KeyboardFocusManager
{
// Focus leaving application
if (currentFocusOwner != null) {
- return new CausedFocusEvent(currentFocusOwner,
+ return new FocusEvent(currentFocusOwner,
FocusEvent.FOCUS_LOST,
- true, null, CausedFocusEvent.Cause.ACTIVATION);
+ true, null, FocusEvent.Cause.ACTIVATION);
} else {
return fe;
}
@@ -2878,15 +2877,15 @@ public abstract class KeyboardFocusManager
? true
: lwFocusRequest.temporary;
- return new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
+ return new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
temporary, lwFocusRequest.component, lwFocusRequest.cause);
} else if (focusedWindowChanged(opposite, currentFocusOwner)) {
// If top-level changed there might be no focus request in a list
// But we know the opposite, we now it is temporary - dispatch the event.
if (!fe.isTemporary() && currentFocusOwner != null) {
// Create copy of the event with only difference in temporary parameter.
- fe = new CausedFocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
- true, opposite, CausedFocusEvent.Cause.ACTIVATION);
+ fe = new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,
+ true, opposite, FocusEvent.Cause.ACTIVATION);
}
return fe;
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/Window.java b/jdk/src/java.desktop/share/classes/java/awt/Window.java
index 5894ad303b7..71fc98009b3 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/Window.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/Window.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,6 @@ import javax.accessibility.*;
import sun.awt.AWTAccessor;
import sun.awt.AWTPermissions;
import sun.awt.AppContext;
-import sun.awt.CausedFocusEvent;
import sun.awt.DebugSettings;
import sun.awt.SunToolkit;
import sun.awt.util.IdentityArrayList;
@@ -2599,7 +2598,7 @@ public class Window extends Container implements Accessible {
{
Component toFocus =
KeyboardFocusManager.getMostRecentFocusOwner(owner);
- if (toFocus != null && toFocus.requestFocus(false, CausedFocusEvent.Cause.ACTIVATION)) {
+ if (toFocus != null && toFocus.requestFocus(false, FocusEvent.Cause.ACTIVATION)) {
return;
}
}
diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java
index afef05edef0..c4483a4d927 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/event/FocusEvent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
package java.awt.event;
import java.awt.Component;
+import java.io.ObjectStreamException;
+
+import sun.awt.AWTAccessor;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
@@ -51,6 +54,10 @@ import sun.awt.SunToolkit;
* the FOCUS_GAINED and FOCUS_LOST event ids; the level may be distinguished in
* the event using the isTemporary() method.
*
+ * Every {@code FocusEvent} records its cause - the reason why this event was
+ * generated. The cause is assigned during the focus event creation and may be
+ * retrieved by calling {@link #getCause}.
+ *
* An unspecified behavior will be caused if the {@code id} parameter
* of any particular {@code FocusEvent} instance is not
* in the range from {@code FOCUS_FIRST} to {@code FOCUS_LAST}.
@@ -65,6 +72,61 @@ import sun.awt.SunToolkit;
*/
public class FocusEvent extends ComponentEvent {
+ /**
+ * This enum represents the cause of a {@code FocusEvent}- the reason why it
+ * occurred. Possible reasons include mouse events, keyboard focus
+ * traversal, window activation.
+ * If no cause is provided then the reason is {@code UNKNOWN}.
+ *
+ * @since 9
+ */
+ public enum Cause {
+ /**
+ * The default value.
+ */
+ UNKNOWN,
+ /**
+ * An activating mouse event.
+ */
+ MOUSE_EVENT,
+ /**
+ * A focus traversal action with unspecified direction.
+ */
+ TRAVERSAL,
+ /**
+ * An up-cycle focus traversal action.
+ */
+ TRAVERSAL_UP,
+ /**
+ * A down-cycle focus traversal action.
+ */
+ TRAVERSAL_DOWN,
+ /**
+ * A forward focus traversal action.
+ */
+ TRAVERSAL_FORWARD,
+ /**
+ * A backward focus traversal action.
+ */
+ TRAVERSAL_BACKWARD,
+ /**
+ * Restoring focus after a focus request has been rejected.
+ */
+ ROLLBACK,
+ /**
+ * A system action causing an unexpected focus change.
+ */
+ UNEXPECTED,
+ /**
+ * An activation of a toplevel window.
+ */
+ ACTIVATION,
+ /**
+ * Clearing global focus owner.
+ */
+ CLEAR_GLOBAL_FOCUS_OWNER
+ }
+
/**
* The first number in the range of ids used for focus events.
*/
@@ -85,6 +147,16 @@ public class FocusEvent extends ComponentEvent {
*/
public static final int FOCUS_LOST = 1 + FOCUS_FIRST; //Event.LOST_FOCUS
+ /**
+ * A focus event has the reason why this event was generated.
+ * The cause is set during the focus event creation.
+ *
+ * @serial
+ * @see #getCause()
+ * @since 9
+ */
+ private final Cause cause;
+
/**
* A focus event can have two different levels, permanent and temporary.
* It will be set to true if some operation takes away the focus
@@ -115,7 +187,8 @@ public class FocusEvent extends ComponentEvent {
/**
* Constructs a {@code FocusEvent} object with the
- * specified temporary state and opposite {@code Component}.
+ * specified temporary state, opposite {@code Component} and the
+ * {@code Cause.UNKNOWN} cause.
* The opposite {@code Component} is the other
* {@code Component} involved in this focus change.
* For a {@code FOCUS_GAINED} event, this is the
@@ -142,13 +215,57 @@ public class FocusEvent extends ComponentEvent {
* @see #getID()
* @see #isTemporary()
* @see #getOppositeComponent()
+ * @see Cause#UNKNOWN
* @since 1.4
*/
public FocusEvent(Component source, int id, boolean temporary,
Component opposite) {
+ this(source, id, temporary, opposite, Cause.UNKNOWN);
+ }
+
+ /**
+ * Constructs a {@code FocusEvent} object with the
+ * specified temporary state, opposite {@code Component} and the cause.
+ * The opposite {@code Component} is the other
+ * {@code Component} involved in this focus change.
+ * For a {@code FOCUS_GAINED} event, this is the
+ * {@code Component} that lost focus. For a
+ * {@code FOCUS_LOST} event, this is the {@code Component}
+ * that gained focus. If this focus change occurs with a native
+ * application, with a Java application in a different VM,
+ * or with no other {@code Component}, then the opposite
+ * {@code Component} is {@code null}.
+ *
This method throws an
+ * {@code IllegalArgumentException} if {@code source} or {@code cause}
+ * is {@code null}.
+ *
+ * @param source The {@code Component} that originated the event
+ * @param id An integer indicating the type of event.
+ * For information on allowable values, see
+ * the class description for {@link FocusEvent}
+ * @param temporary Equals {@code true} if the focus change is temporary;
+ * {@code false} otherwise
+ * @param opposite The other Component involved in the focus change,
+ * or {@code null}
+ * @param cause The focus event cause.
+ * @throws IllegalArgumentException if {@code source} equals {@code null}
+ * or if {@code cause} equals {@code null}
+ * @see #getSource()
+ * @see #getID()
+ * @see #isTemporary()
+ * @see #getOppositeComponent()
+ * @see Cause
+ * @since 9
+ */
+ public FocusEvent(Component source, int id, boolean temporary,
+ Component opposite, Cause cause) {
super(source, id);
+ if (cause == null) {
+ throw new IllegalArgumentException("null cause");
+ }
this.temporary = temporary;
this.opposite = opposite;
+ this.cause = cause;
}
/**
@@ -220,8 +337,8 @@ public class FocusEvent extends ComponentEvent {
return (SunToolkit.targetToAppContext(opposite) ==
AppContext.getAppContext())
- ? opposite
- : null;
+ ? opposite
+ : null;
}
/**
@@ -233,17 +350,56 @@ public class FocusEvent extends ComponentEvent {
public String paramString() {
String typeStr;
switch(id) {
- case FOCUS_GAINED:
- typeStr = "FOCUS_GAINED";
- break;
- case FOCUS_LOST:
- typeStr = "FOCUS_LOST";
- break;
- default:
- typeStr = "unknown type";
+ case FOCUS_GAINED:
+ typeStr = "FOCUS_GAINED";
+ break;
+ case FOCUS_LOST:
+ typeStr = "FOCUS_LOST";
+ break;
+ default:
+ typeStr = "unknown type";
}
return typeStr + (temporary ? ",temporary" : ",permanent") +
- ",opposite=" + getOppositeComponent();
+ ",opposite=" + getOppositeComponent() + ",cause=" + getCause();
}
-}
+ /**
+ * Returns the event cause.
+ *
+ * @return one of {@link Cause} values
+ * @since 9
+ */
+ public final Cause getCause() {
+ return cause;
+ }
+
+ /**
+ * Checks if this deserialized {@code FocusEvent} instance is compatible
+ * with the current specification which implies that focus event has
+ * non-null {@code cause} value. If the check fails a new {@code FocusEvent}
+ * instance is returned which {@code cause} field equals to
+ * {@link Cause#UNKNOWN} and its other fields have the same values as in
+ * this {@code FocusEvent} instance.
+ *
+ * @serial
+ * @see #cause
+ * @since 9
+ */
+ @SuppressWarnings("serial")
+ Object readResolve() throws ObjectStreamException {
+ if (cause != null) {
+ return this;
+ }
+ FocusEvent focusEvent = new FocusEvent(new Component(){}, getID(),
+ isTemporary(), getOppositeComponent());
+ focusEvent.setSource(null);
+ focusEvent.consumed = consumed;
+
+ AWTAccessor.AWTEventAccessor accessor =
+ AWTAccessor.getAWTEventAccessor();
+ accessor.setBData(focusEvent, accessor.getBData(this));
+ return focusEvent;
+ }
+
+
+}
\ No newline at end of file
diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java
index 238dcb988f9..c9ae83659f6 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java
@@ -79,7 +79,7 @@ import jdk.internal.misc.SharedSecrets;
* will be ignored.
*
The identity of the value does not matter, only the actual
* value. For example, {@code TextAttribute.WEIGHT_BOLD} and
- * {@code new Float(2.0)}
+ * {@code Float.valueOf(2.0f)}
* indicate the same {@code WEIGHT}.
* Attribute values of type {@code Number} (used for
* {@code WEIGHT}, {@code WIDTH}, {@code POSTURE},
diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java b/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java
index 4511d0eab15..5f47384697a 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextMeasurer.java
@@ -105,7 +105,7 @@ public final class TextMeasurer implements Cloneable {
String s = System.getProperty("estLines");
if (s != null) {
try {
- Float f = new Float(s);
+ Float f = Float.valueOf(s);
EST_LINES = f.floatValue();
}
catch(NumberFormatException e) {
diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java
index bfbaf5e1b2a..f9a3a2d2058 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/ParameterBlock.java
@@ -392,7 +392,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock add(float f) {
- return add(new Float(f));
+ return add(Float.valueOf(f));
}
/**
@@ -403,7 +403,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock add(double d) {
- return add(new Double(d));
+ return add(Double.valueOf(d));
}
/**
@@ -521,7 +521,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock set(float f, int index) {
- return set(new Float(f), index);
+ return set(Float.valueOf(f), index);
}
/**
@@ -537,7 +537,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock set(double d, int index) {
- return set(new Double(d), index);
+ return set(Double.valueOf(d), index);
}
/**
diff --git a/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java b/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java
index 2ac37efb7d1..40890c784e8 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/peer/ComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,12 +27,12 @@ package java.awt.peer;
import java.awt.*;
import java.awt.event.PaintEvent;
+import java.awt.event.FocusEvent.Cause;
import java.awt.image.ColorModel;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.awt.image.VolatileImage;
-import sun.awt.CausedFocusEvent;
import sun.java2d.pipe.Region;
@@ -343,7 +343,7 @@ public interface ComponentPeer {
*/
boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
- CausedFocusEvent.Cause cause);
+ Cause cause);
/**
* Returns {@code true} when the component takes part in the focus
diff --git a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java
index 3044cd2413a..5a1cf128607 100644
--- a/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java
+++ b/jdk/src/java.desktop/share/classes/java/awt/print/PrinterJob.java
@@ -577,6 +577,8 @@ public abstract class PrinterJob {
/**
* Gets the name of the printing user.
* @return the name of the printing user
+ * @throws SecurityException if a security manager exists and
+ * PropertyPermission - user.name is not given in the policy file
*/
public abstract String getUserName();
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java
index 883e0c0cf7c..56d1df019ba 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@ import java.util.Set;
import java.awt.*;
import java.awt.event.*;
-import java.awt.peer.LightweightPeer;
import java.applet.Applet;
@@ -57,7 +56,6 @@ import javax.accessibility.*;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
import sun.swing.SwingUtilities2;
-import sun.swing.UIClientPropertyKey;
/**
* The base class for all Swing components except top-level containers.
@@ -3558,7 +3556,7 @@ public abstract class JComponent extends Container implements Serializable,
new sun.awt.RequestFocusController() {
public boolean acceptRequestFocus(Component from, Component to,
boolean temporary, boolean focusedWindowChangeAllowed,
- sun.awt.CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
if ((to == null) || !(to instanceof JComponent)) {
return true;
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java
index 3d561b99bef..6de8a0bd750 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java
@@ -98,7 +98,7 @@ import javax.accessibility.*;
*
* layeredPane.add(child, JLayeredPane.DEFAULT_LAYER);
* or
- * layeredPane.add(child, new Integer(10));
+ * layeredPane.add(child, Integer.valueOf.valueOf(10));
*
* The layer attribute can also be set on a Component by calling
* layeredPaneParent.setLayer(child, 10)
@@ -162,23 +162,23 @@ import javax.accessibility.*;
@SuppressWarnings("serial")
public class JLayeredPane extends JComponent implements Accessible {
/// Watch the values in getObjectForLayer()
- /** Convenience object defining the Default layer. Equivalent to new Integer(0).*/
+ /** Convenience object defining the Default layer. Equivalent to Integer.valueOf(0).*/
public static final Integer DEFAULT_LAYER = 0;
- /** Convenience object defining the Palette layer. Equivalent to new Integer(100).*/
+ /** Convenience object defining the Palette layer. Equivalent to Integer.valueOf(100).*/
public static final Integer PALETTE_LAYER = 100;
- /** Convenience object defining the Modal layer. Equivalent to new Integer(200).*/
+ /** Convenience object defining the Modal layer. Equivalent to Integer.valueOf(200).*/
public static final Integer MODAL_LAYER = 200;
- /** Convenience object defining the Popup layer. Equivalent to new Integer(300).*/
+ /** Convenience object defining the Popup layer. Equivalent to Integer.valueOf(300).*/
public static final Integer POPUP_LAYER = 300;
- /** Convenience object defining the Drag layer. Equivalent to new Integer(400).*/
+ /** Convenience object defining the Drag layer. Equivalent to Integer.valueOf(400).*/
public static final Integer DRAG_LAYER = 400;
/** Convenience object defining the Frame Content layer.
* This layer is normally only use to position the contentPane and menuBar
* components of JFrame.
- * Equivalent to new Integer(-30000).
+ * Equivalent to Integer.valueOf(-30000).
* @see JFrame
*/
- public static final Integer FRAME_CONTENT_LAYER = new Integer(-30000);
+ public static final Integer FRAME_CONTENT_LAYER = -30000;
/** Bound property */
public static final String LAYER_PROPERTY = "layeredContainerLayer";
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java b/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java
index 3504f2ef16a..216b18f4b19 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JProgressBar.java
@@ -478,7 +478,7 @@ public class JProgressBar extends JComponent implements SwingConstants, Accessib
if (format == null) {
format = NumberFormat.getPercentInstance();
}
- return format.format(new Double(getPercentComplete()));
+ return format.format(Double.valueOf(getPercentComplete()));
}
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java
index 9ca12ea6ee1..ee53fbffd91 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java
@@ -81,7 +81,7 @@ import sun.swing.PrintingStatus;
* TableModel dataModel = new AbstractTableModel() {
* public int getColumnCount() { return 10; }
* public int getRowCount() { return 10;}
- * public Object getValueAt(int row, int col) { return new Integer(row*col); }
+ * public Object getValueAt(int row, int col) { return Integer.valueOf(row*col); }
* };
* JTable table = new JTable(dataModel);
* JScrollPane scrollpane = new JScrollPane(table);
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java b/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java
index 1d7fa9dec20..3fbd668bb80 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SpinnerNumberModel.java
@@ -51,10 +51,10 @@ import java.io.Serializable;
* range zero to one hundred, with
* fifty as the initial value, one could write:
*
- * Integer value = new Integer(50);
- * Integer min = new Integer(0);
- * Integer max = new Integer(100);
- * Integer step = new Integer(1);
+ * Integer value = Integer.valueOf(50);
+ * Integer min = Integer.valueOf(0);
+ * Integer max = Integer.valueOf(100);
+ * Integer step = Integer.valueOf(1);
* SpinnerNumberModel model = new SpinnerNumberModel(value, min, max, step);
* int fifty = model.getNumber().intValue();
*
@@ -175,7 +175,8 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializ
* minimum <= value <= maximum
*/
public SpinnerNumberModel(double value, double minimum, double maximum, double stepSize) {
- this(new Double(value), new Double(minimum), new Double(maximum), new Double(stepSize));
+ this(Double.valueOf(value), Double.valueOf(minimum),
+ Double.valueOf(maximum), Double.valueOf(stepSize));
}
@@ -337,10 +338,10 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializ
if ((value instanceof Float) || (value instanceof Double)) {
double v = value.doubleValue() + (stepSize.doubleValue() * (double)dir);
if (value instanceof Double) {
- newValue = new Double(v);
+ newValue = Double.valueOf(v);
}
else {
- newValue = new Float(v);
+ newValue = Float.valueOf((float)v);
}
} else {
long v = value.longValue() + (stepSize.longValue() * (long)dir);
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java
index 6a48eb423a3..9900c9b7e0e 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SwingUtilities.java
@@ -845,6 +845,38 @@ public class SwingUtilities implements SwingConstants
return result;
}
+ /**
+ * Check whether MouseEvent contains speficied mouse button or
+ * mouse button down mask based on MouseEvent ID.
+ *
+ * @param anEvent a MouseEvent object
+ * @param mouseButton mouse button type
+ * @param mouseButtonDownMask mouse button down mask event modifier
+ *
+ * @return true if the anEvent contains speficied mouseButton or
+ * mouseButtonDownMask based on MouseEvent ID.
+ */
+ private static boolean checkMouseButton(MouseEvent anEvent,
+ int mouseButton,
+ int mouseButtonDownMask)
+ {
+ switch (anEvent.getID()) {
+ case MouseEvent.MOUSE_PRESSED:
+ case MouseEvent.MOUSE_RELEASED:
+ case MouseEvent.MOUSE_CLICKED:
+ return (anEvent.getButton() == mouseButton);
+
+ case MouseEvent.MOUSE_ENTERED:
+ case MouseEvent.MOUSE_EXITED:
+ case MouseEvent.MOUSE_DRAGGED:
+ return ((anEvent.getModifiersEx() & mouseButtonDownMask) != 0);
+
+ default:
+ return ((anEvent.getModifiersEx() & mouseButtonDownMask) != 0 ||
+ anEvent.getButton() == mouseButton);
+ }
+ }
+
/**
* Returns true if the mouse event specifies the left mouse button.
*
@@ -852,8 +884,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the left mouse button was active
*/
public static boolean isLeftMouseButton(MouseEvent anEvent) {
- return ((anEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0 ||
- anEvent.getButton() == MouseEvent.BUTTON1);
+ return checkMouseButton(anEvent, MouseEvent.BUTTON1,
+ InputEvent.BUTTON1_DOWN_MASK);
}
/**
@@ -863,8 +895,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the middle mouse button was active
*/
public static boolean isMiddleMouseButton(MouseEvent anEvent) {
- return ((anEvent.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0 ||
- anEvent.getButton() == MouseEvent.BUTTON2);
+ return checkMouseButton(anEvent, MouseEvent.BUTTON2,
+ InputEvent.BUTTON2_DOWN_MASK);
}
/**
@@ -874,8 +906,8 @@ public class SwingUtilities implements SwingConstants
* @return true if the right mouse button was active
*/
public static boolean isRightMouseButton(MouseEvent anEvent) {
- return ((anEvent.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0 ||
- anEvent.getButton() == MouseEvent.BUTTON3);
+ return checkMouseButton(anEvent, MouseEvent.BUTTON3,
+ InputEvent.BUTTON3_DOWN_MASK);
}
/**
diff --git a/jdk/src/java.desktop/share/classes/sun/swing/UIClientPropertyKey.java b/jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java
similarity index 76%
rename from jdk/src/java.desktop/share/classes/sun/swing/UIClientPropertyKey.java
rename to jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java
index 6ec361cbf45..8aa2bf393fc 100644
--- a/jdk/src/java.desktop/share/classes/sun/swing/UIClientPropertyKey.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIClientPropertyKey.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,18 +23,19 @@
* questions.
*/
-package sun.swing;
+package javax.swing;
/**
- * This interface is used only for tagging keys for client properties
- * for {@code JComponent} set by UI which needs to be cleared on {@literal L&F}
+ * This interface is used only for tagging keys for client properties for
+ * {@code JComponent} set by UI which needs to be cleared on {@literal L&F}
* change and serialization.
- *
- * All such keys are removed from client properties in {@code
- * JComponent.setUI()} method after uninstalling old UI and before
- * intalling the new one. They are also removed prior to serialization.
+ *
+ * All such keys are removed from client properties in
+ * {@code JComponent.setUI()} method after uninstalling old UI and before
+ * installing the new one. They are also removed prior to serialization.
*
* @author Igor Kushnirskiy
+ * @since 9
*/
public interface UIClientPropertyKey {
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java
index 1955407b75a..2ad447e6a18 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java
@@ -120,7 +120,7 @@ public class UIDefaults extends Hashtable
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 --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java
index d37c57076b9..b19632ff141 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/OceanTheme.java
@@ -134,7 +134,7 @@ public class OceanTheme extends DefaultMetalTheme {
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 @@ public class OceanTheme extends DefaultMetalTheme {
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 @@ public class OceanTheme extends DefaultMetalTheme {
"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 --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java
index e4766bb12c4..71a136f0d63 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthArrowButton.java
@@ -139,7 +139,6 @@ class SynthArrowButton extends JButton implements SwingConstants, UIResource {
}
}
- context.dispose();
return dim;
}
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java
index 8dcbd6ff36c..57a868c7b3a 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthBorder.java
@@ -61,7 +61,6 @@ class SynthBorder extends AbstractBorder implements UIResource {
return;
}
ui.paintBorder(context, g, x, y, width, height);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
index a85cf146849..379bcd9a10a 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
@@ -105,7 +105,6 @@ public class SynthButtonUI extends BasicButtonUI implements
}
}
- context.dispose();
}
/**
@@ -125,7 +124,6 @@ public class SynthButtonUI extends BasicButtonUI implements
SynthContext context = getContext(b, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -226,7 +224,6 @@ public class SynthButtonUI extends BasicButtonUI implements
else {
baseline = textRect.y + fm.getAscent();
}
- context.dispose();
return baseline;
}
@@ -253,7 +250,6 @@ public class SynthButtonUI extends BasicButtonUI implements
SynthLookAndFeel.update(context, g);
paintBackground(context, g, c);
paint(context, g);
- context.dispose();
}
/**
@@ -270,7 +266,6 @@ public class SynthButtonUI extends BasicButtonUI implements
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -321,7 +316,6 @@ public class SynthButtonUI extends BasicButtonUI implements
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 @@ public class SynthButtonUI extends BasicButtonUI implements
b.getVerticalTextPosition(), b.getIconTextGap(),
b.getDisplayedMnemonicIndex());
- ss.dispose();
return size;
}
@@ -494,7 +487,6 @@ public class SynthButtonUI extends BasicButtonUI implements
b.getVerticalTextPosition(), b.getIconTextGap(),
b.getDisplayedMnemonicIndex());
- ss.dispose();
return size;
}
@@ -516,7 +508,6 @@ public class SynthButtonUI extends BasicButtonUI implements
b.getVerticalTextPosition(), b.getIconTextGap(),
b.getDisplayedMnemonicIndex());
- ss.dispose();
return size;
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
index 72ab2b09a16..4f67bd86d3e 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
@@ -65,7 +65,6 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
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 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
private void updateStyle(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -96,7 +94,6 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
SynthContext context = getContext(chooser, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
super.uninstallDefaults();
}
@@ -155,7 +152,6 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
context.getPainter().paintColorChooserBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -172,7 +168,6 @@ public class SynthColorChooserUI extends BasicColorChooserUI implements
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
index 8734d55806d..42ddb3b230a 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
@@ -144,7 +144,6 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
forceOpaque = style.getBoolean(context,
"ComboBox.forceOpaque", false);
}
- context.dispose();
if(listBox != null) {
SynthLookAndFeel.updateStyles(listBox);
@@ -182,7 +181,6 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
SynthContext context = getContext(comboBox, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -323,7 +321,6 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
context.getPainter().paintComboBoxBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -340,7 +337,6 @@ public class SynthComboBoxUI extends BasicComboBoxUI implements
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java
index 64b6e536f79..164dc0c265f 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthContext.java
@@ -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 @@ import javax.swing.JComponent;
* @author Scott Violet
*/
public class SynthContext {
- private static final Queue queue = new ConcurrentLinkedQueue<>();
private JComponent component;
private Region region;
@@ -54,19 +51,15 @@ public class SynthContext {
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 @@ public class SynthContext {
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;
}
@@ -146,23 +143,6 @@ public class SynthContext {
return state;
}
- /**
- * 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 --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java
index 0e5a6478aef..ba1927bb948 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java
@@ -41,7 +41,6 @@ class SynthDefaultLookup extends DefaultLookup {
}
SynthContext context = ((SynthUI)ui).getContext(c);
Object value = context.getStyle().get(context, key);
- context.dispose();
return value;
}
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
index 8da1fe0cf3b..e5463beca23 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
@@ -121,7 +121,6 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI
private void updateStyle(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -131,7 +130,6 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI
protected void uninstallDefaults() {
SynthContext context = getContext(desktopIcon, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -171,7 +169,6 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI
context.getPainter().paintDesktopIconBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -188,7 +185,6 @@ public class SynthDesktopIconUI extends BasicDesktopIconUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
index f7b370eb35b..9702fa980ff 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
@@ -119,7 +119,6 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
uninstallKeyboardActions();
installKeyboardActions();
}
- context.dispose();
}
/**
@@ -143,7 +142,6 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
SynthContext context = getContext(desktop, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
if (taskBar != null) {
@@ -460,7 +458,6 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
context.getPainter().paintDesktopPaneBackground(context, g, 0, 0,
c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -477,7 +474,6 @@ public class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
index 69489197d6a..ffaeece02fb 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
@@ -83,7 +83,6 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
c.putClientProperty("caretAspectRatio", null);
style.uninstallDefaults(context);
- context.dispose();
style = null;
Object clientProperty =
@@ -127,7 +126,6 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -165,7 +163,6 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
SynthLookAndFeel.update(context, g);
paintBackground(context, g, c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
index 92ad059085d..a7413a5577d 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
@@ -138,7 +138,6 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
}
}
}
- context.dispose();
}
protected void installDefaults() {
@@ -149,7 +148,6 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
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 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
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 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
SynthContext context = getContext(this);
LayoutManager lm =
(LayoutManager)style.get(context, "InternalFrameTitlePane.titlePaneLayout");
- context.dispose();
return (lm != null) ? lm : new SynthTitlePaneLayout();
}
@@ -362,7 +358,6 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
Image.SCALE_SMOOTH));
}
}
- context.dispose();
menuButton.setIcon(frameIcon);
}
@@ -433,7 +428,6 @@ class SynthInternalFrameTitlePane extends BasicInternalFrameTitlePane
Insets insets = getInsets();
height += insets.top + insets.bottom;
width += insets.left + insets.right;
- context.dispose();
return new Dimension(width, height);
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
index 8ed25333234..a11e7549d5d 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
@@ -118,7 +118,6 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -128,7 +127,6 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI
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 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI
context.getPainter().paintInternalFrameBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -233,7 +230,6 @@ public class SynthInternalFrameUI extends BasicInternalFrameUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
index 22e57e5e4a8..4d5b900a931 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
@@ -67,7 +67,6 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
void updateStyle(JLabel c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -78,7 +77,6 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -150,7 +148,6 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
else {
baseline = textRect.y + fm.getAscent();
}
- context.dispose();
return baseline;
}
@@ -174,7 +171,6 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
context.getPainter().paintLabelBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -191,7 +187,6 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -242,7 +237,6 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
label.getVerticalTextPosition(), label.getIconTextGap(),
label.getDisplayedMnemonicIndex());
- context.dispose();
return size;
}
@@ -263,7 +257,6 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
label.getVerticalTextPosition(), label.getIconTextGap(),
label.getDisplayedMnemonicIndex());
- context.dispose();
return size;
}
@@ -284,7 +277,6 @@ public class SynthLabelUI extends BasicLabelUI implements SynthUI {
label.getVerticalTextPosition(), label.getIconTextGap(),
label.getDisplayedMnemonicIndex());
- context.dispose();
return size;
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java
index 121ddb5cb81..b7e96f611e9 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthListUI.java
@@ -75,7 +75,6 @@ public class SynthListUI extends BasicListUI
SynthLookAndFeel.update(context, g);
context.getPainter().paintListBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
- context.dispose();
paint(g, c);
}
@@ -162,7 +161,6 @@ public class SynthListUI extends BasicListUI
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -175,7 +173,6 @@ public class SynthListUI extends BasicListUI
SynthContext context = getContext(list, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
index 3998b354ccb..74b0cd2e006 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
@@ -976,7 +976,6 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
if (currBG != null && !currBG.equals(lastBG)) {
comp.repaint();
}
- context.dispose();
}
}
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
index 1f096646495..77c7a819074 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
@@ -83,7 +83,6 @@ public class SynthMenuBarUI extends BasicMenuBarUI
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -94,7 +93,6 @@ public class SynthMenuBarUI extends BasicMenuBarUI
SynthContext context = getContext(menuBar, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -143,7 +141,6 @@ public class SynthMenuBarUI extends BasicMenuBarUI
context.getPainter().paintMenuBarBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -160,7 +157,6 @@ public class SynthMenuBarUI extends BasicMenuBarUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
index 956f76f1fb3..9e07c376675 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
@@ -124,13 +124,11 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
installKeyboardActions();
}
}
- context.dispose();
SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
ENABLED);
accStyle = SynthLookAndFeel.updateStyle(accContext, this);
- accContext.dispose();
}
/**
@@ -140,13 +138,11 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
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 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
defaultTextIconGap, acceleratorDelimiter,
MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix());
- context.dispose();
- accContext.dispose();
return value;
}
@@ -243,7 +237,6 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
SynthLookAndFeel.update(context, g);
paintBackground(context, g, c);
paint(context, g);
- context.dispose();
}
/**
@@ -260,7 +253,6 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -280,7 +272,6 @@ public class SynthMenuItemUI extends BasicMenuItemUI implements
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 --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
index 7bb66a25c93..be1bd34cab1 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
@@ -110,13 +110,11 @@ public class SynthMenuUI extends BasicMenuUI
installKeyboardActions();
}
}
- context.dispose();
SynthContext accContext = getContext(mi, Region.MENU_ITEM_ACCELERATOR,
ENABLED);
accStyle = SynthLookAndFeel.updateStyle(accContext, this);
- accContext.dispose();
}
/**
@@ -140,13 +138,11 @@ public class SynthMenuUI extends BasicMenuUI
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 @@ public class SynthMenuUI extends BasicMenuUI
defaultTextIconGap, acceleratorDelimiter,
MenuItemLayoutHelper.useCheckAndArrow(menuItem),
getPropertyPrefix());
- context.dispose();
- accContext.dispose();
return value;
}
@@ -243,7 +237,6 @@ public class SynthMenuUI extends BasicMenuUI
context.getPainter().paintMenuBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -260,7 +253,6 @@ public class SynthMenuUI extends BasicMenuUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -279,7 +271,6 @@ public class SynthMenuUI extends BasicMenuUI
Icon arrowIcon = style.getIcon(context, prefix + ".arrowIcon");
SynthGraphicsUtils.paint(context, accContext, g, checkIcon, arrowIcon,
acceleratorDelimiter, defaultTextIconGap, getPropertyPrefix());
- accContext.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
index de6f2a7135e..b09ed3a7709 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
@@ -88,7 +88,6 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -99,7 +98,6 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
SynthContext context = getContext(optionPane, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -125,7 +123,6 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
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 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
context.getPainter().paintOptionPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -184,7 +180,6 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -259,7 +254,6 @@ public class SynthOptionPaneUI extends BasicOptionPaneUI implements
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 --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
index 73f37ff530b..a9b91b79099 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
@@ -108,14 +108,12 @@ public class SynthPanelUI extends BasicPanelUI
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 @@ public class SynthPanelUI extends BasicPanelUI
context.getPainter().paintPanelBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -171,7 +168,6 @@ public class SynthPanelUI extends BasicPanelUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
index cbb09f29212..d3f1e25f7ae 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
@@ -77,7 +77,6 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -97,7 +96,6 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI
SynthContext context = getContext(popupMenu, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
if (popupMenu.getLayout() instanceof UIResource) {
@@ -150,7 +148,6 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI
context.getPainter().paintPopupMenuBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -167,7 +164,6 @@ public class SynthPopupMenuUI extends BasicPopupMenuUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
index f38fea87fb6..743366f4112 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
@@ -118,7 +118,6 @@ public class SynthProgressBarUI extends BasicProgressBarUI
}
minBarSize = (Dimension)style.get(context, "ProgressBar.minBarSize");
glowWidth = style.getInt(context, "ProgressBar.glowWidth", 0);
- context.dispose();
}
/**
@@ -129,7 +128,6 @@ public class SynthProgressBarUI extends BasicProgressBarUI
SynthContext context = getContext(progressBar, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -160,7 +158,6 @@ public class SynthProgressBarUI extends BasicProgressBarUI
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 @@ public class SynthProgressBarUI extends BasicProgressBarUI
g, 0, 0, c.getWidth(), c.getHeight(),
progressBar.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -233,7 +229,6 @@ public class SynthProgressBarUI extends BasicProgressBarUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
index 1115fe35551..13244226ba3 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
@@ -67,7 +67,6 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
SynthContext context = getContext(root, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -97,7 +96,6 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
installKeyboardActions((JRootPane)c);
}
}
- context.dispose();
}
/**
@@ -120,7 +118,6 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
context.getPainter().paintRootPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -137,7 +134,6 @@ public class SynthRootPaneUI extends BasicRootPaneUI implements SynthUI {
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
index bf86f377412..b93196a9eab 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
@@ -129,15 +129,12 @@ public class SynthScrollBarUI extends BasicScrollBarUI
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 @@ public class SynthScrollBarUI extends BasicScrollBarUI
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 @@ public class SynthScrollBarUI extends BasicScrollBarUI
SynthContext context = getContext(scrollbar);
boolean value = style.getBoolean(context,
"ScrollBar.allowsAbsolutePositioning", false);
- context.dispose();
return value;
}
@@ -247,7 +240,6 @@ public class SynthScrollBarUI extends BasicScrollBarUI
g, 0, 0, c.getWidth(), c.getHeight(),
scrollbar.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -264,7 +256,6 @@ public class SynthScrollBarUI extends BasicScrollBarUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -278,11 +269,9 @@ public class SynthScrollBarUI extends BasicScrollBarUI
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 --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
index 6b3e29602de..8e4601eb85e 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
@@ -83,7 +83,6 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
context.getPainter().paintScrollPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -100,7 +99,6 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -150,7 +148,6 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
installKeyboardActions(c);
}
}
- context.dispose();
}
/**
@@ -178,7 +175,6 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
if (scrollpane.getViewportBorder() instanceof UIResource) {
scrollpane.setViewportBorder(null);
@@ -254,7 +250,6 @@ public class SynthScrollPaneUI extends BasicScrollPaneUI
}
context.getPainter().paintViewportBorder(context, g, x, y, width,
height);
- context.dispose();
}
@Override
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
index a222a428080..b9de6433b47 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
@@ -106,7 +106,6 @@ public class SynthSeparatorUI extends SeparatorUI
}
}
- context.dispose();
}
/**
@@ -120,7 +119,6 @@ public class SynthSeparatorUI extends SeparatorUI
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -168,7 +166,6 @@ public class SynthSeparatorUI extends SeparatorUI
g, 0, 0, c.getWidth(), c.getHeight(),
separator.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -185,7 +182,6 @@ public class SynthSeparatorUI extends SeparatorUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -231,7 +227,6 @@ public class SynthSeparatorUI extends SeparatorUI
size = new Dimension(insets.left + insets.right,
insets.top + insets.bottom + thickness);
}
- context.dispose();
return size;
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
index 9c222e1a925..9118fb7569f 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
@@ -116,17 +116,14 @@ public class SynthSliderUI extends BasicSliderUI
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 @@ public class SynthSliderUI extends BasicSliderUI
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 @@ public class SynthSliderUI extends BasicSliderUI
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 @@ public class SynthSliderUI extends BasicSliderUI
SynthContext context = getContext(slider);
valueHeight = context.getStyle().getGraphicsUtils(
context).getMaximumCharHeight(context);
- context.dispose();
}
int contentHeight = height - insetCache.top -
insetCache.bottom;
@@ -359,7 +350,6 @@ public class SynthSliderUI extends BasicSliderUI
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 @@ public class SynthSliderUI extends BasicSliderUI
trackRect.x = startX + tickRect.width + trackInsets.left;
}
}
- context.dispose();
lastSize = slider.getSize();
}
@@ -715,7 +704,6 @@ public class SynthSliderUI extends BasicSliderUI
insetCache = newInsets;
calculateGeometry();
}
- context.dispose();
}
/**
@@ -774,7 +762,6 @@ public class SynthSliderUI extends BasicSliderUI
g, 0, 0, c.getWidth(), c.getHeight(),
slider.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -790,7 +777,6 @@ public class SynthSliderUI extends BasicSliderUI
public void paint(Graphics g, JComponent c) {
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -835,13 +821,11 @@ public class SynthSliderUI extends BasicSliderUI
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 --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
index a1293dfdadd..2c430e03e82 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
@@ -131,7 +131,6 @@ public class SynthSpinnerUI extends BasicSpinnerUI
installKeyboardActions();
}
}
- context.dispose();
}
@@ -151,7 +150,6 @@ public class SynthSpinnerUI extends BasicSpinnerUI
SynthContext context = getContext(spinner, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -301,7 +299,6 @@ public class SynthSpinnerUI extends BasicSpinnerUI
context.getPainter().paintSpinnerBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
@@ -319,7 +316,6 @@ public class SynthSpinnerUI extends BasicSpinnerUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java
index c3a203e5237..ab0c0954318 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneDivider.java
@@ -81,7 +81,6 @@ class SynthSplitPaneDivider extends BasicSplitPaneDivider {
context.getPainter().paintSplitPaneDividerForeground(context, g, 0, 0,
getWidth(), getHeight(), splitPane.getOrientation());
- context.dispose();
// super.paint(g2);
for (int counter = 0; counter < getComponentCount(); counter++) {
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
index 667d6ded258..6c4a1d42901 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
@@ -121,7 +121,6 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
ENABLED);
SynthStyle oldDividerStyle = dividerStyle;
dividerStyle = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
context = getContext(splitPane, ENABLED);
SynthStyle oldStyle = style;
@@ -160,7 +159,6 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
divider.setBasicSplitPaneUI(this);
splitPane.add(divider, JSplitPane.DIVIDER);
}
- context.dispose();
}
/**
@@ -180,12 +178,10 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
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 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
context.getPainter().paintSplitPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -304,7 +299,6 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -338,7 +332,6 @@ public class SynthSplitPaneUI extends BasicSplitPaneUI
context.getPainter().paintSplitPaneDragDivider(context, g, x, y, w, h,
splitPane.getOrientation());
g.setClip(oldClip);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
index 211e8a2c331..8e59afe9342 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
@@ -154,27 +154,17 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
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 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
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 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
context.getPainter().paintTabbedPaneBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -424,7 +409,6 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
index 16272ffa819..39acd0e90ea 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
@@ -85,7 +85,6 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -109,7 +108,6 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI
SynthContext context = getContext(header, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -142,7 +140,6 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI
context.getPainter().paintTableHeaderBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -159,7 +156,6 @@ public class SynthTableHeaderUI extends BasicTableHeaderUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java
index 1e5f522416f..08ac1382015 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTableUI.java
@@ -189,7 +189,6 @@ public class SynthTableUI extends BasicTableUI
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -220,7 +219,6 @@ public class SynthTableUI extends BasicTableUI
}
SynthContext context = getContext(table, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -273,7 +271,6 @@ public class SynthTableUI extends BasicTableUI
context.getPainter().paintTableBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -299,7 +296,6 @@ public class SynthTableUI extends BasicTableUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
index 33214dad926..affbb6f4ecd 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
@@ -88,7 +88,6 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI {
getComponent().removeFocusListener(handler);
style.uninstallDefaults(context);
- context.dispose();
style = null;
super.uninstallDefaults();
}
@@ -107,7 +106,6 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI {
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -142,7 +140,6 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI {
context.getPainter().paintTextAreaBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
index 6adb7538e88..cf0e83637ef 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
@@ -79,7 +79,6 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI {
installKeyboardActions();
}
}
- context.dispose();
}
static void updateStyle(JTextComponent comp, SynthContext context,
@@ -179,7 +178,6 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI {
SynthLookAndFeel.update(context, g);
paintBackground(context, g, c);
paint(context, g);
- context.dispose();
}
/**
@@ -262,7 +260,6 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI {
getComponent().removeFocusListener(handler);
style.uninstallDefaults(context);
- context.dispose();
style = null;
super.uninstallDefaults();
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
index a36117cda20..518c25da5a9 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
@@ -98,11 +98,9 @@ public class SynthToolBarUI extends BasicToolBarUI
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 @@ public class SynthToolBarUI extends BasicToolBarUI
installKeyboardActions();
}
}
- context.dispose();
}
/**
@@ -127,7 +124,6 @@ public class SynthToolBarUI extends BasicToolBarUI
SynthContext context = getContext(toolBar, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
handleIcon = null;
@@ -135,13 +131,11 @@ public class SynthToolBarUI extends BasicToolBarUI
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 @@ public class SynthToolBarUI extends BasicToolBarUI
g, 0, 0, c.getWidth(), c.getHeight(),
toolBar.getOrientation());
paint(context, g);
- context.dispose();
}
/**
@@ -232,7 +225,6 @@ public class SynthToolBarUI extends BasicToolBarUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -289,7 +281,6 @@ public class SynthToolBarUI extends BasicToolBarUI
SynthContext subcontext = getContext(
toolBar, Region.TOOL_BAR_CONTENT, contentStyle);
paintContent(subcontext, g, contentRect);
- subcontext.dispose();
}
/**
@@ -326,7 +317,6 @@ public class SynthToolBarUI extends BasicToolBarUI
dragWindow.getOrientation());
context.getPainter().paintToolBarDragWindowBorder(context, g, 0, 0, w, h,
dragWindow.getOrientation());
- context.dispose();
}
//
@@ -383,7 +373,6 @@ public class SynthToolBarUI extends BasicToolBarUI
dim.width += insets.left + insets.right;
dim.height += insets.top + insets.bottom;
- context.dispose();
return dim;
}
@@ -421,7 +410,6 @@ public class SynthToolBarUI extends BasicToolBarUI
dim.width += insets.left + insets.right;
dim.height += insets.top + insets.bottom;
- context.dispose();
return dim;
}
@@ -543,7 +531,6 @@ public class SynthToolBarUI extends BasicToolBarUI
}
}
}
- context.dispose();
}
private boolean isGlue(Component c) {
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
index dc42debba7d..b73d57ab3dd 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
@@ -68,7 +68,6 @@ public class SynthToolTipUI extends BasicToolTipUI
private void updateStyle(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -78,7 +77,6 @@ public class SynthToolTipUI extends BasicToolTipUI
protected void uninstallDefaults(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -139,7 +137,6 @@ public class SynthToolTipUI extends BasicToolTipUI
context.getPainter().paintToolTipBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -165,7 +162,6 @@ public class SynthToolTipUI extends BasicToolTipUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -218,7 +214,6 @@ public class SynthToolTipUI extends BasicToolTipUI
prefSize.height += fm.getHeight();
}
}
- context.dispose();
return prefSize;
}
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
index 603540c6a58..08194e7e3cf 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
@@ -147,11 +147,9 @@ public class SynthTreeUI extends BasicTreeUI
installKeyboardActions();
}
}
- context.dispose();
context = getContext(tree, Region.TREE_CELL, ENABLED);
cellStyle = SynthLookAndFeel.updateStyle(context, this);
- context.dispose();
}
/**
@@ -223,12 +221,10 @@ public class SynthTreeUI extends BasicTreeUI
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 @@ public class SynthTreeUI extends BasicTreeUI
context.getPainter().paintTreeBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -292,7 +287,6 @@ public class SynthTreeUI extends BasicTreeUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
@@ -425,7 +419,6 @@ public class SynthTreeUI extends BasicTreeUI
row++;
}
}
- cellContext.dispose();
paintDropLine(g);
@@ -743,7 +736,6 @@ public class SynthTreeUI extends BasicTreeUI
context.getPainter().paintTreeCellFocus(context, g,
0, 0, getWidth() - imageOffset, getHeight());
}
- context.dispose();
}
SynthLookAndFeel.resetSelectedUI();
}
@@ -785,7 +777,6 @@ public class SynthTreeUI extends BasicTreeUI
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 @@ public class SynthTreeUI extends BasicTreeUI
if (context == null) {
context = getContext(tree);
width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
- context.dispose();
}
else {
width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
@@ -810,7 +800,6 @@ public class SynthTreeUI extends BasicTreeUI
if (context == null) {
context = getContext(tree);
height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
- context.dispose();
}
else {
height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
index dc3e6c6e1a1..94483f983d8 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
@@ -99,7 +99,6 @@ public class SynthViewportUI extends ViewportUI
newStyle.installDefaults(context);
}
this.style = newStyle;
- context.dispose();
}
/**
@@ -128,7 +127,6 @@ public class SynthViewportUI extends ViewportUI
protected void uninstallDefaults(JComponent c) {
SynthContext context = getContext(c, ENABLED);
style.uninstallDefaults(context);
- context.dispose();
style = null;
}
@@ -168,7 +166,6 @@ public class SynthViewportUI extends ViewportUI
context.getPainter().paintViewportBackground(context,
g, 0, 0, c.getWidth(), c.getHeight());
paint(context, g);
- context.dispose();
}
/**
@@ -202,7 +199,6 @@ public class SynthViewportUI extends ViewportUI
SynthContext context = getContext(c);
paint(context, g);
- context.dispose();
}
/**
diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java b/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java
index 3d31a0d1936..ff28193c3e8 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java
@@ -2580,7 +2580,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* @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 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* @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 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* @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 --git a/jdk/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java b/jdk/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java
index 5b5cb3920df..b3db8fceb03 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java
@@ -73,7 +73,7 @@ import sun.swing.SwingUtilities2;
* 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 --git a/jdk/src/java.desktop/share/classes/javax/swing/text/StyleConstants.java b/jdk/src/java.desktop/share/classes/javax/swing/text/StyleConstants.java
index 583b4dffd72..2aea5e5b2b5 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/StyleConstants.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/StyleConstants.java
@@ -608,7 +608,7 @@ public class StyleConstants {
* @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 @@ public class StyleConstants {
* @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 @@ public class StyleConstants {
* @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 @@ public class StyleConstants {
* @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 @@ public class StyleConstants {
* @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 @@ public class StyleConstants {
* @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 --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java b/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java
index 06a8ebf6534..c6e715f6672 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java
@@ -2564,7 +2564,7 @@ public class CSS implements Serializable {
* 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 @@ public class CSS implements Serializable {
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 --git a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/RTFAttributes.java b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/RTFAttributes.java
index 99f2822cdcc..a58fb451de9 100644
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/RTFAttributes.java
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/RTFAttributes.java
@@ -357,7 +357,7 @@ class RTFAttributes
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 @@ class RTFAttributes
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 --git a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java
index 7d67cd6ae47..796b7ab5d79 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@ import jdk.internal.misc.Unsafe;
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 @@ public final class AWTAccessor {
/*
* 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 @@ public final class AWTAccessor {
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause);
+ Cause cause);
/**
* Delivers focus for the lightweight descendant of the heavyweight
* synchronously.
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java b/jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java
index 985b416cffc..638a63f549d 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/CausedFocusEvent.java
@@ -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 @@ package sun.awt;
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 @@ public class CausedFocusEvent extends FocusEvent {
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() {
+ @Override
+ public Object run() {
+ consumedField.setAccessible(true);
+ try {
+ consumedField.set(focusEvent, consumed);
+ } catch (IllegalAccessException e) {
+ }
+ return null;
+ }
+ });
+ } catch (NoSuchFieldException e) {
+ }
+
+ AWTAccessor.AWTEventAccessor accessor =
+ AWTAccessor.getAWTEventAccessor();
+ accessor.setBData(focusEvent, accessor.getBData(this));
+ return focusEvent;
}
}
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java b/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
index 11b54c807c4..b82f1833177 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, 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
@@ -60,8 +60,8 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
focusLog.fine("Clearing global focus owner " + focusOwner);
}
if (focusOwner != null) {
- FocusEvent fl = new CausedFocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
- CausedFocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
+ FocusEvent fl = new FocusEvent(focusOwner, FocusEvent.FOCUS_LOST, false, null,
+ FocusEvent.Cause.CLEAR_GLOBAL_FOCUS_OWNER);
SunToolkit.postPriorityEvent(fl);
}
}
@@ -110,7 +110,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause,
+ FocusEvent.Cause cause,
Component currentFocusOwner) // provided by the descendant peers
{
if (lightweightChild == null) {
@@ -122,7 +122,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
currentOwner = null;
}
if (currentOwner != null) {
- FocusEvent fl = new CausedFocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
+ FocusEvent fl = new FocusEvent(currentOwner, FocusEvent.FOCUS_LOST,
false, lightweightChild, cause);
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
@@ -131,7 +131,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
SunToolkit.postEvent(SunToolkit.targetToAppContext(currentOwner), fl);
}
- FocusEvent fg = new CausedFocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
+ FocusEvent fg = new FocusEvent(lightweightChild, FocusEvent.FOCUS_GAINED,
false, currentOwner, cause);
if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
@@ -142,7 +142,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
}
// WARNING: Don't call it on the Toolkit thread.
- public static boolean requestFocusFor(Component target, CausedFocusEvent.Cause cause) {
+ public static boolean requestFocusFor(Component target, FocusEvent.Cause cause) {
return AWTAccessor.getComponentAccessor().requestFocus(target, cause);
}
@@ -152,7 +152,7 @@ public abstract class KeyboardFocusManagerPeerImpl implements KeyboardFocusManag
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
return KfmAccessor.instance.shouldNativelyFocusHeavyweight(
heavyweight, descendant, temporary, focusedWindowChangeAllowed,
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/NullComponentPeer.java b/jdk/src/java.desktop/share/classes/sun/awt/NullComponentPeer.java
index d44e8ca2535..f95df58145f 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/NullComponentPeer.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/NullComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@ import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.Insets;
-import java.awt.MenuBar;
+import java.awt.event.FocusEvent.Cause;
import java.awt.Point;
import java.awt.Event;
import java.awt.event.PaintEvent;
@@ -178,7 +178,7 @@ public class NullComponentPeer implements LightweightPeer,
public boolean requestFocus
(Component lightweightChild, boolean temporary,
- boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) {
+ boolean focusedWindowChangeAllowed, long time, Cause cause) {
return false;
}
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/RequestFocusController.java b/jdk/src/java.desktop/share/classes/sun/awt/RequestFocusController.java
index a0b9a3ee12b..29c94c6ab1b 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/RequestFocusController.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/RequestFocusController.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,11 @@
package sun.awt;
import java.awt.Component;
+import java.awt.event.FocusEvent.Cause;
public interface RequestFocusController
{
public boolean acceptRequestFocus(Component from, Component to,
boolean temporary, boolean focusedWindowChangeAllowed,
- CausedFocusEvent.Cause cause);
+ Cause cause);
}
diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/PNGImageDecoder.java b/jdk/src/java.desktop/share/classes/sun/awt/image/PNGImageDecoder.java
index 0627f91fca3..edc2fa2039f 100644
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/PNGImageDecoder.java
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/PNGImageDecoder.java
@@ -87,7 +87,7 @@ public class PNGImageDecoder extends ImageDecoder
properties.put(key,value);
}
private void property(String key,float value) {
- property(key,new Float(value));
+ property(key, Float.valueOf(value));
}
private final void pngassert(boolean b) throws IOException {
if(!b) {
diff --git a/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java b/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java
index 19200c8282b..6ac092ed32e 100644
--- a/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java
+++ b/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java
@@ -1843,7 +1843,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
private PhysicalFont registerFontFile(String file) {
if (new File(file).isAbsolute() &&
- !registeredFonts.contains(file)) {
+ !registeredFonts.containsKey(file)) {
int fontFormat = FONTFORMAT_NONE;
int fontRank = Font2D.UNKNOWN_RANK;
if (ttFilter.accept(null, file)) {
diff --git a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java
index b5d8f0daa8f..638e01488e6 100644
--- a/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java
+++ b/jdk/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java
@@ -1388,6 +1388,8 @@ public abstract class RasterPrinterJob extends PrinterJob {
Doc doc = new PageableDoc(getPageable());
if (attributes == null) {
attributes = new HashPrintRequestAttributeSet();
+ attributes.add(new Copies(getCopies()));
+ attributes.add(new JobName(getJobName(), null));
}
try {
job.print(doc, attributes);
diff --git a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java
index f4694100cd2..6e5a4cf3c93 100644
--- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java
+++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java
@@ -1402,8 +1402,8 @@ public class ServiceDialog extends JDialog implements ActionListener {
format.setParseIntegerOnly(false);
format.setDecimalSeparatorAlwaysShown(true);
NumberFormatter nf = new NumberFormatter(format);
- nf.setMinimum(new Float(0.0f));
- nf.setMaximum(new Float(999.0f));
+ nf.setMinimum(Float.valueOf(0.0f));
+ nf.setMaximum(Float.valueOf(999.0f));
nf.setAllowsInvalid(true);
nf.setCommitsOnValidEdit(true);
@@ -1422,13 +1422,13 @@ public class ServiceDialog extends JDialog implements ActionListener {
topMargin.addActionListener(this);
topMargin.getAccessibleContext().setAccessibleName(
getMsg("label.topmargin"));
- topMargin = new JFormattedTextField(nf);
+
bottomMargin = new JFormattedTextField(nf);
bottomMargin.addFocusListener(this);
bottomMargin.addActionListener(this);
bottomMargin.getAccessibleContext().setAccessibleName(
getMsg("label.bottommargin"));
- topMargin = new JFormattedTextField(nf);
+
c.gridwidth = GridBagConstraints.RELATIVE;
lblLeft = new JLabel(getMsg("label.leftmargin") + " " + unitsMsg,
JLabel.LEADING);
@@ -1836,10 +1836,10 @@ public class ServiceDialog extends JDialog implements ActionListener {
rmVal = mediaSize.getX(units) - pax - paw;
bmVal = mediaSize.getY(units) - pay - pah;
- lmObj = new Float(lmVal);
- rmObj = new Float(rmVal);
- tmObj = new Float(tmVal);
- bmObj = new Float(bmVal);
+ lmObj = lmVal;
+ rmObj = rmVal;
+ tmObj = tmVal;
+ bmObj = bmVal;
/* Now we know the values to use, we need to assign them
* to the fields appropriate for the orientation.
diff --git a/jdk/src/java.desktop/share/classes/sun/swing/StringUIClientPropertyKey.java b/jdk/src/java.desktop/share/classes/sun/swing/StringUIClientPropertyKey.java
index ea4bb945b1c..7720d484467 100644
--- a/jdk/src/java.desktop/share/classes/sun/swing/StringUIClientPropertyKey.java
+++ b/jdk/src/java.desktop/share/classes/sun/swing/StringUIClientPropertyKey.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
package sun.swing;
+import javax.swing.UIClientPropertyKey;
+
/**
* An implementation of {@code UIClientPropertyKey} that wraps a {@code String}.
*
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java b/jdk/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java
index ecee8ade0bc..4e60992f314 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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,9 +29,12 @@ import static java.awt.RenderingHints.*;
import java.awt.color.ColorSpace;
import java.awt.image.*;
import java.security.AccessController;
+import java.security.PrivilegedAction;
+
import sun.security.action.GetIntegerAction;
import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection;
import sun.java2d.opengl.OGLRenderQueue;
+import sun.security.action.GetPropertyAction;
public abstract class UNIXToolkit extends SunToolkit
{
@@ -42,6 +45,40 @@ public abstract class UNIXToolkit extends SunToolkit
private static final int[] BAND_OFFSETS_ALPHA = { 0, 1, 2, 3 };
private static final int DEFAULT_DATATRANSFER_TIMEOUT = 10000;
+ // Allowed GTK versions
+ public enum GtkVersions {
+ ANY(0),
+ GTK2(Constants.GTK2_MAJOR_NUMBER),
+ GTK3(Constants.GTK3_MAJOR_NUMBER);
+
+ static class Constants {
+ static final int GTK2_MAJOR_NUMBER = 2;
+ static final int GTK3_MAJOR_NUMBER = 3;
+ }
+
+ final int number;
+
+ GtkVersions(int number) {
+ this.number = number;
+ }
+
+ public static GtkVersions getVersion(int number) {
+ switch (number) {
+ case Constants.GTK2_MAJOR_NUMBER:
+ return GTK2;
+ case Constants.GTK3_MAJOR_NUMBER:
+ return GTK3;
+ default:
+ return ANY;
+ }
+ }
+
+ // major GTK version number
+ public int getNumber() {
+ return number;
+ }
+ };
+
private Boolean nativeGTKAvailable;
private Boolean nativeGTKLoaded;
private BufferedImage tmpImage = null;
@@ -79,7 +116,7 @@ public abstract class UNIXToolkit extends SunToolkit
return nativeGTKAvailable;
} else {
- boolean success = check_gtk();
+ boolean success = check_gtk(getEnabledGtkVersion().getNumber());
nativeGTKAvailable = success;
return success;
}
@@ -97,7 +134,8 @@ public abstract class UNIXToolkit extends SunToolkit
public boolean loadGTK() {
synchronized (GTK_LOCK) {
if (nativeGTKLoaded == null) {
- nativeGTKLoaded = load_gtk();
+ nativeGTKLoaded = load_gtk(getEnabledGtkVersion().getNumber(),
+ isGtkVerbose());
}
}
return nativeGTKLoaded;
@@ -241,14 +279,15 @@ public abstract class UNIXToolkit extends SunToolkit
tmpImage = new BufferedImage(colorModel, raster, false, null);
}
- private static native boolean check_gtk();
- private static native boolean load_gtk();
+ private static native boolean check_gtk(int version);
+ private static native boolean load_gtk(int version, boolean verbose);
private static native boolean unload_gtk();
private native boolean load_gtk_icon(String filename);
private native boolean load_stock_icon(int widget_type, String stock_id,
int iconSize, int textDirection, String detail);
private native void nativeSync();
+ private static native int get_gtk_version();
@Override
public void sync() {
@@ -338,4 +377,26 @@ public abstract class UNIXToolkit extends SunToolkit
}
return false;
}
+
+ public static GtkVersions getEnabledGtkVersion() {
+ String version = AccessController.doPrivileged(
+ new GetPropertyAction("jdk.gtk.version"));
+ if (version == null) {
+ return GtkVersions.ANY;
+ } else if (version.startsWith("2")) {
+ return GtkVersions.GTK2;
+ } else if("3".equals(version) ){
+ return GtkVersions.GTK3;
+ }
+ return GtkVersions.ANY;
+ }
+
+ public static GtkVersions getGtkVersion() {
+ return GtkVersions.getVersion(get_gtk_version());
+ }
+
+ public static boolean isGtkVerbose() {
+ return AccessController.doPrivileged((PrivilegedAction)()
+ -> Boolean.getBoolean("jdk.gtk.verbose"));
+ }
}
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java
index 82715e73ff2..c65a7c79f96 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -287,7 +287,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
@SuppressWarnings("deprecation")
public final boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
if (XKeyboardFocusManagerPeer.
processSynchronousLightweightTransfer(target, lightweightChild, temporary,
@@ -527,7 +527,7 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
// WindowEvent wfg = new WindowEvent(parentWindow, WindowEvent.WINDOW_GAINED_FOCUS);
// parentWindow.dispatchEvent(wfg);
// }
- XKeyboardFocusManagerPeer.requestFocusFor(target, CausedFocusEvent.Cause.MOUSE_EVENT);
+ XKeyboardFocusManagerPeer.requestFocusFor(target, FocusEvent.Cause.MOUSE_EVENT);
}
break;
}
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDesktopPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDesktopPeer.java
index 72a34cf85f8..b3d1c559442 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDesktopPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDesktopPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
package sun.awt.X11;
+import sun.awt.UNIXToolkit;
+
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -57,7 +59,8 @@ public class XDesktopPeer implements DesktopPeer {
XToolkit.awtLock();
try {
if (!initExecuted) {
- nativeLibraryLoaded = init();
+ nativeLibraryLoaded = init(UNIXToolkit.getEnabledGtkVersion()
+ .ordinal(), UNIXToolkit.isGtkVerbose());
}
} finally {
initExecuted = true;
@@ -123,5 +126,5 @@ public class XDesktopPeer implements DesktopPeer {
}
private native boolean gnome_url_show(byte[] url);
- private static native boolean init();
+ private static native boolean init(int gtkVersion, boolean verbose);
}
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java
index 9370b8cdae4..e81ff91575c 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedCanvasPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, 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
@@ -430,13 +430,10 @@ public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener
if (isXEmbedActive()) {
xembedLog.fine("Forwarding FOCUS_GAINED");
int flavor = XEMBED_FOCUS_CURRENT;
- if (e instanceof CausedFocusEvent) {
- CausedFocusEvent ce = (CausedFocusEvent)e;
- if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_FORWARD) {
- flavor = XEMBED_FOCUS_FIRST;
- } else if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_BACKWARD) {
- flavor = XEMBED_FOCUS_LAST;
- }
+ if (e.getCause() == FocusEvent.Cause.TRAVERSAL_FORWARD) {
+ flavor = XEMBED_FOCUS_FIRST;
+ } else if (e.getCause() == FocusEvent.Cause.TRAVERSAL_BACKWARD) {
+ flavor = XEMBED_FOCUS_LAST;
}
xembed.sendMessage(xembed.handle, XEMBED_FOCUS_IN, flavor, 0, 0);
}
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java
index 6bb38b54f24..d8fe392fe2c 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XEmbedChildProxyPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, 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
@@ -195,7 +195,7 @@ public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
int result = XKeyboardFocusManagerPeer
.shouldNativelyFocusHeavyweight(proxy, lightweightChild,
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java
index dde0b87d64c..2ec736feb29 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, 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
@@ -28,7 +28,7 @@ import java.awt.Component;
import java.awt.Window;
import sun.awt.AWTAccessor;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent;
import sun.awt.KeyboardFocusManagerPeerImpl;
import sun.util.logging.PlatformLogger;
@@ -101,7 +101,7 @@ public class XKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
target,
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java
index fa23ae0b66e..58b9559652a 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java
@@ -29,6 +29,8 @@ import java.awt.PopupMenu;
import java.awt.Taskbar.Feature;
import java.awt.peer.TaskbarPeer;
import java.awt.event.ActionEvent;
+
+import sun.awt.UNIXToolkit;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
@@ -45,7 +47,9 @@ final class XTaskbarPeer implements TaskbarPeer {
if (!initExecuted) {
String dname = AccessController.doPrivileged(
new GetPropertyAction("java.desktop.appName", ""));
- nativeLibraryLoaded = init(dname);
+ nativeLibraryLoaded = init(dname,
+ UNIXToolkit.getEnabledGtkVersion().ordinal(),
+ UNIXToolkit.isGtkVerbose());
if (nativeLibraryLoaded) {
Thread t = new Thread(null, () -> { runloop(); },
"TaskBar", 0, false);
@@ -147,7 +151,8 @@ final class XTaskbarPeer implements TaskbarPeer {
}
}
- private static native boolean init(String name);
+ private static native boolean init(String name, int version,
+ boolean verbose);
private static native void runloop();
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java
index 9efe70b17c4..5d769203159 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextAreaPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, 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
@@ -59,7 +59,6 @@ import javax.swing.text.JTextComponent;
import javax.swing.plaf.BorderUIResource;
import java.awt.im.InputMethodRequests;
-import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
@@ -945,14 +944,16 @@ final class XTextAreaPeer extends XComponentPeer implements TextAreaPeer {
void forwardFocusGained( FocusEvent e) {
isFocused = true;
- FocusEvent fe = CausedFocusEvent.retarget(e, this);
+ FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
+ e.getOppositeComponent(), e.getCause());
super.processFocusEvent(fe);
}
void forwardFocusLost( FocusEvent e) {
isFocused = false;
- FocusEvent fe = CausedFocusEvent.retarget(e, this);
+ FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
+ e.getOppositeComponent(), e.getCause());
super.processFocusEvent(fe);
}
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java
index 9df078e9d1f..42730dce98f 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTextFieldPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, 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
@@ -54,7 +54,6 @@ import java.awt.im.InputMethodRequests;
import sun.util.logging.PlatformLogger;
-import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
final class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
@@ -618,13 +617,15 @@ final class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
void forwardFocusGained( FocusEvent e) {
isFocused = true;
- FocusEvent fe = CausedFocusEvent.retarget(e, this);
+ FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
+ e.getOppositeComponent(), e.getCause());
super.processFocusEvent(fe);
}
void forwardFocusLost( FocusEvent e) {
isFocused = false;
- FocusEvent fe = CausedFocusEvent.retarget(e, this);
+ FocusEvent fe = new FocusEvent(this, e.getID(), e.isTemporary(),
+ e.getOppositeComponent(), e.getCause());
super.processFocusEvent(fe);
}
diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
index aa460f9f636..be362ae0781 100644
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
@@ -52,7 +52,6 @@ import sun.awt.*;
import sun.awt.datatransfer.DataTransferer;
import sun.font.FontConfigManager;
import sun.java2d.SunGraphicsEnvironment;
-import sun.misc.*;
import sun.awt.util.PerformanceLogger;
import sun.awt.util.ThreadGroupUtils;
import sun.print.PrintJob2D;
@@ -1144,7 +1143,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
public FileDialogPeer createFileDialog(FileDialog target) {
FileDialogPeer peer = null;
// The current GtkFileChooser is available from GTK+ 2.4
- if (!getSunAwtDisableGtkFileDialogs() && checkGtkVersion(2, 4, 0)) {
+ if (!getSunAwtDisableGtkFileDialogs() &&
+ (checkGtkVersion(2, 4, 0) || checkGtkVersion(3, 0, 0))) {
peer = new GtkFileDialogPeer(target);
} else {
peer = new XFileDialogPeer(target);
diff --git a/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java b/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java
index 4da098d504e..93f65327e08 100644
--- a/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java
+++ b/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java
@@ -117,7 +117,7 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
if (refreshTimeStr != null) {
try {
- minRefreshTime = (new Integer(refreshTimeStr)).intValue();
+ minRefreshTime = (Integer.valueOf(refreshTimeStr)).intValue();
} catch (NumberFormatException e) {
}
if (minRefreshTime < DEFAULT_MINREFRESH) {
diff --git a/jdk/src/java.desktop/unix/native/common/awt/awt.h b/jdk/src/java.desktop/unix/native/common/awt/awt.h
index 0dacab98a40..18a6dee275b 100644
--- a/jdk/src/java.desktop/unix/native/common/awt/awt.h
+++ b/jdk/src/java.desktop/unix/native/common/awt/awt.h
@@ -35,7 +35,9 @@
#include "debug_util.h"
#if !defined(HEADLESS) && !defined(MACOSX)
-#include
+#include
+#include
+typedef char Boolean;
#endif /* !HEADLESS && !MACOSX */
diff --git a/jdk/src/java.desktop/unix/native/common/awt/awt_p.h b/jdk/src/java.desktop/unix/native/common/awt/awt_p.h
index d2d1d74922a..934838c44b1 100644
--- a/jdk/src/java.desktop/unix/native/common/awt/awt_p.h
+++ b/jdk/src/java.desktop/unix/native/common/awt/awt_p.h
@@ -41,13 +41,6 @@
#include
#include
#ifndef HEADLESS
-#include
-#include
-#include
-#include
-#include
-#include
-#include
#include
#endif /* !HEADLESS */
#include "awt.h"
diff --git a/jdk/src/java.desktop/unix/native/common/awt/extutil.h b/jdk/src/java.desktop/unix/native/common/awt/extutil.h
deleted file mode 100644
index ba9f75a7642..00000000000
--- a/jdk/src/java.desktop/unix/native/common/awt/extutil.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * $Xorg: extutil.h,v 1.3 2000/08/18 04:05:45 coskrey Exp $
- *
-Copyright 1989, 1998 The Open Group
-
-All Rights Reserved.
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
- *
- * Author: Jim Fulton, MIT The Open Group
- *
- * Xlib Extension-Writing Utilities
- *
- * This package contains utilities for writing the client API for various
- * protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND
- * ARE SUBJECT TO CHANGE!
- */
-/* $XFree86: xc/include/extensions/extutil.h,v 1.5 2001/01/17 17:53:20 dawes Exp $ */
-
-#if defined(__linux__) || defined(MACOSX)
-
-#ifndef _EXTUTIL_H_
-#define _EXTUTIL_H_
-
-/*
- * We need to keep a list of open displays since the Xlib display list isn't
- * public. We also have to per-display info in a separate block since it isn't
- * stored directly in the Display structure.
- */
-typedef struct _XExtDisplayInfo {
- struct _XExtDisplayInfo *next; /* keep a linked list */
- Display *display; /* which display this is */
- XExtCodes *codes; /* the extension protocol codes */
- XPointer data; /* extra data for extension to use */
-} XExtDisplayInfo;
-
-typedef struct _XExtensionInfo {
- XExtDisplayInfo *head; /* start of list */
- XExtDisplayInfo *cur; /* most recently used */
- int ndisplays; /* number of displays */
-} XExtensionInfo;
-
-typedef struct _XExtensionHooks {
- int (*create_gc)(
-#if NeedNestedPrototypes
- Display* /* display */,
- GC /* gc */,
- XExtCodes* /* codes */
-#endif
-);
- int (*copy_gc)(
-#if NeedNestedPrototypes
- Display* /* display */,
- GC /* gc */,
- XExtCodes* /* codes */
-#endif
-);
- int (*flush_gc)(
-#if NeedNestedPrototypes
- Display* /* display */,
- GC /* gc */,
- XExtCodes* /* codes */
-#endif
-);
- int (*free_gc)(
-#if NeedNestedPrototypes
- Display* /* display */,
- GC /* gc */,
- XExtCodes* /* codes */
-#endif
-);
- int (*create_font)(
-#if NeedNestedPrototypes
- Display* /* display */,
- XFontStruct* /* fs */,
- XExtCodes* /* codes */
-#endif
-);
- int (*free_font)(
-#if NeedNestedPrototypes
- Display* /* display */,
- XFontStruct* /* fs */,
- XExtCodes* /* codes */
-#endif
-);
- int (*close_display)(
-#if NeedNestedPrototypes
- Display* /* display */,
- XExtCodes* /* codes */
-#endif
-);
- Bool (*wire_to_event)(
-#if NeedNestedPrototypes
- Display* /* display */,
- XEvent* /* re */,
- xEvent* /* event */
-#endif
-);
- Status (*event_to_wire)(
-#if NeedNestedPrototypes
- Display* /* display */,
- XEvent* /* re */,
- xEvent* /* event */
-#endif
-);
- int (*error)(
-#if NeedNestedPrototypes
- Display* /* display */,
- xError* /* err */,
- XExtCodes* /* codes */,
- int* /* ret_code */
-#endif
-);
- char *(*error_string)(
-#if NeedNestedPrototypes
- Display* /* display */,
- int /* code */,
- XExtCodes* /* codes */,
- char* /* buffer */,
- int /* nbytes */
-#endif
-);
-} XExtensionHooks;
-
-extern XExtensionInfo *XextCreateExtension(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-extern void XextDestroyExtension(
-#if NeedFunctionPrototypes
- XExtensionInfo* /* info */
-#endif
-);
-extern XExtDisplayInfo *XextAddDisplay(
-#if NeedFunctionPrototypes
- XExtensionInfo* /* extinfo */,
- Display* /* dpy */,
- char* /* ext_name */,
- XExtensionHooks* /* hooks */,
- int /* nevents */,
- XPointer /* data */
-#endif
-);
-extern int XextRemoveDisplay(
-#if NeedFunctionPrototypes
- XExtensionInfo* /* extinfo */,
- Display* /* dpy */
-#endif
-);
-extern XExtDisplayInfo *XextFindDisplay(
-#if NeedFunctionPrototypes
- XExtensionInfo* /* extinfo */,
- Display* /* dpy */
-#endif
-);
-
-#define XextHasExtension(i) ((i) && ((i)->codes))
-#define XextCheckExtension(dpy,i,name,val) \
- if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; }
-#define XextSimpleCheckExtension(dpy,i,name) \
- if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; }
-
-
-/*
- * helper macros to generate code that is common to all extensions; caller
- * should prefix it with static if extension source is in one file; this
- * could be a utility function, but have to stack 6 unused arguments for
- * something that is called many, many times would be bad.
- */
-#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \
-XExtDisplayInfo *proc (Display *dpy) \
-{ \
- XExtDisplayInfo *dpyinfo; \
- if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \
- if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \
- dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \
- return dpyinfo; \
-}
-
-#define XEXT_FIND_DISPLAY_PROTO(proc) \
- XExtDisplayInfo *proc(Display *dpy)
-
-#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \
-int proc (Display *dpy, XExtCodes *codes) \
-{ \
- return XextRemoveDisplay (extinfo, dpy); \
-}
-
-#define XEXT_CLOSE_DISPLAY_PROTO(proc) \
- int proc(Display *dpy, XExtCodes *codes)
-
-#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \
-char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \
-{ \
- code -= codes->first_error; \
- if (code >= 0 && code < nerr) { \
- char tmp[256]; \
- sprintf (tmp, "%s.%d", extname, code); \
- XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \
- return buf; \
- } \
- return (char *)0; \
-}
-
-#define XEXT_ERROR_STRING_PROTO(proc) \
- char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n)
-#endif
-
-#endif /* __linux__ || MACOSX */
diff --git a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c
index e6597a4723c..07c13f7b7e1 100644
--- a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c
+++ b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c
@@ -270,7 +270,6 @@ Java_sun_java2d_x11_XSurfaceData_initOps(JNIEnv *env, jobject xsd,
xsdo->sdOps.Dispose = X11SD_Dispose;
xsdo->GetPixmapWithBg = X11SD_GetPixmapWithBg;
xsdo->ReleasePixmapWithBg = X11SD_ReleasePixmapWithBg;
- xsdo->widget = NULL;
if (peer != NULL) {
xsdo->drawable = JNU_CallMethodByName(env, &hasException, peer, "getWindow", "()J").j;
if (hasException) {
@@ -1087,7 +1086,7 @@ static int
X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
X11SDOps *xsdo)
{
- Position x1=0, y1=0, x2=0, y2=0;
+ short x1=0, y1=0, x2=0, y2=0;
int tmpx, tmpy;
Window tmpchild;
diff --git a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h
index 91ad4626a4c..9de747a70e0 100644
--- a/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h
+++ b/jdk/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h
@@ -101,7 +101,6 @@ struct _X11SDOps {
jboolean isPixmap;
jobject peer;
Drawable drawable;
- Widget widget;
GC javaGC; /* used for Java-level GC validation */
GC cachedGC; /* cached for use in X11SD_Unlock() */
jint depth;
diff --git a/jdk/src/java.desktop/unix/native/include/jawt_md.h b/jdk/src/java.desktop/unix/native/include/jawt_md.h
index b7c2ea749aa..2ba3a8e83cf 100644
--- a/jdk/src/java.desktop/unix/native/include/jawt_md.h
+++ b/jdk/src/java.desktop/unix/native/include/jawt_md.h
@@ -28,7 +28,6 @@
#include
#include
-#include
#include "jawt.h"
#ifdef __cplusplus
diff --git a/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingArea.c b/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingArea.c
deleted file mode 100644
index 712d08409df..00000000000
--- a/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingArea.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef HEADLESS
-
-#include
-#include "VDrawingAreaP.h"
-
-#endif /* !HEADLESS */
-
-#include
-#include
-
-#ifdef __linux__
-/* XXX: Shouldn't be necessary. */
-#include "awt_p.h"
-#endif /* __linux__ */
-
-
-/******************************************************************
- *
- * Provides Canvas widget which allows the X11 visual to be
- * changed (the Motif DrawingArea restricts the visual to that
- * of the parent widget).
- *
- ******************************************************************/
-
-
-/******************************************************************
- *
- * VDrawingArea Widget Resources
- *
- ******************************************************************/
-
-#ifndef HEADLESS
-#define Offset(x) (XtOffsetOf(VDrawingAreaRec, x))
-static XtResource resources[]=
-{
- { XtNvisual, XtCVisual, XtRVisual, sizeof(Visual*),
- Offset(vdrawing_area.visual), XtRImmediate, CopyFromParent}
-};
-
-
-static void Realize();
-static Boolean SetValues();
-static void Destroy ();
-
-static XmBaseClassExtRec baseClassExtRec = {
- NULL,
- NULLQUARK,
- XmBaseClassExtVersion,
- sizeof(XmBaseClassExtRec),
- NULL, /* InitializePrehook */
- NULL, /* SetValuesPrehook */
- NULL, /* InitializePosthook */
- NULL, /* SetValuesPosthook */
- NULL, /* secondaryObjectClass */
- NULL, /* secondaryCreate */
- NULL, /* getSecRes data */
- { 0 }, /* fastSubclass flags */
- NULL, /* getValuesPrehook */
- NULL, /* getValuesPosthook */
- NULL, /* classPartInitPrehook */
- NULL, /* classPartInitPosthook*/
- NULL, /* ext_resources */
- NULL, /* compiled_ext_resources*/
- 0, /* num_ext_resources */
- FALSE, /* use_sub_resources */
- NULL, /* widgetNavigable */
- NULL, /* focusChange */
- NULL /* wrapper_data */
-};
-
-VDrawingAreaClassRec vDrawingAreaClassRec = {
-{
- /* Core class part */
-
- /* superclass */ (WidgetClass)&xmDrawingAreaClassRec,
- /* class_name */ "VDrawingArea",
- /* widget_size */ sizeof(VDrawingAreaRec),
- /* class_initialize */ NULL,
- /* class_part_initialize*/ NULL,
- /* class_inited */ FALSE,
- /* initialize */ NULL,
- /* initialize_hook */ NULL,
- /* realize */ Realize,
- /* actions */ NULL,
- /* num_actions */ 0,
- /* resources */ resources,
- /* num_resources */ XtNumber(resources),
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ FALSE,
- /* compress_exposure */ FALSE,
- /* compress_enterleave*/ FALSE,
- /* visible_interest */ FALSE,
- /* destroy */ Destroy,
- /* resize */ XtInheritResize,
- /* expose */ XtInheritExpose,
- /* set_values */ SetValues,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_offsets */ NULL,
- /* tm_table */ NULL,
- /* query_geometry */ NULL,
- /* display_accelerator */ NULL,
- /* extension */ NULL
- },
-
- { /* composite_class fields */
- XtInheritGeometryManager, /* geometry_manager */
- XtInheritChangeManaged, /* change_managed */
- XtInheritInsertChild, /* insert_child */
- XtInheritDeleteChild, /* delete_child */
- NULL, /* extension */
- },
-
- { /* constraint_class fields */
- NULL, /* resource list */
- 0, /* num resources */
- 0, /* constraint size */
- NULL, /* init proc */
- NULL, /* destroy proc */
- NULL, /* set values proc */
- NULL, /* extension */
- },
-
- { /* manager_class fields */
- XtInheritTranslations, /* translations */
- NULL, /* syn_resources */
- 0, /* num_get_resources */
- NULL, /* syn_cont_resources */
- 0, /* num_get_cont_resources */
- XmInheritParentProcess, /* parent_process */
- NULL, /* extension */
- },
-
- { /* drawingArea class */
- /* extension */ NULL
- },
-
- /* VDrawingArea class part */
- {
- /* extension */ NULL
- }
-};
-
-WidgetClass vDrawingAreaClass = (WidgetClass)&vDrawingAreaClassRec;
-
-static Boolean
-SetValues(cw, rw, nw, args, num_args)
- Widget cw;
- Widget rw;
- Widget nw;
- ArgList args;
- Cardinal *num_args;
-{
- VDrawingAreaWidget current = (VDrawingAreaWidget)cw;
- VDrawingAreaWidget new_w = (VDrawingAreaWidget)nw;
-
- if (new_w->vdrawing_area.visual != current->vdrawing_area.visual) {
- new_w->vdrawing_area.visual = current->vdrawing_area.visual;
-#ifdef DEBUG
- fprintf(stdout, "VDrawingArea.SetValues: can't change visual from: visualID=%ld to visualID=%ld\n",
- current->vdrawing_area.visual->visualid,
- new_w->vdrawing_area.visual->visualid);
-#endif
-
- }
-
- return (False);
-}
-
-int
-FindWindowInList (Window parentWindow, Window *colormap_windows, int count)
-{
- int i;
-
- for (i = 0; i < count; i++)
- if (colormap_windows [i] == parentWindow)
- return i;
- return -1;
-}
-
-static void
-Realize(w, value_mask, attributes)
- Widget w;
- XtValueMask *value_mask;
- XSetWindowAttributes *attributes;
-{
- Widget parent;
- Status status;
- Window *colormap_windows;
- Window *new_colormap_windows;
- int count;
- int i;
- VDrawingAreaWidget vd = (VDrawingAreaWidget)w;
-
-#ifdef DEBUG
- fprintf(stdout, "VDrawingArea.Realize: visualID=%ld, depth=%d\n",
- vd->vdrawing_area.visual->visualid, w->core.depth);
-#endif
-
- /* 4328588:
- * Since we have our own Realize() function, we don't execute the one for
- * our super-super class, XmManager, and miss the code which checks that
- * height and width != 0. I've added that here. -bchristi
- */
- if (!XtWidth(w)) XtWidth(w) = 1 ;
- if (!XtHeight(w)) XtHeight(w) = 1 ;
-
- w->core.window = XCreateWindow (XtDisplay (w), XtWindow (w->core.parent),
- w->core.x, w->core.y, w->core.width, w->core.height,
- 0, w->core.depth, InputOutput,
- vd->vdrawing_area.visual,
- *value_mask, attributes );
-
- /* Need to add this window to the list of Colormap windows */
- parent = XtParent (w);
- while ((parent != NULL) && (!(XtIsShell (parent))))
- parent = XtParent (parent);
- if (parent == NULL) {
- fprintf (stderr, "NO TopLevel widget?!\n");
- return;
- }
-
- status = XGetWMColormapWindows (XtDisplay (w), XtWindow (parent),
- &colormap_windows, &count);
-
- /* If status is zero, add this window and shell to the list
- of colormap Windows */
- if (status == 0) {
- new_colormap_windows = (Window *) calloc (2, sizeof (Window));
- new_colormap_windows [0] = XtWindow (w);
- new_colormap_windows [1] = XtWindow (parent);
- XSetWMColormapWindows (XtDisplay (w), XtWindow (parent),
- new_colormap_windows, 2);
- free (new_colormap_windows);
- } else {
- /* Check if parent is already in the list */
- int parent_entry = -1;
-
- if (count > 0)
- parent_entry = FindWindowInList (XtWindow (parent),
- colormap_windows, count);
- if (parent_entry == -1) { /* Parent not in list */
- new_colormap_windows = (Window *) calloc (count + 2,
- sizeof (Window));
- new_colormap_windows [0] = XtWindow (w);
- new_colormap_windows [1] = XtWindow (parent);
- for (i = 0; i < count; i++)
- new_colormap_windows [i + 2] = colormap_windows [i];
- XSetWMColormapWindows (XtDisplay (w), XtWindow (parent),
- new_colormap_windows, count + 2);
-
- } else { /* parent already in list, just add new window */
- new_colormap_windows = (Window *) calloc (count + 1,
- sizeof (Window));
- new_colormap_windows [0] = XtWindow (w);
- for (i = 0; i < count; i++)
- new_colormap_windows [i + 1] = colormap_windows [i];
- XSetWMColormapWindows (XtDisplay (w), XtWindow (parent),
- new_colormap_windows, count + 1);
- }
- free (new_colormap_windows);
- XFree (colormap_windows);
- }
-
-
-}
-
-static void
-Destroy(Widget widget)
-{
- Status status;
- Widget parent;
- Window *colormap_windows;
- Window *new_colormap_windows;
- int count;
- int listEntry;
- int i;
- int j;
-
- /* Need to get this window's parent shell first */
- parent = XtParent (widget);
- while ((parent != NULL) && (!(XtIsShell (parent))))
- parent = XtParent (parent);
- if (parent == NULL) {
- fprintf (stderr, "NO TopLevel widget?!\n");
- return;
- }
-
- status = XGetWMColormapWindows (XtDisplay (widget), XtWindow (parent),
- &colormap_windows, &count);
-
- /* If status is zero, then there were no colormap windows for
- the parent ?? */
-
- if (status == 0)
- return;
-
- /* Remove this window from the list of colormap windows */
- listEntry = FindWindowInList (XtWindow (widget), colormap_windows,
- count);
-
- new_colormap_windows = (Window *) calloc (count - 1, sizeof (Window));
- j = 0;
- for (i = 0; i < count; i++) {
- if (i == listEntry)
- continue;
- new_colormap_windows [j] = colormap_windows [i];
- j++;
- }
- XSetWMColormapWindows (XtDisplay (widget), XtWindow (parent),
- new_colormap_windows, count - 1);
- free (new_colormap_windows);
- XFree (colormap_windows);
-
-}
-#endif /* !HEADLESS */
diff --git a/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingAreaP.h b/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingAreaP.h
deleted file mode 100644
index 00864fc50cd..00000000000
--- a/jdk/src/java.desktop/unix/native/libawt_headless/awt/VDrawingAreaP.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef _VDrawingAreaP_h_
-#define _VDrawingAreaP_h_
-
-#include
-#include "VDrawingArea.h"
-
-
-/***************************************************************
- * VDrawingArea Widget Data Structures
- *
- *
- **************************************************************/
-
-/* Define part class structure */
-typedef struct _VDrawingAreaClass {
- XtPointer extension;
-} VDrawingAreaClassPart;
-
-/* Define the full class record */
-typedef struct _VDrawingAreaClassRec {
- CoreClassPart core_class;
- CompositeClassPart composite_class;
- ConstraintClassPart constraint_class;
- XmManagerClassPart manager_class;
- XmDrawingAreaClassPart drawing_area_class;
- VDrawingAreaClassPart vdrawingarea_class;
-} VDrawingAreaClassRec;
-
-/* External definition for class record */
-extern VDrawingAreaClassRec vDrawingAreaClassRec;
-
-typedef struct {
- Visual *visual;
-} VDrawingAreaPart;
-
-/****************************************************************
- *
- * Full instance record declaration
- *
- ****************************************************************/
-
-typedef struct _VDrawingAreaRec
-{
- CorePart core;
- CompositePart composite;
- ConstraintPart constraint;
- XmManagerPart manager;
- XmDrawingAreaPart drawing_area;
- VDrawingAreaPart vdrawing_area;
-} VDrawingAreaRec;
-
-
-
-#endif /* !_VDrawingAreaP_h_ */
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c
index 00d04814e86..2dc59c2c77c 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include
#include "awt.h"
@@ -40,7 +41,6 @@
#define THROW_OUT_OF_MEMORY_ERROR() \
JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL)
-#define SETARG(name, value) XtSetArg(args[argc], name, value); argc++
struct X11InputMethodIDs {
jfieldID pData;
@@ -590,7 +590,7 @@ static StatusWindow *createStatusWindow(
char **mclr;
int mccr = 0;
char *dsr;
- Pixel bg, fg, light, dim;
+ unsigned long bg, fg, light, dim;
int x, y, off_x, off_y, xx, yy;
unsigned int w, h, bw, depth;
XGCValues values;
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c
index c9172a6e5f6..0e06972207f 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
#include "awt_GraphicsEnv.h"
#define XK_MISCELLANY
#include
-#include
#include
#include
#include
@@ -45,7 +44,7 @@
#include "wsutils.h"
#include "list.h"
#include "multiVis.h"
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
#if defined(__linux__) || defined(MACOSX)
#include
@@ -264,70 +263,10 @@ Java_sun_awt_X11_XRobotPeer_getRGBPixelsImpl( JNIEnv *env,
int index;
if (isGtkSupported) {
- GdkPixbuf *pixbuf;
- (*fp_gdk_threads_enter)();
- GdkWindow *root = (*fp_gdk_get_default_root_window)();
-
- pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(NULL, root, NULL,
- x, y, 0, 0, width, height);
- if (pixbuf && scale != 1) {
- GdkPixbuf *scaledPixbuf;
- x /= scale;
- y /= scale;
- width /= scale;
- height /= scale;
- dx /= scale;
- dy /= scale;
- scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
- GDK_INTERP_BILINEAR);
- (*fp_g_object_unref)(pixbuf);
- pixbuf = scaledPixbuf;
- }
-
- if (pixbuf) {
- int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
- int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
-
- if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
- && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
- && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
- && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
- && nchan >= 3
- ) {
- guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
-
- ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
- if (!ary) {
- (*fp_g_object_unref)(pixbuf);
- (*fp_gdk_threads_leave)();
- AWT_UNLOCK();
- return;
- }
-
- for (_y = 0; _y < height; _y++) {
- for (_x = 0; _x < width; _x++) {
- p = pix + _y * stride + _x * nchan;
-
- index = (_y + dy) * jwidth + (_x + dx);
- ary[index] = 0xff000000
- | (p[0] << 16)
- | (p[1] << 8)
- | (p[2]);
-
- }
- }
- (*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0);
- if ((*env)->ExceptionCheck(env)) {
- (*fp_g_object_unref)(pixbuf);
- (*fp_gdk_threads_leave)();
- AWT_UNLOCK();
- return;
- }
- gtk_failed = FALSE;
- }
- (*fp_g_object_unref)(pixbuf);
- }
- (*fp_gdk_threads_leave)();
+ gtk->gdk_threads_enter();
+ gtk_failed = gtk->get_drawable_data(env, pixelArray, x, y, width,
+ height, jwidth, dx, dy, scale);
+ gtk->gdk_threads_leave();
}
if (gtk_failed) {
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c
index c8b29f3bdcc..81e3423feec 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -34,7 +34,7 @@
#ifndef HEADLESS
#include "awt.h"
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
#endif /* !HEADLESS */
@@ -45,13 +45,12 @@ static jmethodID icon_upcall_method = NULL;
/*
* Class: sun_awt_UNIXToolkit
* Method: check_gtk
- * Signature: ()Z
+ * Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
-Java_sun_awt_UNIXToolkit_check_1gtk(JNIEnv *env, jclass klass)
-{
+Java_sun_awt_UNIXToolkit_check_1gtk(JNIEnv *env, jclass klass, jint version) {
#ifndef HEADLESS
- return (jboolean)gtk2_check_version();
+ return (jboolean)gtk_check_version(version);
#else
return JNI_FALSE;
#endif /* !HEADLESS */
@@ -61,13 +60,13 @@ Java_sun_awt_UNIXToolkit_check_1gtk(JNIEnv *env, jclass klass)
/*
* Class: sun_awt_UNIXToolkit
* Method: load_gtk
- * Signature: ()Z
+ * Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
-Java_sun_awt_UNIXToolkit_load_1gtk(JNIEnv *env, jclass klass)
-{
+Java_sun_awt_UNIXToolkit_load_1gtk(JNIEnv *env, jclass klass, jint version,
+ jboolean verbose) {
#ifndef HEADLESS
- return (jboolean)gtk2_load(env);
+ return (jboolean)gtk_load(env, version, verbose);
#else
return JNI_FALSE;
#endif /* !HEADLESS */
@@ -83,16 +82,14 @@ JNIEXPORT jboolean JNICALL
Java_sun_awt_UNIXToolkit_unload_1gtk(JNIEnv *env, jclass klass)
{
#ifndef HEADLESS
- return (jboolean)gtk2_unload();
+ return (jboolean)gtk->unload();
#else
return JNI_FALSE;
#endif /* !HEADLESS */
}
-jboolean _icon_upcall(JNIEnv *env, jobject this, GdkPixbuf *pixbuf)
+jboolean init_method(JNIEnv *env, jobject this)
{
- jboolean result = JNI_FALSE;
-
if (this_class == NULL) {
this_class = (*env)->NewGlobalRef(env,
(*env)->GetObjectClass(env, this));
@@ -100,33 +97,7 @@ jboolean _icon_upcall(JNIEnv *env, jobject this, GdkPixbuf *pixbuf)
"loadIconCallback", "([BIIIIIZ)V");
CHECK_NULL_RETURN(icon_upcall_method, JNI_FALSE);
}
-
- if (pixbuf != NULL)
- {
- guchar *pixbuf_data = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
- int row_stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
- int width = (*fp_gdk_pixbuf_get_width)(pixbuf);
- int height = (*fp_gdk_pixbuf_get_height)(pixbuf);
- int bps = (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf);
- int channels = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
- gboolean alpha = (*fp_gdk_pixbuf_get_has_alpha)(pixbuf);
-
- /* Copy the data array into a Java structure so we can pass it back. */
- jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
- JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
-
- (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
- (jbyte *)pixbuf_data);
-
- /* Release the pixbuf. */
- (*fp_g_object_unref)(pixbuf);
-
- /* Call the callback method to create the image on the Java side. */
- (*env)->CallVoidMethod(env, this, icon_upcall_method, data,
- width, height, row_stride, bps, channels, alpha);
- result = JNI_TRUE;
- }
- return result;
+ return JNI_TRUE;
}
/*
@@ -144,7 +115,6 @@ Java_sun_awt_UNIXToolkit_load_1gtk_1icon(JNIEnv *env, jobject this,
int len;
char *filename_str = NULL;
GError **error = NULL;
- GdkPixbuf *pixbuf;
if (filename == NULL)
{
@@ -158,13 +128,17 @@ Java_sun_awt_UNIXToolkit_load_1gtk_1icon(JNIEnv *env, jobject this,
JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
return JNI_FALSE;
}
+ if (!init_method(env, this) ) {
+ return JNI_FALSE;
+ }
(*env)->GetStringUTFRegion(env, filename, 0, len, filename_str);
- pixbuf = (*fp_gdk_pixbuf_new_from_file)(filename_str, error);
+ jboolean result = gtk->get_file_icon_data(env, filename_str, error,
+ icon_upcall_method, this);
/* Release the strings we've allocated. */
free(filename_str);
- return _icon_upcall(env, this, pixbuf);
+ return result;
#else /* HEADLESS */
return JNI_FALSE;
#endif /* !HEADLESS */
@@ -186,7 +160,6 @@ Java_sun_awt_UNIXToolkit_load_1stock_1icon(JNIEnv *env, jobject this,
int len;
char *stock_id_str = NULL;
char *detail_str = NULL;
- GdkPixbuf *pixbuf;
if (stock_id == NULL)
{
@@ -215,8 +188,12 @@ Java_sun_awt_UNIXToolkit_load_1stock_1icon(JNIEnv *env, jobject this,
(*env)->GetStringUTFRegion(env, detail, 0, len, detail_str);
}
- pixbuf = gtk2_get_stock_icon(widget_type, stock_id_str, icon_size,
- text_direction, detail_str);
+ if (!init_method(env, this) ) {
+ return JNI_FALSE;
+ }
+ jboolean result = gtk->get_icon_data(env, widget_type, stock_id_str,
+ icon_size, text_direction, detail_str,
+ icon_upcall_method, this);
/* Release the strings we've allocated. */
free(stock_id_str);
@@ -224,8 +201,7 @@ Java_sun_awt_UNIXToolkit_load_1stock_1icon(JNIEnv *env, jobject this,
{
free(detail_str);
}
-
- return _icon_upcall(env, this, pixbuf);
+ return result;
#else /* HEADLESS */
return JNI_FALSE;
#endif /* !HEADLESS */
@@ -279,11 +255,25 @@ Java_sun_awt_UNIXToolkit_gtkCheckVersionImpl(JNIEnv *env, jobject this,
{
char *ret;
- ret = fp_gtk_check_version(major, minor, micro);
+ ret = gtk->gtk_check_version(major, minor, micro);
if (ret == NULL) {
return TRUE;
}
- free(ret);
return FALSE;
}
+
+/*
+ * Class: sun_awt_UNIXToolkit
+ * Method: get_gtk_version
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL
+Java_sun_awt_UNIXToolkit_get_1gtk_1version(JNIEnv *env, jclass klass)
+{
+#ifndef HEADLESS
+ return gtk ? gtk->version : GTK_ANY;
+#else
+ return GTK_ANY;
+#endif /* !HEADLESS */
+}
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c
index 261986f9ac0..d61c59b5915 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_util.c
@@ -29,7 +29,6 @@
#include "awt_p.h"
#include "color.h"
-#include
#include
#include
#include
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c
index ef58feccd9b..42408da5bbb 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c
@@ -35,52 +35,18 @@
#include
#include "awt.h"
-#define GTK2_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("gtk-x11-2.0", "0")
-#define GTK2_LIB JNI_LIB_NAME("gtk-x11-2.0")
#define GTHREAD_LIB_VERSIONED VERSIONED_JNI_LIB_NAME("gthread-2.0", "0")
#define GTHREAD_LIB JNI_LIB_NAME("gthread-2.0")
-#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0)
-#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1)
-#define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2)
-#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3)
-#define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4)
-#define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5)
-#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6)
-#define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7)
-#define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8)
-#define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9)
-#define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10)
-#define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11)
-#define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12)
-#define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13)
-#define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14)
-#define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15)
-#define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16)
-#define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17)
-#define G_TYPE_BOXED G_TYPE_MAKE_FUNDAMENTAL (18)
-#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19)
-#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
-
#define GTK_TYPE_BORDER ((*fp_gtk_border_get_type)())
#define G_TYPE_FUNDAMENTAL_SHIFT (2)
#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define CONV_BUFFER_SIZE 128
#define NO_SYMBOL_EXCEPTION 1
-/* SynthConstants */
-const gint ENABLED = 1 << 0;
-const gint MOUSE_OVER = 1 << 1;
-const gint PRESSED = 1 << 2;
-const gint DISABLED = 1 << 3;
-const gint FOCUSED = 1 << 8;
-const gint SELECTED = 1 << 9;
-const gint DEFAULT = 1 << 10;
-
static void *gtk2_libhandle = NULL;
static void *gthread_libhandle = NULL;
@@ -105,54 +71,6 @@ static char convertionBuffer[CONV_BUFFER_SIZE];
static gboolean new_combo = TRUE;
const char ENV_PREFIX[] = "GTK_MODULES=";
-/*******************/
-enum GtkWidgetType
-{
- _GTK_ARROW_TYPE,
- _GTK_BUTTON_TYPE,
- _GTK_CHECK_BUTTON_TYPE,
- _GTK_CHECK_MENU_ITEM_TYPE,
- _GTK_COLOR_SELECTION_DIALOG_TYPE,
- _GTK_COMBO_BOX_TYPE,
- _GTK_COMBO_BOX_ARROW_BUTTON_TYPE,
- _GTK_COMBO_BOX_TEXT_FIELD_TYPE,
- _GTK_CONTAINER_TYPE,
- _GTK_ENTRY_TYPE,
- _GTK_FRAME_TYPE,
- _GTK_HANDLE_BOX_TYPE,
- _GTK_HPANED_TYPE,
- _GTK_HPROGRESS_BAR_TYPE,
- _GTK_HSCALE_TYPE,
- _GTK_HSCROLLBAR_TYPE,
- _GTK_HSEPARATOR_TYPE,
- _GTK_IMAGE_TYPE,
- _GTK_MENU_TYPE,
- _GTK_MENU_BAR_TYPE,
- _GTK_MENU_ITEM_TYPE,
- _GTK_NOTEBOOK_TYPE,
- _GTK_LABEL_TYPE,
- _GTK_RADIO_BUTTON_TYPE,
- _GTK_RADIO_MENU_ITEM_TYPE,
- _GTK_SCROLLED_WINDOW_TYPE,
- _GTK_SEPARATOR_MENU_ITEM_TYPE,
- _GTK_SEPARATOR_TOOL_ITEM_TYPE,
- _GTK_SPIN_BUTTON_TYPE,
- _GTK_TEXT_VIEW_TYPE,
- _GTK_TOGGLE_BUTTON_TYPE,
- _GTK_TOOLBAR_TYPE,
- _GTK_TOOLTIP_TYPE,
- _GTK_TREE_VIEW_TYPE,
- _GTK_VIEWPORT_TYPE,
- _GTK_VPANED_TYPE,
- _GTK_VPROGRESS_BAR_TYPE,
- _GTK_VSCALE_TYPE,
- _GTK_VSCROLLBAR_TYPE,
- _GTK_VSEPARATOR_TYPE,
- _GTK_WINDOW_TYPE,
- _GTK_DIALOG_TYPE,
- _GTK_WIDGET_TYPE_SIZE
-};
-
static GtkWidget *gtk2_widgets[_GTK_WIDGET_TYPE_SIZE];
@@ -359,20 +277,6 @@ static void (*fp_gtk_widget_size_request)(GtkWidget *widget,
static GtkAdjustment* (*fp_gtk_range_get_adjustment)(GtkRange* range);
/* Method bodies */
-const char *getStrFor(JNIEnv *env, jstring val)
-{
- int length = (*env)->GetStringLength(env, val);
- if (length > CONV_BUFFER_SIZE-1)
- {
- length = CONV_BUFFER_SIZE-1;
-#ifdef DEBUG
- fprintf(stderr, "Note: Detail is too long: %d chars\n", length);
-#endif /* DEBUG */
- }
-
- (*env)->GetStringUTFRegion(env, val, 0, length, convertionBuffer);
- return convertionBuffer;
-}
static void throw_exception(JNIEnv *env, const char* name, const char* message)
{
@@ -408,33 +312,34 @@ static void* dl_symbol_gthread(const char* name)
return result;
}
-gboolean gtk2_check_version()
+gboolean gtk2_check(const char* lib_name, int flags)
{
if (gtk2_libhandle != NULL) {
/* We've already successfully opened the GTK libs, so return true. */
return TRUE;
} else {
void *lib = NULL;
- gboolean result = FALSE;
- lib = dlopen(GTK2_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
+ lib = dlopen(lib_name, flags);
+
if (lib == NULL) {
- lib = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
- if (lib == NULL) {
- return FALSE;
- }
+ return FALSE;
+ }
+
+ if (flags & RTLD_NOLOAD) {
+ return TRUE;
}
fp_gtk_check_version = dlsym(lib, "gtk_check_version");
/* Check for GTK 2.2+ */
if (!fp_gtk_check_version(2, 2, 0)) {
- result = TRUE;
+ return TRUE;
}
// 8048289: workaround for https://bugzilla.gnome.org/show_bug.cgi?id=733065
// dlclose(lib);
- return result;
+ return FALSE;
}
}
@@ -450,7 +355,7 @@ do { \
} while(0);
-void update_supported_actions(JNIEnv *env) {
+static void update_supported_actions(JNIEnv *env) {
GVfs * (*fp_g_vfs_get_default) (void);
const gchar * const * (*fp_g_vfs_get_supported_uri_schemes) (GVfs * vfs);
const gchar * const * schemes = NULL;
@@ -513,7 +418,7 @@ void update_supported_actions(JNIEnv *env) {
/**
* Functions for awt_Desktop.c
*/
-gboolean gtk2_show_uri_load(JNIEnv *env) {
+static gboolean gtk2_show_uri_load(JNIEnv *env) {
gboolean success = FALSE;
dlerror();
const char *gtk_version = fp_gtk_check_version(2, 14, 0);
@@ -537,6 +442,7 @@ gboolean gtk2_show_uri_load(JNIEnv *env) {
fprintf(stderr, "dlsym(gtk_show_uri) returned NULL\n");
#endif /* DEBUG */
} else {
+ gtk->gtk_show_uri = fp_gtk_show_uri;
update_supported_actions(env);
success = TRUE;
}
@@ -547,7 +453,7 @@ gboolean gtk2_show_uri_load(JNIEnv *env) {
/**
* Functions for sun_awt_X11_GtkFileDialogPeer.c
*/
-void gtk2_file_chooser_load()
+static void gtk2_file_chooser_load()
{
fp_gtk_file_chooser_get_filename = dl_symbol(
"gtk_file_chooser_get_filename");
@@ -576,7 +482,7 @@ void gtk2_file_chooser_load()
fp_gdk_x11_drawable_get_xid = dl_symbol("gdk_x11_drawable_get_xid");
}
-gboolean gtk2_load(JNIEnv *env)
+GtkApi* gtk2_load(JNIEnv *env, const char* lib_name)
{
gboolean result;
int i;
@@ -584,11 +490,9 @@ gboolean gtk2_load(JNIEnv *env)
int (*io_handler)();
char *gtk_modules_env;
- gtk2_libhandle = dlopen(GTK2_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
+ gtk2_libhandle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL);
if (gtk2_libhandle == NULL) {
- gtk2_libhandle = dlopen(GTK2_LIB, RTLD_LAZY | RTLD_LOCAL);
- if (gtk2_libhandle == NULL)
- return FALSE;
+ return FALSE;
}
gthread_libhandle = dlopen(GTHREAD_LIB_VERSIONED, RTLD_LAZY | RTLD_LOCAL);
@@ -962,8 +866,12 @@ gboolean gtk2_load(JNIEnv *env)
{
gtk2_widgets[i] = NULL;
}
-
- return result;
+ if (result) {
+ GtkApi* gtk = (GtkApi*)malloc(sizeof(GtkApi));
+ gtk2_init(gtk);
+ return gtk;
+ }
+ return NULL;
}
int gtk2_unload()
@@ -1007,7 +915,7 @@ int gtk2_unload()
/* Dispatch all pending events from the GTK event loop.
* This is needed to catch theme change and update widgets' style.
*/
-void flush_gtk_event_loop()
+static void flush_gtk_event_loop()
{
while( (*fp_g_main_context_iteration)(NULL, FALSE));
}
@@ -1056,7 +964,7 @@ static void init_containers()
* comparing results. This can be optimized by using subclassed pixmap and
* doing the second drawing only if necessary.
*/
-void gtk2_init_painting(JNIEnv *env, gint width, gint height)
+static void gtk2_init_painting(JNIEnv *env, gint width, gint height)
{
GdkGC *gc;
GdkPixbuf *white, *black;
@@ -1116,7 +1024,7 @@ void gtk2_init_painting(JNIEnv *env, gint width, gint height)
* one of java_awt_Transparency_OPAQUE, java_awt_Transparency_BITMASK, and
* java_awt_Transparency_TRANSLUCENT.
*/
-gint gtk2_copy_image(gint *dst, gint width, gint height)
+static gint gtk2_copy_image(gint *dst, gint width, gint height)
{
gint i, j, r, g, b;
guchar *white, *black;
@@ -1778,7 +1686,7 @@ void gtk2_paint_arrow(WidgetType widget_type, GtkStateType state_type,
x, y, w, h);
}
-void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
GtkShadowType shadow_type, const gchar *detail,
gint x, gint y, gint width, gint height,
gint synth_state, GtkTextDirection dir)
@@ -1948,7 +1856,7 @@ void gtk2_paint_box_gap(WidgetType widget_type, GtkStateType state_type,
x, y, width, height, gap_side, gap_x, gap_width);
}
-void gtk2_paint_check(WidgetType widget_type, gint synth_state,
+static void gtk2_paint_check(WidgetType widget_type, gint synth_state,
const gchar *detail, gint x, gint y, gint width, gint height)
{
GtkStateType state_type = get_gtk_state_type(widget_type, synth_state);
@@ -1965,7 +1873,7 @@ void gtk2_paint_check(WidgetType widget_type, gint synth_state,
x, y, width, height);
}
-void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type,
GtkShadowType shadow_type, const gchar *detail,
gint x, gint y, gint width, gint height)
{
@@ -1978,7 +1886,7 @@ void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type,
x, y, width, height);
}
-void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type,
const gchar *detail, gint x, gint y, gint width, gint height,
GtkExpanderStyle expander_style)
{
@@ -1991,7 +1899,7 @@ void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type,
x + width / 2, y + height / 2, expander_style);
}
-void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type,
GtkShadowType shadow_type, const gchar *detail,
gint x, gint y, gint width, gint height, GtkPositionType gap_side)
{
@@ -2004,7 +1912,7 @@ void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type,
x, y, width, height, gap_side);
}
-void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
GtkShadowType shadow_type, const gchar *detail,
gint x, gint y, gint width, gint height, gboolean has_focus)
{
@@ -2023,7 +1931,7 @@ void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
x, y, width, height);
}
-void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type,
const char *detail, gint x, gint y, gint width, gint height)
{
gtk2_widget = gtk2_get_widget(widget_type);
@@ -2033,7 +1941,7 @@ void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type,
NULL, gtk2_widget, detail, x, y, width, height);
}
-void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type,
GtkShadowType shadow_type, const gchar *detail,
gint x, gint y, gint width, gint height, GtkOrientation orientation)
{
@@ -2046,7 +1954,7 @@ void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type,
x, y, width, height, orientation);
}
-void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type,
const gchar *detail, gint x, gint y, gint width, gint height)
{
gtk2_widget = gtk2_get_widget(widget_type);
@@ -2056,7 +1964,7 @@ void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type,
NULL, gtk2_widget, detail, x, x + width, y);
}
-void gtk2_paint_option(WidgetType widget_type, gint synth_state,
+static void gtk2_paint_option(WidgetType widget_type, gint synth_state,
const gchar *detail, gint x, gint y, gint width, gint height)
{
GtkStateType state_type = get_gtk_state_type(widget_type, synth_state);
@@ -2073,7 +1981,7 @@ void gtk2_paint_option(WidgetType widget_type, gint synth_state,
x, y, width, height);
}
-void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type,
GtkShadowType shadow_type, const gchar *detail,
gint x, gint y, gint width, gint height,
gint synth_state, GtkTextDirection dir)
@@ -2123,9 +2031,10 @@ void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type,
gtk2_set_direction(gtk2_widget, GTK_TEXT_DIR_LTR);
}
-void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type,
GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height, GtkOrientation orientation)
+ gint x, gint y, gint width, gint height, GtkOrientation orientation,
+ gboolean has_focus)
{
gtk2_widget = gtk2_get_widget(widget_type);
(*fp_gtk_paint_slider)(gtk2_widget->style, gtk2_white_pixmap, state_type,
@@ -2136,7 +2045,7 @@ void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type,
x, y, width, height, orientation);
}
-void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
+static void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
const gchar *detail, gint x, gint y, gint width, gint height)
{
gtk2_widget = gtk2_get_widget(widget_type);
@@ -2146,7 +2055,7 @@ void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
NULL, gtk2_widget, detail, y, y + height, x);
}
-void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
+static void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
gint x, gint y, gint width, gint height)
{
gtk2_widget = gtk2_get_widget(widget_type);
@@ -2156,7 +2065,7 @@ void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
gtk2_black_pixmap, TRUE, state_type, NULL, x, y, width, height);
}
-GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
+static GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
GtkIconSize size, GtkTextDirection direction, const char *detail)
{
init_containers();
@@ -2166,8 +2075,52 @@ GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
return (*fp_gtk_widget_render_icon)(gtk2_widget, stock_id, size, detail);
}
+static jboolean gtk2_get_pixbuf_data(JNIEnv *env, GdkPixbuf* pixbuf,
+ jmethodID icon_upcall_method, jobject this) {
+ if (!pixbuf) {
+ return JNI_FALSE;
+ }
+ guchar *pixbuf_data = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
+ if (pixbuf_data) {
+ int row_stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
+ int width = (*fp_gdk_pixbuf_get_width)(pixbuf);
+ int height = (*fp_gdk_pixbuf_get_height)(pixbuf);
+ int bps = (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf);
+ int channels = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
+ gboolean alpha = (*fp_gdk_pixbuf_get_has_alpha)(pixbuf);
+
+ jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
+ JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
+
+ (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
+ (jbyte *)pixbuf_data);
+ (*fp_g_object_unref)(pixbuf);
+
+ /* Call the callback method to create the image on the Java side. */
+ (*env)->CallVoidMethod(env, this, icon_upcall_method, data,
+ width, height, row_stride, bps, channels, alpha);
+ return JNI_TRUE;
+ }
+ return JNI_FALSE;
+}
+
+static jboolean gtk2_get_file_icon_data(JNIEnv *env, const char *filename,
+ GError **error, jmethodID icon_upcall_method, jobject this) {
+ GdkPixbuf* pixbuf = fp_gdk_pixbuf_new_from_file(filename, error);
+ return gtk2_get_pixbuf_data(env, pixbuf, icon_upcall_method, this);
+}
+
+static jboolean gtk2_get_icon_data(JNIEnv *env, gint widget_type,
+ const gchar *stock_id, GtkIconSize size,
+ GtkTextDirection direction, const char *detail,
+ jmethodID icon_upcall_method, jobject this) {
+ GdkPixbuf* pixbuf = gtk2_get_stock_icon(widget_type, stock_id, size,
+ direction, detail);
+ return gtk2_get_pixbuf_data(env, pixbuf, icon_upcall_method, this);
+}
+
/*************************************************/
-gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type)
+static gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type)
{
init_containers();
@@ -2176,7 +2129,7 @@ gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type)
return style->xthickness;
}
-gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type)
+static gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type)
{
init_containers();
@@ -2186,12 +2139,12 @@ gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type)
}
/*************************************************/
-guint8 recode_color(guint16 channel)
+static guint8 recode_color(guint16 channel)
{
return (guint8)(channel>>8);
}
-gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
+static gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
GtkStateType state_type, ColorType color_type)
{
gint result = 0;
@@ -2243,19 +2196,19 @@ gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
}
/*************************************************/
-jobject create_Boolean(JNIEnv *env, jboolean boolean_value);
-jobject create_Integer(JNIEnv *env, jint int_value);
-jobject create_Long(JNIEnv *env, jlong long_value);
-jobject create_Float(JNIEnv *env, jfloat float_value);
-jobject create_Double(JNIEnv *env, jdouble double_value);
-jobject create_Character(JNIEnv *env, jchar char_value);
-jobject create_Insets(JNIEnv *env, GtkBorder *border);
+static jobject create_Boolean(JNIEnv *env, jboolean boolean_value);
+static jobject create_Integer(JNIEnv *env, jint int_value);
+static jobject create_Long(JNIEnv *env, jlong long_value);
+static jobject create_Float(JNIEnv *env, jfloat float_value);
+static jobject create_Double(JNIEnv *env, jdouble double_value);
+static jobject create_Character(JNIEnv *env, jchar char_value);
+static jobject create_Insets(JNIEnv *env, GtkBorder *border);
-jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring jkey)
+static jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type,
+ const char* key)
{
init_containers();
- const char* key = getStrFor(env, jkey);
gtk2_widget = gtk2_get_widget(widget_type);
GValue value;
@@ -2376,7 +2329,7 @@ jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring jkey)
return NULL;
}
-void gtk2_set_range_value(WidgetType widget_type, jdouble value,
+static void gtk2_set_range_value(WidgetType widget_type, jdouble value,
jdouble min, jdouble max, jdouble visible)
{
GtkAdjustment *adj;
@@ -2391,7 +2344,7 @@ void gtk2_set_range_value(WidgetType widget_type, jdouble value,
}
/*************************************************/
-jobject create_Object(JNIEnv *env, jmethodID *cid,
+static jobject create_Object(JNIEnv *env, jmethodID *cid,
const char* class_name,
const char* signature,
jvalue* value)
@@ -2494,7 +2447,7 @@ jobject create_Insets(JNIEnv *env, GtkBorder *border)
}
/*********************************************/
-jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type)
+static jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type)
{
init_containers();
@@ -2513,7 +2466,7 @@ jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type)
}
/***********************************************/
-jobject get_string_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
+static jobject get_string_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
{
jobject result = NULL;
gchar* strval = NULL;
@@ -2525,21 +2478,21 @@ jobject get_string_property(JNIEnv *env, GtkSettings* settings, const gchar* key
return result;
}
-jobject get_integer_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
+static jobject get_integer_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
{
gint intval = NULL;
(*fp_g_object_get)(settings, key, &intval, NULL);
return create_Integer(env, intval);
}
-jobject get_boolean_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
+static jobject get_boolean_property(JNIEnv *env, GtkSettings* settings, const gchar* key)
{
gint intval = NULL;
(*fp_g_object_get)(settings, key, &intval, NULL);
return create_Boolean(env, intval);
}
-jobject gtk2_get_setting(JNIEnv *env, Setting property)
+static jobject gtk2_get_setting(JNIEnv *env, Setting property)
{
GtkSettings* settings = (*fp_gtk_settings_get_default)();
@@ -2557,3 +2510,148 @@ jobject gtk2_get_setting(JNIEnv *env, Setting property)
return NULL;
}
+
+static gboolean gtk2_get_drawable_data(JNIEnv *env, jintArray pixelArray, jint x,
+ jint y, jint width, jint height, jint jwidth, int dx, int dy, jint scale) {
+ GdkPixbuf *pixbuf;
+ jint *ary;
+
+ GdkWindow *root = (*fp_gdk_get_default_root_window)();
+
+ pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(NULL, root, NULL, x, y,
+ 0, 0, width, height);
+ if (pixbuf && scale != 1) {
+ GdkPixbuf *scaledPixbuf;
+ x /= scale;
+ y /= scale;
+ width /= scale;
+ height /= scale;
+ dx /= scale;
+ dy /= scale;
+ scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
+ GDK_INTERP_BILINEAR);
+ (*fp_g_object_unref)(pixbuf);
+ pixbuf = scaledPixbuf;
+ }
+
+ if (pixbuf) {
+ int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
+ int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
+
+ if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
+ && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
+ && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
+ && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
+ && nchan >= 3
+ ) {
+ guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
+
+ ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
+ if (ary) {
+ jint _x, _y;
+ int index;
+ for (_y = 0; _y < height; _y++) {
+ for (_x = 0; _x < width; _x++) {
+ p = pix + _y * stride + _x * nchan;
+
+ index = (_y + dy) * jwidth + (_x + dx);
+ ary[index] = 0xff000000
+ | (p[0] << 16)
+ | (p[1] << 8)
+ | (p[2]);
+
+ }
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0);
+ }
+ }
+ (*fp_g_object_unref)(pixbuf);
+ }
+ return JNI_FALSE;
+}
+
+static GdkWindow* gtk2_get_window(void *widget) {
+ return ((GtkWidget*)widget)->window;
+}
+
+void gtk2_init(GtkApi* gtk) {
+ gtk->version = GTK_2;
+
+ gtk->show_uri_load = >k2_show_uri_load;
+ gtk->unload = >k2_unload;
+ gtk->flush_event_loop = &flush_gtk_event_loop;
+ gtk->gtk_check_version = fp_gtk_check_version;
+ gtk->get_setting = >k2_get_setting;
+
+ gtk->paint_arrow = >k2_paint_arrow;
+ gtk->paint_box = >k2_paint_box;
+ gtk->paint_box_gap = >k2_paint_box_gap;
+ gtk->paint_expander = >k2_paint_expander;
+ gtk->paint_extension = >k2_paint_extension;
+ gtk->paint_flat_box = >k2_paint_flat_box;
+ gtk->paint_focus = >k2_paint_focus;
+ gtk->paint_handle = >k2_paint_handle;
+ gtk->paint_hline = >k2_paint_hline;
+ gtk->paint_vline = >k2_paint_vline;
+ gtk->paint_option = >k2_paint_option;
+ gtk->paint_shadow = >k2_paint_shadow;
+ gtk->paint_slider = >k2_paint_slider;
+ gtk->paint_background = >k_paint_background;
+ gtk->paint_check = >k2_paint_check;
+ gtk->set_range_value = >k2_set_range_value;
+
+ gtk->init_painting = >k2_init_painting;
+ gtk->copy_image = >k2_copy_image;
+
+ gtk->get_xthickness = >k2_get_xthickness;
+ gtk->get_ythickness = >k2_get_ythickness;
+ gtk->get_color_for_state = >k2_get_color_for_state;
+ gtk->get_class_value = >k2_get_class_value;
+
+ gtk->get_pango_font_name = >k2_get_pango_font_name;
+ gtk->get_icon_data = >k2_get_icon_data;
+ gtk->get_file_icon_data = >k2_get_file_icon_data;
+ gtk->gdk_threads_enter = fp_gdk_threads_enter;
+ gtk->gdk_threads_leave = fp_gdk_threads_leave;
+ gtk->gtk_show_uri = fp_gtk_show_uri;
+ gtk->get_drawable_data = >k2_get_drawable_data;
+ gtk->g_free = fp_g_free;
+
+ gtk->gtk_file_chooser_get_filename = fp_gtk_file_chooser_get_filename;
+ gtk->gtk_widget_hide = fp_gtk_widget_hide;
+ gtk->gtk_main_quit = fp_gtk_main_quit;
+ gtk->gtk_file_chooser_dialog_new = fp_gtk_file_chooser_dialog_new;
+ gtk->gtk_file_chooser_set_current_folder =
+ fp_gtk_file_chooser_set_current_folder;
+ gtk->gtk_file_chooser_set_filename = fp_gtk_file_chooser_set_filename;
+ gtk->gtk_file_chooser_set_current_name =
+ fp_gtk_file_chooser_set_current_name;
+ gtk->gtk_file_filter_add_custom = fp_gtk_file_filter_add_custom;
+ gtk->gtk_file_chooser_set_filter = fp_gtk_file_chooser_set_filter;
+ gtk->gtk_file_chooser_get_type = fp_gtk_file_chooser_get_type;
+ gtk->gtk_file_filter_new = fp_gtk_file_filter_new;
+ gtk->gtk_file_chooser_set_do_overwrite_confirmation =
+ fp_gtk_file_chooser_set_do_overwrite_confirmation;
+ gtk->gtk_file_chooser_set_select_multiple =
+ fp_gtk_file_chooser_set_select_multiple;
+ gtk->gtk_file_chooser_get_current_folder =
+ fp_gtk_file_chooser_get_current_folder;
+ gtk->gtk_file_chooser_get_filenames = fp_gtk_file_chooser_get_filenames;
+ gtk->gtk_g_slist_length = fp_gtk_g_slist_length;
+ gtk->g_signal_connect_data = fp_g_signal_connect_data;
+ gtk->gtk_widget_show = fp_gtk_widget_show;
+ gtk->gtk_main = fp_gtk_main;
+ gtk->gtk_main_level = fp_gtk_main_level;
+ gtk->g_path_get_dirname = fp_g_path_get_dirname;
+ gtk->gdk_x11_drawable_get_xid = fp_gdk_x11_drawable_get_xid;
+ gtk->gtk_widget_destroy = fp_gtk_widget_destroy;
+ gtk->gtk_window_present = fp_gtk_window_present;
+ gtk->gtk_window_move = fp_gtk_window_move;
+ gtk->gtk_window_resize = fp_gtk_window_resize;
+ gtk->get_window = >k2_get_window;
+
+ gtk->g_object_unref = fp_g_object_unref;
+ gtk->g_list_append = fp_g_list_append;
+ gtk->g_list_free = fp_g_list_free;
+ gtk->g_list_free_full = fp_g_list_free_full;
+}
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h
index c94749ecb51..b405e070f43 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.h
@@ -28,232 +28,11 @@
#include
#include
#include
-
-#define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip)
-#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type))
-#define GTK_TYPE_FILE_CHOOSER (fp_gtk_file_chooser_get_type ())
-#define GTK_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser))
-#define fp_g_signal_connect(instance, detailed_signal, c_handler, data) \
- fp_g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0)
-#define G_CALLBACK(f) ((GCallback) (f))
-#define G_TYPE_FUNDAMENTAL_SHIFT (2)
-#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
-#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
-#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
-#define GTK_STOCK_CANCEL "gtk-cancel"
-#define GTK_STOCK_SAVE "gtk-save"
-#define GTK_STOCK_OPEN "gtk-open"
-#define GDK_CURRENT_TIME 0L
-
-typedef enum _WidgetType
-{
- BUTTON, /* GtkButton */
- CHECK_BOX, /* GtkCheckButton */
- CHECK_BOX_MENU_ITEM, /* GtkCheckMenuItem */
- COLOR_CHOOSER, /* GtkColorSelectionDialog */
- COMBO_BOX, /* GtkComboBox */
- COMBO_BOX_ARROW_BUTTON, /* GtkComboBoxEntry */
- COMBO_BOX_TEXT_FIELD, /* GtkComboBoxEntry */
- DESKTOP_ICON, /* GtkLabel */
- DESKTOP_PANE, /* GtkContainer */
- EDITOR_PANE, /* GtkTextView */
- FORMATTED_TEXT_FIELD, /* GtkEntry */
- HANDLE_BOX, /* GtkHandleBox */
- HPROGRESS_BAR, /* GtkProgressBar */
- HSCROLL_BAR, /* GtkHScrollbar */
- HSCROLL_BAR_BUTTON_LEFT, /* GtkHScrollbar */
- HSCROLL_BAR_BUTTON_RIGHT, /* GtkHScrollbar */
- HSCROLL_BAR_TRACK, /* GtkHScrollbar */
- HSCROLL_BAR_THUMB, /* GtkHScrollbar */
- HSEPARATOR, /* GtkHSeparator */
- HSLIDER, /* GtkHScale */
- HSLIDER_TRACK, /* GtkHScale */
- HSLIDER_THUMB, /* GtkHScale */
- HSPLIT_PANE_DIVIDER, /* GtkHPaned */
- INTERNAL_FRAME, /* GtkWindow */
- INTERNAL_FRAME_TITLE_PANE, /* GtkLabel */
- IMAGE, /* GtkImage */
- LABEL, /* GtkLabel */
- LIST, /* GtkTreeView */
- MENU, /* GtkMenu */
- MENU_BAR, /* GtkMenuBar */
- MENU_ITEM, /* GtkMenuItem */
- MENU_ITEM_ACCELERATOR, /* GtkLabel */
- OPTION_PANE, /* GtkMessageDialog */
- PANEL, /* GtkContainer */
- PASSWORD_FIELD, /* GtkEntry */
- POPUP_MENU, /* GtkMenu */
- POPUP_MENU_SEPARATOR, /* GtkSeparatorMenuItem */
- RADIO_BUTTON, /* GtkRadioButton */
- RADIO_BUTTON_MENU_ITEM, /* GtkRadioMenuItem */
- ROOT_PANE, /* GtkContainer */
- SCROLL_PANE, /* GtkScrolledWindow */
- SPINNER, /* GtkSpinButton */
- SPINNER_ARROW_BUTTON, /* GtkSpinButton */
- SPINNER_TEXT_FIELD, /* GtkSpinButton */
- SPLIT_PANE, /* GtkPaned */
- TABBED_PANE, /* GtkNotebook */
- TABBED_PANE_TAB_AREA, /* GtkNotebook */
- TABBED_PANE_CONTENT, /* GtkNotebook */
- TABBED_PANE_TAB, /* GtkNotebook */
- TABLE, /* GtkTreeView */
- TABLE_HEADER, /* GtkButton */
- TEXT_AREA, /* GtkTextView */
- TEXT_FIELD, /* GtkEntry */
- TEXT_PANE, /* GtkTextView */
- TITLED_BORDER, /* GtkFrame */
- TOGGLE_BUTTON, /* GtkToggleButton */
- TOOL_BAR, /* GtkToolbar */
- TOOL_BAR_DRAG_WINDOW, /* GtkToolbar */
- TOOL_BAR_SEPARATOR, /* GtkSeparatorToolItem */
- TOOL_TIP, /* GtkWindow */
- TREE, /* GtkTreeView */
- TREE_CELL, /* GtkTreeView */
- VIEWPORT, /* GtkViewport */
- VPROGRESS_BAR, /* GtkProgressBar */
- VSCROLL_BAR, /* GtkVScrollbar */
- VSCROLL_BAR_BUTTON_UP, /* GtkVScrollbar */
- VSCROLL_BAR_BUTTON_DOWN, /* GtkVScrollbar */
- VSCROLL_BAR_TRACK, /* GtkVScrollbar */
- VSCROLL_BAR_THUMB, /* GtkVScrollbar */
- VSEPARATOR, /* GtkVSeparator */
- VSLIDER, /* GtkVScale */
- VSLIDER_TRACK, /* GtkVScale */
- VSLIDER_THUMB, /* GtkVScale */
- VSPLIT_PANE_DIVIDER, /* GtkVPaned */
- WIDGET_TYPE_SIZE
-} WidgetType;
-
-typedef enum _ColorType
-{
- FOREGROUND,
- BACKGROUND,
- TEXT_FOREGROUND,
- TEXT_BACKGROUND,
- FOCUS,
- LIGHT,
- DARK,
- MID,
- BLACK,
- WHITE
-} ColorType;
-
-typedef enum _Setting
-{
- GTK_FONT_NAME,
- GTK_ICON_SIZES,
- GTK_CURSOR_BLINK,
- GTK_CURSOR_BLINK_TIME
-} Setting;
-
-/* GTK types, here to eliminate need for GTK headers at compile time */
-
-#ifndef FALSE
-#define FALSE (0)
-#define TRUE (!FALSE)
-#endif
+#include "gtk_interface.h"
#define GTK_HAS_FOCUS (1 << 12)
#define GTK_HAS_DEFAULT (1 << 14)
-
-/* basic types */
-typedef char gchar;
-typedef short gshort;
-typedef int gint;
-typedef long glong;
-typedef float gfloat;
-typedef double gdouble;
-typedef void* gpointer;
-typedef gint gboolean;
-
-typedef signed char gint8;
-typedef signed short gint16;
-typedef signed int gint32;
-
-typedef unsigned char guchar;
-typedef unsigned char guint8;
-typedef unsigned short gushort;
-typedef unsigned short guint16;
-typedef unsigned int guint;
-typedef unsigned int guint32;
-typedef unsigned int gsize;
-typedef unsigned long gulong;
-
-typedef signed long long gint64;
-typedef unsigned long long guint64;
-
-/* enumerated constants */
-typedef enum
-{
- GTK_ARROW_UP,
- GTK_ARROW_DOWN,
- GTK_ARROW_LEFT,
- GTK_ARROW_RIGHT
-} GtkArrowType;
-
-typedef enum {
- GDK_COLORSPACE_RGB
-} GdkColorspace;
-
-typedef enum
-{
- GTK_EXPANDER_COLLAPSED,
- GTK_EXPANDER_SEMI_COLLAPSED,
- GTK_EXPANDER_SEMI_EXPANDED,
- GTK_EXPANDER_EXPANDED
-} GtkExpanderStyle;
-
-typedef enum
-{
- GTK_ICON_SIZE_INVALID,
- GTK_ICON_SIZE_MENU,
- GTK_ICON_SIZE_SMALL_TOOLBAR,
- GTK_ICON_SIZE_LARGE_TOOLBAR,
- GTK_ICON_SIZE_BUTTON,
- GTK_ICON_SIZE_DND,
- GTK_ICON_SIZE_DIALOG
-} GtkIconSize;
-
-typedef enum
-{
- GTK_ORIENTATION_HORIZONTAL,
- GTK_ORIENTATION_VERTICAL
-} GtkOrientation;
-
-typedef enum
-{
- GTK_POS_LEFT,
- GTK_POS_RIGHT,
- GTK_POS_TOP,
- GTK_POS_BOTTOM
-} GtkPositionType;
-
-typedef enum
-{
- GTK_SHADOW_NONE,
- GTK_SHADOW_IN,
- GTK_SHADOW_OUT,
- GTK_SHADOW_ETCHED_IN,
- GTK_SHADOW_ETCHED_OUT
-} GtkShadowType;
-
-typedef enum
-{
- GTK_STATE_NORMAL,
- GTK_STATE_ACTIVE,
- GTK_STATE_PRELIGHT,
- GTK_STATE_SELECTED,
- GTK_STATE_INSENSITIVE
-} GtkStateType;
-
-typedef enum
-{
- GTK_TEXT_DIR_NONE,
- GTK_TEXT_DIR_LTR,
- GTK_TEXT_DIR_RTL
-} GtkTextDirection;
-
typedef enum
{
GTK_WINDOW_TOPLEVEL,
@@ -270,41 +49,15 @@ typedef enum
G_PARAM_PRIVATE = 1 << 5
} GParamFlags;
-typedef enum {
- GDK_INTERP_NEAREST,
- GDK_INTERP_TILES,
- GDK_INTERP_BILINEAR,
- GDK_INTERP_HYPER
-} GdkInterpType;
-
/* We define all structure pointers to be void* */
-typedef void GError;
typedef void GMainContext;
typedef void GVfs;
-typedef struct _GSList GSList;
-struct _GSList
-{
- gpointer data;
- GSList *next;
-};
-
-typedef struct _GList GList;
-
-struct _GList
-{
- gpointer data;
- GList *next;
- GList *prev;
-};
-
typedef void GdkColormap;
typedef void GdkDrawable;
typedef void GdkGC;
-typedef void GdkScreen;
typedef void GdkPixbuf;
typedef void GdkPixmap;
-typedef void GdkWindow;
typedef void GtkFixed;
typedef void GtkMenuItem;
@@ -364,7 +117,6 @@ typedef struct {
* structures. This is a place where getting rid of gtk
* headers may be dangerous.
******************************************************/
-typedef gulong GType;
typedef struct
{
@@ -599,70 +351,9 @@ struct _GtkProgressBar
guint ellipsize : 3;
};
-typedef enum {
- GTK_RESPONSE_NONE = -1,
- GTK_RESPONSE_REJECT = -2,
- GTK_RESPONSE_ACCEPT = -3,
- GTK_RESPONSE_DELETE_EVENT = -4,
- GTK_RESPONSE_OK = -5,
- GTK_RESPONSE_CANCEL = -6,
- GTK_RESPONSE_CLOSE = -7,
- GTK_RESPONSE_YES = -8,
- GTK_RESPONSE_NO = -9,
- GTK_RESPONSE_APPLY = -10,
- GTK_RESPONSE_HELP = -11
-} GtkResponseType;
-
-typedef struct _GtkWindow GtkWindow;
-
-typedef struct _GtkFileChooser GtkFileChooser;
-
-typedef enum {
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
-} GtkFileChooserAction;
-
-typedef struct _GtkFileFilter GtkFileFilter;
-
-typedef enum {
- GTK_FILE_FILTER_FILENAME = 1 << 0,
- GTK_FILE_FILTER_URI = 1 << 1,
- GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
- GTK_FILE_FILTER_MIME_TYPE = 1 << 3
-} GtkFileFilterFlags;
-
-typedef struct {
- GtkFileFilterFlags contains;
- const gchar *filename;
- const gchar *uri;
- const gchar *display_name;
- const gchar *mime_type;
-} GtkFileFilterInfo;
-
-typedef gboolean (*GtkFileFilterFunc)(const GtkFileFilterInfo *filter_info,
- gpointer data);
-
-typedef void (*GDestroyNotify)(gpointer data);
-
-typedef void (*GCallback)(void);
-
-typedef struct _GClosure GClosure;
-
-typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
-
-typedef enum {
- G_CONNECT_AFTER = 1 << 0, G_CONNECT_SWAPPED = 1 << 1
-} GConnectFlags;
typedef struct _GThreadFunctions GThreadFunctions;
-/*
- * Converts java.lang.String object to UTF-8 character string.
- */
-const char *getStrFor(JNIEnv *env, jstring value);
-
/**
* Returns :
* NULL if the GLib library is compatible with the given version, or a string
@@ -670,7 +361,7 @@ const char *getStrFor(JNIEnv *env, jstring value);
* Please note that the glib_check_version() is available since 2.6,
* so you should use GLIB_CHECK_VERSION macro instead.
*/
-gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,
+static gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,
guint required_micro);
/**
@@ -680,193 +371,96 @@ gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,
#define GLIB_CHECK_VERSION(major, minor, micro) \
(fp_glib_check_version && fp_glib_check_version(major, minor, micro) == NULL)
-/*
- * Check whether the gtk2 library is available and meets the minimum
- * version requirement. If the library is already loaded this method has no
- * effect and returns success.
- * Returns FALSE on failure and TRUE on success.
- */
-gboolean gtk2_check_version();
-
/**
* Returns :
* NULL if the GTK+ library is compatible with the given version, or a string
* describing the version mismatch.
*/
-gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
+static gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
guint required_micro);
-/*
- * Load the gtk2 library. If the library is already loaded this method has no
- * effect and returns success.
- * Returns FALSE on failure and TRUE on success.
- */
-gboolean gtk2_load(JNIEnv *env);
-/*
- * Loads fp_gtk_show_uri function pointer. This initialization is
- * separated because the function is required only
- * for java.awt.Desktop API. The function relies on initialization in
- * gtk2_load, so it must be invoked only after a successful gtk2_load
- * invocation
- */
-gboolean gtk2_show_uri_load(JNIEnv *env);
+static void gtk2_init(GtkApi* gtk);
-/*
- * Unload the gtk2 library. If the library is already unloaded this method has
- * no effect and returns success.
- * Returns FALSE on failure and TRUE on success.
- */
-gboolean gtk2_unload();
+static void (*fp_g_free)(gpointer mem);
+static void (*fp_g_object_unref)(gpointer object);
+static GdkWindow *(*fp_gdk_get_default_root_window) (void);
-void gtk2_paint_arrow(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height,
- GtkArrowType arrow_type, gboolean fill);
-void gtk2_paint_box(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height,
- gint synth_state, GtkTextDirection dir);
-void gtk2_paint_box_gap(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height,
- GtkPositionType gap_side, gint gap_x, gint gap_width);
-void gtk2_paint_check(WidgetType widget_type, gint synth_state,
- const gchar *detail, gint x, gint y, gint width, gint height);
-void gtk2_paint_diamond(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height);
-void gtk2_paint_expander(WidgetType widget_type, GtkStateType state_type,
- const gchar *detail, gint x, gint y, gint width, gint height,
- GtkExpanderStyle expander_style);
-void gtk2_paint_extension(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height, GtkPositionType gap_side);
-void gtk2_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height, gboolean has_focus);
-void gtk2_paint_focus(WidgetType widget_type, GtkStateType state_type,
- const char *detail, gint x, gint y, gint width, gint height);
-void gtk2_paint_handle(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height, GtkOrientation orientation);
-void gtk2_paint_hline(WidgetType widget_type, GtkStateType state_type,
- const gchar *detail, gint x, gint y, gint width, gint height);
-void gtk2_paint_option(WidgetType widget_type, gint synth_state,
- const gchar *detail, gint x, gint y, gint width, gint height);
-void gtk2_paint_shadow(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height,
- gint synth_state, GtkTextDirection dir);
-void gtk2_paint_slider(WidgetType widget_type, GtkStateType state_type,
- GtkShadowType shadow_type, const gchar *detail,
- gint x, gint y, gint width, gint height, GtkOrientation orientation);
-void gtk2_paint_vline(WidgetType widget_type, GtkStateType state_type,
- const gchar *detail, gint x, gint y, gint width, gint height);
-void gtk_paint_background(WidgetType widget_type, GtkStateType state_type,
- gint x, gint y, gint width, gint height);
+static int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
+static guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
+static gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
+static GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
+static GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
-void gtk2_init_painting(JNIEnv *env, gint w, gint h);
-gint gtk2_copy_image(gint *dest, gint width, gint height);
-
-gint gtk2_get_xthickness(JNIEnv *env, WidgetType widget_type);
-gint gtk2_get_ythickness(JNIEnv *env, WidgetType widget_type);
-gint gtk2_get_color_for_state(JNIEnv *env, WidgetType widget_type,
- GtkStateType state_type, ColorType color_type);
-jobject gtk2_get_class_value(JNIEnv *env, WidgetType widget_type, jstring key);
-
-GdkPixbuf *gtk2_get_stock_icon(gint widget_type, const gchar *stock_id,
- GtkIconSize size, GtkTextDirection direction, const char *detail);
-GdkPixbuf *gtk2_get_icon(const gchar *filename, gint size);
-jstring gtk2_get_pango_font_name(JNIEnv *env, WidgetType widget_type);
-
-void flush_gtk_event_loop();
-
-jobject gtk2_get_setting(JNIEnv *env, Setting property);
-
-void gtk2_set_range_value(WidgetType widget_type, jdouble value,
- jdouble min, jdouble max, jdouble visible);
-
-void (*fp_g_free)(gpointer mem);
-void (*fp_g_object_unref)(gpointer object);
-GdkWindow *(*fp_gdk_get_default_root_window) (void);
-
-int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
-guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
-gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
-int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
-int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
-int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
-int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
-GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
-GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
-
-GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest,
+static GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest,
GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y,
int dest_x, int dest_y, int width, int height);
-GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
+static GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
int dest_width, int dest_heigh, GdkInterpType interp_type);
-void (*fp_gtk_widget_destroy)(GtkWidget *widget);
-void (*fp_gtk_window_present)(GtkWindow *window);
-void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
-void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
+static void (*fp_gtk_widget_destroy)(void *widget);
+static void (*fp_gtk_window_present)(GtkWindow *window);
+static void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
+static void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
/**
* Function Pointers for GtkFileChooser
*/
-gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
-void (*fp_gtk_widget_hide)(GtkWidget *widget);
-void (*fp_gtk_main_quit)(void);
-GtkWidget* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
+static gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
+static void (*fp_gtk_widget_hide)(void *widget);
+static void (*fp_gtk_main_quit)(void);
+static void* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
GtkWindow *parent, GtkFileChooserAction action,
const gchar *first_button_text, ...);
-gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
+static gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
const gchar *filename);
-gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
+static gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
const char *filename);
-void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
+static void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
const gchar *name);
-void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
+static void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
GDestroyNotify notify);
-void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
+static void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
GtkFileFilter *filter);
-GType (*fp_gtk_file_chooser_get_type)(void);
-GtkFileFilter* (*fp_gtk_file_filter_new)(void);
-void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
+static GType (*fp_gtk_file_chooser_get_type)(void);
+static GtkFileFilter* (*fp_gtk_file_filter_new)(void);
+static void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
-void (*fp_gtk_file_chooser_set_select_multiple)(
+static void (*fp_gtk_file_chooser_set_select_multiple)(
GtkFileChooser *chooser, gboolean select_multiple);
-gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
-GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
-guint (*fp_gtk_g_slist_length)(GSList *list);
-gulong (*fp_g_signal_connect_data)(gpointer instance,
+static gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
+static GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
+static guint (*fp_gtk_g_slist_length)(GSList *list);
+static gulong (*fp_g_signal_connect_data)(gpointer instance,
const gchar *detailed_signal, GCallback c_handler, gpointer data,
GClosureNotify destroy_data, GConnectFlags connect_flags);
-void (*fp_gtk_widget_show)(GtkWidget *widget);
-void (*fp_gtk_main)(void);
-guint (*fp_gtk_main_level)(void);
-gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
-XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
+static void (*fp_gtk_widget_show)(void *widget);
+static void (*fp_gtk_main)(void);
+static guint (*fp_gtk_main_level)(void);
+static gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
+static XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
-
-GList* (*fp_g_list_append) (GList *list, gpointer data);
-void (*fp_g_list_free) (GList *list);
-void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);
+static GList* (*fp_g_list_append) (GList *list, gpointer data);
+static void (*fp_g_list_free) (GList *list);
+static void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);
/**
* This function is available for GLIB > 2.20, so it MUST be
* called within GLIB_CHECK_VERSION(2, 20, 0) check.
*/
-gboolean (*fp_g_thread_get_initialized)(void);
+static gboolean (*fp_g_thread_get_initialized)(void);
-void (*fp_g_thread_init)(GThreadFunctions *vtable);
-void (*fp_gdk_threads_init)(void);
-void (*fp_gdk_threads_enter)(void);
-void (*fp_gdk_threads_leave)(void);
+static void (*fp_g_thread_init)(GThreadFunctions *vtable);
+static void (*fp_gdk_threads_init)(void);
+static void (*fp_gdk_threads_enter)(void);
+static void (*fp_gdk_threads_leave)(void);
-gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
+static gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
guint32 timestamp, GError **error);
#endif /* !_GTK2_INTERFACE_H */
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c
new file mode 100644
index 00000000000..060b082e53b
--- /dev/null
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c
@@ -0,0 +1,2882 @@
+/*
+ * 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
+ * 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
+#include
+#include
+#include "gtk3_interface.h"
+#include "java_awt_Transparency.h"
+#include "sizecalc.h"
+#include
+#include
+#include "awt.h"
+
+static void *gtk3_libhandle = NULL;
+
+static jmp_buf j;
+
+/* Widgets */
+static GtkWidget *gtk3_widget = NULL;
+static GtkWidget *gtk3_window = NULL;
+static GtkFixed *gtk3_fixed = NULL;
+static GtkStyleProvider *gtk3_css = NULL;
+
+/* Paint system */
+static cairo_surface_t *surface = NULL;
+static cairo_t *cr = NULL;
+
+static const char ENV_PREFIX[] = "GTK_MODULES=";
+
+static GtkWidget *gtk3_widgets[_GTK_WIDGET_TYPE_SIZE];
+
+static void throw_exception(JNIEnv *env, const char* name, const char* message)
+{
+ jclass class = (*env)->FindClass(env, name);
+
+ if (class != NULL)
+ (*env)->ThrowNew(env, class, message);
+
+ (*env)->DeleteLocalRef(env, class);
+}
+
+static void gtk3_add_state(GtkWidget *widget, GtkStateType state) {
+ GtkStateType old_state = fp_gtk_widget_get_state(widget);
+ fp_gtk_widget_set_state(widget, old_state | state);
+}
+
+static void gtk3_remove_state(GtkWidget *widget, GtkStateType state) {
+ GtkStateType old_state = fp_gtk_widget_get_state(widget);
+ fp_gtk_widget_set_state(widget, old_state & ~state);
+}
+
+/* This is a workaround for the bug:
+ * http://sourceware.org/bugzilla/show_bug.cgi?id=1814
+ * (dlsym/dlopen clears dlerror state)
+ * This bug is specific to Linux, but there is no harm in
+ * applying this workaround on Solaris as well.
+ */
+static void* dl_symbol(const char* name)
+{
+ void* result = dlsym(gtk3_libhandle, name);
+ if (!result)
+ longjmp(j, NO_SYMBOL_EXCEPTION);
+
+ return result;
+}
+
+gboolean gtk3_check(const char* lib_name, int flags)
+{
+ if (gtk3_libhandle != NULL) {
+ /* We've already successfully opened the GTK libs, so return true. */
+ return TRUE;
+ } else {
+ return dlopen(lib_name, flags) != NULL;
+ }
+}
+
+#define ADD_SUPPORTED_ACTION(actionStr) \
+do { \
+ jfieldID fld_action = (*env)->GetStaticFieldID(env, cls_action, actionStr, \
+ "Ljava/awt/Desktop$Action;"); \
+ if (!(*env)->ExceptionCheck(env)) { \
+ jobject action = (*env)->GetStaticObjectField(env, cls_action, \
+ fld_action); \
+ (*env)->CallBooleanMethod(env, supportedActions, mid_arrayListAdd, \
+ action); \
+ } else { \
+ (*env)->ExceptionClear(env); \
+ } \
+} while(0);
+
+
+static void update_supported_actions(JNIEnv *env) {
+ GVfs * (*fp_g_vfs_get_default) (void);
+ const gchar * const * (*fp_g_vfs_get_supported_uri_schemes) (GVfs * vfs);
+ const gchar * const * schemes = NULL;
+
+ jclass cls_action = (*env)->FindClass(env, "java/awt/Desktop$Action");
+ CHECK_NULL(cls_action);
+ jclass cls_xDesktopPeer = (*env)->
+ FindClass(env, "sun/awt/X11/XDesktopPeer");
+ CHECK_NULL(cls_xDesktopPeer);
+ jfieldID fld_supportedActions = (*env)->GetStaticFieldID(env,
+ cls_xDesktopPeer, "supportedActions", "Ljava/util/List;");
+ CHECK_NULL(fld_supportedActions);
+ jobject supportedActions = (*env)->GetStaticObjectField(env,
+ cls_xDesktopPeer, fld_supportedActions);
+
+ jclass cls_arrayList = (*env)->FindClass(env, "java/util/ArrayList");
+ CHECK_NULL(cls_arrayList);
+ jmethodID mid_arrayListAdd = (*env)->GetMethodID(env, cls_arrayList, "add",
+ "(Ljava/lang/Object;)Z");
+ CHECK_NULL(mid_arrayListAdd);
+ jmethodID mid_arrayListClear = (*env)->GetMethodID(env, cls_arrayList,
+ "clear", "()V");
+ CHECK_NULL(mid_arrayListClear);
+
+ (*env)->CallVoidMethod(env, supportedActions, mid_arrayListClear);
+
+ ADD_SUPPORTED_ACTION("OPEN");
+
+ /**
+ * gtk_show_uri() documentation says:
+ *
+ * > you need to install gvfs to get support for uri schemes such as http://
+ * > or ftp://, as only local files are handled by GIO itself.
+ *
+ * So OPEN action was safely added here.
+ * However, it looks like Solaris 11 have gvfs support only for 32-bit
+ * applications only by default.
+ */
+
+ fp_g_vfs_get_default = dl_symbol("g_vfs_get_default");
+ fp_g_vfs_get_supported_uri_schemes =
+ dl_symbol("g_vfs_get_supported_uri_schemes");
+ dlerror();
+
+ if (fp_g_vfs_get_default && fp_g_vfs_get_supported_uri_schemes) {
+ GVfs * vfs = fp_g_vfs_get_default();
+ schemes = vfs ? fp_g_vfs_get_supported_uri_schemes(vfs) : NULL;
+ if (schemes) {
+ int i = 0;
+ while (schemes[i]) {
+ if (strcmp(schemes[i], "http") == 0) {
+ ADD_SUPPORTED_ACTION("BROWSE");
+ ADD_SUPPORTED_ACTION("MAIL");
+ break;
+ }
+ i++;
+ }
+ }
+ } else {
+#ifdef DEBUG
+ fprintf(stderr, "Cannot load g_vfs_get_supported_uri_schemes\n");
+#endif /* DEBUG */
+ }
+
+}
+/**
+ * Functions for awt_Desktop.c
+ */
+static gboolean gtk3_show_uri_load(JNIEnv *env) {
+ gboolean success = FALSE;
+ dlerror();
+ fp_gtk_show_uri = dl_symbol("gtk_show_uri");
+ const char *dlsym_error = dlerror();
+ if (dlsym_error) {
+#ifdef DEBUG
+ fprintf (stderr, "Cannot load symbol: %s \n", dlsym_error);
+#endif /* DEBUG */
+ } else if (fp_gtk_show_uri == NULL) {
+#ifdef DEBUG
+ fprintf(stderr, "dlsym(gtk_show_uri) returned NULL\n");
+#endif /* DEBUG */
+ } else {
+ gtk->gtk_show_uri = fp_gtk_show_uri;
+ update_supported_actions(env);
+ success = TRUE;
+ }
+ return success;
+}
+
+/**
+ * Functions for sun_awt_X11_GtkFileDialogPeer.c
+ */
+static void gtk3_file_chooser_load()
+{
+ fp_gtk_file_chooser_get_filename = dl_symbol(
+ "gtk_file_chooser_get_filename");
+ fp_gtk_file_chooser_dialog_new = dl_symbol("gtk_file_chooser_dialog_new");
+ fp_gtk_file_chooser_set_current_folder = dl_symbol(
+ "gtk_file_chooser_set_current_folder");
+ fp_gtk_file_chooser_set_filename = dl_symbol(
+ "gtk_file_chooser_set_filename");
+ fp_gtk_file_chooser_set_current_name = dl_symbol(
+ "gtk_file_chooser_set_current_name");
+ fp_gtk_file_filter_add_custom = dl_symbol("gtk_file_filter_add_custom");
+ fp_gtk_file_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter");
+ fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type");
+ fp_gtk_file_filter_new = dl_symbol("gtk_file_filter_new");
+ fp_gtk_file_chooser_set_do_overwrite_confirmation = dl_symbol(
+ "gtk_file_chooser_set_do_overwrite_confirmation");
+ fp_gtk_file_chooser_set_select_multiple = dl_symbol(
+ "gtk_file_chooser_set_select_multiple");
+ fp_gtk_file_chooser_get_current_folder = dl_symbol(
+ "gtk_file_chooser_get_current_folder");
+ fp_gtk_file_chooser_get_filenames = dl_symbol(
+ "gtk_file_chooser_get_filenames");
+ fp_gtk_g_slist_length = dl_symbol("g_slist_length");
+ fp_gdk_x11_drawable_get_xid = dl_symbol("gdk_x11_window_get_xid");
+}
+
+static void empty() {}
+
+static gboolean gtk3_version_3_10 = TRUE;
+static gboolean gtk3_version_3_14 = FALSE;
+
+GtkApi* gtk3_load(JNIEnv *env, const char* lib_name)
+{
+ gboolean result;
+ int i;
+ int (*handler)();
+ int (*io_handler)();
+ char *gtk_modules_env;
+ gtk3_libhandle = dlopen(lib_name, RTLD_LAZY | RTLD_LOCAL);
+ if (gtk3_libhandle == NULL) {
+ return FALSE;
+ }
+
+ if (setjmp(j) == 0)
+ {
+ fp_gtk_check_version = dl_symbol("gtk_check_version");
+
+ /* GLib */
+ fp_glib_check_version = dlsym(gtk3_libhandle, "glib_check_version");
+ if (!fp_glib_check_version) {
+ dlerror();
+ }
+ fp_g_free = dl_symbol("g_free");
+ fp_g_object_unref = dl_symbol("g_object_unref");
+
+ fp_g_main_context_iteration =
+ dl_symbol("g_main_context_iteration");
+
+ fp_g_value_init = dl_symbol("g_value_init");
+ fp_g_type_is_a = dl_symbol("g_type_is_a");
+ fp_g_value_get_boolean = dl_symbol("g_value_get_boolean");
+ fp_g_value_get_char = dl_symbol("g_value_get_char");
+ fp_g_value_get_uchar = dl_symbol("g_value_get_uchar");
+ fp_g_value_get_int = dl_symbol("g_value_get_int");
+ fp_g_value_get_uint = dl_symbol("g_value_get_uint");
+ fp_g_value_get_long = dl_symbol("g_value_get_long");
+ fp_g_value_get_ulong = dl_symbol("g_value_get_ulong");
+ fp_g_value_get_int64 = dl_symbol("g_value_get_int64");
+ fp_g_value_get_uint64 = dl_symbol("g_value_get_uint64");
+ fp_g_value_get_float = dl_symbol("g_value_get_float");
+ fp_g_value_get_double = dl_symbol("g_value_get_double");
+ fp_g_value_get_string = dl_symbol("g_value_get_string");
+ fp_g_value_get_enum = dl_symbol("g_value_get_enum");
+ fp_g_value_get_flags = dl_symbol("g_value_get_flags");
+ fp_g_value_get_param = dl_symbol("g_value_get_param");
+ fp_g_value_get_boxed = dl_symbol("g_value_get_boxed");
+ fp_g_value_get_pointer = dl_symbol("g_value_get_pointer");
+
+ fp_g_object_get = dl_symbol("g_object_get");
+ fp_g_object_set = dl_symbol("g_object_set");
+
+ fp_g_str_has_prefix = dl_symbol("g_str_has_prefix");
+ fp_g_strsplit = dl_symbol("g_strsplit");
+ fp_g_strfreev = dl_symbol("g_strfreev");
+
+ /* GDK */
+ fp_gdk_get_default_root_window =
+ dl_symbol("gdk_get_default_root_window");
+
+ /* Pixbuf */
+ fp_gdk_pixbuf_new = dl_symbol("gdk_pixbuf_new");
+ fp_gdk_pixbuf_new_from_file =
+ dl_symbol("gdk_pixbuf_new_from_file");
+ fp_gdk_pixbuf_get_from_drawable =
+ dl_symbol("gdk_pixbuf_get_from_window");
+ fp_gdk_pixbuf_get_width = dl_symbol("gdk_pixbuf_get_width");
+ fp_gdk_pixbuf_get_height = dl_symbol("gdk_pixbuf_get_height");
+ fp_gdk_pixbuf_get_pixels = dl_symbol("gdk_pixbuf_get_pixels");
+ fp_gdk_pixbuf_get_rowstride =
+ dl_symbol("gdk_pixbuf_get_rowstride");
+ fp_gdk_pixbuf_get_has_alpha =
+ dl_symbol("gdk_pixbuf_get_has_alpha");
+ fp_gdk_pixbuf_get_bits_per_sample =
+ dl_symbol("gdk_pixbuf_get_bits_per_sample");
+ fp_gdk_pixbuf_get_n_channels =
+ dl_symbol("gdk_pixbuf_get_n_channels");
+ fp_gdk_pixbuf_get_colorspace =
+ dl_symbol("gdk_pixbuf_get_colorspace");
+
+ fp_cairo_image_surface_create = dl_symbol("cairo_image_surface_create");
+ fp_cairo_surface_destroy = dl_symbol("cairo_surface_destroy");
+ fp_cairo_create = dl_symbol("cairo_create");
+ fp_cairo_destroy = dl_symbol("cairo_destroy");
+ fp_cairo_fill = dl_symbol("cairo_fill");
+ fp_cairo_rectangle = dl_symbol("cairo_rectangle");
+ fp_cairo_set_source_rgb = dl_symbol("cairo_set_source_rgb");
+ fp_cairo_set_source_rgba = dl_symbol("cairo_set_source_rgba");
+ fp_cairo_surface_flush = dl_symbol("cairo_surface_flush");
+ fp_cairo_paint = dl_symbol("cairo_paint");
+ fp_cairo_clip = dl_symbol("cairo_clip");
+ fp_cairo_image_surface_get_data =
+ dl_symbol("cairo_image_surface_get_data");
+ fp_cairo_image_surface_get_stride =
+ dl_symbol("cairo_image_surface_get_stride");
+
+ fp_gdk_pixbuf_get_from_surface =
+ dl_symbol("gdk_pixbuf_get_from_surface");
+
+ fp_gtk_widget_get_state = dl_symbol("gtk_widget_get_state");
+ fp_gtk_widget_set_state = dl_symbol("gtk_widget_set_state");
+
+ fp_gtk_widget_is_focus = dl_symbol("gtk_widget_is_focus");
+ fp_gtk_widget_set_allocation = dl_symbol("gtk_widget_set_allocation");
+ fp_gtk_widget_get_parent = dl_symbol("gtk_widget_get_parent");
+ fp_gtk_widget_get_window = dl_symbol("gtk_widget_get_window");
+
+ fp_gtk_widget_get_style_context =
+ dl_symbol("gtk_widget_get_style_context");
+ fp_gtk_style_context_get_color =
+ dl_symbol("gtk_style_context_get_color");
+ fp_gtk_style_context_get_background_color =
+ dl_symbol("gtk_style_context_get_background_color");
+ fp_gtk_widget_get_state_flags = dl_symbol("gtk_widget_get_state_flags");
+ fp_gtk_style_context_set_state =
+ dl_symbol("gtk_style_context_set_state");
+ fp_gtk_style_context_add_class =
+ dl_symbol("gtk_style_context_add_class");
+ fp_gtk_style_context_save = dl_symbol("gtk_style_context_save");
+ fp_gtk_style_context_restore = dl_symbol("gtk_style_context_restore");
+ fp_gtk_render_check = dl_symbol("gtk_render_check");
+ fp_gtk_render_option = dl_symbol("gtk_render_option");
+ fp_gtk_render_extension = dl_symbol("gtk_render_extension");
+ fp_gtk_render_expander = dl_symbol("gtk_render_expander");
+ fp_gtk_render_frame_gap = dl_symbol("gtk_render_frame_gap");
+ fp_gtk_render_line = dl_symbol("gtk_render_line");
+ fp_gtk_widget_render_icon_pixbuf =
+ dl_symbol("gtk_widget_render_icon_pixbuf");
+ if (fp_gtk_check_version(3, 10, 0)) {
+ gtk3_version_3_10 = FALSE;
+ } else {
+ fp_gdk_window_create_similar_image_surface =
+ dl_symbol("gdk_window_create_similar_image_surface");
+ }
+ gtk3_version_3_14 = !fp_gtk_check_version(3, 14, 0);
+
+ fp_gdk_window_create_similar_surface =
+ dl_symbol("gdk_window_create_similar_surface");
+ fp_gtk_settings_get_for_screen =
+ dl_symbol("gtk_settings_get_for_screen");
+ fp_gtk_widget_get_screen = dl_symbol("gtk_widget_get_screen");
+ fp_gtk_css_provider_get_named = dl_symbol("gtk_css_provider_get_named");
+ fp_gtk_style_context_add_provider =
+ dl_symbol("gtk_style_context_add_provider");
+ fp_gtk_render_frame = dl_symbol("gtk_render_frame");
+ fp_gtk_render_focus = dl_symbol("gtk_render_focus");
+ fp_gtk_render_handle = dl_symbol("gtk_render_handle");
+ fp_gtk_render_arrow = dl_symbol("gtk_render_arrow");
+
+ fp_gtk_style_context_get_property =
+ dl_symbol("gtk_style_context_get_property");
+ fp_gtk_scrolled_window_set_shadow_type =
+ dl_symbol("gtk_scrolled_window_set_shadow_type");
+ fp_gtk_render_slider = dl_symbol("gtk_render_slider");
+ fp_gtk_style_context_get_padding =
+ dl_symbol("gtk_style_context_get_padding");
+ fp_gtk_range_set_inverted = dl_symbol("gtk_range_set_inverted");
+ fp_gtk_style_context_get_font = dl_symbol("gtk_style_context_get_font");
+ fp_gtk_widget_get_allocated_width =
+ dl_symbol("gtk_widget_get_allocated_width");
+ fp_gtk_widget_get_allocated_height =
+ dl_symbol("gtk_widget_get_allocated_height");
+ fp_gtk_icon_theme_get_default = dl_symbol("gtk_icon_theme_get_default");
+ fp_gtk_icon_theme_load_icon = dl_symbol("gtk_icon_theme_load_icon");
+
+ fp_gtk_adjustment_set_lower = dl_symbol("gtk_adjustment_set_lower");
+ fp_gtk_adjustment_set_page_increment =
+ dl_symbol("gtk_adjustment_set_page_increment");
+ fp_gtk_adjustment_set_page_size =
+ dl_symbol("gtk_adjustment_set_page_size");
+ fp_gtk_adjustment_set_step_increment =
+ dl_symbol("gtk_adjustment_set_step_increment");
+ fp_gtk_adjustment_set_upper = dl_symbol("gtk_adjustment_set_upper");
+ fp_gtk_adjustment_set_value = dl_symbol("gtk_adjustment_set_value");
+
+ fp_gtk_render_activity = dl_symbol("gtk_render_activity");
+ fp_gtk_render_background = dl_symbol("gtk_render_background");
+ fp_gtk_style_context_has_class =
+ dl_symbol("gtk_style_context_has_class");
+
+ fp_gtk_style_context_set_junction_sides =
+ dl_symbol("gtk_style_context_set_junction_sides");
+ fp_gtk_style_context_add_region =
+ dl_symbol("gtk_style_context_add_region");
+
+ fp_gtk_init_check = dl_symbol("gtk_init_check");
+
+ /* GTK widgets */
+ fp_gtk_arrow_new = dl_symbol("gtk_arrow_new");
+ fp_gtk_button_new = dl_symbol("gtk_button_new");
+ fp_gtk_spin_button_new = dl_symbol("gtk_spin_button_new");
+ fp_gtk_check_button_new = dl_symbol("gtk_check_button_new");
+ fp_gtk_check_menu_item_new =
+ dl_symbol("gtk_check_menu_item_new");
+ fp_gtk_color_selection_dialog_new =
+ dl_symbol("gtk_color_selection_dialog_new");
+ fp_gtk_entry_new = dl_symbol("gtk_entry_new");
+ fp_gtk_fixed_new = dl_symbol("gtk_fixed_new");
+ fp_gtk_handle_box_new = dl_symbol("gtk_handle_box_new");
+ fp_gtk_image_new = dl_symbol("gtk_image_new");
+ fp_gtk_hpaned_new = dl_symbol("gtk_hpaned_new");
+ fp_gtk_vpaned_new = dl_symbol("gtk_vpaned_new");
+ fp_gtk_scale_new = dl_symbol("gtk_scale_new");
+ fp_gtk_hscrollbar_new = dl_symbol("gtk_hscrollbar_new");
+ fp_gtk_vscrollbar_new = dl_symbol("gtk_vscrollbar_new");
+ fp_gtk_hseparator_new = dl_symbol("gtk_hseparator_new");
+ fp_gtk_vseparator_new = dl_symbol("gtk_vseparator_new");
+ fp_gtk_label_new = dl_symbol("gtk_label_new");
+ fp_gtk_menu_new = dl_symbol("gtk_menu_new");
+ fp_gtk_menu_bar_new = dl_symbol("gtk_menu_bar_new");
+ fp_gtk_menu_item_new = dl_symbol("gtk_menu_item_new");
+ fp_gtk_menu_item_set_submenu =
+ dl_symbol("gtk_menu_item_set_submenu");
+ fp_gtk_notebook_new = dl_symbol("gtk_notebook_new");
+ fp_gtk_progress_bar_new =
+ dl_symbol("gtk_progress_bar_new");
+ fp_gtk_progress_bar_set_orientation =
+ dl_symbol("gtk_orientable_set_orientation");
+ fp_gtk_radio_button_new =
+ dl_symbol("gtk_radio_button_new");
+ fp_gtk_radio_menu_item_new =
+ dl_symbol("gtk_radio_menu_item_new");
+ fp_gtk_scrolled_window_new =
+ dl_symbol("gtk_scrolled_window_new");
+ fp_gtk_separator_menu_item_new =
+ dl_symbol("gtk_separator_menu_item_new");
+ fp_gtk_text_view_new = dl_symbol("gtk_text_view_new");
+ fp_gtk_toggle_button_new =
+ dl_symbol("gtk_toggle_button_new");
+ fp_gtk_toolbar_new = dl_symbol("gtk_toolbar_new");
+ fp_gtk_tree_view_new = dl_symbol("gtk_tree_view_new");
+ fp_gtk_viewport_new = dl_symbol("gtk_viewport_new");
+ fp_gtk_window_new = dl_symbol("gtk_window_new");
+ fp_gtk_window_present = dl_symbol("gtk_window_present");
+ fp_gtk_window_move = dl_symbol("gtk_window_move");
+ fp_gtk_window_resize = dl_symbol("gtk_window_resize");
+
+ fp_gtk_dialog_new = dl_symbol("gtk_dialog_new");
+ fp_gtk_frame_new = dl_symbol("gtk_frame_new");
+
+ fp_gtk_adjustment_new = dl_symbol("gtk_adjustment_new");
+ fp_gtk_container_add = dl_symbol("gtk_container_add");
+ fp_gtk_menu_shell_append =
+ dl_symbol("gtk_menu_shell_append");
+ fp_gtk_widget_realize = dl_symbol("gtk_widget_realize");
+ fp_gtk_widget_destroy = dl_symbol("gtk_widget_destroy");
+ fp_gtk_widget_render_icon =
+ dl_symbol("gtk_widget_render_icon");
+ fp_gtk_widget_set_name =
+ dl_symbol("gtk_widget_set_name");
+ fp_gtk_widget_set_parent =
+ dl_symbol("gtk_widget_set_parent");
+ fp_gtk_widget_set_direction =
+ dl_symbol("gtk_widget_set_direction");
+ fp_gtk_widget_style_get =
+ dl_symbol("gtk_widget_style_get");
+ fp_gtk_widget_class_install_style_property =
+ dl_symbol("gtk_widget_class_install_style_property");
+ fp_gtk_widget_class_find_style_property =
+ dl_symbol("gtk_widget_class_find_style_property");
+ fp_gtk_widget_style_get_property =
+ dl_symbol("gtk_widget_style_get_property");
+ fp_pango_font_description_to_string =
+ dl_symbol("pango_font_description_to_string");
+ fp_gtk_settings_get_default =
+ dl_symbol("gtk_settings_get_default");
+ fp_gtk_widget_get_settings =
+ dl_symbol("gtk_widget_get_settings");
+ fp_gtk_border_get_type = dl_symbol("gtk_border_get_type");
+ fp_gtk_arrow_set = dl_symbol("gtk_arrow_set");
+ fp_gtk_widget_size_request =
+ dl_symbol("gtk_widget_size_request");
+ fp_gtk_range_get_adjustment =
+ dl_symbol("gtk_range_get_adjustment");
+
+ fp_gtk_widget_hide = dl_symbol("gtk_widget_hide");
+ fp_gtk_main_quit = dl_symbol("gtk_main_quit");
+ fp_g_signal_connect_data = dl_symbol("g_signal_connect_data");
+ fp_gtk_widget_show = dl_symbol("gtk_widget_show");
+ fp_gtk_main = dl_symbol("gtk_main");
+
+ fp_g_path_get_dirname = dl_symbol("g_path_get_dirname");
+
+ fp_gdk_threads_enter = ∅
+ fp_gdk_threads_leave = ∅
+
+ /**
+ * Functions for sun_awt_X11_GtkFileDialogPeer.c
+ */
+ gtk3_file_chooser_load();
+
+ fp_gtk_combo_box_new = dlsym(gtk3_libhandle, "gtk_combo_box_new");
+ fp_gtk_combo_box_entry_new = dlsym(gtk3_libhandle,
+ "gtk_combo_box_new_with_entry");
+ fp_gtk_separator_tool_item_new = dlsym(gtk3_libhandle,
+ "gtk_separator_tool_item_new");
+
+ fp_g_list_append = dl_symbol("g_list_append");
+ fp_g_list_free = dl_symbol("g_list_free");
+ fp_g_list_free_full = dl_symbol("g_list_free_full");
+ }
+ /* Now we have only one kind of exceptions: NO_SYMBOL_EXCEPTION
+ * Otherwise we can check the return value of setjmp method.
+ */
+ else
+ {
+ dlclose(gtk3_libhandle);
+ gtk3_libhandle = NULL;
+
+ return NULL;
+ }
+
+ /*
+ * Strip the AT-SPI GTK_MODULEs if present
+ */
+ gtk_modules_env = getenv ("GTK_MODULES");
+ if (gtk_modules_env && strstr (gtk_modules_env, "atk-bridge") ||
+ gtk_modules_env && strstr (gtk_modules_env, "gail"))
+ {
+ /* the new env will be smaller than the old one */
+ gchar *s, *new_env = SAFE_SIZE_STRUCT_ALLOC(malloc,
+ sizeof(ENV_PREFIX), 1, strlen (gtk_modules_env));
+
+ if (new_env != NULL )
+ {
+ /* careful, strtok modifies its args */
+ gchar *tmp_env = strdup (gtk_modules_env);
+ strcpy(new_env, ENV_PREFIX);
+
+ /* strip out 'atk-bridge' and 'gail' */
+ size_t PREFIX_LENGTH = strlen(ENV_PREFIX);
+ while (s = strtok(tmp_env, ":"))
+ {
+ if ((!strstr (s, "atk-bridge")) && (!strstr (s, "gail")))
+ {
+ if (strlen (new_env) > PREFIX_LENGTH) {
+ new_env = strcat (new_env, ":");
+ }
+ new_env = strcat(new_env, s);
+ }
+ if (tmp_env)
+ {
+ free (tmp_env);
+ tmp_env = NULL; /* next call to strtok arg1==NULL */
+ }
+ }
+ putenv (new_env);
+ free (new_env);
+ free (tmp_env);
+ }
+ }
+ /*
+ * GTK should be initialized with gtk_init_check() before use.
+ *
+ * gtk_init_check installs its own error handlers. It is critical that
+ * we preserve error handler set from AWT. Otherwise we'll crash on
+ * BadMatch errors which we would normally ignore. The IO error handler
+ * is preserved here, too, just for consistency.
+ */
+ AWT_LOCK();
+ handler = XSetErrorHandler(NULL);
+ io_handler = XSetIOErrorHandler(NULL);
+ result = (*fp_gtk_init_check)(NULL, NULL);
+ XSetErrorHandler(handler);
+ XSetIOErrorHandler(io_handler);
+ AWT_UNLOCK();
+ /* Initialize widget array. */
+ for (i = 0; i < _GTK_WIDGET_TYPE_SIZE; i++)
+ {
+ gtk3_widgets[i] = NULL;
+ }
+ if (result) {
+ GtkApi* gtk = (GtkApi*)malloc(sizeof(GtkApi));
+ gtk3_init(gtk);
+ return gtk;
+ }
+ return NULL;
+}
+
+static int gtk3_unload()
+{
+ int i;
+ char *gtk3_error;
+
+ if (!gtk3_libhandle)
+ return TRUE;
+
+ /* Release painting objects */
+ if (surface != NULL) {
+ fp_cairo_destroy(cr);
+ fp_cairo_surface_destroy(surface);
+ surface = NULL;
+ }
+
+ if (gtk3_window != NULL) {
+ /* Destroying toplevel widget will destroy all contained widgets */
+ (*fp_gtk_widget_destroy)(gtk3_window);
+
+ /* Unset some static data so they get reinitialized on next load */
+ gtk3_window = NULL;
+ }
+
+ dlerror();
+ dlclose(gtk3_libhandle);
+ if ((gtk3_error = dlerror()) != NULL)
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/* Dispatch all pending events from the GTK event loop.
+ * This is needed to catch theme change and update widgets' style.
+ */
+static void flush_gtk_event_loop()
+{
+ while((*fp_g_main_context_iteration)(NULL));
+}
+
+/*
+ * Initialize components of containment hierarchy. This creates a GtkFixed
+ * inside a GtkWindow. All widgets get realized.
+ */
+static void init_containers()
+{
+ if (gtk3_window == NULL)
+ {
+ gtk3_window = (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL);
+ gtk3_fixed = (GtkFixed *)(*fp_gtk_fixed_new)();
+ (*fp_gtk_container_add)((GtkContainer*)gtk3_window,
+ (GtkWidget *)gtk3_fixed);
+ (*fp_gtk_widget_realize)(gtk3_window);
+ (*fp_gtk_widget_realize)((GtkWidget *)gtk3_fixed);
+
+ GtkSettings* settings = fp_gtk_settings_get_for_screen(
+ fp_gtk_widget_get_screen(gtk3_window));
+ gchar* strval = NULL;
+ fp_g_object_get(settings, "gtk-theme-name", &strval, NULL);
+ gtk3_css = fp_gtk_css_provider_get_named(strval, NULL);
+ }
+}
+
+/*
+ * Ensure everything is ready for drawing an element of the specified width
+ * and height.
+ *
+ * We should somehow handle translucent images. GTK can draw to X Drawables
+ * only, which don't support alpha. When we retrieve the image back from
+ * the server, translucency information is lost. There're several ways to
+ * work around this:
+ * 1) Subclass GdkPixmap and cache translucent objects on client side. This
+ * requires us to implement parts of X server drawing logic on client side.
+ * Many X requests can potentially be "translucent"; e.g. XDrawLine with
+ * fill=tile and a translucent tile is a "translucent" operation, whereas
+ * XDrawLine with fill=solid is an "opaque" one. Moreover themes can (and some
+ * do) intermix transparent and opaque operations which makes caching even
+ * more problematic.
+ * 2) Use Xorg 32bit ARGB visual when available. GDK has no native support
+ * for it (as of version 2.6). Also even in JDS 3 Xorg does not support
+ * these visuals by default, which makes optimizing for them pointless.
+ * We can consider doing this at a later point when ARGB visuals become more
+ * popular.
+ * 3') GTK has plans to use Cairo as its graphical backend (presumably in
+ * 2.8), and Cairo supports alpha. With it we could also get rid of the
+ * unnecessary round trip to server and do all the drawing on client side.
+ * 4) For now we draw to two different pixmaps and restore alpha channel by
+ * comparing results. This can be optimized by using subclassed pixmap and
+*/
+static void gtk3_init_painting(JNIEnv *env, gint width, gint height)
+{
+ init_containers();
+
+ if (cr) {
+ fp_cairo_destroy(cr);
+ }
+
+ if (surface != NULL) {
+ /* free old stuff */
+ fp_cairo_surface_destroy(surface);
+
+ }
+
+ if (gtk3_version_3_10) {
+ surface = fp_gdk_window_create_similar_image_surface(
+ fp_gtk_widget_get_window(gtk3_window),
+ CAIRO_FORMAT_ARGB32, width, height, 1);
+ } else {
+ surface = fp_cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+ width, height);
+ }
+
+ cr = fp_cairo_create(surface);
+}
+
+/*
+ * Restore image from white and black pixmaps and copy it into destination
+ * buffer. This method compares two pixbufs taken from white and black
+ * pixmaps and decodes color and alpha components. Pixbufs are RGB without
+ * alpha, destination buffer is ABGR.
+ *
+ * The return value is the transparency type of the resulting image, either
+ * one of java_awt_Transparency_OPAQUE, java_awt_Transparency_BITMASK, and
+ * java_awt_Transparency_TRANSLUCENT.
+ */
+static gint gtk3_copy_image(gint *dst, gint width, gint height)
+{
+ gint i, j, r, g, b;
+ guchar *data;
+ gint stride, padding;
+
+ fp_cairo_surface_flush(surface);
+ data = (*fp_cairo_image_surface_get_data)(surface);
+ stride = (*fp_cairo_image_surface_get_stride)(surface);
+ padding = stride - width * 4;
+
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ int r = *data++;
+ int g = *data++;
+ int b = *data++;
+ int a = *data++;
+ *dst++ = (a << 24 | b << 16 | g << 8 | r);
+ }
+ data += padding;
+ }
+ return java_awt_Transparency_TRANSLUCENT;
+}
+
+static void gtk3_set_direction(GtkWidget *widget, GtkTextDirection dir)
+{
+ /*
+ * Some engines (inexplicably) look at the direction of the widget's
+ * parent, so we need to set the direction of both the widget and its
+ * parent.
+ */
+ (*fp_gtk_widget_set_direction)(widget, dir);
+ GtkWidget* parent = fp_gtk_widget_get_parent(widget);
+ if (parent != NULL) {
+ fp_gtk_widget_set_direction(parent, dir);
+ }
+}
+
+/* GTK state_type filter */
+static GtkStateType get_gtk_state_type(WidgetType widget_type, gint synth_state)
+{
+ GtkStateType result = GTK_STATE_NORMAL;
+
+ if ((synth_state & DISABLED) != 0) {
+ result = GTK_STATE_INSENSITIVE;
+ } else if ((synth_state & PRESSED) != 0) {
+ result = GTK_STATE_ACTIVE;
+ } else if ((synth_state & MOUSE_OVER) != 0) {
+ result = GTK_STATE_PRELIGHT;
+ }
+ return result;
+}
+
+static GtkStateFlags get_gtk_state_flags(gint synth_state)
+{
+ GtkStateFlags flags = 0;
+
+ if ((synth_state & DISABLED) != 0) {
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ }
+ if (((synth_state & PRESSED) != 0 || (synth_state & SELECTED) != 0)) {
+ flags |= GTK_STATE_FLAG_ACTIVE;
+ }
+ if ((synth_state & MOUSE_OVER) != 0) {
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ }
+ if ((synth_state & FOCUSED) != 0) {
+ flags |= GTK_STATE_FLAG_FOCUSED;
+ }
+ return flags;
+}
+
+static GtkStateFlags get_gtk_flags(GtkStateType state_type) {
+ GtkStateFlags flags = 0;
+ switch (state_type)
+ {
+ case GTK_STATE_PRELIGHT:
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ break;
+ case GTK_STATE_SELECTED:
+ flags |= GTK_STATE_FLAG_SELECTED;
+ break;
+ case GTK_STATE_INSENSITIVE:
+ flags |= GTK_STATE_FLAG_INSENSITIVE;
+ break;
+ case GTK_STATE_ACTIVE:
+ flags |= GTK_STATE_FLAG_ACTIVE;
+ break;
+ case GTK_STATE_FOCUSED:
+ flags |= GTK_STATE_FLAG_FOCUSED;
+ break;
+ default:
+ break;
+ }
+ return flags;
+}
+
+/* GTK shadow_type filter */
+static GtkShadowType get_gtk_shadow_type(WidgetType widget_type,
+ gint synth_state)
+{
+ GtkShadowType result = GTK_SHADOW_OUT;
+
+ if ((synth_state & SELECTED) != 0) {
+ result = GTK_SHADOW_IN;
+ }
+ return result;
+}
+
+
+static GtkWidget* gtk3_get_arrow(GtkArrowType arrow_type,
+ GtkShadowType shadow_type)
+{
+ GtkWidget *arrow = NULL;
+ if (NULL == gtk3_widgets[_GTK_ARROW_TYPE])
+ {
+ gtk3_widgets[_GTK_ARROW_TYPE] = (*fp_gtk_arrow_new)(arrow_type,
+ shadow_type);
+ (*fp_gtk_container_add)((GtkContainer *)gtk3_fixed,
+ gtk3_widgets[_GTK_ARROW_TYPE]);
+ (*fp_gtk_widget_realize)(gtk3_widgets[_GTK_ARROW_TYPE]);
+ }
+ arrow = gtk3_widgets[_GTK_ARROW_TYPE];
+
+ (*fp_gtk_arrow_set)(arrow, arrow_type, shadow_type);
+ return arrow;
+}
+
+static GtkAdjustment* create_adjustment()
+{
+ return (GtkAdjustment *)
+ (*fp_gtk_adjustment_new)(50.0, 0.0, 100.0, 10.0, 20.0, 20.0);
+}
+
+/**
+ * Returns a pointer to the cached native widget for the specified widget
+ * type.
+ */
+static GtkWidget *gtk3_get_widget(WidgetType widget_type)
+{
+ gboolean init_result = FALSE;
+ GtkWidget *result = NULL;
+ switch (widget_type)
+ {
+ case BUTTON:
+ case TABLE_HEADER:
+ if (init_result = (NULL == gtk3_widgets[_GTK_BUTTON_TYPE]))
+ {
+ gtk3_widgets[_GTK_BUTTON_TYPE] = (*fp_gtk_button_new)();
+ }
+ result = gtk3_widgets[_GTK_BUTTON_TYPE];
+ break;
+ case CHECK_BOX:
+ if (init_result = (NULL == gtk3_widgets[_GTK_CHECK_BUTTON_TYPE]))
+ {
+ gtk3_widgets[_GTK_CHECK_BUTTON_TYPE] =
+ (*fp_gtk_check_button_new)();
+ }
+ result = gtk3_widgets[_GTK_CHECK_BUTTON_TYPE];
+ break;
+ case CHECK_BOX_MENU_ITEM:
+ if (init_result = (NULL == gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE]))
+ {
+ gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE] =
+ (*fp_gtk_check_menu_item_new)();
+ }
+ result = gtk3_widgets[_GTK_CHECK_MENU_ITEM_TYPE];
+ break;
+ /************************************************************
+ * Creation a dedicated color chooser is dangerous because
+ * it deadlocks the EDT
+ ************************************************************/
+/* case COLOR_CHOOSER:
+ if (init_result =
+ (NULL == gtk3_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE]))
+ {
+ gtk3_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE] =
+ (*fp_gtk_color_selection_dialog_new)(NULL);
+ }
+ result = gtk3_widgets[_GTK_COLOR_SELECTION_DIALOG_TYPE];
+ break;*/
+ case COMBO_BOX:
+ if (init_result = (NULL == gtk3_widgets[_GTK_COMBO_BOX_TYPE]))
+ {
+ gtk3_widgets[_GTK_COMBO_BOX_TYPE] =
+ (*fp_gtk_combo_box_new)();
+ }
+ result = gtk3_widgets[_GTK_COMBO_BOX_TYPE];
+ break;
+ case COMBO_BOX_ARROW_BUTTON:
+ if (init_result =
+ (NULL == gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE]))
+ {
+ gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE] =
+ (*fp_gtk_toggle_button_new)();
+ }
+ result = gtk3_widgets[_GTK_COMBO_BOX_ARROW_BUTTON_TYPE];
+ break;
+ case COMBO_BOX_TEXT_FIELD:
+ if (init_result =
+ (NULL == gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE]))
+ {
+ result = gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE] =
+ (*fp_gtk_entry_new)();
+ }
+ result = gtk3_widgets[_GTK_COMBO_BOX_TEXT_FIELD_TYPE];
+ break;
+ case DESKTOP_ICON:
+ case INTERNAL_FRAME_TITLE_PANE:
+ case LABEL:
+ if (init_result = (NULL == gtk3_widgets[_GTK_LABEL_TYPE]))
+ {
+ gtk3_widgets[_GTK_LABEL_TYPE] =
+ (*fp_gtk_label_new)(NULL);
+ }
+ result = gtk3_widgets[_GTK_LABEL_TYPE];
+ break;
+ case DESKTOP_PANE:
+ case PANEL:
+ case ROOT_PANE:
+ if (init_result = (NULL == gtk3_widgets[_GTK_CONTAINER_TYPE]))
+ {
+ /* There is no constructor for a container type. I've
+ * chosen GtkFixed container since it has a default
+ * constructor.
+ */
+ gtk3_widgets[_GTK_CONTAINER_TYPE] =
+ (*fp_gtk_fixed_new)();
+ }
+ result = gtk3_widgets[_GTK_CONTAINER_TYPE];
+ break;
+ case EDITOR_PANE:
+ case TEXT_AREA:
+ case TEXT_PANE:
+ if (init_result = (NULL == gtk3_widgets[_GTK_TEXT_VIEW_TYPE]))
+ {
+ gtk3_widgets[_GTK_TEXT_VIEW_TYPE] =
+ (*fp_gtk_text_view_new)();
+ }
+ result = gtk3_widgets[_GTK_TEXT_VIEW_TYPE];
+ break;
+ case FORMATTED_TEXT_FIELD:
+ case PASSWORD_FIELD:
+ case TEXT_FIELD:
+ if (init_result = (NULL == gtk3_widgets[_GTK_ENTRY_TYPE]))
+ {
+ gtk3_widgets[_GTK_ENTRY_TYPE] =
+ (*fp_gtk_entry_new)();
+ }
+ result = gtk3_widgets[_GTK_ENTRY_TYPE];
+ break;
+ case HANDLE_BOX:
+ if (init_result = (NULL == gtk3_widgets[_GTK_HANDLE_BOX_TYPE]))
+ {
+ gtk3_widgets[_GTK_HANDLE_BOX_TYPE] =
+ (*fp_gtk_handle_box_new)();
+ }
+ result = gtk3_widgets[_GTK_HANDLE_BOX_TYPE];
+ break;
+ case HSCROLL_BAR:
+ case HSCROLL_BAR_BUTTON_LEFT:
+ case HSCROLL_BAR_BUTTON_RIGHT:
+ case HSCROLL_BAR_TRACK:
+ case HSCROLL_BAR_THUMB:
+ if (init_result = (NULL == gtk3_widgets[_GTK_HSCROLLBAR_TYPE]))
+ {
+ gtk3_widgets[_GTK_HSCROLLBAR_TYPE] =
+ (*fp_gtk_hscrollbar_new)(create_adjustment());
+ }
+ result = gtk3_widgets[_GTK_HSCROLLBAR_TYPE];
+ break;
+ case HSEPARATOR:
+ if (init_result = (NULL == gtk3_widgets[_GTK_HSEPARATOR_TYPE]))
+ {
+ gtk3_widgets[_GTK_HSEPARATOR_TYPE] =
+ (*fp_gtk_hseparator_new)();
+ }
+ result = gtk3_widgets[_GTK_HSEPARATOR_TYPE];
+ break;
+ case HSLIDER:
+ case HSLIDER_THUMB:
+ case HSLIDER_TRACK:
+ if (init_result = (NULL == gtk3_widgets[_GTK_HSCALE_TYPE]))
+ {
+ gtk3_widgets[_GTK_HSCALE_TYPE] =
+ (*fp_gtk_scale_new)(GTK_ORIENTATION_HORIZONTAL, NULL);
+ }
+ result = gtk3_widgets[_GTK_HSCALE_TYPE];
+ break;
+ case HSPLIT_PANE_DIVIDER:
+ case SPLIT_PANE:
+ if (init_result = (NULL == gtk3_widgets[_GTK_HPANED_TYPE]))
+ {
+ gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_hpaned_new)();
+ }
+ result = gtk3_widgets[_GTK_HPANED_TYPE];
+ break;
+ case IMAGE:
+ if (init_result = (NULL == gtk3_widgets[_GTK_IMAGE_TYPE]))
+ {
+ gtk3_widgets[_GTK_IMAGE_TYPE] = (*fp_gtk_image_new)();
+ }
+ result = gtk3_widgets[_GTK_IMAGE_TYPE];
+ break;
+ case INTERNAL_FRAME:
+ if (init_result = (NULL == gtk3_widgets[_GTK_WINDOW_TYPE]))
+ {
+ gtk3_widgets[_GTK_WINDOW_TYPE] =
+ (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL);
+ }
+ result = gtk3_widgets[_GTK_WINDOW_TYPE];
+ break;
+ case TOOL_TIP:
+ if (init_result = (NULL == gtk3_widgets[_GTK_TOOLTIP_TYPE]))
+ {
+ result = (*fp_gtk_window_new)(GTK_WINDOW_TOPLEVEL);
+ gtk3_widgets[_GTK_TOOLTIP_TYPE] = result;
+ }
+ result = gtk3_widgets[_GTK_TOOLTIP_TYPE];
+ break;
+ case LIST:
+ case TABLE:
+ case TREE:
+ case TREE_CELL:
+ if (init_result = (NULL == gtk3_widgets[_GTK_TREE_VIEW_TYPE]))
+ {
+ gtk3_widgets[_GTK_TREE_VIEW_TYPE] =
+ (*fp_gtk_tree_view_new)();
+ }
+ result = gtk3_widgets[_GTK_TREE_VIEW_TYPE];
+ break;
+ case TITLED_BORDER:
+ if (init_result = (NULL == gtk3_widgets[_GTK_FRAME_TYPE]))
+ {
+ gtk3_widgets[_GTK_FRAME_TYPE] = fp_gtk_frame_new(NULL);
+ }
+ result = gtk3_widgets[_GTK_FRAME_TYPE];
+ break;
+ case POPUP_MENU:
+ if (init_result = (NULL == gtk3_widgets[_GTK_MENU_TYPE]))
+ {
+ gtk3_widgets[_GTK_MENU_TYPE] =
+ (*fp_gtk_menu_new)();
+ }
+ result = gtk3_widgets[_GTK_MENU_TYPE];
+ break;
+ case MENU:
+ case MENU_ITEM:
+ case MENU_ITEM_ACCELERATOR:
+ if (init_result = (NULL == gtk3_widgets[_GTK_MENU_ITEM_TYPE]))
+ {
+ gtk3_widgets[_GTK_MENU_ITEM_TYPE] =
+ (*fp_gtk_menu_item_new)();
+ }
+ result = gtk3_widgets[_GTK_MENU_ITEM_TYPE];
+ break;
+ case MENU_BAR:
+ if (init_result = (NULL == gtk3_widgets[_GTK_MENU_BAR_TYPE]))
+ {
+ gtk3_widgets[_GTK_MENU_BAR_TYPE] =
+ (*fp_gtk_menu_bar_new)();
+ }
+ result = gtk3_widgets[_GTK_MENU_BAR_TYPE];
+ break;
+ case COLOR_CHOOSER:
+ case OPTION_PANE:
+ if (init_result = (NULL == gtk3_widgets[_GTK_DIALOG_TYPE]))
+ {
+ gtk3_widgets[_GTK_DIALOG_TYPE] =
+ (*fp_gtk_dialog_new)();
+ }
+ result = gtk3_widgets[_GTK_DIALOG_TYPE];
+ break;
+ case POPUP_MENU_SEPARATOR:
+ if (init_result =
+ (NULL == gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE]))
+ {
+ gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE] =
+ (*fp_gtk_separator_menu_item_new)();
+ }
+ result = gtk3_widgets[_GTK_SEPARATOR_MENU_ITEM_TYPE];
+ break;
+ case HPROGRESS_BAR:
+ if (init_result = (NULL == gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE]))
+ {
+ gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE] =
+ (*fp_gtk_progress_bar_new)();
+ }
+ result = gtk3_widgets[_GTK_HPROGRESS_BAR_TYPE];
+ break;
+ case VPROGRESS_BAR:
+ if (init_result = (NULL == gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE]))
+ {
+ gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE] =
+ (*fp_gtk_progress_bar_new)();
+ /*
+ * Vertical JProgressBars always go bottom-to-top,
+ * regardless of the ComponentOrientation.
+ */
+ (*fp_gtk_progress_bar_set_orientation)(
+ (GtkProgressBar *)gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE],
+ GTK_PROGRESS_BOTTOM_TO_TOP);
+ }
+ result = gtk3_widgets[_GTK_VPROGRESS_BAR_TYPE];
+ break;
+ case RADIO_BUTTON:
+ if (init_result = (NULL == gtk3_widgets[_GTK_RADIO_BUTTON_TYPE]))
+ {
+ gtk3_widgets[_GTK_RADIO_BUTTON_TYPE] =
+ (*fp_gtk_radio_button_new)(NULL);
+ }
+ result = gtk3_widgets[_GTK_RADIO_BUTTON_TYPE];
+ break;
+ case RADIO_BUTTON_MENU_ITEM:
+ if (init_result =
+ (NULL == gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE]))
+ {
+ gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE] =
+ (*fp_gtk_radio_menu_item_new)(NULL);
+ }
+ result = gtk3_widgets[_GTK_RADIO_MENU_ITEM_TYPE];
+ break;
+ case SCROLL_PANE:
+ if (init_result =
+ (NULL == gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE]))
+ {
+ gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE] =
+ (*fp_gtk_scrolled_window_new)(NULL, NULL);
+ }
+ result = gtk3_widgets[_GTK_SCROLLED_WINDOW_TYPE];
+ break;
+ case SPINNER:
+ case SPINNER_ARROW_BUTTON:
+ case SPINNER_TEXT_FIELD:
+ if (init_result = (NULL == gtk3_widgets[_GTK_SPIN_BUTTON_TYPE]))
+ {
+ result = gtk3_widgets[_GTK_SPIN_BUTTON_TYPE] =
+ (*fp_gtk_spin_button_new)(NULL, 0, 0);
+ }
+ result = gtk3_widgets[_GTK_SPIN_BUTTON_TYPE];
+ break;
+ case TABBED_PANE:
+ case TABBED_PANE_TAB_AREA:
+ case TABBED_PANE_CONTENT:
+ case TABBED_PANE_TAB:
+ if (init_result = (NULL == gtk3_widgets[_GTK_NOTEBOOK_TYPE]))
+ {
+ gtk3_widgets[_GTK_NOTEBOOK_TYPE] =
+ (*fp_gtk_notebook_new)(NULL);
+ }
+ result = gtk3_widgets[_GTK_NOTEBOOK_TYPE];
+ break;
+ case TOGGLE_BUTTON:
+ if (init_result = (NULL == gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE]))
+ {
+ gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE] =
+ (*fp_gtk_toggle_button_new)(NULL);
+ }
+ result = gtk3_widgets[_GTK_TOGGLE_BUTTON_TYPE];
+ break;
+ case TOOL_BAR:
+ case TOOL_BAR_DRAG_WINDOW:
+ if (init_result = (NULL == gtk3_widgets[_GTK_TOOLBAR_TYPE]))
+ {
+ gtk3_widgets[_GTK_TOOLBAR_TYPE] =
+ (*fp_gtk_toolbar_new)(NULL);
+ }
+ result = gtk3_widgets[_GTK_TOOLBAR_TYPE];
+ break;
+ case TOOL_BAR_SEPARATOR:
+ if (init_result =
+ (NULL == gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE]))
+ {
+ gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE] =
+ (*fp_gtk_separator_tool_item_new)();
+ }
+ result = gtk3_widgets[_GTK_SEPARATOR_TOOL_ITEM_TYPE];
+ break;
+ case VIEWPORT:
+ if (init_result = (NULL == gtk3_widgets[_GTK_VIEWPORT_TYPE]))
+ {
+ GtkAdjustment *adjustment = create_adjustment();
+ gtk3_widgets[_GTK_VIEWPORT_TYPE] =
+ (*fp_gtk_viewport_new)(adjustment, adjustment);
+ }
+ result = gtk3_widgets[_GTK_VIEWPORT_TYPE];
+ break;
+ case VSCROLL_BAR:
+ case VSCROLL_BAR_BUTTON_UP:
+ case VSCROLL_BAR_BUTTON_DOWN:
+ case VSCROLL_BAR_TRACK:
+ case VSCROLL_BAR_THUMB:
+ if (init_result = (NULL == gtk3_widgets[_GTK_VSCROLLBAR_TYPE]))
+ {
+ gtk3_widgets[_GTK_VSCROLLBAR_TYPE] =
+ (*fp_gtk_vscrollbar_new)(create_adjustment());
+ }
+ result = gtk3_widgets[_GTK_VSCROLLBAR_TYPE];
+ break;
+ case VSEPARATOR:
+ if (init_result = (NULL == gtk3_widgets[_GTK_VSEPARATOR_TYPE]))
+ {
+ gtk3_widgets[_GTK_VSEPARATOR_TYPE] =
+ (*fp_gtk_vseparator_new)();
+ }
+ result = gtk3_widgets[_GTK_VSEPARATOR_TYPE];
+ break;
+ case VSLIDER:
+ case VSLIDER_THUMB:
+ case VSLIDER_TRACK:
+ if (init_result = (NULL == gtk3_widgets[_GTK_VSCALE_TYPE]))
+ {
+ gtk3_widgets[_GTK_VSCALE_TYPE] =
+ (*fp_gtk_scale_new)(GTK_ORIENTATION_VERTICAL, NULL);
+ }
+ result = gtk3_widgets[_GTK_VSCALE_TYPE];
+ /*
+ * Vertical JSliders start at the bottom, while vertical
+ * GtkVScale widgets start at the top (by default), so to fix
+ * this we set the "inverted" flag to get the Swing behavior.
+ */
+ fp_gtk_range_set_inverted((GtkRange*)result, TRUE);
+ break;
+ case VSPLIT_PANE_DIVIDER:
+ if (init_result = (NULL == gtk3_widgets[_GTK_VPANED_TYPE]))
+ {
+ gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_vpaned_new)();
+ }
+ result = gtk3_widgets[_GTK_VPANED_TYPE];
+ break;
+ default:
+ result = NULL;
+ break;
+ }
+
+ if (result != NULL && init_result)
+ {
+ if (widget_type == RADIO_BUTTON_MENU_ITEM ||
+ widget_type == CHECK_BOX_MENU_ITEM ||
+ widget_type == MENU_ITEM ||
+ widget_type == MENU ||
+ widget_type == POPUP_MENU_SEPARATOR)
+ {
+ GtkWidget *menu = gtk3_get_widget(POPUP_MENU);
+ (*fp_gtk_menu_shell_append)((GtkMenuShell *)menu, result);
+ }
+ else if (widget_type == POPUP_MENU)
+ {
+ GtkWidget *menu_bar = gtk3_get_widget(MENU_BAR);
+ GtkWidget *root_menu = (*fp_gtk_menu_item_new)();
+ (*fp_gtk_menu_item_set_submenu)((GtkMenuItem*)root_menu, result);
+ (*fp_gtk_menu_shell_append)((GtkMenuShell *)menu_bar, root_menu);
+ }
+ else if (widget_type == COMBO_BOX_TEXT_FIELD )
+ {
+ GtkWidget* combo = gtk3_get_widget(COMBO_BOX);
+
+ /*
+ * We add a regular GtkButton/GtkEntry to a GtkComboBoxEntry
+ * in order to trick engines into thinking it's a real combobox
+ * arrow button/text field.
+ */
+
+ fp_gtk_container_add ((GtkContainer*)(combo), result);
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (combo);
+ fp_gtk_style_context_add_class (context, "combobox-entry");
+ context = fp_gtk_widget_get_style_context (result);
+ fp_gtk_style_context_add_class (context, "combobox");
+ fp_gtk_style_context_add_class (context, "entry");
+ }
+ else if (widget_type == COMBO_BOX_ARROW_BUTTON )
+ {
+ GtkWidget* combo = gtk3_get_widget(COMBO_BOX);
+ fp_gtk_widget_set_parent(result, combo);
+ }
+ else if (widget_type != TOOL_TIP &&
+ widget_type != INTERNAL_FRAME &&
+ widget_type != OPTION_PANE)
+ {
+ (*fp_gtk_container_add)((GtkContainer *)gtk3_fixed, result);
+ }
+ (*fp_gtk_widget_realize)(result);
+ }
+ return result;
+}
+
+static void gtk3_paint_arrow(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height,
+ GtkArrowType arrow_type, gboolean fill)
+{
+ gdouble xx, yy, a = G_PI;
+ int s = width;
+ gtk3_widget = gtk3_get_arrow(arrow_type, shadow_type);
+
+ switch (widget_type)
+ {
+ case SPINNER_ARROW_BUTTON:
+ s = (int)(0.4 * width + 0.5) + 1;
+ if (arrow_type == GTK_ARROW_UP) {
+ a = 0;
+ } else if (arrow_type == GTK_ARROW_DOWN) {
+ a = G_PI;
+ }
+ break;
+
+ case HSCROLL_BAR_BUTTON_LEFT:
+ s = (int)(0.5 * MIN(height, width * 2) + 0.5) + 1;
+ a = 3 * G_PI / 2;
+ break;
+
+ case HSCROLL_BAR_BUTTON_RIGHT:
+ s = (int)(0.5 * MIN(height, width * 2) + 0.5) + 1;
+ a = G_PI / 2;
+ break;
+
+ case VSCROLL_BAR_BUTTON_UP:
+ s = (int)(0.5 * MIN(height * 2, width) + 0.5) + 1;
+ a = 0;
+ break;
+
+ case VSCROLL_BAR_BUTTON_DOWN:
+ s = (int)(0.5 * MIN(height * 2, width) + 0.5) + 1;
+ a = G_PI;
+ break;
+
+ case COMBO_BOX_ARROW_BUTTON:
+ s = (int)(0.3 * height + 0.5) + 1;
+ a = G_PI;
+ break;
+
+ case TABLE:
+ s = (int)(0.8 * height + 0.5) + 1;
+ if (arrow_type == GTK_ARROW_UP) {
+ a = G_PI;
+ } else if (arrow_type == GTK_ARROW_DOWN) {
+ a = 0;
+ }
+ break;
+
+ case MENU_ITEM:
+ if (arrow_type == GTK_ARROW_UP) {
+ a = G_PI;
+ } else if (arrow_type == GTK_ARROW_DOWN) {
+ a = 0;
+ } else if (arrow_type == GTK_ARROW_RIGHT) {
+ a = G_PI / 2;
+ } else if (arrow_type == GTK_ARROW_LEFT) {
+ a = 3 * G_PI / 2;
+ }
+ break;
+
+ default:
+ if (arrow_type == GTK_ARROW_UP) {
+ a = G_PI;
+ } else if (arrow_type == GTK_ARROW_DOWN) {
+ a = 0;
+ } else if (arrow_type == GTK_ARROW_RIGHT) {
+ a = G_PI / 2;
+ } else if (arrow_type == GTK_ARROW_LEFT) {
+ a = 3 * G_PI / 2;
+ }
+ break;
+ }
+
+ if (s < width && s < height) {
+ xx = x + (0.5 * (width - s) + 0.5);
+ yy = y + (0.5 * (height - s) + 0.5);
+ } else {
+ xx = x;
+ yy = y;
+ }
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ fp_gtk_style_context_save (context);
+
+
+ if (detail != NULL) {
+ transform_detail_string(detail, context);
+ }
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+
+ fp_gtk_style_context_set_state (context, flags);
+
+ (*fp_gtk_render_arrow)(context, cr, a, xx, yy, s);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_box(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height,
+ gint synth_state, GtkTextDirection dir)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ if (widget_type == HSLIDER_TRACK) {
+ /*
+ * For horizontal JSliders with right-to-left orientation, we need
+ * to set the "inverted" flag to match the native GTK behavior where
+ * the foreground highlight is on the right side of the slider thumb.
+ * This is needed especially for the ubuntulooks engine, which looks
+ * exclusively at the "inverted" flag to determine on which side of
+ * the thumb to paint the highlight...
+ */
+ fp_gtk_range_set_inverted((GtkRange*)gtk3_widget, dir ==
+ GTK_TEXT_DIR_RTL);
+
+ /*
+ * Note however that other engines like clearlooks will look at both
+ * the "inverted" field and the text direction to determine how
+ * the foreground highlight is painted:
+ * !inverted && ltr --> paint highlight on left side
+ * !inverted && rtl --> paint highlight on right side
+ * inverted && ltr --> paint highlight on right side
+ * inverted && rtl --> paint highlight on left side
+ * So the only way to reliably get the desired results for horizontal
+ * JSlider (i.e., highlight on left side for LTR ComponentOrientation
+ * and highlight on right side for RTL ComponentOrientation) is to
+ * always override text direction as LTR, and then set the "inverted"
+ * flag accordingly (as we have done above).
+ */
+ dir = GTK_TEXT_DIR_LTR;
+ }
+
+ /*
+ * Some engines (e.g. clearlooks) will paint the shadow of certain
+ * widgets (e.g. COMBO_BOX_ARROW_BUTTON) differently depending on the
+ * the text direction.
+ */
+ gtk3_set_direction(gtk3_widget, dir);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ fp_gtk_style_context_save (context);
+
+ transform_detail_string(detail, context);
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+
+ if (shadow_type == GTK_SHADOW_IN && widget_type != COMBO_BOX_ARROW_BUTTON) {
+ flags |= GTK_STATE_FLAG_ACTIVE;
+ }
+
+ if (synth_state & MOUSE_OVER) {
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ }
+
+ if (synth_state & FOCUSED) {
+ flags |= GTK_STATE_FLAG_FOCUSED;
+ }
+
+ if (synth_state & DEFAULT) {
+ fp_gtk_style_context_add_class (context, "default");
+ }
+
+ fp_gtk_style_context_set_state (context, flags);
+
+ if (fp_gtk_style_context_has_class(context, "progressbar")) {
+ fp_gtk_render_activity (context, cr, x, y, width, height);
+ } else {
+ fp_gtk_render_background (context, cr, x, y, width, height);
+ if (shadow_type != GTK_SHADOW_NONE) {
+ fp_gtk_render_frame(context, cr, x, y, width, height);
+ }
+ }
+
+ fp_gtk_style_context_restore (context);
+ /*
+ * Reset the text direction to the default value so that we don't
+ * accidentally affect other operations and widgets.
+ */
+ gtk3_set_direction(gtk3_widget, GTK_TEXT_DIR_LTR);
+}
+
+static void gtk3_paint_box_gap(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height,
+ GtkPositionType gap_side, gint gap_x, gint gap_width)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+ fp_gtk_style_context_set_state(context, flags);
+
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ }
+ fp_gtk_render_background(context, cr, x, y, width, height);
+
+ if (shadow_type != GTK_SHADOW_NONE) {
+ fp_gtk_render_frame_gap(context, cr, x, y, width, height, gap_side,
+ (gdouble)gap_x, (gdouble)gap_x + gap_width);
+ }
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_check(WidgetType widget_type, gint synth_state,
+ const gchar *detail, gint x, gint y, gint width, gint height)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ GtkStateFlags flags = get_gtk_state_flags(synth_state);
+ if (gtk3_version_3_14 && (synth_state & SELECTED)) {
+ flags = GTK_STATE_FLAG_CHECKED;
+ }
+ fp_gtk_style_context_set_state(context, flags);
+
+ fp_gtk_style_context_add_class (context, "check");
+
+ fp_gtk_render_check (context, cr, x, y, width, height);
+
+ fp_gtk_style_context_restore (context);
+}
+
+
+static void gtk3_paint_expander(WidgetType widget_type, GtkStateType state_type,
+ const gchar *detail, gint x, gint y, gint width, gint height,
+ GtkExpanderStyle expander_style)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+ fp_gtk_style_context_set_state(context, flags);
+
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ }
+
+ fp_gtk_render_expander (context, cr, x, y, width, height);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_extension(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height, GtkPositionType gap_side)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ GtkStateFlags flags = GTK_STATE_FLAG_NORMAL;
+
+ if (state_type == 0) {
+ flags = GTK_STATE_FLAG_ACTIVE;
+ }
+
+ fp_gtk_style_context_set_state(context, flags);
+
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ }
+ switch(gap_side) {
+ case GTK_POS_LEFT:
+ fp_gtk_style_context_add_class(context, "right");
+ break;
+ case GTK_POS_RIGHT:
+ fp_gtk_style_context_add_class(context, "left");
+ break;
+ case GTK_POS_TOP:
+ fp_gtk_style_context_add_class(context, "bottom");
+ break;
+ case GTK_POS_BOTTOM:
+ fp_gtk_style_context_add_class(context, "top");
+ break;
+ default:
+ break;
+ }
+
+ fp_gtk_render_extension(context, cr, x, y, width, height, gap_side);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_flat_box(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height, gboolean has_focus)
+{
+ if (state_type == GTK_STATE_PRELIGHT &&
+ (widget_type == CHECK_BOX || widget_type == RADIO_BUTTON)) {
+ return;
+ }
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ }
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+
+ if (has_focus) {
+ flags |= GTK_STATE_FLAG_FOCUSED;
+ }
+
+ fp_gtk_style_context_set_state (context, flags);
+
+ if (widget_type == COMBO_BOX_TEXT_FIELD) {
+ width += height /2;
+ }
+
+ fp_gtk_render_background (context, cr, x, y, width, height);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_focus(WidgetType widget_type, GtkStateType state_type,
+ const char *detail, gint x, gint y, gint width, gint height)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ fp_gtk_style_context_save (context);
+
+ transform_detail_string(detail, context);
+ fp_gtk_render_focus (context, cr, x, y, width, height);
+
+ fp_gtk_style_context_restore (context);
+
+}
+
+static void gtk3_paint_handle(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height, GtkOrientation orientation)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+ fp_gtk_style_context_set_state(context, GTK_STATE_FLAG_PRELIGHT);
+
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ fp_gtk_style_context_add_class (context, "handlebox_bin");
+ }
+
+ fp_gtk_render_handle(context, cr, x, y, width, height);
+ fp_gtk_render_background(context, cr, x, y, width, height);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_hline(WidgetType widget_type, GtkStateType state_type,
+ const gchar *detail, gint x, gint y, gint width, gint height)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ }
+
+ fp_gtk_render_line(context, cr, x, y, x + width, y);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_vline(WidgetType widget_type, GtkStateType state_type,
+ const gchar *detail, gint x, gint y, gint width, gint height)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ }
+
+ fp_gtk_render_line(context, cr, x, y, x, y + height);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_option(WidgetType widget_type, gint synth_state,
+ const gchar *detail, gint x, gint y, gint width, gint height)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ GtkStateFlags flags = get_gtk_state_flags(synth_state);
+ if (gtk3_version_3_14 && (synth_state & SELECTED)) {
+ flags = GTK_STATE_FLAG_CHECKED;
+ }
+ fp_gtk_style_context_set_state(context, flags);
+
+ if (detail != 0) {
+ transform_detail_string(detail, context);
+ }
+
+ fp_gtk_render_option(context, cr, x, y, width, height);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_shadow(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height,
+ gint synth_state, GtkTextDirection dir)
+{
+ if (shadow_type == GTK_SHADOW_NONE) {
+ return;
+ }
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ /*
+ * Some engines (e.g. clearlooks) will paint the shadow of certain
+ * widgets (e.g. COMBO_BOX_TEXT_FIELD) differently depending on the
+ * the text direction.
+ */
+ gtk3_set_direction(gtk3_widget, dir);
+
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ fp_gtk_style_context_save (context);
+
+ if (detail) {
+ transform_detail_string(detail, context);
+ }
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+
+ if (synth_state & MOUSE_OVER) {
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ }
+
+ if (synth_state & FOCUSED) {
+ flags |= GTK_STATE_FLAG_FOCUSED;
+ }
+
+ fp_gtk_style_context_set_state (context, flags);
+
+ if (widget_type == COMBO_BOX_TEXT_FIELD) {
+ width += height / 2;
+ }
+ fp_gtk_render_frame(context, cr, x, y, width, height);
+
+ fp_gtk_style_context_restore (context);
+
+ /*
+ * Reset the text direction to the default value so that we don't
+ * accidentally affect other operations and widgets.
+ */
+ gtk3_set_direction(gtk3_widget, GTK_TEXT_DIR_LTR);
+}
+
+static void gtk3_paint_slider(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height, GtkOrientation orientation,
+ gboolean has_focus)
+{
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+
+ fp_gtk_style_context_save (context);
+
+ if (detail) {
+ transform_detail_string(detail, context);
+ }
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+
+ if (state_type == GTK_STATE_ACTIVE) {
+ flags |= GTK_STATE_FLAG_PRELIGHT;
+ }
+
+ if (has_focus) {
+ flags |= GTK_STATE_FLAG_FOCUSED;
+ }
+
+ fp_gtk_style_context_set_state (context, flags);
+
+ (*fp_gtk_render_slider)(context, cr, x, y, width, height, orientation);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static void gtk3_paint_background(WidgetType widget_type,
+ GtkStateType state_type, gint x, gint y, gint width, gint height) {
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ fp_gtk_style_context_save (context);
+
+ GtkStateFlags flags = get_gtk_flags(state_type);
+
+ fp_gtk_style_context_set_state (context, flags);
+
+ fp_gtk_render_background (context, cr, x, y, width, height);
+
+ fp_gtk_style_context_restore (context);
+}
+
+static GdkPixbuf *gtk3_get_stock_icon(gint widget_type, const gchar *stock_id,
+ GtkIconSize size, GtkTextDirection direction, const char *detail)
+{
+ int sz;
+
+ switch(size) {
+ case GTK_ICON_SIZE_MENU:
+ sz = 16;
+ break;
+ case GTK_ICON_SIZE_SMALL_TOOLBAR:
+ sz = 18;
+ break;
+ case GTK_ICON_SIZE_LARGE_TOOLBAR:
+ sz = 24;
+ break;
+ case GTK_ICON_SIZE_BUTTON:
+ sz = 20;
+ break;
+ case GTK_ICON_SIZE_DND:
+ sz = 32;
+ break;
+ case GTK_ICON_SIZE_DIALOG:
+ sz = 48;
+ break;
+ default:
+ sz = 0;
+ break;
+ }
+
+ init_containers();
+ gtk3_widget = gtk3_get_widget((widget_type < 0) ? IMAGE : widget_type);
+ (*fp_gtk_widget_set_direction)(gtk3_widget, direction);
+ GtkIconTheme *icon_theme = fp_gtk_icon_theme_get_default();
+ GdkPixbuf *result = fp_gtk_icon_theme_load_icon(icon_theme, stock_id, sz,
+ GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
+ return result;
+}
+
+static jboolean gtk3_get_pixbuf_data(JNIEnv *env, GdkPixbuf* pixbuf,
+ jmethodID icon_upcall_method, jobject this) {
+ if (!pixbuf) {
+ return JNI_FALSE;
+ }
+ guchar *pixbuf_data = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
+ if (pixbuf_data) {
+ int row_stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
+ int width = (*fp_gdk_pixbuf_get_width)(pixbuf);
+ int height = (*fp_gdk_pixbuf_get_height)(pixbuf);
+ int bps = (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf);
+ int channels = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
+ gboolean alpha = (*fp_gdk_pixbuf_get_has_alpha)(pixbuf);
+
+ jbyteArray data = (*env)->NewByteArray(env, (row_stride * height));
+ JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
+
+ (*env)->SetByteArrayRegion(env, data, 0, (row_stride * height),
+ (jbyte *)pixbuf_data);
+ (*fp_g_object_unref)(pixbuf);
+
+ /* Call the callback method to create the image on the Java side. */
+ (*env)->CallVoidMethod(env, this, icon_upcall_method, data,
+ width, height, row_stride, bps, channels, alpha);
+ return JNI_TRUE;
+ }
+ return JNI_FALSE;
+}
+
+static jboolean gtk3_get_file_icon_data(JNIEnv *env, const char *filename,
+ GError **error, jmethodID icon_upcall_method, jobject this) {
+ GdkPixbuf* pixbuf = fp_gdk_pixbuf_new_from_file(filename, error);
+ return gtk3_get_pixbuf_data(env, pixbuf, icon_upcall_method, this);
+}
+
+static jboolean gtk3_get_icon_data(JNIEnv *env, gint widget_type,
+ const gchar *stock_id, GtkIconSize size,
+ GtkTextDirection direction, const char *detail,
+ jmethodID icon_upcall_method, jobject this) {
+ GdkPixbuf* pixbuf = gtk3_get_stock_icon(widget_type, stock_id, size,
+ direction, detail);
+ return gtk3_get_pixbuf_data(env, pixbuf, icon_upcall_method, this);
+}
+
+/*************************************************/
+static gint gtk3_get_xthickness(JNIEnv *env, WidgetType widget_type)
+{
+ init_containers();
+
+ gtk3_widget = gtk3_get_widget(widget_type);
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ if (context) {
+ GtkBorder padding;
+ fp_gtk_style_context_get_padding(context, 0, &padding);
+ return padding.left + 1;
+ }
+ return 0;
+}
+
+static gint gtk3_get_ythickness(JNIEnv *env, WidgetType widget_type)
+{
+ init_containers();
+
+ gtk3_widget = gtk3_get_widget(widget_type);
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ if (context) {
+ GtkBorder padding;
+ fp_gtk_style_context_get_padding(context, 0, &padding);
+ return padding.top + 1;
+ }
+ return 0;
+}
+
+/*************************************************/
+static guint8 recode_color(gdouble channel)
+{
+ guint16 result = (guint16)(channel * 65535);
+ if (result < 0) {
+ result = 0;
+ } else if (result > 65535) {
+ result = 65535;
+ }
+ return (guint8)( result >> 8);
+}
+
+static GtkStateFlags gtk3_get_state_flags(GtkStateType state_type) {
+ switch (state_type)
+ {
+ case GTK_STATE_NORMAL:
+ return GTK_STATE_FLAG_NORMAL;
+ case GTK_STATE_ACTIVE:
+ return GTK_STATE_FLAG_ACTIVE;
+ case GTK_STATE_PRELIGHT:
+ return GTK_STATE_FLAG_PRELIGHT;
+ case GTK_STATE_SELECTED:
+ return GTK_STATE_FLAG_SELECTED;
+ case GTK_STATE_INSENSITIVE:
+ return GTK_STATE_FLAG_INSENSITIVE;
+ case GTK_STATE_INCONSISTENT:
+ return GTK_STATE_FLAG_INCONSISTENT;
+ case GTK_STATE_FOCUSED:
+ return GTK_STATE_FLAG_FOCUSED;
+ }
+ return 0;
+}
+
+
+static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b) {
+ gdouble min;
+ gdouble max;
+ gdouble red;
+ gdouble green;
+ gdouble blue;
+ gdouble h, l, s;
+ gdouble delta;
+
+ red = *r;
+ green = *g;
+ blue = *b;
+
+ if (red > green)
+ {
+ if (red > blue)
+ max = red;
+ else
+ max = blue;
+
+ if (green < blue)
+ min = green;
+ else
+ min = blue;
+ }
+ else
+ {
+ if (green > blue)
+ max = green;
+ else
+ max = blue;
+
+ if (red < blue)
+ min = red;
+ else
+ min = blue;
+ }
+
+ l = (max + min) / 2;
+ s = 0;
+ h = 0;
+
+ if (max != min)
+ {
+ if (l <= 0.5)
+ s = (max - min) / (max + min);
+ else
+ s = (max - min) / (2 - max - min);
+
+ delta = max -min;
+ if (red == max)
+ h = (green - blue) / delta;
+ else if (green == max)
+ h = 2 + (blue - red) / delta;
+ else if (blue == max)
+ h = 4 + (red - green) / delta;
+
+ h *= 60;
+ if (h < 0.0)
+ h += 360;
+ }
+
+ *r = h;
+ *g = l;
+ *b = s;
+}
+
+static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s)
+{
+ gdouble hue;
+ gdouble lightness;
+ gdouble saturation;
+ gdouble m1, m2;
+ gdouble r, g, b;
+
+ lightness = *l;
+ saturation = *s;
+
+ if (lightness <= 0.5)
+ m2 = lightness * (1 + saturation);
+ else
+ m2 = lightness + saturation - lightness * saturation;
+ m1 = 2 * lightness - m2;
+
+ if (saturation == 0)
+ {
+ *h = lightness;
+ *l = lightness;
+ *s = lightness;
+ }
+ else
+ {
+ hue = *h + 120;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ r = m1 + (m2 - m1) * hue / 60;
+ else if (hue < 180)
+ r = m2;
+ else if (hue < 240)
+ r = m1 + (m2 - m1) * (240 - hue) / 60;
+ else
+ r = m1;
+
+ hue = *h;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ g = m1 + (m2 - m1) * hue / 60;
+ else if (hue < 180)
+ g = m2;
+ else if (hue < 240)
+ g = m1 + (m2 - m1) * (240 - hue) / 60;
+ else
+ g = m1;
+
+ hue = *h - 120;
+ while (hue > 360)
+ hue -= 360;
+ while (hue < 0)
+ hue += 360;
+
+ if (hue < 60)
+ b = m1 + (m2 - m1) * hue / 60;
+ else if (hue < 180)
+ b = m2;
+ else if (hue < 240)
+ b = m1 + (m2 - m1) * (240 - hue) / 60;
+ else
+ b = m1;
+
+ *h = r;
+ *l = g;
+ *s = b;
+ }
+}
+
+
+
+static void gtk3_style_shade (const GdkRGBA *a, GdkRGBA *b, gdouble k) {
+ gdouble red = a->red;
+ gdouble green = a->green;
+ gdouble blue = a->blue;
+
+ rgb_to_hls (&red, &green, &blue);
+
+ green *= k;
+ if (green > 1.0)
+ green = 1.0;
+ else if (green < 0.0)
+ green = 0.0;
+
+ blue *= k;
+ if (blue > 1.0)
+ blue = 1.0;
+ else if (blue < 0.0)
+ blue = 0.0;
+
+ hls_to_rgb (&red, &green, &blue);
+
+ b->red = red;
+ b->green = green;
+ b->blue = blue;
+}
+
+static GdkRGBA gtk3_get_color_for_flags(GtkStyleContext* context,
+ GtkStateFlags flags, ColorType color_type) {
+ GdkRGBA c, color;
+
+ switch (color_type)
+ {
+ case FOREGROUND:
+ case TEXT_FOREGROUND:
+ fp_gtk_style_context_get_color(context, flags, &color);
+ break;
+ case BACKGROUND:
+ case TEXT_BACKGROUND:
+ fp_gtk_style_context_get_background_color(context, flags, &color);
+ break;
+ case LIGHT:
+ c = gtk3_get_color_for_flags(context, flags, BACKGROUND);
+ gtk3_style_shade(&c, &color, LIGHTNESS_MULT);
+ break;
+ case DARK:
+ c = gtk3_get_color_for_flags(context, flags, BACKGROUND);
+ gtk3_style_shade (&c, &color, DARKNESS_MULT);
+ break;
+ case MID:
+ {
+ GdkRGBA c1 = gtk3_get_color_for_flags(context, flags, LIGHT);
+ GdkRGBA c2 = gtk3_get_color_for_flags(context, flags, DARK);
+ color.red = (c1.red + c2.red) / 2;
+ color.green = (c1.green + c2.green) / 2;
+ color.blue = (c1.blue + c2.blue) / 2;
+ }
+ break;
+ case FOCUS:
+ case BLACK:
+ color.red = 0;
+ color.green = 0;
+ color.blue = 0;
+ break;
+ case WHITE:
+ color.red = 1;
+ color.green = 1;
+ color.blue = 1;
+ break;
+ }
+ return color;
+}
+
+static gint gtk3_get_color_for_state(JNIEnv *env, WidgetType widget_type,
+ GtkStateType state_type, ColorType color_type)
+{
+
+ gint result = 0;
+ GdkRGBA color;
+
+ GtkStateFlags flags = gtk3_get_state_flags(state_type);
+
+ init_containers();
+
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GtkStyleContext* context = fp_gtk_widget_get_style_context(gtk3_widget);
+
+ if (widget_type == TOOL_TIP) {
+ fp_gtk_style_context_add_class(context, "tooltip");
+ }
+ if (widget_type == CHECK_BOX_MENU_ITEM
+ || widget_type == RADIO_BUTTON_MENU_ITEM) {
+ flags &= GTK_STATE_FLAG_NORMAL | GTK_STATE_FLAG_SELECTED
+ | GTK_STATE_FLAG_INSENSITIVE | GTK_STATE_FLAG_FOCUSED;
+ }
+
+ color = gtk3_get_color_for_flags(context, flags, color_type);
+
+ if (recode_color(color.alpha) == 0) {
+ color = gtk3_get_color_for_flags(
+ fp_gtk_widget_get_style_context(gtk3_get_widget(INTERNAL_FRAME)),
+ 0, BACKGROUND);
+ }
+
+ result = recode_color(color.alpha) << 24 | recode_color(color.red) << 16 |
+ recode_color(color.green) << 8 | recode_color(color.blue);
+
+ return result;
+}
+
+/*************************************************/
+static jobject create_Boolean(JNIEnv *env, jboolean boolean_value);
+static jobject create_Integer(JNIEnv *env, jint int_value);
+static jobject create_Long(JNIEnv *env, jlong long_value);
+static jobject create_Float(JNIEnv *env, jfloat float_value);
+static jobject create_Double(JNIEnv *env, jdouble double_value);
+static jobject create_Character(JNIEnv *env, jchar char_value);
+static jobject create_Insets(JNIEnv *env, GtkBorder *border);
+
+static jobject gtk3_get_class_value(JNIEnv *env, WidgetType widget_type,
+ const char* key)
+{
+ init_containers();
+
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ GValue value = { 0, { { 0 } } };
+
+ GParamSpec* param = (*fp_gtk_widget_class_find_style_property)(
+ ((GTypeInstance*)gtk3_widget)->g_class, key);
+ if ( param )
+ {
+ (*fp_g_value_init)( &value, param->value_type );
+ (*fp_gtk_widget_style_get_property)(gtk3_widget, key, &value);
+
+ if ((*fp_g_type_is_a)( param->value_type, G_TYPE_BOOLEAN ))
+ {
+ gboolean val = (*fp_g_value_get_boolean)(&value);
+ return create_Boolean(env, (jboolean)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_CHAR ))
+ {
+ gchar val = (*fp_g_value_get_char)(&value);
+ return create_Character(env, (jchar)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_UCHAR ))
+ {
+ guchar val = (*fp_g_value_get_uchar)(&value);
+ return create_Character(env, (jchar)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_INT ))
+ {
+ gint val = (*fp_g_value_get_int)(&value);
+ return create_Integer(env, (jint)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_UINT ))
+ {
+ guint val = (*fp_g_value_get_uint)(&value);
+ return create_Integer(env, (jint)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_LONG ))
+ {
+ glong val = (*fp_g_value_get_long)(&value);
+ return create_Long(env, (jlong)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_ULONG ))
+ {
+ gulong val = (*fp_g_value_get_ulong)(&value);
+ return create_Long(env, (jlong)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_INT64 ))
+ {
+ gint64 val = (*fp_g_value_get_int64)(&value);
+ return create_Long(env, (jlong)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_UINT64 ))
+ {
+ guint64 val = (*fp_g_value_get_uint64)(&value);
+ return create_Long(env, (jlong)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_FLOAT ))
+ {
+ gfloat val = (*fp_g_value_get_float)(&value);
+ return create_Float(env, (jfloat)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_DOUBLE ))
+ {
+ gdouble val = (*fp_g_value_get_double)(&value);
+ return create_Double(env, (jdouble)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_ENUM ))
+ {
+ gint val = (*fp_g_value_get_enum)(&value);
+ return create_Integer(env, (jint)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_FLAGS ))
+ {
+ guint val = (*fp_g_value_get_flags)(&value);
+ return create_Integer(env, (jint)val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, G_TYPE_STRING ))
+ {
+ const gchar* val = (*fp_g_value_get_string)(&value);
+
+ /* We suppose that all values come in C locale and
+ * utf-8 representation of a string is the same as
+ * the string itself. If this isn't so we should
+ * use g_convert.
+ */
+ return (*env)->NewStringUTF(env, val);
+ }
+ else if ((*fp_g_type_is_a)( param->value_type, GTK_TYPE_BORDER ))
+ {
+ GtkBorder *border = (GtkBorder*)(*fp_g_value_get_boxed)(&value);
+ return border ? create_Insets(env, border) : NULL;
+ }
+
+ /* TODO: Other types are not supported yet.*/
+/* else if((*fp_g_type_is_a)( param->value_type, G_TYPE_PARAM ))
+ {
+ GParamSpec* val = (*fp_g_value_get_param)(&value);
+ printf( "Param: %p\n", val );
+ }
+ else if((*fp_g_type_is_a)( param->value_type, G_TYPE_BOXED ))
+ {
+ gpointer* val = (*fp_g_value_get_boxed)(&value);
+ printf( "Boxed: %p\n", val );
+ }
+ else if((*fp_g_type_is_a)( param->value_type, G_TYPE_POINTER ))
+ {
+ gpointer* val = (*fp_g_value_get_pointer)(&value);
+ printf( "Pointer: %p\n", val );
+ }
+ else if((*fp_g_type_is_a)( param->value_type, G_TYPE_OBJECT ))
+ {
+ GObject* val = (GObject*)(*fp_g_value_get_object)(&value);
+ printf( "Object: %p\n", val );
+ }*/
+ }
+
+ return NULL;
+}
+
+static void gtk3_set_range_value(WidgetType widget_type, jdouble value,
+ jdouble min, jdouble max, jdouble visible)
+{
+ GtkAdjustment *adj;
+
+ gtk3_widget = gtk3_get_widget(widget_type);
+
+ adj = (*fp_gtk_range_get_adjustment)((GtkRange *)gtk3_widget);
+
+ fp_gtk_adjustment_set_value(adj, value);
+ fp_gtk_adjustment_set_lower(adj, min);
+ fp_gtk_adjustment_set_upper(adj, max);
+ fp_gtk_adjustment_set_page_size(adj, visible);
+}
+
+/*************************************************/
+static jobject create_Object(JNIEnv *env, jmethodID *cid,
+ const char* class_name,
+ const char* signature,
+ jvalue* value)
+{
+ jclass class;
+ jobject result;
+
+ class = (*env)->FindClass(env, class_name);
+ if (class == NULL)
+ return NULL; /* can't find/load the class, exception thrown */
+
+ if (*cid == NULL)
+ {
+ *cid = (*env)->GetMethodID(env, class, "", signature);
+ if (*cid == NULL)
+ {
+ (*env)->DeleteLocalRef(env, class);
+ return NULL; /* can't find/get the method, exception thrown */
+ }
+ }
+
+ result = (*env)->NewObjectA(env, class, *cid, value);
+
+ (*env)->DeleteLocalRef(env, class);
+ return result;
+}
+
+jobject create_Boolean(JNIEnv *env, jboolean boolean_value)
+{
+ static jmethodID cid = NULL;
+ jvalue value;
+
+ value.z = boolean_value;
+
+ return create_Object(env, &cid, "java/lang/Boolean", "(Z)V", &value);
+}
+
+jobject create_Integer(JNIEnv *env, jint int_value)
+{
+ static jmethodID cid = NULL;
+ jvalue value;
+
+ value.i = int_value;
+
+ return create_Object(env, &cid, "java/lang/Integer", "(I)V", &value);
+}
+
+jobject create_Long(JNIEnv *env, jlong long_value)
+{
+ static jmethodID cid = NULL;
+ jvalue value;
+
+ value.j = long_value;
+
+ return create_Object(env, &cid, "java/lang/Long", "(J)V", &value);
+}
+
+jobject create_Float(JNIEnv *env, jfloat float_value)
+{
+ static jmethodID cid = NULL;
+ jvalue value;
+
+ value.f = float_value;
+
+ return create_Object(env, &cid, "java/lang/Float", "(F)V", &value);
+}
+
+jobject create_Double(JNIEnv *env, jdouble double_value)
+{
+ static jmethodID cid = NULL;
+ jvalue value;
+
+ value.d = double_value;
+
+ return create_Object(env, &cid, "java/lang/Double", "(D)V", &value);
+}
+
+jobject create_Character(JNIEnv *env, jchar char_value)
+{
+ static jmethodID cid = NULL;
+ jvalue value;
+
+ value.c = char_value;
+
+ return create_Object(env, &cid, "java/lang/Character", "(C)V", &value);
+}
+
+
+jobject create_Insets(JNIEnv *env, GtkBorder *border)
+{
+ static jmethodID cid = NULL;
+ jvalue values[4];
+
+ values[0].i = border->top;
+ values[1].i = border->left;
+ values[2].i = border->bottom;
+ values[3].i = border->right;
+
+ return create_Object(env, &cid, "java/awt/Insets", "(IIII)V", values);
+}
+
+/*********************************************/
+static jstring gtk3_get_pango_font_name(JNIEnv *env, WidgetType widget_type)
+{
+ init_containers();
+
+ gtk3_widget = gtk3_get_widget(widget_type);
+ jstring result = NULL;
+ GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
+ if (context)
+ {
+ PangoFontDescription* fd = fp_gtk_style_context_get_font(context, 0);
+ gchar* val = (*fp_pango_font_description_to_string)(fd);
+ result = (*env)->NewStringUTF(env, val);
+ (*fp_g_free)( val );
+ }
+
+ return result;
+}
+
+/***********************************************/
+static jobject get_string_property(JNIEnv *env, GtkSettings* settings,
+ const gchar* key) {
+ jobject result = NULL;
+ gchar* strval = NULL;
+
+ (*fp_g_object_get)(settings, key, &strval, NULL);
+ result = (*env)->NewStringUTF(env, strval);
+ (*fp_g_free)(strval);
+
+ return result;
+}
+
+static jobject get_integer_property(JNIEnv *env, GtkSettings* settings,
+ const gchar* key) {
+ gint intval = 0;
+ (*fp_g_object_get)(settings, key, &intval, NULL);
+ return create_Integer(env, intval);
+}
+
+static jobject get_boolean_property(JNIEnv *env, GtkSettings* settings,
+ const gchar* key) {
+ gint intval = 0;
+ (*fp_g_object_get)(settings, key, &intval, NULL);
+ return create_Boolean(env, intval);
+}
+
+static jobject gtk3_get_setting(JNIEnv *env, Setting property)
+{
+ GtkSettings* settings = (*fp_gtk_settings_get_default)();
+
+ switch (property)
+ {
+ case GTK_FONT_NAME:
+ return get_string_property(env, settings, "gtk-font-name");
+ case GTK_ICON_SIZES:
+ return get_string_property(env, settings, "gtk-icon-sizes");
+ case GTK_CURSOR_BLINK:
+ return get_boolean_property(env, settings, "gtk-cursor-blink");
+ case GTK_CURSOR_BLINK_TIME:
+ return get_integer_property(env, settings, "gtk-cursor-blink-time");
+ }
+
+ return NULL;
+}
+
+static void transform_detail_string (const gchar *detail,
+ GtkStyleContext *context) {
+ if (!detail)
+ return;
+
+ if (strcmp (detail, "arrow") == 0)
+ fp_gtk_style_context_add_class (context, "arrow");
+ else if (strcmp (detail, "button") == 0)
+ fp_gtk_style_context_add_class (context, "button");
+ else if (strcmp (detail, "buttondefault") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "button");
+ fp_gtk_style_context_add_class (context, "default");
+ }
+ else if (strcmp (detail, "calendar") == 0)
+ fp_gtk_style_context_add_class (context, "calendar");
+ else if (strcmp (detail, "cellcheck") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "cell");
+ fp_gtk_style_context_add_class (context, "check");
+ }
+ else if (strcmp (detail, "cellradio") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "cell");
+ fp_gtk_style_context_add_class (context, "radio");
+ }
+ else if (strcmp (detail, "checkbutton") == 0)
+ fp_gtk_style_context_add_class (context, "check");
+ else if (strcmp (detail, "check") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "check");
+ fp_gtk_style_context_add_class (context, "menu");
+ }
+ else if (strcmp (detail, "radiobutton") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "radio");
+ }
+ else if (strcmp (detail, "option") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "radio");
+ fp_gtk_style_context_add_class (context, "menu");
+ }
+ else if (strcmp (detail, "entry") == 0 ||
+ strcmp (detail, "entry_bg") == 0)
+ fp_gtk_style_context_add_class (context, "entry");
+ else if (strcmp (detail, "expander") == 0)
+ fp_gtk_style_context_add_class (context, "expander");
+ else if (strcmp (detail, "tooltip") == 0)
+ fp_gtk_style_context_add_class (context, "tooltip");
+ else if (strcmp (detail, "frame") == 0)
+ fp_gtk_style_context_add_class (context, "frame");
+ else if (strcmp (detail, "scrolled_window") == 0)
+ fp_gtk_style_context_add_class (context, "scrolled-window");
+ else if (strcmp (detail, "viewport") == 0 ||
+ strcmp (detail, "viewportbin") == 0)
+ fp_gtk_style_context_add_class (context, "viewport");
+ else if (strncmp (detail, "trough", 6) == 0)
+ fp_gtk_style_context_add_class (context, "trough");
+ else if (strcmp (detail, "spinbutton") == 0)
+ fp_gtk_style_context_add_class (context, "spinbutton");
+ else if (strcmp (detail, "spinbutton_up") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "spinbutton");
+ fp_gtk_style_context_add_class (context, "button");
+ fp_gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
+ }
+ else if (strcmp (detail, "spinbutton_down") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "spinbutton");
+ fp_gtk_style_context_add_class (context, "button");
+ fp_gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+ }
+ else if ((detail[0] == 'h' || detail[0] == 'v') &&
+ strncmp (&detail[1], "scrollbar_", 9) == 0)
+ {
+ fp_gtk_style_context_add_class (context, "button");
+ fp_gtk_style_context_add_class (context, "scrollbar");
+ }
+ else if (strcmp (detail, "slider") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "slider");
+ fp_gtk_style_context_add_class (context, "scrollbar");
+ }
+ else if (strcmp (detail, "vscale") == 0 ||
+ strcmp (detail, "hscale") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "slider");
+ fp_gtk_style_context_add_class (context, "scale");
+ }
+ else if (strcmp (detail, "menuitem") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "menuitem");
+ fp_gtk_style_context_add_class (context, "menu");
+ }
+ else if (strcmp (detail, "menu") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "popup");
+ fp_gtk_style_context_add_class (context, "menu");
+ }
+ else if (strcmp (detail, "accellabel") == 0)
+ fp_gtk_style_context_add_class (context, "accelerator");
+ else if (strcmp (detail, "menubar") == 0)
+ fp_gtk_style_context_add_class (context, "menubar");
+ else if (strcmp (detail, "base") == 0)
+ fp_gtk_style_context_add_class (context, "background");
+ else if (strcmp (detail, "bar") == 0 ||
+ strcmp (detail, "progressbar") == 0)
+ fp_gtk_style_context_add_class (context, "progressbar");
+ else if (strcmp (detail, "toolbar") == 0)
+ fp_gtk_style_context_add_class (context, "toolbar");
+ else if (strcmp (detail, "handlebox_bin") == 0)
+ fp_gtk_style_context_add_class (context, "dock");
+ else if (strcmp (detail, "notebook") == 0)
+ fp_gtk_style_context_add_class (context, "notebook");
+ else if (strcmp (detail, "tab") == 0)
+ {
+ fp_gtk_style_context_add_class (context, "notebook");
+ fp_gtk_style_context_add_region (context, "tab", 0);
+ } else if (strcmp (detail, "paned") == 0) {
+ fp_gtk_style_context_add_class (context, "pane-separator");
+ }
+ else if (fp_g_str_has_prefix (detail, "cell"))
+ {
+ GtkRegionFlags row, col;
+ gboolean ruled = FALSE;
+ gchar** tokens;
+ guint i;
+
+ tokens = fp_g_strsplit (detail, "_", -1);
+ row = col = 0;
+ i = 0;
+
+ while (tokens[i])
+ {
+ if (strcmp (tokens[i], "even") == 0)
+ row |= GTK_REGION_EVEN;
+ else if (strcmp (tokens[i], "odd") == 0)
+ row |= GTK_REGION_ODD;
+ else if (strcmp (tokens[i], "start") == 0)
+ col |= GTK_REGION_FIRST;
+ else if (strcmp (tokens[i], "end") == 0)
+ col |= GTK_REGION_LAST;
+ else if (strcmp (tokens[i], "ruled") == 0)
+ ruled = TRUE;
+ else if (strcmp (tokens[i], "sorted") == 0)
+ col |= GTK_REGION_SORTED;
+
+ i++;
+ }
+
+ if (!ruled)
+ row &= ~(GTK_REGION_EVEN | GTK_REGION_ODD);
+
+ fp_gtk_style_context_add_class (context, "cell");
+ fp_gtk_style_context_add_region (context, "row", row);
+ fp_gtk_style_context_add_region (context, "column", col);
+
+ fp_g_strfreev (tokens);
+ }
+}
+
+static gboolean gtk3_get_drawable_data(JNIEnv *env, jintArray pixelArray,
+ int x, jint y, jint width, jint height, jint jwidth, int dx, int dy,
+ jint scale) {
+ GdkPixbuf *pixbuf;
+ jint *ary;
+
+ GdkWindow *root = (*fp_gdk_get_default_root_window)();
+ pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(root, x, y, width, height);
+ if (pixbuf && scale != 1) {
+ GdkPixbuf *scaledPixbuf;
+ x /= scale;
+ y /= scale;
+ width /= scale;
+ height /= scale;
+ dx /= scale;
+ dy /= scale;
+ scaledPixbuf = (*fp_gdk_pixbuf_scale_simple)(pixbuf, width, height,
+ GDK_INTERP_BILINEAR);
+ (*fp_g_object_unref)(pixbuf);
+ pixbuf = scaledPixbuf;
+ }
+
+ if (pixbuf) {
+ int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
+ int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
+ if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
+ && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
+ && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
+ && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
+ && nchan >= 3
+ ) {
+ guchar *p, *pix = (*fp_gdk_pixbuf_get_pixels)(pixbuf);
+ ary = (*env)->GetPrimitiveArrayCritical(env, pixelArray, NULL);
+ if (ary) {
+ jint _x, _y;
+ int index;
+ for (_y = 0; _y < height; _y++) {
+ for (_x = 0; _x < width; _x++) {
+ p = pix + _y * stride + _x * nchan;
+
+ index = (_y + dy) * jwidth + (_x + dx);
+ ary[index] = 0xff000000
+ | (p[0] << 16)
+ | (p[1] << 8)
+ | (p[2]);
+
+ }
+ }
+ (*env)->ReleasePrimitiveArrayCritical(env, pixelArray, ary, 0);
+ }
+ }
+ (*fp_g_object_unref)(pixbuf);
+ }
+ return JNI_FALSE;
+}
+
+static GdkWindow* gtk3_get_window(void *widget) {
+ return fp_gtk_widget_get_window((GtkWidget*)widget);
+}
+
+static void gtk3_init(GtkApi* gtk) {
+ gtk->version = GTK_3;
+
+ gtk->show_uri_load = >k3_show_uri_load;
+ gtk->unload = >k3_unload;
+ gtk->flush_event_loop = &flush_gtk_event_loop;
+ gtk->gtk_check_version = fp_gtk_check_version;
+ gtk->get_setting = >k3_get_setting;
+
+ gtk->paint_arrow = >k3_paint_arrow;
+ gtk->paint_box = >k3_paint_box;
+ gtk->paint_box_gap = >k3_paint_box_gap;
+ gtk->paint_expander = >k3_paint_expander;
+ gtk->paint_extension = >k3_paint_extension;
+ gtk->paint_flat_box = >k3_paint_flat_box;
+ gtk->paint_focus = >k3_paint_focus;
+ gtk->paint_handle = >k3_paint_handle;
+ gtk->paint_hline = >k3_paint_hline;
+ gtk->paint_vline = >k3_paint_vline;
+ gtk->paint_option = >k3_paint_option;
+ gtk->paint_shadow = >k3_paint_shadow;
+ gtk->paint_slider = >k3_paint_slider;
+ gtk->paint_background = >k3_paint_background;
+ gtk->paint_check = >k3_paint_check;
+ gtk->set_range_value = >k3_set_range_value;
+
+ gtk->init_painting = >k3_init_painting;
+ gtk->copy_image = >k3_copy_image;
+
+ gtk->get_xthickness = >k3_get_xthickness;
+ gtk->get_ythickness = >k3_get_ythickness;
+ gtk->get_color_for_state = >k3_get_color_for_state;
+ gtk->get_class_value = >k3_get_class_value;
+
+ gtk->get_pango_font_name = >k3_get_pango_font_name;
+ gtk->get_icon_data = >k3_get_icon_data;
+ gtk->get_file_icon_data = >k3_get_file_icon_data;
+ gtk->gdk_threads_enter = fp_gdk_threads_enter;
+ gtk->gdk_threads_leave = fp_gdk_threads_leave;
+ gtk->gtk_show_uri = fp_gtk_show_uri;
+ gtk->get_drawable_data = >k3_get_drawable_data;
+ gtk->g_free = fp_g_free;
+
+ gtk->gtk_file_chooser_get_filename = fp_gtk_file_chooser_get_filename;
+ gtk->gtk_widget_hide = fp_gtk_widget_hide;
+ gtk->gtk_main_quit = fp_gtk_main_quit;
+ gtk->gtk_file_chooser_dialog_new = fp_gtk_file_chooser_dialog_new;
+ gtk->gtk_file_chooser_set_current_folder =
+ fp_gtk_file_chooser_set_current_folder;
+ gtk->gtk_file_chooser_set_filename = fp_gtk_file_chooser_set_filename;
+ gtk->gtk_file_chooser_set_current_name =
+ fp_gtk_file_chooser_set_current_name;
+ gtk->gtk_file_filter_add_custom = fp_gtk_file_filter_add_custom;
+ gtk->gtk_file_chooser_set_filter = fp_gtk_file_chooser_set_filter;
+ gtk->gtk_file_chooser_get_type = fp_gtk_file_chooser_get_type;
+ gtk->gtk_file_filter_new = fp_gtk_file_filter_new;
+ gtk->gtk_file_chooser_set_do_overwrite_confirmation =
+ fp_gtk_file_chooser_set_do_overwrite_confirmation;
+ gtk->gtk_file_chooser_set_select_multiple =
+ fp_gtk_file_chooser_set_select_multiple;
+ gtk->gtk_file_chooser_get_current_folder =
+ fp_gtk_file_chooser_get_current_folder;
+ gtk->gtk_file_chooser_get_filenames = fp_gtk_file_chooser_get_filenames;
+ gtk->gtk_g_slist_length = fp_gtk_g_slist_length;
+ gtk->g_signal_connect_data = fp_g_signal_connect_data;
+ gtk->gtk_widget_show = fp_gtk_widget_show;
+ gtk->gtk_main = fp_gtk_main;
+ gtk->gtk_main_level = fp_gtk_main_level;
+ gtk->g_path_get_dirname = fp_g_path_get_dirname;
+ gtk->gdk_x11_drawable_get_xid = fp_gdk_x11_drawable_get_xid;
+ gtk->gtk_widget_destroy = fp_gtk_widget_destroy;
+ gtk->gtk_window_present = fp_gtk_window_present;
+ gtk->gtk_window_move = fp_gtk_window_move;
+ gtk->gtk_window_resize = fp_gtk_window_resize;
+ gtk->get_window = >k3_get_window;
+
+ gtk->g_object_unref = fp_g_object_unref;
+ gtk->g_list_append = fp_g_list_append;
+ gtk->g_list_free = fp_g_list_free;
+ gtk->g_list_free_full = fp_g_list_free_full;
+}
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h
new file mode 100644
index 00000000000..1ffaa8fa9d0
--- /dev/null
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.h
@@ -0,0 +1,577 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+#ifndef _GTK3_INTERFACE_H
+#define _GTK3_INTERFACE_H
+
+#include
+#include
+#include
+#include "gtk_interface.h"
+
+#define LIGHTNESS_MULT 1.3
+#define DARKNESS_MULT 0.7
+
+#define G_PI 3.1415926535897932384626433832795028841971693993751
+
+typedef enum
+{
+ GTK_STATE_FLAG_NORMAL = 0,
+ GTK_STATE_FLAG_ACTIVE = 1 << 0,
+ GTK_STATE_FLAG_PRELIGHT = 1 << 1,
+ GTK_STATE_FLAG_SELECTED = 1 << 2,
+ GTK_STATE_FLAG_INSENSITIVE = 1 << 3,
+ GTK_STATE_FLAG_INCONSISTENT = 1 << 4,
+ GTK_STATE_FLAG_FOCUSED = 1 << 5,
+ GTK_STATE_FLAG_BACKDROP = 1 << 6,
+ GTK_STATE_FLAG_DIR_LTR = 1 << 7,
+ GTK_STATE_FLAG_DIR_RTL = 1 << 8,
+ GTK_STATE_FLAG_LINK = 1 << 9,
+ GTK_STATE_FLAG_VISITED = 1 << 10,
+ GTK_STATE_FLAG_CHECKED = 1 << 11
+} GtkStateFlags;
+
+typedef enum {
+ GTK_JUNCTION_NONE = 0,
+ GTK_JUNCTION_CORNER_TOPLEFT = 1 << 0,
+ GTK_JUNCTION_CORNER_TOPRIGHT = 1 << 1,
+ GTK_JUNCTION_CORNER_BOTTOMLEFT = 1 << 2,
+ GTK_JUNCTION_CORNER_BOTTOMRIGHT = 1 << 3,
+ GTK_JUNCTION_TOP =
+ (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_TOPRIGHT),
+ GTK_JUNCTION_BOTTOM =
+ (GTK_JUNCTION_CORNER_BOTTOMLEFT | GTK_JUNCTION_CORNER_BOTTOMRIGHT),
+ GTK_JUNCTION_LEFT =
+ (GTK_JUNCTION_CORNER_TOPLEFT | GTK_JUNCTION_CORNER_BOTTOMLEFT),
+ GTK_JUNCTION_RIGHT =
+ (GTK_JUNCTION_CORNER_TOPRIGHT | GTK_JUNCTION_CORNER_BOTTOMRIGHT)
+} GtkJunctionSides;
+
+typedef enum {
+ GTK_REGION_EVEN = 1 << 0,
+ GTK_REGION_ODD = 1 << 1,
+ GTK_REGION_FIRST = 1 << 2,
+ GTK_REGION_LAST = 1 << 3,
+ GTK_REGION_ONLY = 1 << 4,
+ GTK_REGION_SORTED = 1 << 5
+} GtkRegionFlags;
+
+typedef enum
+{
+ GTK_WINDOW_TOPLEVEL,
+ GTK_WINDOW_POPUP
+} GtkWindowType;
+
+typedef enum
+{
+ G_PARAM_READABLE = 1 << 0,
+ G_PARAM_WRITABLE = 1 << 1,
+ G_PARAM_CONSTRUCT = 1 << 2,
+ G_PARAM_CONSTRUCT_ONLY = 1 << 3,
+ G_PARAM_LAX_VALIDATION = 1 << 4,
+ G_PARAM_STATIC_NAME = 1 << 5
+} GParamFlags;
+
+typedef enum
+{
+ GTK_ICON_LOOKUP_NO_SVG = 1 << 0,
+ GTK_ICON_LOOKUP_FORCE_SVG = 1 << 1,
+ GTK_ICON_LOOKUP_USE_BUILTIN = 1 << 2,
+ GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3,
+ GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 4
+} GtkIconLookupFlags;
+
+typedef enum
+{
+ GTK_UPDATE_CONTINUOUS,
+ GTK_UPDATE_DISCONTINUOUS,
+ GTK_UPDATE_DELAYED
+} GtkUpdateType;
+
+typedef enum
+{
+ GTK_PROGRESS_CONTINUOUS,
+ GTK_PROGRESS_DISCRETE
+} GtkProgressBarStyle;
+
+typedef enum
+{
+ GTK_PROGRESS_LEFT_TO_RIGHT,
+ GTK_PROGRESS_RIGHT_TO_LEFT,
+ GTK_PROGRESS_BOTTOM_TO_TOP,
+ GTK_PROGRESS_TOP_TO_BOTTOM
+} GtkProgressBarOrientation;
+
+typedef enum {
+ CAIRO_FORMAT_INVALID = -1,
+ CAIRO_FORMAT_ARGB32 = 0,
+ CAIRO_FORMAT_RGB24 = 1,
+ CAIRO_FORMAT_A8 = 2,
+ CAIRO_FORMAT_A1 = 3,
+ CAIRO_FORMAT_RGB16_565 = 4
+} cairo_format_t;
+
+/* We define all structure pointers to be void* */
+typedef void GdkPixbuf;
+typedef void GMainContext;
+typedef void GVfs;
+
+typedef void GdkColormap;
+typedef void GdkDrawable;
+typedef void GdkGC;
+typedef void GdkPixmap;
+typedef void GtkStyleContext;
+typedef void GtkFixed;
+typedef void GtkMenuItem;
+typedef void GtkMenuShell;
+typedef void GtkWidgetClass;
+typedef void PangoFontDescription;
+typedef void GtkSettings;
+typedef void GtkStyleProvider;
+typedef void cairo_pattern_t;
+typedef void cairo_t;
+typedef void cairo_surface_t;
+typedef void GtkScrolledWindow;
+typedef void GtkIconTheme;
+typedef void GtkWidget;
+typedef void GtkMisc;
+typedef void GtkContainer;
+typedef void GtkBin;
+typedef void GtkAdjustment;
+typedef void GtkRange;
+typedef void GtkProgressBar;
+typedef void GtkProgress;
+
+/* Some real structures */
+typedef struct
+{
+ guint32 pixel;
+ guint16 red;
+ guint16 green;
+ guint16 blue;
+} GdkColor;
+
+typedef struct
+{
+ gdouble red;
+ gdouble green;
+ gdouble blue;
+ gdouble alpha;
+} GdkRGBA;
+
+typedef struct {
+ gint fd;
+ gushort events;
+ gushort revents;
+} GPollFD;
+
+typedef struct {
+ gint x;
+ gint y;
+ gint width;
+ gint height;
+} GdkRectangle;
+
+typedef struct {
+ int x, y;
+ int width, height;
+} GtkAllocation;
+
+typedef struct {
+ gint width;
+ gint height;
+} GtkRequisition;
+
+typedef struct {
+ GtkWidgetClass *g_class;
+} GTypeInstance;
+
+typedef struct {
+ gint16 left;
+ gint16 right;
+ gint16 top;
+ gint16 bottom;
+} GtkBorder;
+
+typedef struct
+{
+ GType g_type;
+ union {
+ gint v_int;
+ guint v_uint;
+ glong v_long;
+ gulong v_ulong;
+ gint64 v_int64;
+ guint64 v_uint64;
+ gfloat v_float;
+ gdouble v_double;
+ gpointer v_pointer;
+ } data[2];
+} GValue;
+
+typedef struct {
+ GTypeInstance g_type_instance;
+ const gchar *name;
+ GParamFlags flags;
+ GType value_type;
+ GType owner_type;
+} GParamSpec;
+
+
+static gchar* (*fp_glib_check_version)(guint required_major,
+ guint required_minor, guint required_micro);
+
+/**
+ * Returns :
+ * NULL if the GTK+ library is compatible with the given version, or a string
+ * describing the version mismatch.
+ */
+static gchar* (*fp_gtk_check_version)(guint required_major, guint
+ required_minor, guint required_micro);
+
+static void (*fp_g_free)(gpointer mem);
+static void (*fp_g_object_unref)(gpointer object);
+static GdkWindow *(*fp_gdk_get_default_root_window) (void);
+
+static int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
+static guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
+static gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
+static int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
+static GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename,
+ GError **error);
+static GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
+
+static GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkWindow *window,
+ int src_x, int src_y, int width, int height);
+static GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
+ int dest_width, int dest_heigh, GdkInterpType interp_type);
+
+
+static void (*fp_gtk_widget_destroy)(void *widget);
+static void (*fp_gtk_window_present)(GtkWindow *window);
+static void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
+static void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
+
+/**
+ * Function Pointers for GtkFileChooser
+ */
+static gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
+static void (*fp_gtk_widget_hide)(void *widget);
+static void (*fp_gtk_main_quit)(void);
+static void* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
+ GtkWindow *parent, GtkFileChooserAction action,
+ const gchar *first_button_text, ...);
+static gboolean (*fp_gtk_file_chooser_set_current_folder)
+ (GtkFileChooser *chooser, const gchar *filename);
+static gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
+ const char *filename);
+static void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
+ const gchar *name);
+static void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
+ GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
+ GDestroyNotify notify);
+static void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
+ GtkFileFilter *filter);
+static GType (*fp_gtk_file_chooser_get_type)(void);
+static GtkFileFilter* (*fp_gtk_file_filter_new)(void);
+static void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
+ GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
+static void (*fp_gtk_file_chooser_set_select_multiple)(
+ GtkFileChooser *chooser, gboolean select_multiple);
+static gchar* (*fp_gtk_file_chooser_get_current_folder)
+ (GtkFileChooser *chooser);
+static GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
+static guint (*fp_gtk_g_slist_length)(GSList *list);
+static gulong (*fp_g_signal_connect_data)(gpointer instance,
+ const gchar *detailed_signal, GCallback c_handler, gpointer data,
+ GClosureNotify destroy_data, GConnectFlags connect_flags);
+static void (*fp_gtk_widget_show)(void *widget);
+static void (*fp_gtk_main)(void);
+static guint (*fp_gtk_main_level)(void);
+static gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
+static XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
+
+static GList* (*fp_g_list_append) (GList *list, gpointer data);
+static void (*fp_g_list_free) (GList *list);
+static void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);
+
+static void (*fp_gdk_threads_enter)(void);
+static void (*fp_gdk_threads_leave)(void);
+
+static gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
+ guint32 timestamp, GError **error);
+
+// Implementation functions prototypes
+static void gtk3_init(GtkApi* gtk);
+static GValue* (*fp_g_value_init)(GValue *value, GType g_type);
+static gboolean (*fp_g_type_is_a)(GType type, GType is_a_type);
+static gboolean (*fp_g_value_get_boolean)(const GValue *value);
+static gchar (*fp_g_value_get_char)(const GValue *value);
+static guchar (*fp_g_value_get_uchar)(const GValue *value);
+static gint (*fp_g_value_get_int)(const GValue *value);
+static guint (*fp_g_value_get_uint)(const GValue *value);
+static glong (*fp_g_value_get_long)(const GValue *value);
+static gulong (*fp_g_value_get_ulong)(const GValue *value);
+static gint64 (*fp_g_value_get_int64)(const GValue *value);
+static guint64 (*fp_g_value_get_uint64)(const GValue *value);
+static gfloat (*fp_g_value_get_float)(const GValue *value);
+static gdouble (*fp_g_value_get_double)(const GValue *value);
+static const gchar* (*fp_g_value_get_string)(const GValue *value);
+static gint (*fp_g_value_get_enum)(const GValue *value);
+static guint (*fp_g_value_get_flags)(const GValue *value);
+static GParamSpec* (*fp_g_value_get_param)(const GValue *value);
+static gpointer* (*fp_g_value_get_boxed)(const GValue *value);
+static gpointer* (*fp_g_value_get_pointer)(const GValue *value);
+static void (*fp_g_object_get)(gpointer object,
+ const gchar* fpn, ...);
+static void (*fp_g_object_set)(gpointer object,
+ const gchar *first_property_name,
+ ...);
+
+static gboolean (*fp_g_main_context_iteration)(GMainContext *context);
+static gboolean (*fp_g_str_has_prefix)(const gchar *str, const gchar *prefix);
+static gchar** (*fp_g_strsplit)(const gchar *string, const gchar *delimiter,
+ gint max_tokens);
+static void (*fp_g_strfreev)(gchar **str_array);
+
+
+static cairo_surface_t* (*fp_cairo_image_surface_create)(cairo_format_t format,
+ int width, int height);
+static void (*fp_cairo_surface_destroy)(cairo_surface_t *surface);
+static cairo_t* (*fp_cairo_create)(cairo_surface_t *target);
+static void (*fp_cairo_destroy)(cairo_t *cr);
+static void (*fp_cairo_fill)(cairo_t *cr);
+static void (*fp_cairo_surface_flush)(cairo_surface_t *surface);
+static void (*fp_cairo_rectangle)(cairo_t *cr, double x, double y, double width,
+ double height);
+static void (*fp_cairo_set_source_rgb)(cairo_t *cr, double red, double green,
+ double blue);
+static void (*fp_cairo_set_source_rgba)(cairo_t *cr, double red, double green,
+ double blue, double alpha);
+static void (*fp_cairo_paint)(cairo_t *cr);
+static void (*fp_cairo_clip)(cairo_t *cr);
+static unsigned char* (*fp_cairo_image_surface_get_data)(
+ cairo_surface_t *surface);
+static int (*fp_cairo_image_surface_get_stride) (cairo_surface_t *surface);
+static GdkPixbuf* (*fp_gdk_pixbuf_get_from_surface)(cairo_surface_t *surface,
+ gint src_x, gint src_y, gint width, gint height);
+static GtkStateType (*fp_gtk_widget_get_state)(GtkWidget *widget);
+static void (*fp_gtk_widget_set_state)(GtkWidget *widget, GtkStateType state);
+static gboolean (*fp_gtk_widget_is_focus)(GtkWidget *widget);
+static void (*fp_gtk_widget_set_allocation)(GtkWidget *widget,
+ const GtkAllocation *allocation);
+static GtkWidget* (*fp_gtk_widget_get_parent)(GtkWidget *widget);
+static GtkStyleContext* (*fp_gtk_widget_get_style_context)(GtkWidget *widget);
+static void (*fp_gtk_style_context_get_color)(GtkStyleContext *context,
+ GtkStateFlags state, GdkRGBA *color);
+static void (*fp_gtk_style_context_get_background_color)
+ (GtkStyleContext *context, GtkStateFlags state, GdkRGBA *color);
+static void (*fp_gtk_style_context_get)(GtkStyleContext *context,
+ GtkStateFlags state, ...);
+static GtkStateFlags (*fp_gtk_widget_get_state_flags)(GtkWidget* widget);
+static void (*fp_gtk_style_context_set_state)(GtkStyleContext* style,
+ GtkStateFlags flags);
+static void (*fp_gtk_style_context_add_class)(GtkStyleContext *context,
+ const gchar *class_name);
+static void (*fp_gtk_style_context_save)(GtkStyleContext *context);
+static void (*fp_gtk_style_context_restore)(GtkStyleContext *context);
+static void (*fp_gtk_render_check)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_option)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_extension)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height,
+ GtkPositionType gap_side);
+static void (*fp_gtk_render_expander)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_frame_gap)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height,
+ GtkPositionType gap_side, gdouble xy0_gap,
+ gdouble xy1_gap);
+static void (*fp_gtk_render_line)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x0, gdouble y0, gdouble x1, gdouble y1);
+static GdkPixbuf* (*fp_gtk_widget_render_icon_pixbuf)(GtkWidget *widget,
+ const gchar *stock_id, GtkIconSize size);
+static cairo_surface_t* (*fp_gdk_window_create_similar_image_surface)(
+ GdkWindow *window, cairo_format_t format, int width,
+ int height, int scale);
+static cairo_surface_t* (*fp_gdk_window_create_similar_surface)(
+ GdkWindow *window, cairo_format_t format,
+ int width, int height);
+static GdkWindow* (*fp_gtk_widget_get_window)(GtkWidget *widget);
+static GtkSettings *(*fp_gtk_settings_get_for_screen)(GdkScreen *screen);
+static GdkScreen *(*fp_gtk_widget_get_screen)(GtkWidget *widget);
+static GtkStyleProvider* (*fp_gtk_css_provider_get_named)(const gchar *name,
+ const gchar *variant);
+static void (*fp_gtk_style_context_add_provider)(GtkStyleContext *context,
+ GtkStyleProvider *provider, guint priority);
+static void (*fp_gtk_render_frame)(GtkStyleContext *context,cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_focus)(GtkStyleContext *context,cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_handle)(GtkStyleContext *context,cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_style_context_get_property)(GtkStyleContext *context,
+ const gchar *property, GtkStateFlags state, GValue *value);
+static void (*fp_gtk_render_activity)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height);
+static void (*fp_gtk_render_background)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height);
+static gboolean (*fp_gtk_style_context_has_class)(GtkStyleContext *context,
+ const gchar *class_name);
+static void transform_detail_string (const gchar *detail,
+ GtkStyleContext *context);
+void (*fp_gtk_style_context_set_junction_sides)(GtkStyleContext *context,
+ GtkJunctionSides sides);
+void (*fp_gtk_style_context_add_region)(GtkStyleContext *context,
+ const gchar *region_name, GtkRegionFlags flags);
+void (*fp_gtk_render_arrow)(GtkStyleContext *context, cairo_t *cr,
+ gdouble angle, gdouble x, gdouble y, gdouble size);
+void (*fp_gtk_bin_set_child)(GtkBin *bin, GtkWidget *widget);
+void (*fp_gtk_scrolled_window_set_shadow_type)(
+ GtkScrolledWindow *scrolled_window, GtkShadowType type);
+static void (*fp_gtk_render_slider)(GtkStyleContext *context, cairo_t *cr,
+ gdouble x, gdouble y, gdouble width, gdouble height,
+ GtkOrientation orientation);
+static void (*fp_gtk_style_context_get_padding)(GtkStyleContext *self,
+ GtkStateFlags state, GtkBorder* padding);
+static void (*fp_gtk_range_set_inverted)(GtkRange *range, gboolean setting);
+static PangoFontDescription* (*fp_gtk_style_context_get_font)(
+ GtkStyleContext *context, GtkStateFlags state);
+static int (*fp_gtk_widget_get_allocated_width)(GtkWidget *widget);
+static int (*fp_gtk_widget_get_allocated_height)(GtkWidget *widget);
+static GtkIconTheme* (*fp_gtk_icon_theme_get_default)(void);
+static GdkPixbuf* (*fp_gtk_icon_theme_load_icon)(GtkIconTheme *icon_theme,
+ const gchar *icon_name, gint size,
+ GtkIconLookupFlags flags, GError **error);
+static void (*fp_gtk_adjustment_set_lower)(GtkAdjustment *adjustment,
+ gdouble lower);
+static void (*fp_gtk_adjustment_set_page_increment)(GtkAdjustment *adjustment,
+ gdouble page_increment);
+static void (*fp_gtk_adjustment_set_page_size)(GtkAdjustment *adjustment,
+ gdouble page_size);
+static void (*fp_gtk_adjustment_set_step_increment)(GtkAdjustment *adjustment,
+ gdouble step_increment);
+static void (*fp_gtk_adjustment_set_upper)(GtkAdjustment *adjustment,
+ gdouble upper);
+static void (*fp_gtk_adjustment_set_value)(GtkAdjustment *adjustment,
+ gdouble value);
+static GdkGC *(*fp_gdk_gc_new)(GdkDrawable*);
+static void (*fp_gdk_rgb_gc_set_foreground)(GdkGC*, guint32);
+static void (*fp_gdk_draw_rectangle)(GdkDrawable*, GdkGC*, gboolean,
+ gint, gint, gint, gint);
+static GdkPixbuf *(*fp_gdk_pixbuf_new)(GdkColorspace colorspace,
+ gboolean has_alpha, int bits_per_sample, int width, int height);
+static void (*fp_gdk_drawable_get_size)(GdkDrawable *drawable,
+ gint* width, gint* height);
+static gboolean (*fp_gtk_init_check)(int* argc, char** argv);
+
+/* Widget creation */
+static GtkWidget* (*fp_gtk_arrow_new)(GtkArrowType arrow_type,
+ GtkShadowType shadow_type);
+static GtkWidget* (*fp_gtk_button_new)();
+static GtkWidget* (*fp_gtk_check_button_new)();
+static GtkWidget* (*fp_gtk_check_menu_item_new)();
+static GtkWidget* (*fp_gtk_color_selection_dialog_new)(const gchar* title);
+static GtkWidget* (*fp_gtk_combo_box_new)();
+static GtkWidget* (*fp_gtk_combo_box_entry_new)();
+static GtkWidget* (*fp_gtk_entry_new)();
+static GtkWidget* (*fp_gtk_fixed_new)();
+static GtkWidget* (*fp_gtk_handle_box_new)();
+static GtkWidget* (*fp_gtk_hpaned_new)();
+static GtkWidget* (*fp_gtk_vpaned_new)();
+static GtkWidget* (*fp_gtk_scale_new)(GtkOrientation orientation,
+ GtkAdjustment* adjustment);
+static GtkWidget* (*fp_gtk_hscrollbar_new)(GtkAdjustment* adjustment);
+static GtkWidget* (*fp_gtk_vscrollbar_new)(GtkAdjustment* adjustment);
+static GtkWidget* (*fp_gtk_hseparator_new)();
+static GtkWidget* (*fp_gtk_vseparator_new)();
+static GtkWidget* (*fp_gtk_image_new)();
+static GtkWidget* (*fp_gtk_label_new)(const gchar* str);
+static GtkWidget* (*fp_gtk_menu_new)();
+static GtkWidget* (*fp_gtk_menu_bar_new)();
+static GtkWidget* (*fp_gtk_menu_item_new)();
+static GtkWidget* (*fp_gtk_notebook_new)();
+static GtkWidget* (*fp_gtk_progress_bar_new)();
+static GtkWidget* (*fp_gtk_progress_bar_set_orientation)(
+ GtkProgressBar *pbar,
+ GtkProgressBarOrientation orientation);
+static GtkWidget* (*fp_gtk_radio_button_new)(GSList *group);
+static GtkWidget* (*fp_gtk_radio_menu_item_new)(GSList *group);
+static GtkWidget* (*fp_gtk_scrolled_window_new)(GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment);
+static GtkWidget* (*fp_gtk_separator_menu_item_new)();
+static GtkWidget* (*fp_gtk_separator_tool_item_new)();
+static GtkWidget* (*fp_gtk_text_view_new)();
+static GtkWidget* (*fp_gtk_toggle_button_new)();
+static GtkWidget* (*fp_gtk_toolbar_new)();
+static GtkWidget* (*fp_gtk_tree_view_new)();
+static GtkWidget* (*fp_gtk_viewport_new)(GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment);
+static GtkWidget* (*fp_gtk_window_new)(GtkWindowType type);
+static GtkWidget* (*fp_gtk_dialog_new)();
+static GtkWidget* (*fp_gtk_spin_button_new)(GtkAdjustment *adjustment,
+ gdouble climb_rate, guint digits);
+static GtkWidget* (*fp_gtk_frame_new)(const gchar *label);
+
+/* Other widget operations */
+static GtkAdjustment* (*fp_gtk_adjustment_new)(gdouble value,
+ gdouble lower, gdouble upper, gdouble step_increment,
+ gdouble page_increment, gdouble page_size);
+static void (*fp_gtk_container_add)(GtkContainer *window, GtkWidget *widget);
+static void (*fp_gtk_menu_shell_append)(GtkMenuShell *menu_shell,
+ GtkWidget *child);
+static void (*fp_gtk_menu_item_set_submenu)(GtkMenuItem *menu_item,
+ GtkWidget *submenu);
+static void (*fp_gtk_widget_realize)(GtkWidget *widget);
+static GdkPixbuf* (*fp_gtk_widget_render_icon)(GtkWidget *widget,
+ const gchar *stock_id, GtkIconSize size, const gchar *detail);
+static void (*fp_gtk_widget_set_name)(GtkWidget *widget, const gchar *name);
+static void (*fp_gtk_widget_set_parent)(GtkWidget *widget, GtkWidget *parent);
+static void (*fp_gtk_widget_set_direction)(GtkWidget *widget,
+ GtkTextDirection direction);
+static void (*fp_gtk_widget_style_get)(GtkWidget *widget,
+ const gchar *first_property_name, ...);
+static void (*fp_gtk_widget_class_install_style_property)(
+ GtkWidgetClass* class, GParamSpec *pspec);
+static GParamSpec* (*fp_gtk_widget_class_find_style_property)(
+ GtkWidgetClass* class, const gchar* property_name);
+static void (*fp_gtk_widget_style_get_property)(GtkWidget* widget,
+ const gchar* property_name, GValue* value);
+static char* (*fp_pango_font_description_to_string)(
+ const PangoFontDescription* fd);
+static GtkSettings* (*fp_gtk_settings_get_default)();
+static GtkSettings* (*fp_gtk_widget_get_settings)(GtkWidget *widget);
+static GType (*fp_gtk_border_get_type)();
+static void (*fp_gtk_arrow_set)(GtkWidget* arrow,
+ GtkArrowType arrow_type,
+ GtkShadowType shadow_type);
+static void (*fp_gtk_widget_size_request)(GtkWidget *widget,
+ GtkRequisition *requisition);
+static GtkAdjustment* (*fp_gtk_range_get_adjustment)(GtkRange* range);
+
+#endif /* !_GTK3_INTERFACE_H */
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.c
new file mode 100644
index 00000000000..0a136b39768
--- /dev/null
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.c
@@ -0,0 +1,158 @@
+/*
+ * 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
+ * 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 "jvm_md.h"
+#include "gtk_interface.h"
+
+GtkApi* gtk2_load(JNIEnv *env, const char* lib_name);
+GtkApi* gtk3_load(JNIEnv *env, const char* lib_name);
+
+gboolean gtk2_check(const char* lib_name, int flags);
+gboolean gtk3_check(const char* lib_name, int flags);
+
+GtkApi *gtk;
+
+typedef struct {
+ GtkVersion version;
+ const char* name;
+ const char* vname;
+ GtkApi* (*load)(JNIEnv *env, const char* lib_name);
+ gboolean (*check)(const char* lib_name, int flags);
+} GtkLib;
+
+static GtkLib libs[] = {
+ {
+ GTK_2,
+ JNI_LIB_NAME("gtk-x11-2.0"),
+ VERSIONED_JNI_LIB_NAME("gtk-x11-2.0", "0"),
+ >k2_load,
+ >k2_check
+ },
+ {
+ GTK_3,
+ JNI_LIB_NAME("gtk-3"),
+ VERSIONED_JNI_LIB_NAME("gtk-3", "0"),
+ >k3_load,
+ >k3_check
+ },
+ {
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ }
+};
+
+static GtkLib* get_loaded() {
+ GtkLib* lib = libs;
+ while(!gtk && lib->version) {
+ if (lib->check(lib->vname, RTLD_NOLOAD)) {
+ return lib;
+ }
+ if (lib->check(lib->name, RTLD_NOLOAD)) {
+ return lib;
+ }
+ lib++;
+ }
+ return NULL;
+}
+
+gboolean gtk_load(JNIEnv *env, GtkVersion version, gboolean verbose) {
+ if (gtk == NULL) {
+ GtkLib* lib = get_loaded();
+ if (lib) {
+ if (version != GTK_ANY && lib->version != version) {
+ if (verbose) {
+ fprintf(stderr, "WARNING: Cannot load GTK%d library: \
+ GTK%d has already been loaded\n", version, lib->version);
+ }
+ return FALSE;
+ }
+ if (verbose) {
+ fprintf(stderr, "Looking for GTK%d library...\n", version);
+ }
+ gtk = lib->load(env, lib->vname);
+ if (!gtk) {
+ gtk = lib->load(env, lib->name);
+ }
+ } else {
+ lib = libs;
+ while (!gtk && lib->version) {
+ if (version == GTK_ANY || lib->version == version) {
+ if (verbose) {
+ fprintf(stderr, "Looking for GTK%d library...\n",
+ lib->version);
+ }
+ gtk = lib->load(env, lib->vname);
+ if (!gtk) {
+ gtk = lib->load(env, lib->name);
+ }
+ if (verbose && !gtk) {
+ fprintf(stderr, "Not found.\n");
+ }
+ }
+ lib++;
+ }
+ lib--;
+ }
+ if (verbose) {
+ if (gtk) {
+ fprintf(stderr, "GTK%d library loaded.\n", lib->version);
+ } else {
+ fprintf(stderr, "Failed to load GTK library.\n");
+ }
+ }
+ }
+ return gtk != NULL;
+}
+
+static gboolean check_version(GtkVersion version, int flags) {
+ GtkLib* lib = libs;
+ while (lib->version) {
+ if (version == GTK_ANY || lib->version == version) {
+ if (lib->check(lib->vname, flags)) {
+ return TRUE;
+ }
+ if (lib->check(lib->name, flags)) {
+ return TRUE;
+ }
+ }
+ lib++;
+ }
+ return FALSE;
+}
+
+gboolean gtk_check_version(GtkVersion version) {
+ if (gtk) {
+ return TRUE;
+ }
+ if (check_version(version, RTLD_NOLOAD)) {
+ return TRUE;
+ }
+ return check_version(version, RTLD_LAZY | RTLD_LOCAL);
+}
+
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.h b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.h
new file mode 100644
index 00000000000..e39e172f7e5
--- /dev/null
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk_interface.h
@@ -0,0 +1,560 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+#ifndef _GTK_INTERFACE_H
+#define _GTK_INTERFACE_H
+
+#include
+#include
+
+#ifndef FALSE
+#define FALSE (0)
+#define TRUE (!FALSE)
+#endif
+
+#define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip)
+#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) \
+ (_G_TYPE_CIC ((instance), (g_type), c_type))
+#define GTK_TYPE_FILE_CHOOSER (fp_gtk_file_chooser_get_type ())
+#define GTK_FILE_CHOOSER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser))
+#define G_CALLBACK(f) ((GCallback) (f))
+#define G_TYPE_FUNDAMENTAL_SHIFT (2)
+#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
+#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
+#define GTK_STOCK_CANCEL "gtk-cancel"
+#define GTK_STOCK_SAVE "gtk-save"
+#define GTK_STOCK_OPEN "gtk-open"
+#define GDK_CURRENT_TIME 0L
+
+#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0)
+#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1)
+#define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2)
+#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3)
+#define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4)
+#define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5)
+#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6)
+#define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7)
+#define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8)
+#define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9)
+#define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10)
+#define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11)
+#define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12)
+#define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13)
+#define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14)
+#define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15)
+#define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16)
+#define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17)
+#define G_TYPE_BOXED G_TYPE_MAKE_FUNDAMENTAL (18)
+#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19)
+#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20)
+
+#define GTK_TYPE_BORDER ((*fp_gtk_border_get_type)())
+
+#define G_TYPE_FUNDAMENTAL_SHIFT (2)
+#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
+
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#define CONV_BUFFER_SIZE 128
+#define NO_SYMBOL_EXCEPTION 1
+
+/* basic types */
+typedef char gchar;
+typedef short gshort;
+typedef int gint;
+typedef long glong;
+typedef float gfloat;
+typedef double gdouble;
+typedef void* gpointer;
+typedef gint gboolean;
+typedef signed char gint8;
+typedef signed short gint16;
+typedef signed int gint32;
+typedef unsigned char guchar;
+typedef unsigned char guint8;
+typedef unsigned short gushort;
+typedef unsigned short guint16;
+typedef unsigned int guint;
+typedef unsigned int guint32;
+typedef unsigned int gsize;
+typedef unsigned long gulong;
+typedef signed long long gint64;
+typedef unsigned long long guint64;
+typedef gulong GType;
+
+typedef struct _GList GList;
+struct _GList
+{
+ gpointer data;
+ GList *next;
+ GList *prev;
+};
+
+typedef struct _GSList GSList;
+struct _GSList {
+ gpointer data;
+ GSList *next;
+};
+
+typedef enum {
+ BUTTON, /* GtkButton */
+ CHECK_BOX, /* GtkCheckButton */
+ CHECK_BOX_MENU_ITEM, /* GtkCheckMenuItem */
+ COLOR_CHOOSER, /* GtkColorSelectionDialog */
+ COMBO_BOX, /* GtkComboBox */
+ COMBO_BOX_ARROW_BUTTON, /* GtkComboBoxEntry */
+ COMBO_BOX_TEXT_FIELD, /* GtkComboBoxEntry */
+ DESKTOP_ICON, /* GtkLabel */
+ DESKTOP_PANE, /* GtkContainer */
+ EDITOR_PANE, /* GtkTextView */
+ FORMATTED_TEXT_FIELD, /* GtkEntry */
+ HANDLE_BOX, /* GtkHandleBox */
+ HPROGRESS_BAR, /* GtkProgressBar */
+ HSCROLL_BAR, /* GtkHScrollbar */
+ HSCROLL_BAR_BUTTON_LEFT, /* GtkHScrollbar */
+ HSCROLL_BAR_BUTTON_RIGHT, /* GtkHScrollbar */
+ HSCROLL_BAR_TRACK, /* GtkHScrollbar */
+ HSCROLL_BAR_THUMB, /* GtkHScrollbar */
+ HSEPARATOR, /* GtkHSeparator */
+ HSLIDER, /* GtkHScale */
+ HSLIDER_TRACK, /* GtkHScale */
+ HSLIDER_THUMB, /* GtkHScale */
+ HSPLIT_PANE_DIVIDER, /* GtkHPaned */
+ INTERNAL_FRAME, /* GtkWindow */
+ INTERNAL_FRAME_TITLE_PANE, /* GtkLabel */
+ IMAGE, /* GtkImage */
+ LABEL, /* GtkLabel */
+ LIST, /* GtkTreeView */
+ MENU, /* GtkMenu */
+ MENU_BAR, /* GtkMenuBar */
+ MENU_ITEM, /* GtkMenuItem */
+ MENU_ITEM_ACCELERATOR, /* GtkLabel */
+ OPTION_PANE, /* GtkMessageDialog */
+ PANEL, /* GtkContainer */
+ PASSWORD_FIELD, /* GtkEntry */
+ POPUP_MENU, /* GtkMenu */
+ POPUP_MENU_SEPARATOR, /* GtkSeparatorMenuItem */
+ RADIO_BUTTON, /* GtkRadioButton */
+ RADIO_BUTTON_MENU_ITEM, /* GtkRadioMenuItem */
+ ROOT_PANE, /* GtkContainer */
+ SCROLL_PANE, /* GtkScrolledWindow */
+ SPINNER, /* GtkSpinButton */
+ SPINNER_ARROW_BUTTON, /* GtkSpinButton */
+ SPINNER_TEXT_FIELD, /* GtkSpinButton */
+ SPLIT_PANE, /* GtkPaned */
+ TABBED_PANE, /* GtkNotebook */
+ TABBED_PANE_TAB_AREA, /* GtkNotebook */
+ TABBED_PANE_CONTENT, /* GtkNotebook */
+ TABBED_PANE_TAB, /* GtkNotebook */
+ TABLE, /* GtkTreeView */
+ TABLE_HEADER, /* GtkButton */
+ TEXT_AREA, /* GtkTextView */
+ TEXT_FIELD, /* GtkEntry */
+ TEXT_PANE, /* GtkTextView */
+ TITLED_BORDER, /* GtkFrame */
+ TOGGLE_BUTTON, /* GtkToggleButton */
+ TOOL_BAR, /* GtkToolbar */
+ TOOL_BAR_DRAG_WINDOW, /* GtkToolbar */
+ TOOL_BAR_SEPARATOR, /* GtkSeparatorToolItem */
+ TOOL_TIP, /* GtkWindow */
+ TREE, /* GtkTreeView */
+ TREE_CELL, /* GtkTreeView */
+ VIEWPORT, /* GtkViewport */
+ VPROGRESS_BAR, /* GtkProgressBar */
+ VSCROLL_BAR, /* GtkVScrollbar */
+ VSCROLL_BAR_BUTTON_UP, /* GtkVScrollbar */
+ VSCROLL_BAR_BUTTON_DOWN, /* GtkVScrollbar */
+ VSCROLL_BAR_TRACK, /* GtkVScrollbar */
+ VSCROLL_BAR_THUMB, /* GtkVScrollbar */
+ VSEPARATOR, /* GtkVSeparator */
+ VSLIDER, /* GtkVScale */
+ VSLIDER_TRACK, /* GtkVScale */
+ VSLIDER_THUMB, /* GtkVScale */
+ VSPLIT_PANE_DIVIDER, /* GtkVPaned */
+ WIDGET_TYPE_SIZE
+} WidgetType;
+
+typedef enum
+{
+ _GTK_ARROW_TYPE,
+ _GTK_BUTTON_TYPE,
+ _GTK_CHECK_BUTTON_TYPE,
+ _GTK_CHECK_MENU_ITEM_TYPE,
+ _GTK_COLOR_SELECTION_DIALOG_TYPE,
+ _GTK_COMBO_BOX_TYPE,
+ _GTK_COMBO_BOX_ARROW_BUTTON_TYPE,
+ _GTK_COMBO_BOX_TEXT_FIELD_TYPE,
+ _GTK_CONTAINER_TYPE,
+ _GTK_ENTRY_TYPE,
+ _GTK_FRAME_TYPE,
+ _GTK_HANDLE_BOX_TYPE,
+ _GTK_HPANED_TYPE,
+ _GTK_HPROGRESS_BAR_TYPE,
+ _GTK_HSCALE_TYPE,
+ _GTK_HSCROLLBAR_TYPE,
+ _GTK_HSEPARATOR_TYPE,
+ _GTK_IMAGE_TYPE,
+ _GTK_MENU_TYPE,
+ _GTK_MENU_BAR_TYPE,
+ _GTK_MENU_ITEM_TYPE,
+ _GTK_NOTEBOOK_TYPE,
+ _GTK_LABEL_TYPE,
+ _GTK_RADIO_BUTTON_TYPE,
+ _GTK_RADIO_MENU_ITEM_TYPE,
+ _GTK_SCROLLED_WINDOW_TYPE,
+ _GTK_SEPARATOR_MENU_ITEM_TYPE,
+ _GTK_SEPARATOR_TOOL_ITEM_TYPE,
+ _GTK_SPIN_BUTTON_TYPE,
+ _GTK_TEXT_VIEW_TYPE,
+ _GTK_TOGGLE_BUTTON_TYPE,
+ _GTK_TOOLBAR_TYPE,
+ _GTK_TOOLTIP_TYPE,
+ _GTK_TREE_VIEW_TYPE,
+ _GTK_VIEWPORT_TYPE,
+ _GTK_VPANED_TYPE,
+ _GTK_VPROGRESS_BAR_TYPE,
+ _GTK_VSCALE_TYPE,
+ _GTK_VSCROLLBAR_TYPE,
+ _GTK_VSEPARATOR_TYPE,
+ _GTK_WINDOW_TYPE,
+ _GTK_DIALOG_TYPE,
+ _GTK_WIDGET_TYPE_SIZE
+} GtkWidgetType;
+
+typedef enum
+{
+ GTK_STATE_NORMAL,
+ GTK_STATE_ACTIVE,
+ GTK_STATE_PRELIGHT,
+ GTK_STATE_SELECTED,
+ GTK_STATE_INSENSITIVE,
+ GTK_STATE_INCONSISTENT,
+ GTK_STATE_FOCUSED
+} GtkStateType;
+
+typedef enum
+{
+ GTK_SHADOW_NONE,
+ GTK_SHADOW_IN,
+ GTK_SHADOW_OUT,
+ GTK_SHADOW_ETCHED_IN,
+ GTK_SHADOW_ETCHED_OUT
+} GtkShadowType;
+
+typedef enum
+{
+ GTK_EXPANDER_COLLAPSED,
+ GTK_EXPANDER_SEMI_COLLAPSED,
+ GTK_EXPANDER_SEMI_EXPANDED,
+ GTK_EXPANDER_EXPANDED
+} GtkExpanderStyle;
+
+typedef enum
+{
+ GTK_ICON_SIZE_INVALID,
+ GTK_ICON_SIZE_MENU,
+ GTK_ICON_SIZE_SMALL_TOOLBAR,
+ GTK_ICON_SIZE_LARGE_TOOLBAR,
+ GTK_ICON_SIZE_BUTTON,
+ GTK_ICON_SIZE_DND,
+ GTK_ICON_SIZE_DIALOG
+} GtkIconSize;
+
+typedef enum
+{
+ GTK_ORIENTATION_HORIZONTAL,
+ GTK_ORIENTATION_VERTICAL
+} GtkOrientation;
+
+typedef enum
+{
+ FOREGROUND,
+ BACKGROUND,
+ TEXT_FOREGROUND,
+ TEXT_BACKGROUND,
+ FOCUS,
+ LIGHT,
+ DARK,
+ MID,
+ BLACK,
+ WHITE
+} ColorType;
+
+typedef enum
+{
+ GTK_FONT_NAME,
+ GTK_ICON_SIZES,
+ GTK_CURSOR_BLINK,
+ GTK_CURSOR_BLINK_TIME
+} Setting;
+
+typedef enum
+{
+ GTK_ARROW_UP,
+ GTK_ARROW_DOWN,
+ GTK_ARROW_LEFT,
+ GTK_ARROW_RIGHT,
+ GTK_ARROW_NONE
+} GtkArrowType;
+
+typedef enum
+{
+ GTK_TEXT_DIR_NONE,
+ GTK_TEXT_DIR_LTR,
+ GTK_TEXT_DIR_RTL
+} GtkTextDirection;
+
+typedef enum
+{
+ GTK_POS_LEFT,
+ GTK_POS_RIGHT,
+ GTK_POS_TOP,
+ GTK_POS_BOTTOM
+} GtkPositionType;
+
+/* SynthConstants */
+static const gint ENABLED = 1 << 0;
+static const gint MOUSE_OVER = 1 << 1;
+static const gint PRESSED = 1 << 2;
+static const gint DISABLED = 1 << 3;
+static const gint FOCUSED = 1 << 8;
+static const gint SELECTED = 1 << 9;
+static const gint DEFAULT = 1 << 10;
+
+typedef enum
+{
+ GTK_ANY,
+ GTK_1,
+ GTK_2,
+ GTK_3
+} GtkVersion;
+
+//------------------------------
+
+
+
+typedef enum {
+ GTK_RESPONSE_NONE = -1,
+ GTK_RESPONSE_REJECT = -2,
+ GTK_RESPONSE_ACCEPT = -3,
+ GTK_RESPONSE_DELETE_EVENT = -4,
+ GTK_RESPONSE_OK = -5,
+ GTK_RESPONSE_CANCEL = -6,
+ GTK_RESPONSE_CLOSE = -7,
+ GTK_RESPONSE_YES = -8,
+ GTK_RESPONSE_NO = -9,
+ GTK_RESPONSE_APPLY = -10,
+ GTK_RESPONSE_HELP = -11
+} GtkResponseType;
+
+typedef enum {
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
+} GtkFileChooserAction;
+
+typedef enum {
+ GTK_FILE_FILTER_FILENAME = 1 << 0,
+ GTK_FILE_FILTER_URI = 1 << 1,
+ GTK_FILE_FILTER_DISPLAY_NAME = 1 << 2,
+ GTK_FILE_FILTER_MIME_TYPE = 1 << 3
+} GtkFileFilterFlags;
+
+typedef enum {
+ GDK_COLORSPACE_RGB
+} GdkColorspace;
+
+typedef enum {
+ GDK_INTERP_NEAREST,
+ GDK_INTERP_TILES,
+ GDK_INTERP_BILINEAR,
+ GDK_INTERP_HYPER
+} GdkInterpType;
+
+typedef enum {
+ G_CONNECT_AFTER = 1 << 0, G_CONNECT_SWAPPED = 1 << 1
+} GConnectFlags;
+//------------------------------
+
+
+typedef void GError;
+typedef void GdkScreen;
+typedef void GtkWindow;
+typedef void GdkWindow;
+typedef void GClosure;
+typedef void GtkFileChooser;
+typedef void GtkFileFilter;
+typedef struct {
+ GtkFileFilterFlags contains;
+ const gchar *filename;
+ const gchar *uri;
+ const gchar *display_name;
+ const gchar *mime_type;
+} GtkFileFilterInfo;
+typedef gboolean (*GtkFileFilterFunc)(const GtkFileFilterInfo *filter_info,
+ gpointer data);
+typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
+typedef void (*GDestroyNotify)(gpointer data);
+typedef void (*GCallback)(void);
+
+
+typedef struct GtkApi {
+ int version;
+ gboolean (*show_uri_load)(JNIEnv *env);
+ gboolean (*unload)();
+ void (*flush_event_loop)();
+ gchar* (*gtk_check_version)(guint required_major, guint required_minor,
+ guint required_micro);
+ jobject (*get_setting)(JNIEnv *env, Setting property);
+
+ void (*paint_arrow)(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height,
+ GtkArrowType arrow_type, gboolean fill);
+ void (*paint_box)(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height,
+ gint synth_state, GtkTextDirection dir);
+ void (*paint_box_gap)(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height,
+ GtkPositionType gap_side, gint gap_x, gint gap_width);
+ void (*paint_expander)(WidgetType widget_type, GtkStateType state_type,
+ const gchar *detail, gint x, gint y, gint width, gint height,
+ GtkExpanderStyle expander_style);
+ void (*paint_extension)(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height, GtkPositionType gap_side);
+ void (*paint_flat_box)(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height, gboolean has_focus);
+ void (*paint_focus)(WidgetType widget_type, GtkStateType state_type,
+ const char *detail, gint x, gint y, gint width, gint height);
+ void (*paint_handle)(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height, GtkOrientation orientation);
+ void (*paint_hline)(WidgetType widget_type, GtkStateType state_type,
+ const gchar *detail, gint x, gint y, gint width, gint height);
+ void (*paint_vline)(WidgetType widget_type, GtkStateType state_type,
+ const gchar *detail, gint x, gint y, gint width, gint height);
+ void (*paint_option)(WidgetType widget_type, gint synth_state,
+ const gchar *detail, gint x, gint y, gint width, gint height);
+ void (*paint_shadow)(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height,
+ gint synth_state, GtkTextDirection dir);
+ void (*paint_slider)(WidgetType widget_type, GtkStateType state_type,
+ GtkShadowType shadow_type, const gchar *detail,
+ gint x, gint y, gint width, gint height, GtkOrientation orientation,
+ gboolean has_focus);
+ void (*paint_background)(WidgetType widget_type, GtkStateType state_type,
+ gint x, gint y, gint width, gint height);
+ void (*paint_check)(WidgetType widget_type, gint synth_state,
+ const gchar *detail, gint x, gint y, gint width, gint height);
+ void (*set_range_value)(WidgetType widget_type, jdouble value,
+ jdouble min, jdouble max, jdouble visible);
+
+ void (*init_painting)(JNIEnv *env, gint w, gint h);
+ gint (*copy_image)(gint *dest, gint width, gint height);
+
+ gint (*get_xthickness)(JNIEnv *env, WidgetType widget_type);
+ gint (*get_ythickness)(JNIEnv *env, WidgetType widget_type);
+ gint (*get_color_for_state)(JNIEnv *env, WidgetType widget_type,
+ GtkStateType state_type, ColorType color_type);
+ jobject (*get_class_value)(JNIEnv *env, WidgetType widget_type,
+ const char* key);
+
+ jstring (*get_pango_font_name)(JNIEnv *env, WidgetType widget_type);
+ jboolean (*get_icon_data)(JNIEnv *env, gint widget_type,
+ const gchar *stock_id, GtkIconSize size,
+ GtkTextDirection direction, const char *detail,
+ jmethodID icon_upcall_method, jobject this);
+ jboolean (*get_file_icon_data)(JNIEnv *env, const char *filename,
+ GError **error, jmethodID icon_upcall_method, jobject this);
+ void (*gdk_threads_enter)(void);
+ void (*gdk_threads_leave)(void);
+ gboolean (*gtk_show_uri)(GdkScreen *screen, const gchar *uri,
+ guint32 timestamp, GError **error);
+ gboolean (*get_drawable_data)(JNIEnv *env, jintArray pixelArray,
+ jint x, jint y, jint width, jint height,
+ jint jwidth, int dx, int dy, jint scale);
+ void (*g_free)(gpointer mem);
+
+
+ gchar* (*gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
+ void (*gtk_widget_hide)(void* widget);
+ void (*gtk_main_quit)(void);
+ void* (*gtk_file_chooser_dialog_new)(const gchar *title,
+ GtkWindow *parent, GtkFileChooserAction action,
+ const gchar *first_button_text, ...);
+ gboolean (*gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
+ const gchar *filename);
+ gboolean (*gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
+ const char *filename);
+ void (*gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
+ const gchar *name);
+ void (*gtk_file_filter_add_custom)(GtkFileFilter *filter,
+ GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
+ GDestroyNotify notify);
+ void (*gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
+ GtkFileFilter *filter);
+ GType (*gtk_file_chooser_get_type)(void);
+ GtkFileFilter* (*gtk_file_filter_new)(void);
+ void (*gtk_file_chooser_set_do_overwrite_confirmation)(
+ GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
+ void (*gtk_file_chooser_set_select_multiple)(
+ GtkFileChooser *chooser, gboolean select_multiple);
+ gchar* (*gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
+ GSList* (*gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
+ guint (*gtk_g_slist_length)(GSList *list);
+ gulong (*g_signal_connect_data)(gpointer instance,
+ const gchar *detailed_signal, GCallback c_handler, gpointer data,
+ GClosureNotify destroy_data, GConnectFlags connect_flags);
+ void (*gtk_widget_show)(void *widget);
+ void (*gtk_main)(void);
+ guint (*gtk_main_level)(void);
+ gchar* (*g_path_get_dirname) (const gchar *file_name);
+ XID (*gdk_x11_drawable_get_xid) (void *drawable);
+ void (*gtk_widget_destroy)(void *widget);
+ void (*gtk_window_present)(void *window);
+ void (*gtk_window_move)(void *window, gint x, gint y);
+ void (*gtk_window_resize)(void *window, gint width, gint height);
+ GdkWindow *(*get_window)(void *widget);
+
+ void (*g_object_unref)(gpointer object);
+ GList* (*g_list_append) (GList *list, gpointer data);
+ void (*g_list_free) (GList *list);
+ void (*g_list_free_full) (GList *list, GDestroyNotify free_func);
+} GtkApi;
+
+gboolean gtk_load(JNIEnv *env, GtkVersion version, gboolean verbose);
+gboolean gtk_check_version(GtkVersion version);
+
+extern GtkApi* gtk;
+
+#endif /* !_GTK_INTERFACE_H */
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c
index 97fbcc60da0..556fe252538 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/sun_awt_X11_GtkFileDialogPeer.c
@@ -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,11 +28,12 @@
#include
#include
#include
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
#include "sun_awt_X11_GtkFileDialogPeer.h"
#include "java_awt_FileDialog.h"
#include "debug_assert.h"
+typedef void GtkWidget;
static JavaVM *jvm;
/* To cache some method IDs */
@@ -90,20 +91,20 @@ static void quit(JNIEnv * env, jobject jpeer, gboolean isSignalHandler)
{
// Callbacks from GTK signals are made within the GTK lock
// So, within a signal handler there is no need to call
- // gdk_threads_enter() / fp_gdk_threads_leave()
+ // gdk_threads_enter() / gtk->gdk_threads_leave()
if (!isSignalHandler) {
- fp_gdk_threads_enter();
+ gtk->gdk_threads_enter();
}
- fp_gtk_widget_hide (dialog);
- fp_gtk_widget_destroy (dialog);
+ gtk->gtk_widget_hide (dialog);
+ gtk->gtk_widget_destroy (dialog);
- fp_gtk_main_quit ();
+ gtk->gtk_main_quit ();
(*env)->SetLongField(env, jpeer, widgetFieldID, 0);
if (!isSignalHandler) {
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
}
@@ -133,16 +134,16 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront
{
GtkWidget * dialog;
- fp_gdk_threads_enter();
+ gtk->gdk_threads_enter();
dialog = (GtkWidget*)jlong_to_ptr(
(*env)->GetLongField(env, jpeer, widgetFieldID));
if (dialog != NULL) {
- fp_gtk_window_present((GtkWindow*)dialog);
+ gtk->gtk_window_present((GtkWindow*)dialog);
}
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -155,21 +156,21 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_setBounds
{
GtkWindow* dialog;
- fp_gdk_threads_enter();
+ gtk->gdk_threads_enter();
dialog = (GtkWindow*)jlong_to_ptr(
(*env)->GetLongField(env, jpeer, widgetFieldID));
if (dialog != NULL) {
if (x >= 0 && y >= 0) {
- fp_gtk_window_move(dialog, (gint)x, (gint)y);
+ gtk->gtk_window_move(dialog, (gint)x, (gint)y);
}
if (width > 0 && height > 0) {
- fp_gtk_window_resize(dialog, (gint)width, (gint)height);
+ gtk->gtk_window_resize(dialog, (gint)width, (gint)height);
}
}
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -182,18 +183,18 @@ static gboolean isFromSameDirectory(GSList* list, gchar** baseDir) {
gboolean isAllDirsSame = TRUE;
while (it) {
- gchar* dir = fp_g_path_get_dirname((gchar*) it->data);
+ gchar* dir = gtk->g_path_get_dirname((gchar*) it->data);
if (prevDir && strcmp(prevDir, dir) != 0) {
isAllDirsSame = FALSE;
- fp_g_free(dir);
+ gtk->g_free(dir);
break;
}
if (!prevDir) {
prevDir = strdup(dir);
}
- fp_g_free(dir);
+ gtk->g_free(dir);
it = it->next;
}
@@ -233,7 +234,7 @@ static jobjectArray toFilenamesArray(JNIEnv *env, GSList* list, jstring* jcurren
return NULL;
}
- array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls, NULL);
+ array = (*env)->NewObjectArray(env, gtk->gtk_g_slist_length(list), stringCls, NULL);
if (array == NULL) {
(*env)->ExceptionClear(env);
JNU_ThrowInternalError(env, "Could not instantiate array files array");
@@ -287,7 +288,7 @@ static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
filenames = NULL;
if (responseId == GTK_RESPONSE_ACCEPT) {
- filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
+ filenames = gtk->gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
}
jfilenames = toFilenamesArray(env, filenames, &jcurrent_folder);
@@ -318,7 +319,7 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
JNU_CHECK_EXCEPTION(env);
}
- fp_gdk_threads_enter();
+ gtk->gdk_threads_enter();
const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0);
if (title == NULL) {
@@ -329,19 +330,19 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
if (mode == java_awt_FileDialog_SAVE) {
/* Save action */
- dialog = fp_gtk_file_chooser_dialog_new(title, NULL,
+ dialog = gtk->gtk_file_chooser_dialog_new(title, NULL,
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
}
else {
/* Default action OPEN */
- dialog = fp_gtk_file_chooser_dialog_new(title, NULL,
+ dialog = gtk->gtk_file_chooser_dialog_new(title, NULL,
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
/* Set multiple selection mode, that is allowed only in OPEN action */
if (multiple) {
- fp_gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog),
+ gtk->gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog),
multiple);
}
}
@@ -358,7 +359,7 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
JNU_ThrowOutOfMemoryError(env, "Could not get dir");
return;
}
- fp_gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
+ gtk->gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), dir);
(*env)->ReleaseStringUTFChars(env, jdir, dir);
}
@@ -371,47 +372,48 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
return;
}
if (mode == java_awt_FileDialog_SAVE) {
- fp_gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
+ gtk->gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
} else {
- fp_gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
+ gtk->gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
}
(*env)->ReleaseStringUTFChars(env, jfile, filename);
}
/* Set the file filter */
if (jfilter != NULL) {
- filter = fp_gtk_file_filter_new();
- fp_gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
+ filter = gtk->gtk_file_filter_new();
+ gtk->gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
filenameFilterCallback, jpeer, NULL);
- fp_gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
+ gtk->gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
}
/* Other Properties */
- if (fp_gtk_check_version(2, 8, 0) == NULL) {
- fp_gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(
+ if (gtk->gtk_check_version(2, 8, 0) == NULL ||
+ gtk->gtk_check_version(3, 0, 0) == NULL) {
+ gtk->gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(
dialog), TRUE);
}
/* Set the initial location */
if (x >= 0 && y >= 0) {
- fp_gtk_window_move((GtkWindow*)dialog, (gint)x, (gint)y);
+ gtk->gtk_window_move((GtkWindow*)dialog, (gint)x, (gint)y);
// NOTE: it doesn't set the initial size for the file chooser
// as it seems like the file chooser overrides the size internally
}
- fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
- handle_response), jpeer);
+ gtk->g_signal_connect_data(dialog, "response", G_CALLBACK(
+ handle_response), jpeer, 0, 0);
(*env)->SetLongField(env, jpeer, widgetFieldID, ptr_to_jlong(dialog));
- fp_gtk_widget_show(dialog);
+ gtk->gtk_widget_show(dialog);
- XID xid = fp_gdk_x11_drawable_get_xid(dialog->window);
+ XID xid = gtk->gdk_x11_drawable_get_xid(gtk->get_window(dialog));
if( (*env)->CallBooleanMethod(env, jpeer, setWindowMethodID, xid) ) {
- fp_gtk_main();
+ gtk->gtk_main();
}
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c
index 7d9db4a5632..47c7ad23ebd 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKEngine.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2012, 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
@@ -24,9 +24,24 @@
*/
#include
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
#include "com_sun_java_swing_plaf_gtk_GTKEngine.h"
+/* Static buffer for conversion from java.lang.String to UTF-8 */
+static char conversionBuffer[CONV_BUFFER_SIZE];
+
+const char *getStrFor(JNIEnv *env, jstring val)
+{
+ int length = (*env)->GetStringLength(env, val);
+ if (length > CONV_BUFFER_SIZE-1)
+ {
+ length = CONV_BUFFER_SIZE-1;
+ }
+
+ (*env)->GetStringUTFRegion(env, val, 0, length, conversionBuffer);
+ return conversionBuffer;
+}
+
/*
* Class: com_sun_java_swing_plaf_gtk_GTKEngine
* Method: native_paint_arrow
@@ -38,10 +53,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jint arrow_type)
{
- fp_gdk_threads_enter();
- gtk2_paint_arrow(widget_type, state, shadow_type, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_arrow(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, arrow_type, TRUE);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -56,10 +71,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box(
jint x, jint y, jint w, jint h,
jint synth_state, jint dir)
{
- fp_gdk_threads_enter();
- gtk2_paint_box(widget_type, state, shadow_type, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_box(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, synth_state, dir);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -74,10 +89,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box_1gap(
jint x, jint y, jint w, jint h,
jint gap_side, jint gap_x, jint gap_w)
{
- fp_gdk_threads_enter();
- gtk2_paint_box_gap(widget_type, state, shadow_type, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_box_gap(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, gap_side, gap_x, gap_w);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -91,10 +106,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1check(
jint widget_type, jint synth_state, jstring detail,
jint x, jint y, jint w, jint h)
{
- fp_gdk_threads_enter();
- gtk2_paint_check(widget_type, synth_state, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_check(widget_type, synth_state, getStrFor(env, detail),
x, y, w, h);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -108,10 +123,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1expander(
jint widget_type, jint state, jstring detail,
jint x, jint y, jint w, jint h, jint expander_style)
{
- fp_gdk_threads_enter();
- gtk2_paint_expander(widget_type, state, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_expander(widget_type, state, getStrFor(env, detail),
x, y, w, h, expander_style);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -125,10 +140,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1extension(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jint placement)
{
- fp_gdk_threads_enter();
- gtk2_paint_extension(widget_type, state, shadow_type,
+ gtk->gdk_threads_enter();
+ gtk->paint_extension(widget_type, state, shadow_type,
getStrFor(env, detail), x, y, w, h, placement);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -142,10 +157,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1flat_1box(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jboolean has_focus)
{
- fp_gdk_threads_enter();
- gtk2_paint_flat_box(widget_type, state, shadow_type,
+ gtk->gdk_threads_enter();
+ gtk->paint_flat_box(widget_type, state, shadow_type,
getStrFor(env, detail), x, y, w, h, has_focus);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -159,10 +174,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1focus(
jint widget_type, jint state, jstring detail,
jint x, jint y, jint w, jint h)
{
- fp_gdk_threads_enter();
- gtk2_paint_focus(widget_type, state, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_focus(widget_type, state, getStrFor(env, detail),
x, y, w, h);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -176,10 +191,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1handle(
jint widget_type, jint state, jint shadow_type, jstring detail,
jint x, jint y, jint w, jint h, jint orientation)
{
- fp_gdk_threads_enter();
- gtk2_paint_handle(widget_type, state, shadow_type, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_handle(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, orientation);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -193,10 +208,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1hline(
jint widget_type, jint state, jstring detail,
jint x, jint y, jint w, jint h)
{
- fp_gdk_threads_enter();
- gtk2_paint_hline(widget_type, state, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_hline(widget_type, state, getStrFor(env, detail),
x, y, w, h);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -210,10 +225,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1option(
jint widget_type, jint synth_state, jstring detail,
jint x, jint y, jint w, jint h)
{
- fp_gdk_threads_enter();
- gtk2_paint_option(widget_type, synth_state, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_option(widget_type, synth_state, getStrFor(env, detail),
x, y, w, h);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -228,10 +243,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1shadow(
jint x, jint y, jint w, jint h,
jint synth_state, jint dir)
{
- fp_gdk_threads_enter();
- gtk2_paint_shadow(widget_type, state, shadow_type, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_shadow(widget_type, state, shadow_type, getStrFor(env, detail),
x, y, w, h, synth_state, dir);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -243,12 +258,12 @@ JNIEXPORT void JNICALL
Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider(
JNIEnv *env, jobject this,
jint widget_type, jint state, jint shadow_type, jstring detail,
- jint x, jint y, jint w, jint h, jint orientation)
+ jint x, jint y, jint w, jint h, jint orientation, jboolean has_focus)
{
- fp_gdk_threads_enter();
- gtk2_paint_slider(widget_type, state, shadow_type, getStrFor(env, detail),
- x, y, w, h, orientation);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ gtk->paint_slider(widget_type, state, shadow_type, getStrFor(env, detail),
+ x, y, w, h, orientation, has_focus);
+ gtk->gdk_threads_leave();
}
/*
@@ -262,10 +277,10 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1vline(
jint widget_type, jint state, jstring detail,
jint x, jint y, jint w, jint h)
{
- fp_gdk_threads_enter();
- gtk2_paint_vline(widget_type, state, getStrFor(env, detail),
+ gtk->gdk_threads_enter();
+ gtk->paint_vline(widget_type, state, getStrFor(env, detail),
x, y, w, h);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -278,9 +293,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1background(
JNIEnv *env, jobject this, jint widget_type, jint state,
jint x, jint y, jint w, jint h)
{
- fp_gdk_threads_enter();
- gtk_paint_background(widget_type, state, x, y, w, h);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ gtk->paint_background(widget_type, state, x, y, w, h);
+ gtk->gdk_threads_leave();
}
/*
@@ -292,9 +307,9 @@ JNIEXPORT void JNICALL
Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting(
JNIEnv *env, jobject this, jint w, jint h)
{
- fp_gdk_threads_enter();
- gtk2_init_painting(env, w, h);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ gtk->init_painting(env, w, h);
+ gtk->gdk_threads_leave();
}
/*
@@ -308,9 +323,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting(
{
jint transparency;
gint *buffer = (gint*) (*env)->GetPrimitiveArrayCritical(env, dest, 0);
- fp_gdk_threads_enter();
- transparency = gtk2_copy_image(buffer, width, height);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ transparency = gtk->copy_image(buffer, width, height);
+ gtk->gdk_threads_leave();
(*env)->ReleasePrimitiveArrayCritical(env, dest, buffer, 0);
return transparency;
}
@@ -324,7 +339,9 @@ JNIEXPORT void JNICALL Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch
JNIEnv *env, jobject this)
{
// Note that flush_gtk_event_loop takes care of locks (7053002)
- flush_gtk_event_loop();
+ gtk->gdk_threads_enter();
+ gtk->flush_event_loop();
+ gtk->gdk_threads_leave();
}
/*
@@ -336,9 +353,9 @@ JNIEXPORT jobject JNICALL Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1get
JNIEnv *env, jobject this, jint property)
{
jobject obj;
- fp_gdk_threads_enter();
- obj = gtk2_get_setting(env, property);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ obj = gtk->get_setting(env, property);
+ gtk->gdk_threads_leave();
return obj;
}
@@ -352,7 +369,7 @@ Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeSetRangeValue(
JNIEnv *env, jobject this, jint widget_type,
jdouble value, jdouble min, jdouble max, jdouble visible)
{
- fp_gdk_threads_enter();
- gtk2_set_range_value(widget_type, value, min, max, visible);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ gtk->set_range_value(widget_type, value, min, max, visible);
+ gtk->gdk_threads_leave();
}
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKStyle.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKStyle.c
index 9d24eb44973..a977f6bee2e 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKStyle.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/swing_GTKStyle.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, 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
@@ -24,9 +24,12 @@
*/
#include
-#include "gtk2_interface.h"
+#include
+#include "gtk_interface.h"
#include "com_sun_java_swing_plaf_gtk_GTKStyle.h"
+const char *getStrFor(JNIEnv *env, jstring val);
+
/*
* Class: com_sun_java_swing_plaf_gtk_GTKStyle
* Method: nativeGetXThickness
@@ -37,9 +40,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness(
JNIEnv *env, jclass klass, jint widget_type)
{
jint ret;
- fp_gdk_threads_enter();
- ret = gtk2_get_xthickness(env, widget_type);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ ret = gtk->get_xthickness(env, widget_type);
+ gtk->gdk_threads_leave();
return ret;
}
@@ -53,9 +56,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness(
JNIEnv *env, jclass klass, jint widget_type)
{
jint ret;
- fp_gdk_threads_enter();
- ret = gtk2_get_ythickness(env, widget_type);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ ret = gtk->get_ythickness(env, widget_type);
+ gtk->gdk_threads_leave();
return ret;
}
@@ -70,9 +73,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState(
jint state_type, jint type_id)
{
jint ret;
- fp_gdk_threads_enter();
- ret = gtk2_get_color_for_state(env, widget_type, state_type, type_id);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ ret = gtk->get_color_for_state(env, widget_type, state_type, type_id);
+ gtk->gdk_threads_leave();
return ret;
}
@@ -86,9 +89,9 @@ Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue(
JNIEnv *env, jclass klass, jint widget_type, jstring key)
{
jobject ret;
- fp_gdk_threads_enter();
- ret = gtk2_get_class_value(env, widget_type, key);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ ret = gtk->get_class_value(env, widget_type, getStrFor(env, key));
+ gtk->gdk_threads_leave();
return ret;
}
@@ -102,8 +105,8 @@ Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName(
JNIEnv *env, jclass klass, jint widget_type)
{
jstring ret;
- fp_gdk_threads_enter();
- ret = gtk2_get_pango_font_name(env, widget_type);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ ret = gtk->get_pango_font_name(env, widget_type);
+ gtk->gdk_threads_leave();
return ret;
}
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c b/jdk/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c
index 733606ec444..f408b0178ea 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/java2d/x11/XRBackendNative.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, 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
@@ -72,8 +72,8 @@ typedef struct _XRadialGradient {
#include
-#if defined(__solaris__) || defined(_AIX)
-/* Solaris 10 and AIX will not have these symbols at runtime */
+#if defined(__solaris__)
+/* Solaris 10 will not have these symbols at compile time */
typedef Picture (*XRenderCreateLinearGradientFuncType)
(Display *dpy,
@@ -147,7 +147,22 @@ static jboolean IsXRenderAvailable(jboolean verbose, jboolean ignoreLinuxVersion
return JNI_FALSE;
}
-#if defined(__solaris__) || defined(_AIX)
+#if defined(_AIX)
+ // On AIX we have to use a special syntax because the shared libraries are packed in
+ // multi-architecture archives. We first try to load the system default libXrender
+ // which is contained in the 'X11.base.lib' fileset starting with AIX 6.1
+ xrenderlib = dlopen("libXrender.a(shr_64.o)", RTLD_GLOBAL | RTLD_LAZY | RTLD_MEMBER);
+ if (xrenderlib == NULL) {
+ // If the latter wasn't successful, we also try to load the version under /opt/freeware
+ // This may be downloaded from the "AIX Toolbox for Linux Applications" even for AIX 5.3
+ xrenderlib = dlopen("libXrender.a(libXrender.so.0)", RTLD_GLOBAL | RTLD_LAZY | RTLD_MEMBER);
+ }
+ if (xrenderlib != NULL) {
+ dlclose(xrenderlib);
+ } else {
+ available = JNI_FALSE;
+ }
+#elif defined(__solaris__)
xrenderlib = dlopen("libXrender.so",RTLD_GLOBAL|RTLD_LAZY);
if (xrenderlib != NULL) {
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
index 3b340914658..db32a22ec6c 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XToolkit.c
@@ -354,7 +354,6 @@ JNIEXPORT void JNICALL Java_java_awt_Dialog_initIDs (JNIEnv *env, jclass cls)
static void waitForEvents(JNIEnv *, jlong);
static void awt_pipe_init();
-static void processOneEvent(XtInputMask iMask);
static Boolean performPoll(JNIEnv *, jlong);
static void wakeUp();
static void update_poll_timeout(int timeout_control);
@@ -614,7 +613,7 @@ static uint32_t get_poll_timeout(jlong nextTaskTime)
} /* get_poll_timeout() */
/*
- * Waits for X/Xt events to appear on the pipe. Returns only when
+ * Waits for X events to appear on the pipe. Returns only when
* it is likely (but not definite) that there are events waiting to
* be processed.
*
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Desktop.c b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Desktop.c
index 0c41daee3ab..96acfb59d11 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Desktop.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Desktop.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, 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
@@ -24,7 +24,7 @@
*/
#include "jni_util.h"
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
#include "gnome_interface.h"
static gboolean gtk_has_been_loaded = FALSE;
@@ -36,14 +36,14 @@ static gboolean gnome_has_been_loaded = FALSE;
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_init
- (JNIEnv *env, jclass cls)
+ (JNIEnv *env, jclass cls, jint version, jboolean verbose)
{
if (gtk_has_been_loaded || gnome_has_been_loaded) {
return JNI_TRUE;
}
- if (gtk2_load(env) && gtk2_show_uri_load(env)) {
+ if (gtk_load(env, version, verbose) && gtk->show_uri_load(env)) {
gtk_has_been_loaded = TRUE;
return JNI_TRUE;
} else if (gnome_load()) {
@@ -74,9 +74,9 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XDesktopPeer_gnome_1url_1show
}
if (gtk_has_been_loaded) {
- fp_gdk_threads_enter();
- success = fp_gtk_show_uri(NULL, url_c, GDK_CURRENT_TIME, NULL);
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ success = gtk->gtk_show_uri(NULL, url_c, GDK_CURRENT_TIME, NULL);
+ gtk->gdk_threads_leave();
} else if (gnome_has_been_loaded) {
success = (*gnome_url_show)(url_c, NULL);
}
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c
index 643cc888b51..210f2de4da4 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.c
@@ -109,7 +109,7 @@ void callback(DbusmenuMenuitem* mi, guint ts, jobject data) {
* Signature: (Ljava/lang/String;)Z
*/
JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XTaskbarPeer_init
-(JNIEnv *env, jclass cls, jstring jname) {
+(JNIEnv *env, jclass cls, jstring jname, jint version, jboolean verbose) {
jclass clazz;
jTaskbarCls = (*env)->NewGlobalRef(env, cls);
@@ -121,7 +121,7 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XTaskbarPeer_init
CHECK_NULL_RETURN(
jMenuItemGetLabel = (*env)->GetMethodID(env, clazz, "getLabel", "()Ljava/lang/String;"), JNI_FALSE);
- if (gtk2_load(env) && unity_load()) {
+ if (gtk_load(env, version, verbose) && unity_load()) {
const gchar* name = (*env)->GetStringUTFChars(env, jname, NULL);
if (name) {
entry = fp_unity_launcher_entry_get_for_desktop_file(name);
@@ -139,9 +139,9 @@ JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XTaskbarPeer_init
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_runloop
(JNIEnv *env, jclass cls) {
- fp_gdk_threads_enter();
- fp_gtk_main();
- fp_gdk_threads_leave();
+ gtk->gdk_threads_enter();
+ gtk->gtk_main();
+ gtk->gdk_threads_leave();
}
/*
@@ -151,14 +151,14 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_runloop
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setBadge
(JNIEnv *env, jobject obj, jlong value, jboolean visible) {
- fp_gdk_threads_enter();
+ gtk->gdk_threads_enter();
fp_unity_launcher_entry_set_count(entry, value);
fp_unity_launcher_entry_set_count_visible(entry, visible);
DbusmenuMenuitem* m;
if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
fp_unity_launcher_entry_set_quicklist(entry, m);
}
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -168,13 +168,13 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setBadge
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setUrgent
(JNIEnv *env, jobject obj, jboolean urgent) {
- fp_gdk_threads_enter();
+ gtk->gdk_threads_enter();
fp_unity_launcher_entry_set_urgent(entry, urgent);
DbusmenuMenuitem* m;
if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
fp_unity_launcher_entry_set_quicklist(entry, m);
}
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
/*
@@ -184,14 +184,14 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setUrgent
*/
JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_updateProgress
(JNIEnv *env, jobject obj, jdouble value, jboolean visible) {
- fp_gdk_threads_enter();
+ gtk->gdk_threads_enter();
fp_unity_launcher_entry_set_progress(entry, value);
fp_unity_launcher_entry_set_progress_visible(entry, visible);
DbusmenuMenuitem* m;
if (m = fp_unity_launcher_entry_get_quicklist(entry)) {
fp_unity_launcher_entry_set_quicklist(entry, m);
}
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
void deleteGlobalRef(gpointer data) {
@@ -209,7 +209,7 @@ void fill_menu(JNIEnv *env, jobjectArray items) {
}
elem = (*env)->NewGlobalRef(env, elem);
- globalRefs = fp_g_list_append(globalRefs, elem);
+ globalRefs = gtk->g_list_append(globalRefs, elem);
jstring jlabel = (jstring) (*env)->CallObjectMethod(env, elem, jMenuItemGetLabel);
if (!(*env)->ExceptionCheck(env) && jlabel) {
@@ -224,7 +224,8 @@ void fill_menu(JNIEnv *env, jobjectArray items) {
(*env)->ReleaseStringUTFChars(env, jlabel, label);
fp_dbusmenu_menuitem_child_append(menu, mi);
- fp_g_signal_connect(mi, "item_activated", G_CALLBACK(callback), elem);
+ gtk->g_signal_connect_data(mi, "item_activated",
+ G_CALLBACK(callback), elem, NULL, 0);
}
}
}
@@ -238,7 +239,7 @@ void fill_menu(JNIEnv *env, jobjectArray items) {
JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setNativeMenu
(JNIEnv *env, jobject obj, jobjectArray items) {
- fp_gdk_threads_enter();
+ gtk->gdk_threads_enter();
if (!menu) {
menu = fp_dbusmenu_menuitem_new();
@@ -247,14 +248,14 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_XTaskbarPeer_setNativeMenu
fp_unity_launcher_entry_set_quicklist(entry, menu);
GList* list = fp_dbusmenu_menuitem_take_children(menu);
- fp_g_list_free_full(list, fp_g_object_unref);
+ gtk->g_list_free_full(list, gtk->g_object_unref);
- fp_g_list_free_full(globalRefs, deleteGlobalRef);
+ gtk->g_list_free_full(globalRefs, deleteGlobalRef);
globalRefs = NULL;
if (items) {
fill_menu(env, items);
}
- fp_gdk_threads_leave();
+ gtk->gdk_threads_leave();
}
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h
index 00b8d86dd1f..5baffd8e444 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/awt_Taskbar.h
@@ -26,7 +26,7 @@
#ifndef AWT_TASKBAR_H
#define AWT_TASKBAR_H
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
typedef void UnityLauncherEntry;
typedef void DbusmenuMenuitem;
diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/gnome_interface.h b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/gnome_interface.h
index 2ca444725e8..bfd764364d7 100644
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/gnome_interface.h
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/gnome_interface.h
@@ -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
@@ -25,7 +25,7 @@
#ifndef _GNOME_INTERFACE_H
#define _GNOME_INTERFACE_H
-#include "gtk2_interface.h"
+#include "gtk_interface.h"
#include
#include
#include
diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java
index 51e16b0a1f1..f07857b80b4 100644
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WComponentPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@ import java.awt.*;
import java.awt.peer.*;
import java.awt.image.VolatileImage;
import sun.awt.RepaintArea;
-import sun.awt.CausedFocusEvent;
import sun.awt.image.SunVolatileImage;
import sun.awt.image.ToolkitImage;
import java.awt.image.BufferedImage;
@@ -321,7 +320,7 @@ public abstract class WComponentPeer extends WObjectPeer
WKeyboardFocusManagerPeer.shouldFocusOnClick((Component)target))
{
WKeyboardFocusManagerPeer.requestFocusFor((Component)target,
- CausedFocusEvent.Cause.MOUSE_EVENT);
+ FocusEvent.Cause.MOUSE_EVENT);
}
break;
}
@@ -687,7 +686,7 @@ public abstract class WComponentPeer extends WObjectPeer
@Override
public boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
- CausedFocusEvent.Cause cause)
+ FocusEvent.Cause cause)
{
if (WKeyboardFocusManagerPeer.
processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java
index 383254b815a..40c995def1d 100644
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
package sun.awt.windows;
import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
import java.awt.dnd.DropTarget;
import java.awt.peer.*;
import java.io.File;
@@ -34,7 +35,6 @@ import java.security.PrivilegedAction;
import java.util.ResourceBundle;
import java.util.MissingResourceException;
import java.util.Vector;
-import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
@@ -282,7 +282,7 @@ final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
@Override
public boolean requestFocus
(Component lightweightChild, boolean temporary,
- boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
+ boolean focusedWindowChangeAllowed, long time, Cause cause)
{
return false;
}
diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java
index a475328881a..f11409d4aca 100644
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WKeyboardFocusManagerPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@ import java.awt.peer.ComponentPeer;
import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.ComponentAccessor;
import sun.awt.KeyboardFocusManagerPeerImpl;
-import sun.awt.CausedFocusEvent;
+import java.awt.event.FocusEvent.Cause;
final class WKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
static native void setNativeFocusOwner(ComponentPeer peer);
@@ -75,7 +75,7 @@ final class WKeyboardFocusManagerPeer extends KeyboardFocusManagerPeerImpl {
boolean temporary,
boolean focusedWindowChangeAllowed,
long time,
- CausedFocusEvent.Cause cause)
+ Cause cause)
{
// TODO: do something to eliminate this forwarding
return KeyboardFocusManagerPeerImpl.deliverFocus(lightweightChild,
diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java
index a80e7dd6d13..d4ae0eb491e 100644
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,11 +26,11 @@
package sun.awt.windows;
import java.awt.*;
+import java.awt.event.FocusEvent.Cause;
import java.awt.peer.DialogPeer;
import java.awt.peer.ComponentPeer;
import java.awt.dnd.DropTarget;
import java.util.Vector;
-import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
@@ -153,7 +153,7 @@ class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
@Override
public boolean requestFocus
(Component lightweightChild, boolean temporary,
- boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
+ boolean focusedWindowChangeAllowed, long time, Cause cause)
{
return false;
diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java
index 12885ad2a61..2e8e81262d4 100644
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WWindowPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -300,11 +300,11 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
return getNativeWindowSize();
}
- public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
+ public boolean requestWindowFocus(FocusEvent.Cause cause) {
if (!focusAllowedFor()) {
return false;
}
- return requestWindowFocus(cause == CausedFocusEvent.Cause.MOUSE_EVENT);
+ return requestWindowFocus(cause == FocusEvent.Cause.MOUSE_EVENT);
}
private native boolean requestWindowFocus(boolean isMouseEventCause);
diff --git a/jdk/src/java.desktop/windows/native/libfontmanager/lcdglyph.c b/jdk/src/java.desktop/windows/native/libfontmanager/lcdglyph.c
index 05f4aae9d82..d940e8cb468 100644
--- a/jdk/src/java.desktop/windows/native/libfontmanager/lcdglyph.c
+++ b/jdk/src/java.desktop/windows/native/libfontmanager/lcdglyph.c
@@ -157,6 +157,9 @@ JNIEXPORT jboolean JNICALL
if (hBitmap != 0) { \
DeleteObject(hBitmap); \
} \
+ if (tmpBitmap != 0) { \
+ DeleteObject(tmpBitmap); \
+ } \
if (dibImage != NULL) { \
free(dibImage); \
} \
@@ -196,6 +199,7 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
int bmWidth, bmHeight;
int x, y;
HBITMAP hBitmap = NULL, hOrigBM;
+ HBITMAP tmpBitmap = NULL;
int gamma, orient;
HWND hWnd = NULL;
@@ -250,6 +254,12 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
}
oldFont = SelectObject(hMemoryDC, hFont);
+ tmpBitmap = CreateCompatibleBitmap(hDesktopDC, 1, 1);
+ if (tmpBitmap == NULL) {
+ FREE_AND_RETURN;
+ }
+ hOrigBM = (HBITMAP)SelectObject(hMemoryDC, tmpBitmap);
+
memset(&textMetric, 0, sizeof(TEXTMETRIC));
err = GetTextMetrics(hMemoryDC, &textMetric);
if (err == 0) {
@@ -334,7 +344,7 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
if (hBitmap == NULL) {
FREE_AND_RETURN;
}
- hOrigBM = (HBITMAP)SelectObject(hMemoryDC, hBitmap);
+ SelectObject(hMemoryDC, hBitmap);
/* Fill in black */
rect.left = 0;
@@ -478,6 +488,7 @@ Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
ReleaseDC(hWnd, hDesktopDC);
DeleteObject(hMemoryDC);
DeleteObject(hBitmap);
+ DeleteObject(tmpBitmap);
return ptr_to_jlong(glyphInfo);
}
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncConnection.java b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncConnection.java
new file mode 100644
index 00000000000..8818823af30
--- /dev/null
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncConnection.java
@@ -0,0 +1,68 @@
+/*
+ * 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
+ * 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
+ */
+package java.net.http;
+
+import java.nio.ByteBuffer;
+import java.util.function.Consumer;
+
+/**
+ * Implemented by classes that offer an asynchronous interface.
+ *
+ * PlainHttpConnection, AsyncSSLConnection AsyncSSLDelegate.
+ *
+ * setAsyncCallbacks() is called to set the callback for reading
+ * and error notification. Reads all happen on the selector thread, which
+ * must not block.
+ *
+ * Writing uses the same write() methods as used in blocking mode.
+ * Queues are employed on the writing side to buffer data while it is waiting
+ * to be sent. This strategy relies on HTTP/2 protocol flow control to stop
+ * outgoing queue from continually growing. Writes can be initiated by the
+ * calling thread, but if socket becomes full then the queue is emptied by
+ * the selector thread
+ *
+ */
+interface AsyncConnection {
+
+ /**
+ * Enables asynchronous sending and receiving mode. The given async
+ * receiver will receive all incoming data. asyncInput() will be called
+ * to trigger reads. asyncOutput() will be called to drive writes.
+ *
+ * The errorReceiver callback must be called when any fatal exception
+ * occurs. Connection is assumed to be closed afterwards.
+ *
+ * @param asyncReceiver
+ * @param errorReceiver
+ */
+ void setAsyncCallbacks(
+ Consumer asyncReceiver,
+ Consumer errorReceiver);
+
+ /**
+ * Does whatever is required to start reading. Usually registers
+ * an event with the selector thread.
+ */
+ void startReading();
+}
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncEvent.java b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncEvent.java
index 1cd606fe7a5..b6284398189 100644
--- a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncEvent.java
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncEvent.java
@@ -25,24 +25,27 @@
package java.net.http;
import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.SocketChannel;
/**
* Event handling interface from HttpClientImpl's selector.
*
- * If blockingChannel is true, then the channel will be put in blocking
+ * If BLOCKING is set, then the channel will be put in blocking
* mode prior to handle() being called. If false, then it remains non-blocking.
+ *
+ * If REPEATING is set then the event is not cancelled after being posted.
*/
abstract class AsyncEvent {
- /**
- * Implement this if channel should be made blocking before calling handle()
- */
- public interface Blocking { }
+ public static final int BLOCKING = 0x1; // non blocking if not set
+ public static final int REPEATING = 0x2; // one off event if not set
- /**
- * Implement this if channel should remain non-blocking before calling handle()
- */
- public interface NonBlocking { }
+ protected final int flags;
+
+ AsyncEvent(int flags) {
+ this.flags = flags;
+ }
/** Returns the channel */
public abstract SelectableChannel channel();
@@ -55,4 +58,12 @@ abstract class AsyncEvent {
/** Called when selector is shutting down. Abort all exchanges. */
public abstract void abort();
+
+ public boolean blocking() {
+ return (flags & BLOCKING) != 0;
+ }
+
+ public boolean repeating() {
+ return (flags & REPEATING) != 0;
+ }
}
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLConnection.java b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLConnection.java
new file mode 100644
index 00000000000..3dcd2d4933f
--- /dev/null
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLConnection.java
@@ -0,0 +1,129 @@
+/*
+ * 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
+ * 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
+ */
+package java.net.http;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.SocketChannel;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.Consumer;
+
+/**
+ * Asynchronous version of SSLConnection.
+ */
+class AsyncSSLConnection extends HttpConnection implements AsyncConnection {
+ final AsyncSSLDelegate sslDelegate;
+ final PlainHttpConnection delegate;
+
+ AsyncSSLConnection(InetSocketAddress addr, HttpClientImpl client, String[] ap) {
+ super(addr, client);
+ delegate = new PlainHttpConnection(addr, client);
+ sslDelegate = new AsyncSSLDelegate(delegate, client, ap);
+ }
+
+ @Override
+ public void connect() throws IOException, InterruptedException {
+ delegate.connect();
+ }
+
+ @Override
+ public CompletableFuture connectAsync() {
+ return delegate.connectAsync();
+ }
+
+ @Override
+ boolean connected() {
+ return delegate.connected();
+ }
+
+ @Override
+ boolean isSecure() {
+ return true;
+ }
+
+ @Override
+ boolean isProxied() {
+ return false;
+ }
+
+ @Override
+ SocketChannel channel() {
+ return delegate.channel();
+ }
+
+ @Override
+ ConnectionPool.CacheKey cacheKey() {
+ return ConnectionPool.cacheKey(address, null);
+ }
+
+ @Override
+ synchronized long write(ByteBuffer[] buffers, int start, int number) throws IOException {
+ ByteBuffer[] bufs = Utils.reduce(buffers, start, number);
+ long n = Utils.remaining(bufs);
+ sslDelegate.write(bufs);
+ return n;
+ }
+
+ @Override
+ long write(ByteBuffer buffer) throws IOException {
+ long n = buffer.remaining();
+ sslDelegate.write(buffer);
+ return n;
+ }
+
+ @Override
+ public void close() {
+ Utils.close(sslDelegate, delegate.channel());
+ }
+
+ @Override
+ public void setAsyncCallbacks(Consumer asyncReceiver, Consumer errorReceiver) {
+ sslDelegate.setAsyncCallbacks(asyncReceiver, errorReceiver);
+ delegate.setAsyncCallbacks(sslDelegate::lowerRead, errorReceiver);
+ }
+
+ // Blocking read functions not used here
+
+ @Override
+ protected ByteBuffer readImpl(int length) throws IOException {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
+ @Override
+ protected int readImpl(ByteBuffer buffer) throws IOException {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
+ @Override
+ CompletableFuture whenReceivingResponse() {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+
+ @Override
+ public void startReading() {
+ delegate.startReading();
+ sslDelegate.startReading();
+ }
+}
diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java
new file mode 100644
index 00000000000..217bd7d16ea
--- /dev/null
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java
@@ -0,0 +1,598 @@
+/*
+ * 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
+ * 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
+ */
+package java.net.http;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.concurrent.ExecutorService;
+import java.util.function.Consumer;
+import static javax.net.ssl.SSLEngineResult.Status.*;
+import javax.net.ssl.*;
+import static javax.net.ssl.SSLEngineResult.HandshakeStatus.*;
+
+/**
+ * Asynchronous wrapper around SSLEngine. send and receive is fully non
+ * blocking. When handshaking is required, a thread is created to perform
+ * the handshake and application level sends do not take place during this time.
+ *
+ * Is implemented using queues and functions operating on the receiving end
+ * of each queue.
+ *
+ * Application writes to:
+ * ||
+ * \/
+ * appOutputQ
+ * ||
+ * \/
+ * appOutputQ read by "upperWrite" method which does SSLEngine.wrap
+ * and writes to
+ * ||
+ * \/
+ * channelOutputQ
+ * ||
+ * \/
+ * channelOutputQ is read by "lowerWrite" method which is invoked from
+ * OP_WRITE events on the socket (from selector thread)
+ *
+ * Reading side is as follows
+ * --------------------------
+ *
+ * "upperRead" method reads off channelInputQ and calls SSLEngine.unwrap and
+ * when decrypted data is returned, it is passed to the user's Consumer