This commit is contained in:
Jesper Wilhelmsson 2016-02-11 21:07:37 +01:00
commit 6939cb3b60
1943 changed files with 223081 additions and 22459 deletions

View File

@ -345,3 +345,4 @@ f9bcdce2df26678c3fe468130b535c0342c69b89 jdk-9+99
4379223f8806626852c46c52d4e7a27a584b406e jdk-9+100
80f67512daa15cf37b4825c1c62a675d524d7c49 jdk-9+101
2dc4c11fe48831854916d53c3913bdb7d49023ea jdk-9+102
4a652e4ca9523422149958673033e0ac740d5e1e jdk-9+103

View File

@ -345,3 +345,4 @@ cf1dc4c035fb84693d4ae5ad818785cb4d1465d1 jdk9-b90
c1f30ac14db0eaff398429c04cd9fab92e1b4b2a jdk-9+100
c4d72a1620835b5d657b7b6792c2879367d0154f jdk-9+101
6406ecf5d39482623225bb1b3098c2cac6f7d450 jdk-9+102
47d6462e514b2097663305a57d9c844c15d5b609 jdk-9+103

File diff suppressed because it is too large Load Diff

View File

@ -266,14 +266,3 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_BUILD_TWEAKS],
HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET"
AC_SUBST(HOTSPOT_MAKE_ARGS)
])
# -g is already added by ENABLE_DEBUG_SYMBOLS and the hotspot makefiles
# will basically do slowdebug builds when DEBUG_BINARIES is set for
# fastdebug builds
DEBUG_BINARIES=false
# Fastdebug builds with this setting will essentially be slowdebug
# in hotspot.
# -g is already added by ENABLE_DEBUG_SYMBOLS and the hotspot makefiles
# will basically do slowdebug builds when DEBUG_BINARIES is set for
# fastdebug builds
DEBUG_BINARIES=false

View File

@ -144,6 +144,10 @@ AC_DEFUN_ONCE([LIB_SETUP_LLVM],
fi
done
# Due to https://llvm.org/bugs/show_bug.cgi?id=16902, llvm does not
# always properly detect -ltinfo
LLVM_LIBS="${LLVM_LIBS} -ltinfo"
AC_SUBST(LLVM_CFLAGS)
AC_SUBST(LLVM_LDFLAGS)
AC_SUBST(LLVM_LIBS)

View File

@ -500,7 +500,7 @@ JAVAC_FLAGS?=@JAVAC_FLAGS@
INTERIM_LANGTOOLS_JAR = $(BUILDTOOLS_OUTPUTDIR)/interim_langtools.jar
INTERIM_LANGTOOLS_ARGS = "-Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR)" -cp $(INTERIM_LANGTOOLS_JAR)
NEW_JAVAC = $(INTERIM_LANGTOOLS_ARGS) com.sun.tools.javac.Main
NEW_JAVADOC = $(INTERIM_LANGTOOLS_ARGS) com.sun.tools.javadoc.Main
NEW_JAVADOC = $(INTERIM_LANGTOOLS_ARGS) jdk.javadoc.internal.tool.Main
# Base flags for RC
# Guarding this against resetting value. Legacy make files include spec multiple

View File

@ -433,39 +433,22 @@ AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
# Now we have a compiler binary in $1. Make sure it's okay.
BASIC_FIXUP_EXECUTABLE($1)
TEST_COMPILER="[$]$1"
# Don't remove symbolic links on AIX because 'xlc_r' and 'xlC_r' may all be links
# to 'xlc' but it is crucial that we invoke the compiler with the right name!
if test "x$OPENJDK_BUILD_OS" != xaix; then
# FIXME: This test should not be needed anymore; we don't do that for any platform.
AC_MSG_CHECKING([resolved symbolic links for $1])
BASIC_REMOVE_SYMBOLIC_LINKS(TEST_COMPILER)
AC_MSG_RESULT([$TEST_COMPILER])
fi
AC_MSG_CHECKING([if $1 is disguised ccache])
COMPILER_BASENAME=`$BASENAME "$TEST_COMPILER"`
if test "x$COMPILER_BASENAME" = "xccache"; then
AC_MSG_RESULT([yes, trying to find proper $COMPILER_NAME compiler])
# We /usr/lib/ccache in the path, so cc is a symlink to /usr/bin/ccache.
# We want to control ccache invocation ourselves, so ignore this cc and try
# searching again.
# Remove the path to the fake ccache cc from the PATH
RETRY_COMPILER_SAVED_PATH="$PATH"
COMPILER_DIRNAME=`$DIRNAME [$]$1`
PATH="`$ECHO $PATH | $SED -e "s,$COMPILER_DIRNAME,,g" -e "s,::,:,g" -e "s,^:,,g"`"
# Try again looking for our compiler
AC_CHECK_TOOLS(PROPER_COMPILER_$1, $3)
BASIC_FIXUP_EXECUTABLE(PROPER_COMPILER_$1)
PATH="$RETRY_COMPILER_SAVED_PATH"
AC_MSG_CHECKING([for resolved symbolic links for $1])
BASIC_REMOVE_SYMBOLIC_LINKS(PROPER_COMPILER_$1)
AC_MSG_RESULT([$PROPER_COMPILER_$1])
$1="$PROPER_COMPILER_$1"
AC_MSG_CHECKING([resolved symbolic links for $1])
SYMLINK_ORIGINAL="$TEST_COMPILER"
BASIC_REMOVE_SYMBOLIC_LINKS(SYMLINK_ORIGINAL)
if test "x$TEST_COMPILER" = "x$SYMLINK_ORIGINAL"; then
AC_MSG_RESULT([no symlink])
else
AC_MSG_RESULT([no, keeping $1])
AC_MSG_RESULT([$SYMLINK_ORIGINAL])
# We can't handle ccache by gcc wrappers, since we need to know if we're
# using ccache. Instead ccache usage must be controlled by a configure option.
COMPILER_BASENAME=`$BASENAME "$SYMLINK_ORIGINAL"`
if test "x$COMPILER_BASENAME" = "xccache"; then
AC_MSG_NOTICE([Please use --enable-ccache instead of providing a wrapped compiler.])
AC_MSG_ERROR([$TEST_COMPILER is a symbolic link to ccache. This is not supported.])
fi
fi
TOOLCHAIN_CHECK_COMPILER_VERSION([$1], [$COMPILER_NAME])

View File

@ -306,7 +306,7 @@ compare_general_files() {
! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" \
! -name "*.obj" ! -name "*.o" ! -name "JavaControlPanelHelper" \
! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \
! -name "jspawnhelper" \
! -name "jspawnhelper" ! -name "*.a" \
| $GREP -v "./bin/" | $SORT | $FILTER)
echo Other files with binary differences...
@ -939,7 +939,7 @@ compare_all_libs() {
WORK_DIR=$3
LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' \
-o -name '*.dll' -o -name '*.obj' -o -name '*.o' \
-o -name '*.dll' -o -name '*.obj' -o -name '*.o' -o -name '*.a' \
-o -name '*.cpl' \) | $SORT | $FILTER)
if [ -n "$LIBS" ]; then

View File

@ -345,3 +345,4 @@ ea285530245cf4e0edf0479121a41347d3030eba jdk-9+98
791d0d3ac0138faeb6110bd840a4545bc1950df2 jdk-9+100
30dfb3bd3d06b4bb80a087babc0d1841edba187b jdk-9+101
9c4662334d933d299928d1f599d02ff50777cbf8 jdk-9+102
0680fb7dae4da1ee6cf783c4b74184e3e08d3179 jdk-9+103

View File

@ -505,3 +505,4 @@ f008e8cc10d5b3212fb22d58c96fa01d38654f19 jdk-9+99
bdb0acafc63c42e84d9d8195bf2e2b25ee9c3306 jdk-9+100
9f45d3d57d6948cf526fbc2e2891a9a74ac6941a jdk-9+101
d5239fc1b69749ae50793c61b899fcdacf3df857 jdk-9+102
c5f55130b1b69510d9a6f4a3105b58e21cd7ffe1 jdk-9+103

View File

@ -64,14 +64,18 @@ public class TestPerfCountersAndMemoryPools {
throws Exception {
MemoryPoolMXBean pool = getMemoryPool(memoryPoolName);
// First, call all the methods to let them allocate their own slab of metadata
getMinCapacity(perfNS);
getCapacity(perfNS);
getUsed(perfNS);
pool.getUsage().getInit();
pool.getUsage().getUsed();
pool.getUsage().getCommitted();
assertEQ(1L, 1L);
// Must do a GC to update performance counters
System.gc();
assertEQ(getMinCapacity(perfNS), pool.getUsage().getInit());
// Must do a second GC to update the perfomance counters again, since
// the call pool.getUsage().getInit() could have allocated some
// metadata.
System.gc();
assertEQ(getUsed(perfNS), pool.getUsage().getUsed());
assertEQ(getCapacity(perfNS), pool.getUsage().getCommitted());
}

View File

@ -345,3 +345,4 @@ c8d0845877a811ab4350935892f826929359a3ff jdk-9+95
d45bcd374f6057851e3c2dcd45607cd362afadfa jdk-9+100
d3e834ff74e724a2b92a558e18e8cbf81c6dbc59 jdk-9+101
9dcf193c0b6cf22c0e89e2dc705a2c0f520ae064 jdk-9+102
bdbf2342b21bd8ecad1b4e6499a0dfb314952bd7 jdk-9+103

View File

@ -348,3 +348,4 @@ b55cebc47555293cf9c2aefb3bf63c56e847ab19 jdk-9+96
d0a97e57d2336238edf6a4cd60aafe67deb7258d jdk-9+100
3e99318616da903e0dc8f07f9f9203dc1bd49921 jdk-9+101
0868b93587cc99df3a4f4d3817a1aa756bea60ab jdk-9+102
eb5e005a17e50d7d8340daaf21a5c3c5ae358d68 jdk-9+103

View File

@ -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
@ -29,11 +29,12 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
@ -105,9 +106,9 @@ class ContextFinder {
/**
* If the {@link InvocationTargetException} wraps an exception that shouldn't be wrapped,
* throw the wrapped exception.
* throw the wrapped exception. Otherwise returns exception to be wrapped for further processing.
*/
private static void handleInvocationTargetException(InvocationTargetException x) throws JAXBException {
private static Throwable handleInvocationTargetException(InvocationTargetException x) throws JAXBException {
Throwable t = x.getTargetException();
if (t != null) {
if (t instanceof JAXBException)
@ -118,7 +119,9 @@ class ContextFinder {
throw (RuntimeException) t;
if (t instanceof Error)
throw (Error) t;
return t;
}
return x;
}
@ -157,9 +160,10 @@ class ContextFinder {
} catch (ClassNotFoundException x) {
throw new JAXBException(Messages.format(Messages.PROVIDER_NOT_FOUND, className), x);
} catch (RuntimeException x) {
} catch (RuntimeException | JAXBException x) {
// avoid wrapping RuntimeException to JAXBException,
// because it indicates a bug in this code.
// JAXBException re-thrown as is
throw x;
} catch (Exception x) {
// can't catch JAXBException because the method is hidden behind
@ -189,8 +193,9 @@ class ContextFinder {
try {
Method m = spFactory.getMethod("createContext", String.class, ClassLoader.class, Map.class);
// any failure in invoking this method would be considered fatal
context = m.invoke(null, contextPath, classLoader, properties);
} catch (NoSuchMethodException e) {
Object obj = instantiateProviderIfNecessary(m);
context = m.invoke(obj, contextPath, classLoader, properties);
} catch (NoSuchMethodException ignored) {
// it's not an error for the provider not to have this method.
}
@ -198,8 +203,9 @@ class ContextFinder {
// try the old method that doesn't take properties. compatible with 1.0.
// it is an error for an implementation not to have both forms of the createContext method.
Method m = spFactory.getMethod("createContext", String.class, ClassLoader.class);
Object obj = instantiateProviderIfNecessary(m);
// any failure in invoking this method would be considered fatal
context = m.invoke(null, contextPath, classLoader);
context = m.invoke(obj, contextPath, classLoader);
}
if (!(context instanceof JAXBContext)) {
@ -208,18 +214,11 @@ class ContextFinder {
}
return (JAXBContext) context;
} catch (InvocationTargetException x) {
handleInvocationTargetException(x);
// for other exceptions, wrap the internal target exception
// with a JAXBException
Throwable e = x;
if (x.getTargetException() != null)
e = x.getTargetException();
// throw if it is exception not to be wrapped
// otherwise, wrap with a JAXBException
Throwable e = handleInvocationTargetException(x);
throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, spFactory, e), e);
} catch (RuntimeException x) {
// avoid wrapping RuntimeException to JAXBException,
// because it indicates a bug in this code.
throw x;
} catch (Exception x) {
// can't catch JAXBException because the method is hidden behind
// reflection. Root element collisions detected in the call to
@ -229,6 +228,23 @@ class ContextFinder {
}
}
private static Object instantiateProviderIfNecessary(Method m) throws JAXBException {
Class<?> declaringClass = m.getDeclaringClass();
try {
if (JAXBContextFactory.class.isAssignableFrom(declaringClass)) {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws Exception {
return declaringClass.newInstance();
}
});
}
return null;
} catch (PrivilegedActionException e) {
throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, declaringClass, e), e);
}
}
/**
* Create an instance of a class using the thread context ClassLoader
*/
@ -255,7 +271,8 @@ class ContextFinder {
try {
Method m = spFactory.getMethod("createContext", Class[].class, Map.class);
Object context = m.invoke(null, classes, properties);
Object obj = instantiateProviderIfNecessary(m);
Object context = m.invoke(obj, classes, properties);
if (!(context instanceof JAXBContext)) {
// the cast would fail, so generate an exception with a nice message
throw handleClassCastException(context.getClass(), JAXBContext.class);
@ -264,13 +281,10 @@ class ContextFinder {
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new JAXBException(e);
} catch (InvocationTargetException e) {
handleInvocationTargetException(e);
Throwable x = e;
if (e.getTargetException() != null)
x = e.getTargetException();
// throw if it is exception not to be wrapped
// otherwise, wrap with a JAXBException
Throwable x = handleInvocationTargetException(e);
throw new JAXBException(x);
}

View File

@ -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
@ -94,7 +94,7 @@ import java.io.InputStream;
* allows the merging of global elements and type definitions across a set of schemas (listed
* in the {@code contextPath}). Since each schema in the schema set can belong
* to distinct namespaces, the unification of schemas to an unmarshalling
* context should be namespace independent. This means that a client
* context must be namespace independent. This means that a client
* application is able to unmarshal XML documents that are instances of
* any of the schemas listed in the {@code contextPath}. For example:
*
@ -200,21 +200,28 @@ import java.io.InputStream;
*
* <h3>Discovery of JAXB implementation</h3>
* <p>
* When one of the {@code newInstance} methods is called, a JAXB implementation is discovered
* by the following steps.
* To create an instance of {@link JAXBContext}, one of {@code JAXBContext.newInstance(...)} methods is invoked. After
* JAX-B implementation is discovered, call is delegated to appropriate provider's method {@code createContext(...)}
* passing parameters from the original call.
* <p>
* JAX-B implementation discovery happens each time {@code JAXBContext.newInstance} is invoked. If there is no user
* specific configuration provided, default JAX-B provider must be returned.
* <p>
* Implementation discovery consists of following steps:
*
* <ol>
*
* <li>
* For each package/class explicitly passed in to the {@link #newInstance} method, in the order they are specified,
* {@code jaxb.properties} file is looked up in its package, by using the associated classloader &mdash;
* Packages/classes explicitly passed in to the {@link #newInstance} method are processed in the order they are
* specified, until {@code jaxb.properties} file is looked up in its package, by using the associated classloader &mdash;
* this is {@link Class#getClassLoader() the owner class loader} for a {@link Class} argument, and for a package
* the specified {@link ClassLoader}.
*
* <p>
* If such a file is discovered, it is {@link Properties#load(InputStream) loaded} as a property file, and
* the value of the {@link #JAXB_CONTEXT_FACTORY} key will be assumed to be the provider factory class.
* This class is then loaded by the associated class loader discussed above.
* If such a resource is discovered, it is {@link Properties#load(InputStream) loaded} as a property file, and
* the value of the {@link #JAXB_CONTEXT_FACTORY} key will be assumed to be the provider factory class. If no value
* found, {@code "javax.xml.bind.context.factory"} is used as a key for backwards compatibility reasons. This class is
* then loaded by the associated class loader discussed above.
*
* <p>
* This phase of the look up allows some packages to force the use of a certain JAXB implementation.
@ -222,7 +229,9 @@ import java.io.InputStream;
*
* <li>
* If the system property {@link #JAXB_CONTEXT_FACTORY} exists, then its value is assumed to be the provider
* factory class. This phase of the look up enables per-JVM override of the JAXB implementation.
* factory class. If no such property exists, properties {@code "javax.xml.bind.context.factory"} and
* {@code "javax.xml.bind.JAXBContext"} are checked too (in this order), for backwards compatibility reasons. This phase
* of the look up enables per-JVM override of the JAXB implementation.
*
* <li>
* Provider of {@link javax.xml.bind.JAXBContextFactory} is loaded using the service-provider loading
@ -235,43 +244,58 @@ import java.io.InputStream;
* <br>
* In case of {@link java.util.ServiceConfigurationError service
* configuration error} a {@link javax.xml.bind.JAXBException} will be thrown.
* </li>
*
* <li>
* Look for resource {@code /META-INF/services/javax.xml.bind.JAXBContext} using provided class loader.
* Methods without class loader parameter use {@code Thread.currentThread().getContextClassLoader()}.
* If such a resource exists, its content is assumed to be the provider factory class and must supply
* an implementation class containing the following method signatures:
* If such a resource exists, its content is assumed to be the provider factory class.
*
* <pre>
*
* public static JAXBContext createContext(
* String contextPath,
* ClassLoader classLoader,
* Map&lt;String,Object&gt; properties throws JAXBException
*
* public static JAXBContext createContext(
* Class[] classes,
* Map&lt;String,Object&gt; properties ) throws JAXBException
* </pre>
* This configuration method is deprecated.
*
* <li>
* Finally, if all the steps above fail, then the rest of the look up is unspecified. That said,
* the recommended behavior is to simply look for some hard-coded platform default JAXB implementation.
* This phase of the look up is so that JavaSE can have its own JAXB implementation as the last resort.
* This phase of the look up is so that Java SE can have its own JAXB implementation as the last resort.
* </ol>
*
* <p>
* Once the provider factory class {@link javax.xml.bind.JAXBContextFactory} is discovered, one of its methods
* {@link javax.xml.bind.JAXBContextFactory#createContext(String, ClassLoader, java.util.Map)} or
* {@link javax.xml.bind.JAXBContextFactory#createContext(Class[], java.util.Map)} is invoked
* to create a {@link JAXBContext}.
* Once the provider factory class is discovered, context creation is delegated to one of its
* {@code createContext(...)} methods.
*
* For backward compatibility reasons, there are two ways how to implement provider factory class:
* <ol>
* <li>the class is implementation of {@link javax.xml.bind.JAXBContextFactory}. It must also implement no-arg
* constructor. If discovered in other step then 3, new instance using no-arg constructor is created first.
* After that, appropriate instance method is invoked on this instance.
* <li>the class is not implementation of interface above and then it is mandated to implement the following
* static method signatures:
* <pre>
*
* public static JAXBContext createContext(
* String contextPath,
* ClassLoader classLoader,
* Map&lt;String,Object&gt; properties ) throws JAXBException
*
* public static JAXBContext createContext(
* Class[] classes,
* Map&lt;String,Object&gt; properties ) throws JAXBException
* </pre>
* In this scenario, appropriate static method is used instead of instance method. This approach is incompatible
* with {@link java.util.ServiceLoader} so it can't be used with step 3.
* </ol>
* <p>
* There is no difference in behavior of given method {@code createContext(...)} regardless of whether it uses approach
* 1 (JAXBContextFactory) or 2 (no interface, static methods).
*
* @apiNote
* <p>Service discovery method using file /META-INF/services/javax.xml.bind.JAXBContext (described in step 4)
* and leveraging provider's static methods is supported only to allow backwards compatibility, but it is strongly
* recommended to migrate to standard ServiceLoader mechanism (described in step 3).
* Service discovery method using resource {@code /META-INF/services/javax.xml.bind.JAXBContext} (described in step 4)
* is supported only to allow backwards compatibility, it is strongly recommended to migrate to standard
* {@link java.util.ServiceLoader} mechanism (described in step 3). The difference here is the resource name, which
* doesn't match service's type name.
* <p>
* Also using providers implementing interface {@link JAXBContextFactory} is preferred over using ones defining
* static methods, same as {@link JAXBContext#JAXB_CONTEXT_FACTORY} property is preferred over property
* {@code "javax.xml.bind.context.factory"}
*
* @implNote
* Within the last step, if Glassfish AS environment detected, its specific service loader is used to find factory class.
@ -308,16 +332,10 @@ public abstract class JAXBContext {
* the context class loader of the current thread.
*
* @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext} such as
* <ol>
* <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
* <li>an ambiguity among global elements contained in the contextPath</li>
* <li>failure to locate a value for the context factory provider property</li>
* <li>mixing schema derived packages from different providers on the same contextPath</li>
* </ol>
* {@code JAXBContext}. See {@link JAXBContext#newInstance(String, ClassLoader, Map)} for details.
*/
public static JAXBContext newInstance( String contextPath )
throws JAXBException {
throws JAXBException {
//return newInstance( contextPath, JAXBContext.class.getClassLoader() );
return newInstance( contextPath, getContextClassLoader());
@ -405,13 +423,7 @@ public abstract class JAXBContext {
*
* @return a new instance of a {@code JAXBContext}
* @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext} such as
* <ol>
* <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
* <li>an ambiguity among global elements contained in the contextPath</li>
* <li>failure to locate a value for the context factory provider property</li>
* <li>mixing schema derived packages from different providers on the same contextPath</li>
* </ol>
* {@code JAXBContext}. See {@link JAXBContext#newInstance(String, ClassLoader, Map)} for details.
*/
public static JAXBContext newInstance( String contextPath, ClassLoader classLoader ) throws JAXBException {
@ -427,7 +439,7 @@ public abstract class JAXBContext {
* the instantiation of {@link JAXBContext}.
*
* <p>
* The interpretation of properties is up to implementations. Implementations should
* The interpretation of properties is up to implementations. Implementations must
* throw {@code JAXBException} if it finds properties that it doesn't understand.
*
* @param contextPath list of java package names that contain schema derived classes
@ -439,13 +451,7 @@ public abstract class JAXBContext {
*
* @return a new instance of a {@code JAXBContext}
* @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext} such as
* <ol>
* <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
* <li>an ambiguity among global elements contained in the contextPath</li>
* <li>failure to locate a value for the context factory provider property</li>
* <li>mixing schema derived packages from different providers on the same contextPath</li>
* </ol>
* {@code JAXBContext}. See {@link #newInstance(String, ClassLoader)} for details.
* @since 1.6, JAXB 2.0
*/
public static JAXBContext newInstance( String contextPath,
@ -454,14 +460,14 @@ public abstract class JAXBContext {
return ContextFinder.find(
/* The default property name according to the JAXB spec */
JAXB_CONTEXT_FACTORY,
JAXB_CONTEXT_FACTORY,
/* the context path supplied by the client app */
contextPath,
contextPath,
/* class loader to be used */
classLoader,
properties );
classLoader,
properties );
}
// TODO: resurrect this once we introduce external annotations
@ -583,17 +589,8 @@ public abstract class JAXBContext {
* @return
* A new instance of a {@code JAXBContext}.
*
* @throws JAXBException
* if an error was encountered while creating the
* {@code JAXBContext}, such as (but not limited to):
* <ol>
* <li>No JAXB implementation was discovered
* <li>Classes use JAXB annotations incorrectly
* <li>Classes have colliding annotations (i.e., two classes with the same type name)
* <li>The JAXB implementation was unable to locate
* provider-specific out-of-band information (such as additional
* files generated at the development time.)
* </ol>
* @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext}. See {@link JAXBContext#newInstance(Class[], Map)} for details.
*
* @throws IllegalArgumentException
* if the parameter contains {@code null} (i.e., {@code newInstance(null);})
@ -601,7 +598,7 @@ public abstract class JAXBContext {
* @since 1.6, JAXB 2.0
*/
public static JAXBContext newInstance( Class<?> ... classesToBeBound )
throws JAXBException {
throws JAXBException {
return newInstance(classesToBeBound,Collections.<String,Object>emptyMap());
}
@ -614,7 +611,7 @@ public abstract class JAXBContext {
* to configure 'properties' for this instantiation of {@link JAXBContext}.
*
* <p>
* The interpretation of properties is up to implementations. Implementations should
* The interpretation of properties is up to implementations. Implementations must
* throw {@code JAXBException} if it finds properties that it doesn't understand.
*
* @param classesToBeBound
@ -646,10 +643,10 @@ public abstract class JAXBContext {
* @since 1.6, JAXB 2.0
*/
public static JAXBContext newInstance( Class<?>[] classesToBeBound, Map<String,?> properties )
throws JAXBException {
throws JAXBException {
if (classesToBeBound == null) {
throw new IllegalArgumentException();
throw new IllegalArgumentException();
}
// but it is an error to have nulls in it.

View File

@ -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
@ -56,14 +56,7 @@ public interface JAXBContextFactory {
*
* @throws JAXBException
* if an error was encountered while creating the
* {@code JAXBContext}, such as (but not limited to):
* <ol>
* <li>Classes use JAXB annotations incorrectly
* <li>Classes have colliding annotations (i.e., two classes with the same type name)
* <li>The JAXB implementation was unable to locate
* provider-specific out-of-band information (such as additional
* files generated at the development time.)
* </ol>
* {@code JAXBContext}. See {@link JAXBContext#newInstance(Class[], Map)} for details.
*
* @throws IllegalArgumentException
* if the parameter contains {@code null} (i.e., {@code newInstance(null,someMap);})
@ -81,7 +74,7 @@ public interface JAXBContextFactory {
* For semantics see {@link javax.xml.bind.JAXBContext#newInstance(String, ClassLoader, java.util.Map)}
*
* <p>
* The interpretation of properties is up to implementations. Implementations should
* The interpretation of properties is up to implementations. Implementations must
* throw {@code JAXBException} if it finds properties that it doesn't understand.
*
* @param contextPath list of java package names that contain schema derived classes
@ -93,13 +86,8 @@ public interface JAXBContextFactory {
*
* @return a new instance of a {@code JAXBContext}
* @throws JAXBException if an error was encountered while creating the
* {@code JAXBContext} such as
* <ol>
* <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
* <li>an ambiguity among global elements contained in the contextPath</li>
* <li>failure to locate a value for the context factory provider property</li>
* <li>mixing schema derived packages from different providers on the same contextPath</li>
* </ol>
* {@code JAXBContext}. See {@link JAXBContext#newInstance(String, ClassLoader, Map)} for details.
*
* @since 9, JAXB 2.3
*/
JAXBContext createContext(String contextPath,

View File

@ -247,6 +247,13 @@ ifeq ($(OPENJDK_TARGET_OS), aix)
LIBJIMAGE_TOOLCHAIN := TOOLCHAIN_LINK_CXX
endif # OPENJDK_TARGET_OS aix
JIMAGELIB_CPPFLAGS := \
-I$(JDK_TOPDIR)/src/java.base/share/native/libjava \
-I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
-I$(JDK_TOPDIR)/src/java.base/share/native/libjimage \
-I$(SUPPORT_OUTPUTDIR)/headers/java.base \
#
$(eval $(call SetupNativeCompilation,BUILD_LIBJIMAGE, \
LIBRARY := jimage, \
TOOLCHAIN := $(LIBJIMAGE_TOOLCHAIN), \
@ -255,12 +262,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJIMAGE, \
SRC := $(JDK_TOPDIR)/src/java.base/share/native/libjimage \
$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjimage, \
EXCLUDES := $(LIBJIMAGE_EXCLUDES), \
CFLAGS := $(CFLAGS_JDKLIB) \
$(JIMAGELIB_CPPFLAGS) \
-I$(JDK_TOPDIR)/src/java.base/share/native/libjava \
-I$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
-I$(JDK_TOPDIR)/src/java.base/share/native/libjimage \
-I$(SUPPORT_OUTPUTDIR)/headers/java.base, \
CFLAGS := $(CFLAGS_JDKLIB) $(JIMAGELIB_CPPFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(JIMAGELIB_CPPFLAGS), \
CFLAGS_unix := -UDEBUG, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjimage/mapfile-vers, \
LDFLAGS := $(LDFLAGS_JDKLIB) \

View File

@ -401,18 +401,6 @@ public final class Long extends Number implements Comparable<Long> {
* @param offset the offset in the destination buffer to start at
* @param len the number of characters to write
*/
static void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) {
// assert shift > 0 && shift <=5 : "Illegal shift value";
// assert offset >= 0 && offset < buf.length : "illegal offset";
// assert len > 0 && (offset + len) <= buf.length : "illegal length";
int charPos = offset + len;
int radix = 1 << shift;
int mask = radix - 1;
do {
buf[--charPos] = Integer.digits[((int) val) & mask];
val >>>= shift;
} while (charPos > offset);
}
/** byte[]/LATIN1 version */
static void formatUnsignedLong0(long val, int shift, byte[] buf, int offset, int len) {
@ -436,6 +424,39 @@ public final class Long extends Number implements Comparable<Long> {
} while (charPos > offset);
}
static String fastUUID(long lsb, long msb) {
if (COMPACT_STRINGS) {
byte[] buf = new byte[36];
formatUnsignedLong0(lsb, 4, buf, 24, 12);
formatUnsignedLong0(lsb >>> 48, 4, buf, 19, 4);
formatUnsignedLong0(msb, 4, buf, 14, 4);
formatUnsignedLong0(msb >>> 16, 4, buf, 9, 4);
formatUnsignedLong0(msb >>> 32, 4, buf, 0, 8);
buf[23] = '-';
buf[18] = '-';
buf[13] = '-';
buf[8] = '-';
return new String(buf, LATIN1);
} else {
byte[] buf = new byte[72];
formatUnsignedLong0UTF16(lsb, 4, buf, 24, 12);
formatUnsignedLong0UTF16(lsb >>> 48, 4, buf, 19, 4);
formatUnsignedLong0UTF16(msb, 4, buf, 14, 4);
formatUnsignedLong0UTF16(msb >>> 16, 4, buf, 9, 4);
formatUnsignedLong0UTF16(msb >>> 32, 4, buf, 0, 8);
StringUTF16.putChar(buf, 23, '-');
StringUTF16.putChar(buf, 18, '-');
StringUTF16.putChar(buf, 13, '-');
StringUTF16.putChar(buf, 8, '-');
return new String(buf, UTF16);
}
}
/**
* Returns a {@code String} object representing the specified
* {@code long}. The argument is converted to signed decimal

View File

@ -342,4 +342,12 @@ final class StringConcatHelper {
return new String(buf, coder);
}
/**
* Provides the initial coder for the String.
* @return initial coder
*/
static byte initialCoder() {
return String.COMPACT_STRINGS ? String.LATIN1 : String.UTF16;
}
}

View File

@ -1911,11 +1911,8 @@ public final class System {
public void invokeFinalize(Object o) throws Throwable {
o.finalize();
}
public void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len) {
Long.formatUnsignedLong(val, shift, buf, offset, len);
}
public void formatUnsignedInt(int val, int shift, char[] buf, int offset, int len) {
Integer.formatUnsignedInt(val, shift, buf, offset, len);
public String fastUUID(long lsb, long msb) {
return Long.fastUUID(lsb, msb);
}
});
}

View File

@ -30,7 +30,7 @@ import java.lang.reflect.Field;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
/**
* The JVM interface for the method handles package is all here.

View File

@ -26,6 +26,8 @@ package java.lang.invoke;
/**
* StringConcatException is thrown by {@link StringConcatFactory} when linkage
* invariants are violated.
*
* @since 9
*/
public class StringConcatException extends Exception {
private static final long serialVersionUID = 292L + 9L;

View File

@ -30,7 +30,7 @@ import jdk.internal.org.objectweb.asm.Label;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.internal.org.objectweb.asm.Opcodes;
import jdk.internal.vm.annotation.ForceInline;
import sun.misc.Unsafe;
import jdk.internal.misc.Unsafe;
import java.lang.invoke.MethodHandles.Lookup;
import java.security.AccessController;
@ -96,6 +96,8 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
* more than 200 argument slots. Users requiring more than 200 argument slots in
* concatenation are expected to split the large concatenation in smaller
* expressions.
*
* @since 9
*/
public final class StringConcatFactory {
@ -955,6 +957,22 @@ public final class StringConcatFactory {
storage trimming, which defeats the purpose of exact strategies.
*/
/*
The logic for this check is as follows:
Stack before: Op:
(SB) dup, dup
(SB, SB, SB) capacity()
(int, SB, SB) swap
(SB, int, SB) toString()
(S, int, SB) length()
(int, int, SB) if_icmpeq
(SB) <end>
Note that it leaves the same StringBuilder on exit, like the one on enter.
*/
mv.visitInsn(DUP);
mv.visitInsn(DUP);
mv.visitMethodInsn(
@ -965,7 +983,7 @@ public final class StringConcatFactory {
false
);
mv.visitIntInsn(ISTORE, 0);
mv.visitInsn(SWAP);
mv.visitMethodInsn(
INVOKEVIRTUAL,
@ -975,8 +993,6 @@ public final class StringConcatFactory {
false
);
mv.visitInsn(DUP);
mv.visitMethodInsn(
INVOKEVIRTUAL,
"java/lang/String",
@ -985,8 +1001,6 @@ public final class StringConcatFactory {
false
);
mv.visitIntInsn(ILOAD, 0);
Label l0 = new Label();
mv.visitJumpInsn(IF_ICMPEQ, l0);
@ -1001,16 +1015,16 @@ public final class StringConcatFactory {
mv.visitInsn(ATHROW);
mv.visitLabel(l0);
} else {
mv.visitMethodInsn(
INVOKEVIRTUAL,
"java/lang/StringBuilder",
"toString",
"()Ljava/lang/String;",
false
);
}
mv.visitMethodInsn(
INVOKEVIRTUAL,
"java/lang/StringBuilder",
"toString",
"()Ljava/lang/String;",
false
);
mv.visitInsn(ARETURN);
mv.visitMaxs(-1, -1);
@ -1483,7 +1497,7 @@ public final class StringConcatFactory {
//
// The method handle shape after all length and coder mixers is:
// (int, byte, <args>)String = ("index", "coder", <args>)
byte initialCoder = 0; // initial coder
byte initialCoder = INITIAL_CODER;
int initialLen = 0; // initial length, in characters
for (RecipeElement el : recipe.getElements()) {
switch (el.getTag()) {
@ -1616,11 +1630,14 @@ public final class StringConcatFactory {
private static final ConcurrentMap<Class<?>, MethodHandle> LENGTH_MIXERS;
private static final ConcurrentMap<Class<?>, MethodHandle> CODER_MIXERS;
private static final Class<?> STRING_HELPER;
private static final byte INITIAL_CODER;
static {
try {
STRING_HELPER = Class.forName("java.lang.StringConcatHelper");
} catch (ClassNotFoundException e) {
MethodHandle initCoder = lookupStatic(Lookup.IMPL_LOOKUP, STRING_HELPER, "initialCoder", byte.class);
INITIAL_CODER = (byte) initCoder.invoke();
} catch (Throwable e) {
throw new AssertionError(e);
}

View File

@ -26,10 +26,10 @@
package java.lang.ref;
import jdk.internal.vm.annotation.DontInline;
import sun.misc.Cleaner;
import jdk.internal.HotSpotIntrinsicCandidate;
import jdk.internal.misc.JavaLangRefAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.ref.Cleaner;
/**
* Abstract base class for reference objects. This class defines the

View File

@ -1080,11 +1080,8 @@ public final class URI
* If a protocol handler for the URL could not be found,
* or if some other error occurred while constructing the URL
*/
public URL toURL()
throws MalformedURLException {
if (!isAbsolute())
throw new IllegalArgumentException("URI is not absolute");
return new URL(toString());
public URL toURL() throws MalformedURLException {
return URL.fromURI(this);
}
// -- Component access methods --

View File

@ -659,6 +659,44 @@ public final class URL implements java.io.Serializable {
}
}
/**
* Creates a URL from a URI, as if by invoking {@code uri.toURL()}.
*
* @see java.net.URI#toURL()
*/
static URL fromURI(URI uri) throws MalformedURLException {
if (!uri.isAbsolute()) {
throw new IllegalArgumentException("URI is not absolute");
}
String protocol = uri.getScheme();
// In general we need to go via Handler.parseURL, but for the jrt
// protocol we enforce that the Handler is not overrideable and can
// optimize URI to URL conversion.
//
// Case-sensitive comparison for performance; malformed protocols will
// be handled correctly by the slow path.
if (protocol.equals("jrt") && !uri.isOpaque()
&& uri.getRawFragment() == null) {
String query = uri.getRawQuery();
String path = uri.getRawPath();
String file = (query == null) ? path : path + "?" + query;
// URL represent undefined host as empty string while URI use null
String host = uri.getHost();
if (host == null) {
host = "";
}
int port = uri.getPort();
return new URL("jrt", host, port, file, null);
} else {
return new URL((URL)null, uri.toString(), null);
}
}
/*
* Returns true if specified string is a valid protocol name.
*/
@ -1275,11 +1313,28 @@ public final class URL implements java.io.Serializable {
}
}
private static final String[] NON_OVERRIDEABLE_PROTOCOLS = {"file", "jrt"};
private static boolean isOverrideable(String protocol) {
for (String p : NON_OVERRIDEABLE_PROTOCOLS)
if (protocol.equalsIgnoreCase(p))
/**
* Non-overrideable protocols: "jrt" and "file"
*
* Character-based comparison for performance reasons; also ensures
* case-insensitive comparison in a locale-independent fashion.
*/
static boolean isOverrideable(String protocol) {
if (protocol.length() == 3) {
if ((Character.toLowerCase(protocol.charAt(0)) == 'j') &&
(Character.toLowerCase(protocol.charAt(1)) == 'r') &&
(Character.toLowerCase(protocol.charAt(2)) == 't')) {
return false;
}
} else if (protocol.length() == 4) {
if ((Character.toLowerCase(protocol.charAt(0)) == 'f') &&
(Character.toLowerCase(protocol.charAt(1)) == 'i') &&
(Character.toLowerCase(protocol.charAt(2)) == 'l') &&
(Character.toLowerCase(protocol.charAt(3)) == 'e')) {
return false;
}
}
return true;
}

View File

@ -28,9 +28,9 @@
package java.nio;
import java.io.FileDescriptor;
import sun.misc.Cleaner;
import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.ref.Cleaner;
import sun.nio.ch.DirectBuffer;

View File

@ -150,7 +150,7 @@ public interface Path
* #normalize normalize} method, to eliminate redundant names, for cases where
* <em>shell-like</em> navigation is required.
*
* <p> If this path has one or more elements, and no root component, then
* <p> If this path has more than one element, and no root component, then
* this method is equivalent to evaluating the expression:
* <blockquote><pre>
* subpath(0,&nbsp;getNameCount()-1);

View File

@ -100,6 +100,8 @@ import java.time.temporal.ValueRange;
import java.time.zone.ZoneOffsetTransition;
import java.time.zone.ZoneRules;
import java.util.Objects;
import java.util.stream.LongStream;
import java.util.stream.Stream;
/**
* A date without a time-zone in the ISO-8601 calendar system,
@ -1715,6 +1717,89 @@ public final class LocalDate
return Period.of(Math.toIntExact(years), months, days);
}
/**
* Returns a sequential ordered stream of dates. The returned stream starts from this date
* (inclusive) and goes to {@code endExclusive} (exclusive) by an incremental step of 1 day.
* <p>
* This method is equivalent to {@code datesUntil(endExclusive, Period.ofDays(1))}.
*
* @param endExclusive the end date, exclusive, not null
* @return a sequential {@code Stream} for the range of {@code LocalDate} values
* @throws IllegalArgumentException if end date is before this date
* @since 9
*/
public Stream<LocalDate> datesUntil(LocalDate endExclusive) {
long end = endExclusive.toEpochDay();
long start = toEpochDay();
if (end < start) {
throw new IllegalArgumentException(endExclusive + " < " + this);
}
return LongStream.range(start, end).mapToObj(LocalDate::ofEpochDay);
}
/**
* Returns a sequential ordered stream of dates by given incremental step. The returned stream
* starts from this date (inclusive) and goes to {@code endExclusive} (exclusive).
* <p>
* The n-th date which appears in the stream is equal to {@code this.plus(step.multipliedBy(n))}
* (but the result of step multiplication never overflows). For example, if this date is
* {@code 2015-01-31}, the end date is {@code 2015-05-01} and the step is 1 month, then the
* stream contains {@code 2015-01-31}, {@code 2015-02-28}, {@code 2015-03-31}, and
* {@code 2015-04-30}.
*
* @param endExclusive the end date, exclusive, not null
* @param step the non-zero, non-negative {@code Period} which represents the step.
* @return a sequential {@code Stream} for the range of {@code LocalDate} values
* @throws IllegalArgumentException if step is zero, or {@code step.getDays()} and
* {@code step.toTotalMonths()} have opposite sign, or end date is before this date
* and step is positive, or end date is after this date and step is negative
* @since 9
*/
public Stream<LocalDate> datesUntil(LocalDate endExclusive, Period step) {
if (step.isZero()) {
throw new IllegalArgumentException("step is zero");
}
long end = endExclusive.toEpochDay();
long start = toEpochDay();
long until = end - start;
long months = step.toTotalMonths();
long days = step.getDays();
if ((months < 0 && days > 0) || (months > 0 && days < 0)) {
throw new IllegalArgumentException("period months and days are of opposite sign");
}
if (until == 0) {
return Stream.empty();
}
int sign = months > 0 || days > 0 ? 1 : -1;
if (sign < 0 ^ until < 0) {
throw new IllegalArgumentException(endExclusive + (sign < 0 ? " > " : " < ") + this);
}
if (months == 0) {
long steps = (until - sign) / days; // non-negative
return LongStream.rangeClosed(0, steps).mapToObj(
n -> LocalDate.ofEpochDay(start + n * days));
}
// 48699/1600 = 365.2425/12, no overflow, non-negative result
long steps = until * 1600 / (months * 48699 + days * 1600) + 1;
long addMonths = months * steps;
long addDays = days * steps;
long maxAddMonths = months > 0 ? MAX.getProlepticMonth() - getProlepticMonth()
: getProlepticMonth() - MIN.getProlepticMonth();
// adjust steps estimation
if (addMonths * sign > maxAddMonths
|| (plusMonths(addMonths).toEpochDay() + addDays) * sign >= end * sign) {
steps--;
addMonths -= months;
addDays -= days;
if (addMonths * sign > maxAddMonths
|| (plusMonths(addMonths).toEpochDay() + addDays) * sign >= end * sign) {
steps--;
}
}
return LongStream.rangeClosed(0, steps).mapToObj(
n -> this.plusMonths(months * n).plusDays(days * n));
}
/**
* Formats this date using the specified formatter.
* <p>

View File

@ -649,7 +649,7 @@ public interface Map<K, V> {
try {
k = entry.getKey();
v = entry.getValue();
} catch(IllegalStateException ise) {
} catch (IllegalStateException ise) {
// this usually means the entry is no longer in the map.
throw new ConcurrentModificationException(ise);
}
@ -704,7 +704,7 @@ public interface Map<K, V> {
try {
k = entry.getKey();
v = entry.getValue();
} catch(IllegalStateException ise) {
} catch (IllegalStateException ise) {
// this usually means the entry is no longer in the map.
throw new ConcurrentModificationException(ise);
}
@ -714,7 +714,7 @@ public interface Map<K, V> {
try {
entry.setValue(v);
} catch(IllegalStateException ise) {
} catch (IllegalStateException ise) {
// this usually means the entry is no longer in the map.
throw new ConcurrentModificationException(ise);
}
@ -887,7 +887,7 @@ public interface Map<K, V> {
* or atomicity properties of this method. Any implementation providing
* atomicity guarantees must override this method and document its
* concurrency properties.
*
*
* @param key key with which the specified value is associated
* @param value value to be associated with the specified key
* @return the previous value associated with the specified key, or
@ -984,6 +984,9 @@ public interface Map<K, V> {
* @throws ClassCastException if the class of the specified key or value
* prevents it from being stored in this map
* (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
* @throws IllegalArgumentException if some property of the specified key
* or value prevents it from being stored in this map
* (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
* @since 1.8
*/
default V computeIfAbsent(K key,
@ -1058,6 +1061,9 @@ public interface Map<K, V> {
* @throws ClassCastException if the class of the specified key or value
* prevents it from being stored in this map
* (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
* @throws IllegalArgumentException if some property of the specified key
* or value prevents it from being stored in this map
* (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
* @since 1.8
*/
default V computeIfPresent(K key,
@ -1103,7 +1109,7 @@ public interface Map<K, V> {
* <pre> {@code
* V oldValue = map.get(key);
* V newValue = remappingFunction.apply(key, oldValue);
* if (oldValue != null ) {
* if (oldValue != null) {
* if (newValue != null)
* map.put(key, newValue);
* else
@ -1147,6 +1153,9 @@ public interface Map<K, V> {
* @throws ClassCastException if the class of the specified key or value
* prevents it from being stored in this map
* (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
* @throws IllegalArgumentException if some property of the specified key
* or value prevents it from being stored in this map
* (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
* @since 1.8
*/
default V compute(K key,
@ -1239,6 +1248,9 @@ public interface Map<K, V> {
* @throws ClassCastException if the class of the specified key or value
* prevents it from being stored in this map
* (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
* @throws IllegalArgumentException if some property of the specified key
* or value prevents it from being stored in this map
* (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
* @throws NullPointerException if the specified key is null and this map
* does not support null keys or the value or remappingFunction is
* null
@ -1251,7 +1263,7 @@ public interface Map<K, V> {
V oldValue = get(key);
V newValue = (oldValue == null) ? value :
remappingFunction.apply(oldValue, value);
if(newValue == null) {
if (newValue == null) {
remove(key);
} else {
put(key, newValue);

View File

@ -129,14 +129,6 @@ package java.util;
* <a href="{@docRoot}/../technotes/guides/collections/index.html">
* Java Collections Framework</a>.
*
* @see java.util.Collection
* @see LinkedList
* @see PriorityQueue
* @see java.util.concurrent.LinkedBlockingQueue
* @see java.util.concurrent.BlockingQueue
* @see java.util.concurrent.ArrayBlockingQueue
* @see java.util.concurrent.LinkedBlockingQueue
* @see java.util.concurrent.PriorityBlockingQueue
* @since 1.5
* @author Doug Lea
* @param <E> the type of elements held in this queue

View File

@ -392,17 +392,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
* @return A string representation of this {@code UUID}
*/
public String toString() {
char[] chars = new char[36];
jla.formatUnsignedLong(mostSigBits >> 32, 4, chars, 0, 8);
chars[8] = '-';
jla.formatUnsignedLong(mostSigBits >> 16, 4, chars, 9, 4);
chars[13] = '-';
jla.formatUnsignedLong(mostSigBits, 4, chars, 14, 4);
chars[18] = '-';
jla.formatUnsignedLong(leastSigBits >> 48, 4, chars, 19, 4);
chars[23] = '-';
jla.formatUnsignedLong(leastSigBits, 4, chars, 24, 12);
return jla.newStringUnsafe(chars);
return jla.fastUUID(leastSigBits, mostSigBits);
}
/**

View File

@ -301,19 +301,15 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
*
* @implSpec
* The default implementation is equivalent to the following steps for this
* {@code map}, then returning the current value or {@code null} if now
* absent:
* {@code map}:
*
* <pre> {@code
* if (map.get(key) == null) {
* V newValue = mappingFunction.apply(key);
* if (newValue != null)
* return map.putIfAbsent(key, newValue);
* }}</pre>
*
* The default implementation may retry these steps when multiple
* threads attempt updates including potentially calling the mapping
* function multiple times.
* V oldValue, newValue;
* return ((oldValue = map.get(key)) == null
* && (newValue = mappingFunction.apply(key)) != null
* && (oldValue = map.putIfAbsent(key, newValue)) == null)
* ? newValue
* : oldValue;}</pre>
*
* <p>This implementation assumes that the ConcurrentMap cannot contain null
* values and {@code get()} returning null unambiguously means the key is
@ -323,16 +319,19 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
* @throws UnsupportedOperationException {@inheritDoc}
* @throws ClassCastException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @since 1.8
*/
@Override
default V computeIfAbsent(K key,
Function<? super K, ? extends V> mappingFunction) {
Objects.requireNonNull(mappingFunction);
V v, newValue;
return ((v = get(key)) == null &&
(newValue = mappingFunction.apply(key)) != null &&
(v = putIfAbsent(key, newValue)) == null) ? newValue : v;
V oldValue, newValue;
return ((oldValue = get(key)) == null
&& (newValue = mappingFunction.apply(key)) != null
&& (oldValue = putIfAbsent(key, newValue)) == null)
? newValue
: oldValue;
}
/**
@ -340,22 +339,19 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
*
* @implSpec
* The default implementation is equivalent to performing the following
* steps for this {@code map}, then returning the current value or
* {@code null} if now absent:
* steps for this {@code map}:
*
* <pre> {@code
* if (map.get(key) != null) {
* V oldValue = map.get(key);
* for (V oldValue; (oldValue = map.get(key)) != null; ) {
* V newValue = remappingFunction.apply(key, oldValue);
* if (newValue != null)
* map.replace(key, oldValue, newValue);
* else
* map.remove(key, oldValue);
* }}</pre>
*
* The default implementation may retry these steps when multiple threads
* attempt updates including potentially calling the remapping function
* multiple times.
* if ((newValue == null)
* ? map.remove(key, oldValue)
* : map.replace(key, oldValue, newValue))
* return newValue;
* }
* return null;}</pre>
* When multiple threads attempt updates, map operations and the
* remapping function may be called multiple times.
*
* <p>This implementation assumes that the ConcurrentMap cannot contain null
* values and {@code get()} returning null unambiguously means the key is
@ -365,22 +361,21 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
* @throws UnsupportedOperationException {@inheritDoc}
* @throws ClassCastException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @since 1.8
*/
@Override
default V computeIfPresent(K key,
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
V oldValue;
while ((oldValue = get(key)) != null) {
for (V oldValue; (oldValue = get(key)) != null; ) {
V newValue = remappingFunction.apply(key, oldValue);
if (newValue != null) {
if (replace(key, oldValue, newValue))
return newValue;
} else if (remove(key, oldValue))
return null;
if ((newValue == null)
? remove(key, oldValue)
: replace(key, oldValue, newValue))
return newValue;
}
return oldValue;
return null;
}
/**
@ -388,27 +383,23 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
*
* @implSpec
* The default implementation is equivalent to performing the following
* steps for this {@code map}, then returning the current value or
* {@code null} if absent:
* steps for this {@code map}:
*
* <pre> {@code
* V oldValue = map.get(key);
* V newValue = remappingFunction.apply(key, oldValue);
* if (oldValue != null ) {
* if (newValue != null)
* map.replace(key, oldValue, newValue);
* else
* map.remove(key, oldValue);
* } else {
* if (newValue != null)
* map.putIfAbsent(key, newValue);
* else
* for (;;) {
* V oldValue = map.get(key);
* V newValue = remappingFunction.apply(key, oldValue);
* if (newValue != null) {
* if ((oldValue != null)
* ? map.replace(key, oldValue, newValue)
* : map.putIfAbsent(key, newValue) == null)
* return newValue;
* } else if (oldValue == null || map.remove(key, oldValue)) {
* return null;
* }
* }}</pre>
*
* The default implementation may retry these steps when multiple
* threads attempt updates including potentially calling the remapping
* function multiple times.
* When multiple threads attempt updates, map operations and the
* remapping function may be called multiple times.
*
* <p>This implementation assumes that the ConcurrentMap cannot contain null
* values and {@code get()} returning null unambiguously means the key is
@ -418,50 +409,29 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
* @throws UnsupportedOperationException {@inheritDoc}
* @throws ClassCastException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @since 1.8
*/
@Override
default V compute(K key,
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
V oldValue = get(key);
for (;;) {
V newValue = remappingFunction.apply(key, oldValue);
if (newValue == null) {
// delete mapping
if (oldValue != null || containsKey(key)) {
// something to remove
if (remove(key, oldValue)) {
// removed the old value as expected
return null;
BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
retry: for (;;) {
V oldValue = get(key);
// if putIfAbsent fails, opportunistically use its return value
haveOldValue: for (;;) {
V newValue = remappingFunction.apply(key, oldValue);
if (newValue != null) {
if (oldValue != null) {
if (replace(key, oldValue, newValue))
return newValue;
}
// some other value replaced old value. try again.
oldValue = get(key);
} else {
// nothing to do. Leave things as they were.
else if ((oldValue = putIfAbsent(key, newValue)) == null)
return newValue;
else continue haveOldValue;
} else if (oldValue == null || remove(key, oldValue)) {
return null;
}
} else {
// add or replace old mapping
if (oldValue != null) {
// replace
if (replace(key, oldValue, newValue)) {
// replaced as expected.
return newValue;
}
// some other value replaced old value. try again.
oldValue = get(key);
} else {
// add (replace if oldValue was null)
if ((oldValue = putIfAbsent(key, newValue)) == null) {
// replaced
return newValue;
}
// some other value replaced old value. try again.
}
continue retry;
}
}
}
@ -471,21 +441,25 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
*
* @implSpec
* The default implementation is equivalent to performing the following
* steps for this {@code map}, then returning the current value or
* {@code null} if absent:
* steps for this {@code map}:
*
* <pre> {@code
* V oldValue = map.get(key);
* V newValue = (oldValue == null) ? value :
* remappingFunction.apply(oldValue, value);
* if (newValue == null)
* map.remove(key);
* else
* map.put(key, newValue);}</pre>
*
* <p>The default implementation may retry these steps when multiple
* threads attempt updates including potentially calling the remapping
* function multiple times.
* for (;;) {
* V oldValue = map.get(key);
* if (oldValue != null) {
* V newValue = remappingFunction.apply(oldValue, value);
* if (newValue != null) {
* if (map.replace(key, oldValue, newValue))
* return newValue;
* } else if (map.remove(key, oldValue)) {
* return null;
* }
* } else if (map.putIfAbsent(key, value) == null) {
* return value;
* }
* }}</pre>
* When multiple threads attempt updates, map operations and the
* remapping function may be called multiple times.
*
* <p>This implementation assumes that the ConcurrentMap cannot contain null
* values and {@code get()} returning null unambiguously means the key is
@ -495,6 +469,7 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
* @throws UnsupportedOperationException {@inheritDoc}
* @throws ClassCastException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
* @throws IllegalArgumentException {@inheritDoc}
* @since 1.8
*/
@Override
@ -502,20 +477,23 @@ public interface ConcurrentMap<K,V> extends Map<K,V> {
BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
Objects.requireNonNull(remappingFunction);
Objects.requireNonNull(value);
V oldValue = get(key);
for (;;) {
if (oldValue != null) {
V newValue = remappingFunction.apply(oldValue, value);
if (newValue != null) {
if (replace(key, oldValue, newValue))
return newValue;
} else if (remove(key, oldValue)) {
return null;
}
oldValue = get(key);
} else {
if ((oldValue = putIfAbsent(key, value)) == null) {
return value;
retry: for (;;) {
V oldValue = get(key);
// if putIfAbsent fails, opportunistically use its return value
haveOldValue: for (;;) {
if (oldValue != null) {
V newValue = remappingFunction.apply(oldValue, value);
if (newValue != null) {
if (replace(key, oldValue, newValue))
return newValue;
} else if (remove(key, oldValue)) {
return null;
}
continue retry;
} else {
if ((oldValue = putIfAbsent(key, value)) == null)
return value;
continue haveOldValue;
}
}
}

View File

@ -35,6 +35,9 @@
package java.util.concurrent;
import java.time.temporal.ChronoUnit;
import java.util.Objects;
/**
* A {@code TimeUnit} represents time durations at a given unit of
* granularity and provides utility methods to convert across units,
@ -390,4 +393,48 @@ public enum TimeUnit {
}
}
/**
* Converts this {@code TimeUnit} to the equivalent {@code ChronoUnit}.
*
* @return the converted equivalent ChronoUnit
* @since 9
*/
public ChronoUnit toChronoUnit() {
switch (this) {
case NANOSECONDS: return ChronoUnit.NANOS;
case MICROSECONDS: return ChronoUnit.MICROS;
case MILLISECONDS: return ChronoUnit.MILLIS;
case SECONDS: return ChronoUnit.SECONDS;
case MINUTES: return ChronoUnit.MINUTES;
case HOURS: return ChronoUnit.HOURS;
case DAYS: return ChronoUnit.DAYS;
default: throw new AssertionError();
}
}
/**
* Converts a {@code ChronoUnit} to the equivalent {@code TimeUnit}.
*
* @param chronoUnit the ChronoUnit to convert
* @return the converted equivalent TimeUnit
* @throws IllegalArgumentException if {@code chronoUnit} has no
* equivalent TimeUnit
* @throws NullPointerException if {@code chronoUnit} is null
* @since 9
*/
public static TimeUnit of(ChronoUnit chronoUnit) {
switch (Objects.requireNonNull(chronoUnit, "chronoUnit")) {
case NANOS: return TimeUnit.NANOSECONDS;
case MICROS: return TimeUnit.MICROSECONDS;
case MILLIS: return TimeUnit.MILLISECONDS;
case SECONDS: return TimeUnit.SECONDS;
case MINUTES: return TimeUnit.MINUTES;
case HOURS: return TimeUnit.HOURS;
case DAYS: return TimeUnit.DAYS;
default:
throw new IllegalArgumentException(
"No TimeUnit equivalent for " + chronoUnit);
}
}
}

View File

@ -0,0 +1,609 @@
/*
* 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
* questions.
*/
package jdk;
import java.math.BigInteger;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* A representation of the JDK version-string which contains a version
* number optionally followed by pre-release and build information.
*
* <h2><a name="verNum">Version numbers</a></h2>
*
* A <em>version number</em>, {@code $VNUM}, is a non-empty sequence of
* non-negative integer numerals, without leading or trailing zeroes,
* separated by period characters (U+002E); i.e., it matches the regular
* expression {@code ^[1-9][0-9]*(((\.0)*\.[1-9][0-9]*)*)*$}. The sequence may
* be of arbitrary length but the first three elements are assigned specific
* meanings, as follows:
*
* <blockquote><pre>
* $MAJOR.$MINOR.$SECURITY
* </pre></blockquote>
*
* <ul>
*
* <li><p> <a name="major">{@code $MAJOR}</a> --- The major version number,
* incremented for a major release that contains significant new features as
* specified in a new edition of the Java&#160;SE Platform Specification,
* <em>e.g.</em>, <a href="https://jcp.org/en/jsr/detail?id=337">JSR 337</a>
* for Java&#160;SE&#160;8. Features may be removed in a major release, given
* advance notice at least one major release ahead of time, and incompatible
* changes may be made when justified. The {@code $MAJOR} version number of
* JDK&#160;8 was {@code 8}; the {@code $MAJOR} version number of JDK&#160;9
* is {@code 9}. </p></li>
*
* <li><p> <a name="minor">{@code $MINOR}</a> --- The minor version number,
* incremented for a minor update release that may contain compatible bug
* fixes, revisions to standard APIs mandated by a <a
* href="https://jcp.org/en/procedures/jcp2#5.3">Maintenance Release</a> of
* the relevant Platform Specification, and implementation features outside
* the scope of that Specification such as new JDK-specific APIs, additional
* service providers, new garbage collectors, and ports to new hardware
* architectures. {@code $MINOR} is reset to zero when {@code $MAJOR} is
* incremented. </p></li>
*
* <li><p> <a name="security">{@code $SECURITY}</a> --- The security level,
* incremented for a security-update release that contains critical fixes
* including those necessary to improve security. {@code $SECURITY} is reset
* to zero <strong>only</strong> when {@code $MAJOR} is incremented. A higher
* value of {@code $SECURITY} for a given {@code $MAJOR} value, therefore,
* always indicates a more secure release, regardless of the value of {@code
* $MINOR}. </p></li>
*
* </ul>
*
* <p> The fourth and later elements of a version number are free for use by
* downstream consumers of the JDK code base. Such a consumer may,
* <em>e.g.</em>, use the fourth element to identify patch releases which
* contain a small number of critical non-security fixes in addition to the
* security fixes in the corresponding security release. </p>
*
* <p> The version number does not include trailing zero elements;
* <em>i.e.</em>, {@code $SECURITY} is omitted if it has the value zero, and
* {@code $MINOR} is omitted if both {@code $MINOR} and {@code $SECURITY} have
* the value zero. </p>
*
* <p> The sequence of numerals in a version number is compared to another
* such sequence in numerical, pointwise fashion; <em>e.g.</em>, {@code 9.9.1}
* is less than {@code 9.10.0}. If one sequence is shorter than another then
* the missing elements of the shorter sequence are considered to be zero;
* <em>e.g.</em>, {@code 9.1.2} is equal to {@code 9.1.2.0} but less than
* {@code 9.1.2.1}. </p>
*
* <h2><a name="verStr">Version strings</a></h2>
*
* <p> A <em>version string</em> {@code $VSTR} consists of a version number
* {@code $VNUM}, as described above, optionally followed by pre-release and
* build information, in the format </p>
*
* <blockquote><pre>
* $VNUM(-$PRE)?(\+($BUILD)?(-$OPT)?)?
* </pre></blockquote>
*
* <p> where: </p>
*
* <ul>
*
* <li><p> <a name="pre">{@code $PRE}</a>, matching {@code ([a-zA-Z0-9]+)} ---
* A pre-release identifier. Typically {@code ea}, for an early-access
* release that's under active development and potentially unstable, or {@code
* internal}, for an internal developer build.
*
* <li><p> <a name="build">{@code $BUILD}</a>, matching {@code
* (0|[1-9][0-9]*)} --- The build number, incremented for each promoted build.
* {@code $BUILD} is reset to {@code 1} when any portion of {@code $VNUM} is
* incremented. </p>
*
* <li><p> <a name="opt">{@code $OPT}</a>, matching {@code ([-a-zA-Z0-9\.]+)}
* --- Additional build information, if desired. In the case of an {@code
* internal} build this will often contain the date and time of the
* build. </p>
*
* </ul>
*
* <p> When comparing two version strings the value of {@code $OPT}, if
* present, may or may not be significant depending on the chosen comparison
* method. The comparison methods {@link #compareTo(Version) compareTo()} and
* {@link #compareToIgnoreOpt(Version) compareToIgnoreOpt{}} should be used
* consistently with the corresponding methods {@link #equals(Object) equals()}
* and {@link #equalsIgnoreOpt(Object) equalsIgnoreOpt()}. </p>
*
* <p> A <em>short version string</em> ({@code $SVSTR}), often useful in less
* formal contexts, is simply {@code $VNUM} optionally ended with {@code
* -$PRE}. </p>
*
* @since 9
*/
public final class Version
implements Comparable<Version>
{
private final List<Integer> version;
private final Optional<String> pre;
private final Optional<Integer> build;
private final Optional<String> optional;
private static Version current;
// $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)?
// RE limits the format of version strings
// ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))?
private static final String VNUM
= "(?<VNUM>[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)";
private static final String VNUM_GROUP = "VNUM";
private static final String PRE = "(?:-(?<PRE>[a-zA-Z0-9]+))?";
private static final String PRE_GROUP = "PRE";
private static final String BUILD
= "(?:(?<PLUS>\\+)(?<BUILD>0|[1-9][0-9]*)?)?";
private static final String PLUS_GROUP = "PLUS";
private static final String BUILD_GROUP = "BUILD";
private static final String OPT = "(?:-(?<OPT>[-a-zA-Z0-9.]+))?";
private static final String OPT_GROUP = "OPT";
private static final String VSTR_FORMAT
= "^" + VNUM + PRE + BUILD + OPT + "$";
private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
/**
* Constructs a valid JDK <a href="verStr">version string</a> containing a
* <a href="#verNum">version number</a> followed by pre-release and build
* information.
*
* @param s
* A string to be interpreted as a version
*
* @throws IllegalArgumentException
* If the given string cannot be interpreted a valid version
*
* @throws NullPointerException
* If {@code s} is {@code null}
*
* @throws NumberFormatException
* If an element of the version number or the build number cannot
* be represented as an {@link Integer}
*/
private Version(String s) {
if (s == null)
throw new NullPointerException();
Matcher m = VSTR_PATTERN.matcher(s);
if (!m.matches())
throw new IllegalArgumentException("Invalid version string: '"
+ s + "'");
// $VNUM is a dot-separated list of integers of arbitrary length
version
= Collections.unmodifiableList(
Arrays.stream(m.group(VNUM_GROUP).split("\\."))
.map(Integer::parseInt)
.collect(Collectors.toList()));
pre = Optional.ofNullable(m.group(PRE_GROUP));
String b = m.group(BUILD_GROUP);
// $BUILD is an integer
build = (b == null)
? Optional.<Integer>empty()
: Optional.ofNullable(Integer.parseInt(b));
optional = Optional.ofNullable(m.group(OPT_GROUP));
// empty '+'
if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
if (optional.isPresent()) {
if (pre.isPresent())
throw new IllegalArgumentException("'+' found with"
+ " pre-release and optional components:'" + s + "'");
} else {
throw new IllegalArgumentException("'+' found with neither"
+ " build or optional components: '" + s + "'");
}
}
}
/**
* Parses the given string as a valid JDK <a
* href="#verStr">version string</a> containing a <a
* href="#verNum">version number</a> followed by pre-release and
* build information.
*
* @param s
* A string to interpret as a version
*
* @throws IllegalArgumentException
* If the given string cannot be interpreted a valid version
*
* @throws NullPointerException
* If the given string is {@code null}
*
* @throws NumberFormatException
* If an element of the version number or the build number cannot
* be represented as an {@link Integer}
*
* @return This version
*/
public static Version parse(String s) {
return new Version(s);
}
/**
* Returns {@code System.getProperty("java.version")} as a Version.
*
* @throws SecurityException
* If a security manager exists and its {@link
* SecurityManager#checkPropertyAccess(String)
* checkPropertyAccess} method does not allow access to the
* system property "java.version"
*
* @return {@code System.getProperty("java.version")} as a Version
*/
public static Version current() {
if (current == null) {
current = parse(AccessController.doPrivileged(
new PrivilegedAction<>() {
public String run() {
return System.getProperty("java.version");
}
}));
}
return current;
}
/**
* Returns the <a href="#major">major</a> version number.
*
* @return The major version number
*/
public int major() {
return version.get(0);
}
/**
* Returns the <a href="#minor">minor</a> version number or zero if it was
* not set.
*
* @return The minor version number or zero if it was not set
*/
public int minor() {
return (version.size() > 1 ? version.get(1) : 0);
}
/**
* Returns the <a href="#security">security</a> version number or zero if
* it was not set.
*
* @return The security version number or zero if it was not set
*/
public int security() {
return (version.size() > 2 ? version.get(2) : 0);
}
/**
* Returns an unmodifiable {@link java.util.List List} of the
* integer numerals contained in the <a href="#verNum">version
* number</a>. The {@code List} always contains at least one
* element corresponding to the <a href="#major">major version
* number</a>.
*
* @return An unmodifiable list of the integer numerals
* contained in the version number
*/
public List<Integer> version() {
return version;
}
/**
* Returns the optional <a href="#pre">pre-release</a> information.
*
* @return The optional pre-release information as a String
*/
public Optional<String> pre() {
return pre;
}
/**
* Returns the <a href="#build">build number</a>.
*
* @return The optional build number.
*/
public Optional<Integer> build() {
return build;
}
/**
* Returns <a href="#opt">optional</a> additional identifying build
* information.
*
* @return Additional build information as a String
*/
public Optional<String> optional() {
return optional;
}
/**
* Compares this version to another.
*
* <p> Each of the components in the <a href="#verStr">version</a> is
* compared in the follow order of precedence: version numbers,
* pre-release identifiers, build numbers, optional build information. </p>
*
* <p> Comparison begins by examining the sequence of version numbers. If
* one sequence is shorter than another, then the missing elements of the
* shorter sequence are considered to be zero. </p>
*
* <p> A version with a pre-release identifier is always considered to be
* less than a version without one. Pre-release identifiers are compared
* numerically when they consist only of digits, and lexicographically
* otherwise. Numeric identifiers are considered to be less than
* non-numeric identifiers. </p>
*
* <p> A version without a build number is always less than one with a
* build number; otherwise build numbers are compared numerically. </p>
*
* <p> The optional build information is compared lexicographically.
* During this comparison, a version with optional build information is
* considered to be greater than a version without one. </p>
*
* <p> A version is not comparable to any other type of object.
*
* @param ob
* The object to be compared
*
* @return A negative integer, zero, or a positive integer if this
* {@code Version} is less than, equal to, or greater than the
* given {@code Version}
*
* @throws NullPointerException
* If the given object is {@code null}
*/
@Override
public int compareTo(Version ob) {
return compare(ob, false);
}
/**
* Compares this version to another disregarding optional build
* information.
*
* <p> Two versions are compared by examining the version string as
* described in {@link #compareTo(Version)} with the exception that the
* optional build information is always ignored. </p>
*
* <p> A version is not comparable to any other type of object.
*
* @param ob
* The object to be compared
*
* @return A negative integer, zero, or a positive integer if this
* {@code Version} is less than, equal to, or greater than the
* given {@code Version}
*
* @throws NullPointerException
* If the given object is {@code null}
*/
public int compareToIgnoreOpt(Version ob) {
return compare(ob, true);
}
private int compare(Version ob, boolean ignoreOpt) {
if (ob == null)
throw new NullPointerException("Invalid argument");
int ret = compareVersion(ob);
if (ret != 0)
return ret;
ret = comparePre(ob);
if (ret != 0)
return ret;
ret = compareBuild(ob);
if (ret != 0)
return ret;
if (!ignoreOpt)
return compareOpt(ob);
return 0;
}
private int compareVersion(Version ob) {
int size = version.size();
int oSize = ob.version().size();
int min = Math.min(size, oSize);
for (int i = 0; i < min; i++) {
Integer val = version.get(i);
Integer oVal = ob.version().get(i);
if (val != oVal)
return val - oVal;
}
if (size != oSize)
return size - oSize;
return 0;
}
private int comparePre(Version ob) {
Optional<String> oPre = ob.pre();
if (!pre.isPresent()) {
if (oPre.isPresent())
return 1;
} else {
if (!oPre.isPresent())
return -1;
String val = pre.get();
String oVal = oPre.get();
if (val.matches("\\d+")) {
return (oVal.matches("\\d+")
? (new BigInteger(val)).compareTo(new BigInteger(oVal))
: -1);
} else {
return (oVal.matches("\\d+")
? 1
: val.compareTo(oVal));
}
}
return 0;
}
private int compareBuild(Version ob) {
Optional<Integer> oBuild = ob.build();
if (oBuild.isPresent()) {
return (build.isPresent()
? build.get().compareTo(oBuild.get())
: 1);
} else if (build.isPresent()) {
return -1;
}
return 0;
}
private int compareOpt(Version ob) {
Optional<String> oOpt = ob.optional();
if (!optional.isPresent()) {
if (oOpt.isPresent())
return -1;
} else {
if (!oOpt.isPresent())
return 1;
return optional.get().compareTo(oOpt.get());
}
return 0;
}
/**
* Returns a string representation of this version.
*
* @return The version string
*/
@Override
public String toString() {
StringBuilder sb
= new StringBuilder(version.stream()
.map(Object::toString)
.collect(Collectors.joining(".")));
pre.ifPresent(v -> sb.append("-").append(v));
if (build.isPresent()) {
sb.append("+").append(build.get());
if (optional.isPresent())
sb.append("-").append(optional.get());
} else {
if (optional.isPresent()) {
sb.append(pre.isPresent() ? "-" : "+-");
sb.append(optional.get());
}
}
return sb.toString();
}
/**
* Determines whether this {@code Version} is equal to another object.
*
* <p> Two {@code Version}s are equal if and only if they represent the
* same version string.
*
* <p> This method satisfies the general contract of the {@link
* Object#equals(Object) Object.equals} method. </p>
*
* @param ob
* The object to which this {@code Version} is to be compared
*
* @return {@code true} if, and only if, the given object is a {@code
* Version} that is identical to this {@code Version}
*
*/
@Override
public boolean equals(Object ob) {
boolean ret = equalsIgnoreOpt(ob);
if (!ret)
return false;
Version that = (Version)ob;
return (this.optional().equals(that.optional()));
}
/**
* Determines whether this {@code Version} is equal to another
* disregarding optional build information.
*
* <p> Two {@code Version}s are equal if and only if they represent the
* same version string disregarding the optional build information.
*
* @param ob
* The object to which this {@code Version} is to be compared
*
* @return {@code true} if, and only if, the given object is a {@code
* Version} that is identical to this {@code Version}
* ignoring the optinal build information
*
*/
public boolean equalsIgnoreOpt(Object ob) {
if (this == ob)
return true;
if (!(ob instanceof Version))
return false;
Version that = (Version)ob;
return (this.version().equals(that.version())
&& this.pre().equals(that.pre())
&& this.build().equals(that.build()));
}
/**
* Returns the hash code of this version.
*
* <p> This method satisfies the general contract of the {@link
* Object#hashCode Object.hashCode} method.
*
* @return The hashcode of this version
*/
@Override
public int hashCode() {
int h = 1;
int p = 17;
h = p * h + version.hashCode();
h = p * h + pre.hashCode();
h = p * h + build.hashCode();
h = p * h + optional.hashCode();
return h;
}
}

View File

@ -124,12 +124,7 @@ public interface JavaLangAccess {
void invokeFinalize(Object o) throws Throwable;
/**
* Invokes Long.formatUnsignedLong(long val, int shift, char[] buf, int offset, int len)
* Invokes Long.fastUUID
*/
void formatUnsignedLong(long val, int shift, char[] buf, int offset, int len);
/**
* Invokes Integer.formatUnsignedInt(long val, int shift, char[] buf, int offset, int len)
*/
void formatUnsignedInt(int val, int shift, char[] buf, int offset, int len);
String fastUUID(long lsb, long msb);
}

View File

@ -23,7 +23,7 @@
* questions.
*/
package sun.misc;
package jdk.internal.ref;
import java.lang.ref.*;
import java.security.AccessController;
@ -58,6 +58,7 @@ import java.security.PrivilegedAction;
public class Cleaner
extends PhantomReference<Object>
implements Runnable
{
// Dummy reference queue, needed because the PhantomReference constructor
@ -153,4 +154,11 @@ public class Cleaner
}
}
@Override public void run() {
SecurityManager security = System.getSecurityManager();
if (security != null)
security.checkPackageAccess("jdk.internal.ref");
this.clean();
}
}

View File

@ -25,7 +25,7 @@
package sun.nio.ch;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
public interface DirectBuffer {

View File

@ -47,7 +47,7 @@ import java.util.List;
import jdk.internal.misc.JavaIOFileDescriptorAccess;
import jdk.internal.misc.JavaNioAccess;
import jdk.internal.misc.SharedSecrets;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
import sun.security.action.GetPropertyAction;
public class FileChannelImpl

View File

@ -26,7 +26,7 @@
package sun.nio.ch;
import java.nio.ByteBuffer;
import sun.misc.*;
import jdk.internal.ref.Cleaner;
/**

View File

@ -33,7 +33,7 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
import jdk.internal.misc.Unsafe;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
import sun.security.action.GetPropertyAction;

View File

@ -26,7 +26,7 @@
package sun.nio.fs;
import jdk.internal.misc.Unsafe;
import sun.misc.Cleaner;
import jdk.internal.ref.Cleaner;
/**
* A light-weight buffer in native memory.

View File

@ -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
@ -653,6 +653,7 @@ public final class ProviderList {
String type = null;
String algorithm;
String provider;
String alternateName = null;
PreferredEntry(String t, String p) {
int i = t.indexOf('.');
@ -664,6 +665,11 @@ public final class ProviderList {
}
provider = p;
if (algorithm.compareToIgnoreCase("SHA1") == 0) {
alternateName = "SHA-1";
} else if (algorithm.compareToIgnoreCase("SHA-1") == 0) {
alternateName = "SHA1";
}
}
boolean match(String t, String a) {
@ -685,6 +691,15 @@ public final class ProviderList {
return true;
}
if (alternateName != null &&
a.compareToIgnoreCase(alternateName) == 0) {
if (debug != null) {
debug.println("Config entry found (alternateName): " +
toString());
}
return true;
}
// No match
return false;
}

View File

@ -109,7 +109,8 @@ security.provider.tbd=sun.security.pkcs11.SunPKCS11
# jdk.security.provider.preferred=AES/GCM/NoPadding:SunJCE, \
# MessageDigest.SHA-256:SUN
#ifdef solaris-sparc
jdk.security.provider.preferred=AES:SunJCE, SHA-256:SUN, SHA-384:SUN, SHA-512:SUN
jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, SHA-224:SUN, \
SHA-256:SUN, SHA-384:SUN, SHA-512:SUN
#endif
#ifdef solaris-x86
jdk.security.provider.preferred=AES:SunJCE, RSA:SunRsaSign

View File

@ -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
@ -210,7 +210,7 @@ static jlong* JIMAGE_FindAttributes(JNIEnv *env, jlong* rawAttributes, jbyte* ra
// Locate resource location data.
ImageLocation location;
bool found = reader->find_location(path, location);
delete path;
delete[] path;
// Resource not found.
if (!found) return NULL;
// Expand stream into array.

View File

@ -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
@ -86,7 +86,7 @@ void ImageDecompressor::image_decompressor_init() {
}
void ImageDecompressor::image_decompressor_close() {
delete _decompressors;
delete[] _decompressors;
}
/*
@ -135,13 +135,13 @@ void ImageDecompressor::decompress_resource(u1* compressed, u1* uncompressed,
decompressor->decompress_resource(compressed_resource, decompressed_resource,
&_header, strings);
if (compressed_resource_base != compressed) {
delete compressed_resource_base;
delete[] compressed_resource_base;
}
compressed_resource = decompressed_resource;
}
} while (has_header);
memcpy(uncompressed, decompressed_resource, uncompressed_size);
delete decompressed_resource;
delete[] decompressed_resource;
}
// Zip decompressor
@ -190,8 +190,8 @@ void SharedStringDecompressor::decompress_resource(u1* data,
{ // String in Strings table
*uncompressed_resource = 1;
uncompressed_resource += 1;
int i = decompress_int(data);
const char * string = strings->get(i);
int k = decompress_int(data);
const char * string = strings->get(k);
int str_length = (int) strlen(string);
Endian::set_java(uncompressed_resource, str_length);
uncompressed_resource += 2;
@ -241,7 +241,7 @@ void SharedStringDecompressor::decompress_resource(u1* data,
*fullpkg = '/';
memcpy(uncompressed_resource, pkg_base, len);
uncompressed_resource += len;
delete pkg_base;
delete[] pkg_base;
desc_length += len;
} else { // Empty package
// Nothing to do.

View File

@ -39,7 +39,7 @@ import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.CPlatformWindow;
/**
* The <code>Application</code> class allows you to integrate your Java application with the native Mac OS X environment.
* The {@code Application} class allows you to integrate your Java application with the native Mac OS X environment.
* You can provide your Mac OS X users a greatly enhanced experience by implementing a few basic handlers for standard system events.
*
* For example:
@ -142,7 +142,7 @@ public class Application {
/**
* Installs a handler to show a custom About window for your application.
*
* Setting the {@link AboutHandler} to <code>null</code> reverts it to the default Cocoa About window.
* Setting the {@link AboutHandler} to {@code null} reverts it to the default Cocoa About window.
*
* @param aboutHandler the handler to respond to the {@link AboutHandler#handleAbout()} message
* @since Java for Mac OS X 10.6 Update 3
@ -155,7 +155,7 @@ public class Application {
/**
* Installs a handler to create the Preferences menu item in your application's app menu.
*
* Setting the {@link PreferencesHandler} to <code>null</code> will remove the Preferences item from the app menu.
* Setting the {@link PreferencesHandler} to {@code null} will remove the Preferences item from the app menu.
*
* @param preferencesHandler
* @since Java for Mac OS X 10.6 Update 3
@ -167,8 +167,8 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to open a list of files.
* The {@link OpenFilesHandler#openFiles(AppEvent.OpenFilesEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleDocumentTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleDocumentTypes</code> key to your app's Info.plist.
* The {@link OpenFilesHandler#openFiles(AppEvent.OpenFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleDocumentTypes} key to your app's Info.plist.
*
* @param openFileHandler
* @since Java for Mac OS X 10.6 Update 3
@ -180,8 +180,8 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to print a list of files.
* The {@link PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleDocumentTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleDocumentTypes</code> key to your app's Info.plist.
* The {@link PrintFilesHandler#printFiles(AppEvent.PrintFilesEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleDocumentTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleDocumentTypes} key to your app's Info.plist.
*
* @param printFileHandler
* @since Java for Mac OS X 10.6 Update 3
@ -193,10 +193,10 @@ public class Application {
/**
* Installs the handler which is notified when the application is asked to open a URL.
* The {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} notifications are only sent if the Java app is a bundled application, with a <code>CFBundleURLTypes</code> array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleURLTypes</code> key to your app's Info.plist.
* The {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} notifications are only sent if the Java app is a bundled application, with a {@code CFBundleURLTypes} array present in it's Info.plist.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleURLTypes} key to your app's Info.plist.
*
* Setting the handler to <code>null</code> causes all {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be enqueued until another handler is set.
* Setting the handler to {@code null} causes all {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be enqueued until another handler is set.
*
* @param openURIHandler
* @since Java for Mac OS X 10.6 Update 3
@ -209,7 +209,7 @@ public class Application {
/**
* Installs the handler which determines if the application should quit.
* The handler is passed a one-shot {@link QuitResponse} which can cancel or proceed with the quit.
* Setting the handler to <code>null</code> causes all quit requests to directly perform the default {@link QuitStrategy}.
* Setting the handler to {@code null} causes all quit requests to directly perform the default {@link QuitStrategy}.
*
* @param quitHandler the handler that is called when the application is asked to quit
* @since Java for Mac OS X 10.6 Update 3
@ -432,11 +432,11 @@ public class Application {
/**
* Enables the Preferences item in the application menu. The ApplicationListener receives a callback for
* selection of the Preferences item in the application menu only if this is set to <code>true</code>.
* selection of the Preferences item in the application menu only if this is set to {@code true}.
*
* If a Preferences item isn't present, this method adds and enables it.
*
* @param enable specifies whether the Preferences item in the application menu should be enabled (<code>true</code>) or not (<code>false</code>)
* @param enable specifies whether the Preferences item in the application menu should be enabled ({@code true}) or not ({@code false})
*
* @deprecated no replacement
* @since 1.4
@ -449,12 +449,12 @@ public class Application {
/**
* Enables the About item in the application menu. The ApplicationListener receives a callback for
* selection of the About item in the application menu only if this is set to <code>true</code>. Because AWT supplies
* a standard About window when an application may not, by default this is set to <code>true</code>.
* selection of the About item in the application menu only if this is set to {@code true}. Because AWT supplies
* a standard About window when an application may not, by default this is set to {@code true}.
*
* If the About item isn't present, this method adds and enables it.
*
* @param enable specifies whether the About item in the application menu should be enabled (<code>true</code>) or not (<code>false</code>)
* @param enable specifies whether the About item in the application menu should be enabled ({@code true}) or not ({@code false})
*
* @deprecated no replacement
* @since 1.4
@ -553,7 +553,7 @@ public class Application {
}
/**
* @deprecated Use <code>java.awt.MouseInfo.getPointerInfo().getLocation()</code>.
* @deprecated Use {@code java.awt.MouseInfo.getPointerInfo().getLocation()}.
*
* @since 1.4
*/

View File

@ -26,7 +26,7 @@
package com.apple.eawt;
/**
* An abstract adapter class for receiving <code>ApplicationEvents</code>.
* An abstract adapter class for receiving {@code ApplicationEvents}.
*
* ApplicationEvents are deprecated. Use individual app event listeners or handlers instead.
*

View File

@ -50,9 +50,9 @@ public class ApplicationEvent extends EventObject {
/**
* Determines whether an ApplicationListener has acted on a particular event.
* An event is marked as having been handled with <code>setHandled(true)</code>.
* An event is marked as having been handled with {@code setHandled(true)}.
*
* @return <code>true</code> if the event has been handled, otherwise <code>false</code>
* @return {@code true} if the event has been handled, otherwise {@code false}
*
* @since 1.4
* @deprecated
@ -65,10 +65,10 @@ public class ApplicationEvent extends EventObject {
/**
* Marks the event as handled.
* After this method handles an ApplicationEvent, it may be useful to specify that it has been handled.
* This is usually used in conjunction with <code>getHandled()</code>.
* Set to <code>true</code> to designate that this event has been handled. By default it is <code>false</code>.
* This is usually used in conjunction with {@code getHandled()}.
* Set to {@code true} to designate that this event has been handled. By default it is {@code false}.
*
* @param state <code>true</code> if the event has been handled, otherwise <code>false</code>.
* @param state {@code true} if the event has been handled, otherwise {@code false}.
*
* @since 1.4
* @deprecated
@ -84,7 +84,7 @@ public class ApplicationEvent extends EventObject {
* For example, the Print and Open events refer to specific files.
* For these cases, this returns the appropriate file name.
*
* @return the full path to the file associated with the event, if applicable, otherwise <code>null</code>
* @return the full path to the file associated with the event, if applicable, otherwise {@code null}
*
* @since 1.4
* @deprecated use {@link OpenFilesHandler} or {@link PrintFilesHandler} instead

View File

@ -53,9 +53,9 @@ import java.util.EventListener;
@Deprecated
public interface ApplicationListener extends EventListener {
/**
* Called when the user selects the About item in the application menu. If <code>event</code> is not handled by
* setting <code>isHandled(true)</code>, a default About window consisting of the application's name and icon is
* displayed. To display a custom About window, designate the <code>event</code> as being handled and display the
* Called when the user selects the About item in the application menu. If {@code event} is not handled by
* setting {@code isHandled(true)}, a default About window consisting of the application's name and icon is
* displayed. To display a custom About window, designate the {@code event} as being handled and display the
* appropriate About window.
*
* @param event an ApplicationEvent initiated by the user choosing About in the application menu
@ -99,7 +99,7 @@ public interface ApplicationListener extends EventListener {
* Called when the Preference item in the application menu is selected. Native Mac OS X applications make their
* Preferences window available through the application menu. Java applications are automatically given an application
* menu in Mac OS X. By default, the Preferences item is disabled in that menu. If you are deploying an application
* on Mac OS X, you should enable the preferences item with <code>setEnabledPreferencesMenu(true)</code> in the
* on Mac OS X, you should enable the preferences item with {@code setEnabledPreferencesMenu(true)} in the
* Application object and then display your Preferences window in this handler.
*
* @param event triggered when the user selects Preferences from the application menu
@ -130,8 +130,8 @@ public interface ApplicationListener extends EventListener {
* application menu, when the user types Command-Q, or when the user control clicks on your application icon in the
* Dock and chooses Quit. You can either accept or reject the request to quit. You might want to reject the request
* to quit if the user has unsaved work. Reject the request, move into your code to save changes, then quit your
* application. To accept the request to quit, and terminate the application, set <code>isHandled(true)</code> for the
* <code>event</code>. To reject the quit, set <code>isHandled(false)</code>.
* application. To accept the request to quit, and terminate the application, set {@code isHandled(true)} for the
* {@code event}. To reject the quit, set {@code isHandled(false)}.
*
* @param event a Quit Application event
* @deprecated use {@link QuitHandler} and {@link QuitResponse}

View File

@ -29,8 +29,8 @@ import com.apple.eawt.AppEvent.OpenURIEvent;
/**
* An implementor is notified when the application is asked to open a URI.
* The application only sends {@link com.apple.eawt.EAWTEvent.OpenURIEvent}s when it has been launched as a bundled Mac application, and it's Info.plist claims URL schemes in it's <code>CFBundleURLTypes</code> entry.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a <code>CFBundleURLTypes</code> key to your app's Info.plist.
* The application only sends {@link com.apple.eawt.EAWTEvent.OpenURIEvent}s when it has been launched as a bundled Mac application, and it's Info.plist claims URL schemes in it's {@code CFBundleURLTypes} entry.
* See the <a href="http://developer.apple.com/mac/library/documentation/General/Reference/InfoPlistKeyReference">Info.plist Key Reference</a> for more information about adding a {@code CFBundleURLTypes} key to your app's Info.plist.
*
* @see Application#setOpenURIHandler(OpenURIHandler)
*

View File

@ -38,7 +38,7 @@ package com.apple.eawt;
*/
public enum QuitStrategy {
/**
* Shuts down the application by calling <code>System.exit(0)</code>. This is the default strategy.
* Shuts down the application by calling {@code System.exit(0)}. This is the default strategy.
*/
SYSTEM_EXIT_0,

View File

@ -32,19 +32,19 @@ import java.io.*;
* attributes. These attributes in turn are dependent on HFS and HFS+ file systems. As such, it is important to recognize
* their limitation when writing code that must function well across multiple platforms.<p>
*
* In addition to file name suffixes, Mac OS X can use Finder attributes like file <code>type</code> and <code>creator</code> codes to
* identify and handle files. These codes are unique 4-byte identifiers. The file <code>type</code> is a string that describes the
* contents of a file. For example, the file type <code>APPL</code> identifies the file as an application and therefore
* executable. A file type of <code>TEXT</code> means that the file contains raw text. Any application that can read raw
* text can open a file of type <code>TEXT</code>. Applications that use proprietary file types might assign their files a proprietary
* file <code>type</code> code.
* In addition to file name suffixes, Mac OS X can use Finder attributes like file {@code type} and {@code creator} codes to
* identify and handle files. These codes are unique 4-byte identifiers. The file {@code type} is a string that describes the
* contents of a file. For example, the file type {@code APPL} identifies the file as an application and therefore
* executable. A file type of {@code TEXT} means that the file contains raw text. Any application that can read raw
* text can open a file of type {@code TEXT}. Applications that use proprietary file types might assign their files a proprietary
* file {@code type} code.
* <p>
* To identify the application that can handle a document, the Finder can look at the <code>creator</code>. For example, if a user
* double-clicks on a document with the <code>ttxt</code> <code>creator</code>, it opens up in Text Edit, the application registered
* with the <code>ttxt</code> <code>creator</code> code. Note that the <code>creator</code>
* To identify the application that can handle a document, the Finder can look at the {@code creator}. For example, if a user
* double-clicks on a document with the {@code ttxt creator}, it opens up in Text Edit, the application registered
* with the {@code ttxt creator} code. Note that the {@code creator}
* code can be set to any application, not necessarily the application that created it. For example, if you
* use an editor to create an HTML document, you might want to assign a browser's <code>creator</code> code for the file rather than
* the HTML editor's <code>creator</code> code. Double-clicking on the document then opens the appropriate browser rather than the
* use an editor to create an HTML document, you might want to assign a browser's {@code creator} code for the file rather than
* the HTML editor's {@code creator} code. Double-clicking on the document then opens the appropriate browser rather than the
*HTML editor.
*<p>
* If you plan to publicly distribute your application, you must register its creator and any proprietary file types with the Apple
@ -126,7 +126,7 @@ public class FileManager {
}
/**
* Sets the file <code>type</code> and <code>creator</code> codes for a file or folder.
* Sets the file {@code type} and {@code creator} codes for a file or folder.
*
* @since 1.4
*/
@ -140,7 +140,7 @@ public class FileManager {
private static native void _setFileTypeAndCreator(String filename, int type, int creator) throws IOException;
/**
* Sets the file <code>type</code> code for a file or folder.
* Sets the file {@code type} code for a file or folder.
*
* @since 1.4
*/
@ -154,7 +154,7 @@ public class FileManager {
private static native void _setFileType(String filename, int type) throws IOException;
/**
* Sets the file <code>creator</code> code for a file or folder.
* Sets the file {@code creator} code for a file or folder.
*
* @since 1.4
*/
@ -168,7 +168,7 @@ public class FileManager {
private static native void _setFileCreator(String filename, int creator) throws IOException;
/**
* Obtains the file <code>type</code> code for a file or folder.
* Obtains the file {@code type} code for a file or folder.
*
* @since 1.4
*/
@ -182,7 +182,7 @@ public class FileManager {
private static native int _getFileType(String filename) throws IOException;
/**
* Obtains the file <code>creator</code> code for a file or folder.
* Obtains the file {@code creator} code for a file or folder.
*
* @since 1.4
*/
@ -200,11 +200,11 @@ public class FileManager {
* Locates a folder of a particular type. Mac OS X recognizes certain specific folders that have distinct purposes.
* For example, the user's desktop or temporary folder. These folders have corresponding codes. Given one of these codes,
* this method returns the path to that particular folder. Certain folders of a given type may appear in more than
* one domain. For example, although there is only one <code>root</code> folder, there are multiple <code>pref</code>
* folders. If this method is called to find the <code>pref</code> folder, it will return the first one it finds,
* the user's preferences folder in <code>~/Library/Preferences</code>. To explicitly locate a folder in a certain
* domain use <code>findFolder(short domain, int folderType)</code> or <code>findFolder(short domain, int folderType,
* boolean createIfNeeded)</code>.
* one domain. For example, although there is only one {@code root} folder, there are multiple {@code pref}
* folders. If this method is called to find the {@code pref} folder, it will return the first one it finds,
* the user's preferences folder in {@code ~/Library/Preferences}. To explicitly locate a folder in a certain
* domain use {@code findFolder(short domain, int folderType)} or
* {@code findFolder(short domain, int folderType, boolean createIfNeeded)}.
*
* @return the path to the folder searched for
*
@ -215,8 +215,8 @@ public class FileManager {
}
/**
* Locates a folder of a particular type, within a given domain. Similar to <code>findFolder(int folderType)</code>
* except that the domain to look in can be specified. Valid values for <code>domain</code>include:
* Locates a folder of a particular type, within a given domain. Similar to {@code findFolder(int folderType)}
* except that the domain to look in can be specified. Valid values for {@code domain} include:
* <dl>
* <dt>user</dt>
* <dd>The User domain contains resources specific to the user who is currently logged in</dd>
@ -239,12 +239,12 @@ public class FileManager {
/**
* Locates a folder of a particular type within a given domain and optionally creating the folder if it does
* not exist. The behavior is similar to <code>findFolder(int folderType)</code> and
* <code>findFolder(short domain, int folderType)</code> except that it can create the folder if it does not already exist.
* not exist. The behavior is similar to {@code findFolder(int folderType)} and
* {@code findFolder(short domain, int folderType)} except that it can create the folder if it does not already exist.
*
* @param createIfNeeded
* set to <code>true</code>, by setting to <code>false</code> the behavior will be the
* same as <code>findFolder(short domain, int folderType, boolean createIfNeeded)</code>
* set to {@code true}, by setting to {@code false} the behavior will be the
* same as {@code findFolder(short domain, int folderType, boolean createIfNeeded)}
* @return the path to the folder searched for
*
* @since 1.4
@ -263,9 +263,9 @@ public class FileManager {
/**
* Opens the path specified by a URL in the appropriate application for that URL. HTTP URL's (<code>http://</code>)
* open in the default browser as set in the Internet pane of System Preferences. File (<code>file://</code>) and
* FTP URL's (<code>ftp://</code>) open in the Finder. Note that opening an FTP URL will prompt the user for where
* Opens the path specified by a URL in the appropriate application for that URL. HTTP URL's ({@code http://})
* open in the default browser as set in the Internet pane of System Preferences. File ({@code file://}) and
* FTP URL's ({@code ftp://}) open in the Finder. Note that opening an FTP URL will prompt the user for where
* they want to save the downloaded file(s).
*
* @param url

View File

@ -26,6 +26,7 @@
package com.apple.laf;
import java.awt.ComponentOrientation;
import java.beans.*;
import java.io.File;
import java.util.*;
@ -85,6 +86,15 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
} else if (prop == JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY) {
invalidateFileCache();
validateFileCache();
} else if (prop.equals("componentOrientation")) {
ComponentOrientation o = (ComponentOrientation) e.getNewValue();
JFileChooser cc = (JFileChooser) e.getSource();
if (o != e.getOldValue()) {
cc.applyComponentOrientation(o);
}
fFileList.setComponentOrientation(o);
fFileList.getParent().getParent().setComponentOrientation(o);
}
if (prop == SORT_BY_CHANGED) {// $ Ought to just resort
fSortNames = (((Integer)e.getNewValue()).intValue() == 0);

View File

@ -105,7 +105,9 @@ public class AquaInternalFrameManager extends DefaultDesktopManager {
// Position depends on *current* position of frame, unlike super which reuses the first position
final Rectangle r = getBoundsForIconOf(f);
desktopIcon.setBounds(r.x, r.y, r.width, r.height);
if (!wasIcon(f)) {
setWasIcon(f, Boolean.TRUE);
}
c = f.getParent();
if (c == null) return;

View File

@ -295,9 +295,9 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo
}
/**
* Installs necessary mouse handlers on <code>newPane</code>
* Installs necessary mouse handlers on {@code newPane}
* and adds it to the frame.
* Reverse process for the <code>currentPane</code>.
* Reverse process for the {@code currentPane}.
*/
@Override
protected void replacePane(final JComponent currentPane, final JComponent newPane) {

View File

@ -82,9 +82,9 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
}
/**
* Returns true if the <code>LookAndFeel</code> returned
* <code>RootPaneUI</code> instances support providing Window decorations
* in a <code>JRootPane</code>.
* Returns true if the {@code LookAndFeel} returned
* {@code RootPaneUI} instances support providing Window decorations
* in a {@code JRootPane}.
* <p>
* The default implementation returns false, subclasses that support
* Window decorations should override this and return true.
@ -174,20 +174,20 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
}
/**
* Returns an <code>ActionMap</code>.
* Returns an {@code ActionMap}.
* <P>
* This <code>ActionMap</code> contains <code>Actions</code> that
* This {@code ActionMap} contains {@code Actions} that
* embody the ability to render an auditory cue. These auditory
* cues map onto user and system activities that may be useful
* for an end user to know about (such as a dialog box appearing).
* <P>
* At the appropriate time in a <code>JComponent</code> UI's lifecycle,
* At the appropriate time in a {@code JComponent} UI's lifecycle,
* the ComponentUI is responsible for getting the appropriate
* <code>Action</code> out of the <code>ActionMap</code> and passing
* it on to <code>playSound</code>.
* {@code Action} out of the {@code ActionMap} and passing
* it on to {@code playSound}.
* <P>
* The <code>Actions</code> in this <code>ActionMap</code> are
* created by the <code>createAudioAction</code> method.
* The {@code Actions} in this {@code ActionMap} are
* created by the {@code createAudioAction} method.
*
* @return an ActionMap containing Actions
* responsible for rendering auditory cues

View File

@ -47,7 +47,7 @@ public class AquaOptionPaneUI extends BasicOptionPaneUI {
/**
* Creates and returns a Container containin the buttons. The buttons
* are created by calling <code>getButtons</code>.
* are created by calling {@code getButtons}.
*/
protected Container createButtonArea() {
final Container bottom = super.createButtonArea();
@ -141,5 +141,27 @@ public class AquaOptionPaneUI extends BasicOptionPaneUI {
xLocation += xOffset;
}
}
@Override
public Dimension minimumLayoutSize(Container c) {
if (c != null) {
Component[] children = c.getComponents();
if (children != null && children.length > 0) {
int numChildren = children.length;
Insets cInsets = c.getInsets();
int extraHeight = cInsets.top + cInsets.bottom;
int extraWidth = cInsets.left + cInsets.right;
int okCancelButtonWidth = extraWidth
+ (kOKCancelButtonWidth * numChildren)
+ (numChildren - 1) * padding;
int okbuttonHeight = extraHeight + kButtonHeight;
Dimension minSize = super.minimumLayoutSize(c);
return new Dimension(Math.max(minSize.width,
okCancelButtonWidth),
Math.max(minSize.height, okbuttonHeight));
}
}
return new Dimension(0, 0);
}
}
}

View File

@ -180,10 +180,19 @@ public class AquaProgressBarUI extends ProgressBarUI implements ChangeListener,
final int width = progressBar.getWidth() - (i.right + i.left);
final int height = progressBar.getHeight() - (i.bottom + i.top);
Graphics2D g2 = (Graphics2D) g;
final AffineTransform savedAT = g2.getTransform();
if (!progressBar.getComponentOrientation().isLeftToRight()) {
//Scale operation: Flips component about pivot
//Translate operation: Moves component back into original position
g2.scale(-1, 1);
g2.translate(-progressBar.getWidth(), 0);
}
painter.paint(g, progressBar, i.left, i.top, width, height);
g2.setTransform(savedAT);
if (progressBar.isStringPainted() && !progressBar.isIndeterminate()) {
paintString(g, i.left, i.top, width, height);
paintString(g, i.left, i.top, width, height);
}
}

View File

@ -164,7 +164,7 @@ public class AquaRootPaneUI extends BasicRootPaneUI implements AncestorListener,
/**
* Invoked when a property changes on the root pane. If the event
* indicates the <code>defaultButton</code> has changed, this will
* indicates the {@code defaultButton} has changed, this will
* update the animation.
* If the enabled state changed, it will start or stop the animation
*/

View File

@ -22,7 +22,6 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.apple.laf;
import java.awt.*;
@ -45,33 +44,37 @@ import com.apple.laf.AquaUtils.RecyclableSingleton;
import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor;
/**
* This is originally derived from BasicSpinnerUI, but they made everything private
* so we can't subclass!
* This is originally derived from BasicSpinnerUI, but they made everything
* private so we can't subclass!
*/
public class AquaSpinnerUI extends SpinnerUI {
private static final RecyclableSingleton<? extends PropertyChangeListener> propertyChangeListener
= new RecyclableSingletonFromDefaultConstructor<>(PropertyChangeHandler.class);
static PropertyChangeListener getPropertyChangeListener() {
return propertyChangeListener.get();
}
private static final RecyclableSingleton<ArrowButtonHandler> nextButtonHandler
= new RecyclableSingleton<ArrowButtonHandler>() {
@Override
protected ArrowButtonHandler getInstance() {
return new ArrowButtonHandler("increment", true);
}
};
@Override
protected ArrowButtonHandler getInstance() {
return new ArrowButtonHandler("increment", true);
}
};
static ArrowButtonHandler getNextButtonHandler() {
return nextButtonHandler.get();
}
private static final RecyclableSingleton<ArrowButtonHandler> previousButtonHandler
= new RecyclableSingleton<ArrowButtonHandler>() {
@Override
protected ArrowButtonHandler getInstance() {
return new ArrowButtonHandler("decrement", false);
}
};
@Override
protected ArrowButtonHandler getInstance() {
return new ArrowButtonHandler("decrement", false);
}
};
static ArrowButtonHandler getPreviousButtonHandler() {
return previousButtonHandler.get();
}
@ -92,9 +95,10 @@ public class AquaSpinnerUI extends SpinnerUI {
}
boolean wasOpaque;
@Override
public void installUI(final JComponent c) {
this.spinner = (JSpinner)c;
this.spinner = (JSpinner) c;
installDefaults();
installListeners();
next = createNextButton();
@ -110,8 +114,7 @@ public class AquaSpinnerUI extends SpinnerUI {
installKeyboardActions();
// this doesn't work because JSpinner calls setOpaque(true) directly in it's constructor
// LookAndFeel.installProperty(spinner, "opaque", Boolean.FALSE);
// LookAndFeel.installProperty(spinner, "opaque", Boolean.FALSE);
// ...so we have to handle the is/was opaque ourselves
wasOpaque = spinner.isOpaque();
spinner.setOpaque(false);
@ -208,6 +211,7 @@ public class AquaSpinnerUI extends SpinnerUI {
@SuppressWarnings("serial") // Superclass is not serializable across versions
class TransparentButton extends JButton implements SwingConstants {
boolean interceptRepaints = false;
public TransparentButton() {
@ -219,14 +223,17 @@ public class AquaSpinnerUI extends SpinnerUI {
}
@Override
public void paint(final Graphics g) {}
public void paint(final Graphics g) {
}
@Override
public void repaint() {
// only intercept repaints if we are after this has been initialized
// otherwise we can't talk to our containing class
if (interceptRepaints) {
if (spinPainter == null) return;
if (spinPainter == null) {
return;
}
spinPainter.repaint();
}
super.repaint();
@ -246,7 +253,9 @@ public class AquaSpinnerUI extends SpinnerUI {
}
protected void fixupEditor(final JComponent editor) {
if (!(editor instanceof DefaultEditor)) return;
if (!(editor instanceof DefaultEditor)) {
return;
}
editor.setOpaque(false);
editor.setInheritsPopupMenu(true);
@ -255,7 +264,7 @@ public class AquaSpinnerUI extends SpinnerUI {
editor.setFont(new FontUIResource(spinner.getFont()));
}
final JFormattedTextField editorTextField = ((DefaultEditor)editor).getTextField();
final JFormattedTextField editorTextField = ((DefaultEditor) editor).getTextField();
if (editorTextField.getFont() instanceof UIResource) {
editorTextField.setFont(new FontUIResource(spinner.getFont()));
}
@ -277,7 +286,7 @@ public class AquaSpinnerUI extends SpinnerUI {
child.setEnabled(enabled);
if (child instanceof Container) {
updateEnabledState((Container)child, enabled);
updateEnabledState((Container) child, enabled);
}
}
}
@ -290,13 +299,13 @@ public class AquaSpinnerUI extends SpinnerUI {
private InputMap getInputMap(final int condition) {
if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
return (InputMap)UIManager.get("Spinner.ancestorInputMap");
return (InputMap) UIManager.get("Spinner.ancestorInputMap");
}
return null;
}
private ActionMap getActionMap() {
ActionMap map = (ActionMap)UIManager.get("Spinner.actionMap");
ActionMap map = (ActionMap) UIManager.get("Spinner.actionMap");
if (map == null) {
map = createActionMap();
@ -316,6 +325,7 @@ public class AquaSpinnerUI extends SpinnerUI {
@SuppressWarnings("serial") // Superclass is not serializable across versions
private static class ArrowButtonHandler extends AbstractAction implements MouseListener {
final javax.swing.Timer autoRepeatTimer;
final boolean isNext;
JSpinner spinner = null;
@ -330,9 +340,9 @@ public class AquaSpinnerUI extends SpinnerUI {
private JSpinner eventToSpinner(final AWTEvent e) {
Object src = e.getSource();
while ((src instanceof Component) && !(src instanceof JSpinner)) {
src = ((Component)src).getParent();
src = ((Component) src).getParent();
}
return (src instanceof JSpinner) ? (JSpinner)src : null;
return (src instanceof JSpinner) ? (JSpinner) src : null;
}
@Override
@ -342,13 +352,15 @@ public class AquaSpinnerUI extends SpinnerUI {
spinner = eventToSpinner(e);
}
if (spinner == null) return;
if (spinner == null) {
return;
}
try {
final int calendarField = getCalendarField(spinner);
spinner.commitEdit();
if (calendarField != -1) {
((SpinnerDateModel)spinner.getModel()).setCalendarField(calendarField);
((SpinnerDateModel) spinner.getModel()).setCalendarField(calendarField);
}
final Object value = (isNext) ? spinner.getNextValue() : spinner.getPreviousValue();
if (value != null) {
@ -368,37 +380,46 @@ public class AquaSpinnerUI extends SpinnerUI {
*/
private void select(final JSpinner spinnerComponent) {
final JComponent editor = spinnerComponent.getEditor();
if (!(editor instanceof JSpinner.DateEditor)) return;
if (!(editor instanceof JSpinner.DateEditor)) {
return;
}
final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor) editor;
final JFormattedTextField ftf = dateEditor.getTextField();
final Format format = dateEditor.getFormat();
Object value;
if (format == null || (value = spinnerComponent.getValue()) == null) return;
if (format == null || (value = spinnerComponent.getValue()) == null) {
return;
}
final SpinnerDateModel model = dateEditor.getModel();
final DateFormat.Field field = DateFormat.Field.ofCalendarField(model.getCalendarField());
if (field == null) return;
if (field == null) {
return;
}
try {
final AttributedCharacterIterator iterator = format.formatToCharacterIterator(value);
if (!select(ftf, iterator, field) && field == DateFormat.Field.HOUR0) {
select(ftf, iterator, DateFormat.Field.HOUR1);
}
} catch (final IllegalArgumentException iae) {}
} catch (final IllegalArgumentException iae) {
}
}
/**
* Selects the passed in field, returning true if it is found,
* false otherwise.
* Selects the passed in field, returning true if it is found, false
* otherwise.
*/
private boolean select(final JFormattedTextField ftf, final AttributedCharacterIterator iterator, final DateFormat.Field field) {
final int max = ftf.getDocument().getLength();
iterator.first();
do {
final Map<Attribute,Object> attrs = iterator.getAttributes();
if (attrs == null || !attrs.containsKey(field)) continue;
final Map<Attribute, Object> attrs = iterator.getAttributes();
if (attrs == null || !attrs.containsKey(field)) {
continue;
}
final int start = iterator.getRunStart(field);
final int end = iterator.getRunLimit(field);
@ -412,29 +433,35 @@ public class AquaSpinnerUI extends SpinnerUI {
}
/**
* Returns the calendarField under the start of the selection, or
* -1 if there is no valid calendar field under the selection (or
* the spinner isn't editing dates.
* Returns the calendarField under the start of the selection, or -1 if
* there is no valid calendar field under the selection (or the spinner
* isn't editing dates.
*/
private int getCalendarField(final JSpinner spinnerComponent) {
final JComponent editor = spinnerComponent.getEditor();
if (!(editor instanceof JSpinner.DateEditor)) return -1;
if (!(editor instanceof JSpinner.DateEditor)) {
return -1;
}
final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor)editor;
final JSpinner.DateEditor dateEditor = (JSpinner.DateEditor) editor;
final JFormattedTextField ftf = dateEditor.getTextField();
final int start = ftf.getSelectionStart();
final JFormattedTextField.AbstractFormatter formatter = ftf.getFormatter();
if (!(formatter instanceof InternationalFormatter)) return -1;
if (!(formatter instanceof InternationalFormatter)) {
return -1;
}
final Format.Field[] fields = ((InternationalFormatter)formatter).getFields(start);
final Format.Field[] fields = ((InternationalFormatter) formatter).getFields(start);
for (final Field element : fields) {
if (!(element instanceof DateFormat.Field)) continue;
if (!(element instanceof DateFormat.Field)) {
continue;
}
int calendarField;
if (element == DateFormat.Field.HOUR1) {
calendarField = Calendar.HOUR;
} else {
calendarField = ((DateFormat.Field)element).getCalendarField();
calendarField = ((DateFormat.Field) element).getCalendarField();
}
if (calendarField != -1) {
@ -446,7 +473,9 @@ public class AquaSpinnerUI extends SpinnerUI {
@Override
public void mousePressed(final MouseEvent e) {
if (!SwingUtilities.isLeftMouseButton(e) || !e.getComponent().isEnabled()) return;
if (!SwingUtilities.isLeftMouseButton(e) || !e.getComponent().isEnabled()) {
return;
}
spinner = eventToSpinner(e);
autoRepeatTimer.start();
@ -460,26 +489,35 @@ public class AquaSpinnerUI extends SpinnerUI {
}
@Override
public void mouseClicked(final MouseEvent e) {}
public void mouseClicked(final MouseEvent e) {
}
@Override
public void mouseEntered(final MouseEvent e) {}
public void mouseEntered(final MouseEvent e) {
}
@Override
public void mouseExited(final MouseEvent e) {}
public void mouseExited(final MouseEvent e) {
}
/**
* Requests focus on a child of the spinner if the spinner doesn't
* have focus.
* Requests focus on a child of the spinner if the spinner doesn't have
* focus.
*/
private void focusSpinnerIfNecessary() {
final Component fo = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
if (!spinner.isRequestFocusEnabled() || (fo != null && (SwingUtilities.isDescendingFrom(fo, spinner)))) return;
if (!spinner.isRequestFocusEnabled() || (fo != null && (SwingUtilities.isDescendingFrom(fo, spinner)))) {
return;
}
Container root = spinner;
if (!root.isFocusCycleRoot()) {
root = root.getFocusCycleRootAncestor();
}
if (root == null) return;
if (root == null) {
return;
}
final FocusTraversalPolicy ftp = root.getFocusTraversalPolicy();
final Component child = ftp.getComponentAfter(root, spinner);
@ -491,6 +529,7 @@ public class AquaSpinnerUI extends SpinnerUI {
@SuppressWarnings("serial") // Superclass is not serializable across versions
class SpinPainter extends JComponent {
final AquaPainter<JRSUIState> painter = AquaPainter.create(JRSUIStateFactory.getSpinnerArrows());
ButtonModel fTopModel;
@ -551,11 +590,12 @@ public class AquaSpinnerUI extends SpinnerUI {
}
/**
* A simple layout manager for the editor and the next/previous buttons.
* See the AquaSpinnerUI javadoc for more information about exactly
* how the components are arranged.
* A simple layout manager for the editor and the next/previous buttons. See
* the AquaSpinnerUI javadoc for more information about exactly how the
* components are arranged.
*/
static class SpinnerLayout implements LayoutManager {
private Component nextButton = null;
private Component previousButton = null;
private Component editor = null;
@ -656,26 +696,38 @@ public class AquaSpinnerUI extends SpinnerUI {
}
/**
* Detect JSpinner property changes we're interested in and delegate. Subclasses
* shouldn't need to replace the default propertyChangeListener (although they
* can by overriding createPropertyChangeListener) since all of the interesting
* property changes are delegated to protected methods.
* Detect JSpinner property changes we're interested in and delegate.
* Subclasses shouldn't need to replace the default propertyChangeListener
* (although they can by overriding createPropertyChangeListener) since all
* of the interesting property changes are delegated to protected methods.
*/
static class PropertyChangeHandler implements PropertyChangeListener {
@Override
public void propertyChange(final PropertyChangeEvent e) {
final String propertyName = e.getPropertyName();
final JSpinner spinner = (JSpinner)(e.getSource());
final JSpinner spinner = (JSpinner) (e.getSource());
final SpinnerUI spinnerUI = spinner.getUI();
if (spinnerUI instanceof AquaSpinnerUI) {
final AquaSpinnerUI ui = (AquaSpinnerUI)spinnerUI;
final AquaSpinnerUI ui = (AquaSpinnerUI) spinnerUI;
if ("editor".equals(propertyName)) {
final JComponent oldEditor = (JComponent)e.getOldValue();
final JComponent newEditor = (JComponent)e.getNewValue();
final JComponent oldEditor = (JComponent) e.getOldValue();
final JComponent newEditor = (JComponent) e.getNewValue();
ui.replaceEditor(oldEditor, newEditor);
ui.updateEnabledState();
} else if ("componentOrientation".equals(propertyName)) {
ComponentOrientation o
= (ComponentOrientation) e.getNewValue();
if (o != e.getOldValue()) {
JComponent editor = spinner.getEditor();
if (editor != null) {
editor.applyComponentOrientation(o);
}
spinner.revalidate();
spinner.repaint();
}
} else if ("enabled".equals(propertyName)) {
ui.updateEnabledState();
} else if (JComponent.TOOL_TIP_TEXT_KEY.equals(propertyName)) {
@ -683,8 +735,8 @@ public class AquaSpinnerUI extends SpinnerUI {
} else if ("font".equals(propertyName)) {
JComponent editor = spinner.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
JTextField tf =
((JSpinner.DefaultEditor) editor).getTextField();
JTextField tf
= ((JSpinner.DefaultEditor) editor).getTextField();
if (tf != null) {
if (tf.getFont() instanceof UIResource) {
tf.setFont(new FontUIResource(spinner.getFont()));
@ -703,12 +755,12 @@ public class AquaSpinnerUI extends SpinnerUI {
final Component[] children = spinnerComponent.getComponents();
for (final Component element : children) {
if (element instanceof JSpinner.DefaultEditor) {
final JTextField tf = ((JSpinner.DefaultEditor)element).getTextField();
final JTextField tf = ((JSpinner.DefaultEditor) element).getTextField();
if (tf != null) {
tf.setToolTipText(toolTipText);
}
} else if (element instanceof JComponent) {
((JComponent)element).setToolTipText(toolTipText);
((JComponent) element).setToolTipText(toolTipText);
}
}
}

View File

@ -235,9 +235,9 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
}
/**
* Invoked by <code>installUI</code> to create
* Invoked by {@code installUI} to create
* a layout manager object to manage
* the <code>JTabbedPane</code>.
* the {@code JTabbedPane}.
*
* @return a layout manager object
*
@ -536,7 +536,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
/**
* Sets the tab the mouse is over by location. This is a cover method
* for <code>setRolloverTab(tabForCoordinate(x, y, false))</code>.
* for {@code setRolloverTab(tabForCoordinate(x, y, false))}.
*/
private void setRolloverTab(final int x, final int y) {
// NOTE:
@ -547,8 +547,8 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
}
/**
* Sets the tab the mouse is currently over to <code>index</code>.
* <code>index</code> will be -1 if the mouse is no longer over any
* Sets the tab the mouse is currently over to {@code index}.
* {@code index} will be -1 if the mouse is no longer over any
* tab. No checking is done to ensure the passed in index identifies a
* valid tab.
*
@ -676,7 +676,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
/**
* Returns the amount the baseline is offset by. This is typically
* the same as <code>getTabLabelShiftY</code>.
* the same as {@code getTabLabelShiftY}.
*
* @return amount to offset the baseline by
* @since 1.6
@ -765,10 +765,10 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
/**
* Paints the tabs in the tab area.
* Invoked by paint().
* The graphics parameter must be a valid <code>Graphics</code>
* The graphics parameter must be a valid {@code Graphics}
* object. Tab placement may be either:
* <code>JTabbedPane.TOP</code>, <code>JTabbedPane.BOTTOM</code>,
* <code>JTabbedPane.LEFT</code>, or <code>JTabbedPane.RIGHT</code>.
* {@code JTabbedPane.TOP}, {@code JTabbedPane.BOTTOM},
* {@code JTabbedPane.LEFT}, or {@code JTabbedPane.RIGHT}.
* The selected index must be a valid tabbed pane tab index (0 to
* tab count - 1, inclusive) or -1 if no tab is currently selected.
* The handling of invalid parameters is unspecified.
@ -1406,7 +1406,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
* designated Rectangle object (rather than instantiating and returning
* a new Rectangle each time). The tab index parameter must be a valid
* tabbed pane tab index (0 to tab count - 1, inclusive). The destination
* rectangle parameter must be a valid <code>Rectangle</code> instance.
* rectangle parameter must be a valid {@code Rectangle} instance.
* The handling of invalid parameters is unspecified.
*
* @param tabIndex the index of the tab
@ -3717,7 +3717,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
/**
* An ActionMap that populates its contents as necessary. The
* contents are populated by invoking the <code>loadActionMap</code>
* contents are populated by invoking the {@code loadActionMap}
* method on the passed in Object.
*
* @version 1.6, 11/17/05
@ -3726,14 +3726,14 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
@SuppressWarnings("serial") // Superclass is not serializable across versions
static class LazyActionMap extends ActionMapUIResource {
/**
* Object to invoke <code>loadActionMap</code> on. This may be
* Object to invoke {@code loadActionMap} on. This may be
* a Class object.
*/
private transient Object _loader;
/**
* Installs an ActionMap that will be populated by invoking the
* <code>loadActionMap</code> method on the specified Class
* {@code loadActionMap} method on the specified Class
* when necessary.
* <p>
* This should be used if the ActionMap can be shared.
@ -3755,7 +3755,7 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
/**
* Returns an ActionMap that will be populated by invoking the
* <code>loadActionMap</code> method on the specified Class
* {@code loadActionMap} method on the specified Class
* when necessary.
* <p>
* This should be used if the ActionMap can be shared.

View File

@ -179,8 +179,8 @@ public class AquaTreeUI extends BasicTreeUI {
}
/**
* Paints the expand (toggle) part of a row. The receiver should NOT modify <code>clipBounds</code>, or
* <code>insets</code>.
* Paints the expand (toggle) part of a row. The receiver should NOT modify {@code clipBounds}, or
* {@code insets}.
*/
protected void paintExpandControl(final Graphics g, final Rectangle clipBounds, final Insets insets, final Rectangle bounds, final TreePath path, final int row, final boolean isExpanded, final boolean hasBeenExpanded, final boolean isLeaf) {
final Object value = path.getLastPathComponent();

View File

@ -41,7 +41,7 @@ public class NativeFont extends PhysicalFont {
/**
* Verifies native font is accessible.
* @throws FontFormatException - if the font can't be located.
* @throws FontFormatException if the font can't be located.
*/
public NativeFont(String platName, boolean isBitmapDelegate)
throws FontFormatException {

View File

@ -37,10 +37,10 @@ public final class DataBufferNIOInt extends DataBuffer {
IntBuffer bankdata[];
/**
* Constructs an integer-based <CODE>DataBuffer</CODE> with a single bank
* Constructs an integer-based {@code DataBuffer} with a single bank
* and the specified size.
*
* @param size The size of the <CODE>DataBuffer</CODE>.
* @param size The size of the {@code DataBuffer}.
*/
public DataBufferNIOInt(int size) {
super(TYPE_INT,size);
@ -51,7 +51,7 @@ public final class DataBufferNIOInt extends DataBuffer {
}
/**
* Returns the default (first) IntBuffer in <CODE>DataBuffer</CODE>.
* Returns the default (first) IntBuffer in {@code DataBuffer}.
*
* @return The first IntBuffer.
*/
@ -70,7 +70,7 @@ public final class DataBufferNIOInt extends DataBuffer {
}
/**
* Returns the default (first) int data array in <CODE>DataBuffer</CODE>.
* Returns the default (first) int data array in {@code DataBuffer}.
*
* @return The first integer data array.
*/
@ -137,7 +137,7 @@ public final class DataBufferNIOInt extends DataBuffer {
/**
* Sets the requested data array element in the specified bank
* to the integer value <CODE>i</CODE>.
* to the integer value {@code i}.
* @param bank The bank in which you want to set the data array element.
* @param i The data array element you want to set.
* @param val The integer value to which you want to set the specified data array element.

View File

@ -33,7 +33,7 @@ import java.net.URI;
/**
* Concrete implementation of the interface <code>DesktopPeer</code> for MacOS X
* Concrete implementation of the interface {@code DesktopPeer} for MacOS X
*
* @see DesktopPeer
*/

View File

@ -101,7 +101,7 @@ public class CInputMethod extends InputMethodAdapter {
* method.
*
* @param context the input method context for this input method
* @exception NullPointerException if <code>context</code> is null
* @exception NullPointerException if {@code context} is null
*/
public void setInputMethodContext(InputMethodContext context) {
fIMContext = context;
@ -124,7 +124,7 @@ public class CInputMethod extends InputMethodAdapter {
*
* @param lang locale to input
* @return whether the specified locale is supported
* @exception NullPointerException if <code>locale</code> is null
* @exception NullPointerException if {@code locale} is null
*/
public boolean setLocale(Locale lang) {
return setLocale(lang, false);
@ -205,7 +205,7 @@ public class CInputMethod extends InputMethodAdapter {
* are dispatched to the current input method for this component before
* they are dispatched to the component's methods or event listeners.
* The input method decides whether it needs to handle the event. If it
* does, it also calls the event's <code>consume</code> method; this
* does, it also calls the event's {@code consume} method; this
* causes the event to not get dispatched to the component's event
* processing methods or event listeners.
* <p>
@ -216,7 +216,7 @@ public class CInputMethod extends InputMethodAdapter {
* This method is called by {@link java.awt.im.InputContext#dispatchEvent InputContext.dispatchEvent}.
*
* @param event the event being dispatched to the input method
* @exception NullPointerException if <code>event</code> is null
* @exception NullPointerException if {@code event} is null
*/
public void dispatchEvent(final AWTEvent event) {
// No-op for Mac OS X.

View File

@ -75,8 +75,7 @@ final class CPlatformResponder {
jclickCount = clickCount;
}
int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
modifierFlags);
int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);
eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
@ -90,9 +89,7 @@ final class CPlatformResponder {
void handleScrollEvent(final int x, final int y, final int absX,
final int absY, final int modifierFlags,
final double deltaX, final double deltaY) {
final int buttonNumber = CocoaConstants.kCGMouseButtonCenter;
int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
modifierFlags);
int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
final boolean isShift = (jmodifiers & InputEvent.SHIFT_DOWN_MASK) != 0;
// Vertical scroll.
@ -187,8 +184,7 @@ final class CPlatformResponder {
postsTyped = false;
}
int jmodifiers = NSEvent.nsToJavaKeyModifiers(modifierFlags);
int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
long when = System.currentTimeMillis();
if (jeventType == KeyEvent.KEY_PRESSED) {

View File

@ -35,8 +35,8 @@ public class CPrinterDevice extends GraphicsDevice {
}
/**
* Returns the type of this <code>GraphicsDevice</code>.
* @return the type of this <code>GraphicsDevice</code>, which can
* Returns the type of this {@code GraphicsDevice}.
* @return the type of this {@code GraphicsDevice}, which can
* either be TYPE_RASTER_SCREEN, TYPE_PRINTER or TYPE_IMAGE_BUFFER.
* @see #TYPE_RASTER_SCREEN
* @see #TYPE_PRINTER
@ -48,30 +48,30 @@ public class CPrinterDevice extends GraphicsDevice {
/**
* Returns the identification string associated with this
* <code>GraphicsDevice</code>.
* @return a <code>String</code> that is the identification
* of this <code>GraphicsDevice</code>.
* {@code GraphicsDevice}.
* @return a {@code String} that is the identification
* of this {@code GraphicsDevice}.
*/
public String getIDstring() {
return ("Printer");
}
/**
* Returns all of the <code>GraphicsConfiguration</code>
* objects associated with this <code>GraphicsDevice</code>.
* @return an array of <code>GraphicsConfiguration</code>
* Returns all of the {@code GraphicsConfiguration}
* objects associated with this {@code GraphicsDevice}.
* @return an array of {@code GraphicsConfiguration}
* objects that are associated with this
* <code>GraphicsDevice</code>.
* {@code GraphicsDevice}.
*/
public GraphicsConfiguration[] getConfigurations() {
return new GraphicsConfiguration[] { gc };
}
/**
* Returns the default <code>GraphicsConfiguration</code>
* associated with this <code>GraphicsDevice</code>.
* @return the default <code>GraphicsConfiguration</code>
* of this <code>GraphicsDevice</code>.
* Returns the default {@code GraphicsConfiguration}
* associated with this {@code GraphicsDevice}.
* @return the default {@code GraphicsConfiguration}
* of this {@code GraphicsDevice}.
*/
public GraphicsConfiguration getDefaultConfiguration() {
return gc;

View File

@ -49,9 +49,9 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
/**
* Returns the {@link GraphicsDevice} associated with this
* <code>GraphicsConfiguration</code>.
* @return a <code>GraphicsDevice</code> object that is
* associated with this <code>GraphicsConfiguration</code>.
* {@code GraphicsConfiguration}.
* @return a {@code GraphicsDevice} object that is
* associated with this {@code GraphicsConfiguration}.
*/
public GraphicsDevice getDevice() {
return gd;
@ -59,16 +59,16 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
/**
* Returns a {@link BufferedImage} with a data layout and color model
* compatible with this <code>GraphicsConfiguration</code>. This
* compatible with this {@code GraphicsConfiguration}. This
* method has nothing to do with memory-mapping
* a device. The returned <code>BufferedImage</code> has
* a device. The returned {@code BufferedImage} has
* a layout and color model that is closest to this native device
* configuration and can therefore be optimally blitted to this
* device.
* @param width the width of the returned <code>BufferedImage</code>
* @param height the height of the returned <code>BufferedImage</code>
* @return a <code>BufferedImage</code> whose data layout and color
* model is compatible with this <code>GraphicsConfiguration</code>.
* @param width the width of the returned {@code BufferedImage}
* @param height the height of the returned {@code BufferedImage}
* @return a {@code BufferedImage} whose data layout and color
* model is compatible with this {@code GraphicsConfiguration}.
*/
public BufferedImage createCompatibleImage(int width, int height) {
return createCompatibleImage(width, height, Transparency.OPAQUE);
@ -76,15 +76,15 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
/**
* Returns a {@link VolatileImage} with a data layout and color model
* compatible with this <code>GraphicsConfiguration</code>.
* The returned <code>VolatileImage</code>
* compatible with this {@code GraphicsConfiguration}.
* The returned {@code VolatileImage}
* may have data that is stored optimally for the underlying graphics
* device and may therefore benefit from platform-specific rendering
* acceleration.
* @param width the width of the returned <code>VolatileImage</code>
* @param height the height of the returned <code>VolatileImage</code>
* @return a <code>VolatileImage</code> whose data layout and color
* model is compatible with this <code>GraphicsConfiguration</code>.
* @param width the width of the returned {@code VolatileImage}
* @param height the height of the returned {@code VolatileImage}
* @return a {@code VolatileImage} whose data layout and color
* model is compatible with this {@code GraphicsConfiguration}.
* @see Component#createVolatileImage(int, int)
*/
public VolatileImage createCompatibleVolatileImage(int width, int height) {
@ -97,18 +97,18 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
}
/**
* Returns a <code>BufferedImage</code> that supports the specified
* Returns a {@code BufferedImage} that supports the specified
* transparency and has a data layout and color model
* compatible with this <code>GraphicsConfiguration</code>. This
* compatible with this {@code GraphicsConfiguration}. This
* method has nothing to do with memory-mapping
* a device. The returned <code>BufferedImage</code> has a layout and
* a device. The returned {@code BufferedImage} has a layout and
* color model that can be optimally blitted to a device
* with this <code>GraphicsConfiguration</code>.
* @param width the width of the returned <code>BufferedImage</code>
* @param height the height of the returned <code>BufferedImage</code>
* with this {@code GraphicsConfiguration}.
* @param width the width of the returned {@code BufferedImage}
* @param height the height of the returned {@code BufferedImage}
* @param transparency the specified transparency mode
* @return a <code>BufferedImage</code> whose data layout and color
* model is compatible with this <code>GraphicsConfiguration</code>
* @return a {@code BufferedImage} whose data layout and color
* model is compatible with this {@code GraphicsConfiguration}
* and also supports the specified transparency.
* @see Transparency#OPAQUE
* @see Transparency#BITMASK
@ -121,21 +121,21 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
/**
* Returns the {@link ColorModel} associated with this
* <code>GraphicsConfiguration</code>.
* @return a <code>ColorModel</code> object that is associated with
* this <code>GraphicsConfiguration</code>.
* {@code GraphicsConfiguration}.
* @return a {@code ColorModel} object that is associated with
* this {@code GraphicsConfiguration}.
*/
public ColorModel getColorModel() {
return getColorModel(Transparency.OPAQUE);
}
/**
* Returns the <code>ColorModel</code> associated with this
* <code>GraphicsConfiguration</code> that supports the specified
* Returns the {@code ColorModel} associated with this
* {@code GraphicsConfiguration} that supports the specified
* transparency.
* @param transparency the specified transparency mode
* @return a <code>ColorModel</code> object that is associated with
* this <code>GraphicsConfiguration</code> and supports the
* @return a {@code ColorModel} object that is associated with
* this {@code GraphicsConfiguration} and supports the
* specified transparency.
*/
public ColorModel getColorModel(int transparency) {
@ -144,22 +144,22 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
/**
* Returns the default {@link AffineTransform} for this
* <code>GraphicsConfiguration</code>. This
* <code>AffineTransform</code> is typically the Identity transform
* for most normal screens. The default <code>AffineTransform</code>
* {@code GraphicsConfiguration}. This
* {@code AffineTransform} is typically the Identity transform
* for most normal screens. The default {@code AffineTransform}
* maps coordinates onto the device such that 72 user space
* coordinate units measure approximately 1 inch in device
* space. The normalizing transform can be used to make
* this mapping more exact. Coordinates in the coordinate space
* defined by the default <code>AffineTransform</code> for screen and
* defined by the default {@code AffineTransform} for screen and
* printer devices have the origin in the upper left-hand corner of
* the target region of the device, with X coordinates
* increasing to the right and Y coordinates increasing downwards.
* For image buffers not associated with a device, such as those not
* created by <code>createCompatibleImage</code>,
* this <code>AffineTransform</code> is the Identity transform.
* @return the default <code>AffineTransform</code> for this
* <code>GraphicsConfiguration</code>.
* created by {@code createCompatibleImage},
* this {@code AffineTransform} is the Identity transform.
* @return the default {@code AffineTransform} for this
* {@code GraphicsConfiguration}.
*/
public AffineTransform getDefaultTransform() {
return new AffineTransform();
@ -167,9 +167,9 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
/**
*
* Returns a <code>AffineTransform</code> that can be concatenated
* with the default <code>AffineTransform</code>
* of a <code>GraphicsConfiguration</code> so that 72 units in user
* Returns a {@code AffineTransform} that can be concatenated
* with the default {@code AffineTransform}
* of a {@code GraphicsConfiguration} so that 72 units in user
* space equals 1 inch in device space.
* <p>
* For a particular {@link Graphics2D}, g, one
@ -181,16 +181,16 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
* g.setTransform(gc.getDefaultTransform());
* g.transform(gc.getNormalizingTransform());
* </pre>
* Note that sometimes this <code>AffineTransform</code> is identity,
* Note that sometimes this {@code AffineTransform} is identity,
* such as for printers or metafile output, and that this
* <code>AffineTransform</code> is only as accurate as the information
* {@code AffineTransform} is only as accurate as the information
* supplied by the underlying system. For image buffers not
* associated with a device, such as those not created by
* <code>createCompatibleImage</code>, this
* <code>AffineTransform</code> is the Identity transform
* {@code createCompatibleImage}, this
* {@code AffineTransform} is the Identity transform
* since there is no valid distance measurement.
* @return an <code>AffineTransform</code> to concatenate to the
* default <code>AffineTransform</code> so that 72 units in user
* @return an {@code AffineTransform} to concatenate to the
* default {@code AffineTransform} so that 72 units in user
* space is mapped to 1 inch in device space.
*/
public AffineTransform getNormalizingTransform() {
@ -198,12 +198,12 @@ public class CPrinterGraphicsConfig extends GraphicsConfiguration {
}
/**
* Returns the bounds of the <code>GraphicsConfiguration</code>
* Returns the bounds of the {@code GraphicsConfiguration}
* in the device coordinates. In a multi-screen environment
* with a virtual device, the bounds can have negative X
* or Y origins.
* @return the bounds of the area covered by this
* <code>GraphicsConfiguration</code>.
* {@code GraphicsConfiguration}.
* @since 1.3
*/
public Rectangle getBounds() {

View File

@ -83,13 +83,13 @@ public final class CPrinterJob extends RasterPrinterJob {
* to these native print services.
* To present the cross platform print dialog for all services,
* including native ones instead use
* <code>printDialog(PrintRequestAttributeSet)</code>.
* {@code printDialog(PrintRequestAttributeSet)}.
* <p>
* PrinterJob implementations which can use PrintService's will update
* the PrintService for this PrinterJob to reflect the new service
* selected by the user.
* @return <code>true</code> if the user does not cancel the dialog;
* <code>false</code> otherwise.
* @return {@code true} if the user does not cancel the dialog;
* {@code false} otherwise.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true.
* @see java.awt.GraphicsEnvironment#isHeadless
@ -117,19 +117,19 @@ public final class CPrinterJob extends RasterPrinterJob {
/**
* Displays a dialog that allows modification of a
* <code>PageFormat</code> instance.
* The <code>page</code> argument is used to initialize controls
* {@code PageFormat} instance.
* The {@code page} argument is used to initialize controls
* in the page setup dialog.
* If the user cancels the dialog then this method returns the
* original <code>page</code> object unmodified.
* original {@code page} object unmodified.
* If the user okays the dialog then this method returns a new
* <code>PageFormat</code> object with the indicated changes.
* In either case, the original <code>page</code> object is
* {@code PageFormat} object with the indicated changes.
* In either case, the original {@code page} object is
* not modified.
* @param page the default <code>PageFormat</code> presented to the
* @param page the default {@code PageFormat} presented to the
* user for modification
* @return the original <code>page</code> object if the dialog
* is cancelled; a new <code>PageFormat</code> object
* @return the original {@code page} object if the dialog
* is cancelled; a new {@code PageFormat} object
* containing the format indicated by the user if the
* dialog is acknowledged.
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
@ -157,11 +157,11 @@ public final class CPrinterJob extends RasterPrinterJob {
}
/**
* Clones the <code>PageFormat</code> argument and alters the
* Clones the {@code PageFormat} argument and alters the
* clone to describe a default page size and orientation.
* @param page the <code>PageFormat</code> to be cloned and altered
* @return clone of <code>page</code>, altered to describe a default
* <code>PageFormat</code>.
* @param page the {@code PageFormat} to be cloned and altered
* @return clone of {@code page}, altered to describe a default
* {@code PageFormat}.
*/
@Override
public PageFormat defaultPage(PageFormat page) {

View File

@ -73,7 +73,7 @@ class CRobot implements RobotPeer {
* Presses one or more mouse buttons.
*
* @param buttons the button mask (combination of
* <code>InputEvent.BUTTON1/2/3_MASK</code>)
* {@code InputEvent.BUTTON1/2/3_MASK})
*/
@Override
public void mousePress(int buttons) {
@ -87,7 +87,7 @@ class CRobot implements RobotPeer {
* Releases one or more mouse buttons.
*
* @param buttons the button mask (combination of
* <code>InputEvent.BUTTON1/2/3_MASK</code>)
* {@code InputEvent.BUTTON1/2/3_MASK})
*/
@Override
public void mouseRelease(int buttons) {
@ -133,14 +133,14 @@ class CRobot implements RobotPeer {
* Presses a given key.
* <p>
* Key codes that have more than one physical key associated with them
* (e.g. <code>KeyEvent.VK_SHIFT</code> could mean either the
* (e.g. {@code KeyEvent.VK_SHIFT} could mean either the
* left or right shift key) will map to the left key.
* <p>
* Assumes that the
* peer implementations will throw an exception for other bogus
* values e.g. -1, 999999
*
* @param keycode the key to press (e.g. <code>KeyEvent.VK_A</code>)
* @param keycode the key to press (e.g. {@code KeyEvent.VK_A})
*/
@Override
public void keyPress(final int keycode) {
@ -151,14 +151,14 @@ class CRobot implements RobotPeer {
* Releases a given key.
* <p>
* Key codes that have more than one physical key associated with them
* (e.g. <code>KeyEvent.VK_SHIFT</code> could mean either the
* (e.g. {@code KeyEvent.VK_SHIFT} could mean either the
* left or right shift key) will map to the left key.
* <p>
* Assumes that the
* peer implementations will throw an exception for other bogus
* values e.g. -1, 999999
*
* @param keycode the key to release (e.g. <code>KeyEvent.VK_A</code>)
* @param keycode the key to release (e.g. {@code KeyEvent.VK_A})
*/
@Override
public void keyRelease(final int keycode) {

View File

@ -214,7 +214,7 @@ public class CTrayIcon extends CFRetainedResource implements TrayIconPeer {
jclickCount = nsEvent.getClickCount();
}
int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
int jmodifiers = NSEvent.nsToJavaModifiers(
nsEvent.getModifierFlags());
boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers);

View File

@ -515,13 +515,13 @@ public final class LWCToolkit extends LWToolkit {
* key for menu shortcuts.
* <p>
* Menu shortcuts, which are embodied in the
* <code>MenuShortcut</code> class, are handled by the
* <code>MenuBar</code> class.
* {@code MenuShortcut} class, are handled by the
* {@code MenuBar} class.
* <p>
* By default, this method returns <code>Event.CTRL_MASK</code>.
* By default, this method returns {@code Event.CTRL_MASK}.
* Toolkit implementations should override this method if the
* <b>Control</b> key isn't the correct key for accelerators.
* @return the modifier mask on the <code>Event</code> class
* @return the modifier mask on the {@code Event} class
* that is used for menu shortcuts on this toolkit.
* @see java.awt.MenuBar
* @see java.awt.MenuShortcut

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -231,16 +231,14 @@ final class NSEvent {
return jeventType;
}
/*
* Converts NSEvent mouse modifiers to AWT mouse modifiers.
/**
* Converts NSEvent key modifiers to AWT key modifiers. Note that this
* method adds the current mouse state as a mouse modifiers.
*
* @param modifierFlags the NSEvent key modifiers
* @return the java key and mouse modifiers
*/
static native int nsToJavaMouseModifiers(int buttonNumber,
int modifierFlags);
/*
* Converts NSEvent key modifiers to AWT key modifiers.
*/
static native int nsToJavaKeyModifiers(int modifierFlags);
static native int nsToJavaModifiers(int modifierFlags);
/*
* Converts NSEvent key info to AWT key info.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -579,7 +579,7 @@ NSUInteger JavaModifiersToNsKeyModifiers(jint javaModifiers, BOOL isExtMods)
}
jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags)
jint GetJavaMouseModifiers(NSUInteger modifierFlags)
{
// Mousing needs the key modifiers
jint modifiers = NsKeyModifiersToJavaModifiers(modifierFlags, YES);
@ -632,38 +632,18 @@ Java_java_awt_AWTEvent_nativeSetSource
/*
* Class: sun_lwawt_macosx_NSEvent
* Method: nsToJavaMouseModifiers
* Method: nsToJavaModifiers
* Signature: (II)I
*/
JNIEXPORT jint JNICALL
Java_sun_lwawt_macosx_NSEvent_nsToJavaMouseModifiers
(JNIEnv *env, jclass cls, jint buttonNumber, jint modifierFlags)
{
jint jmodifiers = 0;
JNF_COCOA_ENTER(env);
jmodifiers = GetJavaMouseModifiers(buttonNumber, modifierFlags);
JNF_COCOA_EXIT(env);
return jmodifiers;
}
/*
* Class: sun_lwawt_macosx_NSEvent
* Method: nsToJavaKeyModifiers
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_sun_lwawt_macosx_NSEvent_nsToJavaKeyModifiers
Java_sun_lwawt_macosx_NSEvent_nsToJavaModifiers
(JNIEnv *env, jclass cls, jint modifierFlags)
{
jint jmodifiers = 0;
JNF_COCOA_ENTER(env);
jmodifiers = NsKeyModifiersToJavaModifiers(modifierFlags, YES);
jmodifiers = GetJavaMouseModifiers(modifierFlags);
JNF_COCOA_EXIT(env);

View File

@ -562,6 +562,17 @@ CGGI_CreateImageForGlyph
(CGGI_GlyphCanvas *canvas, const CGGlyph glyph,
GlyphInfo *info, const CGGI_RenderingMode *mode)
{
if (isnan(info->topLeftX) || isnan(info->topLeftY)) {
// Explicitly set glyphInfo width/height to be 0 to ensure
// zero length glyph image is copied into GlyphInfo from canvas
info->width = 0;
info->height = 0;
// copy the "empty" glyph from the canvas into the info
(*mode->glyphDescriptor->copyFxnPtr)(canvas, info);
return;
}
// clean the canvas
CGGI_ClearCanvas(canvas, info);
@ -570,7 +581,6 @@ CGGI_CreateImageForGlyph
-info->topLeftX,
canvas->image->height + info->topLeftY,
&glyph, 1);
// copy the glyph from the canvas into the info
(*mode->glyphDescriptor->copyFxnPtr)(canvas, info);
}

View File

@ -259,6 +259,10 @@ AWTGetGlyphOutline(CGGlyph *glyphs, NSFont *font,
OSStatus status = noErr;
if ( isnan(tx->a) || isnan(tx->b) || isnan(tx->c) ||
isnan(tx->d) || isnan(tx->tx) || isnan(tx->ty)) {
return status;
}
glyphs = glyphs + inStartIndex;
// advanceArray = advanceArray + inStartIndex; // TODO(cpc): use advance

View File

@ -3,4 +3,5 @@ com.sun.media.sound.AuFileReader
com.sun.media.sound.AiffFileReader
com.sun.media.sound.WaveFileReader
com.sun.media.sound.WaveFloatFileReader
com.sun.media.sound.WaveExtensibleFileReader
com.sun.media.sound.SoftMidiAudioFileReader

View File

@ -2,3 +2,4 @@
com.sun.media.sound.AuFileWriter
com.sun.media.sound.AiffFileWriter
com.sun.media.sound.WaveFileWriter
com.sun.media.sound.WaveFloatFileWriter

View File

@ -74,7 +74,7 @@ import com.sun.imageio.plugins.common.I18N;
/** This class is the Java Image IO plugin reader for BMP images.
* It may subsample the image, clip the image, select sub-bands,
* and shift the decoded image origin if the proper decoding parameter
* are set in the provided <code>ImageReadParam</code>.
* are set in the provided {@code ImageReadParam}.
*
* This class supports Microsoft Windows Bitmap Version 3-5,
* as well as OS/2 Bitmap Version 2.x (for single-image BMP file).
@ -159,8 +159,8 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
/** source and destination bands. */
private int[] sourceBands, destBands;
/** Constructs <code>BMPImageReader</code> from the provided
* <code>ImageReaderSpi</code>.
/** Constructs {@code BMPImageReader} from the provided
* {@code ImageReaderSpi}.
*/
public BMPImageReader(ImageReaderSpi originator) {
super(originator);
@ -1681,8 +1681,8 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
/** Decodes the jpeg/png image embedded in the bitmap using any jpeg
* ImageIO-style plugin.
*
* @param bi The destination <code>BufferedImage</code>.
* @param bmpParam The <code>ImageReadParam</code> for decoding this
* @param bi The destination {@code BufferedImage}.
* @param bmpParam The {@code ImageReadParam} for decoding this
* BMP image. The parameters for subregion, band selection and
* subsampling are used in decoding the jpeg image.
*/

View File

@ -69,7 +69,7 @@ import com.sun.imageio.plugins.common.I18N;
* a BMP format.
*
* The encoding process may clip, subsample using the parameters
* specified in the <code>ImageWriteParam</code>.
* specified in the {@code ImageWriteParam}.
*
* @see javax.imageio.plugins.bmp.BMPImageWriteParam
*/
@ -88,8 +88,8 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
private short[] spixels;
private int[] ipixels;
/** Constructs <code>BMPImageWriter</code> based on the provided
* <code>ImageWriterSpi</code>.
/** Constructs {@code BMPImageWriter} based on the provided
* {@code ImageWriterSpi}.
*/
public BMPImageWriter(ImageWriterSpi originator) {
super(originator);

View File

@ -28,7 +28,7 @@ package com.sun.imageio.plugins.common;
import java.awt.color.ColorSpace;
/**
* A dummy <code>ColorSpace</code> to enable <code>ColorModel</code>
* A dummy {@code ColorSpace} to enable {@code ColorModel}
* for image data which do not have an innate color representation.
*/
@SuppressWarnings("serial") // JDK-implementation class
@ -37,8 +37,8 @@ public class BogusColorSpace extends ColorSpace {
* Return the type given the number of components.
*
* @param numComponents The number of components in the
* <code>ColorSpace</code>.
* @exception IllegalArgumentException if <code>numComponents</code>
* {@code ColorSpace}.
* @exception IllegalArgumentException if {@code numComponents}
* is less than 1.
*/
private static int getType(int numComponents) {
@ -62,11 +62,11 @@ public class BogusColorSpace extends ColorSpace {
}
/**
* Constructs a bogus <code>ColorSpace</code>.
* Constructs a bogus {@code ColorSpace}.
*
* @param numComponents The number of components in the
* <code>ColorSpace</code>.
* @exception IllegalArgumentException if <code>numComponents</code>
* {@code ColorSpace}.
* @exception IllegalArgumentException if {@code numComponents}
* is less than 1.
*/
public BogusColorSpace(int numComponents) {

View File

@ -37,9 +37,9 @@ import java.net.URL;
* the file from the jar as the package name is included automatically.
*
* <p>Extenders need only provide a static method
* <code>getString(String)</code> which calls the static method in this
* {@code getString(String)} which calls the static method in this
* class with the name of the invoking class and returns a
* <code>String</code>.
* {@code String}.
*/
public class I18NImpl {
/**

View File

@ -58,35 +58,35 @@ import javax.imageio.spi.ImageWriterSpi;
public class ImageUtil {
/**
* Creates a <code>ColorModel</code> that may be used with the
* specified <code>SampleModel</code>. If a suitable
* <code>ColorModel</code> cannot be found, this method returns
* <code>null</code>.
* Creates a {@code ColorModel} that may be used with the
* specified {@code SampleModel}. If a suitable
* {@code ColorModel} cannot be found, this method returns
* {@code null}.
*
* <p> Suitable <code>ColorModel</code>s are guaranteed to exist
* for all instances of <code>ComponentSampleModel</code>.
* For 1- and 3- banded <code>SampleModel</code>s, the returned
* <code>ColorModel</code> will be opaque. For 2- and 4-banded
* <code>SampleModel</code>s, the output will use alpha transparency
* <p> Suitable {@code ColorModel}s are guaranteed to exist
* for all instances of {@code ComponentSampleModel}.
* For 1- and 3- banded {@code SampleModel}s, the returned
* {@code ColorModel} will be opaque. For 2- and 4-banded
* {@code SampleModel}s, the output will use alpha transparency
* which is not premultiplied. 1- and 2-banded data will use a
* grayscale <code>ColorSpace</code>, and 3- and 4-banded data a sRGB
* <code>ColorSpace</code>. Data with 5 or more bands will have a
* <code>BogusColorSpace</code>.</p>
* grayscale {@code ColorSpace}, and 3- and 4-banded data a sRGB
* {@code ColorSpace}. Data with 5 or more bands will have a
* {@code BogusColorSpace}.</p>
*
* <p>An instance of <code>DirectColorModel</code> will be created for
* instances of <code>SinglePixelPackedSampleModel</code> with no more
* <p>An instance of {@code DirectColorModel} will be created for
* instances of {@code SinglePixelPackedSampleModel} with no more
* than 4 bands.</p>
*
* <p>An instance of <code>IndexColorModel</code> will be created for
* instances of <code>MultiPixelPackedSampleModel</code>. The colormap
* will be a grayscale ramp with <code>1&nbsp;<<&nbsp;numberOfBits</code>
* <p>An instance of {@code IndexColorModel} will be created for
* instances of {@code MultiPixelPackedSampleModel}. The colormap
* will be a grayscale ramp with <code>1&nbsp;&lt;&lt;&nbsp;numberOfBits</code>
* entries ranging from zero to at most 255.</p>
*
* @return An instance of <code>ColorModel</code> that is suitable for
* the supplied <code>SampleModel</code>, or <code>null</code>.
* @return An instance of {@code ColorModel} that is suitable for
* the supplied {@code SampleModel}, or {@code null}.
*
* @throws IllegalArgumentException If <code>sampleModel</code> is
* <code>null</code>.
* @throws IllegalArgumentException If {@code sampleModel} is
* {@code null}.
*/
public static final ColorModel createColorModel(SampleModel sampleModel) {
// Check the parameter.
@ -194,19 +194,19 @@ public class ImageUtil {
}
/**
* For the case of binary data (<code>isBinary()</code> returns
* <code>true</code>), return the binary data as a packed byte array.
* For the case of binary data ({@code isBinary()} returns
* {@code true}), return the binary data as a packed byte array.
* The data will be packed as eight bits per byte with no bit offset,
* i.e., the first bit in each image line will be the left-most of the
* first byte of the line. The line stride in bytes will be
* <code>(int)((getWidth()+7)/8)</code>. The length of the returned
* array will be the line stride multiplied by <code>getHeight()</code>
* {@code (int)((getWidth()+7)/8)}. The length of the returned
* array will be the line stride multiplied by {@code getHeight()}
*
* @return the binary data as a packed array of bytes with zero offset
* of <code>null</code> if the data are not binary.
* @throws IllegalArgumentException if <code>isBinary()</code> returns
* <code>false</code> with the <code>SampleModel</code> of the
* supplied <code>Raster</code> as argument.
* of {@code null} if the data are not binary.
* @throws IllegalArgumentException if {@code isBinary()} returns
* {@code false} with the {@code SampleModel} of the
* supplied {@code Raster} as argument.
*/
public static byte[] getPackedBinaryData(Raster raster,
Rectangle rect) {
@ -387,11 +387,11 @@ public class ImageUtil {
/**
* Returns the binary data unpacked into an array of bytes.
* The line stride will be the width of the <code>Raster</code>.
* The line stride will be the width of the {@code Raster}.
*
* @throws IllegalArgumentException if <code>isBinary()</code> returns
* <code>false</code> with the <code>SampleModel</code> of the
* supplied <code>Raster</code> as argument.
* @throws IllegalArgumentException if {@code isBinary()} returns
* {@code false} with the {@code SampleModel} of the
* supplied {@code Raster} as argument.
*/
public static byte[] getUnpackedBinaryData(Raster raster,
Rectangle rect) {
@ -467,13 +467,13 @@ public class ImageUtil {
}
/**
* Sets the supplied <code>Raster</code>'s data from an array
* Sets the supplied {@code Raster}'s data from an array
* of packed binary data of the form returned by
* <code>getPackedBinaryData()</code>.
* {@code getPackedBinaryData()}.
*
* @throws IllegalArgumentException if <code>isBinary()</code> returns
* <code>false</code> with the <code>SampleModel</code> of the
* supplied <code>Raster</code> as argument.
* @throws IllegalArgumentException if {@code isBinary()} returns
* {@code false} with the {@code SampleModel} of the
* supplied {@code Raster} as argument.
*/
public static void setPackedBinaryData(byte[] binaryDataArray,
WritableRaster raster,
@ -713,16 +713,16 @@ public class ImageUtil {
}
/**
* Copies data into the packed array of the <code>Raster</code>
* Copies data into the packed array of the {@code Raster}
* from an array of unpacked data of the form returned by
* <code>getUnpackedBinaryData()</code>.
* {@code getUnpackedBinaryData()}.
*
* <p> If the data are binary, then the target bit will be set if
* and only if the corresponding byte is non-zero.
*
* @throws IllegalArgumentException if <code>isBinary()</code> returns
* <code>false</code> with the <code>SampleModel</code> of the
* supplied <code>Raster</code> as argument.
* @throws IllegalArgumentException if {@code isBinary()} returns
* {@code false} with the {@code SampleModel} of the
* supplied {@code Raster} as argument.
*/
public static void setUnpackedBinaryData(byte[] bdata,
WritableRaster raster,
@ -983,7 +983,7 @@ public class ImageUtil {
* @param g The green channel color indices.
* @param b The blue channel color indices.
* @return If all the indices have 256 entries, and are identical mappings,
* return <code>true</code>; otherwise, return <code>false</code>.
* return {@code true}; otherwise, return {@code false}.
*/
public static boolean isIndicesForGrayscale(byte[] r, byte[] g, byte[] b) {
if (r.length != g.length || r.length != b.length)
@ -1004,7 +1004,7 @@ public class ImageUtil {
return true;
}
/** Converts the provided object to <code>String</code> */
/** Converts the provided object to {@code String} */
public static String convertObjectToString(Object obj) {
if (obj == null)
return "";
@ -1035,10 +1035,10 @@ public class ImageUtil {
}
/** Checks that the provided <code>ImageWriter</code> can encode
* the provided <code>ImageTypeSpecifier</code> or not. If not, an
* <code>IIOException</code> will be thrown.
* @param writer The provided <code>ImageWriter</code>.
/** Checks that the provided {@code ImageWriter} can encode
* the provided {@code ImageTypeSpecifier} or not. If not, an
* {@code IIOException} will be thrown.
* @param writer The provided {@code ImageWriter}.
* @param type The image to be tested.
* @throws IIOException If the writer cannot encoded the provided image.
*/
@ -1053,12 +1053,12 @@ public class ImageUtil {
}
}
/** Checks that the provided <code>ImageWriter</code> can encode
* the provided <code>ColorModel</code> and <code>SampleModel</code>.
* If not, an <code>IIOException</code> will be thrown.
* @param writer The provided <code>ImageWriter</code>.
* @param colorModel The provided <code>ColorModel</code>.
* @param sampleModel The provided <code>SampleModel</code>.
/** Checks that the provided {@code ImageWriter} can encode
* the provided {@code ColorModel} and {@code SampleModel}.
* If not, an {@code IIOException} will be thrown.
* @param writer The provided {@code ImageWriter}.
* @param colorModel The provided {@code ColorModel}.
* @param sampleModel The provided {@code SampleModel}.
* @throws IIOException If the writer cannot encoded the provided image.
*/
public static final void canEncodeImage(ImageWriter writer,

View File

@ -31,9 +31,9 @@ import java.io.PrintStream;
* General purpose LZW String Table.
* Extracted from GIFEncoder by Adam Doppelt
* Comments added by Robin Luiten
* <code>expandCode</code> added by Robin Luiten
* {@code expandCode} added by Robin Luiten
* The strLen table to give quick access to the lenght of an expanded
* code for use by the <code>expandCode</code> method added by Robin.
* code for use by the {@code expandCode} method added by Robin.
**/
public class LZWStringTable {
/** codesize + Reserved Codes */

View File

@ -70,19 +70,19 @@ public class PaletteBuilder {
/**
* Creates an image representing given image
* <code>src</code> using <code>IndexColorModel</code>.
* {@code src} using {@code IndexColorModel}.
*
* Lossless conversion is not always possible (e.g. if number
* of colors in the given image exceeds maximum palette size).
* Result image then is an approximation constructed by octree
* quantization method.
*
* @exception IllegalArgumentException if <code>src</code> is
* <code>null</code>.
* @exception IllegalArgumentException if {@code src} is
* {@code null}.
*
* @exception UnsupportedOperationException if implemented method
* is unable to create approximation of <code>src</code>
* and <code>canCreatePalette</code> returns <code>false</code>.
* is unable to create approximation of {@code src}
* and {@code canCreatePalette} returns {@code false}.
*
* @see createIndexColorModel
*
@ -97,15 +97,15 @@ public class PaletteBuilder {
/**
* Creates an palette representing colors from given image
* <code>img</code>. If number of colors in the given image exceeds
* {@code img}. If number of colors in the given image exceeds
* maximum palette size closest colors would be merged.
*
* @exception IllegalArgumentException if <code>img</code> is
* <code>null</code>.
* @exception IllegalArgumentException if {@code img} is
* {@code null}.
*
* @exception UnsupportedOperationException if implemented method
* is unable to create approximation of <code>img</code>
* and <code>canCreatePalette</code> returns <code>false</code>.
* is unable to create approximation of {@code img}
* and {@code canCreatePalette} returns {@code false}.
*
* @see createIndexedImage
*
@ -119,17 +119,17 @@ public class PaletteBuilder {
}
/**
* Returns <code>true</code> if PaletteBuilder is able to create
* Returns {@code true} if PaletteBuilder is able to create
* palette for given image type.
*
* @param type an instance of <code>ImageTypeSpecifier</code> to be
* @param type an instance of {@code ImageTypeSpecifier} to be
* indexed.
*
* @return <code>true</code> if the <code>PaletteBuilder</code>
* @return {@code true} if the {@code PaletteBuilder}
* is likely to be able to create palette for this image type.
*
* @exception IllegalArgumentException if <code>type</code>
* is <code>null</code>.
* @exception IllegalArgumentException if {@code type}
* is {@code null}.
*/
public static boolean canCreatePalette(ImageTypeSpecifier type) {
if (type == null) {
@ -139,17 +139,17 @@ public class PaletteBuilder {
}
/**
* Returns <code>true</code> if PaletteBuilder is able to create
* Returns {@code true} if PaletteBuilder is able to create
* palette for given rendered image.
*
* @param image an instance of <code>RenderedImage</code> to be
* @param image an instance of {@code RenderedImage} to be
* indexed.
*
* @return <code>true</code> if the <code>PaletteBuilder</code>
* @return {@code true} if the {@code PaletteBuilder}
* is likely to be able to create palette for this image type.
*
* @exception IllegalArgumentException if <code>image</code>
* is <code>null</code>.
* @exception IllegalArgumentException if {@code image}
* is {@code null}.
*/
public static boolean canCreatePalette(RenderedImage image) {
if (image == null) {

View File

@ -134,25 +134,25 @@ public class ReaderUtil {
* pixels that will be written during a particular decoding pass.
* The intent is to simplify the work done by readers in combining
* the source region, source subsampling, and destination offset
* information obtained from the <code>ImageReadParam</code> with
* information obtained from the {@code ImageReadParam} with
* the offsets and periods of a progressive or interlaced decoding
* pass.
*
* @param sourceRegion a <code>Rectangle</code> containing the
* @param sourceRegion a {@code Rectangle} containing the
* source region being read, offset by the source subsampling
* offsets, and clipped against the source bounds, as returned by
* the <code>getSourceRegion</code> method.
* @param destinationOffset a <code>Point</code> containing the
* the {@code getSourceRegion} method.
* @param destinationOffset a {@code Point} containing the
* coordinates of the upper-left pixel to be written in the
* destination.
* @param dstMinX the smallest X coordinate (inclusive) of the
* destination <code>Raster</code>.
* destination {@code Raster}.
* @param dstMinY the smallest Y coordinate (inclusive) of the
* destination <code>Raster</code>.
* destination {@code Raster}.
* @param dstMaxX the largest X coordinate (inclusive) of the destination
* <code>Raster</code>.
* {@code Raster}.
* @param dstMaxY the largest Y coordinate (inclusive) of the destination
* <code>Raster</code>.
* {@code Raster}.
* @param sourceXSubsampling the X subsampling factor.
* @param sourceYSubsampling the Y subsampling factor.
* @param passXStart the smallest source X coordinate (inclusive)
@ -168,7 +168,7 @@ public class ReaderUtil {
* @param passPeriodY the Y period (vertical spacing between
* pixels) of the current progressive pass.
*
* @return an array of 6 <code>int</code>s containing the
* @return an array of 6 {@code int}s containing the
* destination min X, min Y, width, height, X period and Y period
* of the region that will be updated.
*/

View File

@ -1017,7 +1017,7 @@ public class GIFImageReader extends ImageReader {
/**
* Remove all settings including global settings such as
* <code>Locale</code>s and listeners, as well as stream settings.
* {@code Locale}s and listeners, as well as stream settings.
*/
public void reset() {
super.reset();

View File

@ -70,7 +70,7 @@ public class GIFImageWriter extends ImageWriter {
GIFWritableImageMetadata.NATIVE_FORMAT_NAME;
/**
* The <code>output</code> case to an <code>ImageOutputStream</code>.
* The {@code output} case to an {@code ImageOutputStream}.
*/
private ImageOutputStream stream = null;
@ -272,7 +272,7 @@ public class GIFImageWriter extends ImageWriter {
}
/**
* Merges <code>inData</code> into <code>outData</code>. The supplied
* Merges {@code inData} into {@code outData}. The supplied
* metadata format name is attempted first and failing that the standard
* metadata format name is attempted.
*/
@ -554,8 +554,8 @@ public class GIFImageWriter extends ImageWriter {
*
* @param writeHeader Whether to write the header.
* @param writeTrailer Whether to write the trailer.
* @param sm The stream metadata or <code>null</code> if
* <code>writeHeader</code> is <code>false</code>.
* @param sm The stream metadata or {@code null} if
* {@code writeHeader} is {@code false}.
* @param iioimage The image and image metadata.
* @param p The write parameters.
*
@ -564,10 +564,10 @@ public class GIFImageWriter extends ImageWriter {
* greater than 8.
* @throws IllegalArgumentException if the color component size is
* greater than 8.
* @throws IllegalArgumentException if <code>writeHeader</code> is
* <code>true</code> and <code>sm</code> is <code>null</code>.
* @throws IllegalArgumentException if <code>writeHeader</code> is
* <code>false</code> and a sequence is not being written.
* @throws IllegalArgumentException if {@code writeHeader} is
* {@code true} and {@code sm} is {@code null}.
* @throws IllegalArgumentException if {@code writeHeader} is
* {@code false} and a sequence is not being written.
*/
private void write(boolean writeHeader,
boolean writeTrailer,

View File

@ -32,7 +32,7 @@ import org.w3c.dom.Node;
/**
* Class which adds utility DOM element attribute access methods to
* <code>IIOMetadata</code> for subclass use.
* {@code IIOMetadata} for subclass use.
*/
abstract class GIFMetadata extends IIOMetadata {

View File

@ -39,7 +39,7 @@ import org.w3c.dom.Node;
* comment data as it is read from the stream. If the marker segment is
* constructed from a String, then local default encoding is assumed
* when creating the byte array. If the marker segment is created from
* an <code>IIOMetadataNode</code>, the user object, if present is
* an {@code IIOMetadataNode}, the user object, if present is
* assumed to be a byte array containing the comment data. If there is
* no user object then the comment attribute is used to create the
* byte array, again assuming the default local encoding.
@ -49,7 +49,7 @@ class COMMarkerSegment extends MarkerSegment {
/**
* Constructs a marker segment from the given buffer, which contains
* data from an <code>ImageInputStream</code>. This is used when
* data from an {@code ImageInputStream}. This is used when
* reading metadata from a stream.
*/
COMMarkerSegment(JPEGBuffer buffer) throws IOException {
@ -69,7 +69,7 @@ class COMMarkerSegment extends MarkerSegment {
/**
* Constructs a marker segment from a native tree node. If the node
* is an <code>IIOMetadataNode</code> and contains a user object,
* is an {@code IIOMetadataNode} and contains a user object,
* that object is used rather than the string attribute. If the
* string attribute is used, the default encoding is used.
*/
@ -103,7 +103,7 @@ class COMMarkerSegment extends MarkerSegment {
}
/**
* Returns an <code>IIOMetadataNode</code> containing the data array
* Returns an {@code IIOMetadataNode} containing the data array
* as a user object and a string encoded using ISO-8895-1, as an
* attribute.
*/

View File

@ -90,7 +90,7 @@ class JFIFMarkerSegment extends MarkerSegment {
private final boolean debug = false;
/**
* Set to <code>true</code> when reading the chunks of an
* Set to {@code true} when reading the chunks of an
* ICC profile. All chunks are consolidated to create a single
* "segment" containing all the chunks. This flag is a state
* variable identifying whether to construct a new segment or
@ -594,10 +594,10 @@ class JFIFMarkerSegment extends MarkerSegment {
/**
* Writes out a default JFIF marker segment to the given
* output stream. If <code>thumbnails</code> is not <code>null</code>,
* output stream. If {@code thumbnails} is not {@code null},
* writes out the set of thumbnail images as JFXX marker segments, or
* incorporated into the JFIF segment if appropriate.
* If <code>iccProfile</code> is not <code>null</code>,
* If {@code iccProfile} is not {@code null},
* writes out the profile after the JFIF segment using as many APP2
* marker segments as necessary.
*/

View File

@ -36,7 +36,7 @@ import java.awt.color.ICC_ColorSpace;
/**
* A class containing JPEG-related constants, definitions, and
* static methods. This class and its constants must be public so that
* <code>JPEGImageWriteParam</code> can see it.
* {@code JPEGImageWriteParam} can see it.
*/
public class JPEG {
@ -234,10 +234,10 @@ public class JPEG {
public static final float DEFAULT_QUALITY = 0.75F;
/**
* Returns <code>true</code> if the given <code>ColorSpace</code>
* Returns {@code true} if the given {@code ColorSpace}
* object is an instance of ICC_ColorSpace but is not one of the
* standard <code>ColorSpaces</code> returned by
* <code>ColorSpace.getInstance()</code>.
* standard {@code ColorSpaces} returned by
* {@code ColorSpace.getInstance()}.
*/
static boolean isNonStandardICC(ColorSpace cs) {
boolean retval = false;
@ -255,8 +255,8 @@ public class JPEG {
/**
* Returns <code>true</code> if the given imageType can be used
* in a JFIF file. If <code>input</code> is true, then the
* Returns {@code true} if the given imageType can be used
* in a JFIF file. If {@code input} is true, then the
* image type is considered before colorspace conversion.
*/
static boolean isJFIFcompliant(ImageTypeSpecifier imageType,
@ -295,7 +295,7 @@ public class JPEG {
/**
* Given an image type, return the Adobe transform corresponding to
* that type, or ADOBE_IMPOSSIBLE if the image type is incompatible
* with an Adobe marker segment. If <code>input</code> is true, then
* with an Adobe marker segment. If {@code input} is true, then
* the image type is considered before colorspace conversion.
*/
static int transformForType(ImageTypeSpecifier imageType, boolean input) {

View File

@ -75,12 +75,12 @@ class JPEGBuffer {
}
/**
* Ensures that there are at least <code>count</code> bytes available
* Ensures that there are at least {@code count} bytes available
* in the buffer, loading more data and moving any remaining
* bytes to the front. A count of 0 means to just fill the buffer.
* If the count is larger than the buffer size, just fills the buffer.
* If the end of the stream is encountered before a non-0 count can
* be satisfied, an <code>IIOException</code> is thrown with the
* be satisfied, an {@code IIOException} is thrown with the
* message "Image Format Error".
*/
void loadBuf(int count) throws IOException {
@ -122,7 +122,7 @@ class JPEGBuffer {
* the buffer and then reading directly from the stream
* if necessary. The buffer is left in an appropriate
* state. If the end of the stream is encountered, an
* <code>IIOException</code> is thrown with the
* {@code IIOException} is thrown with the
* message "Image Format Error".
*/
void readData(byte [] data) throws IOException {
@ -149,9 +149,9 @@ class JPEGBuffer {
}
/**
* Skips <code>count</code> bytes, leaving the buffer
* Skips {@code count} bytes, leaving the buffer
* in an appropriate state. If the end of the stream is
* encountered, an <code>IIOException</code> is thrown with the
* encountered, an {@code IIOException} is thrown with the
* message "Image Format Error".
*/
void skipData(int count) throws IOException {
@ -195,8 +195,8 @@ class JPEGBuffer {
* the buffer as necessary. The buffer position is left
* pointing to the first non-0xff byte after a run of
* 0xff bytes. If the end of the stream is encountered,
* an EOI marker is inserted into the buffer and <code>true</code>
* is returned. Otherwise returns <code>false</code>.
* an EOI marker is inserted into the buffer and {@code true}
* is returned. Otherwise returns {@code false}.
*/
boolean scanForFF(JPEGImageReader reader) throws IOException {
boolean retval = false;

View File

@ -544,7 +544,7 @@ public class JPEGImageReader extends ImageReader {
}
/**
* Returns <code>true</code> if there is an image beyond
* Returns {@code true} if there is an image beyond
* the current stream position. Does not disturb the
* stream position.
*/
@ -614,13 +614,13 @@ public class JPEGImageReader extends ImageReader {
/**
* Read in the header information starting from the current
* stream position, returning <code>true</code> if the
* stream position, returning {@code true} if the
* header was a tables-only image. After this call, the
* native IJG decompression struct will contain the image
* information required by most query calls below
* (e.g. getWidth, getHeight, etc.), if the header was not
* a tables-only image.
* If reset is <code>true</code>, the state of the IJG
* If reset is {@code true}, the state of the IJG
* object is reset so that it can read a header again.
* This happens automatically if the header was a tables-only
* image.
@ -867,7 +867,7 @@ public class JPEGImageReader extends ImageReader {
* Checks the implied color conversion between the stream and
* the target image, altering the IJG output color space if necessary.
* If a java color conversion is required, then this sets up
* <code>convert</code>.
* {@code convert}.
* If bands are being rearranged at all (either source or destination
* bands are specified in the param), then the default color
* conversions are assumed to be correct.
@ -1394,7 +1394,7 @@ public class JPEGImageReader extends ImageReader {
}
/**
* Returns <code>true</code> if the read was aborted.
* Returns {@code true} if the read was aborted.
*/
private native boolean readImage(long structPointer,
byte [] buffer,
@ -1788,6 +1788,8 @@ class ImageTypeProducer {
case JPEG.JCS_GRAYSCALE:
return ImageTypeSpecifier.createFromBufferedImageType
(BufferedImage.TYPE_BYTE_GRAY);
case JPEG.JCS_YCbCr:
//there is no YCbCr raw type so by default we assume it as RGB
case JPEG.JCS_RGB:
return ImageTypeSpecifier.createInterleaved(JPEG.JCS.sRGB,
JPEG.bOffsRGB,

View File

@ -1130,10 +1130,10 @@ public class JPEGImageWriter extends ImageWriter {
/*
* from jpeg_metadata.html:
* If no stream metadata is supplied to
* <code>ImageWriter.prepareWriteSequence</code>, then no
* {@code ImageWriter.prepareWriteSequence}, then no
* tables-only image is written. If stream metadata containing
* no tables is supplied to
* <code>ImageWriter.prepareWriteSequence</code>, then a tables-only
* {@code ImageWriter.prepareWriteSequence}, then a tables-only
* image containing default visually lossless tables is written.
*/
if (streamMetadata != null) {
@ -1699,7 +1699,7 @@ public class JPEGImageWriter extends ImageWriter {
private native void setDest(long structPointer);
/**
* Returns <code>true</code> if the write was aborted.
* Returns {@code true} if the write was aborted.
*/
private native boolean writeImage(long structPointer,
byte [] data,

View File

@ -66,17 +66,17 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
private static final boolean debug = false;
/**
* A copy of <code>markerSequence</code>, created the first time the
* <code>markerSequence</code> is modified. This is used by reset
* A copy of {@code markerSequence}, created the first time the
* {@code markerSequence} is modified. This is used by reset
* to restore the original state.
*/
private List<MarkerSegment> resetSequence = null;
/**
* Set to <code>true</code> when reading a thumbnail stored as
* Set to {@code true} when reading a thumbnail stored as
* JPEG. This is used to enforce the prohibition of JFIF thumbnails
* containing any JFIF marker segments, and to ensure generation of
* a correct native subtree during <code>getAsTree</code>.
* a correct native subtree during {@code getAsTree}.
*/
private boolean inThumb = false;
@ -93,7 +93,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
/////// Package-access variables
/**
* All data is a list of <code>MarkerSegment</code> objects.
* All data is a list of {@code MarkerSegment} objects.
* When accessing the list, use the tag to identify the particular
* subclass. Any JFIF marker segment must be the first element
* of the list if it is present, and any JFXX or APP2ICC marker
@ -132,17 +132,17 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
}
/*
* Constructs a <code>JPEGMetadata</code> object by reading the
* contents of an <code>ImageInputStream</code>. Has package-only
* Constructs a {@code JPEGMetadata} object by reading the
* contents of an {@code ImageInputStream}. Has package-only
* access.
*
* @param isStream A boolean indicating whether this object will be
* stream or image metadata.
* @param isThumb A boolean indicating whether this metadata object
* is for an image or for a thumbnail stored as JPEG.
* @param iis An <code>ImageInputStream</code> from which to read
* @param iis An {@code ImageInputStream} from which to read
* the metadata.
* @param reader The <code>JPEGImageReader</code> calling this
* @param reader The {@code JPEGImageReader} calling this
* constructor, to which warnings should be sent.
*/
JPEGMetadata(boolean isStream,
@ -365,7 +365,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
}
/**
* Constructs a default stream <code>JPEGMetadata</code> object appropriate
* Constructs a default stream {@code JPEGMetadata} object appropriate
* for the given write parameters.
*/
JPEGMetadata(ImageWriteParam param, JPEGImageWriter writer) {
@ -398,7 +398,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
}
/**
* Constructs a default image <code>JPEGMetadata</code> object appropriate
* Constructs a default image {@code JPEGMetadata} object appropriate
* for the given image type and write parameters.
*/
JPEGMetadata(ImageTypeSpecifier imageType,
@ -2248,7 +2248,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
/**
* Check that this metadata object is in a consistent state and
* return <code>true</code> if it is or <code>false</code>
* return {@code true} if it is or {@code false}
* otherwise. All the constructors and modifiers should call
* this method at the end to guarantee that the data is always
* consistent, as the writer relies on this.

View File

@ -133,12 +133,12 @@ abstract class JPEGMetadataFormat extends IIOMetadataFormatImpl {
}
/**
* Returns <code>true</code> if the named element occurs in the
* Returns {@code true} if the named element occurs in the
* subtree of the format starting with the node named by
* <code>subtreeName</code>, including the node
* itself. <code>subtreeName</code> may be any node in
* {@code subtreeName}, including the node
* itself. {@code subtreeName} may be any node in
* the format. If it is not, an
* <code>IllegalArgumentException</code> is thrown.
* {@code IllegalArgumentException} is thrown.
*/
protected boolean isInSubtree(String elementName,
String subtreeName) {

View File

@ -51,8 +51,8 @@ class MarkerSegment implements Cloneable {
boolean unknown = false; // Set to true if the tag is not recognized
/**
* Constructor for creating <code>MarkerSegment</code>s by reading
* from an <code>ImageInputStream</code>.
* Constructor for creating {@code MarkerSegment}s by reading
* from an {@code ImageInputStream}.
*/
MarkerSegment(JPEGBuffer buffer) throws IOException {

Some files were not shown because too many files have changed in this diff Show More