HELLO--JAVA10 new features, check out

Source: Internet
Author: User
Tags deprecated time zones stack trace string format

March 20, 2018, Java 10 officially released!

Related address:

Official address: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html

Installation Guide: https://docs.oracle.com/javase/10/install/overview-jdk-10-and-jre-10-installation.htm

Java Status:

1) According to statistics, the current 90% of users in the use of JAVA8 and the following version (thankfully, JAVA8 has become the main force).

2) with the constant stimulation of the community, for faster iteration versions. The official version will be updated annually in 3 September (the update cycle will be stable for 6 months).

3) in the latest development language rankings, Java is still the top of the pack, stable first!

I. 12 key new features in JAVA10

? type inference for local variables

Java starts referencing the Var type (weak type) in JavaScript like scripting language, allowing you to define any type of variable through var.

For developers, this is the only feature that is closely related to you. It can help you greatly simplify the code.

Some students will ask, what is the difference between Var and object?

Let's raise a chestnut:

Object objlist = new arraylist<string> (); Objlist.add ("hello,world! ");//This code will appear compile exception var varlist = new arraylist<string> (); Varlist.add (" hello,world! ");//And this code is compiled by

When the above code is compiled by JAVA10, the 2nd line will have an exception (error: The symbol cannot be found), and of course the version below Java10 can also compile the exception.

But variables defined by Var can be compiled and passed, why? Because Var is a type reference object, it has the same properties as the type on the right side of the expression.

That is, the following two lines of code are equivalent:

var varlist = new arraylist<string> (); arraylist<string> varlist = new arraylist<string> ();

? application-class data Sharing (CDS)

CDS were introduced at JDK5 to improve JVM startup performance while reducing resource consumption when multiple virtual machines are running on the same physical or virtual machine.
JDK10 will extend CDS to the class loader that allows the internal system, the class loader for the internal platform, and the custom class loader to load the obtained classes. Previously, the use of CDS was limited to the Bootstrap class loader.

? additional Unicode language tag extensions

This will improve the Java.util.Locale class and related APIs to implement Unicode extensions for additional BCP47 language tags. In particular, labels for currency types, the first day of the week, area overrides, and time zones will now be supported.

? time-based version control

Our JDK version string format is almost as much as the JDK version. Fortunately, this is the last thing that needs to be used, and we can stick with it. This format is used much like the one presented in JDK9 to provide a more semantic form. One thing that bothers me is the inclusion of a interim element, as the JEP proposal says, "Forever is 0." Well, if it's always 0, what's the point? They said it was a reservation for future use, but I still don't agree. I think this is a bit redundant.
This also eliminates the rather strange situation that has been in the JDK9. The first update is JDK 9.0.1, which is very logical. The second update is JDK 9.0.4, illogical. The reason is that in the version count mode of JDK9, you need to leave a blank space for an emergency or not to use the expected update. But since no update is necessary, why not simply call it JDK 9.0.2?

? Root Certificate

A default set of CA root certificates will be provided in the JDK. Key security components, such as TLS, will be in effect by default in the OpenJDK build. This is a useful addition to Oracle's efforts to ensure that the OpenJDK binary and Oracle JDK binaries function as part of the same work.

? Parallel full garbage collector G1

G1 is designed to be a low-latency garbage collector (However, if it does not keep up with the rate of increase of the old heap fragments, it will still take the full compression set). Before JDK9, the default collector is parallel, throughput, collector. To reduce the difference in application performance profiles that use the default collector, G1 now has a parallel complete collection mechanism.

? Remove Native-header Auto-build tool

Java9 started some housekeeping on the JDK, which is a continuation of this feature. When compiling JNI code, a separate tool is no longer required to generate the header file, as this can be done through Javac. At some point in the future, JNI will be replaced by the results of the Panama project, but it's unclear when it happens.

? Garbage Collector Interface

This is not an interface for developers to control garbage collection, but an integrated interface that allows additional garbage collector in the JVM source code.

? Threading-local variable control

This is a fairly low level of change within the JVM and will now allow thread callbacks to be implemented without running the global virtual machine security point. This makes it possible and inexpensive to stop a single thread, rather than just enabling or stopping all threads.

? heap allocation on the standby storage appliance

Hardware technology continues to evolve, and it is now possible to use nonvolatile RAM with the same interface and similar performance characteristics as traditional DRAM. This JEP will enable the JVM to use a heap that is suitable for different types of storage mechanisms.

? Experimental Java-based JIT compiler

The recently announced Metropolis project proposes to rewrite most of the JVM with Java. At first thought, it was strange. If the JVM is written in Java, does it require a JVM to run the JVM? Correspondingly, this leads to a good image analogy. The reality is that using Java to write a JVM does not mean that it has to be compiled into bytecode, you can use AOT compilation, and then compile the code at run time to improve performance.

This JEP introduces the Graal compiler research project into the JDK. And to make the Metropolis project a reality, to provide the basis for JVM performance to rival (or be fortunate to surpass) the current version of C + +.

? Merge JDK Multiple code warehouses into a single repository

In JDK9, there are 8 warehouses: root, CORBA, hotspot, Jaxp, Jaxws, JDK, Langtools, and Nashorn. In JDK10 these will be merged into one, making it possible to run atomic commit (atomic commit) of the repository across the interdependent changeset.

Second, new API or function

73 additions have been added to the standard class library.

? Java.awt.Toolkit:
int Getmenushortcutkeymaskex (): determines which extension modifier key is the appropriate accelerator for menu shortcuts.

? Java.awt.geom.Path2D:
void TrimToSize (): calculates the capacity of this path2d instance to its current size. The app can use this action to minimize the storage space for the path. This method is also added to the path2d.double and Path2d.float classes.

? Java.io.ByteArrayOutputStream:
string ToString (Charset): overloads ToString () to convert the contents of the buffer to a string by decoding the bytes with the specified character set.

? Java.io.PrintStream:
Lang.io.PrintWriter:
These two classes have three new constructors that require additional Charset parameters.

? Java.io.Reader:
long transferTo: reads all characters from this reader and writes the characters to the given writer in the order in which they are read.

? Java.lang.Runtime.Version:
There are four new ways to return the integer value of the new (JEP 322) Version string field: Feature (), Interim (), Patch (), and update ().

? Java.lang.StackWalker.StackFrame:
String getdescriptor (): Returns the descriptor of the method represented by this stack frame according to the JVM standard.
String Getmethodtype (): Returns the method type represented by this stack frame, describing the parameter type and the return value type.

? Java.lang.invoke.MethodType:
class<?> Lastparametertype (): returns the last parameter type of this method type. If the method type has no parameters, an empty type is returned as the Sentry value (Sentinel values).

? Java.lang.management.RuntimeMXBean:
long Getpid (): Returns the process ID of the running JVM.

? Java.lang.management.ThreadMXBean:
threadinfo[] Dumpallthreads (Boolean, Boolean, int): Returns the thread information for all active threads, which has a stack trace that specifies the maximum number of elements and synchronization information.
threadinfo[] GetThreadInfo (long[], Boolean, Boolean, int): returns thread information for each thread whose identity is in the input array. It has a stack trace that specifies the maximum number of elements and synchronization information.

? Java.lang.reflect.MalformedParameterizedTypeException:

Added a new constructor, which takes the form of a string as a parameter for detailed information.

? Java.net.URLDecoder:
Java.net.URLEncoder:
These two classes have new overloaded decoding and encoding methods, with CharSet as additional parameters.

? Java.nio.channels.Channels:
Two new static overloaded methods that allow the use of Charset Newreader (Readbytechannel,charset) and Newwriter (Writebytechannel,charset).

? Java.nio.file.FileStore:
long Getblocksize (): Returns the number of bytes per block in this file store.

? Java.time.chrono.HijrahEra:

Java.time.chrono.MiinguoEra:

Java.time.chrono.ThaiBuddhistEra:
String GetDisplayName (TextStyle, Locale): This returns the name of the text used to identify era, which is appropriate for presenting to the user.

? Java.time.format.DateTimeFormatter:
Localizedby (Locale): Returns a copy of the specified formatter that contains localized values for the region, calendar, Region, Decimal, and/or time zone, which supersedes the values in the formatter.

? Java.util.DoubleSummaryStatistics:

Java.util.IntSummaryStatistics:

Java.util.LongSummaryStatistics:

These 3 classes add a new constructor that contains 4 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 3 interfaces adds a new static method, CopyOf (Collection). These functions return a non-modifiable list, a map, or a collection of elements that contain a given collection, in the order in which they are iterated.

? Java.util.Optional:
Java.util.OptionalDouble:
Java.util.OptionalInt:
Java.util.OptionalLong: These classes have added a new method Orelsethrow (). It is essentially the same as get (), that is, if Optional has a value, it is returned. Otherwise, Nosuchelementexception will be thrown.

? Java.util.Formatter:
Java.util.Scanner:
These two classes have three new constructors, all with a charset parameter, in addition to the other parameters.

? Java.util.Properties:

Added a new constructor that takes an int parameter. This creates a list of empty properties without a default value, and specifies the initial size to accommodate the specified number of elements without dynamically resizing. There is also a new overloaded replace method that accepts three Object arguments and returns a Boolean value. The entry for the specified key is replaced only if it is currently mapped to the specified value.

? Java. Splittablerandom:
void Nextbytes (byte[]): Populates a user-supplied byte array with the generated pseudo-random bytes.

? Java.util.concurrent.FutureTask:

Added the ToString () method, which returns a string that identifies Futuretask and its completion status. In parentheses, the state contains one of the following strings, "completed normally", "completed exceptionally", "Cancelled", or "not completed".

? Java.util.concurrent.locks.StampedLock:
Boolean Islockstamp (Long): Returns a token stamp indicating whether a lock is held.
Boolean Isoptimisticreadstamp (Long): Returns a token stamp that indicates whether an optimistic read was successful (optimistic read).
Boolean Isreadlockstamp (Long): Returns a token stamp indicating whether to hold a non-exclusive lock (that is, read lock).
Boolean Iswritelockstamp (Long): Returns a token stamp indicating whether an exclusive lock (that is, write lock) is held.

? Java.jar.JarEntry:
String getrealname (): returns the true name of this jarentry. If this jarentry is the entry for a multi-version jar file, it is configured to do so, and the name returned by this method is the entry for the version entry represented by Jarentry, not the path name of the base entry returned by Zipentry.getname (). If Jarentry does not represent a versioned entry for a multi-version jar file or if the jar file is not configured to be processed as a multi-version jar file, this method returns the same name as Zipentry.getname ().

? Java.util.jar.JarFile:
stream<jarentry> Versionedstream (): Returns the entry for the specified version of the jar file that corresponds to the Stream. Similar to the Getrealname method of Jarentry, this is related to the multi-version jar file.

? Java.util.spi.LocaleNameProvider:
Getdisplayunicodeextensionkey (String, Locale): Returns a localized name for the given Unicode extension key.
Getdisplayunicodeextensiontype (String, String, Locale): Returns a localized name for the given Unicode extension key.

? Java.util.stream.Collectors:
Tounmodifiablelist ():
Tounmodifiableset ():
Tounmodifiablemap (function, function):
tounmodifiablemap (function, function, binaryoperator):

All four new methods return collectors, aggregating input elements into the appropriate non-modifiable collection.

? Java.lang.model.SourceVersion:

Now you have a field that represents the version of JDK 10.

? JAVA.LANG.MODEL.UTIL.TYPEKINDVISITOR6:
JAVAX.LANG.MODEL.UTIL.TYPEKINDVISITOR9:
R visitnotypeasmodule (Notype, P): accesses a MODULE of Pseudo-type. It is unclear why Visitor7 and Visitor8 do not have this method.

? Javax.remote.management.rmi.RMIConnectorServer:
This class adds two fields: Credentials_filter_pattern and Serial_filter_pattern.

? Javax. Buttonmodel:
Buttongroup Getgroup (): returns the group to which the button belongs. Typically used for radio buttons, which are mutually exclusive in a group.

? Javax.plaf.basic.BasicMenuUI:
Dimension getminimumsize (jcomponent): Returns the minimum size of the specified component for the impression.

Third, other

? if the Kerberos profile krb5.conf contains a includedir option, all files ending with. conf in the Includedir directory will be loaded by default.

? the startup options for Java that have expired in previous versions-d32 and –D64 have been removed from the current version. If you still use these two options in the new version, the JVM will not start properly.

? JDK10 support for the JDK8 versions in the new version doclet,jdk6, JDK7, Doclet in JDK9 are no longer supported.

? JDK10 re-enabled the Newfactory () method that was inappropriately outdated in JDK9.

? JDK10 introduces a new Javadoc tag: {@summary ...}, which resolves an issue in which the previous version could not generate an API digest.

? the JDK10 removed the Biasedlockingstartupdelay 4-second start delay.

? the following obsolete classes in the Com.sun.security.auth package have been removed in the new version:

PolicyFile

Solarisnumericgroupprincipal

Solarisnumericuserprincipal

X500principal

Solarisloginmodule

Solarissystem

? the following properties and methods in the Java.lang.SecurityManager class (obsolete from JDK 1.2) were finally removed:

Incheck (attributes)

Getincheck

Classdepth

Classloaderdepth

Currentclassloader

Currentloadedclass

Inclass

Inclassloader

? the deprecated internationalization methods in the following Java.lang.Runtime classes are removed in the new version:

Getlocalizedinputstream

Getlocalizedoutputstream

? the following deprecated hotspot–x options have been removed in the new version:-xoss,-xsqnopause,-xoptimize,-xboundthreads and–xusealtsigs.

? Policytool is removed in the new version.

? the Javadoc tool supports multiple stylesheets in the new version with the –add-stylesheets command option.

? the new version of the JVM is able to configure the thread pool and GC mechanism based on the number of CPUs and memory allocated to the current Docker container by the system, instead of directly using the system's CPU and memory. And added three more powerful command options:-xx:initialrampercentage,-xx:maxrampercentage, and-xx:minrampercentage.

? The new version adds a new system property: Jdk.disablelastusagetracking. This new property, like its name, disables the last use trace of the JRE.

In summary, we can see that each version of the JDK upgrade will affect us more or less, we need to constantly learn new technologies, accept new thinking patterns.

Of course, some internal optimizations for the JDK are transparent to the developer. It's constantly getting stronger while optimizing performance, security, and stability.

JAVA10 has come, so Java11 still far? We September, we don't see!

HELLO--JAVA10 new features, check out

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.