Additions in Java API in JDK 1.10.0 - IT magazine

IT magazine

Knowledge that matters

Additions in Java API in JDK 1.10.0

Share This
Ready for java 10
The new version of Java JDK 1.10.0 adds almost 73 standard libraries to the Java API.
  • java.awt.Toolkit
    int getMenuShortcutKeyMaskEx()
    : Determines which extended modifier key is the appropriate accelerator key for menu shortcuts.
  • java.awt.geom.Path2D:
    void trimToSize(): Trims the capacity of this Path2D instance to its current size. An application can use this operation to minimize the storage of a path. This has also been added to the inner Path2D.Double and Path2D.Float classes.
  • java.lang.io.ByteArrayOutputStream:
    String toString(Charset)
    : Overloaded toString that converts the buffer's contents into a string by decoding the bytes using the specified charset.
Ready for java 10
  • java.lang.io.PrintStream:
    lang.io.PrintWriter:

    Both these classes have three new constructors that take an additional charset argument.
  • java.lang.io.Reader:
    long transferTo(Writer):
     reads all characters from this reader and writes the characters to the given writer in the order that they are read.
  • java.lang.Runtime.Version:
    There are four new methods that return an integer value of the new (JEP 322) version string fields: feature(), interim(), patch() and update().
  • java.lang.StackWalker.StackFrame:
    String getDescriptor(): Returns the descriptor of the method represented by this stack frame as defined by The Java Virtual Machine Specification.
    String getMethodType():Returns the MethodType representing the parameter types and the return type for the method represented by the stack frame.
Java 10

  • java.lang.invoke.MethodType:
    Class<?> lastParameterType():
    Returns the last parameter type of this method type. If this type has no parameters, the sentinel value void.class is returned instead.
  • java.lang.management.RuntimeMXBean:
    long getPid():
    Returns the pid of the running Java virtual machine.
  • java.lang.management.ThreadMXBean:
    ThreadInfo[] dumpAllThreads(boolean, boolean, int):
    Returns the thread information for all live threads with a stack trace of the specified maximum number of elements and synchronization information.
    ThreadInfo[] getThreadInfo(long[], boolean, boolean, int): Returns the thread information for each thread whose identity is in the input array, with a stack trace of the specified maximum number of elements and synchronization information.
  • java.lang.reflect.MalformedParameterizedTypeException: A new constructor has been added that takes a detail message in the form of a String as a parameter.
  • java.net.URLDecoder:
    java.net.URLEncoder:

    both these classes have new overloaded decode and encode methods that take a charset as an additional parameter.
  • java.nio.channels.Channels:
    Two new static overloaded methods, newReader(ReadByteChannel, Charset) and newWriter(WriteByteChannel, Charset) that allow the use of a charset.
  • java.nio.file.FileStore:
    long getBlockSize():
     Returns the number of bytes per block in this file store.
  • java.time.chrono: Three classes in this package, HijrahEra, MiinguoEra and ThaiBuddhistEra, have had the same method added
    String getDisplayName(TextStyle, Locale): This returns the textual name used to identify the era, suitable for presentation to the user.
  • java.time.format.DateTimeFormatter:
    localizedBy(Locale):
     Returns a copy of this formatter with localized values of the locale, calendar, region, decimal style and/or time zone, that supersede values in this formatter.
  • java.util: DoubleSummaryStatistics, IntSummaryStatistics, and LongSummaryStatistics all have a new constructor that takes four numeric values. It constructs a non-empty instance with the specified count, minimum, maximum, and sum.
  • java.util.List:
    java.util.Map:
    java.util.Set:
     Each of these interfaces gains a new static method, copyOf(Collection). These return an unmodifiable List, Map or Set containing the elements of the given Collection, in its iteration order.
  • java.util.Optional:
    java.util.OptionalDouble:
    java.util.OptionalInt:
    java.util.OptionalLong:
    Each of these classes gets a new method, orElseThrow(), which essentially does the same as get(), i.e. if the Optional holds a value it is returned. Otherwise, a NoSuchElementException is thrown.
  • java.util.Formatter:
    java.util.Scanner:
    Both these classes have three new constructors, all of which take a charset in addition to other arguments.
  • java.util.Properties: This has a new constructor that takes an int argument. This creates an empty property list with no default values, and with an initial size accommodating the specified number of elements without the need to dynamically resize. There is also a new, overloaded, version of the replace method that takes three Object parameters and returns a boolean. This replaces the entry for the specified key only if currently mapped to the specified value.
  • java.SplittableRandom:
    void nextBytes(byte[]): Fills a user-supplied byte array with generated pseudorandom bytes.
  • java.util.concurrent.FutureTask: A toString() method has been added, that returns a string identifying the FutureTask, as well as its completion state. The state, in brackets, contains one of the strings "Completed Normally" , "Completed Exceptionally" , "Cancelled", or "Not completed".
  • java.util.concurrent.locks.StampedLock:
    boolean isLockStamp(long): Returns whether a stamp represents holding a lock.
    boolean isOptimisticReadStamp(long): Returns whether a stamp represents a successful, optimistic read.
    boolean isReadLockStamp(long): Returns whether a stamp represents holding a lock non-exclusively (i.e. a read lock).
    boolean isWriteLockStamp(long): Returns whether a stamp represents holding a lock exclusively (i.e. a write lock).
  • java.jar.JarEntry:
    String getRealName(): Returns the real name of this JarEntry. If this JarEntry is an entry of a multi-release jar file, which is configured to be processed as such, the name returned by this method is the pathname of the versioned entry that the JarEntry represents, rather than the path name of the base entry that ZipEntry.getName() returns. If the JarEntry does not represent a versioned entry of a multi-release jar file or the jar file is not configured for processing as a multi-release jar file, this method returns the same name that ZipEntry.getName() returns.
  • java.util.jar.JarFile:
    Stream<JarEntry> versionedStream(): Returns a Stream of the versioned jar file entries. Like the getRealName method of JarEntry, this is related to multi-release jar files.
  • java.util.spi.LocaleNameProvider:
    getDisplayUnicodeExtensionKey(String, Locale):
     Returns a localised name for the given Unicode extension key.
    getDisplayUnicodeExtensionType(String, String, Locale): Returns a localised name for the given Unicode extension key.
  • java.util.stream.Collectors:
    toUnmodifiableList():
    toUnmodifiableSet():
    toUnmodifiableMap(Function, Function):
    toUnmodifiableMap(Function, Function, BinaryOperator):
     These four new methods return Collectors that accumulate the input elements into the appropriate unmodifiable collection.
  • java.lang.model.SourceVersion: This now has a field, RELEASE_10 that represents the version for JDK 10.
  • java.lang.model.util.TypeKindVisitor6:
    javax.lang.model.util.TypeKindVisitor9:
    I have to confess I've never even heard of these classes
    R visitNoTypeAsModule(NoType, P): Visits a MODULE pseudo-type. I'm not sure why only these two classes got this method as there are also Visitor7 and Visitor8 variants.
  • javax.remote.management.rmi.RMIConnectorServer:
    This class has had two fields added: CREDENTIALS_FILTER_PATTERN and SERIAL_FILTER_PATTERN.
  • javax.ButtonModel: Look, Swing is still being updated!
    ButtonGroup getGroup(): Returns the group that the button belongs to. Normally used with radio buttons, which are mutually exclusive within their group.
  • javax.plaf.basic.BasicMenuUI:
    Dimension getMinimumSize(JComponent): Returns the specified component's minimum size appropriate for the look and feel.

No comments:

Post a Comment